]> code.delx.au - pymsnt/commitdiff
Fixed tel:+ jid being invalid. Added cache to (hopefully) speed things up.
authorjamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>
Sun, 16 Apr 2006 10:20:33 +0000 (10:20 +0000)
committerjamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>
Sun, 16 Apr 2006 10:20:33 +0000 (10:20 +0000)
git-svn-id: http://delx.cjb.net/svn/pymsnt/trunk@135 55fbd22a-6204-0410-b2f0-b6c764c7e90a

committer: jamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>

src/jabw.py
src/lang.py
src/legacy/glue.py
src/tlib/msn/msnw.py

index 71058369d1af6894f39ce9ba19db1b87a6876064..755b49a716540a11506f8176429c7b719c1c9774 100644 (file)
@@ -82,9 +82,9 @@ def sendErrorMessage(pytrans, to, fro, etype, condition, explanation, body=None)
        error.attributes["type"] = etype
        error.attributes["code"] = str(utils.errorCodeMap[condition])
        desc = error.addElement(condition)
-       desc.attributes["xmlns"] = XMPP_STANZAS
+       desc.attributes["xmlns"] = disco.XMPP_STANZAS
        text = error.addElement("text")
-       text.attributes["xmlns"] = XMPP_STANZAS
+       text.attributes["xmlns"] = disco.XMPP_STANZAS
        text.addContent(explanation)
        if(body and len(body) > 0):
                b = el.addElement("body")
index 477188a65fdc37f45d9b64c31fb3d1b2a0561e19..9ad46d1672363f173cae7ac8b4afce1f5c07b528 100644 (file)
@@ -159,7 +159,7 @@ class strings:
        
        class de: # German - Florian Holzhauer <xmpp:fh@jabber.ccc.de>
                registerText = u"Bitte trage Deine MSN-Passport-ID (user@hotmail.com) als User ein, sowie Dein Passwort und Deinen Nickname.\n Mehr Informationen zu diesem Gateway findest Du unter http://msn-transport.jabberstudio.org/docs/users"
-               gatewayTranslator = u"Enter the user's MSN account." # FIXMELANG!!
+               gatewayTranslator = u"Enter the user's MSN account."
                userMapping = u"The MSN contact %s has a Jabber ID %s. It is recommended to talk to this person through Jabber."
                notLoggedIn = u"Fehler. Du musst beim Gateway eingeloggt sein bevor Du Nachrichten schicken kannst."
                notRegistered = u"Sorry, Du scheinst Dich bei diesem Gateway noch nicht registriert zu haben. Bitte registriere Dich und versuche es noch einmal. Bei Problemen wendest Du Dich am besten an Deinen Jabber-Administrator"
index 30f05818ee5937700949e868fa5f886021906554..d9dbdd17432f821fc8115ef98b3ce6492f2fff21 100644 (file)
@@ -94,16 +94,45 @@ def updateStats(statistics):
        #stats["FailedAvatarCount"] = msnp2p.MSNP2P_Avatar.ERROR_COUNT
 
 
+msn2jid_cache = {}
 def msn2jid(msnid, withResource):
        """ Converts a MSN passport into a JID representation to be used with the transport """
-       return msnid.replace('@', '%') + "@" + config.jid + (withResource and "/msn" or "")
+       global msn2jid_cache
+       global jid2msn_cache
+
+       if msn2jid_cache.has_key(msnid):
+               jid = msn2jid_cache[msnid]
+               if withResource:
+                       jid += "/msn"
+               return jid
+       else:
+               if msnid.startswith("tel:+"):
+                       msnid = msnid.replace("tel:+", "") + "%tel"
+               jid = msnid.replace('@', '%') + "@" + config.jid + (withResource and "/msn" or "")
+               msn2jid_cache[msnid] = jid
+               jid2msn_cache[jid] = msnid
+               return jid
 
 # Marks this as the function to be used in jabber:iq:gateway (Service ID Translation)
-translateAccount = lambda a: msn2jid(a, False)
+def translateAccount(msnid):
+       return msn2jid(msnid, False)
 
+jid2msn_cache = {}
 def jid2msn(jid):
        """ Converts a JID representation of a MSN passport into the original MSN passport """
-       return unicode(jid[:jid.find('@')].replace('%', '@')).split("/")[0]
+       global jid2msn_cache
+       global msn2jid_cache
+
+       if jid2msn_cache.has_key(jid):
+               msnid = jid2msn_cache[jid]
+               return msnid
+       else:
+               if jid.index("%tel@") > 0:
+                       jid = "tel:+" + jid.replace("%tel@", "@")
+               msnid = unicode(jid[:jid.find('@')].replace('%', '@')).split("/")[0]
+               jid2msn_cache[jid] = msnid
+               msn2jid_cache[msnid] = jid
+               return msnid
 
 
 def presence2state(show, ptype): 
index c4f7c34fbca500deaa97722b3b81f547a1aab2a8..0b4f42711353c0b0951737f1c62cef9e07d27b48 100644 (file)
@@ -50,6 +50,7 @@ class MSNConnection:
 
        def _getNotificationReferral(self):
                def timeout():
+                       self.timeout = None
                        if not d.called:
                                d.errback()
                                self.logOut() # Clean up everything
@@ -65,6 +66,7 @@ class MSNConnection:
        
        def _gotNotificationReferral(self, (host, port)):
                self.timeout.cancel()
+               self.timeout = None
                # Create the NotificationClient
                self.notificationFactory = msn.NotificationFactory()
                self.notificationFactory.userHandle = self.username
@@ -649,9 +651,7 @@ class OneSwitchboardSession(SwitchboardSessionBase):
                del self.remoteUser
                self.contactCount = 0
                self.msncon.gotGroupchat(self, userHandle)
-               if not self.groupchat:
-                       LogEvent(ERROR, self.ident)
-                       raise Exception("YouNeedAGroupchat-WeHaveAProblemError") # FIXME
+               assert self.groupchat
        
        def failedMessage(self, text):
                self.msncon.failedMessage(self.remoteUser, text)