Bug 102399 - [liboscar/icq] all contacts shown offline
Summary: [liboscar/icq] all contacts shown offline
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Unmaintained
Component: ICQ and AIM Plugins (show other bugs)
Version: unspecified
Platform: FreeBSD Ports FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-24 21:15 UTC by Bartosz Fabianowski
Modified: 2005-09-05 22:55 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bartosz Fabianowski 2005-03-24 21:15:10 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    FreeBSD Ports
Compiler:          gcc version 3.4.2 [FreeBSD] 20040728 Configured with: FreeBSD/i386 system compiler    Thread model: posix
OS:                FreeBSD

I am getting a very strange malfunction with Kopete 0.10 from KDE 3.4.0.

I can log in to ICQ just fine, but all contacts are shown as offline and when they try to message me, the messages get lost somewhere. This happens in a normal build no matter how I launch it.

With a debug build, behavior is different. When launched from the K Menu, the ICQ plug-in still malfunctions. But when Kopete is started by typing "kopete" into a Konsole window, contacts properly show up as online and messaging is working as expected.

I realize this bug is probably very hard to reproduce on other systems and it is very obscure. The most annoying part is that when I switch on debugging and launch from a console so I can actually see what is going on, the bug does not occur.

If somebody has an idea how to debug this any further, I would be very happy to hear about it.
Comment 1 gentoo 2005-03-25 00:25:04 UTC
I have the same problem on my Gentoo-Linux-Box, too.
I recently updated my whole KDE, which included Kopete and since then
ICQ didn't work properly.

I can connect to the network without any graphical error-message.
But all contacts are shown as offline, even when they send me a message, wich is displayed correctly. Furthermore I may chat with them as normal.
The only problem is, that I can't see who's online.

Launched in a console, Kopete gives the following output:

QGDict::hashKeyString: Invalid null key
QGDict::hashKeyString: Invalid null key
QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()
QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()
QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()
QMetaObject::findSignal:ClientStream: Conflict with Stream::readyRead()
QGArray::find: Index 0 out of range
QGArray::find: Index 0 out of range
QGArray::find: Index 0 out of range

I also deleted my kopeterc file and ~/.kde/* directories, but this didn't change anything. Let me know, if I can give you somehow some more debug-output or important information.
Comment 2 Will Stephenson 2005-03-25 16:39:26 UTC
Bartosz: Are both Kopetes the same version?
Comment 3 Matt Rogers 2005-03-25 17:50:39 UTC
Regarding comment #1: if you show all offline contacts, do they have red 'X's over the icq icon? If so, you have a different bug (which technically isn't a bug, but something that we'll probably have to work around anyways)
Comment 4 gentoo 2005-03-26 11:48:12 UTC
I'm using Kopete 0.10 and there is no X over the ICQ-Icon. It just looks normal, except the fact, that it's shown as offline.
Comment 5 Bartosz Fabianowski 2005-03-26 17:49:35 UTC
Re #2: Yes. I am always using the KDE 3.4.0 release tarballs and the only difference is that for a debug build, I set WANT_KDE_DEBUG=1 and otherwise, I don't.

Also, like the other poster, I have no red X's on any of my contacts. Except of the ones who haven't authorized me yet, of course, but that is expected behavior and what the X symbol is for as far as I know.
Comment 6 gentoo 2005-04-01 16:56:40 UTC
SOLUTION:

I've found a way to fix this problem! It doesn't seem to be a bug - concerning the described problem, but there probably is another mistake in Kopete's contact-management.

Yesterday I connected to the ICQ network by using Trillian and it told me, that it found some contacts I added to my list with Kopete. So Trillian wanted to add them to the (server-sided?) contact-list AGAIN!

Now I started Kopete today and exactely THESE contacts went online correctly!
I tried this to firm my theory:

Remove your old ICQ contact. Re-add it to your contact-list and it should work! Now I wonder whether there is a possibility to circumvent this time-consuming procedure.

So I gues, that Kopete made a mistake when I used it to add my contacts to the contact-list. I hope that helps the developers to fix the problem, but I would be glad to hear about you opinion.
Comment 7 Cyrill Helg 2005-04-01 19:44:41 UTC
Hi, I've the same problem here. So I installed an older version of kopete (0.9.2). And now almost all of my ICQ contacts are shown with a !, so this means I need to re-authorize them or re-add them to my contact list. Is there a possibilty to solve this? When I log in web icq, all these contacts marked with a ! are not there. 

In my case this problem was caused by sorting my contacts in new groups :(
Comment 8 Cyrill Helg 2005-04-02 01:27:48 UTC
Hi, I've the same problem here. So I installed an older version of kopete (0.9.2). And now almost all of my ICQ contacts are shown with a !, so this means I need to re-authorize them or re-add them to my contact list. Is there a possibilty to solve this? When I log in web icq, all these contacts marked with a ! are not there. 

In my case this problem was caused by sorting my contacts in new groups :(
Comment 9 Bartosz Fabianowski 2005-04-04 02:21:49 UTC
This bug had suddenly appeared for me and now it has just as suddenly disappeared. For the last few days, I have been able to log into ICQ without any problems at all, no matter how I launched Kopete. Also, I have just installed a no-debug build and that one works perfectly, too.

I have no idea what was wrong. Maybe it was something transient on the servers. Either way, I am now unable to reproduce the problem and unfortunately can't be of any more help in tracking it down :(.
Comment 10 Matthias H 2005-05-09 12:16:00 UTC
I can exactly confirm the behaviour of "Additional Comment #1 From gentoo at mofog.de 2005-03-25 00:25" on my system with Kubuntu 5.04
Comment 11 gentoo 2005-05-09 16:38:43 UTC
Is somebody working on this problem, or do we post these messages for nothing?
I recently switched back to GAIM, wich is not as nice and doesn't offer as much eye-candy as Kopete does, but the most important fact is: it works.

I couldn't find out anything else about Kopete's strange behaviour.
But some friends told me, that they couldn't auhtorize me with their windows-client, though I was online and had them on my contact-list, too.
Comment 12 S. Burmeister 2005-05-20 10:38:02 UTC
In bug 90353 it is stated:
 - Delayed contact creation. Contacts aren't created on the kopete list until 
   we get a confirmation back from the server that they were added correctly. 

So this should work, yet I see this behaviour too with 0.10, so either it was not fixed, or there is a regression.
Comment 13 Lars Uebernickel 2005-06-20 21:50:40 UTC
I was able to solve this problem to by removing and re-adding contacts. It seems that kopete does not add contacts to the server sometimes. It happened for me when I added a contact through a chat window (Chat -> Contacts -> Add ...). I tried to move these contacts to a new group, but kopete gave me some server error (probably because the server didn't know of these contacts).
Comment 14 Dominik Schmidt 2005-06-30 22:33:29 UTC
*** This bug has been confirmed by popular vote. ***
Comment 15 Matt Rogers 2005-07-09 00:17:59 UTC
w/o access to the account, or some sort of debug log, I can't fix this. So, you'll either need to recompile kopete with debug info (./configure --enable-debug) or you'll need to let me have access to your account. If you choose the second option, you can mail it to me in private.
Comment 16 Tom Schumm 2005-08-09 01:10:52 UTC
I've emailed you my account info.  If you are able to fix this bug, I will erect a shrine in your honor and bow to it 16 times daily.  I'd have fire ants driven behind my eyeballs than switch back to gaim.
Comment 17 Matt Rogers 2005-08-28 03:32:26 UTC
working on a fix. might take some time though
Comment 18 Matt Rogers 2005-09-05 22:55:58 UTC
SVN commit 457416 by mattr:

Tell users that they don't have certain contacts on their server side
contact list and give them the option to add them. Fixes bug 102399. Please
make sure it works for you.

BUG: 102399.


 M  +3 -1      Makefile.am  
 M  +9 -0      icq/icqprotocol.cpp  
 M  +89 -1     oscaraccount.cpp  
 M  +2 -0      oscaraccount.h  
 M  +4 -1      oscarcontact.cpp  
 M  +14 -1     oscarlistnonservercontacts.cpp  
 M  +7 -0      oscarlistnonservercontacts.h  


--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/Makefile.am #457415:457416
@@ -6,6 +6,8 @@
 
 lib_LTLIBRARIES = libkopete_oscar.la
 
-libkopete_oscar_la_SOURCES = oscaraccount.cpp oscarcontact.cpp oscarmyselfcontact.cpp oscarencodingselectionbase.ui oscarencodingselectiondialog.cpp
+libkopete_oscar_la_SOURCES = oscaraccount.cpp oscarcontact.cpp oscarmyselfcontact.cpp \
+	oscarencodingselectionbase.ui oscarencodingselectiondialog.cpp \
+	oscarlistcontactsbase.ui oscarlistnonservercontacts.cpp
 libkopete_oscar_la_LDFLAGS = -no-undefined -version-info 2:0:0 $(all_libraries)
 libkopete_oscar_la_LIBADD  = $(LIB_KIO) $(top_builddir)/kopete/libkopete/libkopete.la ./liboscar/liboscar.la
--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/icq/icqprotocol.cpp #457415:457416
@@ -760,12 +760,21 @@
 	uint ssiGid = 0, ssiBid = 0, ssiType = 0xFFFF;
 	QString ssiName;
 	bool ssiWaitingAuth = false;
+    if ( serializedData.contains( "ssi_name" ) )
 	ssiName = serializedData["ssi_name"];
+
+    if ( serializedData.contains( "ssi_waitingAuth" ) )
+    {
 	QString authStatus = serializedData["ssi_waitingAuth"];
 	if ( authStatus == "true" )
 		ssiWaitingAuth = true;
+    }
+
+    if ( serializedData.contains( "ssi_gid" ) )
 	ssiGid = serializedData["ssi_gid"].toUInt();
+    if ( serializedData.contains( "ssi_bid" ) )
 	ssiBid = serializedData["ssi_bid"].toUInt();
+    if ( serializedData.contains( "ssi_type" ) )
 	ssiType = serializedData["ssi_type"].toUInt();
 
 	Oscar::SSI item( ssiName, ssiGid, ssiBid, ssiType, QValueList<TLV>(), 0 );
--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/oscaraccount.cpp #457415:457416
@@ -51,6 +51,7 @@
 #include "oscarclientstream.h"
 #include "oscarconnector.h"
 #include "ssimanager.h"
+#include "oscarlistnonservercontacts.h"
 #include <qtextcodec.h>
 
 class OscarAccountPrivate
@@ -68,6 +69,7 @@
 	//contacts waiting on their group to be added
 	QMap<QString, QString> contactAddQueue;
 
+    OscarListNonServerContacts* olnscDialog;
 
 };
 
@@ -79,7 +81,7 @@
 
 	d = new OscarAccountPrivate;
 	d->engine = new Client( this );
-
+    d->olnscDialog = 0L;
     QObject::connect( d->engine, SIGNAL( loggedIn() ), this, SLOT( loginActions() ) );
 	QObject::connect( d->engine, SIGNAL( messageReceived( const Oscar::Message& ) ),
 	                  this, SLOT( messageReceived(const Oscar::Message& ) ) );
@@ -238,9 +240,95 @@
 	                  this, SLOT( ssiGroupAdded( const Oscar::SSI& ) ) );
 
     //TODO: check the kopete contact list and handle non server side contacts appropriately.
+    QDict<Kopete::Contact> nonServerContacts = contacts();
+    QDictIterator<Kopete::Contact> it( nonServerContacts );
+    QStringList nonServerContactList;
+    for ( ; it.current(); ++it )
+    {
+        OscarContact* oc = dynamic_cast<OscarContact*>( ( *it ) );
+        if ( !oc )
+            continue;
+        kdDebug(OSCAR_GEN_DEBUG) << k_funcinfo << oc->contactId() << " contact ssi type: " << oc->ssiItem().type() << endl;
+        if ( !oc->isOnServer() )
+            nonServerContactList.append( ( *it )->contactId() );
+    }
+    kdDebug(OSCAR_GEN_DEBUG) << k_funcinfo << "the following contacts are not on the server side list"
+                             << nonServerContactList << endl;
+    if ( !nonServerContactList.isEmpty() )
+    {
+        d->olnscDialog = new OscarListNonServerContacts( Kopete::UI::Global::mainWidget() );
+        QObject::connect( d->olnscDialog, SIGNAL( closing() ),
+                          this, SLOT( nonServerAddContactDialogClosed() ) );
+        d->olnscDialog->addContacts( nonServerContactList );
+        d->olnscDialog->show();
+    }
 }
 
+void OscarAccount::nonServerAddContactDialogClosed()
+{
+    //use sender() because i'm lazy
+    if ( !d->olnscDialog )
+        return;
 
+    kdDebug(OSCAR_GEN_DEBUG) << "non server contacts notification dialog closed" << endl;
+    if ( d->olnscDialog->result() == QDialog::Accepted )
+    {
+        //start adding contacts
+        kdDebug(OSCAR_GEN_DEBUG) << "adding non server contacts to the contact list" << endl;
+        //get the contact list. get the OscarContact object, then the group
+        //check if the group is on ssi, if not, add it
+        //if so, add the contact.
+        QStringList offliners = d->olnscDialog->nonServerContactList();
+        QStringList::iterator it, itEnd = offliners.end();
+        for ( it = offliners.begin(); it != itEnd; ++it )
+        {
+            OscarContact* oc = dynamic_cast<OscarContact*>( contacts()[( *it )] );
+            if ( !oc )
+            {
+                kdDebug(OSCAR_GEN_DEBUG) << k_funcinfo << "no OscarContact object available for"
+                                         << ( *it ) << endl;
+                continue;
+            }
+
+            Kopete::MetaContact* mc = oc->metaContact();
+            if ( !mc )
+            {
+                kdDebug(OSCAR_GEN_DEBUG) << k_funcinfo << "no metacontact object available for"
+                                         << ( oc->contactId() ) << endl;
+                continue;
+            }
+
+            Kopete::Group* group = mc->groups().first();
+            if ( !group )
+            {
+                kdDebug(OSCAR_GEN_DEBUG) << k_funcinfo << "no metacontact object available for"
+                                         << ( oc->contactId() ) << endl;
+                continue;
+            }
+
+            SSIManager* listManager = d->engine->ssiManager();
+            if ( !listManager->findGroup( group->displayName() ) )
+            {
+                kdDebug(OSCAR_GEN_DEBUG) << k_funcinfo << "adding non-existant group "
+                                         << group->displayName() << endl;
+                d->contactAddQueue[Oscar::normalize( ( *it ) )] = group->displayName();
+                d->engine->addGroup( group->displayName() );
+            }
+            else
+            {
+                d->engine->addContact( ( *it ), group->displayName() );
+            }
+        }
+
+
+    }
+    else
+        kdDebug(OSCAR_GEN_DEBUG) << "NOT adding non server contacts to the contact list" << endl;
+
+    d->olnscDialog->delayedDestruct();
+    d->olnscDialog = 0L;
+}
+
 void OscarAccount::slotGoOffline()
 {
 	OscarAccount::disconnect();
--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/oscaraccount.h #457415:457416
@@ -131,6 +131,8 @@
 	void userStartedTyping( const QString & contact );
 	void userStoppedTyping( const QString & contact );
 
+    void nonServerAddContactDialogClosed();
+
 signals:
 
 	void accountDisconnected( Kopete::Account::DisconnectReason reason );
--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/oscarcontact.cpp #457415:457416
@@ -70,7 +70,10 @@
 
 bool OscarContact::isOnServer() const
 {
-	return ( m_ssiItem.type() != 0xFFFF );
+    SSIManager* serverList = mAccount->engine()->ssiManager();
+    SSI ssi = serverList->findContact( Oscar::normalize( contactId() ) );
+
+	return ( ssi && ssi.type() != 0xFFFF );
 }
 
 void OscarContact::setSSIItem( const Oscar::SSI& ssiItem )
--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/oscarlistnonservercontacts.cpp #457415:457416
@@ -31,7 +31,6 @@
     setMainWidget( m_contactsList );
     setButtonText( Ok, i18n( "&Add" ) );
     setButtonText( Cancel, i18n( "Do &not add" ) );
-
 }
 
 OscarListNonServerContacts::~OscarListNonServerContacts()
@@ -50,4 +49,18 @@
     return m_nonServerContacts;
 }
 
+
+
+void OscarListNonServerContacts::slotCancel()
+{
+    KDialogBase::slotCancel();
+    emit closing();
+}
+
+void OscarListNonServerContacts::slotOk()
+{
+    KDialogBase::slotOk();
+    emit closing();
+}
+
 #include "oscarlistnonservercontacts.moc"
--- branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/oscarlistnonservercontacts.h #457415:457416
@@ -34,6 +34,13 @@
     void addContacts( const QStringList& contactList );
     QStringList nonServerContactList() const;
 
+protected:
+    virtual void slotOk();
+    virtual void slotCancel();
+
+signals:
+    void closing();
+
 private:
     OscarListContactsBase* m_contactsList;
     QStringList m_nonServerContacts;