[commit-gajim] r11208 - in trunk/src: . common
asterix at gajim.org
asterix at gajim.org
Tue Apr 7 19:07:04 CEST 2009
Author: asterix
Date: 2009-04-07 19:07:04 +0200 (Tue, 07 Apr 2009)
New Revision: 11208
Modified:
trunk/src/chat_control.py
trunk/src/common/contacts.py
trunk/src/groupchat_control.py
Log:
factorize send_file action in chat / groupchat / private chat. see #3948
Modified: trunk/src/chat_control.py
===================================================================
--- trunk/src/chat_control.py 2009-04-07 11:08:12 UTC (rev 11207)
+++ trunk/src/chat_control.py 2009-04-07 17:07:04 UTC (rev 11208)
@@ -836,6 +836,34 @@
gajim.interface.instances['logs'] = \
history_window.HistoryWindow(jid, self.account)
+ def _on_send_file(self, gc_contact=None):
+ '''gc_contact can be set when we are in a groupchat control'''
+ def _on_ok(c):
+ gajim.interface.instances['file_transfers'].show_file_send_request(
+ self.account, c)
+ if self.TYPE_ID == message_control.TYPE_PM:
+ gc_contact = self.gc_contact
+ if gc_contact:
+ # gc or pm
+ gc_control = gajim.interface.msg_win_mgr.get_gc_control(
+ gc_contact.room_jid, self.account)
+ self_contact = gajim.contacts.get_gc_contact(self.account,
+ gc_control.room_jid, gc_control.nick)
+ if gc_control.is_anonymous and gc_contact.affiliation not in ['admin',
+ 'owner'] and self_contact.affiliation in ['admin', 'owner']:
+ contact = gajim.contacts.get_contact(self.account, gc_contact.jid)
+ if not contact or contact.sub not in ('both', 'to'):
+ 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_ok, gc_contact))
+ dialog.popup()
+ return
+ _on_ok(gc_contact)
+ return
+ _on_ok(self.contact)
+
def on_minimize_menuitem_toggled(self, widget):
'''When a grouchat is minimized, unparent the tab, put it in roster etc'''
old_value = False
@@ -2635,12 +2663,7 @@
self.bigger_avatar_window.window.set_cursor(cursor)
def _on_send_file_menuitem_activate(self, widget):
- if self.TYPE_ID == message_control.TYPE_PM:
- c = self.gc_contact
- else:
- c = self.contact
- gajim.interface.instances['file_transfers'].show_file_send_request(
- self.account, c)
+ self._on_send_file()
def _on_add_to_roster_menuitem_activate(self, widget):
dialogs.AddNewContactWindow(self.account, self.contact.jid)
Modified: trunk/src/common/contacts.py
===================================================================
--- trunk/src/common/contacts.py 2009-04-07 11:08:12 UTC (rev 11207)
+++ trunk/src/common/contacts.py 2009-04-07 17:07:04 UTC (rev 11208)
@@ -576,9 +576,9 @@
def contact_from_gc_contact(self, gc_contact):
'''Create a Contact instance from a GC_Contact instance'''
jid = gc_contact.get_full_jid()
- return Contact(jid=jid, resource='', name=gc_contact.name, groups=[],
- show=gc_contact.show, status=gc_contact.status, sub='none',
- caps_node=gc_contact.caps_node,
+ return Contact(jid=jid, resource=gc_contact.resource,
+ name=gc_contact.name, groups=[], show=gc_contact.show,
+ status=gc_contact.status, sub='none', caps_node=gc_contact.caps_node,
caps_hash_method=gc_contact.caps_hash_method,
caps_hash=gc_contact.caps_hash)
Modified: trunk/src/groupchat_control.py
===================================================================
--- trunk/src/groupchat_control.py 2009-04-07 11:08:12 UTC (rev 11207)
+++ trunk/src/groupchat_control.py 2009-04-07 17:07:04 UTC (rev 11208)
@@ -1004,24 +1004,7 @@
def on_send_file(self, widget, gc_contact):
'''sends a file to a contact in the room'''
- def _on_send_files(gc_c):
- 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'] and \
- gc_contact.jid not in gajim.contacts.get_jid_list(self.account):
- contact = gajim.contacts.get_contact(self.account, gc_contact.jid)
- if not contact or contact.sub not in ('both', 'to'):
- 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()
- return
- _on_send_files(gc_contact)
+ self._on_send_file(gc_contact)
def draw_contact(self, nick, selected=False, focus=False):
iter_ = self.get_contact_iter(nick)
More information about the Commits
mailing list