prevent the user before sending a file to a groupchat contact that doesn't know his real jid.

This commit is contained in:
Yann Leboulanger 2007-09-12 23:12:29 +00:00
parent b05579dc13
commit 8ec061f5f6
3 changed files with 35 additions and 10 deletions

View File

@ -1609,18 +1609,19 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if subject != None:
self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp))
else:
statusCode = msg.getStatusCode()
if not msg.getTag('body'): #no <body>
# It could be a config change. See
# http://www.xmpp.org/extensions/xep-0045.html#roomconfig-notify
if msg.getTag('x'):
statusCode = msg.getStatusCode()
if statusCode != []:
self.dispatch('GC_CONFIG_CHANGE', (jid, statusCode))
return
# Ignore message from room in which we are not
if not self.last_history_line.has_key(jid):
return
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml,
statusCode))
if self.name not in no_log_for and not int(float(mktime(tim)))\
<= self.last_history_line[jid] and msgtxt:
try:
@ -1774,12 +1775,12 @@ returns the session that we last sent a message to.'''
who = helpers.get_full_jid_from_iq(prs)
except:
if prs.getTag('error').getTag('jid-malformed'):
# wrong jid, we probably tried to change our nick in a room to a non valid
# one
# wrong jid, we probably tried to change our nick in a room to a non
# valid one
who = str(prs.getFrom())
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
self.dispatch('GC_MSG', (jid_stripped,
_('Nickname not allowed: %s') % resource, None, False, None))
_('Nickname not allowed: %s') % resource, None, False, None, []))
return
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
timestamp = None

View File

@ -1144,7 +1144,8 @@ class Interface:
self.remote_ctrl.raise_signal('GCPresence', (account, array))
def handle_event_gc_msg(self, account, array):
# ('GC_MSG', account, (jid, msg, time, has_timestamp, htmlmsg))
# ('GC_MSG', account, (jid, msg, time, has_timestamp, htmlmsg,
# [status_codes]))
jids = array[0].split('/', 1)
room_jid = jids[0]
@ -1166,7 +1167,7 @@ class Interface:
# message from someone
nick = jids[1]
gc_control.on_message(nick, array[1], array[2], array[3], xhtml)
gc_control.on_message(nick, array[1], array[2], array[3], xhtml, array[5])
contact = gajim.contacts.\
get_contact_with_highest_priority(account, room_jid)
@ -1257,6 +1258,7 @@ class Interface:
if '100' in statusCode:
# Can be a presence (see chg_contact_status in groupchat_contol.py)
changes.append(_('Any occupant is allowed to see your full JID'))
gc_control.is_anonymous = False
if '102' in statusCode:
changes.append(_('Room now shows unavailable member'))
if '103' in statusCode:
@ -1271,10 +1273,13 @@ class Interface:
changes.append(_('Room logging is now disabled'))
if '172' in statusCode:
changes.append(_('Room is now non-anonymous'))
gc_control.is_anonymous = False
if '173' in statusCode:
changes.append(_('Room is now semi-anonymous'))
gc_control.is_anonymous = True
if '174' in statusCode:
changes.append(_('Room is now fully-anonymous'))
gc_control.is_anonymous = True
for change in changes:
gc_control.print_conversation(change)

View File

@ -159,6 +159,7 @@ class GroupchatControl(ChatControlBase):
'muc_child_vbox', contact, acct);
self.is_continued=is_continued
self.is_anonymous = True
widget = self.xml.get_widget('muc_window_actions_button')
id = widget.connect('clicked', self.on_actions_button_clicked)
@ -532,7 +533,11 @@ class GroupchatControl(ChatControlBase):
self.change_nick_menuitem.set_sensitive(False)
return self.gc_popup_menu
def on_message(self, nick, msg, tim, has_timestamp = False, xhtml = None):
def on_message(self, nick, msg, tim, has_timestamp = False, xhtml = None,
status_code = []):
if '100' in status_code:
# Room is not anonymous
self.is_anonymous = False
if not nick:
# message from server
self.print_conversation(msg, tim = tim, xhtml = xhtml)
@ -842,8 +847,22 @@ class GroupchatControl(ChatControlBase):
def on_send_file(self, widget, gc_contact):
'''sends a file to a contact in the room'''
gajim.interface.instances['file_transfers'].show_file_send_request(
self.account, gc_contact)
def _on_send_files(widget, gc_c):
if widget:
widget.destroy()
gajim.interface.instances['file_transfers'].show_file_send_request(
self.account, gc_c)
self_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid,
self.nick)
if self.is_anonymous and gc_contact.affiliation not in ['admin', 'owner']\
and self_contact.affiliation in ['admin', 'owner']:
prim_text = _('Really send file?')
sec_text = _('If you send a file to %s, he/she will know your real Jabber ID.') % gc_contact.name
dialog = dialogs.NonModalConfirmationDialog(prim_text, sec_text,
on_response_ok = (_on_send_files, gc_contact))
dialog.popup()
else:
_on_send_files(None, gc_contact)
def draw_contact(self, nick, selected=False, focus=False):
iter = self.get_contact_iter(nick)