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

List:       kde-commits
Subject:    extragear/network/konversation/src
From:       Eli MacKenzie <argonel () sympatico ! ca>
Date:       2009-09-20 22:39:12
Message-ID: 1253486352.484096.2292.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1026169 by argonel:

Work around bad values in konversationrc, and attempt to prevent it from
happening again by making the application object own the common queue
rates instead of using a global static.

BUG: 204970

 M  +44 -4     application.cpp  
 M  +8 -0      application.h  
 M  +1 -1      commit.h  
 M  +1 -11     irc/ircqueue.cpp  
 M  +7 -5      irc/ircqueue.h  
 M  +5 -36     irc/server.cpp  
 M  +1 -6      irc/server.h  
 M  +1 -1      queuetuner.cpp  


--- trunk/extragear/network/konversation/src/application.cpp #1026168:1026169
@@ -61,7 +61,7 @@
 Application::~Application()
 {
     kDebug();
-    Server::_stashRates();
+    stashQueueRates();
     Preferences::self()->writeConfig();
     saveOptions(false);
 
@@ -609,7 +609,7 @@
     KConfigGroup cgEncodings(KGlobal::config()->group("Encodings"));
     QMap<QString,QString> encodingEntries=cgEncodings.entryMap();
     QList<QString> encodingEntryKeys=encodingEntries.keys();
-    
+
     QRegExp reg("^(.+) ([^\\s]+) ([^\\s]+)$");
     for(QList<QString>::const_iterator itStr=encodingEntryKeys.constBegin(); itStr \
!= encodingEntryKeys.constEnd(); ++itStr)  {
@@ -622,8 +622,7 @@
         }
     }
 
-    // O, what a tangled web
-    Server::_fetchRates();
+    fetchQueueRates();
 
     updateProxySettings();
 }
@@ -838,6 +837,47 @@
         emit appearanceChanged();
 }
 
+void Application::fetchQueueRates()
+{
+    //The following rate was found in the rc for all queues, which were deliberately \
bad numbers chosen for debugging. +    //Its possible that the static array was \
constructed or deconstructed at the wrong time, and so those values saved +    //in \
the rc. When reading the values out of the rc, we must check to see if they're this \
specific value, +    //and if so, reset to defaults. --argonel
+    IRCQueue::EmptyingRate shit(6, 50000, IRCQueue::EmptyingRate::Lines);
+    int bad = 0;
+    for (int i=0; i <= countOfQueues(); i++)
+    {
+        QList<int> r = Preferences::self()->queueRate(i);
+        staticrates[i] = IRCQueue::EmptyingRate(r[0], r[1]*1000, \
IRCQueue::EmptyingRate::RateType(r[2])); +        if (staticrates[i] == shit)
+            bad++;
+    }
+    if (bad == 3)
+        resetQueueRates();
+}
+
+void Application::stashQueueRates()
+{
+    for (int i=0; i <= countOfQueues(); i++)
+    {
+        QList<int> r;
+        r.append(staticrates[i].m_rate);
+        r.append(staticrates[i].m_interval / 1000);
+        r.append(int(staticrates[i].m_type));
+        Preferences::self()->setQueueRate(i, r);
+    }
+}
+
+void Application::resetQueueRates()
+{
+    for (int i=0; i <= countOfQueues(); i++)
+    {
+        Preferences::self()->queueRateItem(i)->setDefault();
+        QList<int> r=Preferences::self()->queueRate(i);
+        staticrates[i]=IRCQueue::EmptyingRate(r[0], r[1]*1000, \
IRCQueue::EmptyingRate::RateType(r[2])); +    }
+}
+
 // FIXME: use KUrl maybe?
 void Application::storeUrl(const QString& who,const QString& newUrl)
 {
--- trunk/extragear/network/konversation/src/application.h #1026168:1026169
@@ -21,6 +21,7 @@
 #include "osd.h"
 #include "identity.h"
 #include "nickinfo.h"
+#include "ircqueue.h"
 
 #include <kuniqueapplication.h>
 
@@ -118,6 +119,8 @@
 
         Konversation::Sound* sound();
 
+        IRCQueue::EmptyingRate staticrates[Server::_QueueListSize];
+
         Images* images() { return m_images; }
 
         Konversation::NotificationHandler* notificationHandler() const { return \
m_notificationHandler; } @@ -141,6 +144,11 @@
         void readOptions();
         void saveOptions(bool updateGUI=true);
 
+        void fetchQueueRates(); ///< on Application::readOptions()
+        void stashQueueRates(); ///< on application exit
+        void resetQueueRates(); ///< when QueueTuner says to
+        int countOfQueues() { return Server::_QueueListSize-1; }
+
         void deleteUrl(const QString& who,const QString& url);
         void clearUrlList();
 
--- trunk/extragear/network/konversation/src/commit.h #1026168:1026169
@@ -1,4 +1,4 @@
 // This COMMIT number is added to version string to be used as "patch level"
 #ifndef COMMIT
-#define COMMIT 3437
+#define COMMIT 3438
 #endif
--- trunk/extragear/network/konversation/src/irc/ircqueue.cpp #1026168:1026169
@@ -4,7 +4,7 @@
     published by the Free Software Foundation; either version 2 of
     the License or (at your option) version 3 or any later version
     accepted by the membership of KDE e.V. (or its successor approved
-    by the membership of KDE e.V.), which shall act as a proxy 
+    by the membership of KDE e.V.), which shall act as a proxy
     defined in Section 14 of version 3 of the license.
 */
 
@@ -19,16 +19,6 @@
 
 #include "server.h"
 
-//#include "/home/ejm/argnl.h"
-
-IRCQueue::EmptyingRate staticrates[Server::Howmanyqueuesdoweneedanywayquestionmark]; \
                /*=
-    {
-        IRCQueue::EmptyingRate(6,60000)
-        ,IRCQueue::EmptyingRate(20,60000)
-        ,IRCQueue::EmptyingRate(1,1000)//,IRCQueue::EmptyingRate::Bytes)
-    };
-*/
-
 int IRCQueue::EmptyingRate::nextInterval(int, int elapsed)
 {
     if (!isValid())
--- trunk/extragear/network/konversation/src/irc/ircqueue.h #1026168:1026169
@@ -4,7 +4,7 @@
     published by the Free Software Foundation; either version 2 of
     the License or (at your option) version 3 or any later version
     accepted by the membership of KDE e.V. (or its successor approved
-    by the membership of KDE e.V.), which shall act as a proxy 
+    by the membership of KDE e.V.), which shall act as a proxy
     defined in Section 14 of version 3 of the license.
 */
 
@@ -56,7 +56,7 @@
 
     //FIXME wire this up
     //QTextCodec* codec;
-    //operator const char * () const { return codec->fromUnicode(text()); } 
+    //operator const char * () const { return codec->fromUnicode(text()); }
 
 };
 
@@ -78,7 +78,7 @@
             Lines, ///< Lines per interval.
             Bytes  ///< Bytes per interval. Not implemented. FIXME
         };
-        EmptyingRate(int rate=6, int msec_interval=50000, RateType type=Lines):
+        EmptyingRate(int rate=39, int msec_interval=59000, RateType type=Lines):
                 m_rate(rate), m_interval(msec_interval), m_type(type)
         {
         }
@@ -89,6 +89,10 @@
         int m_interval;
         RateType m_type;
         bool isValid()  { return m_rate > 0; }
+        bool operator==(const EmptyingRate& o)
+        {
+            return (m_rate == o.m_rate && m_interval == o.m_interval && m_type == \
o.m_type)? true : false; +        }
     };
 
     IRCQueue(Server *server, EmptyingRate& rate, int myindex=0);
@@ -140,6 +144,4 @@
     int m_myIndex;
 };
 
-extern IRCQueue::EmptyingRate staticrates[];
-
 #endif
--- trunk/extragear/network/konversation/src/irc/server.cpp #1026168:1026169
@@ -64,10 +64,10 @@
 
     m_connectionState = Konversation::SSNeverConnected;
 
-    for (int i=0;i<=_max_queue();i++)
+    for (int i=0; i <= Application::instance()->countOfQueues(); i++)
     {
         //QList<int> r=Preferences::queueRate(i);
-        IRCQueue *q=new IRCQueue(this, staticrates[i]); //FIXME these are supposed \
to be in the rc +        IRCQueue *q=new IRCQueue(this, \
Application::instance()->staticrates[i]); //FIXME these are supposed to be in the rc  \
m_queues.append(q);  }
 
