OSDN Git Service

Use `//' style comments
[kita/kita.git] / src / libkita / boarddatabase.cpp
index 081f2c2..6e0e002 100644 (file)
@@ -86,7 +86,7 @@ QString BoardDatabase::ext()
 QString BoardDatabase::boardId()
 {
     BoardData * bdata = getBoardData();
-    return (bdata == 0) ? QString() : bdata->bbsPath().mid(1); /* remove "/" */
+    return (bdata == 0) ? QString() : bdata->bbsPath().mid(1); // remove "/"
 }
 
 /* (hostname)/(rootPath)/(bbsPath)/subject.txt */ /* public */
@@ -140,12 +140,12 @@ void BoardDatabase::getThreadList(
     threadList.clear();
     oldLogList.clear();
 
-    /* get all obtained threads list from cache */
+    // get all obtained threads list from cache
     if (m_url.prettyUrl() == "http://virtual/obtained/") {
 
         QStringList bbslist = allBoardUrlList();
 
-        /* search all cache dirs */
+        // search all cache dirs
         QString thread;
         foreach (thread, bbslist) {
             getCachedThreadList(thread, threadList);
@@ -154,15 +154,15 @@ void BoardDatabase::getThreadList(
         return ;
     }
 
-    /*-------------------------*/
+    //-------------------------
 
     BoardData* bdata = getBoardData();
     if (bdata == 0) return ;
 
-    /* download subject.txt */
+    // download subject.txt
     if (online) {
 
-        /* make directory */
+        // make directory
         Cache cache(m_url);
         QString cacheDir = cache.getDirPath();
         if (!QDir::root().mkpath(cacheDir)) return;
@@ -175,10 +175,10 @@ void BoardDatabase::getThreadList(
         KIO::NetAccess::download(subjectUrl(), subjectPath, 0);
     }
 
-    /* open and read subject.txt */
+    // open and read subject.txt
     readSubjectTxt(bdata, threadList);
 
-    /* get old logs */
+    // get old logs
     if (oldLogs) {
 
         QList<Thread*> tmpList;
@@ -201,7 +201,7 @@ void BoardDatabase::getCachedThreadList(const KUrl& url,
     QDir d(cacheDir);
     if (d.exists()) {
 
-        /* get all file names */
+        // get all file names
         QString ext = getBoardData(url)->ext();
         QString boardUrl = getBoardData(url)->basePath();
         QStringList filter('*' + ext);
@@ -212,7 +212,7 @@ void BoardDatabase::getCachedThreadList(const KUrl& url,
 
             QString datUrl = boardUrl + "dat/" + file;
 
-            /* read idx file */
+            // read idx file
             Thread* thread = Thread::getByUrlNew(datUrl);
             if (thread == 0) {
 
@@ -232,7 +232,7 @@ void BoardDatabase::getCachedThreadList(const KUrl& url,
 /* open subject.txt and get list of Thread classes */ /* private */
 bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
 {
-    /* get all names of cached files to read idx.  */
+    // get all names of cached files to read idx.
     QStringList cacheList;
     if (!bdata->readIdx()) {
         Cache cache(m_url);
@@ -245,7 +245,7 @@ bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
         }
     }
 
-    /* open subject.txt */
+    // open subject.txt
     Cache cache(m_url);
     QString subjectPath = cache.getSubjectPath();
     QIODevice * device = KFilterDev::deviceForFile(subjectPath, "application/x-gzip");
@@ -283,7 +283,7 @@ bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
             QString subject = regexp.cap(2);
             QString num = regexp.cap(3);
 
-            /* get pointer of Thread class */
+            // get pointer of Thread class
             QString datUrl = boardUrl() + "dat/" + fname;
             Thread* thread = Thread::getByUrl(datUrl);
             ThreadIndex threadIndex(datUrl);
@@ -291,10 +291,10 @@ bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
                 threadList.append(thread);
             }
 
-            /* set thread name */
+            // set thread name
             thread->setThreadName(subject);
 
-            /* load index file */
+            // load index file
             if (!bdata->readIdx()) {
 
                 if (cacheList.contains(fname)) {
@@ -302,9 +302,9 @@ bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
                 }
             }
 
-            /* update res num */
+            // update res num
             int newNum = num.toInt();
-            if (thread->readNum()) { /* cache exists */
+            if (thread->readNum()) { // cache exists
                 int oldNum = thread->resNum();
 
                 if (newNum > oldNum) {
@@ -316,7 +316,7 @@ bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
     }
 
     device->close();
-    bdata->setReadIdx(true); /* never read idx files again */
+    bdata->setReadIdx(true); // never read idx files again
 
     return true;
 }
@@ -370,7 +370,7 @@ int BoardDatabase::recordBoard(const QString& boardName, QString& oldUrl, int ty
 
     if (type == Board_Unknown) return Board_recordFailed;
 
-    /* check if the board is recorded or moved. */
+    // check if the board is recorded or moved.
     BoardData *data;
     foreach (data, m_boardDataList) {
 
@@ -379,20 +379,20 @@ int BoardDatabase::recordBoard(const QString& boardName, QString& oldUrl, int ty
                 && data->bbsPath() == bbsPath) {
 
             if (data->hostName() == hostname
-                    && data->rootPath() == rootPath) { /* recorded */
+                    && data->rootPath() == rootPath) { // recorded
                 return Board_recordRecorded;
-            } else { /* moved */
+            } else { // moved
                 oldUrl = data->basePath();
                 return Board_recordMoved;
             }
         }
     }
 
-    /* test only */
+    // test only
     if (test)
         return Board_recordNew;
 
-    /* record new board */
+    // record new board
     BoardData* bdata = new BoardData(boardName, hostname, rootPath, delimiter, bbsPath, ext, type);
     m_boardDataList.append(bdata);
 
@@ -419,7 +419,7 @@ int BoardDatabase::parseBoardUrl(
     bbsPath.clear();
     ext.clear();
 
-    /* decide type */
+    // decide type
     if (type == Board_Unknown) {
 
         if (m_url.host().contains("machi.to"))
@@ -430,17 +430,17 @@ int BoardDatabase::parseBoardUrl(
             type = Board_2ch;
     }
 
-    /* parse */
+    // parse
     switch (type) {
 
-    case Board_MachiBBS:     /* MACHI : http:// *.machi.to/(bbsPath)/ */
+    case Board_MachiBBS:     // MACHI : http:// *.machi.to/(bbsPath)/
 
         delimiter = "/bbs/read.pl";
         bbsPath = m_url.fileName();
         ext = ".cgi";
         break;
 
-    case Board_JBBS:   /* JBBS : http://jbbs.livedoor.jp/(bbsPath)/ */
+    case Board_JBBS:   // JBBS : http://jbbs.livedoor.jp/(bbsPath)/
 
         delimiter = "/bbs/read.cgi";
         bbsPath = m_url.prettyUrl().remove(hostname);
@@ -448,7 +448,7 @@ int BoardDatabase::parseBoardUrl(
         ext = ".cgi";
         break;
 
-    case Board_FlashCGI:  /* test for Flash CGI/Mini Thread  */
+    case Board_FlashCGI:  // test for Flash CGI/Mini Thread
 
         delimiter = "/test/read.cgi";
         bbsPath = m_url.fileName();
@@ -458,7 +458,7 @@ int BoardDatabase::parseBoardUrl(
         ext = ".dat";
         break;
 
-    default:   /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
+    default:   // 2ch : http://(hostname)/(rootPath)/(bbsPath)/
 
         delimiter = "/test/read.cgi";
         bbsPath = m_url.fileName();
@@ -470,7 +470,7 @@ int BoardDatabase::parseBoardUrl(
         break;
     }
 
-    /* For example, if bbsPath = "linux/", then m_bbsPath = "/linux" */
+    // For example, if bbsPath = "linux/", then m_bbsPath = "/linux"
     const QRegExp exp("/$");
     rootPath.remove(exp);
     bbsPath.remove(exp);
@@ -495,7 +495,7 @@ BoardData* BoardDatabase::getBoardData(const KUrl& url)
         return 0;
     QString urlstr = url.prettyUrl();
 
-    /* cache */
+    // cache
     if (m_previousBoardData != 0 && m_previousBoardUrl == urlstr)
         return m_previousBoardData;
 
@@ -507,7 +507,7 @@ BoardData* BoardDatabase::getBoardData(const KUrl& url)
             if (urlstr.contains(data->keyBasePathList()[i])
                     || urlstr.contains(data->keyCgiBasePathList()[i])) {
 
-                /* cache */
+                // cache
                 m_previousBoardData = data;
                 m_previousBoardUrl = urlstr;
 
@@ -588,20 +588,20 @@ bool BoardDatabase::moveBoard(const KUrl& fromUrl, const KUrl& toUrl)
 
     if (oldUrl == newUrl) return false;
 
-    /* Is oldURL recorded? */
+    // Is oldURL recorded?
     BoardData* bdata = getBoardData(oldUrl);
     if (bdata == 0) {
 
-        /* Is newURL recorded? */
+        // Is newURL recorded?
         bdata = getBoardData(newUrl);
         if (bdata == 0) return false;
     }
 
 
-    /*---------------------------*/
-    /* update BoardData */
+    //---------------------------
+    // update BoardData
 
-    /* get the path of old cache */
+    // get the path of old cache
     bdata->setHostName(oldhost);
     QStringList keyHosts = bdata->keyHostList();
     keyHosts.removeOne(oldhost);
@@ -610,18 +610,17 @@ bool BoardDatabase::moveBoard(const KUrl& fromUrl, const KUrl& toUrl)
     Cache cache(bdata->basePath());
     QString oldCachePath = cache.getDirPath();
 
-    /* update URL */
+    // update URL
     bdata->setHostName(newhost);
 
-    /* update keys */
-    /* The order of keyHosts will be like this:
-       
-      newhost      
-      oldhost      
-      foohost1
-      foohost2
-      
-    */
+    // update keys
+    // The order of keyHosts will be like this:
+    //   
+    //  newhost      
+    //  oldhost      
+    //  foohost1
+    //  foohost2
+    //  
     keyHosts = bdata->keyHostList();
     keyHosts.removeOne(oldhost);
     keyHosts.prepend(oldhost);
@@ -629,42 +628,42 @@ bool BoardDatabase::moveBoard(const KUrl& fromUrl, const KUrl& toUrl)
     keyHosts.prepend(newhost);
     bdata->createKeys(keyHosts);
 
-    /* reset BoardData */
+    // reset BoardData
     bdata->setReadIdx(false);
     bdata->setSettingLoaded(false);
 
 
-    /*---------------------------*/
-    /* move cache dir */
+    //---------------------------
+    // move cache dir
 
     QDir qdir;
     if (! qdir.exists(oldCachePath)) return true;
 
-    /* mkdir new server dir */
+    // mkdir new server dir
     Cache newCache(bdata->basePath());
     QString newCachePath = Cache::baseDir() + newCache.serverDir();
     QDir::root().mkpath(newCachePath);
 
-    /* backup old dir */
+    // backup old dir
     newCachePath += newCache.boardDir();
     if (qdir.exists (newCachePath)) {
         QString bkupPath = newCachePath;
-        bkupPath.truncate(bkupPath.length() - 1); /* remove '/' */
+        bkupPath.truncate(bkupPath.length() - 1); // remove '/'
         bkupPath +=
             '.' + QString::number(QDateTime::currentDateTime().toTime_t());
         qdir.rename(newCachePath, bkupPath);
     }
 
-    /* move cache dir */
+    // move cache dir
     if (qdir.exists(oldCachePath)) {
         qdir.rename(oldCachePath, newCachePath);
     } else
         QDir::root().mkpath(newCachePath);
 
-    /* make old dir */
+    // make old dir
     if (! qdir.exists(oldCachePath)) {
         QDir::root().mkpath(oldCachePath);
-        /* create BBS_MOVED */
+        // create BBS_MOVED
         QString movedPath = oldCachePath + "/BBS_MOVED";
         QFile file(movedPath);
         if (file.open(QIODevice::WriteOnly)) {
@@ -674,8 +673,8 @@ bool BoardDatabase::moveBoard(const KUrl& fromUrl, const KUrl& toUrl)
         file.close();
     }
 
-    /*---------------------------*/
-    /* update BBSHISTRY */
+    //---------------------------
+    // update BBSHISTRY
 
     Cache historyCache(bdata->basePath());
     QFile file(historyCache.getBBSHistoryPath());
@@ -693,8 +692,8 @@ bool BoardDatabase::moveBoard(const KUrl& fromUrl, const KUrl& toUrl)
     }
 
 
-    /*---------------------------*/
-    /* update other information */
+    //---------------------------
+    // update other information
     FavoriteThreads::replace(oldUrl, newUrl);
     Thread::replace(oldUrl, newUrl);
     ThreadInfo::replace(oldUrl, newUrl);