Bug 62427

Summary: wrong change from invisible to active
Product: [Unmaintained] kopete Reporter: Alejandro Exojo <suy21>
Component: Main ApplicationAssignee: Kopete Developers <kopete-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Alejandro Exojo 2003-08-09 21:39:43 UTC
Version:           0.7.0 (using KDE 3.1.3)
Installed from:     (3.0)
Compiler:          gcc version 2.95.4 20011002 (Debian prerelease)
OS:          Linux (i686) release 2.4.18-bf2.4

Hi.

I was using kopete with msn and jabber protocols at the same time. My jabber state was online, and my msn state was invisible. I went away from the keyboard for a while, and when returned, I saw jabber state changing from away to online (right), and msn state changing from away to online (wrong!, I was supposed to be offline, and after being idle, kopete showed people that I was really connected).

In "behaviour", kopete is configured to use auto away feature, but "motion auto-away" plugin is disabled. The expected behaviour, I think is not to change a "very-away" state like invisible, to a "not-so-away" state like "away". The automatic change of state, should be only from "online" status.

OTOH, congratulations for kopete, is a really great software! I'm using it a lot.

Best regards.
Comment 1 Matt Rogers 2003-10-07 21:07:56 UTC
Motion auto-away has nothing to do with this since it monitors webcams as a motion detection 
type thing.  
Comment 2 Olivier Goffart 2003-10-08 19:08:50 UTC
It's normal, the MSN "Invisible" mode is considered by libkopete as "Online" 
a solution would be to consider it as "Away"  But it does not make a lot of sens. 
And "Offiline" is not the solution either because "disconnect all" and "connect all" will 
not work as exepted again. 
 
(and Unknown and Connecting made no more sens) 
 
Any idea?  
Comment 3 Martijn Klingens 2003-10-08 20:45:52 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On Wednesday 08 October 2003 19:08, Olivier Goffart wrote:
> Any idea?

We could add a status 'Hidden' or so, but this is really a hairy problem.

For me Invisible is not 'away', it is 'online' since I'm really online. In 
fact, with e.g. Jabber I continue talking in invisible mode. I just don't 
want others to assume I'm available, they can send offline messages if they 
want and I may or may not respond quickly.

In short, I think Hidden is a very special case that contains elements of many 
other statuses.

Comment 4 Jason Keirstead 2003-10-09 14:17:44 UTC
This is not correct, I agree with the original poster. 
 
If someone is invisible, auto-away should not change that status, because that defeats the 
whole point of being invisible in the first place! (to hide the fact that you are online with the 
service ), since everyone with you as a contact suddenly sees you appear marked as away. 
 
Even worse is the fact that we are switching back to Online after coming back from away. Auto 
away should remember the state that the contact was in beforehand and set it back to that 
(example, in ICQ there are a few different "Online" states, such as Free to Chat etc, and the 
state should be put back to that after returning ). 
 
The solution to the second problem is easy, not so much with the first one, since not all 
protocols have invisble etc. Perhaps we can have a special Hidden KOS liek Martijn suggested. 
Not sure, but the bug is very valid. You sholdn't be marked as away with auto-away if you are 
invisible. 
Comment 5 Olivier Goffart 2003-10-09 14:56:48 UTC
> This is not correct, I agree with the original poster.  
 
uh? what is not correct? 
And of course, this is a valid bug, and i think we all agree with the original poster. 
 
My problem is: "how to fix it"   
 
A Hidden status would help us,  but if we intruduce that, it will be only used for 
autowaway, and by some protocol (Invisible is a flag that can be set with another 
status for ICQ) 
Now, i think this bug is important enough to fix it for KDE 3.2 
 
> The solution to the second problem is easy 
 
not as easy as that...  at least, our current API does not allow libkopete to change the 
status to other than online/away/offline. 
 
 
Comment 6 Jason Keirstead 2003-10-09 15:18:04 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

> A Hidden status would help us,  but if we intruduce that, it will be only
> used for autowaway, and by some protocol (Invisible is a flag that can be
> set with another status for ICQ)

Invisible would just be another KOS like away and Online, and a protocol could
use it how they see fit. If only Jabber and ICQ and MSN used it, that's fine. 
When auto-away triggers, it won't change these contacts to away.

> not as easy as that...  at least, our current API does not allow libkopete
> to change the status to other than online/away/offline.

Yes it does, at the KopeteContact level (setOnlineStatus)

Since to fix this you will need to store the individual KopeteContact statuses 
anyways, when you come back from auto-away instead of calling KMC->Online you 
iterate through the sub-contacts and set all their statuses to the correct 
values you had saved.

Comment 7 Olivier Goffart 2003-10-09 16:20:22 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

Le Jeudi 09 Octobre 2003 15:17, Jason Keirstead a 
Comment 8 Jason Keirstead 2003-10-09 16:27:14 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On October 09, 2003 11:20 am, Olivier Goffart wrote:
> > If only Jabber and ICQ and MSN used it,  that's fine.
>
> not ICQ

er, huh? ICQ has an invisible mode.

> And i am back to my previous affirmation: the api does not allow to use a
> custom status to change the account's status

Well the API should be changed to incluide this.  KopeteAccount should have a 
setOnlineStatus just like KopeteContact. An account can be more than offline, 
online and away. I am really surprised that this is lacking, it would really 
cripple a plugin's ability to adjust an accounts status.

Comment 9 Olivier Goffart 2003-10-09 16:33:33 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

Le Jeudi 09 Octobre 2003 16:27, Jason Keirstead a 
Comment 10 Will Stephenson 2003-10-09 17:02:23 UTC
Isn't this the point of the XXXAccount::myself() member? 
 
 
Comment 11 Martijn Klingens 2003-10-09 17:10:25 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On Thursday 09 October 2003 16:26, Jason Keirstead wrote:
> Well the API should be changed to incluide this.  KopeteAccount should have
> a setOnlineStatus just like KopeteContact. An account can be more than
> offline, online and away. I am really surprised that this is lacking,

That's on purpose.

KopeteOnlineStatus only cares about the BASIC status, which is used everywhere 
in libkopete. Changing this by adding more basic states should be done with 
utmost care, it is _VERY_ likely to cause subtle bugs. I for one oppose such 
a change until KDE 3.2 is out.

After that we can consider a special status for Hidden, and even that is 
tricky since hidden is mostly like Online. Having to add hidden to every if() 
that checks for Online now is not the way to go. It's messy and error prone, 
not to mention that you're abusing KopeteOnlineStatus for exactly what it was 
trying to AVOID: having a gazillion of subtly different statuses in libkopete 
where they are not interesting at all.

Comment 12 Jason Keirstead 2003-10-09 18:44:49 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On October 09, 2003 12:10 pm, Martijn Klingens wrote:
> KopeteOnlineStatus only cares about the BASIC status, which is used
> everywhere in libkopete

This isn't true. Everry protocol has their own internal KOS states. And the 
away system should respect these on an account by account basis.

If I am set to "Free for Chat" on ICQ, then auto away triggers, when it comes 
back I should not be set to "Online". It should restore my original KOS 
state. Adding a steOnlineStatus to KopeteAccount wond perform this task 
nicely, and I really don't see how it could cause bugs in existing code since 
internally accounts change their online status all the time.

> Changing this by adding more basic states should 
> be done with utmost care, it is _VERY_ likely to cause subtle bugs. I for
> one oppose such a change until KDE 3.2 is out.

Why would adding an Invisible state cause bugs? Please elaborate, if no 
existing code uses the new state I don't see how it could be a problem.

> After that we can consider a special status for Hidden, and even that is
> tricky since hidden is mostly like Online. 

HIdden is not like online.. you are hiding from people. Auto away should never 
affect a hidden status and thus invalidate the reason for invisible.

> Having to add hidden to every 
> if() that checks for Online now is not the way to go. It's messy and error
> prone, not to mention that you're abusing KopeteOnlineStatus for exactly
> what it was trying to AVOID: having a gazillion of subtly different
> statuses in libkopete where they are not interesting at all

There'd only be ONE place to change, the isOnline function in 
kopetecontact.cpp. 

bool KopeteContact::isOnline() const
{
	return d->onlineStatus.status() != KopeteOnlineStatus::Offline && 
d->onlineStatus.status() != KopeteOnlineStatus::Unknown;
}

