Esempio n. 1
0
 def _onIncoming( self, sslConn, peerKey, incomingName, peerKeyID,
         serviceName ) :
     assert self.sm.current() == self.ONLINE
     if not isValidUserName(incomingName) :
         sslAbort( sslConn )
         return
     if not isValidServiceName(serviceName) :
         sslAbort( sslConn )
         return
     contact = self.profile.getContactByPublicKey( peerKey )
     if contact is None :
         contactName = peerKeyID
     else :
         contactName = contact.name
     if serviceName not in self.services :
         action = ACCESS_DENY
     else :
         action = self.permissions.execute( contactName,
                 serviceName )
     def onActionDone( result ) :
         self.sm.removeCallback( callbackId )
     if action == ACCESS_DENY :
         actionOp = self._rejectIncoming( sslConn, onActionDone )
     else:
     # elif action == ACCESS_ALLOW  :
         actionOp = self._acceptIncoming( sslConn, serviceName,
                 peerKey, contactName, peerKeyID, incomingName, onActionDone )
     # else :
     #     assert action == ACCESS_PROMPT
     #     actionOp = self._promptIncoming( sslConn, serviceName,
     #             peerKey, contactName, incomingName, onActionDone )
     callbackId = self.sm.insertCallback( actionOp.cancel,
             src=self.ONLINE, single=True )
Esempio n. 2
0
 def _listServices( self, settings ) :
     services = []
     for entry in settings.listEntries('Services') :
         serviceName = entry.split('/')[-1]
         assert isValidServiceName(serviceName)
         serviceCommand = _readCommand( settings, entry )
         services.append( (serviceName,serviceCommand) )
     return services
Esempio n. 3
0
 def _listActions( self, settings ) :
     actions = []
     for entry in settings.listEntries('ContactActions') :
         actionDir = entry.split('/')[-1]
         assert isValidServiceName(actionDir)
         actionName = settings.getData( entry+'/Action' ).strip()
         actionCommand = _readCommand( settings, entry+'/Command' )
         actionOrder = settings.getInt(entry+'/SortOrder',10000)
         actions.append( (actionDir,actionName,actionCommand,actionOrder) )
     return actions
Esempio n. 4
0
    def _onIncoming(self, sslConn, peerKey, incomingName, serviceName):
        assert self.sm.current() == self.ONLINE
        if not isValidUserName(incomingName):
            sslAbort(sslConn)
            return
        if not isValidServiceName(serviceName):
            sslAbort(sslConn)
            return
        contact = self.profile.getContactByPublicKey(peerKey)
        if contact is None:
            contactName = ''
        else:
            contactName = contact.name

        if serviceName not in self.services:
            action = ACCESS_DENY
        else:
            action = self.permissions.execute(contactName, serviceName)

        def onActionDone(result):
            self.sm.removeCallback(callbackId)

        if action == ACCESS_DENY:
            actionOp = self._rejectIncoming(sslConn, onActionDone)
        elif action == ACCESS_ALLOW:
            actionOp = self._acceptIncoming(sslConn, serviceName, peerKey,
                                            contactName, incomingName,
                                            onActionDone)
        else:
            assert action == ACCESS_PROMPT
            actionOp = self._promptIncoming(sslConn, serviceName, peerKey,
                                            contactName, incomingName,
                                            onActionDone)
        callbackId = self.sm.insertCallback(actionOp.cancel,
                                            src=self.ONLINE,
                                            single=True)
Esempio n. 5
0
 def registerService(self, serviceName, serviceCallback):
     assert isValidServiceName(serviceName)
     if serviceName in self.services:
         return False
     self.services[serviceName] = serviceCallback
     return True
Esempio n. 6
0
 def registerService( self, serviceName, serviceCallback ) :
     assert isValidServiceName(serviceName)
     if serviceName in self.services :
         return False
     self.services[serviceName] = serviceCallback
     return True