initializing Repository, adding gui mockup
[dpim.git] / jclient.py
blobfd042b6f0ff93bbfc4697404620e866580e01db9
1 import sys,xmpp
4 class jclient():
5 def __init__(self,userjid,password):
6 self.userjid = userjid
7 self.password = password
8 def connect(self):
9 print "connecting"
11 jid=xmpp.protocol.JID(self.userjid)
12 self.cl=xmpp.Client(jid.getDomain(),debug=[])
13 con=self.cl.connect()
15 if not con:
16 print 'could not connect!'
17 sys.exit()
18 print 'connected with',con
21 auth=self.cl.auth(jid.getNode(),self.password,resource=jid.getResource())
22 if not auth:
23 print 'could not authenticate!'
24 sys.exit()
25 print 'authenticated using',auth
27 #cl.SendInitPresence(requestRoster=0) # you may need to uncomment this for old server
29 def sendMessage(self,to_jid,text):
30 id=self.cl.send(xmpp.protocol.Message(to_jid,text))
31 print 'sent message with id',id
33 def disconnect(self):
34 self.cl.disconnect()