Example #1
0
 def myConnection(self,topicid):
     cr = ''
     uid = ''
     self.topicid = topicid
     
     '''
     1. Partner Check
     2. User Availablity for support
     3. if 1 and 2 proceed else stop
     '''
     self.partnerdata=rpc.RPCProxy('crm_livechat.livechat.partner').get_live_parnter()
     self.partid = self.partnerdata['jid']
     self.livechatdata = rpc.RPCProxy('crm_livechat.livechat').get_configuration(topicid)
    
     if self.livechatdata and self.partnerdata:
         self.logininfo['jid'] = jid = self.partnerdata['jid']
         self.logininfo['jserver'] = jserver = self.partnerdata['server']
         self.logininfo['pwd']= pwd = self.partnerdata['pwd']
         self.login = jid
         
         jid=xmpp.protocol.JID(jid)
         cl=xmpp.Client(jid.getDomain(),debug=[])
         try:
             x = cl.connect((jserver,5223))
         except AttributeError:
              logger.notifyChannel("Exception Error .........")
         if x == "":
             return "ConError"
         else:
             try:
                 auth = cl.auth(jid.getNode(),pwd,"test")
             except AttributeError, err:
                 raise common.error(_("Connection refused !"), _("%s \n Verify USERNAME and PASSWORD in Jabber Config" % err))
Example #2
0
 def justsend(self,**kw):
     if not self.client == 'chatended':
         sendto = ''
         msg = kw.get('messg')
         if(self.user):
             sendto = self.user
         self.recepients = sendto
         msg_obj = xmpp.protocol.Message(sendto,msg);
         try:
             self.client.send(msg_obj)
         except:
             jid = self.logininfo['jid']
             jserver = self.logininfo['jserver']
             pwd = self.logininfo['pwd']
             jid=xmpp.protocol.JID(jid)
             cl=xmpp.Client(jid.getDomain(),debug=[])
             x = cl.connect((jserver,5223))
             if x == "":
                 return "ConError"
             else:
                 try:
                     auth = cl.auth(jid.getNode(),pwd,"test")
                 except AttributeError, err:
                     raise common.error(_("Connection refused !"), _("%s \n Verify USERNAME and PASSWORD in Jabber Config" % err))
             
             self.client = cl
             self.client.send(msg_obj)
         msgformat = {"sender":str(self.login) , "message" : str(msg),"type":'sender'}
         self.msglist.append(msgformat)
         self.newlist.append(msgformat)
         return dict()