Bug 75054

Summary: account preference doesn't work
Product: [Unmaintained] kopete Reporter: Jan Trmal <jtrmal>
Component: generalAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: sven.burmeister
Priority: NOR    
Version: 0.8.0   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Jan Trmal 2004-02-12 10:41:39 UTC
Version:           0.8.0 (using KDE 3.2.0, Gentoo)
Compiler:          gcc version 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r3, propolice)
OS:          Linux (i686) release 2.4.24

I have some friends available through both IRC and ICQ.
No matter how I change plugin/account order in settings/acounts (with the move-up and move-down buttons), the default method of contacting them is via IRC account.
Comment 1 jstuart 2004-02-12 20:15:35 UTC
Jan, how are you trying to chat with your friend?  IE when you click on them, do you click on the IRC icon or do you click on their name?  Or do you right click and then choose send message?
Comment 2 Jan Trmal 2004-02-12 20:24:35 UTC
When I click on specific icon beside his name, I get desired protocol. After the right-click I can select desired protocol. It all works OK. But when I click directly on his nickname, I always get IRC (not ICQ which I select in settings/Accounts settings as preffered protocol (via move-up button)). I'm just curious, this order is not related to preffered method (protocol) of contact, when more methods available? In that case I've to apologize, I'm wasting your time. Or my english is so bad you can't understand?
Comment 3 jstuart 2004-02-13 06:49:35 UTC
Ok Jan, question.  For this metacontact, is the IRC account shown FIRST and THEN the other protocols?  
Comment 4 Richard Smith 2004-02-13 16:11:10 UTC
Confirmed. The order of contacts within a metacontact doesn't seem to affect the outcome. Investigating...
Comment 5 Jan Trmal 2004-02-13 22:16:29 UTC
> 06:49 ------- Ok Jan, question.  For this metacontact, is the IRC account
> shown FIRST and THEN the other protocols?
The IRC account icon is show first. I've tried also create first the ICQ 
contact in metacontact and then add IRC contact to the same contact, but the 
order is still the same... [Name IRC ICQ]

Comment 6 Richard Smith 2004-02-14 16:39:58 UTC
I'm on it... it's a KOS design flaw :)
Comment 7 Richard Smith 2004-02-14 17:34:12 UTC
CVS commit by lilachaze: 

Choose preferred contact by online status only, not weight, not protocol,
not internal status :)
Reverse meaning of KopeteAccount::priority() - higher numbers now mean
higher priorities. This will reverse the order of account lists, but up
until this patch they were pretty much ignored anyway.
CCMAIL: 75054@bugs.kde.org


  M +2 -3      kopete/config/accounts/kopeteaccountconfig.cpp   1.15
  M +2 -2      libkopete/kopeteaccountmanager.cpp   1.46
  M +8 -6      libkopete/kopetemetacontact.cpp   1.201


--- kdenetwork/kopete/kopete/config/accounts/kopeteaccountconfig.cpp  #1.14:1.15
@@ -61,5 +61,4 @@ KopeteAccountConfig::KopeteAccountConfig
         m_view->mButtonUp->setPixmap( SmallIcon( "up" ) );
         m_view->mButtonDown->setPixmap( SmallIcon( "down" ) );
-        m_view->mAccountList->setSorting( 1 );
 
         connect( m_view->mButtonNew,    SIGNAL( clicked() ), this, SLOT( slotAddAccount() ) );
@@ -79,10 +78,10 @@ KopeteAccountConfig::KopeteAccountConfig
 void KopeteAccountConfig::save()
 {
-        uint priority = 0;
+        uint priority = m_view->mAccountList->childCount();
 
         KopeteAccountLVI *i = static_cast<KopeteAccountLVI*>( m_view->mAccountList->firstChild() );
         while( i )
         {
-                  i->account()->setPriority( priority++ );
+                  i->account()->setPriority( priority-- );
                   i = static_cast<KopeteAccountLVI*>( i->nextSibling() );
         }

--- kdenetwork/kopete/libkopete/kopeteaccountmanager.cpp  #1.45:1.46
@@ -44,7 +44,7 @@ class KopeteAccountPtrList : public QPtr
                                 return 0;
                         else if( priority1 > priority2 )
-                                return -1;
-                        else
                                 return 1;
+                        else
+                                return -1;
                 }
 };

--- kdenetwork/kopete/libkopete/kopetemetacontact.cpp  #1.200:1.201
@@ -327,15 +327,17 @@ KopeteContact *KopeteMetaContact::prefer
         */
 
-        KopeteContact *contact = 0L;
+        KopeteContact *contact = 0;
 
-        QPtrList<KopeteAccount> accounts = KopeteAccountManager::manager()->accounts();
         for ( QPtrListIterator<KopeteContact> it( d->contacts ); it.current(); ++it )
         {
                 // FIXME: The isConnected call should be handled in KopeteContact::isReachable
                 //        after KDE 3.2 - Martijn
-                if ( it.current()->account() && it.current()->account()->isConnected() && it.current()->isReachable() &&
-                        ( !contact || it.current()->onlineStatus() > contact->onlineStatus()  ||
-                        ( it.current()->onlineStatus() == contact->onlineStatus() &&
-                        it.current()->account()->priority() < contact->account()->priority() ) ) )
+                if ( !it.current()->account() || !it.current()->account()->isConnected() || !it.current()->isReachable() )
+                        continue;
+
+                if ( !contact ||
+                     it.current()->onlineStatus().status() > contact->onlineStatus().status() ||
+                     ( it.current()->onlineStatus().status() == contact->onlineStatus().status() &&
+                       it.current()->account()->priority() > contact->account()->priority() ) )
                 {
                         contact = *it;


Comment 8 Richard Smith 2004-02-14 17:39:13 UTC
CVS commit by lilachaze: 

Choose preferred contact by online status only, not weight, not protocol,
not internal status :)
Reverse meaning of KopeteAccount::priority() - higher numbers now mean
higher priorities. This will reverse the order of account lists, but up
until this patch they were pretty much ignored anyway. [BACKPORT]
CCMAIL: 75054-done@bugs.kde.org


  M +2 -3      kopete/config/accounts/kopeteaccountconfig.cpp   1.14.2.1
  M +2 -2      libkopete/kopeteaccountmanager.cpp   1.43.2.3
  M +11 -6     libkopete/kopetemetacontact.cpp   1.197.2.1


--- kdenetwork/kopete/kopete/config/accounts/kopeteaccountconfig.cpp  #1.14:1.14.2.1
@@ -61,5 +61,4 @@ KopeteAccountConfig::KopeteAccountConfig
         m_view->mButtonUp->setPixmap( SmallIcon( "up" ) );
         m_view->mButtonDown->setPixmap( SmallIcon( "down" ) );
-        m_view->mAccountList->setSorting( 1 );
 
         connect( m_view->mButtonNew,    SIGNAL( clicked() ), this, SLOT( slotAddAccount() ) );
@@ -79,10 +78,10 @@ KopeteAccountConfig::KopeteAccountConfig
 void KopeteAccountConfig::save()
 {
-        uint priority = 0;
+        uint priority = m_view->mAccountList->childCount();
 
         KopeteAccountLVI *i = static_cast<KopeteAccountLVI*>( m_view->mAccountList->firstChild() );
         while( i )
         {
-                  i->account()->setPriority( priority++ );
+                  i->account()->setPriority( priority-- );
                   i = static_cast<KopeteAccountLVI*>( i->nextSibling() );
         }

--- kdenetwork/kopete/libkopete/kopeteaccountmanager.cpp  #1.43.2.2:1.43.2.3
@@ -44,7 +44,7 @@ class KopeteAccountPtrList : public QPtr
                                 return 0;
                         else if( priority1 > priority2 )
-                                return -1;
-                        else
                                 return 1;
+                        else
+                                return -1;
                 }
 };

--- kdenetwork/kopete/libkopete/kopetemetacontact.cpp  #1.197:1.197.2.1
@@ -312,12 +312,17 @@ KopeteContact *KopeteMetaContact::prefer
         */
 
-        KopeteContact *contact = 0L;
+        KopeteContact *contact = 0;
 
-        QPtrList<KopeteAccount> accounts = KopeteAccountManager::manager()->accounts();
-        for( QPtrListIterator<KopeteContact> it( d->contacts ) ; it.current(); ++it )
+        for ( QPtrListIterator<KopeteContact> it( d->contacts ); it.current(); ++it )
         {
-                if( ( *it )->isReachable() && ( !contact || ( *it )->onlineStatus() > contact->onlineStatus()  ||
-                                ( (*it)->account() && (*it)->onlineStatus() == contact->onlineStatus() &&
-                                (*it)->account()->priority() < contact->account()->priority() ) ) )
+                // FIXME: The isConnected call should be handled in KopeteContact::isReachable
+                //        after KDE 3.2 - Martijn
+                if ( !it.current()->account() || !it.current()->account()->isConnected() || !it.current()->isReachable() )
+                        continue;
+
+                if ( !contact ||
+                     it.current()->onlineStatus().status() > contact->onlineStatus().status() ||
+                     ( it.current()->onlineStatus().status() == contact->onlineStatus().status() &&
+                       it.current()->account()->priority() > contact->account()->priority() ) )
                 {
                         contact = *it;


Comment 9 S. Burmeister 2007-07-02 08:04:05 UTC
Is this patch still in kopete? If I understand it correctly, the account with the lowest entry in the account-list is now the first entry, which would not make sense.