Exemple #1
0
    def __on_auth_succeeded(self, xmlstream):
        # Nothing happens until we actually send a presence
        presence = domish.Element(('jabber:client', 'presence'))
        presence.addElement('status').addContent('Online')

        xmlstream.send(presence)

        # add a callback for the messages
        xmlstream.addObserver('/message', self.__on_message)
        
        self._xmlstream = xmlstream

        self._reset()
        
        notifications = NotificationSet(self)        
        self.global_resource._update_property(("online-desktop:/p/o/global", "online"),
                                              UPDATE_REPLACE, CARDINALITY_1, True,
                                              notifications)

        self.global_resource._update_property(("online-desktop:/p/o/global", "webBaseUrl"),
                                              UPDATE_REPLACE, CARDINALITY_1,  self.web_base_url,
                                              notifications)

        self_resource_id = self.web_base_url + "/o/user/" + self.username
        self_resource = self._ensure_resource(self_resource_id,
                                              "http://mugshot.org/p/o/user")
        
        self.global_resource._update_property(("online-desktop:/p/o/global", "self"),
                                              UPDATE_REPLACE, CARDINALITY_01, self_resource,
                                              notifications)

        notifications.send()
        
        self._on_ready()
Exemple #2
0
 def __on_message(self, message):
     child = message.firstChildElement()
     if child.uri == "http://mugshot.org/p/system" and child.name == "notify":
         notifications = NotificationSet(self)
         for resource_element in child.elements():
             self._update_resource_from_element(resource_element, notifications=notifications)
         notifications.send()
Exemple #3
0
    def __go_offline(self):
        # Common handling if an error occurs in the initialization path or we lose the
        # connection to the server; we change the state to be offline and if we were
        # still in the "not yet ready" state, signal the end of initialization
        #
        if self.global_resource == None:
            self._reset()
        notifications = NotificationSet(self)
        self.global_resource._update_property(("online-desktop:/p/o/global", "online"),
                                              UPDATE_REPLACE, CARDINALITY_1, False,
                                              notifications)
        notifications.send()

        if not self.ready:
            self._on_ready()