def showHelpAction(self, el, sessionid=None):
		to = el.getAttribute('from')
		ID = el.getAttribute('id')
		ulang = utils.getLang(el)
		
		iq = Element((None, 'iq'))
		iq.attributes['to'] = to
		iq.attributes['from'] = config.jid
		if ID:
			iq.attributes['id'] = ID
		iq.attributes['type'] = 'result'
		
		command = iq.addElement('command')
		if sessionid:
			command.attributes['sessionid'] = sessionid
		else:
			command.attributes['sessionid'] = self.pytrans.makeMessageID()
		command.attributes['node'] = 'help'
		command.attributes['xmlns'] = globals.COMMANDS
		command.attributes['status'] = 'executing'
		
		actions = command.addElement('actions')
		actions.attributes['execute'] = 'next'
		actions.addElement('next')

		x = command.addElement('x')
		x.attributes['xmlns'] = 'jabber:x:data'
		x.attributes['type'] = 'form'

		title = x.addElement('title')
		title.addContent(lang.get('command_Help'))
		
		instructions = x.addElement('instructions')
		instructions.addContent(lang.get('help_documentation'))
		
		field = x.addElement('field')
		field.attributes['var'] = 'help_action'
		field.attributes['type'] = 'list-single'
		field.attributes['label'] = lang.get('help_action')
		desc = field.addElement('desc')
		desc.addContent(lang.get('help_action_Desc'))
		
		option = field.addElement('option')
		option.attributes['label'] = help_mainroom
		value = option.addElement('value')
		value.addContent(help_mainroom)
		
		if config.supportRoom:
			option = field.addElement('option')
			option.attributes['label'] = config.supportRoom
			value = option.addElement('value')
			value.addContent(config.supportRoom)
			
		stage = x.addElement('field')
		stage.attributes['type'] = 'hidden'
		stage.attributes['var'] = 'stage'
		value = stage.addElement('value')
		value.addContent('2')
		
		self.pytrans.send(iq)
	def sendCompletedForm(self, el, sessionid=None):
		to = el.getAttribute('from')
		ID = el.getAttribute('id')
		ulang = utils.getLang(el)
		
		iq = Element((None, 'iq'))
		iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
		if ID:
			iq.attributes['id'] = ID
		command = iq.addElement('command')
		command.attributes = {
			'node': 'settings', 
			'xmlns': globals.COMMANDS, 
			'status': 'completed'
		}
		if sessionid:
			command.attributes['sessionid'] = sessionid
		else:
			command.attributes['sessionid'] = self.pytrans.makeMessageID()

		note = command.addElement('note', None, lang.get('settings_changed'))
		note.attributes['type'] = 'info'
		
		x = command.addElement('x')
		x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
		x.addElement('title', None, lang.get('command_Settings'))
		x.addElement('instructions', None, lang.get('settings_changed'))
		
		self.pytrans.send(iq)
Example #3
0
    def checkUserJoined(self, ignored=None):
        self.checkTimer = None
        if not self.ready:
            LogEvent(INFO, self.session.jabberID,
                     "Join timeout after two minutes.")

            text = []
            text.append(
                lang.get("groupchatfailjoin1", self.session.lang) %
                (self.roomJID()))
            for contact in self.contacts:
                text.append("\t%s" % (contact))
            text.append("")
            text.append(lang.get("groupchatfailjoin2", self.session.lang))
            text.append("")
            for (source, message, timestamp) in self.messageBuffer:
                if source:
                    text.append("%s says: %s" % (source, message))
                else:
                    text.append(message)

            body = string.join(text, "\n")

            self.session.sendMessage(to=self.user(),
                                     fro=config.confjid,
                                     body=body)

            self.removeMe()
Example #4
0
    def incomingIq(self, el):
        to = el.getAttribute("from")
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        iq = Element((None, "iq"))
        iq.attributes["to"] = to
        iq.attributes["from"] = config.jid
        if ID:
            iq.attributes["id"] = ID
        iq.attributes["type"] = "result"

        command = iq.addElement("command")
        command.attributes["sessionid"] = self.pytrans.makeMessageID()
        command.attributes["xmlns"] = globals.COMMANDS
        command.attributes["status"] = "completed"

        x = command.addElement("x")
        x.attributes["xmlns"] = globals.XDATA
        x.attributes["type"] = "result"

        title = x.addElement("title")
        title.addContent(lang.get("command_Statistics", ulang))

        for key in self.stats:
            label = lang.get("statistics_%s" % key, ulang)
            description = lang.get("statistics_%s_Desc" % key, ulang)
            field = x.addElement("field")
            field.attributes["var"] = key
            field.attributes["label"] = label
            field.attributes["type"] = "text-single"
            field.addElement("value").addContent(str(self.stats[key]))
            field.addElement("desc").addContent(description)

        self.pytrans.send(iq)
Example #5
0
	def incomingIq(self, el):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_Statistics", ulang))

		for key in self.stats:
			label = lang.get("statistics_%s" % key, ulang)
			description = lang.get("statistics_%s_Desc" % key, ulang)
			field = x.addElement("field")
			field.attributes["var"] = key
			field.attributes["label"] = label
			field.attributes["type"] = "text-single"
			field.addElement("value").addContent(str(self.stats[key]))
			field.addElement("desc").addContent(description)

		self.pytrans.send(iq)
Example #6
0
    def checkUserJoined(self, ignored=None):
        self.checkTimer = None
        if (not self.ready):
            LogEvent(
                INFO, self.roomJID(),
                "User hasn't joined after two minutes. Removing them from the room."
            )

            text = []
            text.append(
                lang.get(self.session.lang).groupchatFailJoin1 %
                (self.roomJID()))
            for contact in self.contacts:
                text.append("\t%s" % (contact))
            text.append("")
            text.append(lang.get(self.session.lang).groupchatFailJoin2)
            text.append("")
            for (source, message, timestamp) in self.messageBuffer:
                if (source):
                    text.append("%s says: %s" % (source, message))
                else:
                    text.append(message)

            body = string.join(text, "\n")

            self.session.sendMessage(to=self.user(), fro=config.jid, body=body)

            self.removeMe()
