Bug 95419 - Implement auto-away and auto-return
Summary: Implement auto-away and auto-return
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: 0.15
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Eike Hein
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-18 22:54 UTC by _
Modified: 2024-11-12 18:08 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 _ 2004-12-18 22:54:40 UTC
Version:           0.15 (using KDE KDE 3.3.1)
Installed from:    Compiled From Sources
Compiler:          gcc 3.3.4 
OS:                Linux

1. Feature to send /me messages for away
2. Feature to set auto-away after n minutes
3. Set konversation away when locking KDE, like kopete does.
Comment 1 John Tapsell 2004-12-19 17:01:02 UTC
> 1. Feature to send /me messages for away

Already possible.  See File->Identies under Away.  It's a bit obscure I 
admit :\

> 2. Feature to set auto-away after n minutes
This is possibly the same as number 3.  lock when screensaver comes on.

> 3. Set konversation away when locking KDE, like kopete does.
I have implemented this just now.  will commit after testing.

Comment 2 John Tapsell 2004-12-19 20:07:29 UTC
CVS commit by johnflux: 

Add infrastructure needed to support auto-away.
CCBUG:95419


  M +17 -0     konvdcop.cpp   1.35
  M +2 -0      konvdcop.h   1.27
  M +15 -1     konversationapplication.cpp   1.211
  M +1 -0      konversationapplication.h   1.54
  M +1 -0      konviface.h   1.28
  M +6 -1      server.cpp   1.404
  M +8 -0      server.h   1.189



Comment 3 John Tapsell 2005-01-04 12:05:30 UTC
Update for this..

The problem isn't auto-away, the problem is coming back online.  What needs to be done is to copy the code from kopete (or elsewhere - cartman has his own preferences) to detect when the mouse has moved.  I really wish there was a better way to know when they are back online.

Comment 4 Ismail Donmez 2005-01-04 12:10:41 UTC
> ------- Additional Comments From johnflux hotmail com  2005-01-04 12:05
> ------- Update for this..
>
> The problem isn't auto-away, the problem is coming back online.  What needs
> to be done is to copy the code from kopete (or elsewhere - cartman has his
> own preferences) to detect when the mouse has moved.

Feel free to use Kopete's code as I am busy with other stuff now. We can 
enhance it later.

Comment 5 _ 2005-01-08 12:35:15 UTC
Doesn't KDE have something like this built in, to e.g. activate the screensaver and such? Kopete sets me away when I lock my session, too.
Comment 6 Andreas Loibl 2006-06-04 15:20:11 UTC
*** This bug has been confirmed by popular vote. ***
Comment 7 Eike Hein 2006-11-19 16:35:00 UTC
I'm comitting to implementing per-identity configurable auto-away triggered by n minutes of inactivity or screensaver activation with optional return on activity for the next release, which will be Konversation 1.1 in early 2007. Assigning.
Comment 8 Eike Hein 2008-06-01 13:22:29 UTC
Implemented as of SVN revision 814915.
Comment 9 John Tapsell 2010-07-01 15:53:26 UTC
commit 08458611e504ab107ca65a11dac127b54b54a00d
Author: John Tapsell <john.tapsell@kdemail.net>
Date:   Sun Dec 19 19:07:24 2004 +0000

    Add infrastructure needed to support auto-away.
    CCBUG:95419
    
    svn path=/trunk/kdeextragear-2/konversation/; revision=372006

diff --git a/konversation/konvdcop.cpp b/konversation/konvdcop.cpp
index 282d0d0..b423e72 100644
--- a/konversation/konvdcop.cpp
+++ b/konversation/konvdcop.cpp
@@ -36,6 +36,19 @@ KonvDCOP::KonvDCOP()
     kapp->dcopClient()->registerAs("konversation");
     kapp->dcopClient()->setDefaultObject(objId());
   }
+  KConfig *config = KGlobal::config();
+  config->setGroup("AutoAway");  //TODO - add this to preferences somewhere
+
+  if (config->readBoolEntry("UseAutoAway", true))
+  {
+    connectDCOPSignal("kdesktop", "KScreensaverIface",
+                      "KDE_start_screensaver()", "setAutoAway()", false);
+  }
+  else
+  {
+    disconnectDCOPSignal("kdesktop", "KScreensaverIface",
+    "KDE_start_screensaver()", "setAutoAway()");
+  }
 }
 
 void KonvDCOP::raw(const QString& server,const QString& command)
@@ -52,6 +65,10 @@ void KonvDCOP::setAway(const QString &awaymessage)
   else
     emit dcopMultiServerRaw("away " + awaymessage);
 }