... just throw in Hidden.

There should be no other place in the code that is checking if the contact is 
online by comparing KOS states. If there is then THAT is the bug.

Comment 13 Jason Keirstead 2003-10-09 19:03:36 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On October 09, 2003 1:44 pm, Jason Keirstead wrote:

> There'd only be ONE place to change, the isOnline function in
> kopetecontact.cpp.
>
> bool KopeteContact::isOnline() const
> {
> 	return d->onlineStatus.status() != KopeteOnlineStatus::Offline &&
> d->onlineStatus.status() != KopeteOnlineStatus::Unknown;
> }
>
> ... just throw in Hidden.
>

Actually screw that, you wouldn't need ot change it at all since it just 
checks if it is != Offline and Hidden would satisfy this!

Comment 14 Martijn Klingens 2003-10-09 19:44:58 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On Thursday 09 October 2003 18:44, Jason Keirstead wrote:
> On October 09, 2003 12:10 pm, Martijn Klingens wrote:
> > KopeteOnlineStatus only cares about the BASIC status, which is used
> > everywhere in libkopete
>
> This isn't true. Everry protocol has their own internal KOS states. And the
> away system should respect these on an account by account basis.
>
> If I am set to "Free for Chat" on ICQ, then auto away triggers, when it
> comes back I should not be set to "Online". It should restore my original
> KOS state.

Sure, but that's not the topic at hand here. We're not talking about going 
away and back, we're talking about adding Invisible or Hidden as a new online 
status.

> Adding a steOnlineStatus to KopeteAccount wond perform this task 
> nicely

(It doesn't belong in KopeteAccount. The away code should maintain its own 
QMap/QPtrList/whatever to hold the previous state.)

But you're right that it doesn't cause regressions.

And again, this is NOT the case at hand here, because we're discussing the 
addition of a Hidden online status.

> > Changing this by adding more basic states should
> > be done with utmost care, it is _VERY_ likely to cause subtle bugs. I for
> > one oppose such a change until KDE 3.2 is out.
>
> Why would adding an Invisible state cause bugs? Please elaborate, if no
> existing code uses the new state I don't see how it could be a problem.

We use if() and case() on status() all the time. The sorting in 
KopeteContactListView uses it, the checks for online state, *everything*.

While it's mostly the KopeteContact side of things that is affected (and not 
the KopeteAccount code paths) you can not change the API for one without 
affecting the other.

We're talking about an API here, not about 'hey, it's a hack, but it works, so 
who bothers?' code. In other words: If we introduce another status we should 
not rely on KopeteContact not using it, it will have to work *everywhere*.

In fact if we do it we should make active use for it in KopeteContact as well, 
it would make sense. As such the amount of regressions is too much, after KDE 
3.2 I'm all for it and not a minute sooner.

> HIdden is not like online.. you are hiding from people. Auto away should
> never affect a hidden status and thus invalidate the reason for invisible.

True. There are reasons for adding Hidden. There are also reasons for not 
doing so _NOW_. After KDE 3.2 you're welcome to do it properly.

Comment 15 Jason Keirstead 2003-10-09 20:03:01 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On October 09, 2003 2:45 pm, Martijn Klingens wrote:

> Sure, but that's not the topic at hand here. We're not talking about going
> away and back, we're talking about adding Invisible or Hidden as a new
> online status.

We are talking about both. Either / Both of these bugs require a 
setOnlineStatus in Kopete Account

> Adding a steOnlineStatus to KopeteAccount wond perform this task 
> nicely

> (It doesn't belong in KopeteAccount. The away code should maintain its own
> QMap/QPtrList/whatever to hold the previous state.)

Er huh? how to you expect the away system to set the status if setOnlineStatus 
doesnt exist?

It should save the KOS of each account as it sets them away in a QMap of 
KopeteAccount->KOS, then call setOnlineStatus ont he accounts when they 
return to put them back to their original state. There is really no other way 
to do it unless you call account->mySelf->setOnlineStatus, but someone eais 
earlier already that doesn't function that way.

> We use if() and case() on status() all the time. 

