Example #1
0
class BaseStorage(database.Storage):
    def __init__(self):
        database.Storage.__init__(self)
        self._mi = ManagementInterface(Config.xmlrpc_url)

    def _notify_watchers(self, response, user_id, event, type):
        def _eb_mi(f):
            log.error(
                "Error while notifying OpenSIPS management interface for user %s: %s"
                % (user_id, f.getErrorMessage()))
            return response

        d = self._mi.notify_watchers(
            '%s@%s' % (user_id.username, user_id.domain), event, type)
        d.addCallback(lambda x: response)
        d.addErrback(_eb_mi)
        return d

    def put_document(self, uri, document, check_etag):
        application_id = uri.application_id
        d = self.conn.runInteraction(
            super(BaseStorage, self)._put_document, uri, document, check_etag)
        if application_id in ('pres-rules',
                              'org.openmobilealliance.pres-rules',
                              'pidf-manipulation', 'org.openxcap.dialog-rules',
                              'resource-lists', 'rls-services'):
            type = 1 if application_id == 'pidf-manipulation' else 0
            event = 'dialog' if application_id == 'org.openxcap.dialog-rules' else 'presence'
            d.addCallback(self._notify_watchers, uri.user, event, type)
        return d
Example #2
0
class BaseStorage(database.Storage):

    def __init__(self):
        database.Storage.__init__(self)
        self._mi = ManagementInterface(Config.xmlrpc_url)

    def _notify_watchers(self, response, user_id, event, type):
        def _eb_mi(f):
            log.error("Error while notifying OpenSIPS management interface for user %s: %s" % (user_id, f.getErrorMessage()))
            return response
        d = self._mi.notify_watchers('%s@%s' % (user_id.username, user_id.domain), event, type)
        d.addCallback(lambda x: response)
        d.addErrback(_eb_mi)
        return d

    def put_document(self, uri, document, check_etag):
        application_id = uri.application_id
        d = self.conn.runInteraction(super(BaseStorage, self)._put_document, uri, document, check_etag)
        if application_id in ('pres-rules', 'org.openmobilealliance.pres-rules', 'pidf-manipulation', 'org.openxcap.dialog-rules', 'resource-lists', 'rls-services'):
            type = 1 if application_id == 'pidf-manipulation' else 0
            event = 'dialog' if application_id == 'org.openxcap.dialog-rules' else 'presence'
            d.addCallback(self._notify_watchers, uri.user, event, type)
        return d
Example #3
0
 def __init__(self):
     database.Storage.__init__(self)
     self._mi = ManagementInterface(Config.xmlrpc_url)
Example #4
0
 def __init__(self):
     database.Storage.__init__(self)
     self._mi = ManagementInterface(Config.xmlrpc_url)