| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | import gtk |
|---|
| 22 | import gobject |
|---|
| 23 | import os |
|---|
| 24 | |
|---|
| 25 | import gtkgui_helpers |
|---|
| 26 | import vcard |
|---|
| 27 | import conversation_textview |
|---|
| 28 | import message_control |
|---|
| 29 | |
|---|
| 30 | try: |
|---|
| 31 |     import gtkspell |
|---|
| 32 | Â Â Â Â HAS_GTK_SPELL = True |
|---|
| 33 | except: |
|---|
| 34 | Â Â Â Â HAS_GTK_SPELL = False |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | from filetransfers_window import FileTransfersWindow |
|---|
| 39 | from gajim_themes_window import GajimThemesWindow |
|---|
| 40 | from advanced import AdvancedConfigurationWindow |
|---|
| 41 | |
|---|
| 42 | from common import gajim |
|---|
| 43 | from common import helpers |
|---|
| 44 | from common.exceptions import GajimGeneralException |
|---|
| 45 | |
|---|
| 46 | class EditGroupsDialog: |
|---|
| 47 | Â Â Â Â '''Class for the edit group dialog window''' |
|---|
| 48 |     def __init__(self, list_): |
|---|
| 49 | Â Â Â Â Â Â Â Â '''list_ is a list of (contact, account) tuples''' |
|---|
| 50 | Â Â Â Â Â Â Â Â self.xml = gtkgui_helpers.get_glade('edit_groups_dialog.glade') |
|---|
| 51 | Â Â Â Â Â Â Â Â self.dialog = self.xml.get_widget('edit_groups_dialog') |
|---|
| 52 | Â Â Â Â Â Â Â Â self.dialog.set_transient_for(gajim.interface.roster.window) |
|---|
| 53 | Â Â Â Â Â Â Â Â self.list_ = list_ |
|---|
| 54 | Â Â Â Â Â Â Â Â self.changes_made = False |
|---|
| 55 | Â Â Â Â Â Â Â Â self.list = self.xml.get_widget('groups_treeview') |
|---|
| 56 |         if len(list_) == 1: |
|---|
| 57 | Â Â Â Â Â Â Â Â Â Â Â Â contact = list_[0][0] |
|---|
| 58 | Â Â Â Â Â Â Â Â Â Â Â Â self.xml.get_widget('nickname_label').set_markup( |
|---|
| 59 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â _("Contact name: <i>%s</i>") % contact.get_shown_name()) |
|---|
| 60 | Â Â Â Â Â Â Â Â Â Â Â Â self.xml.get_widget('jid_label').set_markup( |
|---|
| 61 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â _('Jabber ID: <i>%s</i>') % contact.jid) |
|---|
| 62 | Â Â Â Â Â Â Â Â else: |
|---|
| 63 | Â Â Â Â Â Â Â Â Â Â Â Â self.xml.get_widget('nickname_label').set_no_show_all(True) |
|---|
| 64 | Â Â Â Â Â Â Â Â Â Â Â Â self.xml.get_widget('nickname_label').hide() |
|---|
| 65 | Â Â Â Â Â Â Â Â Â Â Â Â self.xml.get_widget('jid_label').set_no_show_all(True) |
|---|
| 66 | Â Â Â Â Â Â Â Â Â Â Â Â self.xml.get_widget('jid_label').hide() |
|---|
| 67 | |
|---|
| 68 | Â Â Â Â Â Â Â Â self.xml.signal_autoconnect(self) |
|---|
| 69 | Â Â Â Â Â Â Â Â self.init_list() |
|---|
| 70 | |
|---|
| 71 |     def run(self): |
|---|
| 72 | Â Â Â Â Â Â Â Â self.dialog.show_all() |
|---|
| 73 |         if self.changes_made: |
|---|
| 74 |             for (contact, account) in self.list_: |
|---|
| 75 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.connections[account].update_contact(contact.jid, contact.name, |
|---|
| 76 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contact.groups) |
|---|
| 77 | |
|---|
| 78 |     def on_edit_groups_dialog_response(self, widget, response_id): |
|---|
| 79 |         if response_id == gtk.RESPONSE_CLOSE: |
|---|
| 80 | Â Â Â Â Â Â Â Â Â Â Â Â self.dialog.destroy() |
|---|
| 81 | |
|---|
| 82 |     def update_contact(self): |
|---|
| 83 |         for (contact, account) in self.list_: |
|---|
| 84 | Â Â Â Â Â Â Â Â Â Â Â Â tag = gajim.contacts.get_metacontacts_tag(account, contact.jid) |
|---|
| 85 |             if not tag: |
|---|
| 86 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.interface.roster.remove_contact(contact, account) |
|---|
| 87 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.interface.roster.add_contact_to_roster(contact.jid, account) |
|---|
| 88 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.connections[account].update_contact(contact.jid, contact.name, |
|---|
| 89 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contact.groups) |
|---|
| 90 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 91 | Â Â Â Â Â Â Â Â Â Â Â Â all_jid = gajim.contacts.get_metacontacts_jids(tag) |
|---|
| 92 |             for _account in all_jid: |
|---|
| 93 |                 if not gajim.interface.roster.regroup and _account != account: |
|---|
| 94 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 95 |                 for _jid in all_jid[_account]: |
|---|
| 96 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â c = gajim.contacts.get_first_contact_from_jid(_account, _jid) |
|---|
| 97 |                     if not c: |
|---|
| 98 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 99 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.interface.roster.remove_contact(c, _account) |
|---|
| 100 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.interface.roster.add_contact_to_roster(_jid, _account) |
|---|
| 101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.connections[_account].update_contact(_jid, c.name, |
|---|
| 102 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â c.groups) |
|---|
| 103 | |
|---|
| 104 |     def remove_group(self, group): |
|---|
| 105 | Â Â Â Â Â Â Â Â '''remove group group from all contacts and all their brothers''' |
|---|
| 106 |         for (contact, account) in self.list_: |
|---|
| 107 | Â Â Â Â Â Â Â Â Â Â Â Â tag = gajim.contacts.get_metacontacts_tag(account, contact.jid) |
|---|
| 108 |             if not tag: |
|---|
| 109 |                 if group in contact.groups: |
|---|
| 110 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contact.groups.remove(group) |
|---|
| 111 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 112 | Â Â Â Â Â Â Â Â Â Â Â Â all_jid = gajim.contacts.get_metacontacts_jids(tag) |
|---|
| 113 |             for _account in all_jid: |
|---|
| 114 |                 if not gajim.interface.roster.regroup and _account != account: |
|---|
| 115 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 116 |                 for _jid in all_jid[_account]: |
|---|
| 117 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contacts = gajim.contacts.get_contact(_account, _jid) |
|---|
| 118 |                     for c in contacts: |
|---|
| 119 |                         if group in c.groups: |
|---|
| 120 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â c.groups.remove(group) |
|---|
| 121 | |
|---|
| 122 |     def add_group(self, group): |
|---|
| 123 | Â Â Â Â Â Â Â Â '''add group group to all contacts and all their brothers''' |
|---|
| 124 |         for (contact, account) in self.list_: |
|---|
| 125 | Â Â Â Â Â Â Â Â Â Â Â Â tag = gajim.contacts.get_metacontacts_tag(account, contact.jid) |
|---|
| 126 |             if not tag: |
|---|
| 127 |                 if group not in contact.groups: |
|---|
| 128 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contact.groups.append(group) |
|---|
| 129 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 130 | Â Â Â Â Â Â Â Â Â Â Â Â all_jid = gajim.contacts.get_metacontacts_jids(tag) |
|---|
| 131 |             for _account in all_jid: |
|---|
| 132 |                 if not gajim.interface.roster.regroup and _account != account: |
|---|
| 133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 134 |                 for _jid in all_jid[_account]: |
|---|
| 135 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contacts = gajim.contacts.get_contact(_account, _jid) |
|---|
| 136 |                     for c in contacts: |
|---|
| 137 |                         if not group in c.groups: |
|---|
| 138 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â c.groups.append(group) |
|---|
| 139 | |
|---|
| 140 |     def on_add_button_clicked(self, widget): |
|---|
| 141 | Â Â Â Â Â Â Â Â group = self.xml.get_widget('group_entry').get_text().decode('utf-8') |
|---|
| 142 |         if not group: |
|---|
| 143 | Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 144 | Â Â Â Â Â Â Â Â |
|---|
| 145 |         if group in helpers.special_groups: |
|---|
| 146 | Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 147 | Â Â Â Â Â Â Â Â |
|---|
| 148 | Â Â Â Â Â Â Â Â model = self.list.get_model() |
|---|
| 149 | Â Â Â Â Â Â Â Â iter = model.get_iter_root() |
|---|
| 150 |         while iter: |
|---|
| 151 |             if model.get_value(iter, 0).decode('utf-8') == group: |
|---|
| 152 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 153 | Â Â Â Â Â Â Â Â Â Â Â Â iter = model.iter_next(iter) |
|---|
| 154 | Â Â Â Â Â Â Â Â self.changes_made = True |
|---|
| 155 | Â Â Â Â Â Â Â Â model.append((group, True, False)) |
|---|
| 156 | Â Â Â Â Â Â Â Â self.add_group(group) |
|---|
| 157 | Â Â Â Â Â Â Â Â self.update_contact() |
|---|
| 158 | Â Â Â Â Â Â Â Â self.init_list() |
|---|
| 159 | |
|---|
| 160 |     def group_toggled_cb(self, cell, path): |
|---|
| 161 | Â Â Â Â Â Â Â Â self.changes_made = True |
|---|
| 162 | Â Â Â Â Â Â Â Â model = self.list.get_model() |
|---|
| 163 |         if model[path][2]: |
|---|
| 164 | Â Â Â Â Â Â Â Â Â Â Â Â model[path][2] = False |
|---|
| 165 | Â Â Â Â Â Â Â Â Â Â Â Â model[path][1] = True |
|---|
| 166 | Â Â Â Â Â Â Â Â else: |
|---|
| 167 |             model[path][1] = not model[path][1] |
|---|
| 168 | Â Â Â Â Â Â Â Â group = model[path][0].decode('utf-8') |
|---|
| 169 |         if model[path][1]: |
|---|
| 170 | Â Â Â Â Â Â Â Â Â Â Â Â self.add_group(group) |
|---|
| 171 | Â Â Â Â Â Â Â Â else: |
|---|
| 172 | Â Â Â Â Â Â Â Â Â Â Â Â self.remove_group(group) |
|---|
| 173 | Â Â Â Â Â Â Â Â self.update_contact() |
|---|
| 174 | |
|---|
| 175 |     def init_list(self): |
|---|
| 176 | Â Â Â Â Â Â Â Â store = gtk.ListStore(str, bool, bool) |
|---|
| 177 | Â Â Â Â Â Â Â Â self.list.set_model(store) |
|---|
| 178 |         for column in self.list.get_columns(): |
|---|
| 179 | Â Â Â Â Â Â Â Â Â Â Â Â self.list.remove_column(column) |
|---|
| 180 | Â Â Â Â Â Â Â Â accounts = [] |
|---|
| 181 | Â Â Â Â Â Â Â Â |
|---|
| 182 | Â Â Â Â Â Â Â Â |
|---|
| 183 | Â Â Â Â Â Â Â Â groups = {} |
|---|
| 184 |         for (contact, account) in self.list_: |
|---|
| 185 |             if account not in accounts: |
|---|
| 186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accounts.append(account) |
|---|
| 187 |                 for g in gajim.groups[account].keys(): |
|---|
| 188 |                     if g in groups: |
|---|
| 189 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 190 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â groups[g] = 0 |
|---|
| 191 |             for g in contact.groups: |
|---|
| 192 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â groups[g] += 1 |
|---|
| 193 | Â Â Â Â Â Â Â Â group_list = [] |
|---|
| 194 | Â Â Â Â Â Â Â Â |
|---|
| 195 |         for group in groups: |
|---|
| 196 |             if group not in helpers.special_groups or groups[group] > 0: |
|---|
| 197 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â group_list.append(group) |
|---|
| 198 | Â Â Â Â Â Â Â Â group_list.sort()Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 199 |         for group in group_list: |
|---|
| 200 | Â Â Â Â Â Â Â Â Â Â Â Â iter = store.append() |
|---|
| 201 | Â Â Â Â Â Â Â Â Â Â Â Â store.set(iter, 0, group) |
|---|
| 202 |             if groups[group] == 0: |
|---|
| 203 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â store.set(iter, 1, False) |
|---|
| 204 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 205 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â store.set(iter, 1, True) |
|---|
| 206 |                 if groups[group] == len(self.list_): |
|---|
| 207 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 208 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â store.set(iter, 2, False) |
|---|
| 209 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 210 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â store.set(iter, 2, True) |
|---|
| 211 | Â Â Â Â Â Â Â Â column = gtk.TreeViewColumn(_('Group')) |
|---|
| 212 | Â Â Â Â Â Â Â Â column.set_expand(True) |
|---|
| 213 | Â Â Â Â Â Â Â Â self.list.append_column(column) |
|---|
| 214 | Â Â Â Â Â Â Â Â renderer = gtk.CellRendererText() |
|---|
| 215 | Â Â Â Â Â Â Â Â column.pack_start(renderer) |
|---|
| 216 | Â Â Â Â Â Â Â Â column.set_attributes(renderer, text = 0) |
|---|
| 217 | |
|---|
| 218 | Â Â Â Â Â Â Â Â column = gtk.TreeViewColumn(_('In the group')) |
|---|
| 219 | Â Â Â Â Â Â Â Â column.set_expand(False) |
|---|
| 220 | Â Â Â Â Â Â Â Â self.list.append_column(column) |
|---|
| 221 | Â Â Â Â Â Â Â Â renderer = gtk.CellRendererToggle() |
|---|
| 222 | Â Â Â Â Â Â Â Â column.pack_start(renderer) |
|---|
| 223 | Â Â Â Â Â Â Â Â renderer.set_property('activatable', True) |
|---|
| 224 | Â Â Â Â Â Â Â Â renderer.connect('toggled', self.group_toggled_cb) |
|---|
| 225 | Â Â Â Â Â Â Â Â column.set_attributes(renderer, active = 1, inconsistent = 2) |
|---|
| 226 | |
|---|
| 227 | class PassphraseDialog: |
|---|
| 228 | Â Â Â Â '''Class for Passphrase dialog''' |
|---|
| 229 |     def run(self): |
|---|
| 230 | Â Â Â Â Â Â Â Â '''Wait for OK button to be pressed and return passphrase/password''' |
|---|
| 231 | Â Â Â Â Â Â Â Â rep = self.window.run() |
|---|
| 232 |         if rep == gtk.RESPONSE_OK: |
|---|
| 233 | Â Â Â Â Â Â Â Â Â Â Â Â passphrase = self.passphrase_entry.get_text().decode('utf-8') |
|---|
| 234 | Â Â Â Â Â Â Â Â else: |
|---|
| 235 | Â Â Â Â Â Â Â Â Â Â Â Â passphrase = -1 |
|---|
| 236 | Â Â Â Â Â Â Â Â save_passphrase_checkbutton = self.xml.\ |
|---|
| 237 | Â Â Â Â Â Â Â Â Â Â Â Â get_widget('save_passphrase_checkbutton') |
|---|
| 238 | Â Â Â Â Â Â Â Â self.window.destroy() |
|---|
| 239 |         return passphrase, save_passphrase_checkbutton.get_active() |
|---|
| 240 | |
|---|
| 241 |     def __init__(self, titletext, labeltext, checkbuttontext): |
|---|
| 242 | Â Â Â Â Â Â Â Â self.xml = gtkgui_helpers.get_glade('passphrase_dialog.glade') |
|---|
| 243 | Â Â Â Â Â Â Â Â self.window = self.xml.get_widget('passphrase_dialog') |
|---|
| 244 | Â Â Â Â Â Â Â Â self.passphrase_entry = self.xml.get_widget('passphrase_entry') |
|---|
| 245 | Â Â Â Â Â Â Â Â self.passphrase = -1 |
|---|
| 246 | Â Â Â Â Â Â Â Â self.window.set_title(titletext) |
|---|
| 247 | Â Â Â Â Â Â Â Â self.xml.get_widget('message_label').set_text(labeltext) |
|---|
| 248 | Â Â Â Â Â Â Â Â self.xml.get_widget('save_passphrase_checkbutton').set_label( |
|---|
| 249 | Â Â Â Â Â Â Â Â Â Â Â Â checkbuttontext) |
|---|
| 250 | Â Â Â Â Â Â Â Â self.xml.signal_autoconnect(self) |
|---|
| 251 | Â Â Â Â Â Â Â Â self.window.show_all() |
|---|
| 252 | |
|---|
| 253 | class ChooseGPGKeyDialog: |
|---|
| 254 | Â Â Â Â '''Class for GPG key dialog''' |
|---|
| 255 |     def __init__(self, title_text, prompt_text, secret_keys, selected = None): |
|---|
| 256 | Â Â Â Â Â Â Â Â |
|---|
| 257 | Â Â Â Â Â Â Â Â xml = gtkgui_helpers.get_glade('choose_gpg_key_dialog.glade') |
|---|
| 258 | Â Â Â Â Â Â Â Â self.window = xml.get_widget('choose_gpg_key_dialog') |
|---|
| 259 | Â Â Â Â Â Â Â Â self.window.set_title(title_text) |
|---|
| 260 | Â Â Â Â Â Â Â Â self.keys_treeview = xml.get_widget('keys_treeview') |
|---|
| 261 | Â Â Â Â Â Â Â Â prompt_label = xml.get_widget('prompt_label') |
|---|
| 262 | Â Â Â Â Â Â Â Â prompt_label.set_text(prompt_text) |
|---|
| 263 | Â Â Â Â Â Â Â Â model = gtk.ListStore(str, str) |
|---|
| 264 | Â Â Â Â Â Â Â Â model.set_sort_func(1, self.sort_keys) |
|---|
| 265 | Â Â Â Â Â Â Â Â model.set_sort_column_id(1, gtk.SORT_ASCENDING) |
|---|
| 266 | Â Â Â Â Â Â Â Â self.keys_treeview.set_model(model) |
|---|
| 267 | Â Â Â Â Â Â Â Â |
|---|
| 268 | Â Â Â Â Â Â Â Â renderer = gtk.CellRendererText() |
|---|
| 269 | Â Â Â Â Â Â Â Â self.keys_treeview.insert_column_with_attributes(-1, _('KeyID'), |
|---|
| 270 | Â Â Â Â Â Â Â Â Â Â Â Â renderer, text = 0) |
|---|
| 271 | Â Â Â Â Â Â Â Â renderer = gtk.CellRendererText() |
|---|
| 272 | Â Â Â Â Â Â Â Â self.keys_treeview.insert_column_with_attributes(-1, _('Contact name'), |
|---|
| 273 | Â Â Â Â Â Â Â Â Â Â Â Â renderer, text = 1) |
|---|
| 274 | Â Â Â Â Â Â Â Â self.keys_treeview.set_search_column(1) |
|---|
| 275 | Â Â Â Â Â Â Â Â self.fill_tree(secret_keys, selected) |
|---|
| 276 | Â Â Â Â Â Â Â Â self.window.show_all() |
|---|
| 277 | |
|---|
| 278 |     def sort_keys(self, model, iter1, iter2): |
|---|
| 279 | Â Â Â Â Â Â Â Â value1 = model[iter1][1] |
|---|
| 280 | Â Â Â Â Â Â Â Â value2 = model[iter2][1] |
|---|
| 281 |         if value1 == _('None'): |
|---|
| 282 |             return -1 |
|---|
| 283 |         elif value2 == _('None'): |
|---|
| 284 |             return 1 |
|---|
| 285 |         elif value1 < value2: |
|---|
| 286 |             return -1 |
|---|
| 287 |         return 1 |
|---|
| 288 | |
|---|
| 289 |     def run(self): |
|---|
| 290 | Â Â Â Â Â Â Â Â rep = self.window.run() |
|---|
| 291 |         if rep == gtk.RESPONSE_OK: |
|---|
| 292 | Â Â Â Â Â Â Â Â Â Â Â Â selection = self.keys_treeview.get_selection() |
|---|
| 293 | Â Â Â Â Â Â Â Â Â Â Â Â (model, iter) = selection.get_selected() |
|---|
| 294 | Â Â Â Â Â Â Â Â Â Â Â Â keyID = [ model[iter][0].decode('utf-8'), |
|---|
| 295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model[iter][1].decode('utf-8') ] |
|---|
| 296 | Â Â Â Â Â Â Â Â else: |
|---|
| 297 | Â Â Â Â Â Â Â Â Â Â Â Â keyID = None |
|---|
| 298 | Â Â Â Â Â Â Â Â self.window.destroy() |
|---|
| 299 |         return keyID |
|---|
| 300 | |
|---|
| 301 |     def fill_tree(self, list, selected): |
|---|
| 302 | Â Â Â Â Â Â Â Â model = self.keys_treeview.get_model() |
|---|
| 303 |         for keyID in list.keys(): |
|---|
| 304 | Â Â Â Â Â Â Â Â Â Â Â Â iter = model.append((keyID, list[keyID])) |
|---|
| 305 |             if keyID == selected: |
|---|
| 306 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â path = model.get_path(iter) |
|---|
| 307 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.keys_treeview.set_cursor(path) |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | class ChangeStatusMessageDialog: |
|---|
| 311 |     def __init__(self, show = None): |
|---|
| 312 | Â Â Â Â Â Â Â Â self.show = show |
|---|
| 313 | Â Â Â Â Â Â Â Â self.xml = gtkgui_helpers.get_glade('change_status_message_dialog.glade') |
|---|
| 314 | Â Â Â Â Â Â Â Â self.window = self.xml.get_widget('change_status_message_dialog') |
|---|
| 315 | Â Â Â Â Â Â Â Â self.window.set_transient_for(gajim.interface.roster.window) |
|---|
| 316 |         if show: |
|---|
| 317 | Â Â Â Â Â Â Â Â Â Â Â Â uf_show = helpers.get_uf_show(show) |
|---|
| 318 | Â Â Â Â Â Â Â Â Â Â Â Â title_text = _('%s Status Message') % uf_show |
|---|
| 319 | Â Â Â Â Â Â Â Â else: |
|---|
| 320 | Â Â Â Â Â Â Â Â Â Â Â Â title_text = _('Status Message') |
|---|
| 321 | Â Â Â Â Â Â Â Â self.window.set_title(title_text) |
|---|
| 322 | |
|---|
| 323 | Â Â Â Â Â Â Â Â message_textview = self.xml.get_widget('message_textview') |
|---|
| 324 | Â Â Â Â Â Â Â Â self.message_buffer = message_textview.get_buffer() |
|---|
| 325 | Â Â Â Â Â Â Â Â self.message_buffer.connect('changed', |
|---|
| 326 | Â Â Â Â Â Â Â Â Â Â Â Â self.toggle_sensitiviy_of_save_as_preset) |
|---|
| 327 | Â Â Â Â Â Â Â Â msg = None |
|---|
| 328 |         if show: |
|---|
| 329 | Â Â Â Â Â Â Â Â Â Â Â Â msg = gajim.config.get('last_status_msg_'Â + show) |
|---|
| 330 |         if not msg: |
|---|
| 331 | Â Â Â Â Â Â Â Â Â Â Â Â msg = '' |
|---|
| 332 | Â Â Â Â Â Â Â Â msg = helpers.from_one_line(msg) |
|---|
| 333 | Â Â Â Â Â Â Â Â self.message_buffer.set_text(msg) |
|---|
| 334 | |
|---|
| 335 | Â Â Â Â Â Â Â Â |
|---|
| 336 | Â Â Â Â Â Â Â Â self.preset_messages_dict = {'': ''} |
|---|
| 337 |         for msg_name in gajim.config.get_per('statusmsg'): |
|---|
| 338 | Â Â Â Â Â Â Â Â Â Â Â Â msg_text = gajim.config.get_per('statusmsg', msg_name, 'message') |
|---|
| 339 | Â Â Â Â Â Â Â Â Â Â Â Â msg_text = helpers.from_one_line(msg_text) |
|---|
| 340 | Â Â Â Â Â Â Â Â Â Â Â Â self.preset_messages_dict[msg_name] = msg_text |
|---|
| 341 | Â Â Â Â Â Â Â Â sorted_keys_list = helpers.get_sorted_keys(self.preset_messages_dict) |
|---|
| 342 | |
|---|
| 343 | Â Â Â Â Â Â Â Â self.message_liststore = gtk.ListStore(str) |
|---|
| 344 | Â Â Â Â Â Â Â Â self.message_combobox = self.xml.get_widget('message_combobox') |
|---|
| 345 | Â Â Â Â Â Â Â Â self.message_combobox.set_model(self.message_liststore) |
|---|
| 346 | Â Â Â Â Â Â Â Â cellrenderertext = gtk.CellRendererText() |
|---|
| 347 | Â Â Â Â Â Â Â Â self.message_combobox.pack_start(cellrenderertext, True) |
|---|
| 348 | Â Â Â Â Â Â Â Â self.message_combobox.add_attribute(cellrenderertext, 'text', 0) |
|---|
| 349 |         for msg_name in sorted_keys_list: |
|---|
| 350 | Â Â Â Â Â Â Â Â Â Â Â Â self.message_liststore.append((msg_name,)) |
|---|
| 351 | Â Â Â Â Â Â Â Â self.xml.signal_autoconnect(self) |
|---|
| 352 | Â Â Â Â Â Â Â Â self.window.show_all() |
|---|
| 353 | |
|---|
| 354 |     def run(self): |
|---|
| 355 | Â Â Â Â Â Â Â Â '''Wait for OK or Cancel button to be pressed and return status messsage |
|---|
| 356 | Â Â Â Â Â Â Â Â (None if users pressed Cancel or x button of WM''' |
|---|
| 357 | Â Â Â Â Â Â Â Â rep = self.window.run() |
|---|
| 358 |         if rep == gtk.RESPONSE_OK: |
|---|
| 359 | Â Â Â Â Â Â Â Â Â Â Â Â beg, end = self.message_buffer.get_bounds() |
|---|
| 360 | Â Â Â Â Â Â Â Â Â Â Â Â message = self.message_buffer.get_text(beg, end).decode('utf-8')\ |
|---|
| 361 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â .strip() |
|---|
| 362 | Â Â Â Â Â Â Â Â Â Â Â Â msg = helpers.to_one_line(message) |
|---|
| 363 |             if self.show: |
|---|
| 364 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gajim.config.set('last_status_msg_'Â + self.show, msg) |
|---|
| 365 | Â Â Â Â Â Â Â Â else: |
|---|
| 366 | Â Â Â Â Â Â Â Â Â Â Â Â message = None |
|---|
| 367 | Â Â Â Â Â Â Â Â self.window.destroy() |
|---|
| 368 |         return message |
|---|
| 369 | |
|---|
| 370 |     def on_message_combobox_changed(self, widget): |
|---|
| 371 | Â Â Â Â Â Â Â Â model = widget.get_model() |
|---|
| 372 | Â Â Â Â Â Â Â Â active = widget.get_active() |
|---|
| 373 |         if active < 0: |
|---|
| 374 |             return None |
|---|
| 375 | Â Â Â Â Â Â Â Â name = model[active][0].decode('utf-8') |
|---|
| 376 | Â Â Â Â Â Â Â Â self.message_buffer.set_text(self.preset_messages_dict[name]) |
|---|
| 377 | |
|---|
| 378 |     def on_change_status_message_dialog_key_press_event(self, widget, event): |
|---|
| 379 |         if event.keyval == gtk.keysyms.Return or \ |
|---|
| 380 | Â Â Â Â Â Â Â Â event.keyval == gtk.keysyms.KP_Enter:Â |
|---|
| 381 |             if (event.state & gtk.gdk.CONTROL_MASK): |
|---|
| 382 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.window.response(gtk.RESPONSE_OK) |
|---|
| 383 | |
|---|
| 384 |     def toggle_sensitiviy_of_save_as_preset(self, widget): |
|---|
| 385 | Â Â Â Â Â Â Â Â btn = self.xml.get_widget('save_as_preset_button') |
|---|
| 386 |         if self.message_buffer.get_char_count() == 0: |
|---|
| 387 | Â Â Â Â Â Â Â Â Â Â Â Â btn.set_sensitive(False) |
|---|
| 388 | Â Â Â Â Â Â Â Â else: |
|---|
| 389 | Â Â Â Â Â Â Â Â Â Â Â Â btn.set_sensitive(True) |
|---|
| 390 | |
|---|
| 391 |     def on_save_as_preset_button_clicked(self, widget): |
|---|
| 392 | Â Â Â Â Â Â Â Â start_iter, finish_iter = self.message_buffer.get_bounds() |
|---|
| 393 | Â Â Â Â Â Â Â Â status_message_to_save_as_preset = self.message_buffer.get_text( |
|---|
| 394 | Â Â Â Â Â Â Â Â Â Â Â Â start_iter, finish_iter) |
|---|
| 395 | Â Â Â Â Â Â Â Â dlg = InputDialog(_('Save as Preset Status Message'), |
|---|
| 396 | Â Â Â Â Â Â Â Â Â Â Â Â _('Please type a name for this status message'), is_modal = True) |
|---|
| 397 | Â Â Â Â Â Â Â Â response = dlg.get_response() |
|---|
| 398 |         if response == gtk.RESPONSE_OK: |
|---|
| 399 | Â Â Â Â Â Â Â Â Â Â Â Â msg_name = dlg.input_entry.get_text() |
|---|
| 400 | Â Â Â Â Â Â Â Â Â Â Â Â msg_text = status_message_to_save_as_preset.decode('utf-8') |
|---|
| 401 | Â Â Â Â Â Â Â Â Â Â Â Â msg_text_1l = helpers.to_one_line(msg_text) |
|---|
| 402 |             if not msg_name: |
|---|
| 403 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â msg_name = msg_text_1l |
|---|
| 404 | Â Â Â Â Â Â Â Â Â Â Â Â msg_name = msg_name.decode('utf-8') |
|---|
| 405 | Â Â Â Â Â Â Â Â Â Â Â Â iter_ = self.message_liststore.append((msg_name,)) |
|---|
| 406 | |
|---|
| 407 | Â Â Â Â Â Â Â Â Â Â Â Â gajim.config.add_per('statusmsg', msg_name) |
|---|
| 408 | Â Â Â Â Â Â Â Â Â Â Â Â gajim.config.set_per('statusmsg', msg_name, 'message', msg_text_1l) |
|---|
| 409 | Â Â Â Â Â Â Â Â Â Â Â Â self.preset_messages_dict[msg_name] = msg_text |
|---|
| 410 | Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 411 | Â Â Â Â Â Â Â Â Â Â Â Â self.message_combobox.set_active_iter(iter_) |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | class AddNewContactWindow: |
|---|
| 415 | Â Â Â Â '''Class for AddNewContactWindow''' |
|---|
| 416 | Â Â Â Â uid_labels = {'jabber': _('Jabber ID:'), |
|---|
| 417 | Â Â Â Â Â Â Â Â 'aim': _('AIM Address:'), |
|---|
| 418 | Â Â Â Â Â Â Â Â 'gadu-gadu': _('GG Number:'), |
|---|
| 419 | Â Â Â Â Â Â Â Â 'icq': _('ICQ Number:'), |
|---|
| 420 | Â Â Â Â Â Â Â Â 'msn': _('MSN Address:'), |
|---|
| 421 | Â Â Â Â Â Â Â Â 'yahoo': _('Yahoo! Address:')} |
|---|
| 422 |     def __init__(self, account = None, jid = None, user_nick = None, |
|---|
| 423 | Â Â Â Â group = None): |
|---|
| 424 | Â Â Â Â Â Â Â Â self.account = account |
|---|
| 425 |         if account == None: |
|---|
| 426 | Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 427 | Â Â Â Â Â Â Â Â Â Â Â Â accounts = [] |
|---|
| 428 |             for account in gajim.connections.keys(): |
|---|
| 429 |                 if gajim.connections[account].connected > 1: |
|---|
| 430 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accounts.append(account) |
|---|
| 431 |             if not accounts: |
|---|
| 432 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 433 |             if len(accounts) == 1: |
|---|
| 434 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.account = account |
|---|
| 435 | Â Â Â Â Â Â Â Â else: |
|---|
| 436 | Â Â Â Â Â Â Â Â Â Â Â Â accounts = [self.account] |
|---|
| 437 |         if self.account: |
|---|
| 438 | Â Â Â Â Â Â Â Â Â Â Â Â location = gajim.interface.instances[self.account] |
|---|
| 439 | Â Â Â Â Â Â Â Â else: |
|---|
| 440 | Â Â Â Â Â Â Â Â Â Â Â Â location = gajim.interface.instances |
|---|
| 441 |         if location.has_key('add_contact'): |
|---|
| 442 | Â Â Â Â Â Â Â Â Â Â Â Â location['add_contact'].window.present() |
|---|
| 443 | Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 444 | Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 445 | Â Â Â Â Â Â Â Â location['add_contact'] = self |
|---|
| 446 | Â Â Â Â Â Â Â Â self.xml = gtkgui_helpers.get_glade('add_new_contact_window.glade') |
|---|
| 447 | Â Â Â Â Â Â Â Â self.window = self.xml.get_widget('add_new_contact_window') |
|---|
| 448 |         for w in ('account_combobox', 'account_hbox', 'account_label', |
|---|
| 449 | Â Â Â Â Â Â Â Â 'uid_label', 'uid_entry', 'protocol_combobox', 'protocol_jid_combobox', |
|---|
| 450 | Â Â Â Â Â Â Â Â 'protocol_hbox', 'nickname_entry', 'message_scrolledwindow', |
|---|
| 451 | Â Â Â Â Â Â Â Â 'register_hbox', 'subscription_table', 'add_button', |
|---|
| 452 | Â Â Â Â Â Â Â Â 'message_textview', 'connected_label', 'group_comboboxentry', |
|---|
| 453 | Â Â Â Â Â Â Â Â 'auto_authorize_checkbutton'): |
|---|
| 454 | Â Â Â Â Â Â Â Â Â Â Â Â self.__dict__[w] = self.xml.get_widget(w) |
|---|
| 455 |         if account and len(gajim.connections) >= 2: |
|---|
| 456 | Â Â Â Â Â Â Â Â Â Â Â Â prompt_text =\ |
|---|
| 457 | _('Please fill in the data of the contact you want to add in account %s') %account |
|---|
| 458 | Â Â Â Â Â Â Â Â else: |
|---|
| 459 | Â Â Â Â Â Â Â Â Â Â Â Â prompt_text = _('Please fill in the data of the contact you want to add') |
|---|
| 460 | Â Â Â Â Â Â Â Â self.xml.get_widget('prompt_label').set_text(prompt_text) |
|---|
| 461 | Â Â Â Â Â Â Â Â self.agents = {'jabber': []} |
|---|
| 462 | Â Â Â Â Â Â Â Â |
|---|
| 463 | Â Â Â Â Â Â Â Â self.available_types = [] |
|---|
| 464 |         for acct in accounts: |
|---|
| 465 |             for j in gajim.contacts.get_jid_list(acct): |
|---|
| 466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contact = gajim.contacts.get_first_contact_from_jid(acct, j) |
|---|
| 467 |                 if gajim.jid_is_transport(j): |
|---|
| 468 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type_ = gajim.get_transport_name_from_jid(j) |
|---|
| 469 |                     if self.agents.has_key(type_): |
|---|
| 470 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.agents[type_].append(j) |
|---|
| 471 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 472 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.agents[type_] = [j] |
|---|
| 473 | Â Â Â Â Â Â Â Â |
|---|
| 474 |         for acct in accounts: |
|---|
| 475 |             for type_ in gajim.connections[account].available_transports: |
|---|
| 476 |                 if type_ in self.agents: |
|---|
| 477 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.agents[type_] = [] |
|---|
| 479 |                 for jid_ in gajim.connections[account].available_transports[type_]: |
|---|
| 480 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.agents[type_].append(jid_) |
|---|
| 481 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.available_types.append(type_) |
|---|
| 482 | Â Â Â Â Â Â Â Â liststore = gtk.ListStore(str) |
|---|
| 483 | Â Â Â Â Â Â Â Â self.group_comboboxentry.set_model(liststore) |
|---|
| 484 | Â Â Â Â Â Â Â Â liststore = gtk.ListStore(str, str) |
|---|
| 485 | Â Â Â Â Â Â Â Â uf_type = {'jabber': 'Jabber', 'aim': 'AIM', 'gadu-gadu': 'Gadu Gadu', |
|---|
| 486 | Â Â Â Â Â Â Â Â Â Â Â Â 'icq': 'ICQ', 'msn': 'MSN', 'yahoo': 'Yahoo'} |
|---|
| 487 | Â Â Â Â Â Â Â Â |
|---|
| 488 | Â Â Â Â Â Â Â Â liststore.append(['Jabber', 'jabber']) |
|---|
| 489 |         for type_ in self.agents: |
|---|
| 490 |             if type_ == 'jabber': |
|---|
| 491 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue |
|---|
| 492 |             if type_ in uf_type: |
|---|
| 493 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â liststore.append([uf_type[type_], type_]) |
|---|
| 494 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 495 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â liststore.append([type_, type_]) |
|---|
| 496 | Â Â Â Â Â Â Â Â self.protocol_combobox.set_model(liststore) |
|---|
| 497 | Â Â Â Â Â Â Â Â self.protocol_combobox.set_active(0) |
|---|
| 498 | Â Â Â Â Â Â Â Â self.protocol_jid_combobox.set_no_show_all(True) |
|---|
| 499 | Â Â Â Â Â Â Â Â self.protocol_jid_combobox.hide() |
|---|
| 500 | Â Â Â Â Â Â Â Â self.subscription_table.set_no_show_all(True) |
|---|
| 501 | Â Â Â Â Â Â Â Â self.auto_authorize_checkbutton.show() |
|---|
| 502 | Â Â Â Â Â Â Â Â self.message_scrolledwindow.set_no_show_all(True) |
|---|
| 503 | Â Â Â Â Â Â Â Â self.register_hbox.set_no_show_all(True) |
|---|
| 504 | Â Â Â Â Â Â Â Â self.register_hbox.hide() |
|---|
| 505 | Â Â Â Â Â Â Â Â self.connected_label.set_no_show_all(True) |
|---|
| 506 | Â Â Â Â Â Â Â Â self.connected_label.hide() |
|---|
| 507 | Â Â Â Â Â Â Â Â liststore = gtk.ListStore(str) |
|---|
| 508 | Â Â Â Â Â Â Â Â self.protocol_jid_combobox.set_model(liststore) |
|---|
| 509 | Â Â Â Â Â Â Â Â self.xml.signal_autoconnect(self) |
|---|
| 510 |         if jid: |
|---|
| 511 | Â Â Â Â Â Â Â Â Â Â Â Â type_ = gajim.get_transport_name_from_jid(jid) |
|---|
| 512 |             if not type_: |
|---|
| 513 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type_ = 'jabber' |
|---|
| 514 |             if type_ == 'jabber': |
|---|
| 515 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.uid_entry.set_text(jid) |
|---|
| 516 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 517 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â uid, transport = gajim.get_name_and_server_from_jid(jid) |
|---|
| 518 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.uid_entry.set_text(uid.replace('%', '@', 1)) |
|---|
| 519 | Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 520 | Â Â Â Â Â Â Â Â Â Â Â Â model = self.protocol_combobox.get_model() |
|---|
| 521 | Â Â Â Â Â Â Â Â Â Â Â Â iter = model.get_iter_first() |
|---|
| 522 | Â Â Â Â Â Â Â Â Â Â Â Â i = 0 |
|---|
| 523 |             while iter: |
|---|
| 524 |                 if model[iter][1] == type_: |
|---|
| 525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_combobox.set_active(i) |
|---|
| 526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break |
|---|
| 527 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iter = model.iter_next(iter) |
|---|
| 528 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â i += 1 |
|---|
| 529 | |
|---|
| 530 | Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 531 | Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_jid_combobox.set_active(0) |
|---|
| 532 | Â Â Â Â Â Â Â Â Â Â Â Â model = self.protocol_jid_combobox.get_model() |
|---|
| 533 | Â Â Â Â Â Â Â Â Â Â Â Â iter = model.get_iter_first() |
|---|
| 534 | Â Â Â Â Â Â Â Â Â Â Â Â i = 0 |
|---|
| 535 |             while iter: |
|---|
| 536 |                 if model[iter][0] == transport: |
|---|
| 537 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_jid_combobox.set_active(i) |
|---|
| 538 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break |
|---|
| 539 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iter = model.iter_next(iter) |
|---|
| 540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â i += 1 |
|---|
| 541 |             if user_nick: |
|---|
| 542 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.nickname_entry.set_text(user_nick) |
|---|
| 543 | Â Â Â Â Â Â Â Â Â Â Â Â self.nickname_entry.grab_focus() |
|---|
| 544 | Â Â Â Â Â Â Â Â else: |
|---|
| 545 | Â Â Â Â Â Â Â Â Â Â Â Â self.uid_entry.grab_focus() |
|---|
| 546 | Â Â Â Â Â Â Â Â group_names = [] |
|---|
| 547 |         for acct in accounts: |
|---|
| 548 |             for g in gajim.groups[acct].keys(): |
|---|
| 549 |                 if g not in helpers.special_groups and g not in group_names: |
|---|
| 550 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â group_names.append(g) |
|---|
| 551 | Â Â Â Â Â Â Â Â group_names.sort() |
|---|
| 552 | Â Â Â Â Â Â Â Â i = 0 |
|---|
| 553 |         for g in group_names: |
|---|
| 554 | Â Â Â Â Â Â Â Â Â Â Â Â self.group_comboboxentry.append_text(g) |
|---|
| 555 |             if group == g: |
|---|
| 556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.group_comboboxentry.set_active(i) |
|---|
| 557 | Â Â Â Â Â Â Â Â Â Â Â Â i += 1 |
|---|
| 558 | |
|---|
| 559 |         if self.account: |
|---|
| 560 | Â Â Â Â Â Â Â Â Â Â Â Â self.account_label.hide() |
|---|
| 561 | Â Â Â Â Â Â Â Â Â Â Â Â self.account_hbox.hide() |
|---|
| 562 | Â Â Â Â Â Â Â Â Â Â Â Â self.account_label.set_no_show_all(True) |
|---|
| 563 | Â Â Â Â Â Â Â Â Â Â Â Â self.account_hbox.set_no_show_all(True) |
|---|
| 564 | Â Â Â Â Â Â Â Â else: |
|---|
| 565 | Â Â Â Â Â Â Â Â Â Â Â Â liststore = gtk.ListStore(str, str) |
|---|
| 566 |             for acct in accounts: |
|---|
| 567 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â liststore.append([acct, acct]) |
|---|
| 568 | Â Â Â Â Â Â Â Â Â Â Â Â self.account_combobox.set_model(liststore) |
|---|
| 569 | Â Â Â Â Â Â Â Â Â Â Â Â self.account_combobox.set_active(0) |
|---|
| 570 | Â Â Â Â Â Â Â Â self.window.show_all() |
|---|
| 571 | |
|---|
| 572 |     def on_add_new_contact_window_destroy(self, widget): |
|---|
| 573 |         if self.account: |
|---|
| 574 | Â Â Â Â Â Â Â Â Â Â Â Â location = gajim.interface.instances[self.account] |
|---|
| 575 | Â Â Â Â Â Â Â Â else: |
|---|
| 576 | Â Â Â Â Â Â Â Â Â Â Â Â location = gajim.interface.instances |
|---|
| 577 |         del location['add_contact'] |
|---|
| 578 | |
|---|
| 579 |     def on_register_button_clicked(self, widget): |
|---|
| 580 | Â Â Â Â Â Â Â Â jid = self.protocol_jid_combobox.get_active_text().decode('utf-8') |
|---|
| 581 | Â Â Â Â Â Â Â Â gajim.connections[self.account].request_register_agent_info(jid) |
|---|
| 582 | |
|---|
| 583 |     def on_add_new_contact_window_key_press_event(self, widget, event): |
|---|
| 584 |         if event.keyval == gtk.keysyms.Escape: |
|---|
| 585 | Â Â Â Â Â Â Â Â Â Â Â Â self.window.destroy() |
|---|
| 586 | |
|---|
| 587 |     def on_cancel_button_clicked(self, widget): |
|---|
| 588 | Â Â Â Â Â Â Â Â '''When Cancel button is clicked''' |
|---|
| 589 | Â Â Â Â Â Â Â Â self.window.destroy() |
|---|
| 590 | |
|---|
| 591 |     def on_add_button_clicked(self, widget): |
|---|
| 592 | Â Â Â Â Â Â Â Â '''When Subscribe button is clicked''' |
|---|
| 593 | Â Â Â Â Â Â Â Â jid = self.uid_entry.get_text().decode('utf-8') |
|---|
| 594 |         if not jid: |
|---|
| 595 | Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 596 | |
|---|
| 597 | Â Â Â Â Â Â Â Â model = self.protocol_combobox.get_model() |
|---|
| 598 | Â Â Â Â Â Â Â Â iter = self.protocol_combobox.get_active_iter() |
|---|
| 599 | Â Â Â Â Â Â Â Â type_ = model[iter][1] |
|---|
| 600 |         if type_ != 'jabber': |
|---|
| 601 | Â Â Â Â Â Â Â Â Â Â Â Â transport = self.protocol_jid_combobox.get_active_text().decode( |
|---|
| 602 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'utf-8') |
|---|
| 603 | Â Â Â Â Â Â Â Â Â Â Â Â jid = jid.replace('@', '%') + '@'Â + transport |
|---|
| 604 | |
|---|
| 605 | Â Â Â Â Â Â Â Â |
|---|
| 606 | Â Â Â Â Â Â Â Â try: |
|---|
| 607 | Â Â Â Â Â Â Â Â Â Â Â Â jid = helpers.parse_jid(jid) |
|---|
| 608 |         except helpers.InvalidFormat, s: |
|---|
| 609 | Â Â Â Â Â Â Â Â Â Â Â Â pritext = _('Invalid User ID') |
|---|
| 610 | Â Â Â Â Â Â Â Â Â Â Â Â ErrorDialog(pritext, str(s)) |
|---|
| 611 | Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 612 | |
|---|
| 613 | Â Â Â Â Â Â Â Â |
|---|
| 614 |         if jid.find('/') >= 0: |
|---|
| 615 | Â Â Â Â Â Â Â Â Â Â Â Â pritext = _('Invalid User ID') |
|---|
| 616 | Â Â Â Â Â Â Â Â Â Â Â Â ErrorDialog(pritext, _('The user ID must not contain a resource.')) |
|---|
| 617 | Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 618 | |
|---|
| 619 |         nickname = self.nickname_entry.get_text().decode('utf-8') or '' |
|---|
| 620 | Â Â Â Â Â Â Â Â |
|---|
| 621 |         if not self.account: |
|---|
| 622 | Â Â Â Â Â Â Â Â Â Â Â Â model = self.account_combobox.get_model() |
|---|
| 623 | Â Â Â Â Â Â Â Â Â Â Â Â index = self.account_combobox.get_active() |
|---|
| 624 | Â Â Â Â Â Â Â Â Â Â Â Â self.account = model[index][1] |
|---|
| 625 | |
|---|
| 626 | Â Â Â Â Â Â Â Â |
|---|
| 627 |         if jid in gajim.contacts.get_jid_list(self.account): |
|---|
| 628 | Â Â Â Â Â Â Â Â Â Â Â Â c = gajim.contacts.get_first_contact_from_jid(self.account, jid) |
|---|
| 629 |             if _('Not in Roster') not in c.groups and c.sub in ('both', 'to'): |
|---|
| 630 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ErrorDialog(_('Contact already in roster'), |
|---|
| 631 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â _('This contact is already listed in your roster.')) |
|---|
| 632 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 633 | |
|---|
| 634 |         if type_ == 'jabber': |
|---|
| 635 | Â Â Â Â Â Â Â Â Â Â Â Â message_buffer = self.message_textview.get_buffer() |
|---|
| 636 | Â Â Â Â Â Â Â Â Â Â Â Â start_iter = message_buffer.get_start_iter() |
|---|
| 637 | Â Â Â Â Â Â Â Â Â Â Â Â end_iter = message_buffer.get_end_iter() |
|---|
| 638 | Â Â Â Â Â Â Â Â Â Â Â Â message = message_buffer.get_text(start_iter, end_iter).decode('utf-8') |
|---|
| 639 | Â Â Â Â Â Â Â Â else: |
|---|
| 640 | Â Â Â Â Â Â Â Â Â Â Â Â message= '' |
|---|
| 641 | Â Â Â Â Â Â Â Â group = self.group_comboboxentry.child.get_text().decode('utf-8') |
|---|
| 642 | Â Â Â Â Â Â Â Â groups = [] |
|---|
| 643 |         if group: |
|---|
| 644 | Â Â Â Â Â Â Â Â Â Â Â Â groups = [group] |
|---|
| 645 | Â Â Â Â Â Â Â Â auto_auth = self.auto_authorize_checkbutton.get_active() |
|---|
| 646 | Â Â Â Â Â Â Â Â gajim.interface.roster.req_sub(self, jid, message, self.account, |
|---|
| 647 | Â Â Â Â Â Â Â Â Â Â Â Â groups = groups, nickname = nickname, auto_auth = auto_auth) |
|---|
| 648 | Â Â Â Â Â Â Â Â self.window.destroy() |
|---|
| 649 | |
|---|
| 650 |     def on_protocol_combobox_changed(self, widget): |
|---|
| 651 | Â Â Â Â Â Â Â Â model = widget.get_model() |
|---|
| 652 | Â Â Â Â Â Â Â Â iter = widget.get_active_iter() |
|---|
| 653 | Â Â Â Â Â Â Â Â type_ = model[iter][1] |
|---|
| 654 | Â Â Â Â Â Â Â Â model = self.protocol_jid_combobox.get_model() |
|---|
| 655 | Â Â Â Â Â Â Â Â model.clear() |
|---|
| 656 |         if len(self.agents[type_]): |
|---|
| 657 |             for jid_ in self.agents[type_]: |
|---|
| 658 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model.append([jid_]) |
|---|
| 659 | Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_jid_combobox.set_active(0) |
|---|
| 660 |         if len(self.agents[type_]) > 1: |
|---|
| 661 | Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_jid_combobox.set_no_show_all(False) |
|---|
| 662 | Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_jid_combobox.show_all() |
|---|
| 663 | Â Â Â Â Â Â Â Â else: |
|---|
| 664 | Â Â Â Â Â Â Â Â Â Â Â Â self.protocol_jid_combobox.hide() |
|---|
| 665 |         if type_ in self.uid_labels: |
|---|
| 666 | Â Â Â Â Â Â Â Â Â Â Â Â self.uid_label.set_text(self.uid_labels[type_]) |
|---|
| 667 | Â Â Â Â Â Â Â Â else: |
|---|
| 668 | Â Â Â Â Â Â Â Â Â Â Â Â self.uid_label.set_text(_('User ID:')) |
|---|
| 669 |         if type_ == 'jabber': |
|---|
| 670 | Â Â Â Â Â Â Â Â Â Â Â Â self.message_scrolledwindow.show() |
|---|
| 671 | Â Â Â Â Â Â Â Â else: |
|---|
| 672 | Â Â Â Â Â Â Â Â Â Â Â Â self.message_scrolledwindow.hide() |
|---|
| 673 |         if type_ in self.available_types: |
|---|
| 674 | Â Â Â Â Â Â Â Â Â Â Â Â self.register_hbox.set_no_show_all(False) |
|---|
| 675 | Â Â Â Â Â Â Â Â Â Â Â Â self.register_hbox.show_all() |
|---|
| 676 | Â Â Â Â Â Â Â Â Â Â Â Â self.auto_authorize_checkbutton.hide() |
|---|
| 677 | Â Â Â Â Â Â Â Â Â Â Â Â self.connected_label.hide() |
|---|
| 678 | Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.hide() |
|---|
| 679 | Â Â Â Â Â Â Â Â Â Â Â Â self.add_button.set_sensitive(False) |
|---|
| 680 | Â Â Â Â Â Â Â Â else: |
|---|
| 681 | Â Â Â Â Â Â Â Â Â Â Â Â self.register_hbox.hide() |
|---|
| 682 |             if type_ != 'jabber': |
|---|
| 683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â jid = self.protocol_jid_combobox.get_active_text() |
|---|
| 684 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â contact = gajim.contacts.get_first_contact_from_jid(self.account, |
|---|
| 685 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â jid) |
|---|
| 686 |                 if contact.show in ('offline', 'error'): |
|---|
| 687 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.hide() |
|---|
| 688 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.connected_label.show() |
|---|
| 689 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.add_button.set_sensitive(False) |
|---|
| 690 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.auto_authorize_checkbutton.hide() |
|---|
| 691 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 692 | Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.set_no_show_all(False) |
|---|
| 693 | Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.show_all() |
|---|
| 694 | Â Â Â Â Â Â Â Â Â Â Â Â self.auto_authorize_checkbutton.show() |
|---|
| 695 | Â Â Â Â Â Â Â Â Â Â Â Â self.connected_label.hide() |
|---|
| 696 | Â Â Â Â Â Â Â Â Â Â Â Â self.add_button.set_sensitive(True) |
|---|
| 697 | |
|---|
| 698 |     def transport_signed_in(self, jid): |
|---|
| 699 |         if self.protocol_jid_combobox.get_active_text() == jid: |
|---|
| 700 | Â Â Â Â Â Â Â Â Â Â Â Â self.register_hbox.hide() |
|---|
| 701 | Â Â Â Â Â Â Â Â Â Â Â Â self.connected_label.hide() |
|---|
| 702 | Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.set_no_show_all(False) |
|---|
| 703 | Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.show_all() |
|---|
| 704 | Â Â Â Â Â Â Â Â Â Â Â Â self.add_button.set_sensitive(True) |
|---|
| 705 | |
|---|
| 706 |     def transport_signed_out(self, jid): |
|---|
| 707 |         if self.protocol_jid_combobox.get_active_text() == jid: |
|---|
| 708 | Â Â Â Â Â Â Â Â Â Â Â Â self.subscription_table.hide() |
|---|
| 709 | Â Â Â Â Â Â Â Â Â Â Â Â self.connected_label.show() |
|---|
| 710 | Â Â Â Â Â Â Â Â Â Â Â Â self.add_button.set_sensitive(False) |
|---|
| 711 | |
|---|
| 712 | class AboutDialog: |
|---|
| 713 | Â Â Â Â '''Class for about dialog''' |
|---|
| 714 |     def __init__(self): |
|---|
| 715 | Â Â Â Â Â Â Â Â dlg = gtk.AboutDialog() |
|---|
| 716 | Â Â Â Â Â Â Â Â dlg.set_transient_for(gajim.interface.roster.window) |
|---|
| 717 | Â Â Â Â Â Â Â Â dlg.set_name('Gajim') |
|---|
| 718 | Â Â Â Â Â Â Â Â dlg.set_version(gajim.version) |
|---|
| 719 |         s = u'Copyright © 2003-2006 Gajim Team' |
|---|
| 720 | Â Â Â Â Â Â Â Â dlg.set_copyright(s) |
|---|
| 721 | Â Â Â Â Â Â Â Â copying_file_path = None |
|---|
| 722 |         if os.path.isfile(os.path.join(gajim.defs.docdir, 'COPYING')): |
|---|
| 723 | Â Â Â Â Â Â Â Â Â Â Â Â copying_file_path = os.path.join(gajim.defs.docdir, 'COPYING') |
|---|
| 724 |         elif os.path.isfile('../COPYING'): |
|---|
| 725 | Â Â Â Â Â Â Â Â Â Â Â Â copying_file_path = '../COPYING' |
|---|
| 726 |         if copying_file_path: |
|---|
| 727 | Â Â Â Â Â Â Â Â Â Â Â Â text = open(copying_file_path).read() |
|---|
| 728 | Â Â Â Â Â Â Â Â Â Â Â Â dlg.set_license(text) |
|---|
| 729 | |
|---|
| 730 | Â Â Â Â Â Â Â Â dlg.set_comments('%s\n%s %s\n%s %s'Â |
|---|
| 731 | Â Â Â Â Â Â Â Â Â Â Â Â % (_('A GTK+ jabber client'), \ |
|---|
| 732 | Â Â Â Â Â Â Â Â Â Â Â Â _('GTK+ Version:'), self.tuple2str(gtk.gtk_version), \ |
|---|
| 733 | Â Â Â Â Â Â Â Â Â Â Â Â _('PyGTK Version:'), self.tuple2str(gtk.pygtk_version))) |
|---|
| 734 | Â Â Â Â Â Â Â Â dlg.set_website('http://www.gajim.org/') |
|---|
| 735 | |
|---|
| 736 | Â Â Â Â Â Â Â Â authors_file_path = None |
|---|
| 737 |         if os.path.isfile(os.path.join(gajim.defs.docdir, 'AUTHORS')): |
|---|
| 738 | Â Â Â Â Â Â Â Â Â Â Â Â authors_file_path = os.path.join(gajim.defs.docdir, 'AUTHORS') |
|---|
| 739 |         elif os.path.isfile('../AUTHORS'): |
|---|
| 740 | Â Â Â Â Â Â Â Â Â Â Â Â authors_file_path = '../AUTHORS' |
|---|
| 741 |         if authors_file_path: |
|---|
| 742 | Â Â Â Â Â Â Â Â Â Â Â Â authors = [] |
|---|
| 743 | Â Â Â Â Â Â Â Â Â Â Â Â authors_file = open(authors_file_path).read() |
|---|
| 744 | Â Â Â Â Â Â Â Â Â Â Â Â authors_file = authors_file.split('\n') |
|---|
| 745 |             for author in authors_file: |
|---|
| 746 |                 if author == 'CURRENT DEVELOPERS:': |
|---|
| 747 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â authors.append(_('Current Developers:')) |
|---|
| 748 |                 elif author == 'PAST DEVELOPERS:': |
|---|
| 749 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â authors.append('\n'Â + _('Past Developers:')) |
|---|
| 750 |                 elif author != '': |
|---|
| 751 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â authors.append(author) |
|---|
| 752 | |
|---|
| 753 | Â Â Â Â Â Â Â Â Â Â Â Â thanks_file_path = None |
|---|
| 754 |             if os.path.isfile(os.path.join(gajim.defs.docdir, 'THANKS')): |
|---|
| 755 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â thanks_file_path = os.path.join(gajim.defs.docdir, 'THANKS') |
|---|
| 756 |             elif os.path.isfile('../THANKS'): |
|---|
| 757 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â thanks_file_path = '../THANKS' |
|---|
| 758 |             if thanks_file_path: |
|---|
| 759 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â authors.append('\n'Â + _('THANKS:')) |
|---|
| 760 | |
|---|
| 761 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â text = open(thanks_file_path).read() |
|---|
| 762 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â text_splitted = text.split('\n') |
|---|
| 763 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â text = '\n'.join(text_splitted[:-2]) |
|---|
| 764 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 765 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â text += '\n%s\n'Â % _('Last but not least, we would like to thank all ' |
|---|
| 766 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'the package maintainers.') |
|---|
| 767 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â authors.append(text) |
|---|
| 768 | |
|---|
| 769 | Â Â Â Â Â Â Â Â Â Â Â Â dlg.set_authors(authors) |
|---|
| 770 | |
|---|
| 771 |         if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0): |
|---|
| 772 | Â Â Â Â Â Â Â Â Â Â Â Â dlg.props.wrap_license = True |
|---|
| 773 | |
|---|
| 774 | Â Â Â Â Â Â Â Â pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join( |
|---|
| 775 | Â Â Â Â Â Â Â Â Â Â Â Â gajim.DATA_DIR, 'pixmaps', 'gajim_about.png'))Â Â Â Â Â Â Â Â Â |
|---|
| 776 | |
|---|
| 777 | Â Â Â Â Â Â Â Â dlg.set_logo(pixbuf) |
|---|
| 778 | Â Â Â Â Â Â Â Â |
|---|
| 779 | Â Â Â Â Â Â Â Â dlg.set_translator_credits(_('translator-credits')) |
|---|
| 780 | |
|---|
| 781 |         artists = ['Anders Ström', 'Christophe Got', 'Dennis Craven', |
|---|
| 782 | Â Â Â Â Â Â Â Â Â Â Â Â 'Guillaume Morin', 'Josef VybÃral', 'Membris Khan'] |
|---|
| 783 | Â Â Â Â Â Â Â Â dlg.set_artists(artists) |
|---|
| 784 | |
|---|
| 785 | Â Â Â Â Â Â Â Â rep = dlg.run() |
|---|
| 786 | Â Â Â Â Â Â Â Â dlg.destroy() |
|---|
| 787 | |
|---|
| 788 |     def tuple2str(self, tuple_): |
|---|
| 789 | Â Â Â Â Â Â Â Â str_ = '' |
|---|
| 790 |         for num in tuple_: |
|---|
| 791 | Â Â Â Â Â Â Â Â Â Â Â Â str_ += str(num) + '.' |
|---|
| 792 |         return str_[0:-1] |
|---|
| 793 | |
|---|
| 794 | class Dialog(gtk.Dialog): |
|---|
| 795 |     def __init__(self, parent, title, buttons, default = None): |
|---|
| 796 | Â Â Â Â Â Â Â Â gtk.Dialog.__init__(self, title, parent, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL | gtk.DIALOG_NO_SEPARATOR) |
|---|
| 797 | |
|---|
| 798 | Â Â Â Â Â Â Â Â self.set_border_width(6) |
|---|
| 799 | Â Â Â Â Â |
|---|