Example #7
0
    def sendForm(self, el, sessionid=None, errormsg=None):
        to = el.getAttribute("from")
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        iq = Element((None, "iq"))
        iq.attributes["to"] = to
        iq.attributes["from"] = config.jid
        if ID:
            iq.attributes["id"] = ID
        iq.attributes["type"] = "result"

        command = iq.addElement("command")
        if sessionid:
            command.attributes["sessionid"] = sessionid
        else:
            command.attributes["sessionid"] = self.pytrans.makeMessageID()
        command.attributes["node"] = "changepassword"
        command.attributes["xmlns"] = globals.COMMANDS
        command.attributes["status"] = "executing"

        if errormsg:
            note = command.addElement("note")
            note.attributes["type"] = "error"
            note.addContent(errormsg)

        actions = command.addElement("actions")
        actions.attributes["execute"] = "complete"
        actions.addElement("complete")

        x = command.addElement("x")
        x.attributes["xmlns"] = "jabber:x:data"
        x.attributes["type"] = "form"

        title = x.addElement("title")
        title.addContent(lang.get("command_ChangePassword", ulang))

        instructions = x.addElement("instructions")
        instructions.addContent(
            lang.get("command_ChangePassword_Instructions", ulang))

        oldpassword = x.addElement("field")
        oldpassword.attributes["type"] = "text-private"
        oldpassword.attributes["var"] = "oldpassword"
        oldpassword.attributes["label"] = lang.get(
            "command_ChangePassword_OldPassword", ulang)

        newpassword = x.addElement("field")
        newpassword.attributes["type"] = "text-private"
        newpassword.attributes["var"] = "newpassword"
        newpassword.attributes["label"] = lang.get(
            "command_ChangePassword_NewPassword", ulang)

        newpassworda = x.addElement("field")
        newpassworda.attributes["type"] = "text-private"
        newpassworda.attributes["var"] = "newpasswordagain"
        newpassworda.attributes["label"] = lang.get(
            "command_ChangePassword_NewPasswordAgain", ulang)

        self.pytrans.send(iq)
Example #8
0
    def pwdChangeResults(self, results, el, sessionid, newpassword):
        to = el.getAttribute("from")
        toj = internJID(to)
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        iq = Element((None, "iq"))
        iq.attributes["to"] = to
        iq.attributes["from"] = config.jid
        if ID:
            iq.attributes["id"] = ID
        iq.attributes["type"] = "result"

        command = iq.addElement("command")
        if sessionid:
            command.attributes["sessionid"] = sessionid
        else:
            command.attributes["sessionid"] = self.pytrans.makeMessageID()
        command.attributes["node"] = "changepassword"
        command.attributes["xmlns"] = globals.COMMANDS
        command.attributes["status"] = "completed"

        note = command.addElement("note")
        if results[3]:
            note.attributes["type"] = "error"
            note.addContent(lang.get("command_ChangePassword_Failed", ulang))
        else:
            note.attributes["type"] = "info"
            note.addContent(lang.get("command_Done", ulang))
            (username,
             oldpassword) = self.pytrans.xdb.getRegistration(toj.userhost())
            self.pytrans.xdb.setRegistration(toj.userhost(), username,
                                             newpassword)

        self.pytrans.send(iq)
Example #9
0
    def sendResponse(self, failure, el, sessionid=None):
        LogEvent(INFO)
        to = el.getAttribute("from")
        toj = internJID(to)
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        iq = Element((None, "iq"))
        iq.attributes["to"] = to
        iq.attributes["from"] = config.jid
        if ID:
            iq.attributes["id"] = ID
        iq.attributes["type"] = "result"

        command = iq.addElement("command")
        if sessionid:
            command.attributes["sessionid"] = sessionid
        else:
            command.attributes["sessionid"] = self.pytrans.makeMessageID()
        command.attributes["node"] = "confirmaccount"
        command.attributes["xmlns"] = globals.COMMANDS
        command.attributes["status"] = "completed"

        note = command.addElement("note")
        if failure:
            note.attributes["type"] = "error"
            note.addContent(lang.get("command_ConfirmAccount_Failed", ulang))
        else:
            note.attributes["type"] = "info"
            note.addContent(lang.get("command_ConfirmAccount_Complete", ulang))

        self.pytrans.send(iq)
	def incomingIq(self, el):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		if config.admins.count(internJID(to).userhost()) == 0:
			self.pytrans.iq.sendIqError(to=to, fro=config.jid, ID=ID, xmlns=globals.COMMANDS, etype="cancel", condition="not-authorized")
			return

		self.sendProbes()

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_ConnectUsers", ulang))

		field = x.addElement("field")
		field.attributes["type"] = "fixed"
		field.addElement("value").addContent(lang.get("command_Done", ulang))

		self.pytrans.send(iq)
Example #11
0
	def sendResponse(self, failure, el, sessionid=None):
		LogEvent(INFO)
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "confirmaccount"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if failure:
			note.attributes["type"] = "error"
			note.addContent(lang.get("command_ConfirmAccount_Failed", ulang))
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_ConfirmAccount_Complete", ulang))

		self.pytrans.send(iq)
