[Kita-svn] [2486] don't set functions static

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 7月 29日 (水) 18:10:42 JST


Revision: 2486
          http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2486
Author:   nogu
Date:     2009-07-29 18:10:42 +0900 (Wed, 29 Jul 2009)

Log Message:
-----------
don't set functions static

Modified Paths:
--------------
    kita/branches/KITA-KDE4/kita/src/libkita/access.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/boardmanager.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/cache.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/cache.h
    kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/threadindex.cpp

Modified: kita/branches/KITA-KDE4/kita/src/libkita/access.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/access.cpp	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/access.cpp	2009-07-29 09:10:42 UTC (rev 2486)
@@ -50,7 +50,8 @@
     QByteArray orgData;
 
     // get cache path.
-    QString cachePath = Cache::getPath(m_datURL);
+    Cache cache(m_datURL);
+    QString cachePath = cache.getPath();
     if (cachePath.isEmpty()) {
         return;
     }
@@ -94,7 +95,8 @@
 
     m_dataSize += m_threadData.length();
 
-    QString cachePath = Cache::getPath(m_datURL);
+    Cache cache(m_datURL);
+    QString cachePath = cache.getPath();
     if (!cachePath.isEmpty()) {
         FILE * fs = fopen(QFile::encodeName(cachePath), "a");
         if (!fs) return ;

Modified: kita/branches/KITA-KDE4/kita/src/libkita/boardmanager.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/boardmanager.cpp	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/boardmanager.cpp	2009-07-29 09:10:42 UTC (rev 2486)
@@ -458,14 +458,16 @@
     if (online) {
 
         /* make directory */
-        QString cacheDir = Cache::baseDir() + Cache::serverDir(url) + Cache::boardDir(url);
-        if (!mkdir(cacheDir)) return ;
+        Cache cache(url);
+        QString cacheDir
+            = Cache::baseDir() + cache.serverDir() + cache.boardDir();
+        if (!mkdir(cacheDir)) return;
 
         KIO::SlaveConfig::self() ->setConfigData("http",
                 url.host() ,
                 "UserAgent",
                 QString("Monazilla/1.00 (Kita/%1)").arg("0.200.0"));
-        QString subjectPath = Cache::getSubjectPath(url);
+        QString subjectPath = cache.getSubjectPath();
         KIO::NetAccess::download(subjectURL(url), subjectPath, 0);
     }
 
@@ -490,7 +492,8 @@
 /* read the cache dir & get the list of all threads. */ /* private */ /* static */
 void BoardManager::getCachedThreadList(const KUrl& url, QList<Thread*>& threadList)
 {
-    QString cacheDir = Cache::baseDir() + Cache::serverDir(url) + Cache::boardDir(url);
+    Cache cache(url);
+    QString cacheDir = Cache::baseDir() + cache.serverDir() + cache.boardDir();
     QDir d(cacheDir);
     if (d.exists()) {
 
@@ -527,8 +530,9 @@
     /* get all names of cached files to read idx.  */
     QStringList cacheList;
     if (!bdata->readIdx()) {
-
-        QString cacheDir = Cache::baseDir() + Cache::serverDir(url) + Cache::boardDir(url);
+        Cache cache(url);
+        QString cacheDir
+            = Cache::baseDir() + cache.serverDir() + cache.boardDir();
         QDir d(cacheDir);
         if (d.exists()) {
             QString ext = BoardManager::getBoardData(url) ->ext();
@@ -538,7 +542,8 @@
     }
 
     /* open subject.txt */
-    QString subjectPath = Cache::getSubjectPath(url);
+    Cache cache(url);
+    QString subjectPath = cache.getSubjectPath();
     QIODevice * device = KFilterDev::deviceForFile(subjectPath, "application/x-gzip");
     if (!device->open(QIODevice::ReadOnly)) return false;
 
@@ -825,7 +830,8 @@
 
     QStringList keyHosts(bdata->hostName());
 
-    QFile file(Cache::getBBSHistoryPath(url));
+    Cache cache(url);
+    QFile file(cache.getBBSHistoryPath());
     if (file.open(QIODevice::ReadOnly)) {
 
         QTextStream ts(&file);
@@ -882,8 +888,9 @@
     keyHosts.removeOne(oldhost);
     keyHosts.prepend(oldhost);
     bdata->createKeys(keyHosts);
-    QString oldCachePath = Cache::baseDir() + Cache::serverDir(bdata->basePath())
-                           + Cache::boardDir(bdata->basePath());
+    Cache cache(bdata->basePath());
+    QString oldCachePath = Cache::baseDir() + cache.serverDir()
+                           + cache.boardDir();
 
     /* update URL */
     bdata->setHostName(newhost);
@@ -916,11 +923,12 @@
     if (! qdir.exists(oldCachePath)) return true;
 
     /* mkdir new server dir */
-    QString newCachePath = Cache::baseDir() + Cache::serverDir(bdata->basePath());
+    Cache newCache(bdata->basePath());
+    QString newCachePath = Cache::baseDir() + newCache.serverDir();
     mkdir(newCachePath);
 
     /* backup old dir */
-    newCachePath += Cache::boardDir(bdata->basePath());
+    newCachePath += newCache.boardDir();
     if (qdir.exists (newCachePath)) {
         QString bkupPath = newCachePath;
         bkupPath.truncate(bkupPath.length() - 1); /* remove '/' */
@@ -949,7 +957,8 @@
     /*---------------------------*/
     /* update BBSHISTRY */
 
-    QFile file(Cache::getBBSHistoryPath(bdata->basePath()));
+    Cache historyCache(bdata->basePath());
+    QFile file(historyCache.getBBSHistoryPath());
     if (file.open(QIODevice::WriteOnly)) {
 
         QTextStream ts(&file);

Modified: kita/branches/KITA-KDE4/kita/src/libkita/cache.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/cache.cpp	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/cache.cpp	2009-07-29 09:10:42 UTC (rev 2486)
@@ -11,12 +11,15 @@
 
 #include <kglobal.h>
 #include <kstandarddirs.h>
-#include <kurl.h>
 
 #include "boardmanager.h"
 
 using namespace Kita;
 
+Cache::Cache(const KUrl& url) : m_url(url)
+{
+}
+
 QString Cache::baseDir()
 {
     QString dir = KGlobal::dirs() ->saveLocation("cache", "kita");
@@ -27,10 +30,10 @@
 }
 
 
-QString Cache::serverDir(const KUrl& url)
+QString Cache::serverDir()
 {
     /* Is board enrolled ? */
-    BoardData * bdata = BoardManager::getBoardData(url);
+    BoardData * bdata = BoardManager::getBoardData(m_url);
     if (bdata == 0) return QString();
 
     QString root = bdata->hostName() + bdata->rootPath();
@@ -39,10 +42,10 @@
 }
 
 
-QString Cache::boardDir(const KUrl& url)
+QString Cache::boardDir()
 {
     /* Is board enrolled ? */
-    BoardData * bdata = BoardManager::getBoardData(url);
+    BoardData * bdata = BoardManager::getBoardData(m_url);
     if (bdata == 0) return QString();
 
     QString bbs = bdata->bbsPath();
@@ -51,19 +54,19 @@
 }
 
 
-QString Cache::getPath(const KUrl& url)
+QString Cache::getPath()
 {
-    QString path = baseDir() + serverDir(url) + boardDir(url);
+    QString path = baseDir() + serverDir() + boardDir();
     if (path.isEmpty()) return QString();
 
     //    qDebug("%s -> %s",url.prettyUrl().ascii(),path.ascii());
 
-    return path + url.fileName();
+    return path + m_url.fileName();
 }
 
-QString Cache::getIndexPath(const KUrl& url)
+QString Cache::getIndexPath()
 {
-    QString path = getPath(url);
+    QString path = getPath();
     if (path.isEmpty()) {
         return QString();
     } else {
@@ -77,27 +80,27 @@
 
 
 /* public */
-QString Cache::getSettingPath(const KUrl& url)
+QString Cache::getSettingPath()
 {
-    QString path = baseDir() + serverDir(url) + boardDir(url);
+    QString path = baseDir() + serverDir() + boardDir();
     if (path.isEmpty()) return QString();
 
     return path + "SETTING.TXT";
 }
 
 /* public */
-QString Cache::getBBSHistoryPath(const KUrl& url)
+QString Cache::getBBSHistoryPath()
 {
-    QString path = baseDir() + serverDir(url) + boardDir(url);
+    QString path = baseDir() + serverDir() + boardDir();
     if (path.isEmpty()) return QString();
 
     return path + "BBSHISTORY";
 }
 
 /* public */
-QString Cache::getSubjectPath(const KUrl& url)
+QString Cache::getSubjectPath()
 {
-    QString path = baseDir() + serverDir(url) + boardDir(url);
+    QString path = baseDir() + serverDir() + boardDir();
     if (path.isEmpty()) return QString();
 
     return path + "subject.txt";

Modified: kita/branches/KITA-KDE4/kita/src/libkita/cache.h
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/cache.h	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/cache.h	2009-07-29 09:10:42 UTC (rev 2486)
@@ -12,7 +12,7 @@
 
 #include <QtCore/QString>
 
-class KUrl;
+#include <kurl.h>
 
 namespace Kita
 {
@@ -22,18 +22,23 @@
     */
     class Cache
     {
-    public:
-        static QString baseDir();
-        static QString serverDir(const KUrl& url);
-        static QString boardDir(const KUrl& url);
+        public:
+            Cache(const KUrl& url);
 
-        static QString getPath(const KUrl& url);
-        static QString getIndexPath(const KUrl& url);
-        static QString getSettingPath(const KUrl& url);
-        static QString getBBSHistoryPath(const KUrl& url);
-        static QString getSubjectPath(const KUrl& url);
+            QString serverDir();
+            QString boardDir();
+
+            QString getPath();
+            QString getIndexPath();
+            QString getSettingPath();
+            QString getBBSHistoryPath();
+            QString getSubjectPath();
+
+            static QString baseDir();
+
+        private:
+            KUrl m_url;
     };
-
 }
 
 #endif

Modified: kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/datinfo.cpp	2009-07-29 09:10:42 UTC (rev 2486)
@@ -61,7 +61,8 @@
     m_framestr3 = utf8ToUnicode(KITAUTF8_FRAME3); /* L  */
 
     /* make directory */
-    QString cacheDir = Cache::baseDir() + Cache::serverDir(m_datURL) + Cache::boardDir(m_datURL);
+    Cache cache(m_datURL);
+    QString cacheDir = Cache::baseDir() + cache.serverDir() + cache.boardDir();
     if (!mkdir(cacheDir)) return ;
 
     initPrivate(

Modified: kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/datmanager.cpp	2009-07-29 09:10:42 UTC (rev 2486)
@@ -210,8 +210,9 @@
     thread->setViewPos(0);
 
     /* delete cache */
-    QString cachePath = Cache::getPath(datURL);
-    QString indexPath = Cache::getIndexPath(datURL);
+    Cache cache(datURL);
+    QString cachePath = cache.getPath();
+    QString indexPath = cache.getIndexPath();
     QFile::remove(indexPath);
     QFile::remove(cachePath);
 
@@ -316,12 +317,12 @@
 
 const QString DatManager::getCachePath(const KUrl& url)
 {
-    return Cache::getPath(url);
+    return Cache(url).getPath();
 }
 
 const QString DatManager::getCacheIndexPath(const KUrl& url)
 {
-    return Cache::getIndexPath(url);
+    return Cache(url).getIndexPath();
 }
 
 /*---------------------------------------*/

Modified: kita/branches/KITA-KDE4/kita/src/libkita/threadindex.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/threadindex.cpp	2009-07-27 13:33:00 UTC (rev 2485)
+++ kita/branches/KITA-KDE4/kita/src/libkita/threadindex.cpp	2009-07-29 09:10:42 UTC (rev 2486)
@@ -25,63 +25,72 @@
 
 QString ThreadIndex::getSubject(const KUrl& url)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     return getSubjectPrivate(config);
 }
 
 void ThreadIndex::setSubject(const KUrl& url, const QString& str)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     setSubjectPrivate(str, config);
 }
 
 int ThreadIndex::getResNum(const KUrl& url)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     return getResNumPrivate(url, config);
 }
 
 void ThreadIndex::setResNum(const KUrl& url, int resNum)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     setResNumPrivate(resNum, config);
 }
 
 int ThreadIndex::getReadNum(const KUrl& url)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     return getReadNumPrivate(url, config, true);
 }
 
 void ThreadIndex::setReadNum(const KUrl& url, int readNum)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     setReadNumPrivate(readNum, config);
 }
 
 int ThreadIndex::getViewPos(const KUrl& url)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     return getViewPosPrivate(config);
 }
 
 void ThreadIndex::setViewPos(const KUrl& url, int viewPos)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     setViewPosPrivate(viewPos, config);
 }
 
 void ThreadIndex::setMarkList(const KUrl& url, const QList<int>& markList)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
     setMarkListPrivate(markList, config);
 }
@@ -93,7 +102,8 @@
 /* load thread information */  /* public */ /* static */
 void ThreadIndex::loadIndex(Thread* thread, const KUrl& url, bool checkCached)
 {
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
 
     /* load read number */
@@ -134,7 +144,8 @@
         QFile::remove(indexPath);
     }
 
-    QString indexPath = Cache::getIndexPath(url);
+    Cache cache(url);
+    QString indexPath = cache.getIndexPath();
     KConfig config(indexPath);
 
     /* save thread name */




Kita-svn メーリングリストの案内
Back to archive index