Changeset 8709 for branches/gajim_0.11.1/src
- Timestamp:
- 09/04/07 20:32:31 (15 months ago)
- Location:
- branches/gajim_0.11.1/src
- Files:
-
- 6 modified
-
chat_control.py (modified) (1 diff)
-
common/connection_handlers.py (modified) (9 diffs)
-
gajim.py (modified) (3 diffs)
-
groupchat_control.py (modified) (7 diffs)
-
roster_window.py (modified) (2 diffs)
-
vcard.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11.1/src/chat_control.py
r8683 r8709 1589 1589 return 1590 1590 1591 jid = self.contact.jid 1592 jid_with_resource = jid 1593 if resource: 1594 jid_with_resource += '/' + resource 1591 is_fake = False 1592 if self.TYPE_ID == message_control.TYPE_PM: 1593 is_fake = True 1594 jid_with_resource = self.contact.jid # fake jid 1595 else: 1596 jid_with_resource = self.contact.jid 1597 if resource: 1598 jid_with_resource += '/' + resource 1595 1599 1596 1600 # we assume contact has no avatar 1597 1601 scaled_pixbuf = None 1598 1602 1599 pixbuf = None1600 is_fake = False1601 if gajim.contacts.is_pm_from_jid(self.account, jid):1602 is_fake = True1603 1603 pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid_with_resource, 1604 1604 is_fake) 1605 1605 if pixbuf == 'ask': 1606 1606 # we don't have the vcard 1607 gajim.connections[self.account].request_vcard(jid_with_resource, 1608 is_fake) 1607 if self.TYPE_ID == message_control.TYPE_PM: 1608 if self.gc_contact.jid: 1609 # We know the real jid of this contact 1610 real_jid = self.gc_contact.jid 1611 if self.gc_contact.resource: 1612 real_jid += '/' + self.gc_contact.resource 1613 else: 1614 real_jid = jid_with_resource 1615 gajim.connections[self.account].request_vcard(real_jid, 1616 jid_with_resource) 1617 else: 1618 gajim.connections[self.account].request_vcard(jid_with_resource) 1609 1619 return 1610 1620 if pixbuf is not None: -
branches/gajim_0.11.1/src/common/connection_handlers.py
r8699 r8709 797 797 self.vcard_shas = {} # sha of contacts 798 798 self.room_jids = [] # list of gc jids so that vcard are saved in a folder 799 self.groupchat_jids = {} # {ID : groupchat_jid} 799 800 800 801 def add_sha(self, p, send_caps = True): … … 895 896 return vcard 896 897 897 def request_vcard(self, jid = None, is_fake_jid = False): 898 '''request the VCARD. If is_fake_jid is True, it means we request a vcard 899 to a fake jid, like in private messages in groupchat''' 898 def request_vcard(self, jid = None, groupchat_jid = None): 899 '''request the VCARD. If groupchat_jid is not nul, it means we request a vcard 900 to a fake jid, like in private messages in groupchat. jid can be the 901 real jid of the contact, but we want to consider it comes from a fake jid''' 900 902 if not self.connection: 901 903 return … … 910 912 if not j: 911 913 j = gajim.get_jid_from_account(self.name) 912 self.awaiting_answers[id] = (VCARD_ARRIVED, j )913 if is_fake_jid:914 room_jid, nick = gajim.get_room_and_nick_from_fjid( jid)914 self.awaiting_answers[id] = (VCARD_ARRIVED, j, groupchat_jid) 915 if groupchat_jid: 916 room_jid, nick = gajim.get_room_and_nick_from_fjid(groupchat_jid) 915 917 if not room_jid in self.room_jids: 916 918 self.room_jids.append(room_jid) 919 self.groupchat_jids[id] = groupchat_jid 917 920 self.connection.send(iq) 918 #('VCARD', {entry1: data, entry2: {entry21: data, ...}, ...})919 921 920 922 def send_vcard(self, vcard): … … 999 1001 # it knows it arrived 1000 1002 jid = self.awaiting_answers[id][1] 1003 groupchat_jid = self.awaiting_answers[id][2] 1004 frm = jid 1005 if groupchat_jid: 1006 # We do as if it comes from the fake_jid 1007 frm = groupchat_jid 1001 1008 our_jid = gajim.get_jid_from_account(self.name) 1002 1009 if iq_obj.getType() == 'error' and jid == our_jid: … … 1004 1011 self.vcard_supported = False 1005 1012 if not iq_obj.getTag('vCard') or iq_obj.getType() == 'error': 1006 if jid and jid!= our_jid:1013 if frm and frm != our_jid: 1007 1014 # Write an empty file 1008 self.save_vcard_to_hd( jid, '')1009 self.dispatch('VCARD', {'jid': jid})1010 elif jid== our_jid:1011 self.dispatch('MYVCARD', {'jid': jid})1015 self.save_vcard_to_hd(frm, '') 1016 self.dispatch('VCARD', {'jid': frm}) 1017 elif frm == our_jid: 1018 self.dispatch('MYVCARD', {'jid': frm}) 1012 1019 elif self.awaiting_answers[id][0] == AGENT_REMOVED: 1013 1020 jid = self.awaiting_answers[id][1] … … 1052 1059 if not vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD: 1053 1060 return 1061 id = vc.getID() 1054 1062 frm_iq = vc.getFrom() 1055 1063 our_jid = gajim.get_jid_from_account(self.name) 1056 1064 resource = '' 1057 if frm_iq: 1065 if id in self.groupchat_jids: 1066 who = self.groupchat_jids[id] 1067 frm, resource = gajim.get_room_and_nick_from_fjid(who) 1068 del self.groupchat_jids[id] 1069 elif frm_iq: 1058 1070 who = helpers.get_full_jid_from_iq(vc) 1059 1071 frm, resource = gajim.get_room_and_nick_from_fjid(who) … … 1127 1139 self.connection.send(p) 1128 1140 else: 1141 #('VCARD', {entry1: data, entry2: {entry21: data, ...}, ...}) 1129 1142 self.dispatch('VCARD', vcard) 1130 1143 … … 1655 1668 if gajim.config.get('log_contact_status_changes') and self.name\ 1656 1669 not in no_log_for and jid_stripped not in no_log_for: 1657 gc_c = gajim.contacts.get_gc_contact(self.name, jid_stripped, resource) 1670 gc_c = gajim.contacts.get_gc_contact(self.name, jid_stripped, 1671 resource) 1658 1672 st = status or '' 1659 1673 if gc_c: … … 1673 1687 puny_nick = helpers.sanitize_filename(resource) 1674 1688 gajim.interface.remove_avatar_files(jid_stripped, puny_nick) 1675 if self.vcard_shas.has_key(who): # Verify sha cached in mem 1676 if avatar_sha != self.vcard_shas[who]: 1677 # avatar has been updated 1678 self.request_vcard(who, True) 1679 else: # Verify sha cached in hdd 1680 cached_vcard = self.get_cached_vcard(who, True) 1681 if cached_vcard and cached_vcard.has_key('PHOTO') and \ 1682 cached_vcard['PHOTO'].has_key('SHA'): 1683 cached_sha = cached_vcard['PHOTO']['SHA'] 1684 else: 1685 cached_sha = '' 1686 if cached_sha != avatar_sha: 1687 # avatar has been updated 1688 # sha in mem will be updated later 1689 self.request_vcard(who, True) 1690 else: 1691 # save sha in mem NOW 1692 self.vcard_shas[who] = avatar_sha 1689 # if it's a gc presence, don't ask vcard here. We may ask it to 1690 # real jid in gui part. 1693 1691 self.dispatch('GC_NOTIFY', (jid_stripped, show, status, resource, 1694 1692 prs.getRole(), prs.getAffiliation(), prs.getJid(), 1695 1693 prs.getReason(), prs.getActor(), prs.getStatusCode(), 1696 prs.getNewNick() ))1694 prs.getNewNick(), avatar_sha)) 1697 1695 return 1698 1696 -
branches/gajim_0.11.1/src/gajim.py
r8700 r8709 759 759 gc_c = gajim.contacts.create_gc_contact(room_jid = jid, 760 760 name = nick, show = show) 761 c = gajim.contacts.contact_from_gc_contact(gc_c) 762 self.roster.new_chat(c, account, private_chat = True) 761 self.roster.new_private_chat(gc_c, account) 763 762 ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account) 764 763 ctrl.print_conversation('Error %s: %s' % (array[1], array[2]), … … 1001 1000 def handle_event_gc_notify(self, account, array): 1002 1001 #'GC_NOTIFY' (account, (room_jid, show, status, nick, 1003 # role, affiliation, jid, reason, actor, statusCode, newNick ))1002 # role, affiliation, jid, reason, actor, statusCode, newNick, avatar_sha)) 1004 1003 nick = array[3] 1005 1004 if not nick: … … 1017 1016 if control: 1018 1017 control.chg_contact_status(nick, show, status, array[4], array[5], 1019 array[6], array[7], array[8], array[9], array[10] )1018 array[6], array[7], array[8], array[9], array[10], array[11]) 1020 1019 1021 1020 # print status in chat window and update status/GPG image -
branches/gajim_0.11.1/src/groupchat_control.py
r8696 r8709 104 104 TYPE_ID = message_control.TYPE_PM 105 105 106 def __init__(self, parent_win, contact, acct):106 def __init__(self, parent_win, gc_contact, contact, acct): 107 107 room_jid = contact.jid.split('/')[0] 108 108 room_ctrl = gajim.interface.msg_win_mgr.get_control(room_jid, acct) 109 109 self.room_name = room_ctrl.name 110 self.gc_contact = gc_contact 110 111 ChatControl.__init__(self, parent_win, contact, acct) 111 112 self.TYPE_ID = 'pm' … … 826 827 827 828 def chg_contact_status(self, nick, show, status, role, affiliation, jid, 828 reason, actor, statusCode, new_nick ):829 reason, actor, statusCode, new_nick, avatar_sha, tim = None): 829 830 '''When an occupant changes his or her status''' 830 831 if show == 'invisible': … … 835 836 if not affiliation: 836 837 affiliation = 'none' 837 838 fake_jid = self.room_jid + '/' + nick 838 839 newly_created = False 839 840 if show in ('offline', 'error'): … … 896 897 self.print_conversation(s, 'info') 897 898 898 if len(gajim.events.get_events(self.account, 899 self.room_jid + '/' + nick)) == 0: 899 if len(gajim.events.get_events(self.account, fake_jid)) == 0: 900 900 self.remove_contact(nick) 901 901 else: … … 955 955 affiliation, status, jid) 956 956 else: 957 c = gajim.contacts.get_gc_contact(self.account, self.room_jid, 958 nick) 959 if c.show == show and c.status == status and \ 960 c.affiliation == affiliation: #no change 957 if gc_c.show == show and gc_c.status == status and \ 958 gc_c.affiliation == affiliation: # no change 961 959 return 962 c.show = show963 c.affiliation = affiliation964 c.status = status960 gc_c.show = show 961 gc_c.affiliation = affiliation 962 gc_c.status = status 965 963 self.draw_contact(nick) 966 964 … … 1029 1027 if gajim.config.get('ask_avatars_on_startup') and \ 1030 1028 not server.startswith('irc'): 1031 f jid = self.room_jid + '/' + nick1032 pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(f jid, True)1029 fake_jid = self.room_jid + '/' + nick 1030 pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(fake_jid, True) 1033 1031 if pixbuf == 'ask': 1034 gajim.connections[self.account].request_vcard(fjid, True) 1032 if j: 1033 fjid = j 1034 if resource: 1035 fjid += '/' + resource 1036 gajim.connections[self.account].request_vcard(fjid, fake_jid) 1037 else: 1038 gajim.connections[self.account].request_vcard(fake_jid, fake_jid) 1035 1039 if nick == self.nick: # we became online 1036 1040 self.got_connected() … … 1748 1752 def _start_private_message(self, nick): 1749 1753 gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) 1750 c = gajim.contacts.contact_from_gc_contact(gc_c) 1751 nick_jid = c.jid 1754 nick_jid = gc_c.get_full_jid() 1752 1755 1753 1756 win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account) 1754 1757 if not win: 1755 gajim.interface.roster.new_ chat(c, self.account, private_chat = True)1758 gajim.interface.roster.new_private_chat(gc_c, self.account) 1756 1759 win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account) 1757 1760 win.set_active_tab(nick_jid, self.account) -
branches/gajim_0.11.1/src/roster_window.py
r8707 r8709 3056 3056 self.update_status_combobox() 3057 3057 3058 def new_chat(self, contact, account, private_chat = False, resource = None): 3058 def new_private_chat(self, gc_contact, account): 3059 contact = gajim.contacts.contact_from_gc_contact(gc_contact) 3060 type_ = message_control.TYPE_PM 3061 fjid = gc_contact.room_jid + '/' + gc_contact.name 3062 mw = gajim.interface.msg_win_mgr.get_window(fjid, account) 3063 if not mw: 3064 mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_) 3065 3066 chat_control = PrivateChatControl(mw, gc_contact, contact, account) 3067 mw.new_tab(chat_control) 3068 if len(gajim.events.get_events(account, fjid)): 3069 # We call this here to avoid race conditions with widget validation 3070 chat_control.read_queue() 3071 3072 def new_chat(self, contact, account, resource = None): 3059 3073 # Get target window, create a control, and associate it with the window 3060 if not private_chat: 3061 type_ = message_control.TYPE_CHAT 3062 else: 3063 type_ = message_control.TYPE_PM 3074 type_ = message_control.TYPE_CHAT 3064 3075 3065 3076 fjid = contact.jid … … 3070 3081 mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_) 3071 3082 3072 if not private_chat: 3073 chat_control = ChatControl(mw, contact, account, resource) 3074 else: 3075 chat_control = PrivateChatControl(mw, contact, account) 3083 chat_control = ChatControl(mw, contact, account, resource) 3076 3084 3077 3085 mw.new_tab(chat_control) -
branches/gajim_0.11.1/src/vcard.py
r8621 r8709 359 359 self.fill_status_label() 360 360 361 gajim.connections[self.account].request_vcard(self.contact.jid, 362 self.gc_contact is not None) 361 if self.gc_contact: 362 gajim.connections[self.account].request_vcard(self.contact.jid, 363 self.gc_contact.get_full_jid()) 364 else: 365 gajim.connections[self.account].request_vcard(self.contact.jid) 363 366 364 367 def on_close_button_clicked(self, widget):
