[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Konversation] f7d5d91: Implement away timer
From:       Peter Simonsson <peter.simonsson () gmail ! com>
Date:       2010-07-01 13:27:33
Message-ID: 20100701132733.43234BB563E () projects ! kde ! org
[Download RAW message or body]

commit f7d5d915da158785b7a6a1cc4c566737b742581d
Author: Peter Simonsson <peter.simonsson@gmail.com>
Date:   Fri Jun 18 15:05:10 2004 +0000

    Implement away timer
    
    svn path=/trunk/kdeextragear-2/konversation/; revision=321717

diff --git a/ChangeLog b/ChangeLog
index 87e78cf..c43cff2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 Changes from 0.13 to 0.14
+- Measure away time and make it available via placeholder (%t)
 - (Very much) Improved OSD.
 - New application icons by luciash d' being <luci@sh.ground.cz>. Thanks!
 - Added /server command for connecting to a server.
diff --git a/TODO b/TODO
index 23dabf8..a75a367 100644
--- a/TODO
+++ b/TODO
@@ -11,7 +11,6 @@ SHORT-TERM (URGENT):
 - /WHOWAS after /WHOIS if /WHOIS returns unknown nickname
 - Add ETA counter for DCC transfers
 - Show / Hide tab types (status tabs ect.)
-- Measure away time and make it available via placeholder
 - Support "CTCP-DCC reply from <nickname>: REJECT SEND <filename> <reason>"
 
 MID-TERM:
diff --git a/konversation/inputfilter.cpp b/konversation/inputfilter.cpp
index 931a44f..e326e38 100644
--- a/konversation/inputfilter.cpp
+++ b/konversation/inputfilter.cpp
@@ -1254,6 +1254,7 @@ void InputFilter::parseServerCommand(const QString &prefix, \
const QString &comma  }
       case RPL_NOWAWAY:
         {
+          server->startAwayTimer();
           server->appendStatusMessage(i18n("Away"),i18n("You are now marked as being \
away."));  emit away();
 
@@ -1261,6 +1262,13 @@ void InputFilter::parseServerCommand(const QString &prefix, \
const QString &comma  }
       case RPL_UNAWAY:
         {
+          Identity identity = *(server->getIdentity());
+          
+          if(identity.getShowAwayMessage()) {
+            QString message = identity.getReturnMessage();
+            server->sendToAllChannels(message.replace(QRegExp("%t", false), \
server->awayTime())); +          }
+          
           server->appendStatusMessage(i18n("Away"),i18n("You are no longer marked as \
being away."));  emit unAway();
 
diff --git a/konversation/outputfilter.cpp b/konversation/outputfilter.cpp
index 741455c..b3512db 100644
--- a/konversation/outputfilter.cpp
+++ b/konversation/outputfilter.cpp
@@ -363,9 +363,6 @@ void OutputFilter::parseAway(const QString &reason)
 {
   if(reason.isEmpty())
   {
-    if(identity.getShowAwayMessage())
-      emit sendToAllChannels(identity.getReturnMessage());
-
     toServer="AWAY";
   }
   else
diff --git a/konversation/server.cpp b/konversation/server.cpp
index cc5c880..9582b8f 100644
--- a/konversation/server.cpp
+++ b/konversation/server.cpp
@@ -27,6 +27,7 @@ typedef unsigned long long __u64;
 #include <qregexp.h>
 #include <qhostaddress.h>
 #include <qtextcodec.h>
+#include <qdatetime.h>
 
 #include <kapp.h>
 #include <klocale.h>
@@ -72,6 +73,7 @@ Server::Server(KonversationMainWindow* newMainWindow,int id)
   alreadyConnected=false;
   rejoinChannels=false;
   connecting=false;
+  isAway = false;
 
   timerInterval=1;  // flood protection
 
@@ -2691,4 +2693,45 @@ void Server::connectToNewServer(const QString& server, const \
QString& port, cons  konvApp->quickConnectToServer(server, port, \
KonversationApplication::preferences.getNickname(0), password);  }
 
+QString Server::awayTime()
+{
+  QString retVal;
+  
+  if(isAway) {
+    int diff = QDateTime::currentDateTime().toTime_t() - m_awayTime;
+    int num = diff / 3600;
+    
+    if(num < 10) {
+      retVal = "0" + QString::number(num) + ":";
+    } else {
+      retVal = QString::number(num) + ":";
+    }
+    
+    num = (diff % 3600) / 60;
+    
+    if(num < 10) {
+      retVal += "0";
+    }
+    
+    retVal += QString::number(num) + ":";
+    
+    num = (diff % 3600) % 60;
+    
+    if(num < 10) {
+      retVal += "0";
+    }
+    
+    retVal += QString::number(num);
+  } else {
+    retVal = "00:00:00";
+  }
+  
+  return retVal;
+}
+
+void Server::startAwayTimer()
+{
+  m_awayTime = QDateTime::currentDateTime().toTime_t();
+}
+
 #include "server.moc"
diff --git a/konversation/server.h b/konversation/server.h
index afa41b5..4143e24 100644
--- a/konversation/server.h
+++ b/konversation/server.h
@@ -16,7 +16,6 @@
 #define SERVER_H
 
 #include <qtimer.h>
-#include <qdatetime.h>
 #include <qdict.h>
 #include <ksharedptr.h>
 
@@ -218,6 +217,8 @@ class Server : public QObject
     const NickInfoMap* getNicksOnline();
     // Returns a list of the nicks on the watch list that are offline.
     const NickInfoMap* getNicksOffline();
+    
+    QString awayTime();
 
   signals:
     void nicknameChanged(const QString&);
@@ -283,6 +284,9 @@ class Server : public QObject
     void executeMultiServerCommand(const QString& command, const QString& \
parameter);  void reconnect();
     void connectToNewServer(const QString& server, const QString& port, const \
QString& password); +    
+    void startAwayTimer();
+    void sendToAllChannels(const QString& text);
 
   protected slots:
     void ircServerConnectionSuccess();
@@ -308,7 +312,6 @@ class Server : public QObject
     void dccStatusChanged(const DccTransfer* item);
     void away();
     void unAway();
-    void sendToAllChannels(const QString& text);
     void scriptNotFound(const QString& name);
     void scriptExecutionError(const QString& name);
     void userhost(const QString& nick,const QString& hostmask,bool away,bool ircOp);
@@ -425,7 +428,6 @@ class Server : public QObject
     RawLog* rawLog;
     ChannelListPanel* channelListPanel;
 
-    QDateTime awayTime;
     bool isAway;
     bool alreadyConnected;
     bool rejoinChannels;
@@ -448,6 +450,8 @@ class Server : public QObject
     NickInfoMap nicknamesOffline;
     // List of nicks in Queries.
     NickInfoMap queryNicks;
+    
+    int m_awayTime;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic