~jtaylor/ubuntu/oneiric/gajim/multiple-CVE

« back to all changes in this revision

Viewing changes to src/message_control.py

  • Committer: Bazaar Package Importer
  • Author(s): Nafallo Bjälevik
  • Date: 2008-11-16 00:26:27 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20081116002627-4olie99o2rqc7001
Tags: 0.12~beta1-0ubuntu1
* New upstream beta release:
  + Security improvements: End-to-End encryption, SSL certificat verification
  + Ability to minimize groupchats in roster
  + Chat to groupchat transformation
  + Block/Unblock contacts directly from roster
  + Single window mode
  + PEP support (User activity, mood and tune)
  + Security improvements: Kerberos (GSSAPI) SASL Authentication mechanism
  + Improve GUI of some windows
  + Fix handling of invalid XML
  + Fix freeze on connection
* Dropped all changes, patches and backports.
* src/common/passwords.py:
  - Change keyring to 'login', which is what gets unlocked at login.
* debian/copyright:
  - Updated for the GPL-3 change and for the amount of upstream authors.
* debian/control:
  - Update Standards-Version and drop XS for Vcs-Bzr.
  - Add Homepage and use ${shlibs:Depends}.
* debian/rules:
  - Update to not ignore errors from make clean.
  - Update with dh_shlibdeps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##      message_control.py
2
 
##
3
 
## Copyright (C) 2006 Travis Shirk <travis@pobox.com>
4
 
##
5
 
## This program is free software; you can redistribute it and/or modify
 
1
# -*- coding:utf-8 -*-
 
2
## src/message_control.py
 
3
##
 
4
## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
 
5
##                    Nikos Kouremenos <kourem AT gmail.com>
 
6
## Copyright (C) 2006-2007 Jean-Marie Traissard <jim AT lapin.org>
 
7
##                         Travis Shirk <travis AT pobox.com>
 
8
## Copyright (C) 2006-2008 Yann Leboulanger <asterix AT lagaule.org>
 
9
## Copyright (C) 2007 Julien Pivotto <roidelapluie AT gmail.com>
 
10
##                    Stephan Erb <steve-e AT h3c.de>
 
11
## Copyright (C) 2007-2008 Brendan Taylor <whateley AT gmail.com>
 
12
## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
 
13
##
 
14
## This file is part of Gajim.
 
15
##
 
16
## Gajim is free software; you can redistribute it and/or modify
6
17
## it under the terms of the GNU General Public License as published
7
 
## by the Free Software Foundation; version 2 only.
 
18
## by the Free Software Foundation; version 3 only.
8
19
##
9
 
## This program is distributed in the hope that it will be useful,
 
20
## Gajim is distributed in the hope that it will be useful,
10
21
## but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
23
## GNU General Public License for more details.
13
24
##
 
25
## You should have received a copy of the GNU General Public License
 
26
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
27
##
 
28
 
14
29
import gtkgui_helpers
15
30
 
16
31
from common import gajim
 
32
from common import helpers
17
33
 
18
34
# Derived types MUST register their type IDs here if custom behavor is required
19
35
TYPE_CHAT = 'chat'
26
42
        '''An abstract base widget that can embed in the gtk.Notebook of a MessageWindow'''
27
43
 
28
44
        def __init__(self, type_id, parent_win, widget_name, contact, account, resource = None):
29
 
                # dict { cb id : widget} 
 
45
                # dict { cb id : widget}
30
46
                # keep all registered callbacks of widgets, created by self.xml
31
 
                self.handlers = {} 
 
47
                self.handlers = {}
32
48
                self.type_id = type_id
33
49
                self.parent_win = parent_win
34
50
                self.widget_name = widget_name
35
51
                self.contact = contact
36
52
                self.account = account
37
 
                self.hide_chat_buttons_current = False
 
53
                self.hide_chat_buttons = False
38
54
                self.resource = resource
39
55
 
 
56
                self.session = None
 
57
 
40
58
                gajim.last_message_time[self.account][self.get_full_jid()] = 0
41
59
 
42
60
                self.xml = gtkgui_helpers.get_glade('message_window.glade', widget_name)
53
71
                or inactive (state is False)'''
54
72
                pass  # Derived classes MUST implement this method
55
73
 
56
 
        def allow_shutdown(self, method):
 
74
        def allow_shutdown(self, method, on_response_yes, on_response_no,
 
75
        on_response_minimize):
57
76
                '''Called to check is a control is allowed to shutdown.
