def __init__(self, xmlnode=None, from_jid=None, to_jid=None, stanza_type=None, stanza_id=None, error=None, error_cond=None, stream=None): """Initialize an `Iq` object. :Parameters: - `xmlnode`: XML node to_jid be wrapped into the `Iq` object or other Iq object to be copied. If not given then new presence stanza is created using following parameters. - `from_jid`: sender JID. - `to_jid`: recipient JID. - `stanza_type`: staza type: one of: "get", "set", "result" or "error". - `stanza_id`: stanza id -- value of stanza's "id" attribute. If not given, then unique for the session value is generated. - `error_cond`: error condition name. Ignored if `stanza_type` is not "error". :Types: - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Iq` - `from_jid`: `JID` - `to_jid`: `JID` - `stanza_type`: `unicode` - `stanza_id`: `unicode` - `error_cond`: `unicode`""" self.xmlnode = None if isinstance(xmlnode, Iq): pass elif isinstance(xmlnode, Stanza): raise TypeError, "Couldn't make Iq from other Stanza" elif isinstance(xmlnode, libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError, "Couldn't make Iq from %r" % (type(xmlnode), ) elif not stanza_type: raise ValueError, "type is required for Iq" else: if not stanza_id and stanza_type in ("get", "set"): stanza_id = gen_id() if not xmlnode and stanza_type not in ("get", "set", "result", "error"): raise ValueError, "Invalid Iq type: %r" % (stanza_type, ) if xmlnode is None: xmlnode = "iq" Stanza.__init__(self, xmlnode, from_jid=from_jid, to_jid=to_jid, stanza_type=stanza_type, stanza_id=stanza_id, error=error, error_cond=error_cond, stream=stream)
def __init__(self, xmlnode = None, from_jid = None, to_jid = None, stanza_type = None, stanza_id = None, show = None, status = None, priority = 0, error = None, error_cond = None, stream = None): """Initialize a `Presence` object. :Parameters: - `xmlnode`: XML node to_jid be wrapped into the `Presence` object or other Presence object to be copied. If not given then new presence stanza is created using following parameters. - `from_jid`: sender JID. - `to_jid`: recipient JID. - `stanza_type`: staza type: one of: None, "available", "unavailable", "subscribe", "subscribed", "unsubscribe", "unsubscribed" or "error". "available" is automaticaly changed to_jid None. - `stanza_id`: stanza id -- value of stanza's "id" attribute - `show`: "show" field of presence stanza. One of: None, "away", "xa", "dnd", "chat". - `status`: descriptive text for the presence stanza. - `priority`: presence priority. - `error_cond`: error condition name. Ignored if `stanza_type` is not "error" :Types: - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Stanza` - `from_jid`: `JID` - `to_jid`: `JID` - `stanza_type`: `unicode` - `stanza_id`: `unicode` - `show`: `unicode` - `status`: `unicode` - `priority`: `unicode` - `error_cond`: `unicode`""" self.xmlnode=None if isinstance(xmlnode,Presence): pass elif isinstance(xmlnode,Stanza): raise TypeError,"Couldn't make Presence from other Stanza" elif isinstance(xmlnode,libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError,"Couldn't make Presence from %r" % (type(xmlnode),) if stanza_type and stanza_type not in presence_types: raise ValueError, "Invalid presence type: %r" % (type,) if stanza_type=="available": stanza_type=None if xmlnode is None: xmlnode="presence" Stanza.__init__(self, xmlnode, from_jid = from_jid, to_jid = to_jid, stanza_type = stanza_type, stanza_id = stanza_id, error = error, error_cond = error_cond, stream = stream) if show: self.xmlnode.newTextChild(common_ns,"show",to_utf8(show)) if status: self.xmlnode.newTextChild(common_ns,"status",to_utf8(status)) if priority and priority!=0: self.xmlnode.newTextChild(common_ns,"priority",to_utf8(unicode(priority)))
def __init__(self, xmlnode = None, from_jid = None, to_jid = None, stanza_type = None, stanza_id = None, subject = None, body = None, thread = None, error = None, error_cond = None, stream = None): """Initialize a `Message` object. :Parameters: - `xmlnode`: XML node to_jid be wrapped into the `Message` object or other Message object to be copied. If not given then new presence stanza is created using following parameters. - `from_jid`: sender JID. - `to_jid`: recipient JID. - `stanza_type`: staza type: one of: "get", "set", "result" or "error". - `stanza_id`: stanza id -- value of stanza's "id" attribute. If not given, then unique for the session value is generated. - `subject`: message subject, - `body`: message body. - `thread`: message thread id. - `error_cond`: error condition name. Ignored if `stanza_type` is not "error". :Types: - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Stanza` - `from_jid`: `JID` - `to_jid`: `JID` - `stanza_type`: `unicode` - `stanza_id`: `unicode` - `subject`: `unicode` - `body`: `unicode` - `thread`: `unicode` - `error_cond`: `unicode`""" self.xmlnode=None if isinstance(xmlnode,Message): pass elif isinstance(xmlnode,Stanza): raise TypeError, "Couldn't make Message from other Stanza" elif isinstance(xmlnode,libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError, "Couldn't make Message from %r" % (type(xmlnode),) if xmlnode is None: xmlnode="message" Stanza.__init__(self, xmlnode, from_jid = from_jid, to_jid = to_jid, stanza_type = stanza_type, stanza_id = stanza_id, error = error, error_cond = error_cond, stream = stream) if subject is not None: self.xmlnode.newTextChild(common_ns,"subject",to_utf8(subject)) if body is not None: self.xmlnode.newTextChild(common_ns,"body",to_utf8(body)) if thread is not None: self.xmlnode.newTextChild(common_ns,"thread",to_utf8(thread))
def __init__(self, xmlnode = None, from_jid = None, to_jid = None, stanza_type = None, stanza_id = None, error = None, error_cond=None, stream = None): """Initialize an `Iq` object. :Parameters: - `xmlnode`: XML node to_jid be wrapped into the `Iq` object or other Iq object to be copied. If not given then new presence stanza is created using following parameters. - `from_jid`: sender JID. - `to_jid`: recipient JID. - `stanza_type`: staza type: one of: "get", "set", "result" or "error". - `stanza_id`: stanza id -- value of stanza's "id" attribute. If not given, then unique for the session value is generated. - `error_cond`: error condition name. Ignored if `stanza_type` is not "error". :Types: - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Iq` - `from_jid`: `JID` - `to_jid`: `JID` - `stanza_type`: `unicode` - `stanza_id`: `unicode` - `error_cond`: `unicode`""" self.xmlnode=None if isinstance(xmlnode,Iq): pass elif isinstance(xmlnode,Stanza): raise TypeError,"Couldn't make Iq from other Stanza" elif isinstance(xmlnode,libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError,"Couldn't make Iq from %r" % (type(xmlnode),) elif not stanza_type: raise ValueError, "type is required for Iq" else: if not stanza_id and stanza_type in ("get", "set"): stanza_id=gen_id() if not xmlnode and stanza_type not in ("get","set","result","error"): raise ValueError, "Invalid Iq type: %r" % (stanza_type,) if xmlnode is None: xmlnode="iq" Stanza.__init__(self, xmlnode, from_jid = from_jid, to_jid = to_jid, stanza_type = stanza_type, stanza_id = stanza_id, error = error, error_cond = error_cond, stream = stream)
def __init__(self, xmlnode = None, from_jid = None, to_jid = None,\ stanza_type = None, stanza_id = None, error = None,\ error_cond = None, stream = None): """Initialize a `PubSubMessage` object.......... - `error_cond`: `unicode`""" self.xmlnode=None if isinstance(xmlnode,PubSubMessage): pass elif isinstance(xmlnode,Stanza): raise TypeError, "Couldn't make PubSubMessage from other Stanza" elif isinstance(xmlnode,libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError, "Couldn't make PubSubMessage from %r" % (type(xmlnode),) if xmlnode is None: xmlnode="message" Stanza.__init__(self, xmlnode, from_jid = from_jid, to_jid = to_jid,\ stanza_type = stanza_type, stanza_id = stanza_id, \ error = error, error_cond = error_cond, stream = stream)
def __init__(self, xmlnode=None, from_jid=None, to_jid=None, stanza_type=None, stanza_id=None, show=None, status=None, priority=0, error=None, error_cond=None, stream=None): """Initialize a `Presence` object. :Parameters: - `xmlnode`: XML node to_jid be wrapped into the `Presence` object or other Presence object to be copied. If not given then new presence stanza is created using following parameters. - `from_jid`: sender JID. - `to_jid`: recipient JID. - `stanza_type`: staza type: one of: None, "available", "unavailable", "subscribe", "subscribed", "unsubscribe", "unsubscribed" or "error". "available" is automaticaly changed to_jid None. - `stanza_id`: stanza id -- value of stanza's "id" attribute - `show`: "show" field of presence stanza. One of: None, "away", "xa", "dnd", "chat". - `status`: descriptive text for the presence stanza. - `priority`: presence priority. - `error_cond`: error condition name. Ignored if `stanza_type` is not "error" :Types: - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Stanza` - `from_jid`: `JID` - `to_jid`: `JID` - `stanza_type`: `unicode` - `stanza_id`: `unicode` - `show`: `unicode` - `status`: `unicode` - `priority`: `unicode` - `error_cond`: `unicode`""" self.xmlnode = None if isinstance(xmlnode, Presence): pass elif isinstance(xmlnode, Stanza): raise TypeError, "Couldn't make Presence from other Stanza" elif isinstance(xmlnode, libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError, "Couldn't make Presence from %r" % ( type(xmlnode), ) if stanza_type and stanza_type not in presence_types: raise ValueError, "Invalid presence type: %r" % (type, ) if stanza_type == "available": stanza_type = None if xmlnode is None: xmlnode = "presence" Stanza.__init__(self, xmlnode, from_jid=from_jid, to_jid=to_jid, stanza_type=stanza_type, stanza_id=stanza_id, error=error, error_cond=error_cond, stream=stream) if show: self.xmlnode.newTextChild(common_ns, "show", to_utf8(show)) if status: self.xmlnode.newTextChild(common_ns, "status", to_utf8(status)) if priority and priority != 0: self.xmlnode.newTextChild(common_ns, "priority", to_utf8(unicode(priority)))
def __init__(self, xmlnode=None, from_jid=None, to_jid=None, stanza_type=None, stanza_id=None, subject=None, body=None, thread=None, error=None, error_cond=None, stream=None): """Initialize a `Message` object. :Parameters: - `xmlnode`: XML node to_jid be wrapped into the `Message` object or other Message object to be copied. If not given then new presence stanza is created using following parameters. - `from_jid`: sender JID. - `to_jid`: recipient JID. - `stanza_type`: staza type: one of: "get", "set", "result" or "error". - `stanza_id`: stanza id -- value of stanza's "id" attribute. If not given, then unique for the session value is generated. - `subject`: message subject, - `body`: message body. - `thread`: message thread id. - `error_cond`: error condition name. Ignored if `stanza_type` is not "error". :Types: - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Stanza` - `from_jid`: `JID` - `to_jid`: `JID` - `stanza_type`: `unicode` - `stanza_id`: `unicode` - `subject`: `unicode` - `body`: `unicode` - `thread`: `unicode` - `error_cond`: `unicode`""" self.xmlnode = None if isinstance(xmlnode, Message): pass elif isinstance(xmlnode, Stanza): raise TypeError, "Couldn't make Message from other Stanza" elif isinstance(xmlnode, libxml2.xmlNode): pass elif xmlnode is not None: raise TypeError, "Couldn't make Message from %r" % ( type(xmlnode), ) if xmlnode is None: xmlnode = "message" Stanza.__init__(self, xmlnode, from_jid=from_jid, to_jid=to_jid, stanza_type=stanza_type, stanza_id=stanza_id, error=error, error_cond=error_cond, stream=stream) if subject is not None: self.xmlnode.newTextChild(common_ns, "subject", to_utf8(subject)) if body is not None: self.xmlnode.newTextChild(common_ns, "body", to_utf8(body)) if thread is not None: self.xmlnode.newTextChild(common_ns, "thread", to_utf8(thread))