chat window now print when encryption in enabled / disabled and automatically activate/desactivate the gpg_toggle button
This commit is contained in:
parent
a43a3f539f
commit
efd470a44f
|
@ -192,6 +192,7 @@ class Connection:
|
||||||
tim = msg.getTimestamp()
|
tim = msg.getTimestamp()
|
||||||
tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')
|
tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')
|
||||||
tim = time.localtime(timegm(tim))
|
tim = time.localtime(timegm(tim))
|
||||||
|
encrypted = False
|
||||||
xtags = msg.getTags('x')
|
xtags = msg.getTags('x')
|
||||||
encTag = None
|
encTag = None
|
||||||
decmsg = ''
|
decmsg = ''
|
||||||
|
@ -208,6 +209,7 @@ class Connection:
|
||||||
decmsg = self.gpg.decrypt(encmsg, keyID)
|
decmsg = self.gpg.decrypt(encmsg, keyID)
|
||||||
if decmsg:
|
if decmsg:
|
||||||
msgtxt = decmsg
|
msgtxt = decmsg
|
||||||
|
encrypted = True
|
||||||
if mtype == 'error':
|
if mtype == 'error':
|
||||||
self.dispatch('MSGERROR', (str(msg.getFrom()), \
|
self.dispatch('MSGERROR', (str(msg.getFrom()), \
|
||||||
msg.getErrorCode(), msg.getError(), msgtxt, tim))
|
msg.getErrorCode(), msg.getError(), msgtxt, tim))
|
||||||
|
@ -220,7 +222,7 @@ class Connection:
|
||||||
gajim.logger.write('gc', msgtxt, str(msg.getFrom()), tim = tim)
|
gajim.logger.write('gc', msgtxt, str(msg.getFrom()), tim = tim)
|
||||||
else:
|
else:
|
||||||
gajim.logger.write('incoming', msgtxt, str(msg.getFrom()), tim = tim)
|
gajim.logger.write('incoming', msgtxt, str(msg.getFrom()), tim = tim)
|
||||||
self.dispatch('MSG', (str(msg.getFrom()), msgtxt, tim))
|
self.dispatch('MSG', (str(msg.getFrom()), msgtxt, tim, encrypted))
|
||||||
# END messageCB
|
# END messageCB
|
||||||
|
|
||||||
def _presenceCB(self, con, prs):
|
def _presenceCB(self, con, prs):
|
||||||
|
|
|
@ -329,7 +329,7 @@ class Interface:
|
||||||
array[10], array[11], account)
|
array[10], array[11], account)
|
||||||
|
|
||||||
def handle_event_msg(self, account, array):
|
def handle_event_msg(self, account, array):
|
||||||
#('MSG', account, (user, msg, time))
|
#('MSG', account, (user, msg, time, encrypted))
|
||||||
jid = array[0].split('/')[0]
|
jid = array[0].split('/')[0]
|
||||||
if jid.find('@') <= 0:
|
if jid.find('@') <= 0:
|
||||||
jid = jid.replace('@', '')
|
jid = jid.replace('@', '')
|
||||||
|
@ -352,7 +352,7 @@ class Interface:
|
||||||
instance = dialogs.Popup_notification_window(self,
|
instance = dialogs.Popup_notification_window(self,
|
||||||
'New Message', jid, account)
|
'New Message', jid, account)
|
||||||
self.roster.popup_notification_windows.append(instance)
|
self.roster.popup_notification_windows.append(instance)
|
||||||
self.roster.on_message(jid, array[1], array[2], account)
|
self.roster.on_message(jid, array[1], array[2], account, array[3])
|
||||||
if gajim.config.get_per('soundevents', 'first_message_received', \
|
if gajim.config.get_per('soundevents', 'first_message_received', \
|
||||||
'enabled') and first:
|
'enabled') and first:
|
||||||
self.play_sound('first_message_received')
|
self.play_sound('first_message_received')
|
||||||
|
|
|
@ -956,7 +956,7 @@ class Roster_window:
|
||||||
self.plugin.windows[account]['gc'][jid] = \
|
self.plugin.windows[account]['gc'][jid] = \
|
||||||
groupchat_window.Groupchat_window(jid, nick, self.plugin, account)
|
groupchat_window.Groupchat_window(jid, nick, self.plugin, account)
|
||||||
|
|
||||||
def on_message(self, jid, msg, tim, account):
|
def on_message(self, jid, msg, tim, account, encrypted = False):
|
||||||
'''when we receive a message'''
|
'''when we receive a message'''
|
||||||
if not self.contacts[account].has_key(jid):
|
if not self.contacts[account].has_key(jid):
|
||||||
keyID = ''
|
keyID = ''
|
||||||
|
@ -985,7 +985,7 @@ class Roster_window:
|
||||||
self.draw_contact(jid, account)
|
self.draw_contact(jid, account)
|
||||||
if self.plugin.systray_enabled:
|
if self.plugin.systray_enabled:
|
||||||
self.plugin.systray.add_jid(jid, account)
|
self.plugin.systray.add_jid(jid, account)
|
||||||
self.plugin.queues[account][jid].put((msg, tim))
|
self.plugin.queues[account][jid].put((msg, tim, encrypted))
|
||||||
self.nb_unread += 1
|
self.nb_unread += 1
|
||||||
self.show_title()
|
self.show_title()
|
||||||
if not path:
|
if not path:
|
||||||
|
@ -1005,7 +1005,7 @@ class Roster_window:
|
||||||
self.tree.scroll_to_cell(path)
|
self.tree.scroll_to_cell(path)
|
||||||
self.tree.set_cursor(path)
|
self.tree.set_cursor(path)
|
||||||
self.plugin.windows[account]['chats'][jid].print_conversation(msg,
|
self.plugin.windows[account]['chats'][jid].print_conversation(msg,
|
||||||
jid, tim = tim)
|
jid, tim = tim, encrypted = encrypted)
|
||||||
|
|
||||||
def on_preferences_menuitem_activate(self, widget):
|
def on_preferences_menuitem_activate(self, widget):
|
||||||
if self.plugin.windows['preferences'].window.get_property('visible'):
|
if self.plugin.windows['preferences'].window.get_property('visible'):
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Tabbed_chat_window(chat.Chat):
|
||||||
def __init__(self, user, plugin, account):
|
def __init__(self, user, plugin, account):
|
||||||
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
|
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
|
||||||
self.users = {}
|
self.users = {}
|
||||||
|
self.encrypted = {}
|
||||||
self.new_user(user)
|
self.new_user(user)
|
||||||
self.show_title()
|
self.show_title()
|
||||||
self.xml.signal_connect('on_tabbed_chat_window_destroy',
|
self.xml.signal_connect('on_tabbed_chat_window_destroy',
|
||||||
|
@ -176,6 +177,7 @@ class Tabbed_chat_window(chat.Chat):
|
||||||
self.childs[user.jid] = self.xmls[user.jid].get_widget('chats_vbox')
|
self.childs[user.jid] = self.xmls[user.jid].get_widget('chats_vbox')
|
||||||
chat.Chat.new_tab(self, user.jid)
|
chat.Chat.new_tab(self, user.jid)
|
||||||
self.users[user.jid] = user
|
self.users[user.jid] = user
|
||||||
|
self.encrypted[user.jid] = False
|
||||||
|
|
||||||
self.redraw_tab(user.jid)
|
self.redraw_tab(user.jid)
|
||||||
self.draw_widgets(user)
|
self.draw_widgets(user)
|
||||||
|
@ -233,11 +235,13 @@ class Tabbed_chat_window(chat.Chat):
|
||||||
self.on_clear(None, widget) # clear message textview too
|
self.on_clear(None, widget) # clear message textview too
|
||||||
return True
|
return True
|
||||||
keyID = ''
|
keyID = ''
|
||||||
|
encrypted = False
|
||||||
if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
|
if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
|
||||||
keyID = self.users[jid].keyID
|
keyID = self.users[jid].keyID
|
||||||
|
encrypted = True
|
||||||
gajim.connections[self.account].send_message(jid, message, keyID)
|
gajim.connections[self.account].send_message(jid, message, keyID)
|
||||||
message_buffer.set_text('', -1)
|
message_buffer.set_text('', -1)
|
||||||
self.print_conversation(message, jid, jid)
|
self.print_conversation(message, jid, jid, encrypted = encrypted)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_contact_button_clicked(self, widget):
|
def on_contact_button_clicked(self, widget):
|
||||||
|
@ -251,7 +255,8 @@ class Tabbed_chat_window(chat.Chat):
|
||||||
user = self.users[jid]
|
user = self.users[jid]
|
||||||
while not q.empty():
|
while not q.empty():
|
||||||
event = q.get()
|
event = q.get()
|
||||||
self.print_conversation(event[0], jid, tim = event[1])
|
self.print_conversation(event[0], jid, tim = event[1],
|
||||||
|
encrypted = event[2])
|
||||||
self.plugin.roster.nb_unread -= 1
|
self.plugin.roster.nb_unread -= 1
|
||||||
self.plugin.roster.show_title()
|
self.plugin.roster.show_title()
|
||||||
del self.plugin.queues[self.account][jid]
|
del self.plugin.queues[self.account][jid]
|
||||||
|
@ -264,7 +269,8 @@ class Tabbed_chat_window(chat.Chat):
|
||||||
if len(self.plugin.roster.contacts[self.account][jid]) == 1:
|
if len(self.plugin.roster.contacts[self.account][jid]) == 1:
|
||||||
self.plugin.roster.really_remove_user(user, self.account)
|
self.plugin.roster.really_remove_user(user, self.account)
|
||||||
|
|
||||||
def print_conversation(self, text, jid, contact = '', tim = None):
|
def print_conversation(self, text, jid, contact = '', tim = None,
|
||||||
|
encrypted = False):
|
||||||
"""Print a line in the conversation:
|
"""Print a line in the conversation:
|
||||||
if contact is set to status: it's a status message
|
if contact is set to status: it's a status message
|
||||||
if contact is set to another value: it's an outgoing message
|
if contact is set to another value: it's an outgoing message
|
||||||
|
@ -274,6 +280,14 @@ class Tabbed_chat_window(chat.Chat):
|
||||||
kind = 'status'
|
kind = 'status'
|
||||||
name = ''
|
name = ''
|
||||||
else:
|
else:
|
||||||
|
if encrypted and not self.encrypted[jid]:
|
||||||
|
chat.Chat.print_conversation_line(self, 'Encryption enabled', jid,
|
||||||
|
'status', '', tim)
|
||||||
|
if not encrypted and self.encrypted[jid]:
|
||||||
|
chat.Chat.print_conversation_line(self, 'Encryption disabled', jid,
|
||||||
|
'status', '', tim)
|
||||||
|
self.encrypted[jid] = encrypted
|
||||||
|
self.xmls[jid].get_widget('gpg_togglebutton').set_active(encrypted)
|
||||||
if contact:
|
if contact:
|
||||||
kind = 'outgoing'
|
kind = 'outgoing'
|
||||||
name = self.plugin.nicks[self.account]
|
name = self.plugin.nicks[self.account]
|
||||||
|
|
Loading…
Reference in New Issue