print "---- blist callback example: %s" % name
blist_cbs["new_list"] = blist_callback
-blist_cbs["new_node"] = blist_callback
blist_cbs["show"] = blist_callback
-blist_cbs["update"] = blist_callback
-blist_cbs["remove"] = blist_callback
blist_cbs["destroy"] = blist_callback
blist_cbs["set_visible"] = blist_callback
blist_cbs["request_add_buddy"] = blist_callback
blist_cbs["request_add_chat"] = blist_callback
blist_cbs["request_add_group"] = blist_callback
+def new_node_cb(type, name=None, totalsize=None, currentsize=None, online=None):
+ if type == 0:
+ print "---- blist callback: new node (group): %s (%s/%s) (%s online)" % \
+ (name, totalsize, currentsize, online)
+ elif type == 1:
+ print "---- blist callback: new node (contact): %s (%s/%s) (%s online)" % \
+ (name, totalsize, currentsize, online)
+ elif type == 2: # totalsize = alias
+ print "---- blist callback: new node (buddy): %s (%s)" % (name, totalsize)
+ elif type == 3:
+ print "---- blist callback: new node (chat): %s" % alias
+ elif type == 4:
+ print "---- blist callback: new node (other type)"
+ else:
+ print "---- blist callback: new node (unknown type %s)" % type
+
+def update_cb(type, name=None, totalsize=None, currentsize=None, online=None):
+ if type == 0:
+ print "---- blist callback: update (group): %s (%s/%s) (%s online)" % \
+ (name, totalsize, currentsize, online)
+ elif type == 1:
+ print "---- blist callback: update (contact): %s (%s/%s) (%s online)" % \
+ (name, totalsize, currentsize, online)
+ elif type == 2: # totalsize = alias
+ print "---- blist callback: update (buddy): %s (%s)" % \
+ (name, totalsize)
+ elif type == 3:
+ print "---- blist callback: update (chat): %s" % alias
+ elif type == 4:
+ print "---- blist callback: update (other type)"
+ else:
+ print "---- blist callback: update (unknown type %s)" % type
+
+def remove_cb(type, name=None, totalsize=None, currentsize=None, online=None):
+ if type == 0:
+ print "---- blist callback: remove (group): %s (%s/%s) (%s online)" % \
+ (name, totalsize, currentsize, online)
+ elif type == 1:
+ print "---- blist callback: remove (contact): %s (%s/%s) (%s online)" % \
+ (name, totalsize, currentsize, online)
+ elif type == 2: # totalsize = alias
+ print "---- blist callback: remove (buddy): %s (%s)" % \
+ (name, totalsize)
+ elif type == 3:
+ print "---- blist callback: remove (chat): %s" % alias
+ elif type == 4:
+ print "---- blist callback: remove (other type)"
+ else:
+ print "---- blist callback: remove (unknown type %s)" % type
+
+blist_cbs["new_node"] = new_node_cb
+blist_cbs["update"] = update_cb
+blist_cbs["remove"] = remove_cb
+
cbs["blist"] = blist_cbs
def conn_callback(name):
def __init__(self):
self.p = purple.Purple(debug_enabled=False)
self.account = None
+ self.protocol_id = "prpl-jabber"
def execute(self):
global cbs
self.p.purple_init(cbs)
- def set_protocol(self, protocol):
- for p in self.p.get_protocols():
- if p.get_name() == protocol:
- print "-- NULLCLIENT --: Choosing %s as protocol" % protocol
- self.protocol = p
- print "-- NULLCLIENT --: Protocol successfully chosen: %s" % p.get_id()
- return
-
- def new_account(self, username, protocol, password):
- self.account = purple.Account(username, protocol.get_id())
+ def new_account(self, username, password):
+ self.account = purple.Account(username, self.protocol_id)
self.account.set_password(password)
- proxy = self.account.get_proxyinfo()
- if proxy is None:
- print "None"
- proxy = purple.ProxyInfo()
- proxy.cnew()
-
- proxy.set_type(purple.ProxyInfoType().HTTP())
- proxy.set_host("172.18.216.211")
- proxy.set_port(8080)
-
- self.account.set_proxyinfo(proxy)
+ self.account.proxy.set_type(purple.ProxyInfoType().HTTP)
+ self.account.proxy.set_host("172.18.216.211")
+ self.account.proxy.set_port(8080)
self.account.get_protocol_options()
client = NullClient()
client.execute()
- client.set_protocol("XMPP")
username = getuser()
password = getpassword()
- client.new_account(username, client.protocol, password)
+ client.new_account(username, password)
client.p.connect()
client.p.attach_signals(signal_cbs)