Ejemplo n.º 1
0
    def update_presence(self, presence, buddy=None):
        groups = jabber_util.xpath_eval(presence.xmlnode, 'd:group',
                                        {'d': "digsby:setgroup"})
        if groups:
            try:
                self.widget_to_group(groups[0].getContent())
            except Exception:
                pass

        ips = jabber_util.xpath_eval(presence.xmlnode, 'i:ip', {'i': ip.IP_NS})
        if ips:
            try:
                self.ip = ip.Ip(ips[0]).ip
            except Exception:
                pass

        pagetimes = jabber_util.xpath_eval(presence.xmlnode, 'p:pagetime',
                                           {'p': pagetime.PAGETIME_NS})
        if pagetimes:
            try:
                self.online_time = pagetime.PageTime(
                    pagetimes[0]).pagetime / 1000
            except Exception:
                pass

        jbuddy.update_presence(self, presence, buddy=buddy)
Ejemplo n.º 2
0
 def __from_xml(self, node):
     if node.type!="element":
         raise ValueError,"XML node is not an Accounts element (not en element)"
     ns=get_node_ns_uri(node)
     if ns and ns!=DIGSBY_ACCOUNTS_NS or node.name!="query":
         raise ValueError,"XML node is not an Accounts element"
     accts = xpath_eval(node, 'a:account',{'a':DIGSBY_ACCOUNTS_NS})
     orders = xpath_eval(node, 'a:order',{'a':DIGSBY_ACCOUNTS_NS})
     self.order = [ord(c) for c in
              base64.decodestring(orders[0].getContent())] if orders else []
     self.extend(Account(acct) for acct in accts)
Ejemplo n.º 3
0
    def from_xml(self, xmlnode):
        if xmlnode.type!="element":
            raise ValueError,"XML node is not a photo (not en element)"
        ns=get_node_ns_uri(xmlnode)
        if ns and ns!=self.xml_element_namespace or xmlnode.name!=self.xml_element_name:
            raise ValueError,"XML node is not a %s descriptor" % self.xml_element_name

        self.offline   = bool(xpath_eval(xmlnode, 'x:offline',  {'x':X_EVENT_NS}))
        self.delivered = bool(xpath_eval(xmlnode, 'x:delivered',{'x':X_EVENT_NS}))
        self.displayed = bool(xpath_eval(xmlnode, 'x:displayed',{'x':X_EVENT_NS}))
        self.composing = bool(xpath_eval(xmlnode, 'x:composing',{'x':X_EVENT_NS}))

        ids = xpath_eval(xmlnode, 'x:id',{'x':X_EVENT_NS})

        self.id = ids[0].getContent() if ids else None
Ejemplo n.º 4
0
 def __from_xml(self, node):
     if node.type!="element":
         raise ValueError,"XML node is not an Widgets element (not en element)"
     ns=get_node_ns_uri(node)
     if ns and ns!=DIGSBY_WIDGETS_NS or node.name!="query":
         raise ValueError,"XML node is not an Widgets element"
     widgets = xpath_eval(node, 'w:widget',{'w':DIGSBY_WIDGETS_NS})
     self.extend(Widget(widget) for widget in widgets)
Ejemplo n.º 5
0
 def __from_xml(self, node):
     if node.type != "element":
         raise ValueError, "XML node is not an Widgets element (not en element)"
     ns = get_node_ns_uri(node)
     if ns and ns != DIGSBY_WIDGETS_NS or node.name != "query":
         raise ValueError, "XML node is not an Widgets element"
     widgets = xpath_eval(node, 'w:widget', {'w': DIGSBY_WIDGETS_NS})
     self.extend(Widget(widget) for widget in widgets)
Ejemplo n.º 6
0
    def from_xml(self, xmlnode):
        if xmlnode.type != "element":
            raise ValueError, "XML node is not a photo (not en element)"
        ns = get_node_ns_uri(xmlnode)
        if ns and ns != self.xml_element_namespace or xmlnode.name != self.xml_element_name:
            raise ValueError, "XML node is not a %s descriptor" % self.xml_element_name

        self.offline = bool(xpath_eval(xmlnode, 'x:offline',
                                       {'x': X_EVENT_NS}))
        self.delivered = bool(
            xpath_eval(xmlnode, 'x:delivered', {'x': X_EVENT_NS}))
        self.displayed = bool(
            xpath_eval(xmlnode, 'x:displayed', {'x': X_EVENT_NS}))
        self.composing = bool(
            xpath_eval(xmlnode, 'x:composing', {'x': X_EVENT_NS}))

        ids = xpath_eval(xmlnode, 'x:id', {'x': X_EVENT_NS})

        self.id = ids[0].getContent() if ids else None
Ejemplo n.º 7
0
    def update_presence(self, presence, buddy=None):
        groups = jabber_util.xpath_eval(presence.xmlnode, 'd:group',{'d':"digsby:setgroup"})
        if groups:
            try:
                self.widget_to_group(groups[0].getContent())
            except Exception: pass

        ips = jabber_util.xpath_eval(presence.xmlnode, 'i:ip',{'i':ip.IP_NS})
        if ips:
            try:
                self.ip = ip.Ip(ips[0]).ip
            except Exception: pass

        pagetimes = jabber_util.xpath_eval(presence.xmlnode, 'p:pagetime',{'p':pagetime.PAGETIME_NS})
        if pagetimes:
            try:
                self.online_time = pagetime.PageTime(pagetimes[0]).pagetime/1000
            except Exception: pass

        jbuddy.update_presence(self, presence, buddy=buddy)