Nullclient.py: changing mainloop
[python-purple] / nullclient.py
1 import purple
2 import ecore
3
4 class NullClient:
5     def __init__(self):
6         self.p = purple.Purple()
7         self.account = None
8
9     def execute(self):
10         self.p.purple_init()
11
12     def set_protocol(self, protocol):
13         for i in self.p.get_protocols():
14             if i[1] == protocol:
15                 print "-- NULLCLIENT --: Choosing %s as protocol" % protocol
16                 self.protocol = i[0]
17                 print "-- NULLCLIENT --: Protocol successfully chosen: %s" % i[0]
18                 return
19
20     def new_account(self, username, protocol, password):
21         self.account = purple.Account(username, protocol)
22         self.account.set_password(password)
23         self.account.set_enabled("carman-purple-python", True)
24
25 if __name__ == '__main__':
26
27     client = NullClient()
28     client.execute()
29     client.set_protocol("XMPP")
30     client.new_account("seu_email@email.com", client.protocol,"sua_senha_aqui")
31
32     client.p.connect()
33     ecore.main_loop_begin()