Example #12
0
	def sendSearchForm(self, el):
		LogEvent(INFO)
		ulang = utils.getLang(el)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = el.getAttribute("to")
		iq.attributes["to"] = el.getAttribute("from")
		if el.getAttribute("id"):
			iq.attributes["id"] = el.getAttribute("id")
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.IQSEARCH
		forminstr = query.addElement("instructions")
		forminstr.addContent(lang.get("searchnodataform", ulang))
		x = query.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "form"
		title = x.addElement("title")
		title.addContent(lang.get("searchtitle", ulang))
		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("searchinstructions", ulang))
		x.addChild(utils.makeDataFormElement("hidden", "FORM_TYPE", value="jabber:iq:search"))
		x.addChild(utils.makeDataFormElement("text-single", "email", "E-Mail Address"))
		x.addChild(utils.makeDataFormElement("text-single", "first", "First Name"))
		x.addChild(utils.makeDataFormElement("text-single", "middle", "Middle Name"))
		x.addChild(utils.makeDataFormElement("text-single", "last", "Last Name"))
		x.addChild(utils.makeDataFormElement("text-single", "maiden", "Maiden Name"))
		x.addChild(utils.makeDataFormElement("text-single", "nick", "Nickname"))
		x.addChild(utils.makeDataFormElement("text-single", "address", "Street Address"))
		x.addChild(utils.makeDataFormElement("text-single", "city", "City"))
		x.addChild(utils.makeDataFormElement("text-single", "state", "State"))
		x.addChild(utils.makeDataFormElement("text-single", "zip", "Zip Code"))
		x.addChild(utils.makeDataFormElement("text-single", "country", "Country"))
		x.addChild(utils.makeDataFormElement("text-single", "interest", "Interest"))

		self.pytrans.send(iq)
Example #13
0
	def pwdChangeResults(self, results, el, sessionid, newpassword):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "changepassword"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(lang.get("command_ChangePassword_Failed", ulang))
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))
			(username, oldpassword) = self.pytrans.xdb.getRegistration(toj.userhost())
			self.pytrans.xdb.setRegistration(toj.userhost(), username, newpassword)

		self.pytrans.send(iq)
Example #14
0
	def sendForm(self, el, sessionid=None, errormsg=None):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "changepassword"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "executing"

		if errormsg:
			note = command.addElement("note")
			note.attributes["type"] = "error"
			note.addContent(errormsg)

		actions = command.addElement("actions")
		actions.attributes["execute"] = "complete"
		actions.addElement("complete")

		x = command.addElement("x")
		x.attributes["xmlns"] = "jabber:x:data"
		x.attributes["type"] = "form"

		title = x.addElement("title")
		title.addContent(lang.get("command_ChangePassword", ulang))

		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("command_ChangePassword_Instructions", ulang))

		oldpassword = x.addElement("field")
		oldpassword.attributes["type"] = "text-private"
		oldpassword.attributes["var"] = "oldpassword"
		oldpassword.attributes["label"] = lang.get("command_ChangePassword_OldPassword", ulang)

		newpassword = x.addElement("field")
		newpassword.attributes["type"] = "text-private"
		newpassword.attributes["var"] = "newpassword"
		newpassword.attributes["label"] = lang.get("command_ChangePassword_NewPassword", ulang)

		newpassworda = x.addElement("field")
		newpassworda.attributes["type"] = "text-private"
		newpassworda.attributes["var"] = "newpasswordagain"
		newpassworda.attributes["label"] = lang.get("command_ChangePassword_NewPasswordAgain", ulang)

		self.pytrans.send(iq)
Example #15
0
    def incomingIq(self, el):
        to = el.getAttribute("from")
        toj = internJID(to)
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        sessionid = None
        oldpassword = None
        newpassword = None
        newpasswordagain = None

        for command in el.elements():
            sessionid = command.getAttribute("sessionid")
            if command.getAttribute("action") == "cancel":
                self.pytrans.adhoc.sendCancellation("changepassword", el,
                                                    sessionid)
                return
            for child in command.elements():
                if child.name == "x" and child.getAttribute(
                        "type") == "submit":
                    for field in child.elements():
                        if field.name == "field" and field.getAttribute(
                                "var") == "newpassword":
                            for value in field.elements():
                                if value.name == "value":
                                    newpassword = value.__str__()
                        elif field.name == "field" and field.getAttribute(
                                "var") == "newpasswordagain":
                            for value in field.elements():
                                if value.name == "value":
                                    newpasswordagain = value.__str__()
                        elif field.name == "field" and field.getAttribute(
                                "var") == "oldpassword":
                            for value in field.elements():
                                if value.name == "value":
                                    oldpassword = value.__str__()

        if not self.pytrans.sessions.has_key(toj.userhost()) or not hasattr(
                self.pytrans.sessions[toj.userhost()].legacycon, "bos"):
            self.pytrans.adhoc.sendError("changepassword",
                                         el,
                                         errormsg=lang.get(
                                             "command_NoSession", ulang),
                                         sessionid=sessionid)
        elif newpassword and newpassword != newpasswordagain:
            self.sendForm(el,
                          sessionid=sessionid,
                          errormsg=lang.get("command_ChangePassword_Mismatch",
                                            ulang))
        elif oldpassword and newpassword:
            self.changePassword(el, oldpassword, newpassword, sessionid)
        else:
            self.sendForm(el)
Example #16
0
    def render_statistics(self, ctx, data):
        ret = T.table(border=0, width="100%", cellspacing=5, cellpadding=2)
        for key in self.pytrans.serviceplugins['Statistics'].stats:
            label = lang.get("statistics_%s" % key, config.lang)
            description = lang.get("statistics_%s_Desc" % key, config.lang)

            row = T.tr[
                T.th(align="right")[label + ":"],
                T.td[self.pytrans.serviceplugins['Statistics'].stats[key]],
                T.td[description]]
            ret[row]
        return ret
	def incomingIq(self, el):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		sessionid = None
		refresh = False
		if el.firstChildElement():
			sessionid = el.firstChildElement().getAttribute('sessionid')
			if el.firstChildElement().getAttribute('action') == 'next':
				refresh = True

		command = iq.addElement("command")
		if not refresh and sessionid:
			command.attributes["status"] = 'completed'
		else:
			command.attributes["status"] = 'executing'
			actions = command.addElement('actions')
			actions.attributes['execute'] = 'complete'
			actions.addElement('next')
			actions.addElement('complete')
		if not sessionid:
			sessionid = self.pytrans.makeMessageID()
		command.attributes["sessionid"] = sessionid
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes['node'] = 'stats'

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_Statistics", ulang))

		for key in self.stats:
			label = lang.get("statistics_%s" % key, ulang)
			description = lang.get("statistics_%s_Desc" % key, ulang)
			field = x.addElement("field")
			field.attributes["var"] = key
			field.attributes["label"] = label
			field.attributes["type"] = "text-single"
			field.addElement("value").addContent(str(self.stats[key]))
			field.addElement("desc").addContent(description)

		self.pytrans.send(iq)
	def render_statistics(self, ctx, data):
		ret = T.table(border = 0,width = "100%",cellspacing=5,cellpadding=2)
		for key in self.pytrans.serviceplugins['Statistics'].stats:
			label = lang.get("statistics_%s" % key, config.lang)
			description = lang.get("statistics_%s_Desc" % key, config.lang)

			row = T.tr[
				T.th(align = "right")[label+":"],
				T.td[self.pytrans.serviceplugins['Statistics'].stats[key]],
				T.td[description]
			]
			ret[row]
		return ret
