Author: asterix Date: 2007-04-24 21:56:24 +0200 (Tue, 24 Apr 2007) New Revision: 8100
Added: trunk/data/glade/blocked_contacts_window.glade Modified: trunk/data/glade/advanced_menuitem_menu.glade trunk/data/glade/roster_contact_context_menu.glade trunk/po/fr.po trunk/src/common/connection.py trunk/src/common/connection_handlers.py trunk/src/dialogs.py trunk/src/gajim.py trunk/src/roster_window.py Log: [roidelapluie] add ability to block / unblock a contact / group directly from roster. see #253
Modified: trunk/data/glade/advanced_menuitem_menu.glade =================================================================== --- trunk/data/glade/advanced_menuitem_menu.glade 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/data/glade/advanced_menuitem_menu.glade 2007-04-24 19:56:24 UTC (rev 8100) @@ -11,7 +11,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1457"> + <widget class="GtkImage" id="image1461"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -32,6 +32,15 @@ </child>
<child> + <widget class="GtkMenuItem" id="blocked_contacts_menuitem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Blocked Contacts</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_blocked_contacts_menuitem_activate" last_modification_time="Thu, 19 Apr 2007 15:32:47 GMT"/> + </widget> + </child> + + <child> <widget class="GtkMenuItem" id="privacy_lists_menuitem"> <property name="label" translatable="yes">_Privacy Lists</property> <property name="use_underline">True</property> @@ -58,7 +67,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1458"> + <widget class="GtkImage" id="image1462"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -100,7 +109,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1459"> + <widget class="GtkImage" id="image1463"> <property name="visible">True</property> <property name="stock">gtk-clear</property> <property name="icon_size">1</property>
Added: trunk/data/glade/blocked_contacts_window.glade =================================================================== --- trunk/data/glade/blocked_contacts_window.glade (rev 0) +++ trunk/data/glade/blocked_contacts_window.glade 2007-04-24 19:56:24 UTC (rev 8100) @@ -0,0 +1,84 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="blocked_contacts_window"> + <property name="visible">True</property> + <property name="title" translatable="yes">Blocked Contacts</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <signal name="destroy" handler="on_blocked_contacts_window_destroy" last_modification_time="Sun, 22 Apr 2007 14:44:11 GMT"/> + + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkScrolledWindow" id="contacts_scrolledwindow"> + <property name="border_width">3</property> + <property name="width_request">250</property> + <property name="height_request">300</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="contacts_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="rules_hint">True</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="remove_button"> + <property name="border_width">3</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-remove</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_remove_button_clicked" last_modification_time="Sun, 22 Apr 2007 14:02:48 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface>
Modified: trunk/data/glade/roster_contact_context_menu.glade =================================================================== --- trunk/data/glade/roster_contact_context_menu.glade 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/data/glade/roster_contact_context_menu.glade 2007-04-24 19:56:24 UTC (rev 8100) @@ -12,7 +12,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1569"> + <widget class="GtkImage" id="image1650"> <property name="visible">True</property> <property name="stock">gtk-jump-to</property> <property name="icon_size">1</property> @@ -32,7 +32,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1570"> + <widget class="GtkImage" id="image1651"> <property name="visible">True</property> <property name="stock">gtk-go-up</property> <property name="icon_size">1</property> @@ -52,7 +52,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1571"> + <widget class="GtkImage" id="image1652"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -72,7 +72,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1572"> + <widget class="GtkImage" id="image1653"> <property name="visible">True</property> <property name="stock">gtk-go-back</property> <property name="icon_size">1</property> @@ -91,7 +91,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1573"> + <widget class="GtkImage" id="image1654"> <property name="visible">True</property> <property name="stock">gtk-refresh</property> <property name="icon_size">1</property> @@ -112,6 +112,48 @@ </child>
<child> + <widget class="GtkImageMenuItem" id="block_menuitem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Block</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_block_menuitem_activate" last_modification_time="Sun, 22 Apr 2007 10:35:33 GMT"/> + + <child internal-child="image"> + <widget class="GtkImage" id="image1655"> + <property name="visible">True</property> + <property name="stock">gtk-stop</property> + <property name="icon_size">1</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkImageMenuItem" id="unblock_menuitem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Unblock</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_unblock_menuitem_activate" last_modification_time="Sun, 22 Apr 2007 12:08:00 GMT"/> + + <child internal-child="image"> + <widget class="GtkImage" id="image1656"> + <property name="visible">True</property> + <property name="stock">gtk-stop</property> + <property name="icon_size">1</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + </child> + + <child> <widget class="GtkSeparatorMenuItem" id="above_send_file_separator"> <property name="visible">True</property> </widget> @@ -124,7 +166,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1574"> + <widget class="GtkImage" id="image1657"> <property name="visible">True</property> <property name="stock">gtk-file</property> <property name="icon_size">1</property> @@ -144,7 +186,7 @@ <signal name="activate" handler="on_assign_openpgp_key_menuitem_activate" last_modification_time="Thu, 30 Jun 2005 22:57:59 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1575"> + <widget class="GtkImage" id="image1658"> <property name="visible">True</property> <property name="stock">gtk-dialog-authentication</property> <property name="icon_size">1</property> @@ -164,7 +206,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1576"> + <widget class="GtkImage" id="image1659"> <property name="visible">True</property> <property name="stock">gtk-info</property> <property name="icon_size">1</property> @@ -184,7 +226,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1577"> + <widget class="GtkImage" id="image1660"> <property name="visible">True</property> <property name="stock">gtk-execute</property> <property name="icon_size">1</property> @@ -209,7 +251,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1578"> + <widget class="GtkImage" id="image1661"> <property name="visible">True</property> <property name="stock">gtk-dialog-question</property> <property name="icon_size">1</property> @@ -230,7 +272,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1579"> + <widget class="GtkImage" id="image1662"> <property name="visible">True</property> <property name="stock">gtk-go-up</property> <property name="icon_size">1</property> @@ -250,7 +292,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1580"> + <widget class="GtkImage" id="image1663"> <property name="visible">True</property> <property name="stock">gtk-go-down</property> <property name="icon_size">1</property> @@ -270,7 +312,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1581"> + <widget class="GtkImage" id="image1664"> <property name="visible">True</property> <property name="stock">gtk-stop</property> <property name="icon_size">1</property> @@ -293,7 +335,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1582"> + <widget class="GtkImage" id="image1665"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -312,7 +354,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1583"> + <widget class="GtkImage" id="image1666"> <property name="visible">True</property> <property name="stock">gtk-remove</property> <property name="icon_size">1</property> @@ -344,7 +386,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1584"> + <widget class="GtkImage" id="image1667"> <property name="visible">True</property> <property name="stock">gtk-justify-fill</property> <property name="icon_size">1</property>
Modified: trunk/po/fr.po =================================================================== --- trunk/po/fr.po 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/po/fr.po 2007-04-24 19:56:24 UTC (rev 8100) @@ -6504,6 +6504,21 @@ msgid "Error while adding service. %s" msgstr "Erreur en ajoutant le service. %s"
+msgid "_Blocked Contacts" +msgstr "Contacts _Bloqués" + +msgid "Blocked Contacts for %s" +msgstr "Contacts Bloqués avec le compte %s" + +msgid "Blocked Contacts" +msgstr "Contacts Bloqués" + +msgid "_Block" +msgstr "_Bloquer" + +msgid "_Unblock" +msgstr "_Débloquer" + #~ msgid "2003-12-13T18:30:02Z" #~ msgstr "2003-12-13T18:30:02Z" #~ msgid "<small>Romeo and Juliet</small>"
Modified: trunk/src/common/connection.py =================================================================== --- trunk/src/common/connection.py 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/src/common/connection.py 2007-04-24 19:56:24 UTC (rev 8100) @@ -87,6 +87,9 @@ else: self.keepalives = 0 self.privacy_rules_supported = False + self.blocked_list = [] + self.blocked_contacts = [] + self.blocked_groups = [] self.pep_supported = False # Do we continue connection when we get roster (send presence,get vcard...) self.continue_connect_info = None @@ -741,7 +744,7 @@ msg = '' keyID = gajim.config.get_per('accounts', self.name, 'keyid') if show == 'offline': - p = common.xmpp.Presence(typ = 'unavailable') + p = common.xmpp.Presence(typ = 'unavailable', to = jid) p = self.add_sha(p, False) if msg: p.setStatus(msg)
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/src/common/connection_handlers.py 2007-04-24 19:56:24 UTC (rev 8100) @@ -1051,6 +1051,7 @@ elif self.awaiting_answers[id][0] == PRIVACY_ARRIVED: if iq_obj.getType() != 'error': self.privacy_rules_supported = True + self.get_privacy_list('block') # Ask metacontacts before roster self.get_metacontacts()
Modified: trunk/src/dialogs.py =================================================================== --- trunk/src/dialogs.py 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/src/dialogs.py 2007-04-24 19:56:24 UTC (rev 8100) @@ -2276,7 +2276,7 @@
gajim.connections[self.account].set_privacy_list( self.privacy_list_name, tags) - self.privacy_list_received(tags) + self.refresh_rules() self.add_edit_vbox.hide() if 'privacy_lists' in gajim.interface.instances[self.account]: win = gajim.interface.instances[self.account]['privacy_lists'] @@ -2299,6 +2299,78 @@ def on_close_button_clicked(self, widget): self.window.destroy()
+class BlockedContactsWindow: + '''Window that is the main window for ContactWindows;''' + def __init__(self, account): + self.account = account + self.xml = gtkgui_helpers.get_glade('blocked_contacts_window.glade') + self.window = self.xml.get_widget('blocked_contacts_window') + self.remove_button = self.xml.get_widget('remove_button') + self.contacts_treeview = self.xml.get_widget('contacts_treeview') + renderer = gtk.CellRendererText() + + + self.store = gtk.ListStore(str) + self.contacts_treeview.set_model(self.store) + + column = gtk.TreeViewColumn("Contact", renderer, text=0) + self.contacts_treeview.append_column(column) + + if len(gajim.connections) > 1: + title = _('Blocked Contacts for %s') % self.account + else: + title = _('Blocked Contacts') + self.window.set_title(title) + + self.window.show_all() + self.xml.signal_autoconnect(self) + gajim.connections[self.account].get_privacy_list('block') + + def on_blocked_contacts_window_destroy(self, widget): + key_name = 'blocked_contacts' + if key_name in gajim.interface.instances[self.account]: + del gajim.interface.instances[self.account][key_name] + + def on_remove_button_clicked(self, widget): + tags=[] + rule_selected = self.store.get_path( + self.contacts_treeview.get_selection().get_selected()[1])[0] + for i in range(0,len(self.global_rules)): + if i != rule_selected: + tags.append(self.global_rules[i]) + for rule in self.global_rules_to_append: + tags.append(rule) + gajim.connections[self.account].set_privacy_list( + 'block', tags) + gajim.connections[self.account].set_active_list('block') + gajim.connections[self.account].set_default_list('block') + gajim.connections[self.account].get_privacy_list('block') + if len(tags) == 0: + self.privacy_list_received([]) + gajim.connections[self.account].blocked_contacts = [] + gajim.connections[self.account].blocked_list = [] + gajim.connections[self.account].set_default_list('') + gajim.connections[self.account].set_active_list('') + gajim.connections[self.account].del_privacy_list('block') + + + def privacy_list_received(self, rules): + self.store.clear() + self.global_rules = [] + self.global_rules_to_append = [] + for rule in rules: + if rule['type'] == "jid" and rule['action'] == "deny": + #self.global_rules[text_item] = rule + self.store.append([rule['value']]) + self.global_rules.append(rule) + elif rule['type'] == "group" and rule['action'] == "deny": + text_item = _('Group %s') % rule['value'] + self.store.append([text_item]) + self.global_rules.append(rule) + else: + self.global_rules_to_append.append(rule) + + class PrivacyListsWindow: '''Window that is the main window for Privacy Lists; we can list there the privacy lists and ask to create a new one
Modified: trunk/src/gajim.py =================================================================== --- trunk/src/gajim.py 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/src/gajim.py 2007-04-24 19:56:24 UTC (rev 8100) @@ -1620,6 +1620,25 @@ if self.instances[account].has_key('privacy_list_%s' % name): self.instances[account]['privacy_list_%s' % name].\ privacy_list_received(rules) + if name == 'block': + gajim.connections[account].blocked_contacts = [] + gajim.connections[account].blocked_groups = [] + gajim.connections[account].blocked_list = [] + for rule in rules: + if rule['type'] == 'jid' and rule['action'] == 'deny': + gajim.connections[account].blocked_contacts.append(rule['value']) + if rule['type'] == 'group' and rule['action'] == 'deny': + gajim.connections[account].blocked_groups.append(rule['value']) + gajim.connections[account].blocked_list.append(rule) + #elif rule['type'] == "group" and action == "deny": + # text_item = _('%s group "%s"') % _(rule['action']), rule['value'] + # self.store.append([text_item]) + # self.global_rules.append(rule) + #else: + # self.global_rules_to_append.append(rule) + if self.instances[account].has_key('blocked_contacts'): + self.instances[account]['blocked_contacts'].\ + privacy_list_received(rules)
def handle_event_privacy_lists_active_default(self, account, data): if not data:
Modified: trunk/src/roster_window.py =================================================================== --- trunk/src/roster_window.py 2007-04-24 18:43:13 UTC (rev 8099) +++ trunk/src/roster_window.py 2007-04-24 19:56:24 UTC (rev 8100) @@ -730,6 +730,13 @@ else: gajim.interface.instances[account]['privacy_lists'] = \ dialogs.PrivacyListsWindow(account) + + def on_blocked_contacts_menuitem_activate(self, widget, account): + if gajim.interface.instances[account].has_key('blocked_contacts'): + gajim.interface.instances[account]['blocked_contacts'].window.present() + else: + gajim.interface.instances[account]['blocked_contacts'] = \ + dialogs.BlockedContactsWindow(account)
def on_set_motd_menuitem_activate(self, widget, account): server = gajim.config.get_per('accounts', account, 'hostname') @@ -763,6 +770,7 @@ send_single_message_menuitem = xml.get_widget( 'send_single_message_menuitem') xml_console_menuitem = xml.get_widget('xml_console_menuitem') + blocked_contacts_menuitem = xml.get_widget('blocked_contacts_menuitem') privacy_lists_menuitem = xml.get_widget('privacy_lists_menuitem') administrator_menuitem = xml.get_widget('administrator_menuitem') send_server_message_menuitem = xml.get_widget( @@ -776,9 +784,12 @@
if gajim.connections[account] and gajim.connections[account].\ privacy_rules_supported: + blocked_contacts_menuitem.connect('activate', + self.on_blocked_contacts_menuitem_activate, account) privacy_lists_menuitem.connect('activate', self.on_privacy_lists_menuitem_activate, account) else: + blocked_contacts_menuitem.set_sensitive(False) privacy_lists_menuitem.set_sensitive(False)
if gajim.connections[account].is_zeroconf: @@ -1413,6 +1424,97 @@ self.dialog = dialogs.ConfirmationDialog(pritext, sectext, on_response_ok = (remove, list_))
+ def on_block(self, widget, iter, blockedlist): + model = self.tree.get_model() + accounts = [] + if blockedlist == None: + jid = model[iter][C_JID].decode('utf-8') + account = model[iter][C_ACCOUNT].decode('utf-8') + accounts.append(account) + msg = self.get_status_message('offline') + self.send_status(account, 'offline', msg, to = jid) + new_rule = {'order': u'1', 'type': u'jid', 'action': u'deny', + 'value' : jid, 'child': [u'message', u'iq', u'presence-out']} + else: + model = self.tree.get_model() + group = model[iter][C_JID].decode('utf-8') + msg = self.get_status_message('offline') + for (contact, account) in blockedlist: + if account not in accounts: + if gajim.connections[account].privacy_rules_supported: + accounts.append(account) + self.send_status(account, 'offline', msg, to = contact.jid) + else: + self.send_status(account, 'offline', msg, to = contact.jid) + new_rule = {'order': u'1', 'type': u'group', 'action': u'deny', + 'value' : group, 'child': [u'message', u'iq', u'presence-out']} + for account in accounts: + gajim.connections[account].blocked_list.append(new_rule) + gajim.connections[account].set_privacy_list( + 'block', gajim.connections[account].blocked_list) + if len(gajim.connections[account].blocked_list) == 1: + gajim.connections[account].set_active_list('block') + gajim.connections[account].set_default_list('block') + gajim.connections[account].get_privacy_list('block') + + def on_unblock(self, widget, iter, blockedlist): + model = self.tree.get_model() + accounts = [] + if blockedlist == None: + jid = model[iter][C_JID].decode('utf-8') + jid_account = model[iter][C_ACCOUNT].decode('utf-8') + accounts.append(jid_account) + gajim.connections[jid_account].new_blocked_list = [] + for rule in gajim.connections[jid_account].blocked_list: + if rule['action'] != 'deny' or rule['type'] != 'jid' or rule['value'] != jid: + gajim.connections[jid_account].new_blocked_list.append(rule) + else: + model = self.tree.get_model() + group = model[iter][C_JID].decode('utf-8') + for (contact, account) in blockedlist: + if account not in accounts: + if gajim.connections[account].privacy_rules_supported: + accounts.append(account) + gajim.connections[account].new_blocked_list = [] + for rule in gajim.connections[account].blocked_list: + if rule['action'] != 'deny' or rule['type'] != 'group' or rule['value'] != group: + gajim.connections[account].new_blocked_list.append(rule) + for account in accounts: + gajim.connections[account].set_privacy_list( + 'block', gajim.connections[account].new_blocked_list) + gajim.connections[account].get_privacy_list('block') + if len(gajim.connections[account].new_blocked_list) == 0: + gajim.connections[account].blocked_list = [] + gajim.connections[account].blocked_contacts = [] + gajim.connections[account].blocked_groups = [] + gajim.connections[account].set_default_list('') + gajim.connections[account].set_active_list('') + gajim.connections[account].del_privacy_list('block') + if blockedlist == None: + status = gajim.connections[jid_account].connected + msg = gajim.connections[jid_account].status + if not self.regroup: + show = gajim.SHOW_LIST[status] + else: # accounts merged + show = helpers.get_global_show() + self.send_status(jid_account, show, msg, to = jid) + else: + for (contact, account) in blockedlist: + if not self.regroup: + show = gajim.SHOW_LIST[gajim.connections[account].connected] + else: # accounts merged + show = helpers.get_global_show() + if account not in accounts: + if gajim.connections[account].privacy_rules_supported: + accounts.append(account) + self.send_status(account, show, + gajim.connections[account].status, to = contact.jid) + else: + self.send_status(account, show, + gajim.connections[account].status, to = contact.jid) + + + def on_rename(self, widget, iter, path): # this function is called either by F2 or by Rename menuitem if gajim.interface.instances.has_key('rename'): @@ -1739,6 +1841,8 @@ send_single_message_menuitem = xml.get_widget( 'send_single_message_menuitem') invite_menuitem = xml.get_widget('invite_menuitem') + block_menuitem = xml.get_widget('block_menuitem') + unblock_menuitem = xml.get_widget('unblock_menuitem') rename_menuitem = xml.get_widget('rename_menuitem') edit_groups_menuitem = xml.get_widget('edit_groups_menuitem') # separator has with send file, assign_openpgp_key_menuitem, etc.. @@ -1968,6 +2072,22 @@ remove_from_roster_menuitem, execute_command_menuitem]: widget.set_sensitive(False)
+ if gajim.connections[account] and gajim.connections[account].\ + privacy_rules_supported: + if jid in gajim.connections[account].blocked_contacts: + block_menuitem.set_no_show_all(True) + unblock_menuitem.connect('activate', self.on_unblock, iter, None) + block_menuitem.hide() + else: + unblock_menuitem.set_no_show_all(True) + block_menuitem.connect('activate', self.on_block, iter, None) + unblock_menuitem.hide() + else: + block_menuitem.set_no_show_all(True) + unblock_menuitem.set_no_show_all(True) + block_menuitem.hide() + unblock_menuitem.hide() + event_button = gtkgui_helpers.get_possible_button_event(event)
roster_contact_context_menu.attach_to_widget(self.tree, None) @@ -2198,6 +2318,28 @@ status_menuitem.set_image(icon) status_menuitems.append(status_menuitem) menu.append(send_custom_status_menuitem) + is_blocked = False + if self.regroup: + for g_account in gajim.connections: + if group in gajim.connections[g_account].blocked_groups: + is_blocked = True + else: + if group in gajim.connections[account].blocked_groups: + is_blocked = True + + if group not in helpers.special_groups + (_('General'),): + if is_blocked: + unblock_menuitem = gtk.ImageMenuItem(_('_Unblock')) + icon = gtk.image_new_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + unblock_menuitem.set_image(icon) + unblock_menuitem.connect('activate', self.on_unblock, iter, list_) + menu.append(unblock_menuitem) + else: + block_menuitem = gtk.ImageMenuItem(_('_Block')) + icon = gtk.image_new_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + block_menuitem.set_image(icon) + block_menuitem.connect('activate', self.on_block, iter, list_) + menu.append(block_menuitem)
event_button = gtkgui_helpers.get_possible_button_event(event)