@@ -221,37 +221,6 @@
     if (m_preShellCommand.state() == QProcess::NotRunning) \
preShellCommandExited(m_preShellCommand.exitCode(), m_preShellCommand.exitStatus());  \
}  
-void Server::_fetchRates()
-{
-    for (int i=0;i<=_max_queue();i++)
-    {
-        QList<int> r=Preferences::self()->queueRate(i);
-        staticrates[i]=IRCQueue::EmptyingRate(r[0], \
                r[1]*1000,IRCQueue::EmptyingRate::RateType(r[2]));
-    }
-}
-
-void Server::_stashRates()
-{
-    for (int i=0;i<=_max_queue();i++)
-    {
-        QList<int> r;
-        r.append(staticrates[i].m_rate);
-        r.append(staticrates[i].m_interval/1000);
-        r.append(int(staticrates[i].m_type));
-        Preferences::self()->setQueueRate(i, r);
-    }
-}
-
-void Server::_resetRates()
-{
-    for (int i=0;i<=_max_queue();i++)
-    {
-        Preferences::self()->queueRateItem(i)->setDefault();
-        QList<int> r=Preferences::self()->queueRate(i);
-        staticrates[i]=IRCQueue::EmptyingRate(r[0], \
                r[1]*1000,IRCQueue::EmptyingRate::RateType(r[2]));
-    }
-}
-
 void Server::initTimers()
 {
     m_notifyTimer.setObjectName("notify_timer");
@@ -1261,7 +1230,7 @@
 
 bool Server::validQueue(QueuePriority priority)
 {
-   if (priority >=0 && priority <= _max_queue())
+   if (priority >=0 && priority <= Application::instance()->countOfQueues())
        return true;
    return false;
 }
@@ -1295,7 +1264,7 @@
 
 void Server::resetQueues()
 {
-    for (int i=0;i<=_max_queue();i++)
+    for (int i=0; i <= Application::instance()->countOfQueues(); i++)
         m_queues[i]->reset();
 }
 
@@ -1307,7 +1276,7 @@
     {
         cue=-1;
         int wait=0;
-        for (int i=1;i<=_max_queue();i++) //slow queue can rot
+        for (int i=1; i <= Application::instance()->countOfQueues(); i++) //slow \
queue can rot  {
             IRCQueue *queue=m_queues[i];
             //higher queue indices have higher priorty, higher queue priority wins \
                tie
--- trunk/extragear/network/konversation/src/irc/server.h #1026168:1026169
@@ -77,7 +77,7 @@
             StandardPriority, ///<regular queue, for chat and user initiated \
commands  HighPriority,     ///<for pongs and quits
 
-            Howmanyqueuesdoweneedanywayquestionmark,
+            _QueueListSize,
 
             HiPriority=HighPriority,
             LoPriority=LowPriority,
@@ -357,7 +357,6 @@
     // IRCQueueManager
         bool validQueue(QueuePriority priority); ///< is this queue index valid?
         void resetQueues(); ///< Tell all of the queues to reset
-        static int _max_queue() { return Howmanyqueuesdoweneedanywayquestionmark-1; \
}  
         /** Forces the queued data to be sent in sequence of age, without pause.
 
@@ -369,11 +368,7 @@
         void flushQueues();
 
         //These are really only here to limit where ircqueue.h is included
-        static void _fetchRates(); ///< on Application::readOptions()
-        static void _stashRates(); ///< on application exit
-        static void _resetRates(); ///< when QueueTuner says to
 
-
     signals:
         void destroyed(int connectionId);
         void nicknameChanged(const QString&);
--- trunk/extragear/network/konversation/src/queuetuner.cpp #1026168:1026169
@@ -247,7 +247,7 @@
         int x = KMessageBox::warningContinueCancel(this, question, i18n("Reset \
Values"), KStandardGuiItem::reset(), KGuiItem(), QString(), KMessageBox::Dangerous);  \
if ( x == KMessageBox::Continue)  {
-            Server::_resetRates();
+            Application::instance()->resetQueueRates();
             getRates();
         }
     }


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

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