Example #19
0
    def sendForm(self, current, el, sessionid=None, errormsg=None):
        to = el.getAttribute("from")
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        iq = Element((None, "iq"))
        iq.attributes["to"] = to
        iq.attributes["from"] = config.jid
        if ID:
            iq.attributes["id"] = ID
        iq.attributes["type"] = "result"

        command = iq.addElement("command")
        if sessionid:
            command.attributes["sessionid"] = sessionid
        else:
            command.attributes["sessionid"] = self.pytrans.makeMessageID()
        command.attributes["node"] = "formatscreenname"
        command.attributes["xmlns"] = globals.COMMANDS
        command.attributes["status"] = "executing"

        if errormsg:
            note = command.addElement("note")
            note.attributes["type"] = "error"
            note.addContent(errormsg)

        actions = command.addElement("actions")
        actions.attributes["execute"] = "complete"
        actions.addElement("complete")

        x = command.addElement("x")
        x.attributes["xmlns"] = globals.XDATA
        x.attributes["type"] = "form"

        title = x.addElement("title")
        title.addContent(lang.get("command_FormatScreenName", ulang))

        instructions = x.addElement("instructions")
        instructions.addContent(
            lang.get("command_FormatScreenName_Instructions", ulang))

        fmtsn = x.addElement("field")
        fmtsn.attributes["type"] = "text-single"
        fmtsn.attributes["var"] = "fmtsn"
        fmtsn.attributes["label"] = lang.get(
            "command_FormatScreenName_FMTScreenName", ulang)
        if current[1]:
            fmtsn.addElement("value").addContent(current[1])

        self.pytrans.send(iq)
Example #20
0
    def sendForm(self, el, sessionid=None, errormsg=None):
        to = el.getAttribute("from")
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        iq = Element((None, "iq"))
        iq.attributes["to"] = to
        iq.attributes["from"] = config.jid
        if ID:
            iq.attributes["id"] = ID
        iq.attributes["type"] = "result"

        command = iq.addElement("command")
        if sessionid:
            command.attributes["sessionid"] = sessionid
        else:
            command.attributes["sessionid"] = self.pytrans.makeMessageID()
        command.attributes["node"] = "emaillookup"
        command.attributes["xmlns"] = globals.COMMANDS
        command.attributes["status"] = "executing"

        if errormsg:
            note = command.addElement("note")
            note.attributes["type"] = "error"
            note.addContent(errormsg)

        actions = command.addElement("actions")
        actions.attributes["execute"] = "complete"
        actions.addElement("complete")

        x = command.addElement("x")
        x.attributes["xmlns"] = "jabber:x:data"
        x.attributes["type"] = "form"

        title = x.addElement("title")
        title.addContent(lang.get("command_EmailLookup", ulang))

        instructions = x.addElement("instructions")
        instructions.addContent(
            lang.get("command_EmailLookup_Instructions", ulang))

        email = x.addElement("field")
        email.attributes["type"] = "text-single"
        email.attributes["var"] = "email"
        email.attributes["label"] = lang.get("command_EmailLookup_Email",
                                             ulang)

        self.pytrans.send(iq)
Example #21
0
	def sendForm(self, current, el, sessionid=None, errormsg=None):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "changeemail"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "executing"

		if errormsg:
			note = command.addElement("note")
			note.attributes["type"] = "error"
			note.addContent(errormsg)

		actions = command.addElement("actions")
		actions.attributes["execute"] = "complete"
		actions.addElement("complete")

		x = command.addElement("x")
		x.attributes["xmlns"] = "jabber:x:data"
		x.attributes["type"] = "form"

		title = x.addElement("title")
		title.addContent(lang.get("command_ChangeEmail", ulang))

		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("command_ChangeEmail_Instructions", ulang))

		email = x.addElement("field")
		email.attributes["type"] = "text-single"
		email.attributes["var"] = "email"
		email.attributes["label"] = lang.get("command_ChangeEmail_Email", ulang)
		if current[4]:
			email.addElement("value").addContent(current[4])

		self.pytrans.send(iq)
Example #22
0
	def sendForm(self, current, el, sessionid=None, errormsg=None):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "formatscreenname"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "executing"

		if errormsg:
			note = command.addElement("note")
			note.attributes["type"] = "error"
			note.addContent(errormsg)

		actions = command.addElement("actions")
		actions.attributes["execute"] = "complete"
		actions.addElement("complete")

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "form"

		title = x.addElement("title")
		title.addContent(lang.get("command_FormatScreenName", ulang))

		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("command_FormatScreenName_Instructions", ulang))

		fmtsn = x.addElement("field")
		fmtsn.attributes["type"] = "text-single"
		fmtsn.attributes["var"] = "fmtsn"
		fmtsn.attributes["label"] = lang.get("command_FormatScreenName_FMTScreenName", ulang)
		if current[1]:
			fmtsn.addElement("value").addContent(current[1])

		self.pytrans.send(iq)
