Show
Ignore:
Timestamp:
01/06/07 12:00:50 (23 months ago)
Author:
asterix
Message:

merge changeset from trunk except pyopenssl stuff

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11/src/roster_window.py

    r7682 r7787  
    151151                        iters = self.get_contact_iter(jid, account) 
    152152                        path = self.tree.get_model().get_path(iters[0]) 
     153                if self.dragging: 
     154                        # do not change selection while DND'ing 
     155                        return 
    153156                # popup == False so we show awaiting event in roster 
    154                 # show and select contact line in roster (even if he is not in roster)  
     157                # show and select contact line in roster (even if he is not in roster) 
    155158                self.tree.expand_row(path[0:1], False) 
    156159                self.tree.expand_row(path[0:2], False) 
     
    226229                        # account row not expanded 
    227230                        account_name = '[%s]' % account_name 
    228                 if gajim.account_is_connected(account) or (self.regroup and \ 
    229                 gajim.get_number_of_connected_accounts()): 
     231                if (gajim.account_is_connected(account) or (self.regroup and \ 
     232                gajim.get_number_of_connected_accounts())) and gajim.config.get( 
     233                'show_contacts_number'): 
    230234                        nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 
    231235                                accounts = accounts)             
     
    387391                else: 
    388392                        accounts = [account] 
    389                 nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 
    390                         accounts = accounts, groups = [group]) 
     393                text = group 
     394                if gajim.config.get('show_contacts_number'): 
     395                        nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 
     396                                accounts = accounts, groups = [group]) 
     397                        text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) 
    391398                model = self.tree.get_model() 
    392                 model.set_value(iter, 1 , gtkgui_helpers.escape_for_pango_markup( 
    393                         '%s (%s/%s)' % (group, repr(nbr_on), repr(nbr_total))))          
     399                model.set_value(iter, 1 , gtkgui_helpers.escape_for_pango_markup(text)) 
    394400 
    395401        def add_to_not_in_the_roster(self, account, jid, nick = ''): 
     
    11521158                                pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(ji) 
    11531159                                if pixbuf == 'ask': 
    1154                                         jid_with_resource = contact1.jid 
    1155                                         if contact1.resource: 
    1156                                                 jid_with_resource += '/' + contact1.resource 
    1157                                         gajim.connections[account].request_vcard(jid_with_resource) 
     1160                                        transport = gajim.get_transport_name_from_jid(contact1.jid) 
     1161                                        if not transport or gajim.jid_is_transport(contact1.jid): 
     1162                                                jid_with_resource = contact1.jid 
     1163                                                if contact1.resource: 
     1164                                                        jid_with_resource += '/' + contact1.resource 
     1165                                                gajim.connections[account].request_vcard(jid_with_resource) 
     1166                                        else: 
     1167                                                host = gajim.get_server_from_jid(contact1.jid) 
     1168                                                if not gajim.transport_avatar[account].has_key(host): 
     1169                                                        gajim.transport_avatar[account][host] = [contact1.jid] 
     1170                                                else: 
     1171                                                        gajim.transport_avatar[account][host].append(contact1.jid) 
    11581172                        # If we already have a chat window opened, update it with new contact 
    11591173                        # instance 
     
    11821196                                win = gajim.interface.msg_win_mgr.get_window(jid, account) 
    11831197                                ctrl = win.get_control(jid, account) 
    1184                                 ctrl.contact = contact 
     1198                                ctrl.contact = gajim.contacts.get_contact_with_highest_priority( 
     1199                                        account, contact.jid) 
    11851200                                ctrl.update_ui() 
    11861201                                win.redraw_tab(ctrl) 
     
    13841399                        pritext = _('Transport "%s" will be removed') % contact.jid 
    13851400                        sectext = _('You will no longer be able to send and receive messages ' 
    1386                                 'to contacts from this transport.') 
     1401                                'from contacts using this transport.') 
    13871402                else: 
    13881403                        pritext = _('Transports will be removed') 
     
    14731488                        on_canceled) 
    14741489 
     1490        def readd_if_needed(self, contact, account): 
     1491                need_readd = False 
     1492                if len(gajim.events.get_events(account, contact.jid)): 
     1493                        need_readd = True 
     1494                elif gajim.interface.msg_win_mgr.has_window(contact.jid, account): 
     1495                        if _('Not in Roster') in contact.groups: 
     1496                                # Close chat window 
     1497                                msg_win = gajim.interface.msg_win_mgr.get_window(contact.jid, 
     1498                                        account) 
     1499                                ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) 
     1500                                msg_win.remove_tab(ctrl, msg_win.CLOSE_CLOSE_BUTTON) 
     1501                        else: 
     1502                                need_readd = True 
     1503                if need_readd: 
     1504                        c = gajim.contacts.create_contact(jid = contact.jid, 
     1505                                name = '', groups = [_('Not in Roster')], 
     1506                                show = 'not in roster', status = '', ask = 'none', 
     1507                                keyID = contact.keyID) 
     1508                        gajim.contacts.add_contact(account, c) 
     1509                        self.add_contact_to_roster(contact.jid, account) 
     1510 
    14751511        def on_remove_group_item_activated(self, widget, group, account): 
    14761512                dlg = dialogs.ConfirmationDialogCheck(_('Remove Group'), 
     
    14881524                                else: 
    14891525                                        gajim.connections[account].unsubscribe(contact.jid)  
    1490                  
     1526                                        for c in gajim.contacts.get_contact(account, contact.jid): 
     1527                                                self.remove_contact(c, account) 
     1528                                        gajim.contacts.remove_jid(account, c.jid) 
     1529                                        self.readd_if_needed(contact, account) 
     1530                        self.draw_account(account) 
     1531 
    14911532        def on_assign_pgp_key(self, widget, contact, account): 
    14921533                attached_keys = gajim.config.get_per('accounts', account, 
     
    24312472                        if not len(list_of_paths): 
    24322473                                return 
    2433                         type = model[list_of_paths[0]][C_TYPE] 
     2474                        type_ = model[list_of_paths[0]][C_TYPE] 
    24342475                        account = model[list_of_paths[0]][C_ACCOUNT] 
    24352476                        list_ = [] 
    24362477                        for path in list_of_paths: 
    2437                                 if model[path][C_TYPE] != type: 
     2478                                if model[path][C_TYPE] != type_: 
    24382479                                        return 
    24392480                                jid = model[path][C_JID].decode('utf-8') 
     
    24422483                                        jid) 
    24432484                                list_.append((contact, account)) 
    2444                         if type in ('account', 'group', 'self_contact') or \ 
     2485                        if type_ in ('account', 'group', 'self_contact') or \ 
    24452486                        account == gajim.ZEROCONF_ACC_NAME: 
    24462487                                return 
    2447                         if type == 'contact': 
     2488                        if type_ == 'contact': 
    24482489                                self.on_req_usub(widget, list_) 
    2449                         elif type == 'agent': 
     2490                        elif type_ == 'agent': 
    24502491                                self.on_remove_agent(widget, list_) 
    24512492 
     
    24532494                # iters must be all of the same type 
    24542495                model = self.tree.get_model() 
    2455                 type = model[iters[0]][C_TYPE] 
     2496                type_ = model[iters[0]][C_TYPE] 
    24562497                for iter in iters[1:]: 
    2457                         if model[iter][C_TYPE] != type: 
     2498                        if model[iter][C_TYPE] != type_: 
    24582499                                return 
    2459                 if type == 'group' and len(iters) == 1: 
     2500                if type_ == 'group' and len(iters) == 1: 
    24602501                        self.make_group_menu(event, iters[0]) 
    2461                 elif type == 'agent' and len(iters) == 1: 
     2502                elif type_ == 'agent' and len(iters) == 1: 
    24622503                        self.make_transport_menu(event, iters[0]) 
    2463                 elif type in ('contact', 'self_contact') and len(iters) == 1: 
     2504                elif type_ in ('contact', 'self_contact') and len(iters) == 1: 
    24642505                        self.make_contact_menu(event, iters[0]) 
    2465                 elif type  == 'contact': 
     2506                elif type_  == 'contact': 
    24662507                        self.make_multiple_contact_menu(event, iters) 
    2467                 elif type == 'account' and len(iters) == 1: 
     2508                elif type_ == 'account' and len(iters) == 1: 
    24682509                        self.make_account_menu(event, iters[0]) 
    24692510 
     
    25182559                                self.tree.get_selection().unselect_all() 
    25192560                                self.tree.get_selection().select_path(path) 
    2520                         type = model[path][C_TYPE] 
    2521                         if type in ('agent', 'contact', 'self_contact'): 
     2561                        type_ = model[path][C_TYPE] 
     2562                        if type_ in ('agent', 'contact', 'self_contact'): 
    25222563                                self.on_roster_treeview_row_activated(widget, path) 
    2523                         elif type == 'account': 
     2564                        elif type_ == 'account': 
    25242565                                account = model[path][C_ACCOUNT].decode('utf-8') 
    25252566                                if account != 'all': 
     
    25452586                elif event.button == 1: # Left click 
    25462587                        model = self.tree.get_model() 
    2547                         type = model[path][C_TYPE] 
    2548                         if type == 'group' and x < 27: 
     2588                        type_ = model[path][C_TYPE] 
     2589                        if type_ == 'group' and x < 27: 
    25492590                                # first cell in 1st column (the arrow SINGLE clicked) 
    25502591                                if (self.tree.row_expanded(path)): 
     
    25532594                                        self.tree.expand_row(path, False) 
    25542595 
    2555                         elif type == 'contact' and x < 27: 
     2596                        elif type_ == 'contact' and x < 27: 
    25562597                                account = model[path][C_ACCOUNT].decode('utf-8') 
    25572598                                jid = model[path][C_JID].decode('utf-8') 
     
    25842625                                # redraw account rows for contact numbers 
    25852626                                self.draw_account(account) 
    2586                                 need_readd = False 
    25872627                                if not remove_auth and contact.sub == 'both': 
    25882628                                        contact.name = '' 
     
    25912631                                        gajim.contacts.add_contact(account, contact) 
    25922632                                        self.add_contact_to_roster(contact.jid, account) 
    2593                                 elif len(gajim.events.get_events(account, contact.jid)): 
    2594                                         need_readd = True 
    2595                                 elif gajim.interface.msg_win_mgr.has_window(contact.jid, account): 
    2596                                         if _('Not in Roster') in contact.groups: 
    2597                                                 # Close chat window 
    2598                                                 msg_win = gajim.interface.msg_win_mgr.get_window(contact.jid, 
    2599                                                         account) 
    2600                                                 ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, 
    2601                                                         account) 
    2602                                                 msg_win.remove_tab(ctrl, msg_win.CLOSE_CLOSE_BUTTON) 
    2603                                         else: 
    2604                                                 need_readd = True 
    2605                                 if need_readd: 
    2606                                         c = gajim.contacts.create_contact(jid = contact.jid, 
    2607                                                 name = '', groups = [_('Not in Roster')], 
    2608                                                 show = 'not in roster', status = '', ask = 'none', 
    2609                                                 keyID = contact.keyID) 
    2610                                         gajim.contacts.add_contact(account, c) 
    2611                                         self.add_contact_to_roster(contact.jid, account) 
     2633                                else: 
     2634                                        self.readd_if_needed(contact, account) 
    26122635                if len(list_) == 1: 
    26132636                        contact = list_[0][0] 
     
    26622685                                if not gajim.connections[account].password: 
    26632686                                        passphrase = '' 
    2664                                         w = dialogs.PassphraseDialog( 
    2665                                                 _('Password Required'), 
    2666                                                 _('Enter your password for account %s') % account, 
     2687                                        text = _('Enter your password for account %s') % account 
     2688                                        if passwords.USER_HAS_GNOMEKEYRING and \ 
     2689                                        not passwords.USER_USES_GNOMEKEYRING: 
     2690                                                text += '\n' + _('Gnomekeyring is installed but not correctly started (environment variable probably not correctly set)') 
     2691                                        w = dialogs.PassphraseDialog(_('Password Required'), text, 
    26672692                                                _('Save password')) 
    26682693                                        passphrase, save = w.run() 
     
    29642989                # Get target window, create a control, and associate it with the window 
    29652990                if not private_chat: 
    2966                         type = message_control.TYPE_CHAT 
    2967                 else: 
    2968                         type = message_control.TYPE_PM 
     2991                        type_ = message_control.TYPE_CHAT 
     2992                else: 
     2993                        type_ = message_control.TYPE_PM 
    29692994 
    29702995                fjid = contact.jid 
     
    29732998                mw = gajim.interface.msg_win_mgr.get_window(fjid, account) 
    29742999                if not mw: 
    2975                         mw = gajim.interface.msg_win_mgr.create_window(contact, account, type) 
     3000                        mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_) 
    29763001 
    29773002                if not private_chat: 
     
    31023127                        if not ctrl: 
    31033128                                self.new_chat(contact, account, resource = resource_for_chat) 
    3104                                 if path: 
     3129                                if path and not self.dragging: 
    31053130                                        # we curently see contact in our roster OR he 
    31063131                                        # is not in the roster at all.  
    31073132                                        # show and select his line in roster  
     3133                                        # do not change selection while DND'ing 
    31083134                                        self.tree.expand_row(path[0:1], False) 
    31093135                                        self.tree.expand_row(path[0:2], False) 
     
    34133439                model = self.tree.get_model() 
    34143440                account = model[path][C_ACCOUNT].decode('utf-8') 
    3415                 type = model[path][C_TYPE] 
     3441                type_ = model[path][C_TYPE] 
    34163442                jid = model[path][C_JID].decode('utf-8') 
    34173443                resource = None 
    34183444                iter = model.get_iter(path) 
    3419                 if type in ('group', 'account'): 
     3445                if type_ in ('group', 'account'): 
    34203446                        if self.tree.row_expanded(path): 
    34213447                                self.tree.collapse_row(path) 
     
    34613487                else: 
    34623488                        accounts = [model[iter][C_ACCOUNT].decode('utf-8')] 
    3463                 type = model[iter][C_TYPE] 
    3464                 if type == 'group': 
     3489                type_ = model[iter][C_TYPE] 
     3490                if type_ == 'group': 
    34653491                        model.set_value(iter, 0, self.jabber_state_images['16']['opened']) 
    34663492                        jid = model[iter][C_JID].decode('utf-8') 
     
    34703496                                        if account + jid in self.collapsed_rows: 
    34713497                                                self.collapsed_rows.remove(account + jid) 
    3472                 elif type == 'account': 
     3498                elif type_ == 'account': 
    34733499                        account = accounts[0] # There is only one cause we don't use merge 
    34743500                        if account in self.collapsed_rows: 
     
    34803506                                        self.tree.expand_row(pathG, False) 
    34813507                        self.draw_account(account) 
    3482                 elif type == 'contact': 
     3508                elif type_ == 'contact': 
    34833509                        jid =  model[iter][C_JID].decode('utf-8') 
    34843510                        account = model[iter][C_ACCOUNT].decode('utf-8') 
     
    34933519                else: 
    34943520                        accounts = [model[iter][C_ACCOUNT].decode('utf-8')] 
    3495                 type = model[iter][C_TYPE] 
    3496                 if type == 'group': 
     3521                type_ = model[iter][C_TYPE] 
     3522                if type_ == 'group': 
    34973523                        model.set_value(iter, 0, self.jabber_state_images['16']['closed']) 
    34983524                        jid = model[iter][C_JID].decode('utf-8') 
     
    35023528                                        if not account + jid in self.collapsed_rows: 
    35033529                                                self.collapsed_rows.append(account + jid) 
    3504                 elif type == 'account': 
     3530                elif type_ == 'account': 
    35053531                        account = accounts[0] # There is only one cause we don't use merge 
    35063532                        if not account in self.collapsed_rows: 
    35073533                                self.collapsed_rows.append(account) 
    35083534                        self.draw_account(account) 
    3509                 elif type == 'contact': 
     3535                elif type_ == 'contact': 
    35103536                        jid =  model[iter][C_JID].decode('utf-8') 
    35113537                        account = model[iter][C_ACCOUNT].decode('utf-8') 
     
    39063932                selection.set(selection.target, 8, data) 
    39073933 
     3934        def drag_begin(self, treeview, context): 
     3935                self.dragging = True 
     3936 
     3937        def drag_end(self, treeview, context): 
     3938                self.dragging = False 
     3939 
    39083940        def on_drop_in_contact(self, widget, account_source, c_source, account_dest, 
    39093941                c_dest, was_big_brother, context, etime): 
     
    39573989                        ' to continue?') 
    39583990                sectext = _('Metacontacts are a way to regroup several contacts in one ' 
    3959                         'line. Generaly it is used when the same person has several Jabber ' 
     3991                        'line. Generally it is used when the same person has several Jabber ' 
    39603992                        'accounts or transport accounts.') 
    39613993                dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, 
     
    42334265                self.transports_state_images = {'16': {}, '32': {}, 'opened': {}, 
    42344266                        'closed': {}} 
    4235                  
     4267 
    42364268                self.last_save_dir = None 
    42374269                self.editing_path = None  # path of row with cell in edit mode 
     
    43884420                        gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY) 
    43894421                self.tree.enable_model_drag_dest(TARGETS2, gtk.gdk.ACTION_DEFAULT) 
     4422                self.tree.connect('drag_begin', self.drag_begin) 
     4423                self.tree.connect('drag_end', self.drag_end) 
    43904424                self.tree.connect('drag_data_get', self.drag_data_get_data) 
    43914425                self.tree.connect('drag_data_received', self.drag_data_received_data) 
     4426                self.dragging = False 
    43924427                self.xml.signal_autoconnect(self) 
    43934428                self.combobox_callback_active = True