Changeset 9556
- Timestamp:
- 05/02/08 04:32:28 (7 months ago)
- Location:
- branches/session_centric/src
- Files:
-
- 8 modified
-
chat_control.py (modified) (2 diffs)
-
common/connection_handlers.py (modified) (3 diffs)
-
gajim.py (modified) (11 diffs)
-
groupchat_control.py (modified) (5 diffs)
-
message_window.py (modified) (8 diffs)
-
roster_window.py (modified) (12 diffs)
-
session.py (modified) (1 diff)
-
vcard.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/session_centric/src/chat_control.py
r9548 r9556 917 917 if self.type_id == message_control.TYPE_PM: 918 918 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 919 groupchat_control = gajim.interface.msg_win_mgr.get_ control(919 groupchat_control = gajim.interface.msg_win_mgr.get_gc_control( 920 920 room_jid, self.account) 921 921 if room_jid in gajim.interface.minimized_controls[self.account]: … … 928 928 gajim.interface.roster.draw_contact(room_jid, self.account) 929 929 groupchat_control.draw_contact(nick) 930 mw = gajim.interface.msg_win_mgr.get_ window(room_jid, self.account)930 mw = gajim.interface.msg_win_mgr.get_gc_window(room_jid, self.account) 931 931 if mw: 932 932 mw.redraw_tab(groupchat_control) -
branches/session_centric/src/common/connection_handlers.py
r9465 r9556 1299 1299 1300 1300 con.send(reply) 1301 1301 1302 1302 raise common.xmpp.NodeProcessed 1303 1303 … … 1329 1329 errcode = iq_obj.getErrorCode() 1330 1330 self.dispatch('ERROR_ANSWER', (id, jid_from, errmsg, errcode)) 1331 1331 1332 1332 def _PrivateCB(self, con, iq_obj): 1333 1333 ''' … … 1591 1591 msg = session.decrypt_stanza(msg) 1592 1592 except: 1593 self.dispatch('FAILED_DECRYPT', (frm, tim ))1593 self.dispatch('FAILED_DECRYPT', (frm, tim, session)) 1594 1594 1595 1595 msgtxt = msg.getBody() -
branches/session_centric/src/gajim.py
r9326 r9556 447 447 prompt = data[2] 448 448 proposed_nick = data[3] 449 gc_control = self.msg_win_mgr.get_ control(room_jid, account)449 gc_control = self.msg_win_mgr.get_gc_control(room_jid, account) 450 450 if not gc_control and \ 451 451 room_jid in self.minimized_controls[account]: … … 501 501 conn.disconnect_transfer(file_props) 502 502 return 503 ctrl = self.msg_win_mgr.get_control(jid_from, account) 504 if ctrl and ctrl.type_id == message_control.TYPE_GC: 505 ctrl.print_conversation('Error %s: %s' % (array[2], array[1])) 503 504 for ctrl in self.msg_win_mgr.get_chat_controls(jid_from, account): 505 if ctrl.type_id == message_control.TYPE_GC: 506 ctrl.print_conversation('Error %s: %s' % (array[2], array[1])) 506 507 507 508 def handle_event_con_type(self, account, con_type): … … 957 958 958 959 # show avatar in chat 959 win = None 960 ctrl = None 960 ctrls = [] 961 961 if resource and self.msg_win_mgr.has_window( 962 962 jid + '/' + resource, account): 963 963 win = self.msg_win_mgr.get_window(jid + '/' + resource, 964 964 account) 965 ctrl = win.get_control(jid + '/' + resource, account)965 ctrls = win.get_controls(jid + '/' + resource, account) 966 966 elif self.msg_win_mgr.has_window(jid, account): 967 967 win = self.msg_win_mgr.get_window(jid, account) 968 ctrl = win.get_control(jid, account) 969 if win and ctrl.type_id != message_control.TYPE_GC: 970 ctrl.show_avatar() 968 ctrls = win.get_controls(jid, account) 969 970 for ctrl in ctrls: 971 if ctrl.type_id != message_control.TYPE_GC: 972 ctrl.show_avatar() 971 973 972 974 # Show avatar in roster or gc_roster 973 gc_ctrl = self.msg_win_mgr.get_ control(jid, account)975 gc_ctrl = self.msg_win_mgr.get_gc_control(jid, account) 974 976 if not gc_ctrl and \ 975 977 jid in self.minimized_controls[account]: … … 1028 1030 # Get the window and control for the updated status, this may be a 1029 1031 # PrivateChatControl 1030 control = self.msg_win_mgr.get_control(room_jid, account) 1032 control = self.msg_win_mgr.get_gc_control(room_jid, account) 1033 1031 1034 if not control and \ 1032 1035 room_jid in self.minimized_controls[account]: 1033 1036 control = self.minimized_controls[account][room_jid] 1034 1037 1035 if control and control.type_id != message_control.TYPE_GC:1036 return 1037 if control: 1038 control.chg_contact_status(nick, show, status, array[4], array[5],1039 array[6], array[7], array[8], array[9], array[10], array[11])1038 if not control or (control and control.type_id != message_control.TYPE_GC): 1039 return 1040 1041 control.chg_contact_status(nick, show, status, array[4], array[5], 1042 array[6], array[7], array[8], array[9], array[10], array[11]) 1040 1043 1041 1044 contact = gajim.contacts.\ … … 1044 1047 self.roster.draw_contact(room_jid, account) 1045 1048 1046 ctrl = self.msg_win_mgr.get_control(fjid, account) 1047 1048 # print status in chat window and update status/GPG image 1049 if ctrl: 1049 # print status in chat windows and update status/GPG image 1050 for ctrl in self.msg_win_mgr.get_chat_controls(fjid, account): 1050 1051 statusCode = array[9] 1051 1052 if '303' in statusCode: … … 1083 1084 room_jid = jids[0] 1084 1085 1085 gc_control = self.msg_win_mgr.get_ control(room_jid, account)1086 gc_control = self.msg_win_mgr.get_gc_control(room_jid, account) 1086 1087 if not gc_control and \ 1087 1088 room_jid in self.minimized_controls[account]: … … 1116 1117 jid = jids[0] 1117 1118 1118 gc_control = self.msg_win_mgr.get_ control(jid, account)1119 gc_control = self.msg_win_mgr.get_gc_control(jid, account) 1119 1120 1120 1121 if not gc_control and \ … … 1181 1182 statusCode = array[1] 1182 1183 1183 gc_control = self.msg_win_mgr.get_ control(jid, account)1184 gc_control = self.msg_win_mgr.get_gc_control(jid, account) 1184 1185 if not gc_control and \ 1185 1186 jid in self.minimized_controls[account]: … … 1240 1241 else: 1241 1242 win = self.msg_win_mgr.get_window(room_jid, account) 1242 ctrl = win.get_ control(room_jid, account)1243 ctrl = win.get_gc_control(room_jid, account) 1243 1244 win.remove_tab(ctrl, 3) 1244 1245 … … 1783 1784 1784 1785 def handle_event_failed_decrypt(self, account, data): 1785 jid, tim = data1786 1787 ctrl = self.msg_win_mgr.get_control(jid, account )1786 jid, tim, session = data 1787 1788 ctrl = self.msg_win_mgr.get_control(jid, account, session.thread_id) 1788 1789 if ctrl: 1789 1790 ctrl.print_conversation_line('Unable to decrypt message from %s\nIt may have been tampered with.' % (jid), 'status', '', tim) … … 2584 2585 gajim.events.remove_events(account, jid, event) 2585 2586 self.roster.draw_contact(jid, account) 2587 2586 2588 if w: 2587 2589 w.set_active_tab(fjid, account) -
branches/session_centric/src/groupchat_control.py
r9326 r9556 44 44 from common import gajim 45 45 from common import helpers 46 from common.stanza_session import StanzaSession 46 47 47 48 from chat_control import ChatControl … … 58 59 C_AVATAR, # avatar of the contact 59 60 ) = range(5) 60 61 61 62 def set_renderer_color(treeview, renderer, set_background = True): 62 63 '''set style for group row, using PRELIGHT system color''' … … 210 211 self.new_nick = '' 211 212 self.name = self.room_jid.split('@')[0] 213 214 self.session = StanzaSession(gajim.connections[self.account], 215 self.room_jid, 'gc', 'gc') 212 216 213 217 compact_view = gajim.config.get('compact_view') … … 853 857 # Update pm chat window 854 858 fjid = self.room_jid + '/' + nick 855 ctrl = gajim.interface.msg_win_mgr.get_control(fjid, self.account)856 859 gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, 857 860 nick) 858 if ctrl:861 for ctrl in gajim.interface.msg_win_mgr.get_chat_controls(fjid, self.account): 859 862 gc_contact.show = 'offline' 860 863 gc_contact.status = '' … … 2023 2026 menu.popup(None, None, None, event.button, event.time) 2024 2027 2025 def _start_private_message(self, nick , session = None):2028 def _start_private_message(self, nick): 2026 2029 gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) 2027 2030 nick_jid = gc_c.get_full_jid() -
branches/session_centric/src/message_window.py
r9548 r9556 397 397 gtkgui_helpers.set_unset_urgency_hint(self.window, False) 398 398 399 def set_active_tab(self, session): 400 ctrl = self._controls[session.conn.name][session.jid][session.thread_id] 399 def set_active_tab(self, ctrl): 401 400 ctrl_page = self.notebook.page_num(ctrl.widget) 402 401 self.notebook.set_current_page(ctrl_page) … … 539 538 ctrl.update_tags() 540 539 541 def get_control(self, key, acct ):540 def get_control(self, key, acct, thread_id): 542 541 '''Return the MessageControl for jid or n, where n is a notebook page index. 543 When key is an int index acct may be None'''542 When key is an int index acct and thread_id may be None''' 544 543 if isinstance(key, str): 545 544 key = unicode(key, 'utf-8') … … 548 547 jid = key 549 548 try: 550 return self._controls[acct][jid] 549 return self._controls[acct][jid][thread_id] 551 550 except: 552 551 return None … … 558 557 nth_child = notebook.get_nth_page(page_num) 559 558 return self._widget_to_control(nth_child) 559 560 def get_gc_control(self, jid, acct): 561 return self.get_control(jid, acct, 'gc') 562 563 def get_controls(self, jid, acct): 564 try: 565 return self._controls[acct][jid].values() 566 except KeyError: 567 return [] 560 568 561 569 def change_key(self, old_jid, new_jid, acct): … … 595 603 if ind < 0: 596 604 ind = self.notebook.get_n_pages() - 1 597 ctrl = self.get_control(ind, None )605 ctrl = self.get_control(ind, None, None) 598 606 if ctrl.get_nb_unread() > 0: 599 607 found = True … … 787 795 def get_window(self, jid, acct): 788 796 for win in self.windows(): 789 if win.get_control(jid, acct): 790 return win 797 try: 798 if win._controls[acct][jid]: 799 return win 800 except KeyError: 801 pass 802 return None 803 804 def get_gc_control(self, jid, acct): 805 win = self.get_window(jid, acct) 806 807 if win: 808 return win.get_gc_control(jid, acct) 809 791 810 return None 792 811 … … 915 934 return 916 935 917 def get_control(self, jid, acct ):936 def get_control(self, jid, acct, session): 918 937 '''Amongst all windows, return the MessageControl for jid''' 919 938 win = self.get_window(jid, acct) 920 939 if win: 921 return win.get_control(jid, acct )940 return win.get_control(jid, acct, session) 922 941 return None 923 942 … … 930 949 ctrls.append(c) 931 950 return ctrls 951 952 def get_chat_controls(self, jid, acct): 953 win = self.get_window(jid, acct) 954 955 if win: 956 return win.get_controls(jid, acct) 957 else: 958 return [] 932 959 933 960 def windows(self): -
branches/session_centric/src/roster_window.py
r9548 r9556 778 778 def join_gc_room(self, account, room_jid, nick, password, minimize=False, 779 779 is_continued=False): 780 '''joins the room immediatel ly'''780 '''joins the room immediately''' 781 781 if gajim.interface.msg_win_mgr.has_window(room_jid, account) and \ 782 782 gajim.gc_connected[account][room_jid]: 783 783 win = gajim.interface.msg_win_mgr.get_window(room_jid, account) 784 ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account) 784 785 win.window.present() 785 win.set_active_tab( room_jid, account)786 win.set_active_tab(ctrl) 786 787 dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid) 787 788 return … … 809 810 if not minimized_control_exists: 810 811 gc_win = gajim.interface.msg_win_mgr.get_window(room_jid, account) 811 gc_win.set_active_tab(room_jid, account) 812 gc_control = gc_win.get_gc_control(room_jid, account) 813 gc_win.set_active_tab(gc_control) 812 814 gc_win.window.present() 813 815 gajim.connections[account].join_gc(nick, room_jid, password) … … 1362 1364 else: 1363 1365 gajim.transport_avatar[account][host].append(contact1.jid) 1364 # If we already have a chat window opened, update it with new contact 1366 1367 # If we already have chat windows opened, update them with new contact 1365 1368 # instance 1366 chat_control = gajim.interface.msg_win_mgr.get_control(ji, account) 1367 if chat_control: 1369 for chat_control in gajim.interface.msg_win_mgr.get_chat_controls(ji, account): 1368 1370 chat_control.contact = contact1 1369 1371 … … 1386 1388 win = gajim.interface.msg_win_mgr.get_window(jid_with_resource, 1387 1389 account) 1388 ctrl = win.get_control(jid_with_resource, account) 1389 ctrl.update_ui() 1390 win.redraw_tab(ctrl) 1390 for ctrl in win.get_controls(jid_with_resource, account): 1391 ctrl.update_ui() 1392 win.redraw_tab(ctrl) 1393 1391 1394 gajim.contacts.remove_contact(account, contact) 1392 1395 self.remove_contact(contact, account) … … 1395 1398 if gajim.interface.msg_win_mgr.has_window(contact.jid, account): 1396 1399 win = gajim.interface.msg_win_mgr.get_window(contact.jid, account) 1397 ctrl = win.get_control(contact.jid, account)1398 ctrl.contact = gajim.contacts.get_contact_with_highest_priority(1399 account, contact.jid)1400 ctrl.update_ui()1401 win.redraw_tab(ctrl)1402 1403 1400 uf_show = helpers.get_uf_show(show) 1404 if status: 1405 ctrl.print_conversation(_('%s is now %s (%s)') % (name, uf_show, 1406 status), 'status') 1407 else: # No status message 1408 ctrl.print_conversation(_('%s is now %s') % (name, uf_show), 1409 'status') 1401 1402 for ctrl in win.get_controls(contact.jid, account): 1403 ctrl.contact = gajim.contacts.get_contact_with_highest_priority( 1404 account, contact.jid) 1405 ctrl.update_ui() 1406 win.redraw_tab(ctrl) 1407 1408 if status: 1409 ctrl.print_conversation(_('%s is now %s (%s)') % (name, uf_show, 1410 status), 'status') 1411 else: # No status message 1412 ctrl.print_conversation(_('%s is now %s') % (name, uf_show), 1413 'status') 1410 1414 1411 1415 # unset custom status … … 1809 1813 gajim.connections[account].update_contact(jid, new_text, u.groups) 1810 1814 self.draw_contact(jid, account) 1811 # Update opened chat 1812 ctrl = gajim.interface.msg_win_mgr.get_control(jid, account) 1813 if ctrl: 1815 # Update opened chats 1816 for ctrl in gajim.interface.msg_win_mgr.get_controls(jid, account): 1814 1817 ctrl.update_ui() 1815 1818 win = gajim.interface.msg_win_mgr.get_window(jid, account) … … 1859 1862 msg_win = gajim.interface.msg_win_mgr.get_window(contact.jid, 1860 1863 account) 1861 ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) 1862 msg_win.remove_tab(ctrl, msg_win.CLOSE_CLOSE_BUTTON) 1864 for ctrl in gajim.interface.msg_win_mgr.get_controls(contact.jid, 1865 account): 1866 msg_win.remove_tab(ctrl, msg_win.CLOSE_CLOSE_BUTTON) 1863 1867 else: 1864 1868 need_readd = True … … 1919 1923 keys[contact.jid] = keyID 1920 1924 1921 if gajim.interface.msg_win_mgr.has_window(contact.jid, account): 1922 ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) 1925 for ctrl in gajim.interface.msg_win_mgr.get_chat_controls(contact.jid, account): 1923 1926 ctrl.update_ui() 1924 1927 keys_str = '' … … 1935 1938 # Update chat window 1936 1939 if gajim.interface.msg_win_mgr.has_window(jid, account): 1937 win = gajim.interface.msg_win_mgr.get_window(jid, account) 1938 ctrl = win.get_control(jid, account) 1939 if win and ctrl.type_id != message_control.TYPE_GC: 1940 ctrl.show_avatar() 1940 for ctrl in gajim.interface.msg_win_mgr.get_chat_controls(jid, account): 1941 if ctrl.type_id != message_control.TYPE_GC: 1942 ctrl.show_avatar() 1941 1943 1942 1944 def on_set_custom_avatar_activate(self, widget, contact, account): … … 2655 2657 ctrl.parent_win = mw 2656 2658 mw.new_tab(ctrl) 2657 mw.set_active_tab( jid, account)2659 mw.set_active_tab(ctrl) 2658 2660 mw.window.present() 2659 2661 del gajim.interface.minimized_controls[account][jid] … … 3972 3974 3973 3975 mw = gajim.interface.msg_win_mgr.get_window(fjid, account) 3974 mw.set_active_tab( fjid, account)3976 mw.set_active_tab(session.control) 3975 3977 mw.window.present() 3976 3978 # For JEP-0172 3977 3979 if added_to_roster: 3978 mc = mw.get_control(fjid, account)3979 mc.user_nick = gajim.nicks[account]3980 for mc in mw.get_controls(fjid, account): 3981 mc.user_nick = gajim.nicks[account] 3980 3982 3981 3983 def new_room(self, room_jid, nick, account, is_continued=False): … … 4323 4325 4324 4326 win = session.control.parent_win 4325 win.set_active_tab(session )4327 win.set_active_tab(session.control) 4326 4328 4327 4329 if conn.is_zeroconf and conn.status in ('offline', 'invisible'): 4328 win.get_control(fjid, account).got_disconnected() 4330 for ctrl in win.get_controls(fjid, account): 4331 ctrl.got_disconnected() 4329 4332 4330 4333 win.window.present() -
branches/session_centric/src/session.py
r9548 r9556 108 108 jid = jid.replace('@', '') 109 109 110 groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name)110 #groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name) 111 111 112 112 # XXX fixme -
branches/session_centric/src/vcard.py
r9299 r9556 124 124 # Update roster 125 125 gajim.interface.roster.draw_avatar(jid, self.account) 126 # Update chat window 127 if gajim.interface.msg_win_mgr.has_window(jid, self.account): 128 win = gajim.interface.msg_win_mgr.get_window(jid, self.account) 129 ctrl = win.get_control(jid, self.account) 130 if win and ctrl.type_id != message_control.TYPE_GC: 126 # Update chat windows 127 for ctrl in gajim.interface.msg_win_mgr.get_chat_controls(jid, self.account): 128 &