Example #23
0
    def messageReceived(self, source, resource, dest, destr, mtype, body,
                        noerror):
        if dest == config.jid:
            if body.lower().startswith("end"):
                LogEvent(INFO, self.jabberID, "Received 'end' request.")
                self.removeMe()
            return

        if not self.ready:
            self.sendNotReadyError(source, resource, dest, body)
            return

        # Sends the message to the legacy translator
        groupchat = self.findGroupchat(dest)
        if groupchat:
            # It's for a groupchat
            if destr and len(destr) > 0 and not noerror:
                self.sendErrorMessage(to=(source + "/" + resource),
                                      fro=dest,
                                      etype="cancel",
                                      condition="not-allowed",
                                      explanation=lang.get(
                                          self.lang).groupchatPrivateError,
                                      body=body)
            else:
                LogEvent(INFO, self.jabberID, "Groupchat.")
                groupchat.sendMessage(body, noerror)
        else:
            LogEvent(INFO, self.jabberID, "Message.")
            self.legacycon.sendMessage(dest, resource, body, noerror)
Example #24
0
	def emailNotificationReceived(self, addr, url, unreadnum, hasunread):
		LogEvent(INFO, self.session.jabberID)
		#debug.log("B: emailNotificationReceived %s %s %d %d" % (addr, url, unreadnum, hasunread))
		if unreadnum > self.unreadmessages:
			diff = unreadnum - self.unreadmessages
			self.session.sendMessage(to=self.session.jabberID, fro=config.jid, body=lang.get("icqemailnotification", config.jid) % (diff, addr, url), mtype="headline")
		self.unreadmessages = unreadnum
Example #25
0
	def sendDiscoItemsResponse(self, to, ID, ulang, jid):
		""" Send a service discovery disco#items stanza to the given 'to'. 'jid' is the JID that was queried. """
		LogEvent(INFO)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = jid
		iq.attributes["to"] = to
		if ID:
			iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_ITEMS

		searchjid = jid
		if jid.find('@') > 0: searchjid = "USER"

		for node in self.nodes.get(searchjid, []):
			handler, name, rootnode = self.nodes[jid][node]
			if rootnode:
				LogEvent(INFO, msg="Found node %r" % (node))
				name = lang.get(name, ulang)
				item = query.addElement("item")
				item.attributes["jid"] = jid
				item.attributes["node"] = node
				item.attributes["name"] = name

		if searchjid == "USER":
			# Add any user specific items
			for hndl in self.userItemHandlers:
				hndl(jid, query)
		
		self.pytrans.send(iq)
Example #26
0
	def incomingIq(self, el):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		sessionid = None
		email = None

		for command in el.elements():
			sessionid = command.getAttribute("sessionid")
			if command.getAttribute("action") == "cancel":
				self.pytrans.adhoc.sendCancellation("changeemail", el, sessionid)
				return
			for child in command.elements():
				if child.name == "x" and child.getAttribute("type") == "submit":
					for field in child.elements():
						if field.name == "field" and field.getAttribute("var") == "email":
							for value in field.elements():
								if value.name == "value":
									email = value.__str__()

		if not self.pytrans.sessions.has_key(toj.userhost()) or not hasattr(self.pytrans.sessions[toj.userhost()].legacycon, "bos"):
			self.pytrans.adhoc.sendError("changeemail", el, errormsg=lang.get("command_NoSession", ulang), sessionid=sessionid)
		elif email:
			self.changeEmail(el, email, sessionid)
		else:
			self.pytrans.sessions[toj.userhost()].legacycon.bos.getEmailAddress().addCallback(self.sendForm, el)
Example #27
0
	def emailChangeResults(self, results, el, sessionid):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "changeemail"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(results[3][1])
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))

		self.pytrans.send(iq)
Example #28
0
	def removeContact(self, userHandle):
		LogEvent(INFO, self.session.jabberID)
		try:
			def cb(arg=None):
				self.updatePresence(userHandle, "unsubscribed")

			savetheseusers = []

			if userHandle in self.bos.authorizationRequests:
				self.bos.sendAuthorizationResponse(userHandle, False, "")
				self.bos.authorizationRequests.remove(userHandle)

			for g in self.bos.ssigroups:
				for u in g.users:
					icqHandle = self.icq2uhandle(u.name)
					LogEvent(INFO, self.session.jabberID, "Comparing %s and %s" % (icqHandle, userHandle))
					if icqHandle == userHandle:
						LogEvent(INFO, self.session.jabberID, "Located user %s" % (u.name))
						savetheseusers.append(u)

			if len(savetheseusers) == 0:
				LogEvent(INFO, self.session.jabberID, "Did not find user")
				return

			self.bos.startModifySSI()
			for u in savetheseusers:
				LogEvent(INFO, self.session.jabberID, "Removing %s (u:%d g:%d) from group %s"%(u.name, u.buddyID, u.groupID, u.group.name))
				de = self.bos.delItemSSI(u)
				de.addCallback(self.SSIItemDeleted, u)
			de.addCallback(cb)
			self.bos.endModifySSI()
		except AttributeError:
			self.alertUser(lang.get("sessionnotactive", config.jid))
Example #29
0
	def sendDiscoItemsResponse(self, to, ID, ulang, jid):
		""" Send a service discovery disco#items stanza to the given 'to'. 'jid' is the JID that was queried. """
		LogEvent(INFO)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = jid
		iq.attributes["to"] = to
		if ID:
			iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_ITEMS

		searchjid = jid
		if jid.find('@') > 0: searchjid = "USER"

		for node in self.nodes.get(searchjid, []):
			handler, name, rootnode = self.nodes[jid][node]
			if rootnode:
				LogEvent(INFO, msg="Found node %r" % (node))
				name = lang.get(name, ulang)
				item = query.addElement("item")
				item.attributes["jid"] = jid
				item.attributes["node"] = node
				item.attributes["name"] = name

		if searchjid == "USER":
			# Add any user specific items
			for hndl in self.userItemHandlers:
				hndl(jid, query)
		
		self.pytrans.send(iq)