As I said above,  the ONLY place where you should compare status == Online is 
in isOnline in KopeteContact, and this isn't even done there. There may be 
some internally in the plugins, but those are internal plugin issues that 
should be fixed not Kopete API ones.

> The sorting in 
> KopeteContactListView uses it, the checks for online state, *everything*.

Thse just compare the values of the status using <>. There is no == 
KOS::Online involved here. All you need ot do is make invisible less than 
away but greater than offline and the lists will be sorted properly.

> We're talking about an API here, not about 'hey, it's a hack, but it works,
> so who bothers?' code. In other words: If we introduce another status we
> should not rely on KopeteContact not using it, it will have to work
> *everywhere*.

I still don't see why it wouldn't work anywhere. I could add this code and it 
wouldn't affect anything at all.

Comment 16 Martijn Klingens 2003-10-09 20:22:29 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On Thursday 09 October 2003 20:03, Jason Keirstead wrote:
> > Adding a steOnlineStatus to KopeteAccount wond perform this task
> > nicely
> >
> > (It doesn't belong in KopeteAccount. The away code should maintain its
> > own QMap/QPtrList/whatever to hold the previous state.)
>
> Er huh? how to you expect the away system to set the status if
> setOnlineStatus doesnt exist?

"setOnlineStatus" ? I read that text of yours as "lastOnlineStatus", which fit 
way better with the rest of the text. Please spell check your mail before 
sending it.

Yes, setOnlineStatus is fine with me. In fact, I want this for a long time, 
together with all code in the plugins to register the available KOS objects 
so the entire Go Online/Offline/Whatever menu will be handled in libkopete. 
Would save quite some code in all plugins. I postponed this until post 3.2 
though.

> As I said above,  the ONLY place where you should compare status == Online
> is in isOnline in KopeteContact, and this isn't even done there. There may
> be some internally in the plugins, but those are internal plugin issues
> that should be fixed not Kopete API ones.

No, the API is ok. The whole idea behind it is that it should be used 
everywhere. Obviously that results in regressions when you add a status, but 
that's not bad per se. Only right now during a freeze.

Comment 17 Olivier Goffart 2003-10-09 20:54:03 UTC
Stop please. 
 
The Bug 62427 (this bug) is about do not go away if we was offline when auto-away. 
This is IMO an important which need to be fixed for KDE 3.2 
 
A easy solution (workaround) for that is tu use the Away type for the invisible KOS 
(since away account are not set away when auto-away, and are not set online when 
activity   [see the cvs comment of the revision 1.20 of kopeteaway.cpp] ) 
 
The problem with free for chat is another minor problem, (which will need a setStatus 
in KopeteAccount. )  But this is not the point of this bug. Please do not continue to talk 
about that on this bug report. (I think there are already another bug report for that) 
 
 
 
Now, for this bug, like i said, using the Away status for the invisible KOS is a good 
compromise until KDE 3.2:  
+It does not need api changes. 
+Since the invisible status is never used for contact, that's not a metacontact status 
problem or so.  
+I don't think it will have side effect because it should act exactly like the Busy status. 
 
anyway, we could imagine the Invisible/Hidden status.  For that, i would wait after KDE 
3.2 because of side effect 
 
Martijn, is that ok for you?  after all, Invisible is about like busy.... 
 
Comment 18 Jason Keirstead 2003-10-09 21:05:06 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On October 09, 2003 3:54 pm, Olivier Goffart wrote:

> A easy solution (workaround) for that is tu use the Away type for the
> invisible KOS (since away account are not set away when auto-away, and are
> not set online when activity   [see the cvs comment of the revision 1.20 of
> kopeteaway.cpp] )

This is not really anywhere near a solution since Away is not the same as 
Invisible at all.

> The problem with free for chat is another minor problem, (which will need a
> setStatus in KopeteAccount. )  But this is not the point of this bug.
> Please do not continue to talk about that on this bug report. (I think
> there are already another bug report for that)

The problems are actually very closely related.

> Now, for this bug, like i said, using the Away status for the invisible KOS
> is a good compromise until KDE 3.2:

No it isn't :P

> +Since the invisible status is never used for contact, that's not a
> metacontact status problem or so.

