Changeset 9616
- Timestamp:
- 05/11/08 15:17:28 (4 months ago)
- Location:
- trunk/src
- Files:
-
- 2 removed
- 14 modified
-
chat_control.py (modified) (56 diffs)
-
common/connection_handlers.py (modified) (19 diffs)
-
common/events.py (modified) (2 diffs)
-
common/gajim.py (modified) (2 diffs)
-
common/pep.py (modified) (1 diff)
-
common/stanza_session.py (modified) (8 diffs)
-
common/zeroconf/connection_handlers_zeroconf.py (modified) (2 diffs)
-
gajim.py (modified) (22 diffs)
-
groupchat_control.py (modified) (14 diffs)
-
message_control.py (modified) (4 diffs)
-
message_window.py (modified) (12 diffs)
-
notify.py (modified) (2 diffs)
-
roster_window.py (modified) (20 diffs)
-
session.py (deleted)
-
tictactoe.py (deleted)
-
vcard.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/chat_control.py
r9614 r9616 7 7 ## Copyright (C) 2007 Lukas Petrovicky <lukas@petrovicky.net> 8 8 ## Julien Pivotto <roidelapluie@gmail.com> 9 ## Stephan Erb <steve-e@h3c.de> 9 ## Stephan Erb <steve-e@h3c.de> 10 10 ## 11 11 ## This file is part of Gajim. … … 105 105 106 106 def draw_banner(self): 107 '''Draw the fat line at the top of the window that 108 houses the icon, jid, ... 107 '''Draw the fat line at the top of the window that 108 houses the icon, jid, ... 109 109 ''' 110 110 self.draw_banner_text() … … 134 134 helpers.launch_browser_mailer('url', url) 135 135 136 def __init__(self, type_id, parent_win, widget_name, contact, acct, 136 def __init__(self, type_id, parent_win, widget_name, contact, acct, 137 137 resource = None): 138 138 MessageControl.__init__(self, type_id, parent_win, widget_name, … … 239 239 gtk.DEST_DEFAULT_HIGHLIGHT, 240 240 self.dnd_list, gtk.gdk.ACTION_COPY) 241 241 242 242 self.update_font() 243 243 … … 267 267 # iterating on a copy 268 268 for lang in dict(langs): 269 try: 269 try: 270 270 spell.set_language(langs[lang]) 271 271 except: … … 331 331 menu.show_all() 332 332 333 # moved from ChatControl 333 # moved from ChatControl 334 334 def _on_banner_eventbox_button_press_event(self, widget, event): 335 335 '''If right-clicked, show popup''' … … 363 363 self.disconnect_style_event(self.banner_status_label) 364 364 if bgcolor: 365 banner_eventbox.modify_bg(gtk.STATE_NORMAL, 365 banner_eventbox.modify_bg(gtk.STATE_NORMAL, 366 366 gtk.gdk.color_parse(bgcolor)) 367 367 default_bg = False … … 392 392 widget.disconnect(id) 393 393 del self.handlers[id] 394 394 395 395 def connect_style_event(self, widget, set_fg = False, set_bg = False): 396 396 self.disconnect_style_event(widget) … … 399 399 400 400 def _on_style_set_event(self, widget, style, *opts): 401 '''set style of widget from style class *.Frame.Eventbox 401 '''set style of widget from style class *.Frame.Eventbox 402 402 opts[0] == True -> set fg color 403 403 opts[1] == True -> set bg color''' … … 565 565 else: # ENTER 566 566 send_message = True 567 567 568 568 if gajim.connections[self.account].connected < 2: # we are not connected 569 569 dialogs.ErrorDialog(_('A connection is not available'), … … 645 645 max_size = gajim.config.get('key_up_lines') 646 646 if size >= max_size: 647 for i in xrange(0, size - 1): 647 for i in xrange(0, size - 1): 648 648 self.sent_history[i] = self.sent_history[i + 1] 649 649 self.sent_history[max_size - 1] = message … … 694 694 # we want to have save this message in events list 695 695 # other_tags_for_text == ['marked'] --> highlighted gc message 696 type_ = 'printed_' + self.type_id 697 event = 'message_received' 696 698 if gc_message: 697 699 if 'marked' in other_tags_for_text: … … 700 702 type_ = 'printed_gc_msg' 701 703 event = 'gc_message_received' 702 else:703 type_ = 'printed_' + self.type_id704 event = 'message_received'705 704 show_in_roster = notify.get_show_in_roster(event, 706 self.account, self.contact , self.session)705 self.account, self.contact) 707 706 show_in_systray = notify.get_show_in_systray(event, 708 707 self.account, self.contact, type_) 709 710 708 event = gajim.events.create_event(type_, None, 711 709 show_in_roster = show_in_roster, … … 725 723 kind in ('incoming', 'incoming_queue'): 726 724 self.parent_win.redraw_tab(self) 725 ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account) 727 726 if not self.parent_win.is_active(): 728 self.parent_win.show_title(True, self) # Enabled Urgent hint727 self.parent_win.show_title(True, ctrl) # Enabled Urgent hint 729 728 else: 730 self.parent_win.show_title(False, self) # Disabled Urgent hint729 self.parent_win.show_title(False, ctrl) # Disabled Urgent hint 731 730 732 731 def toggle_emoticons(self): … … 858 857 # we don't want to always resize in height the message_textview 859 858 # so we have minimum on conversation_textview's scrolled window 860 # but we also want to avoid window resizing so if we reach that 859 # but we also want to avoid window resizing so if we reach that 861 860 # minimum for conversation_textview and maximum for message_textview 862 861 # we set to automatic the scrollbar policy … … 869 868 # scroll only when scrollbar appear 870 869 if policy != gtk.POLICY_AUTOMATIC: 871 self.msg_scrolledwindow.set_property('vscrollbar-policy', 870 self.msg_scrolledwindow.set_property('vscrollbar-policy', 872 871 gtk.POLICY_AUTOMATIC) 873 self.msg_scrolledwindow.set_property('height-request', 872 self.msg_scrolledwindow.set_property('height-request', 874 873 message_height + conversation_height - min_height) 875 874 self.bring_scroll_to_end(msg_textview) 876 875 else: 877 self.msg_scrolledwindow.set_property('vscrollbar-policy', 876 self.msg_scrolledwindow.set_property('vscrollbar-policy', 878 877 gtk.POLICY_NEVER) 879 878 self.msg_scrolledwindow.set_property('height-request', -1) … … 885 884 # if message we have in message_textview is too big 886 885 if requisition.width > message_width: 887 self.msg_scrolledwindow.set_property('hscrollbar-policy', 886 self.msg_scrolledwindow.set_property('hscrollbar-policy', 888 887 gtk.POLICY_AUTOMATIC) 889 888 else: 890 self.msg_scrolledwindow.set_property('hscrollbar-policy', 889 self.msg_scrolledwindow.set_property('hscrollbar-policy', 891 890 gtk.POLICY_NEVER) 892 891 … … 918 917 919 918 if not len(gajim.events.get_events(self.account, jid, types_list)): 920 return 919 return 921 920 if not self.parent_win: 922 921 return … … 925 924 self.parent_win.window.is_active(): 926 925 # we are at the end 927 if not self.session.remove_events(types_list): 926 if not gajim.events.remove_events(self.account, self.get_full_jid(), 927 types = types_list): 928 928 # There were events to remove 929 929 self.redraw_after_event_removed(jid) 930 930 931 931 def redraw_after_event_removed(self, jid): 932 ''' We just removed a 'printed_*' event, redraw contact in roster or 932 ''' We just removed a 'printed_*' event, redraw contact in roster or 933 933 gc_roster and titles in roster and msg_win ''' 934 934 self.parent_win.redraw_tab(self) … … 937 937 if self.type_id == message_control.TYPE_PM: 938 938 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 939 groupchat_control = gajim.interface.msg_win_mgr.get_ gc_control(939 groupchat_control = gajim.interface.msg_win_mgr.get_control( 940 940 room_jid, self.account) 941 941 if room_jid in gajim.interface.minimized_controls[self.account]: … … 948 948 gajim.interface.roster.draw_contact(room_jid, self.account) 949 949 groupchat_control.draw_contact(nick) 950 if groupchat_control.parent_win: 951 groupchat_control.parent_win.redraw_tab(groupchat_control) 950 mw = gajim.interface.msg_win_mgr.get_window(room_jid, self.account) 951 if mw: 952 mw.redraw_tab(groupchat_control) 952 953 else: 953 954 gajim.interface.roster.draw_contact(jid, self.account) … … 955 956 956 957 def sent_messages_scroll(self, direction, conv_buf): 957 size = len(self.sent_history) 958 size = len(self.sent_history) 958 959 if self.orig_msg is None: 959 960 # user was typing something and then went into history, so save … … 1053 1054 self.widget_set_visible(self.xml.get_widget('banner_eventbox'), 1054 1055 gajim.config.get('hide_chat_banner')) 1055 1056 1056 1057 # Add lock image to show chat encryption 1057 1058 self.lock_image = self.xml.get_widget('lock_image') … … 1080 1081 gajim.connections[self.account].is_zeroconf: 1081 1082 convert_to_gc_button.set_sensitive(False) 1082 1083 1083 1084 # keep timeout id and window obj for possible big avatar 1084 1085 # it is on enter-notify and leave-notify so no need to be per jid … … 1126 1127 msg = _('GPG encryption enabled') 1127 1128 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1128 1129 1129 1130 if self.session: 1130 1131 self.session.loggable = gajim.config.get('log_encrypted_sessions') 1131 1132 self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 1132 1133 self.session.is_loggable()) 1133 1134 1134 1135 self.status_tooltip = gtk.Tooltips() 1135 1136 … … 1154 1155 avatar_w = avatar_pixbuf.get_width() 1155 1156 avatar_h = avatar_pixbuf.get_height() 1156 1157 1157 1158 scaled_buf = self.xml.get_widget('avatar_image').get_pixbuf() 1158 1159 scaled_buf_w = scaled_buf.get_width() 1159 1160 scaled_buf_h = scaled_buf.get_height() 1160 1161 1161 1162 # do we have something bigger to show? 1162 1163 if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h: … … 1164 1165 self.show_bigger_avatar_timeout_id = gobject.timeout_add(500, 1165 1166 self.show_bigger_avatar, widget) 1166 1167 1167 1168 def on_avatar_eventbox_leave_notify_event(self, widget, event): 1168 1169 '''we left the eventbox area that holds the avatar img''' … … 1176 1177 menu = gtk.Menu() 1177 1178 menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) 1178 id = menuitem.connect('activate', 1179 id = menuitem.connect('activate', 1179 1180 gtkgui_helpers.on_avatar_save_as_menuitem_activate, 1180 1181 self.contact.jid, self.account, self.contact.get_shown_name() + \ … … 1183 1184 menu.append(menuitem) 1184 1185 menu.show_all() 1185 menu.connect('selection-done', lambda w:w.destroy()) 1186 menu.connect('selection-done', lambda w:w.destroy()) 1186 1187 # show the menu 1187 1188 menu.show_all() … … 1268 1269 1269 1270 def draw_banner_text(self): 1270 '''Draw the text in the fat line at the top of the window that 1271 houses the name, jid. 1271 '''Draw the text in the fat line at the top of the window that 1272 houses the name, jid. 1272 1273 ''' 1273 1274 contact = self.contact … … 1276 1277 banner_name_label = self.xml.get_widget('banner_name_label') 1277 1278 banner_eventbox = self.xml.get_widget('banner_eventbox') 1278 1279 1279 1280 name = contact.get_shown_name() 1280 1281 if self.resource: … … 1363 1364 self.gpg_is_active = False 1364 1365 msg = _('GPG encryption disabled') 1365 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1366 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1366 1367 if self.session: 1367 1368 self.session.loggable = True … … 1388 1389 gajim.config.set_per('contacts', self.contact.jid, 'gpg_enabled', 1389 1390 self.gpg_is_active) 1390 1391 1391 1392 self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 1392 1393 self.session.is_loggable()) 1393 1394 1394 1395 def _show_lock_image(self, visible, enc_type = '', enc_enabled = False, chat_logged = False): 1395 '''Set lock icon visibiity and create tooltip''' 1396 '''Set lock icon visibiity and create tooltip''' 1396 1397 status_string = enc_enabled and 'is' or 'is NOT' 1397 1398 logged_string = chat_logged and 'will' or 'will NOT' … … 1549 1550 # True refresh 30 seconds vars too or else it's 30 - 5 = 25 seconds! 1550 1551 self.reset_kbd_mouse_timeout_vars() 1551 return True # loop forever 1552 return True # loop forever 1552 1553 1553 1554 def check_for_possible_inactive_chatstate(self, arg): … … 1601 1602 ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 1602 1603 self._show_lock_image(e2e_is_active, 'E2E', e2e_is_active, self.session and \ 1603 self.session.is_loggable()) 1604 self.session.is_loggable()) 1604 1605 1605 1606 def print_conversation(self, text, frm='', tim=None, encrypted=False, … … 1625 1626 if not encrypted: 1626 1627 msg = _('The following message was NOT encrypted') 1627 ChatControlBase.print_conversation_line(self, msg, 1628 ChatControlBase.print_conversation_line(self, msg, 1628 1629 'status', '', tim) 1629 1630 else: … … 1631 1632 if encrypted and not self.gpg_is_active: 1632 1633 msg = _('The following message was encrypted') 1633 ChatControlBase.print_conversation_line(self, msg, 1634 ChatControlBase.print_conversation_line(self, msg, 1634 1635 'status', '', tim) 1635 1636 self._toggle_gpg() … … 1672 1673 unread = '[' + unicode(num_unread) + ']' 1673 1674 1674 # Draw tab label using chatstate 1675 # Draw tab label using chatstate 1675 1676 theme = gajim.config.get('roster_theme') 1676 1677 color = None … … 1700 1701 else: # active or not chatstate, get color from gtk 1701 1702 color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] 1702 1703 1703 1704 1704 1705 name = self.contact.get_shown_name() … … 1719 1720 # Set tab image (always 16x16); unread messages show the 'event' image 1720 1721 tab_img = None 1721 1722 1722 1723 if num_unread and gajim.config.get('show_unread_tab_icon'): 1723 1724 img_16 = gajim.interface.roster.get_appropriate_state_images( … … 1760 1761 muc_icon = gtkgui_helpers.load_icon('muc_active') 1761 1762 if muc_icon: 1762 convert_to_gc_menuitem.set_image(muc_icon) 1763 convert_to_gc_menuitem.set_image(muc_icon) 1763 1764 1764 1765 ag = gtk.accel_groups_from_object(self.parent_win.window)[0] … … 1774 1775 contact = self.parent_win.get_active_contact() 1775 1776 jid = contact.jid 1776 1777 1777 1778 # check if we support and use gpg 1778 1779 if not gajim.config.get_per('accounts', self.account, 'keyid') or\ … … 1814 1815 1815 1816 # connect signals 1816 id = history_menuitem.connect('activate', 1817 id = history_menuitem.connect('activate', 1817 1818 self._on_history_menuitem_activate) 1818 1819 self.handlers[id] = history_menuitem 1819 id = send_file_menuitem.connect('activate', 1820 id = send_file_menuitem.connect('activate', 1820 1821 self._on_send_file_menuitem_activate) 1821 self.handlers[id] = send_file_menuitem 1822 self.handlers[id] = send_file_menuitem 1822 1823 id = add_to_roster_menuitem.connect('activate', 1823 1824 self._on_add_to_roster_menuitem_activate) … … 1826 1827 self._on_toggle_gpg_menuitem_activate) 1827 1828 self.handlers[id] = toggle_gpg_menuitem 1828 id = toggle_e2e_menuitem.connect('activate', 1829 id = toggle_e2e_menuitem.connect('activate', 1829 1830 self._on_toggle_e2e_menuitem_activate) 1830 self.handlers[id] = toggle_e2e_menuitem 1831 id = information_menuitem.connect('activate', 1831 self.handlers[id] = toggle_e2e_menuitem 1832 id = information_menuitem.connect('activate', 1832 1833 self._on_contact_information_menuitem_activate) 1833 1834 self.handlers[id] = information_menuitem … … 1885 1886 # this function checks for that and just returns so it's safe to call it 1886 1887 # with same state. 1887 1888 1888 1889 # This functions also checks for violation in state transitions 1889 1890 # and raises RuntimeException with appropriate message … … 1914 1915 return 1915 1916 1916 # if the new state we wanna send (state) equals 1917 # if the new state we wanna send (state) equals 1917 1918 # the current state (contact.our_chatstate) then return 1918 1919 if contact.our_chatstate == state: … … 1926 1927 # for that procedure so return to make sure we send only once 1927 1928 # 'active' until we know peer supports jep85 1928 return 1929 return 1929 1930 1930 1931 if contact.our_chatstate == 'ask': … … 1946 1947 contact.our_chatstate = 'active' 1947 1948 self.reset_kbd_mouse_timeout_vars() 1948 1949 1949 1950 # if we're inactive prevent composing (JEP violation) 1950 1951 elif contact.our_chatstate == 'inactive' and state == 'composing': … … 1963 1964 # destroy banner tooltip - bug #pygtk for that! 1964 1965 self.status_tooltip.destroy() 1965 1966 1966 # Send 'gone' chatstate 1967 1967 self.send_chatstate('gone', self.contact) 1968 1968 self.contact.chatstate = None 1969 1969 self.contact.our_chatstate = None 1970 1971 # terminate session1972 self.session.control = None1973 1974 1970 # Disconnect timer callbacks 1975 1971 gobject.source_remove(self.possible_paused_timeout_id) … … 1991 1987 1992 1988 def allow_shutdown(self, method): 1993 print repr(self.get_full_jid())1994 print repr(gajim.last_message_time[self.account])1995 1989 if time.time() - gajim.last_message_time[self.account]\ 1996 1990 [self.get_full_jid()] < 2: … … 2180 2174 self.print_esession_details() 2181 2175 2176 # Is it a pm ? 2177 is_pm = False 2178 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 2179 control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) 2180 if control and control.type_id == message_control.TYPE_GC: 2181 is_pm = True 2182 2182 # list of message ids which should be marked as read 2183 2183 message_ids = [] … … 2204 2204 2205 2205 typ = 'chat' # Is it a normal chat or a pm ? 2206 2207 2206 # reset to status image in gc if it is a pm 2208 # Is it a pm ? 2209 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 2210 control = gajim.interface.msg_win_mgr.get_gc_control(room_jid,