Example #30
0
	def sendCommandInfoResponse(self, to, ID, node, ulang):
		LogEvent(INFO, msg="Replying to disco#info")
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = config.jid
		iq.attributes["to"] = to
		if ID: iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_INFO

		# Add identity
		identity = query.addElement("identity")
		identity.attributes["name"] = lang.get(self.commandNames[node], ulang)
		identity.attributes["category"] = "automation"
		identity.attributes["type"] = "command-node"

		# Add supported feature
		feature = query.addElement("feature")
		feature.attributes["var"] = globals.COMMANDS

		# Add supported feature
		feature = query.addElement("feature")
		feature.attributes["var"] = globals.XDATA

		self.pytrans.send(iq)
Example #31
0
    def sendRegistrationFields(self, incoming):
        # Construct a reply with the fields they must fill out
        LogEvent(INFO)
        reply = Element((None, "iq"))
        reply.attributes["from"] = config.jid
        reply.attributes["to"] = incoming.getAttribute("from")
        reply.attributes["id"] = incoming.getAttribute("id")
        reply.attributes["type"] = "result"
        query = reply.addElement("query")
        query.attributes["xmlns"] = globals.IQREGISTER
        instructions = query.addElement("instructions")
        ulang = utils.getLang(incoming)
        instructions.addContent(lang.get("registertext", ulang))
        userEl = query.addElement("username")
        passEl = query.addElement("password")

        # Check to see if they're registered
        source = internJID(incoming.getAttribute("from")).userhost()
        result = self.pytrans.xdb.getRegistration(source)
        if result:
            username, password = result
            if username != "local":
                userEl.addContent(username)
                query.addElement("registered")

        self.pytrans.send(reply)
Example #32
0
    def sendRegistrationFields(self, incoming):
        # Construct a reply with the fields they must fill out
        ID = incoming.getAttribute("id")
        fro = incoming.getAttribute("from")
        LogEvent(INFO)
        reply = Element((None, "iq"))
        reply.attributes["from"] = config.jid
        reply.attributes["to"] = fro
        if ID:
            reply.attributes["id"] = ID
        reply.attributes["type"] = "result"
        query = reply.addElement("query")
        query.attributes["xmlns"] = "jabber:iq:register"
        instructions = query.addElement("instructions")
        ulang = utils.getLang(incoming)
        instructions.addContent(lang.get(ulang).registerText)
        userEl = query.addElement("username")
        passEl = query.addElement("password")

        # Check to see if they're registered
        result = self.getRegInfo(incoming.getAttribute("from"))
        if (result):
            username, password = result
            userEl.addContent(username)
            query.addElement("registered")

        self.pytrans.send(reply)
	def incomingIq(self, el):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		sessionid = None
		email = None

		for command in el.elements():
			sessionid = command.getAttribute("sessionid")
			if command.getAttribute("action") == "cancel":
				self.pytrans.adhoc.sendCancellation("emaillookup", el, sessionid)
				return
			for child in command.elements():
				if child.name == "x" and child.getAttribute("type") == "submit":
					for field in child.elements():
						if field.name == "field" and field.getAttribute("var") == "email":
							for value in field.elements():
								if value.name == "value":
									email = value.__str__()

		if not self.pytrans.sessions.has_key(toj.userhost()) or not hasattr(self.pytrans.sessions[toj.userhost()].legacycon, "bos"):
			self.pytrans.adhoc.sendError("emaillookup", el, errormsg=lang.get("command_NoSession", ulang), sessionid=sessionid)
		elif email:
			self.lookupEmail(el, email, sessionid=sessionid)
		else:
			self.sendForm(el)
Example #34
0
 def multipleLogin(self):
     LogEvent(INFO, self.jabberID)
     self.session.sendMessage(to=self.jabberID,
                              fro=config.jid,
                              body=lang.get(
                                  self.session.lang).msnMultipleLogin)
     self.session.removeMe()
Example #35
0
def delete(path):
    import lang
    path = expand_path(path)
    if os.path.exists(path):
        if os.path.isdir(path):
            shutil.rmtree(path)
            debug(lang.get("files","delete_dir"),path)
            return True
        elif os.path.isfile(path):
            os.remove(path)
            debug(lang.get("files","delete_file"),path)
            return True
        else:
            return False
    else:
        return False
Example #36
0
	def incomingIq(self, el):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		sessionid = None
		fmtsn = None

		for command in el.elements():
			sessionid = command.getAttribute("sessionid")
			if command.getAttribute("action") == "cancel":
				self.pytrans.adhoc.sendCancellation("formatscreenname", el, sessionid)
				return
			for child in command.elements():
				if child.name == "x" and child.getAttribute("type") == "submit":
					for field in child.elements():
						if field.name == "field" and field.getAttribute("var") == "fmtsn":
							for value in field.elements():
								if value.name == "value":
									fmtsn = value.__str__()

		if not self.pytrans.sessions.has_key(toj.userhost()) or not hasattr(self.pytrans.sessions[toj.userhost()].legacycon, "bos"):
			self.pytrans.adhoc.sendError("formatscreenname", el, errormsg=lang.get("command_NoSession", ulang), sessionid=sessionid)
		elif fmtsn:
			self.changeSNFormat(el, fmtsn, sessionid)
		else:
			self.pytrans.sessions[toj.userhost()].legacycon.bos.getFormattedScreenName().addCallback(self.sendForm, el)
Example #37
0
	def snfmtChangeResults(self, results, el, sessionid):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "formatscreenname"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(results[3][1])
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))

		self.pytrans.send(iq)
	def sendCommandList(self, el):
		to = el.getAttribute("from")
		toj_uh = internJID(to).userhost()
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_ITEMS
		query.attributes["node"] = globals.COMMANDS
		
		rights = rights_guest
		if toj_uh in self.pytrans.sessions: # logined
			rights = rights_user 
		if toj_uh in config.admins: # admin
			rights = rights_admin
			
		for command in self.commands:
			if self.commandRights[command] <= rights: # user can view this item (enough rights)
				item = query.addElement("item")
				item.attributes["jid"] = config.jid
				item.attributes["node"] = command
				item.attributes["name"] = lang.get(self.commandNames[command], ulang)

		self.pytrans.send(iq)