Not sure what this sentence means, but MSN Jabber and ICQ all have Invisible 
KOS states that should definitly not be changed when auto-away is triggered

> +I don't think it will have side effect because it should act exactly like
> the Busy status.

Busy is not the same as invisible at all. Invisible means no one can see that 
you are online except those who you set to allow. Busy everyone can see you 
online.

The only real solutions to this bug are either 

1. Add setOnlineStatus to KopeteAccount (which would also fix the other bug ) 
and also add an Invisible or Hidden KOS state

2. Remove auto-away from the release (not really an option )

3. Leave it up to the plugins themselves to have setAway( foo ) not set them 
away if they are invisible and don't touch auto away at all. This would be a 
good fix but that still leaves you with the other bug that requires a 
setOnlineStatus in KopeteAccount

Comment 19 Olivier Goffart 2003-10-09 21:26:37 UTC
Jason, I read maybe wrong, but i think you don't know what you are talking about.  
please read again the kopete away code. 
 
Some presision: 
-by the KOS type, i mean the KOS::OnlineStatus  enum.  each KOS have one of that 
type that allow libkopete to handle status without to care to differences between 
protocols  
-the KOS for Invisible, like the KOS for Connecting, is only used by the account, 
contacts will not have this status 
-If an account is has a KOS with the type away, this status will not be modified when 
auto-away, nor activity detected. 
 
 
 
Le Jeudi 09 Octobre 2003 21:05, Jason Keirstead a 
Comment 20 Martijn Klingens 2003-10-10 12:43:39 UTC
Subject: Re: [Kopete-devel]   wrong change from invisible to active

On Thursday 09 October 2003 20:54, Olivier Goffart wrote:
> Now, for this bug, like i said, using the Away status for the invisible KOS
> is a good compromise until KDE 3.2:
> + It does not need api changes.
> + Since the invisible status is never used for contact, that's not a
>   metacontact status problem or so.
> + I don't think it will have side effect because it should act exactly like
>   the Busy status.
>
> anyway, we could imagine the Invisible/Hidden status.  For that, i would
> wait after KDE 3.2 because of side effect
>
> Martijn, is that ok for you?  after all, Invisible is about like busy....

Perfect.

The only problem I am somewhat afraid of is away-messages being sent by 
Kopete.

Comment 21 Olivier Goffart 2003-10-11 02:47:55 UTC
Subject: Re: [Kopete-devel]  wrong change from invisible to active

Le Vendredi 10 Octobre 2003 12:43, Martijn Klingens a 
Comment 22 Olivier Goffart 2003-10-11 20:37:18 UTC
Subject: kdenetwork/kopete/protocols/msn

CVS commit by ogoffart: 

Finaly use the away status for the invisible mode.
Effect: You will not become suddenly away and active after when auto-away

CCMAIL: 62427-done@bugs.kde.org


  M +2 -2      msnprotocol.cpp   1.246


--- kdenetwork/kopete/protocols/msn/msnprotocol.cpp  #1.245:1.246
@@ -47,5 +47,5 @@ MSNProtocol::MSNProtocol( QObject *paren
         LUN( KopeteOnlineStatus::Away,    15, this, 6, "msn_lunch",     i18n( "Set Out To &Lunch" ),  i18n( "Out to Lunch" ) ),
         FLN( KopeteOnlineStatus::Offline,  0, this, 7, QString::null,   i18n( "Go &Offline" ),        i18n( "Offline" ) ),
-        HDN( KopeteOnlineStatus::Online,   3, this, 8, "msn_invisible", i18n( "Set &Invisible" ),     i18n( "Invisible" ) ),
+        HDN( KopeteOnlineStatus::Away,     3, this, 8, "msn_invisible", i18n( "Set &Invisible" ),     i18n( "Invisible" ) ), //We use away because we don't want to see this state changed when autoaway.
         IDL( KopeteOnlineStatus::Away,    10, this, 9, "msn_away",      "FIXME: Make this unselectable", i18n( "Idle" ) ),
         UNK( KopeteOnlineStatus::Unknown, 25, this, 0, "status_unknown","FIXME: Make this unselectable", i18n( "Status not available" ) ),