Changeset 9548
- Timestamp:
- 04/30/08 04:55:13 (7 months ago)
- Location:
- branches/session_centric/src
- Files:
-
- 5 modified
-
chat_control.py (modified) (23 diffs)
-
common/events.py (modified) (1 diff)
-
message_window.py (modified) (5 diffs)
-
roster_window.py (modified) (3 diffs)
-
session.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/session_centric/src/chat_control.py
r9326 r9548 386 386 widget.disconnect(id) 387 387 del self.handlers[id] 388 388 389 389 def connect_style_event(self, widget, set_fg = False, set_bg = False): 390 390 self.disconnect_style_event(widget) … … 710 710 kind in ('incoming', 'incoming_queue'): 711 711 self.parent_win.redraw_tab(self) 712 ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account)713 712 if not self.parent_win.is_active(): 714 self.parent_win.show_title(True, ctrl) # Enabled Urgent hint713 self.parent_win.show_title(True, self) # Enabled Urgent hint 715 714 else: 716 self.parent_win.show_title(False, ctrl) # Disabled Urgent hint715 self.parent_win.show_title(False, self) # Disabled Urgent hint 717 716 718 717 def toggle_emoticons(self): … … 906 905 self.parent_win.window.is_active(): 907 906 # we are at the end 908 if not gajim.events.remove_events(self.account, self.get_full_jid(), 909 types = ['printed_' + type_, type_]): 907 if not self.session.remove_events(['printed_' + type_, type_]): 910 908 # There were events to remove 911 909 self.redraw_after_event_removed(jid) … … 1020 1018 self.widget_set_visible(self.xml.get_widget('banner_eventbox'), 1021 1019 gajim.config.get('hide_chat_banner')) 1022 1020 1023 1021 # Add lock image to show chat encryption 1024 1022 self.lock_image = self.xml.get_widget('lock_image') 1025 1023 self.lock_tooltip = gtk.Tooltips() 1026 1024 1027 1025 # keep timeout id and window obj for possible big avatar 1028 1026 # it is on enter-notify and leave-notify so no need to be per jid … … 1070 1068 msg = _('GPG encryption enabled') 1071 1069 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1072 1070 1073 1071 if self.session: 1074 1072 self.session.loggable = gajim.config.get('log_encrypted_sessions') 1075 1073 self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 1076 1074 self.session.is_loggable()) 1077 1075 1078 1076 self.status_tooltip = gtk.Tooltips() 1079 1077 self.update_ui() … … 1094 1092 avatar_w = avatar_pixbuf.get_width() 1095 1093 avatar_h = avatar_pixbuf.get_height() 1096 1094 1097 1095 scaled_buf = self.xml.get_widget('avatar_image').get_pixbuf() 1098 1096 scaled_buf_w = scaled_buf.get_width() 1099 1097 scaled_buf_h = scaled_buf.get_height() 1100 1098 1101 1099 # do we have something bigger to show? 1102 1100 if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h: … … 1104 1102 self.show_bigger_avatar_timeout_id = gobject.timeout_add(500, 1105 1103 self.show_bigger_avatar, widget) 1106 1104 1107 1105 def on_avatar_eventbox_leave_notify_event(self, widget, event): 1108 1106 '''we left the eventbox area that holds the avatar img''' … … 1123 1121 menu.append(menuitem) 1124 1122 menu.show_all() 1125 menu.connect('selection-done', lambda w:w.destroy()) 1123 menu.connect('selection-done', lambda w:w.destroy()) 1126 1124 # show the menu 1127 1125 menu.show_all() … … 1190 1188 banner_name_label = self.xml.get_widget('banner_name_label') 1191 1189 banner_eventbox = self.xml.get_widget('banner_eventbox') 1192 1190 1193 1191 name = contact.get_shown_name() 1194 1192 if self.resource: … … 1276 1274 self.gpg_is_active = False 1277 1275 msg = _('GPG encryption disabled') 1278 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1276 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1279 1277 if self.session: 1280 1278 self.session.loggable = True … … 1301 1299 gajim.config.set_per('contacts', self.contact.jid, 'gpg_enabled', 1302 1300 self.gpg_is_active) 1303 1301 1304 1302 self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 1305 1303 self.session.is_loggable()) 1306 1304 1307 1305 def _show_lock_image(self, visible, enc_type = '', enc_enabled = False, chat_logged = False): 1308 1306 '''Set lock icon visibiity and create tooltip''' … … 1468 1466 # True refresh 30 seconds vars too or else it's 30 - 5 = 25 seconds! 1469 1467 self.reset_kbd_mouse_timeout_vars() 1470 return True # loop forever 1468 return True # loop forever 1471 1469 1472 1470 def check_for_possible_inactive_chatstate(self, arg): … … 1618 1616 else: # active or not chatstate, get color from gtk 1619 1617 color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] 1620 1618 1621 1619 1622 1620 name = self.contact.get_shown_name() … … 1637 1635 # Set tab image (always 16x16); unread messages show the 'event' image 1638 1636 tab_img = None 1639 1637 1640 1638 if num_unread and gajim.config.get('show_unread_tab_icon'): 1641 1639 img_16 = gajim.interface.roster.get_appropriate_state_images( … … 1673 1671 muc_icon = gajim.interface.roster.load_icon('muc_active') 1674 1672 if muc_icon: 1675 convert_to_gc_menuitem.set_image(muc_icon) 1673 convert_to_gc_menuitem.set_image(muc_icon) 1676 1674 1677 1675 ag = gtk.accel_groups_from_object(self.parent_win.window)[0] … … 1683 1681 contact = self.parent_win.get_active_contact() 1684 1682 jid = contact.jid 1685 1683 1686 1684 # check if we support and use gpg 1687 1685 if not gajim.config.get_per('accounts', self.account, 'keyid') or\ … … 1766 1764 # this function checks for that and just returns so it's safe to call it 1767 1765 # with same state. 1768 1766 1769 1767 # This functions also checks for violation in state transitions 1770 1768 # and raises RuntimeException with appropriate message … … 1795 1793 return 1796 1794 1797 # if the new state we wanna send (state) equals 1795 # if the new state we wanna send (state) equals 1798 1796 # the current state (contact.our_chatstate) then return 1799 1797 if contact.our_chatstate == state: … … 1807 1805 # for that procedure so return to make sure we send only once 1808 1806 # 'active' until we know peer supports jep85 1809 return 1807 return 1810 1808 1811 1809 if contact.our_chatstate == 'ask': … … 1827 1825 contact.our_chatstate = 'active' 1828 1826 self.reset_kbd_mouse_timeout_vars() 1829 1827 1830 1828 # if we're inactive prevent composing (JEP violation) 1831 1829 elif contact.our_chatstate == 'inactive' and state == 'composing': … … 2053 2051 self.print_esession_details() 2054 2052 2055 # Is it a pm ?2056 is_pm = False2057 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)2058 control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account)2059 if control and control.type_id == message_control.TYPE_GC:2060 is_pm = True2061 2053 # list of message ids which should be marked as read 2062 2054 message_ids = [] … … 2083 2075 2084 2076 typ = 'chat' # Is it a normal chat or a pm ? 2077 2085 2078 # reset to status image in gc if it is a pm 2086 if is_pm: 2087 control.update_ui() 2088 control.parent_win.show_title() 2089 typ = 'pm' 2079 # Is it a pm ? 2080 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 2081 # XXX fixme somehow 2082 # control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) 2083 # if control and control.type_id == message_control.TYPE_GC: 2084 # control.update_ui() 2085 # control.parent_win.show_title() 2086 # typ = 'pm' 2090 2087 2091 2088 self.redraw_after_event_removed(jid) … … 2098 2095 gajim.interface.roster.really_remove_contact(self.contact, 2099 2096 self.account) 2100 elif typ == 'pm':2101 control.remove_contact(nick)2097 # elif typ == 'pm': 2098 # control.remove_contact(nick) 2102 2099 2103 2100 def show_bigger_avatar(self, small_avatar): -
branches/session_centric/src/common/events.py
r9307 r9548 117 117 def remove_events(self, account, jid, event = None, types = []): 118 118 '''if event is not specified, remove all events from this jid, 119 option naly only from given type119 optionally only from given type 120 120 return True if no such event found''' 121 121 if not self._events.has_key(account): -
branches/session_centric/src/message_window.py
r9326 r9548 153 153 def get_num_controls(self): 154 154 n = 0 155 for dict in self._controls.values(): 156 n += len(dict) 155 for jid_dict in self._controls.values(): 156 for dict in jid_dict.values(): 157 n += len(dict) 157 158 return n 158 159 … … 207 208 self._controls[control.account] = {} 208 209 fjid = control.get_full_jid() 209 self._controls[control.account][fjid] = control 210 211 if not self._controls[control.account].has_key(fjid): 212 self._controls[control.account][fjid] = {} 213 214 self._controls[control.account][fjid][control.session.thread_id] = control 210 215 211 216 if self.get_num_controls() == 2: … … 392 397 gtkgui_helpers.set_unset_urgency_hint(self.window, False) 393 398 394 def set_active_tab(self, jid, acct):395 ctrl = self._controls[ acct][jid]399 def set_active_tab(self, session): 400 ctrl = self._controls[session.conn.name][session.jid][session.thread_id] 396 401 ctrl_page = self.notebook.page_num(ctrl.widget) 397 402 self.notebook.set_current_page(ctrl_page) … … 425 430 426 431 fjid = ctrl.get_full_jid() 427 del self._controls[ctrl.account][fjid] 432 thread_id = ctrl.session.thread_id 433 del self._controls[ctrl.account][fjid][thread_id] 434 435 if len(self._controls[ctrl.account][fjid]) == 0: 436 del self._controls[ctrl.account][fjid] 437 428 438 if len(self._controls[ctrl.account]) == 0: 429 439 del self._controls[ctrl.account] … … 564 574 565 575 def controls(self): 566 for ctrl_dict in self._controls.values(): 567 for ctrl in ctrl_dict.values(): 568 yield ctrl 576 for jid_dict in self._controls.values(): 577 for ctrl_dict in jid_dict.values(): 578 for ctrl in ctrl_dict.values(): 579 yield ctrl 569 580 570 581 def move_to_next_unread_tab(self, forward): -
branches/session_centric/src/roster_window.py
r9459 r9548 4313 4313 session = conn.get_session(fjid, None, 'chat') 4314 4314 4315 win = gajim.interface.msg_win_mgr.get_window(fjid, account) 4316 if not win: 4315 if not session.control: 4317 4316 session.control = self.new_chat(session, contact, account, resource=resource) 4318 4317 … … 4320 4319 session.control.read_queue() 4321 4320 4322 win = gajim.interface.msg_win_mgr.get_window(fjid, account)4323 4321 # last message is long time ago 4324 4322 gajim.last_message_time[account][session.control.get_full_jid()] = 0 4325 4323 4326 win.set_active_tab(fjid, account) 4324 win = session.control.parent_win 4325 win.set_active_tab(session) 4326 4327 4327 if conn.is_zeroconf and conn.status in ('offline', 'invisible'): 4328 4328 win.get_control(fjid, account).got_disconnected() … … 5205 5205 elif nb_unread == 1: 5206 5206 start = '* ' 5207 5207 5208 self.window.set_title(start + 'Gajim') 5208 5209 -
branches/session_centric/src/session.py
r9465 r9548 19 19 20 20 self.control = None 21 22 # remove events associated with this session from the queue 23 def remove_events(self, types): 24 any_removed = False 25 26 for event in gajim.events.get_events(self.conn, self.jid, types=types): 27 if event.parameters[8] != self: 28 continue 29 30 r = gajim.events.remove_events(self.conn, self.jid, event) 31 32 if not_any_removed: 33 any_removed = r 34 35 return any_removed 21 36 22 37 # extracts chatstate from a <message/> stanza … … 94 109 95 110 groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name) 96 if not groupchat_control and \ 97 jid in gajim.interface.minimized_controls[self.conn.name]: 98 groupchat_control = self.minimized_controls[self.conn.name][jid] 111 112 # XXX fixme 113 # if not groupchat_control and \ 114 # jid in gajim.interface.minimized_controls[self.conn.name]: 115 # groupchat_control = self.minimized_controls[self.conn.name][jid] 99 116 100 117 pm = False 101 if groupchat_control and groupchat_control.type_id == \102 message_control.TYPE_GC:118 # if groupchat_control and groupchat_control.type_id == \ 119 # message_control.TYPE_GC: 103 120 # It's a Private message 104 pm = True105 msg_type = 'pm'121 # pm = True 122 # msg_type = 'pm' 106 123 107 124 jid_of_control = full_jid_with_resource … … 185 202 subject=None, resource='', msg_id=None, user_nick='', 186 203 advanced_notif_num=None, xhtml=None, form_node=None): 204 187 205 contact = None 188 206 # if chat window will be for specific resource