Example #39
0
 def createChat(self, chatroom, exchange):
     LogEvent(INFO, self.session.jabberID)
     try:
         self.bos.createChat(chatroom,
                             exchange).addCallback(self.bos.createdRoom)
     except AttributeError:
         self.alertUser(lang.get("sessionnotactive", config.jid))
Example #40
0
 def doSearch(self, form, iq):
     LogEvent(INFO, self.session.jabberID)
     #TEST self.bos.sendInterestsRequest()
     email = utils.getDataFormValue(form, "email")
     first = utils.getDataFormValue(form, "first")
     middle = utils.getDataFormValue(form, "middle")
     last = utils.getDataFormValue(form, "last")
     maiden = utils.getDataFormValue(form, "maiden")
     nick = utils.getDataFormValue(form, "nick")
     address = utils.getDataFormValue(form, "address")
     city = utils.getDataFormValue(form, "city")
     state = utils.getDataFormValue(form, "state")
     zip = utils.getDataFormValue(form, "zip")
     country = utils.getDataFormValue(form, "country")
     interest = utils.getDataFormValue(form, "interest")
     try:
         d = defer.Deferred()
         self.bos.sendDirectorySearch(email=email,
                                      first=first,
                                      middle=middle,
                                      last=last,
                                      maiden=maiden,
                                      nickname=nick,
                                      address=address,
                                      city=city,
                                      state=state,
                                      zip=zip,
                                      country=country,
                                      interest=interest).addCallback(
                                          self.gotSearchResults, iq,
                                          d).addErrback(
                                              self.gotSearchError, d)
         return d
     except AttributeError:
         self.alertUser(lang.get("sessionnotactive", config.jid))
Example #41
0
    def incomingIq(self, el):
        to = el.getAttribute("from")
        toj = internJID(to)
        ID = el.getAttribute("id")
        ulang = utils.getLang(el)

        sessionid = None

        for command in el.elements():
            sessionid = command.getAttribute("sessionid")
            if command.getAttribute("action") == "cancel":
                self.pytrans.adhoc.sendCancellation("confirmaccount", el,
                                                    sessionid)
                return

        if not self.pytrans.sessions.has_key(toj.userhost()) or not hasattr(
                self.pytrans.sessions[toj.userhost()].legacycon, "bos"):
            self.pytrans.adhoc.sendError("confirmaccount",
                                         el,
                                         errormsg=lang.get(
                                             "command_NoSession", ulang),
                                         sessionid=sessionid)
        else:
            self.pytrans.sessions[
                toj.userhost()].legacycon.bos.confirmAccount().addCallback(
                    self.sendResponse, el, sessionid)
Example #42
0
def move(src,dst):
    import lang
    src = expand_path(src)
    dst = expand_path(dst)
    shutil.move(src,dst)
    debug(lang.get("files","move"),src,dst)
    return True
Example #43
0
	def sendRegistrationFields(self, incoming):
		# Construct a reply with the fields they must fill out
		LogEvent(INFO)
		reply = Element((None, "iq"))
		reply.attributes["from"] = config.jid
		reply.attributes["to"] = incoming.getAttribute("from")
		reply.attributes["id"] = incoming.getAttribute("id")
		reply.attributes["type"] = "result"
		query = reply.addElement("query")
		query.attributes["xmlns"] = globals.IQREGISTER
		instructions = query.addElement("instructions")
		ulang = utils.getLang(incoming)
		instructions.addContent(lang.get("registertext", ulang))
		userEl = query.addElement("username")
		passEl = query.addElement("password")
		
		# Check to see if they're registered
		source = internJID(incoming.getAttribute("from")).userhost()
		result = self.pytrans.xdb.getRegistration(source)
		if result:
			username, password = result
			if username != "local":
				userEl.addContent(username)
				query.addElement("registered")
		
		self.pytrans.send(reply)
Example #44
0
 def authContact(self, userHandle):
     LogEvent(INFO, self.session.jabberID)
     try:
         if userHandle in self.bos.authorizationRequests:
             self.bos.sendAuthorizationResponse(userHandle, True, "OK")
             self.bos.authorizationRequests.remove(userHandle)
     except AttributeError:
         self.alertUser(lang.get("sessionnotactive", config.jid))
Example #45
0
	def sendForm(self, el, sessionid=None, errormsg=None):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "aimuritranslate"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "executing"

		if errormsg:
			note = command.addElement("note")
			note.attributes["type"] = "error"
			note.addContent(errormsg)

		actions = command.addElement("actions")
		actions.attributes["execute"] = "complete"
		actions.addElement("complete")

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "form"

		title = x.addElement("title")
		title.addContent(lang.get("command_AIMURITranslate", ulang))

		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("command_AIMURITranslate_Instructions", ulang))

		email = x.addElement("field")
		email.attributes["type"] = "text-single"
		email.attributes["var"] = "uri"
		email.attributes["label"] = lang.get("command_AIMURITranslate_URI", ulang)

		self.pytrans.send(iq)
Example #46
0
 def sendInvite(self, chatroom, contact):
     LogEvent(INFO, self.session.jabberID)
     try:
         for c in self.bos.chats:
             if c.name.lower() == chatroom.lower():
                 self.bos.sendInvite(contact, c)
     except AttributeError:
         self.alertUser(lang.get("sessionnotactive", config.jid))
Example #47
0
 def connectionLost(self, reason):
     LogEvent(INFO, self.jabberID)
     if reason.type != error.ConnectionDone:
         text = lang.get(self.session.lang).msnDisconnected % reason
         self.session.sendMessage(to=self.jabberID,
                                  fro=config.jid,
                                  body=text)
     self.session.removeMe()  # Tear down the session
