def test_add_contacts(self): me = self.build_me() cloud = self.build_cloud() accounts = { CLOUD_ACCOUNT: e3.Contact(CLOUD_ACCOUNT, cid="2"), ME_ACCOUNT: e3.Contact(ME_ACCOUNT, cid="1") } logger.add_contacts(accounts) time.sleep(1) self.assertEquals(len(logger.logger.accounts), 2)
def _log_message(self, message, error=False): # log the message contact = self.session.contacts.me src = e3.Logger.Account(contact.attrs.get('CID', None), None, contact.account, contact.status, contact.nick, contact.message, contact.picture) # we remove the content type part since it's always equal msgstr = message.format().split('\r\n', 1)[1] # remove the Content-type, X-MMS-IM-Format and TypingUser msgstr = msgstr.replace('Content-Type: ', '') msgstr = msgstr.replace('X-MMS-IM-Format: ', '') msgstr = msgstr.replace('TypingUser: '******'') if error: event = 'message-error' else: event = 'message' for dst_account in self.members: dst = self.session.contacts.get(dst_account) if dst is None: dst = e3.Contact(message.account) dest = e3.Logger.Account(dst.attrs.get('CID', None), None, dst.account, dst.status, dst.nick, dst.message, dst.picture) self.session.logger.log(event, contact.status, msgstr, src, dest)
def _on_presence(self, presence): '''handle the reception of a presence message''' message = presence['status'] show = presence.get_type() account = presence.get_from().bare stat = STATUS_MAP_REVERSE.get(show, e3.status.ONLINE) contact = self.session.contacts.contacts.get(account, None) if not contact: contact = e3.Contact(account) self.session.contacts.contacts[account] = contact old_message = contact.message old_status = contact.status contact.message = message contact.status = stat log_account = e3.Logger.Account(contact.cid, None, contact.account, contact.status, contact.nick, contact.message, contact.picture) if old_status != stat: self.session.contact_attr_changed(account, 'status', old_status) self.session.log('status change', stat, str(stat), log_account) if old_message != contact.message: self.session.contact_attr_changed(account, 'message', old_message) self.session.log('message change', contact.status, contact.message, log_account)
def _session_started(self): categories_dict = {} default_group = e3.Group('Friends', 'Friends') group_group = e3.Group('Groups', 'Groups') categories_dict[0] = default_group categories_dict[-1] = group_group for index in self.res_manager.categories: key = index.key() group = e3.Group(self.res_manager.categories[key].name, key) categories_dict[key] = group for uin in self.res_manager.contacts: key = uin.key() #nick = self.res_manager.contacts[uin].nick _status = e3.status.OFFLINE try: if not self.res_manager.contacts[key].status == '': _status = STATUS_MAP_REVERSE[ self.res_manager.contacts[key].status] except KeyError, e: _stauts = e3.status.ONLINE contact = e3.Contact(account=key, identifier=str(key), message=self.res_manager.contacts[key].lnick, _status=_status, blocked=False, cid=key) index = self.res_manager.contacts[key].cate_index group = categories_dict[index] self._add_contact_to_group(contact, group.name) self.session.contacts.contacts[key] = contact
def _on_chats_ready(self, results): '''called when the chat history is ready''' if not results: return for stat, timestamp, msg_text, nick, account in results: contact = founded_account = self.session.contacts.get(account) if contact == None: contact = e3.Contact(account, nick=nick) is_me = self.session.contacts.me.account == account datetimestamp = datetime.datetime.fromtimestamp(timestamp) if is_me: self.text.send_message(self.formatter, contact, msg_text, None, None, None, self.first) else: message = e3.Message(e3.Message.TYPE_MESSAGE, msg_text, account, timestamp=datetimestamp) self.text.receive_message(self.formatter, contact, message, None, None, self.first) self.first = False
def on_receive_message(self, message, account, received_custom_emoticons): '''method called when a message arrives to the conversation''' contact = self.session.contacts.get(account) if contact is None: contact = e3.Contact(account) if message.type == e3.Message.TYPE_MESSAGE or message.type == e3.Message.TYPE_FLNMSG: if self.session.config.b_override_text_color: message.style.color = e3.base.Color.from_hex( self.session.config.override_text_color) user_emcache = self.caches.get_emoticon_cache(account) self.output.receive_message(self.formatter, contact, message, received_custom_emoticons, user_emcache.path, self.first) self.play_type() elif message.type == e3.Message.TYPE_NUDGE: self.output.information( self.formatter, contact, _('%s just sent you a nudge!') % (contact.display_name, )) self.play_nudge() self.first = False
def _on_chats_ready(self, results): '''called when the chat history is ready''' self.conversation.conv_status.clear() if not results: self.conversation.output.unlock() return for stat, timestamp, msg_text, nick, account in results: is_me = self.session.contacts.me.account == account if is_me: contact = self.session.contacts.me else: contact = self.session.contacts.get(account) if contact == None: contact = e3.Contact(account, nick=nick) datetimestamp = datetime.datetime.utcfromtimestamp(timestamp) message = e3.Message(e3.Message.TYPE_OLDMSG, msg_text, account, timestamp=datetimestamp) message.style = self.conversation.cstyle if is_me: self.conversation.output_message(message, None) else: self.conversation.input_message(message, contact, None, None) self.conversation.conv_status.clear() self.conversation.output.unlock()
def _session_started(self, event): '''Process the session_start event''' self.client.get_roster(block=True) self.client.send_presence() for jid in self.client.client_roster.keys(): state = self.client.client_roster[jid] if jid == self.session.account.account: self.session.contacts.me.nick = state['name'] self.session.nick_change_succeed(state['name']) continue if jid in self.session.contacts.contacts: contact = self.session.contacts.contacts[jid] else: contact = e3.Contact(jid, jid) self.session.contacts.contacts[jid] = contact avatars = self.session.caches.get_avatar_cache(jid) if 'last' in avatars: contact.picture = os.path.join(avatars.path, 'last') contact.nick = state['name'] #TODO: Support other infos like groups, etc. # account, identifier=None, nick='', message=None, # _status=status.OFFLINE, alias='', blocked=False, cid=None for group in state['groups']: self._add_contact_to_group(contact, group) self.session.login_succeed() self.session.contact_list_ready()
def on_receive_message(self, message, account, received_custom_emoticons): '''method called when a message arrives to the conversation''' contact = self.session.contacts.get(account) if contact is None: contact = e3.Contact(account) if message.type == e3.Message.TYPE_MESSAGE or message.type == e3.Message.TYPE_FLNMSG: if self.session.config.b_override_text_color: message.style.color = e3.base.Color.from_hex( self.session.config.override_text_color) user_emcache = self.caches.get_emoticon_cache(account) self.input_message(message, contact, received_custom_emoticons, user_emcache.path) self.play_type() elif message.type == e3.Message.TYPE_NUDGE: message.body = _('%s just sent you a nudge!') % ( contact.display_name, ) msg = gui.Message.from_information(contact, message) self.output.information(self.formatter, msg) self.conv_status.post_process_message(msg) self.play_nudge() self.conv_status.update_status()
def _on_chats_ready(self, results): '''called when the chat history is ready''' account_colors = {} style = e3.Style() font_color_default = style.color.to_hex() possible_colors = [ "#0000FF", "#00FFFF", "#FF0000", "#FF00FF", font_color_default ] if not results: return self.conv_status.clear() for stat, timestamp, msg_text, nick, account in results: is_me = self.session.contacts.me.account == account if is_me: contact = self.session.contacts.me else: contact = self.session.contacts.get(account) if contact == None: contact = e3.Contact(account, nick=nick) datetimestamp = datetime.datetime.utcfromtimestamp(timestamp) message = e3.Message(e3.Message.TYPE_OLDMSG, msg_text, account, timestamp=datetimestamp) if is_me: msg = self.conv_status.pre_process_message( contact, message, False, None, None, message.timestamp, message.type, None) self.text.send_message(self.formatter, msg) else: try: account_colors[account] except KeyError: if not len(possible_colors) == 0: account_colors[account] = possible_colors.pop() else: account_colors[account] = font_color_default message.style = self._get_style(account_colors[account]) msg = self.conv_status.pre_process_message( contact, message, True, None, None, message.timestamp, message.type, message.style) self.text.receive_message(self.formatter, msg) self.conv_status.post_process_message(msg) self.conv_status.update_status() if len(results) >= 1000: self.nicebar.new_message(_('Too many messages to display'), gtk.STOCK_DIALOG_WARNING)
def _handle_action_login(self, account, password, status_, host, port): '''handle Action.ACTION_LOGIN ''' self.my_avatars = self.caches.get_avatar_cache( self.session.account.account) try: if self.client.connect((host, int(port)), proxy=self.proxy_data) == "": self.session.login_failed('Connection error') return except xmpp.protocol.HostUnknown: self.session.login_failed('Connection error') return if self.client.auth(self.jid.getNode(), self.session.account.password) == None: self.session.login_failed('Authentication error') return self.session.login_succeed() self.start_time = time.time() self.client.RegisterHandler('message', self._on_message) self.client.RegisterHandler('presence', self._on_presence) self.client.RegisterHandler('presence', self._on_photo_update) self.client.sendInitPresence() while self.client.Process(1) != '0': pass self.roster = self.client.getRoster() for account in self.roster.getItems(): name = self.roster.getName(account) if account == self.session.account.account: if name is not None: self.session.contacts.me.nick = name self.session.nick_change_succeed(name) continue if account in self.session.contacts.contacts: contact = self.session.contacts.contacts[account] else: contact = e3.Contact(account, cid=account) self.session.contacts.contacts[account] = contact if name is not None: contact.nick = name self.session.contact_list_ready() self._change_status(status_)
def handle_response(self, request, response): '''handle the response''' if response.status == 200: self.command_queue.put(Command('ADL', payload=common.build_adl(self.account, 1))) self.command_queue.put(Command('ADL', payload=common.build_adl(self.account, 2))) self.session.contacts.contacts[self.account] = e3.Contact(self.account) self.session.add_event(e3.Event.EVENT_CONTACT_ADD_SUCCEED, self.account) else: self.session.add_event(e3.Event.EVENT_CONTACT_ADD_FAILED, self.account)
def test_account_from_contact(self): contact = e3.Contact(ME_ACCOUNT, "1", "nick", "message", e3.status.BUSY, "alias", cid="1") contact.picture = "picture" account = e3.Logger.Account.from_contact(contact) self.assertEquals(contact.account, account.account) self.assertEquals(contact.cid, account.id) self.assertEquals(contact.status, account.status) self.assertEquals(contact.nick, account.nick) self.assertEquals(contact.message, account.message) self.assertEquals(contact.picture, account.path)
def _on_message(self, command): '''handle the message''' message = MsnMessage.Message.parse(command) # TODO: nudge and file transfer invitations goes here too if (message.type == MsnMessage.Message.TYPE_MESSAGE or \ message.type == MsnMessage.Message.TYPE_NUDGE) and \ not self.first_action: self.first_action = True self.session.add_event(e3.Event.EVENT_CONV_FIRST_ACTION, self.cid, self.members[:]) if message.type == MsnMessage.Message.TYPE_MESSAGE or \ message.type == MsnMessage.Message.TYPE_TYPING or \ message.type == MsnMessage.Message.TYPE_NUDGE: self.session.add_event(e3.Event.EVENT_CONV_MESSAGE, self.cid, message.account, message) # log the message if message.type != MsnMessage.Message.TYPE_TYPING: contact = self.session.contacts.get(message.account) if contact is None: contact = e3.Contact(message.account) src = e3.Logger.Account(contact.attrs.get('CID', None), None, contact.account, contact.status, contact.nick, contact.message, contact.picture) dst = self.session.contacts.me dest = e3.Logger.Account(dst.attrs.get('CID', None), None, dst.account, dst.status, dst.nick, dst.message, dst.picture) # we remove the content type part since it's always equal msgstr = message.format().split('\r\n', 1)[1] # remove the Content-type, X-MMS-IM-Format and TypingUser # XXX WHAT THE HELL msgstr = msgstr.replace('Content-Type: ', '') msgstr = msgstr.replace('X-MMS-IM-Format: ', '') msgstr = msgstr.replace('TypingUser: '******'') self.session.logger.log('message', contact.status, msgstr, src, dest) elif message.type == MsnMessage.Message.TYPE_P2P and \ message.dest == self.account and \ len(self.members) == 0: self.p2p_input.put( (p2p.Manager.ACTION_INPUT, self.members[0], message))
def _handle_action_login(self, account, password, status_, host, port): '''handle Action.ACTION_LOGIN ''' if self.client.connect((host, int(port)), proxy=self.proxy_data) == "": self.session.add_event(e3.Event.EVENT_LOGIN_FAILED, 'Connection error') return if self.client.auth(self.jid.getNode(), self.session.account.password) == None: self.session.add_event(e3.Event.EVENT_LOGIN_FAILED, 'Authentication error') return self.session.add_event(e3.Event.EVENT_LOGIN_SUCCEED) self.start_time = time.time() self.client.RegisterHandler('message', self._on_message) self.client.RegisterHandler('presence', self._on_presence) self.client.sendInitPresence() while self.client.Process(1) != '0': pass self.roster = self.client.getRoster() for account in self.roster.getItems(): name = self.roster.getName(account) if account == self.session.account.account: if name is not None: self.session.contacts.me.nick = name self.session.add_event(e3.Event.EVENT_NICK_CHANGE_SUCCEED, nick) continue if account in self.session.contacts.contacts: contact = self.session.contacts.contacts[account] else: contact = e3.Contact(account) self.session.contacts.contacts[account] = contact if name is not None: contact.nick = name self.session.add_event(e3.Event.EVENT_CONTACT_LIST_READY) self._change_status(status_)
def _on_presence(self, client, presence): '''handle the reception of a presence message''' message = presence.getStatus() or '' show = presence.getShow() type_ = presence.getType() account = presence.getFrom().getStripped() stat = STATUS_MAP_REVERSE.get(show, e3.status.ONLINE) contact = self.session.contacts.contacts.get(account, None) if not contact: contact = e3.Contact(account) self.session.contacts.contacts[account] = contact old_message = contact.message old_status = contact.status contact.message = message contact.status = stat log_account = e3.Logger.Account(contact.attrs.get('CID', None), None, contact.account, contact.status, contact.nick, contact.message, contact.picture) if old_status != stat: change_type = 'status' if old_status == e3.status.OFFLINE: change_type = 'online' if stat == e3.status.OFFLINE: change_type = 'offline' do_notify = (self.start_time + Worker.NOTIFICATION_DELAY) < \ time.time() self.session.add_event(e3.Event.EVENT_CONTACT_ATTR_CHANGED, account, change_type, old_status, do_notify) self.session.logger.log('status change', stat, str(stat), log_account) if old_message != contact.message: self.session.add_event(e3.Event.EVENT_CONTACT_ATTR_CHANGED, account, 'message', old_message) self.session.logger.log('message change', contact.status, contact.message, log_account)
def _on_chats_ready(self, results): '''called when the chat history is ready''' account_colors = {} style = e3.Style() font_color_default = style.color.to_hex() possible_colors = ["#0000FF", "#00FFFF", "#FF0000", "#FF00FF", font_color_default] if not results: return for stat, timestamp, msg_text, nick, account in results: is_me = self.session.contacts.me.account == account if is_me: contact = self.session.contacts.me else: contact = self.session.contacts.get(account) if contact == None: contact = e3.Contact(account, nick=nick) datetimestamp = datetime.datetime.utcfromtimestamp(timestamp) message = e3.Message(e3.Message.TYPE_MESSAGE, msg_text, account, timestamp=datetimestamp) if is_me: self.text.send_message(self.formatter, contact, message, None, None, self.first) else: try: account_colors[account] except KeyError: if not len(possible_colors) == 0: account_colors[account] = possible_colors.pop() else: account_colors[account] = font_color_default message.style = self._get_style(account_colors[account]) self.text.receive_message(self.formatter, contact, message, None, None, self.first) self.first = False
def on_receive_message(self, message, account, cedict): '''method called when a message arrives to the conversation''' contact = self.session.contacts.get(account) if contact is None: contact = e3.Contact(account) if message.type == e3.Message.TYPE_MESSAGE: self.output.receive_message(self.formatter, contact, message, cedict, self.first) self.play_send() elif message.type == e3.Message.TYPE_NUDGE: self.output.information( self.formatter, contact, '%s just sent you a nudge!' % (contact.display_name, )) self.play_nudge() self.first = False
def _start_from_cache(self): '''try to send the adl with the data from cache''' logger = self.session.logger.logger if len(logger.accounts) < 2: return False # thread madness I should be careful to not modify accounts while # iterating for (account, contact) in logger.accounts.items(): new_contact = e3.Contact(account, contact.cid, contact.nick, contact.message) new_contact.groups = contact.groups[:] self.session.contacts.contacts[account] = new_contact for (gid, group) in logger.groups.iteritems(): new_group = e3.Group(group.name, gid) new_group.contacts = group.accounts[:] self.session.groups[gid] = new_group nick = my_account = self.session.account.account account_info = logger.accounts.get(my_account, None) if account_info: if account_info.nick: nick = account_info.nick else: nick = my_account nick = nick.decode('utf-8', 'replace').encode('utf-8') self.socket.send_command('PRP', ('MFN', urllib.quote(nick))) self.session.add_event(e3.Event.EVENT_NICK_CHANGE_SUCCEED, nick) self.socket.send_command('BLP', ('BL', )) for adl in self.session.contacts.get_adls(): self.socket.send_command('ADL', payload=adl) self.session.add_event(e3.Event.EVENT_CONTACT_LIST_READY) return True
def _on_presence(self, client, presence): '''handle the reception of a presence message''' message = presence.getStatus() or '' show = presence.getShow() account = presence.getFrom().getStripped() if show == None: show = presence.getAttrs().get('type', 'chat') stat = STATUS_MAP_REVERSE.get(show, e3.status.ONLINE) contact = self.session.contacts.contacts.get(account, None) if not contact: contact = e3.Contact(account) self.session.contacts.contacts[account] = contact old_message = contact.message old_status = contact.status contact.message = message contact.status = stat log_account = e3.Logger.Account(contact.cid, None, contact.account, contact.status, contact.nick, contact.message, contact.picture) if old_status != stat: do_notify = (self.start_time + Worker.NOTIFICATION_DELAY) < \ time.time() self.session.contact_attr_changed(account, 'status', old_status, do_notify) self.session.log('status change', stat, str(stat), log_account) if old_message != contact.message: self.session.contact_attr_changed(account, 'message', old_message) self.session.log('message change', contact.status, contact.message, log_account)
def _on_presence(self, presence): '''handle the reception of a presence message''' message = presence['status'] show = presence.get_type() account = presence.get_from().bare #TODO: ask for vcard only when vcard-temp:x:update and photo are # in presence (?) self.client.plugin['xep_0054'].get_vcard(jid=presence.get_from(), block=False, callback=self._on_vcard_get) stat = STATUS_MAP_REVERSE.get(show, e3.status.ONLINE) contact = self.session.contacts.contacts.get(account, None) if not contact: contact = e3.Contact(account) self.session.contacts.contacts[account] = contact old_message = contact.message old_status = contact.status contact.message = message contact.status = stat log_account = e3.Logger.Account(contact.cid, None, contact.account, contact.status, contact.nick, contact.message, contact.picture) if old_status != stat: self.session.contact_attr_changed(account, 'status', old_status) self.session.log('status change', stat, str(stat), log_account) if old_message != contact.message: self.session.contact_attr_changed(account, 'message', old_message) self.session.log('message change', contact.status, contact.message, log_account)
def log_message(session, members, message, sent, error=False, cid=None): '''log a message, session is an e3.Session object, members is a list of members only used if sent is True, sent is True if we sent the message, False if we received the message. error is True if the message send failed''' if not session.config.get_or_set('b_log_enabled', True): return if message.type == e3.Message.TYPE_TYPING: return if error: event = 'message-error' else: event = 'message' if sent: contact = session.contacts.me status = contact.status src = e3.Logger.Account.from_contact(session.contacts.me) if message.type == e3.Message.TYPE_NUDGE: message.body = _("You just sent a nudge!") logs = [] if len(members) == 1: member = members[0] dst = session.contacts.safe_get(members[0]) dest = e3.Logger.Account.from_contact(dst) logs.append((event, status, message.body, src, dest, cid)) session.logger.logs(logs) else: for dst_account in members: dst = session.contacts.safe_get(dst_account) dest = e3.Logger.Account.from_contact(dst) logs.append((event, status, message.body, src, dest, cid)) session.logger.logs(logs) else: dest = e3.Logger.Account.from_contact(session.contacts.me) contact = session.contacts.get(message.account) if contact is None: src = e3.Contact(message.account) status = e3.status.OFFLINE display_name = message.account else: src = e3.Logger.Account.from_contact(contact) status = contact.status display_name = contact.display_name if message.type == e3.Message.TYPE_NUDGE: message.body = _("%s just sent you a nudge!" % display_name) session.log(event, status, message.body, src, dest, cid=cid)
def handle_response(self, request, response): '''handle the response''' if response.status == 200: parser = XmlParser.MembershipParser(response.body) self.session.contacts.pending = {} self.session.contacts.reverse = {} pending = self.session.contacts.pending reverse = self.session.contacts.reverse contacts = self.session.contacts.contacts new_accounts = [] for membership in parser.memberships: role = membership['MemberRole'] for member in membership['Members']: if 'PassportName' in member: email = member['PassportName'].lower() else: continue if email in contacts: contact = contacts[email] else: contact = e3.Contact(email) if role == 'Pending': pending[email] = contact contact.attrs['pending'] = True if 'DisplayName' in member: contact.nick = member['DisplayName'] if role == 'Reverse': reverse[email] = contact contact.attrs['Reverse'] = True if role == 'Allow': new_accounts.append(email) contacts[email] = contact if role == 'Block': contact.blocked = True else: contact.blocked = False if 'CID' in member: contact.cid = member['CID'] all_accounts = set(contacts.keys()) removed_accounts = all_accounts.difference(new_accounts) for email in removed_accounts: # TODO: send some kind of signal to inform to remove the # contact del contacts[email] DynamicItems(self.session, self.command_queue, self.on_login, self.started_from_cache).start() else: log.debug('error requesting membership ' + response.status) log.debug(response.body)
def handle_response(self, request, response): '''handle the response''' if response.status == 200: parser = XmlParser.DynamicParser(response.body) # Retrieve groups for group_dict in parser.groups: group_id = group_dict['groupId'] group_name = group_dict['name'] if group_id in self.session.groups: self.session.groups[group_id].name = group_name else: self.session.groups[group_id] = \ e3.Group(group_name, group_id) # Retrieve contacts for contact_dict in parser.contacts: if 'isMessengerUser' in contact_dict \ and 'passportName' in contact_dict \ and contact_dict['isMessengerUser'] == 'true': # valid email = contact_dict['passportName'].lower() if email in self.session.contacts.contacts: contact = self.session.contacts.contacts[email] else: contact = e3.Contact(email) self.session.contacts.contacts[email] = contact else: continue contact.identifier = contact_dict.get('contactId', '') contact.cid = contact_dict.get('CID', '') contact.groups = [] for guid in contact_dict['groupIds']: contact.groups.append(guid) group = self.session.groups[guid] if contact.account not in group.contacts: group.contacts.append(contact.account) for ann in contact_dict['Annotations']: if ann.get('Name', None) == 'AB.NickName': contact.alias = urllib.unquote(ann['Value']) break if not contact.nick: contact.nick = urllib.unquote(contact_dict.get( 'displayName', contact.account)) contact.attrs['mobile'] = \ contact_dict.get('isMobileIMEnabled', None) == 'true' contact.attrs['space'] = \ contact_dict.get('hasSpace', None) == 'true' log.debug('dynamic finished') self.session.contacts.me.identifier = \ response.body.split('<contactType>Me</contactType>')\ [1].split('</CID>')[0].split('<CID>')[1].strip() # get our nick try: nick = response.body.split('<contactType>Me</contactType>')\ [1].split('</displayName>')[0].split('<displayName>')[1] nick = common.unescape(nick) except IndexError: nick = self.session.contacts.me.account if not self.session.contacts.me.nick or \ self.session.contacts.me != self.session.account.account: self.session.contacts.me.nick = nick if self.on_login: # set our nick self.command_queue.put(Command('PRP', params=('MFN', urllib.quote(nick)))) self.session.add_event(e3.Event.EVENT_NICK_CHANGE_SUCCEED, nick) if not self.started_from_cache: self.command_queue.put(Command('BLP', params=('BL',))) accounts = self.session.contacts.pending.keys() for account in accounts: # account in pending that is already on some other role # (corrupted userlist) if account in self.session.contacts.contacts or account in self.session.contacts.reverse: del self.session.contacts.pending[account] # this line doen't work for accounts on corrupted userlists # RemovePendingContact(self.session, account).start() self.session.add_event(e3.Event.EVENT_CONTACT_LIST_READY) self.session.logger.add_contact_by_group( self.session.contacts.contacts, self.session.groups) if not self.started_from_cache: for adl in self.session.contacts.get_adls(): self.command_queue.put(Command('ADL', payload=adl)) GetProfile(self.session, self.session.contacts.me.identifier).start() else: log.debug('error requestion dynamic items')
def _add_contact(self, mail, nick, status_, alias, blocked): """ method to add a contact to the contact list """ self.session.contacts.contacts[mail] = e3.Contact(mail, mail, nick, '...', status_, alias, blocked)
_status=_status, blocked=False, cid=key) index = self.res_manager.contacts[key].cate_index group = categories_dict[index] self._add_contact_to_group(contact, group.name) self.session.contacts.contacts[key] = contact for group_id in self.res_manager.groups: group_id_key = group_id.key() _status = e3.status.ONLINE contact = e3.Contact( account=group_id_key, identifier=str(group_id_key), nick=self.res_manager.groups[group_id_key].name, message=self.res_manager.groups[group_id_key].memo, _status=_status, blocked=False, cid=group_id_key) self._add_contact_to_group(contact, group_group.name) self.session.contacts.contacts[group_id_key] = contact ''' for uins in self.res_manager.group_contacts[group_id_key]: uin_key = uins.key() buddy = self.res_manager.group_contacts[group_id_key][uin_key] uin = buddy.uin _status = e3.status.ONLINE contact = e3.Contact(account = uin, identifier = str(uin), nick = buddy.nick, message = buddy.lnick , _status = _status, blocked = False, cid = uin) #self.session.contacts.contacts[uin] = contact '''