58
77
                If a control is not in a suitable shutdown state this method
59
 
                should return False'''
 
78
                should call on_response_no, else on_response_yes or
 
79
                on_response_minimize '''
60
80
                # NOTE: Derived classes MAY implement this
61
 
                return True
 
81
                on_response_yes(self)
62
82
 
63
83
        def shutdown(self):
64
84
                # NOTE: Derived classes MUST implement this
80
100
                pass # NOTE: Derived classes SHOULD implement this
81
101
 
82
102
        def get_tab_label(self, chatstate):
83
 
                '''Return a suitable the tab label string.  Returns a tuple such as:
 
103
                '''Return a suitable tab label string.  Returns a tuple such as:
84
104
                (label_str, color) either of which can be None
85
105
                if chatstate is given that means we have HE SENT US a chatstate and
86
106
                we want it displayed'''
90
110
                pass
91
111
 
92
112
        def get_tab_image(self):
93
 
                '''Return a suitable tab image for display.  None clears any current label.'''
 
113
                # Return a suitable tab image for display.
 
114
                # None clears any current label.
94
115
                return None
95
116
 
96
117
        def prepare_context_menu(self):
99
120
 
100
121
        def chat_buttons_set_visible(self, state):
101
122
                # NOTE: Derived classes MAY implement this
102
 
                self.hide_chat_buttons_current = state
 
123
                self.hide_chat_buttons = state
103
124
 
104
125
        def got_connected(self):
105
126
                pass
108
129
                pass
109
130
 
110
131
        def get_specific_unread(self):
111
 
                return len(gajim.events.get_events(self.account, self.contact.jid))
112
 
 
113
 
        def send_message(self, message, keyID = '', type = 'chat',
 
132
                return len(gajim.events.get_events(self.account,
 
133
                        self.contact.jid))
 
134
 
 
135
        def set_session(self, session):
 
136
                oldsession = None
 
137
                if hasattr(self, 'session'):
 
138
                        oldsession = self.session
 
139
 
 
140
                if oldsession and session == oldsession:
 
141
                        return
 
142
 
 
143
                self.session = session
 
144
 
 
145
                new_key = None
 
146
                if session:
 
147
                        session.control = self
 
148
                        new_key = session.thread_id
 
149
 
 
150
                if oldsession:
 
151
                        oldsession.control = None
 
152
 
 
153
                        jid = self.contact.jid
 
154
                        if self.resource:
 
155
                                jid += '/' + self.resource
 
156
 
 
157
                crypto_changed = bool(session and session.enable_encryption) != \
 
158
                        bool(oldsession and oldsession.enable_encryption)
 
159
 
 
160
                if crypto_changed:
 
161
                        self.print_esession_details()
 
162
 
 
163
        def send_message(self, message, keyID = '', type_ = 'chat',
114
164
        chatstate = None, msg_id = None, composing_xep = None, resource = None,
115
165
        user_nick = None):
116
 
                '''Send the given message to the active tab. Doesn't return None if error
117
 
                '''
 
166
                # Send the given message to the active tab.
 
167
                # Doesn't return None if error
118
168
                jid = self.contact.jid
 
169
 
 
170
                message = helpers.remove_invalid_xml_chars(message)
 
171
 
 
172
                original_message = message
 
173
                conn = gajim.connections[self.account]
 
174
 
 
175
                if not self.session:
 
176
                        sess = conn.find_controlless_session(jid)
 
177
 
 
178
                        if self.resource:
 
179
                                jid += '/' + self.resource
 
180
 
 
181
                        if not sess:
 
182
                                sess = conn.make_new_session(jid)
 
183
 
 
184
                        self.set_session(sess)
 
185
 
119
186
                # Send and update history
120
 
                return gajim.connections[self.account].send_message(jid, message, keyID,
121
 
                        type = type, chatstate = chatstate, msg_id = msg_id,
122
 
                        composing_xep = composing_xep, resource = self.resource,
123
 
                        user_nick = user_nick)
 
187
                return conn.send_message(jid, message, keyID, type_ = type_,
 
188
                        chatstate = chatstate, msg_id = msg_id,
 
189
                        composing_xep = composing_xep,
 
190
                        resource = self.resource, user_nick = user_nick,
 
191
                        session = self.session,
 
192
                        original_message = original_message)
 
193
 
 
194
# vim: se ts=3: