# Licensed for distribution under the GPL version 2, check COPYING for details
import utils
-from tlib.xmlw import Element
+from tlib.xmlw import Element, jid
from twisted.internet.defer import Deferred
from twisted.internet import reactor
from debug import LogEvent, INFO, WARN, ERROR
iqType = el.getAttribute("type")
ulang = utils.getLang(el)
try: # Stringprep
- froj = utils.jid(fro)
- to = utils.jid(to).full()
+ froj = jid.intern(fro)
+ to = jid.intern(to).full()
except Exception, e:
LogEvent(WARN, "", "Dropping IQ because of stringprep error")
# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
+import tlib.xmlw
+
import utils
import config
import xdb
for file in os.listdir(pre):
try:
file = xdb.unmangle(file).decode("utf-8")
- filej = utils.jid(file).full()
+ filej = xmlw.jid.intern(file).full()
if(file != filej):
file = xdb.mangle(file)
filej = xdb.mangle(filej)
# Licensed for distribution under the GPL version 2, check COPYING for details
import utils
-from tlib.xmlw import Element
+from tlib.xmlw import Element, jid
from debug import LogEvent, INFO, WARN, ERROR
import disco
def sendPresence(pytrans, to, fro, show=None, status=None, priority=None, ptype=None, avatarHash=None, nickname=None, payload=[]):
# Strip the resource off any presence subscribes (as per XMPP RFC 3921 Section 5.1.6)
# Makes eJabberd behave :)
- if(ptype == "subscribe"):
- (user,host,res) = utils.jid(to)
- to = "%s@%s" % (user, host)
+ if ptype == "subscribe":
+ to = jid.intern(to).userhost()
el = Element((None, "presence"))
el.attributes["to"] = to
fro = el.getAttribute("from")
to = el.getAttribute("to")
try:
- froj = utils.jid(fro)
- toj = utils.jid(to)
+ froj = jid.intern(fro)
+ toj = jid.intern(to)
except Exception, e:
LogEvent(WARN, self.jabberID)
return
""" Handles incoming presence packets """
#LogEvent(INFO, self.jabberID)
fro = el.getAttribute("from")
- froj = utils.jid(fro)
+ froj = jid.intern(fro)
to = el.getAttribute("to")
- toj = utils.jid(to)
+ toj = jid.intern(to)
# Grab the contents of the <presence/> packet
ptype = el.getAttribute("type")
if switchboardSession:
self.switchboardSession = switchboardSession
else:
- self.switchboardSession = msn.MultiSwitchboardSession(self)
+ self.switchboardSession = msn.MultiSwitchboardSession(self.session.legacycon)
LogEvent(INFO, self.roomJID())
userHandle = jid2msn(contactJID)
self.switchboardSession.inviteUser(userHandle)
- def gotMessage(self, userHandle, text)
+ def gotMessage(self, userHandle, text):
LogEvent(INFO, self.roomJID())
self.messageReceived(userHandle, text)
def contactAvatarChanged(self, userHandle, hash):
LogEvent(INFO, self.session.jabberID)
+ jid = msn2jid(userHandle)
c = self.session.contactList.findContact(jid)
if not c: return
if av:
msnContact = self.getContacts().getContact(userHandle)
msnContact.msnobjGot = True
- jid = msn2jid(userHandle)
c.updateAvatar(av)
else:
def updateAvatar((imageData,)):
av = self.session.pytrans.avatarCache.setAvatar(imageData)
c.updateAvatar(av)
- self.sendAvatarRequest(userHandle).addCallback(updateAvatar)
+ d = self.sendAvatarRequest(userHandle)
+ if d:
+ d.addCallback(updateAvatar)
else:
# They've turned off their avatar
global defaultAvatar
def onMessage(self, el):
fro = el.getAttribute("from")
try:
- froj = utils.jid(fro)
+ froj = jid.intern(fro)
except Exception, e:
LogEvent(WARN, "", "Failed stringprep.")
return
fro = el.getAttribute("from")
to = el.getAttribute("to")
try:
- froj = utils.jid(fro)
- toj = utils.jid(to)
+ froj = jid.intern(fro)
+ toj = jid.intern(to)
except Exception, e:
LogEvent(WARN, "", "Failed stringprep.")
return
ID = el.getAttribute("id")
ulang = utils.getLang(el)
- if config.admins.count(utils.jid(to).userhost()) == 0:
+ if config.admins.count(jid.intern(to).userhost()) == 0:
self.pytrans.discovery.sendIqError(to=to, fro=config.jid, ID=ID, xmlns=disco.COMMANDS, etype="cancel", condition="not-authorized")
return
def incomingIq(self, el):
itype = el.getAttribute("type")
fro = el.getAttribute("from")
- froj = utils.jid(fro)
+ froj = jid.intern(fro)
to = el.getAttribute("to")
ID = el.getAttribute("id")
def incomingIq(self, el):
itype = el.getAttribute("type")
fro = el.getAttribute("from")
- froj = utils.jid(fro)
+ froj = jid.intern(fro)
to = el.getAttribute("to")
ID = el.getAttribute("id")
if(itype != "get" and itype != "error"):
def incomingIq(self, el):
itype = el.getAttribute("type")
fro = el.getAttribute("from")
- froj = utils.jid(fro)
+ froj = jid.intern(fro)
to = el.getAttribute("to")
ID = el.getAttribute("id")
# Licensed for distribution under the GPL version 2, check COPYING for details
import utils
-from tlib.xmlw import Element
+from tlib.xmlw import Element, jid
from debug import LogEvent, INFO, WARN, ERROR
import disco
import session
(blah1, password, blah3) = self.getRegInfo(jabberID)
reginfo = legacy.formRegEntry(username, password)
- self.pytrans.xdb.set(utils.jid(jabberID).userhost(), legacy.namespace, reginfo)
+ self.pytrans.xdb.set(jid.intern(jabberID).userhost(), legacy.namespace, reginfo)
def getRegInfo(self, jabberID):
LogEvent(INFO)
- result = self.pytrans.xdb.request(utils.jid(jabberID).userhost(), legacy.namespace)
+ result = self.pytrans.xdb.request(jid.intern(jabberID).userhost(), legacy.namespace)
if(result == None):
LogEvent(INFO, "", "Not registered!")
return None
ID = incoming.getAttribute("id")
fro = incoming.getAttribute("from")
LogEvent(INFO)
- source = utils.jid(fro).userhost()
+ source = jid.intern(fro).userhost()
ulang = utils.getLang(incoming)
username = None
password = None
# Copyright 2004-2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
+from tlib.xmlw import jid
+
import utils
import legacy
import jabw
def updateNickname(self, nickname):
self.nickname = nickname
if not self.nickname:
- j = utils.jid(self.jabberID)
+ j = jid.intern(self.jabberID)
self.nickname = j.user
self.setStatus(self.show, self.status)
-from msnw import MSNConnection
+from msnw import MSNConnection, MultiSwitchboardSession
from msn import FORWARD_LIST, ALLOW_LIST, BLOCK_LIST, REVERSE_LIST, PENDING_LIST
from msn import STATUS_ONLINE, STATUS_OFFLINE, STATUS_HIDDEN, STATUS_IDLE, STATUS_AWAY, STATUS_BUSY, STATUS_BRB, STATUS_PHONE, STATUS_LUNCH
from msn import MSNContact, MSNContactList
def handle_PRP(self, params):
if params[1] == "MFN":
- self._fireCallback(int(params[0]), unquote(params[2]))
+ self._fireCallback(int(params[0]))
elif self._getState() == 'SYNC':
self._getStateData('phone').append((params[0], unquote(params[1])))
else:
@return: A Deferred, the callback for which will be called
when the server acknowledges the change.
- The callback argument will be a tuple of 1 element,
- the new screen name.
+ The callback argument will be an empty tuple.
"""
id, d = self._createIDMapping()
self.sendLine("PRP %s MFN %s" % (id, quote(newName)))
def _cb(r):
- self.factory.screenName = r[0]
+ self.factory.screenName = newName
return r
return d.addCallback(_cb)
MAXMESSAGESIZE = 1400
SWITCHBOARDTIMEOUT = 30.0*60.0
-GETALLAVATARS = True
+GETALLAVATARS = False
"""
@param personal: the user's new personal message.
"""
+ if not screenName: screenName = self.username
if self.notificationClient:
count = 0
def cb(ignored=None):
self.notificationClient.changeStatus(statusCode.encode("utf-8")).addCallback(cb)
self.notificationClient.changeScreenName(screenName.encode("utf-8")).addCallback(cb)
if not personal: personal = ""
- self.notificationClient.changePersonalMessage(personal.encode("utf-8"))
+ self.notificationClient.changePersonalMessage(personal.encode("utf-8")).addCallback(cb)
else:
self.savedEvents.statusCode = statusCode
self.savedEvents.screenName = screenName
def gotSwitchboardInvitation(self, sessionID, host, port, key, userHandle, screenName):
LogEvent(INFO, self.factory.msncon.ident)
sb = self.factory.msncon.switchboardSessions.get(userHandle)
- if sb:
+ if sb and sb.transport:
sb.transport.loseConnection()
else:
sb = OneSwitchboardSession(self.factory.msncon, userHandle)
del self.msncon
self.transport.disconnect()
+ def loggedIn(self):
+ LogEvent(INFO, self.ident)
+ self.ready = True
+ self.flushBuffer()
+
def connect(self):
LogEvent(INFO, self.ident)
self.ready = False
after instantiation. """
userHandle = str(userHandle)
if self.ready:
- LogEvent(INFO, self.ident)
- msn.SwitchboardClient.inviteUser(userHandle)
+ LogEvent(INFO, self.ident, "immediate")
+ msn.SwitchboardClient.inviteUser(self, userHandle)
else:
- self.funcBuffer.append(lambda: msn.SwitchboardClient.inviteUser(userHandle))
+ LogEvent(INFO, self.ident, "pending")
+ self.funcBuffer.append(lambda: msn.SwitchboardClient.inviteUser(self, userHandle))
def gotMessage(self, message):
self.groupchat.gotMessage(message.userHandle, message.getMessage())
LogEvent(INFO, self.ident)
if not self.reply:
def failCB(arg=None):
- LogEvent(INFO, ident, "User has not joined after 30 seconds.")
+ LogEvent(INFO, self.ident, "User has not joined after 30 seconds.")
del self.msncon.switchboardSessions[self.remoteUser]
d = self.inviteUser(self.remoteUser)
d.addErrback(failCB)
self._ready()
if userHandle != self.remoteUser:
# Another user has joined, so we now have three participants.
- self.switchToMulti(self)
+ self._switchToMulti(self)
self.userJoined(userHandle)
def userLeft(self, userHandle):
-try:
- from twisted.words.protocols.jabber import intern as jid
-except:
- from tlib.jabber.jid import intern as jid
-
-
def getLang(el):
return el.getAttribute((u'http://www.w3.org/XML/1998/namespace', u'lang'))