+void KonvDCOP::setAutoAway()
+{
+  emit setAutoAway();
+}
 void KonvDCOP::setBack()
 {
   emit dcopMultiServerRaw("away");
diff --git a/konversation/konvdcop.h b/konversation/konvdcop.h
index 409b714..e5e5632 100644
--- a/konversation/konvdcop.h
+++ b/konversation/konvdcop.h
@@ -26,12 +26,14 @@ class KonvDCOP : public QObject, virtual public KonvIface
     void dcopConnectToServer(const QString& url, int port, const QString& channel, const QString& password);
     void dcopRaw(const QString& server, const QString& command);
     void dcopMultiServerRaw(const QString& command);
+    void dcopSetAutoAway();
 
   public slots:
     int registerEventHook(const QString& type,const QString& criteria,const QString& app,const QString& object,const QString& signal);
     void unregisterEventHook (int id);
 
     void setAway(const QString &awaymessage);
+    void setAutoAway();
     void setBack();
     void sayToAll(const QString &message);
     void actionToAll(const QString &message);
diff --git a/konversation/konversationapplication.cpp b/konversation/konversationapplication.cpp
index 5ea0b7b..92d3887 100644
--- a/konversation/konversationapplication.cpp
+++ b/konversation/konversationapplication.cpp
@@ -128,7 +128,9 @@ KonversationApplication::KonversationApplication()
     connect(dcopObject,SIGNAL (dcopInfo(const QString&)),
                     this,SLOT (dcopInfo(const QString&)) );
     connect(dcopObject,SIGNAL (dcopInsertRememberLine()),
-                    this,SLOT(insertRememberLine()));
+                    this,SLOT (insertRememberLine()));
+    connect(dcopObject,SIGNAL (dcopSetAutoAway()),
+                    this,SLOT (setAutoAway()));
     connect(dcopObject,SIGNAL(dcopConnectToServer(const QString&, int,const QString&, const QString&)),
 	    this,SLOT(dcopConnectToServer(const QString&, int,const QString&, const QString&)));
   }
@@ -158,6 +160,18 @@ KonversationMainWindow *KonversationApplication::getMainWindow() {
   return mainWindow;
 }
 
+void KonversationApplication::setAutoAway()
+{
+  Server* lookServer=serverList.first();
+  while(lookServer)
+  {
+    if(!lookServer->isAway()) {
+      lookServer->setAutoAway();
+    }
+    lookServer=serverList.next();
+  }
+ 
+}
 void KonversationApplication::toggleAway()
 {
   kdDebug() << "toggleAway()" << endl;
diff --git a/konversation/konversationapplication.h b/konversation/konversationapplication.h
index ca9b5e7..a519e74 100644
--- a/konversation/konversationapplication.h
+++ b/konversation/konversationapplication.h
@@ -147,6 +147,7 @@ class KonversationApplication : public KApplication
     void dcopRaw(const QString& server, const QString &command);
     void dcopSay(const QString& server,const QString& target,const QString& command);
     void dcopInfo(const QString& string);
+    void setAutoAway();
     void insertRememberLine();
     void appearanceChanged();
     void sendMultiServerCommand(const QString& command, const QString& parameter);
diff --git a/konversation/konviface.h b/konversation/konviface.h
index 828cc66..258c763 100644
--- a/konversation/konviface.h
+++ b/konversation/konviface.h
@@ -14,6 +14,7 @@ class KonvIface : virtual public DCOPObject
 
   k_dcop:
     virtual void setAway(const QString &awaymessage) = 0;
+    virtual void setAutoAway() = 0;
     virtual void setBack() = 0;
     virtual void sayToAll(const QString &message) = 0;
     virtual void actionToAll(const QString &message) = 0;
diff --git a/konversation/server.cpp b/konversation/server.cpp
index 6486dd4..c7826bf 100644
--- a/konversation/server.cpp
+++ b/konversation/server.cpp
@@ -2849,7 +2849,12 @@ void Server::away()
   }
   
 }
-
+void Server::setAutoAway() {
+  kdDebug() << "going autoaway!" << endl;
+  m_isAutoAway = true;
+  //note that we now need to tell the server we are away.  m_isAway is set when we get a reply from the server saying we are now away.
+  executeMultiServerCommand("away", i18n("Gone away for now.")); //fix this to use a prefered auto-away string.
+}
 void Server::unAway()
 {
   m_isAway=false;
diff --git a/konversation/server.h b/konversation/server.h
index e0f08e6..aacfb97 100644
--- a/konversation/server.h
+++ b/konversation/server.h
@@ -281,7 +281,14 @@ class Server : public QObject
      *  If we are not away, returns 00:00:00
      */
     QString awayTime() const;
+    /** Does the _server_ think we are away.  Note that if we went auto-away when not connected to the server, this may
+     *  return false.
+     */
     bool isAway() const;
+    /** Put the server in autoaway.  This means that when there is mouse activity, we will set to available again
+     *  @see isAway
+     */
+    void setAutoAway();
 
     void emitChannelNickChanged(const ChannelNickPtr channelNick);
     void emitNickInfoChanged(const NickInfoPtr nickInfo);
@@ -584,6 +591,7 @@ class Server : public QObject
     ChannelListPanel* channelListPanel;
 
     bool m_isAway;
+    bool m_isAutoAway; ///Note that this may be true, but m_isAway is false, if we go auto-away when disconnected.
     bool alreadyConnected;
     bool rejoinChannels;
     bool sendUnlocked;
Comment 10 Christoph Cullmann 2024-11-12 18:08:07 UTC
*** Bug 496180 has been marked as a duplicate of this bug. ***