Example #48
0
	def getvCard(self, vcard, user):
		LogEvent(INFO, self.session.jabberID)
		try:
			d = defer.Deferred()
			self.bos.getProfile(user).addCallback(self.gotvCard, user, vcard, d).addErrback(self.gotnovCard, user, vcard, d)
			return d
		except AttributeError:
			self.alertUser(lang.get("sessionnotactive", config.jid))
Example #49
0
	def authContact(self, userHandle):
		LogEvent(INFO, self.session.jabberID)
		try:
			if userHandle in self.bos.authorizationRequests:
				self.bos.sendAuthorizationResponse(userHandle, True, "OK")
				self.bos.authorizationRequests.remove(userHandle)
		except AttributeError:
			self.alertUser(lang.get("sessionnotactive", config.jid))
Example #50
0
	def sendInvite(self, chatroom, contact):
		LogEvent(INFO, self.session.jabberID)
		try:
			for c in self.bos.chats:
				if c.name.lower() == chatroom.lower():
					self.bos.sendInvite(contact, c)
		except AttributeError:
			self.alertUser(lang.get("sessionnotactive", config.jid))
Example #51
0
	def incomingIq(self, el):
		to = el.getAttribute("from")
		fro = el.getAttribute("from")
		froj = internJID(fro)
		ID = el.getAttribute("id")
		if not hasattr(self.pytrans, "legacycon"):
			self.pytrans.iq.sendIqError(to=to, fro=config.jid, ID=ID, xmlns=globals.COMMANDS, etype="cancel", condition="service-unavailable")
		ulang = utils.getLang(el)

		if not self.pytrans.sessions.has_key(froj.userhost()):
			self.pytrans.iq.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns=globals.COMMANDS, etype="cancel", condition="service-unavailable")
			return
		s = self.pytrans.sessions[froj.userhost()]
		if not s.ready:
			self.pytrans.iq.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns=globals.COMMANDS, etype="cancel", condition="service-unavailable")
			return

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "retrieveroster"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_RosterRetrieval", ulang))

		reported = x.addElement("reported")
		reported.addChild(utils.makeDataFormElement(None, "legacyid", "Legacy ID"))
		reported.addChild(utils.makeDataFormElement(None, "nick", "Nickname"))

		entities = s.pytrans.xdb.getList("roster", s.jabberID)
		if entities != None:
			for e in entities:
				name = e[0]
				attrs = e[1]

				item = x.addElement("item")

				field = item.addElement("field")
				field.attributes["var"] = "legacyid"
				field.addElement("value").addContent(name)

				field = item.addElement("field")
				field.attributes["var"] = "nick"
				field.addElement("value").addContent(attrs.get('nickname',''))

		self.pytrans.send(iq)
Example #52
0
def addBatch():
	fileBrowser = xbmcgui.Dialog()
	file = fileBrowser.browse(
		browseTypes[ 'ShowAndGetFile' ] #type
		, lang.get( "Add_Batch_Browse_File_Header" ) #heading
		, "files" #shares
		, config.BatchFileTypeMask #mask
		, False #useThumbs
		, False #treatAsFolder
		, os.getcwd() + os.sep #default
	)
	if not os.path.isfile( file ): #the user cancelled the dialog
		return
	location = getSaveLocation( lang.get( "Add_Batch_Browse_Location_Header" ) )
	if location is None:
		return
	progress = xbmcgui.DialogProgress()
	progress.create( lang.get( "Add_Batch_Progress_Header" ) )
	result = act.processBatch( file, location, progress, lang )
	progress.close()
	if result[ 0 ] >= 0 and result[ 1 ] >= 0 and result[ 2 ] >= 0:
		dlg = xbmcgui.Dialog()
		ok( lang.get( "Add_Batch_Results_Header" )
			, lang.get( "Add_Batch_Results_Copied" ).replace( "{0}", str( result[ 0 ] ) )
			, lang.get( "Add_Batch_Results_Failed" ).replace( "{0}", str( result[ 1 ] ) )
			, lang.get( "Add_Batch_Results_Skipped" ).replace( "{0}", str( result[ 2 ] ) ) )
Example #53
0
 def gotInitialEmailNotification(self, inboxunread, foldersunread):
     if config.mailNotifications:
         LogEvent(INFO, self.jabberID)
         text = lang.get(self.session.lang).msnInitialMail % (inboxunread,
                                                              foldersunread)
         self.session.sendMessage(to=self.jabberID,
                                  fro=config.jid,
                                  body=text,
                                  mtype="headline")
Example #54
0
	def parseAndSearchForMood(self, title):
		LogEvent(INFO, self.session.jabberID)
		for key in MOODS:
			title_lo = title.lower().replace('_', ' ')
			native_lo = lang.get(key).lower().replace('_', ' ')
			intern_lo = MOODS[key].replace('_', ' ')
			if title_lo.find(intern_lo) != -1 or title_lo.find(native_lo) != -1:
				return MOODS[key]
		return None
Example #55
0
 def gotRealtimeEmailNotification(self, mailfrom, fromaddr, subject):
     if config.mailNotifications:
         LogEvent(INFO, self.jabberID)
         text = lang.get(self.session.lang).msnRealtimeMail % (
             mailfrom, fromaddr, subject)
         self.session.sendMessage(to=self.jabberID,
                                  fro=config.jid,
                                  body=text,
                                  mtype="headline")
Example #56
0
 def leaveChat(self, chatroom):
     LogEvent(INFO, self.session.jabberID)
     try:
         for c in self.bos.chats:
             if c.name == chatroom:
                 c.leaveChat()
                 self.bos.chats.remove(c)
                 break
     except AttributeError:
         self.alertUser(lang.get("sessionnotactive", config.jid))
Example #57
0
 def getvCard(self, vcard, user):
     LogEvent(INFO, self.session.jabberID)
     try:
         d = defer.Deferred()
         self.bos.getProfile(user).addCallback(self.gotvCard, user, vcard,
                                               d).addErrback(
                                                   self.gotnovCard, user,
                                                   vcard, d)
         return d
     except AttributeError:
         self.alertUser(lang.get("sessionnotactive", config.jid))