OSDN Git Service

remove code for KDE 3.1.x
[kita/kita.git] / kita / src / libkita / boardmanager.cpp
index cd9a5cc..a0c0bb3 100644 (file)
@@ -41,12 +41,12 @@ using namespace Kita;
 /* BoardData */
 
 BoardData::BoardData( const QString& boardName,
-                     const QString& hostname,
-                     const QString& rootPath,
-                     const QString& delimiter,
-                     const QString& bbsPath,
-                     const QString& ext,
-                     int boardtype )
+                      const QString& hostname,
+                      const QString& rootPath,
+                      const QString& delimiter,
+                      const QString& bbsPath,
+                      const QString& ext,
+                      int boardtype )
 {
     m_readIdx = FALSE;
     m_boardName = boardName;
@@ -60,7 +60,7 @@ BoardData::BoardData( const QString& boardName,
     setHostName( hostname );
 
     /* create default key */
-    QStringList keyHosts = m_hostname;    
+    QStringList keyHosts = m_hostname;
     createKeys( keyHosts );
 
     /* reset SETTING.TXT */
@@ -79,16 +79,16 @@ void BoardData::setHostName( const QString& hostName )
     /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
     m_basePath = m_hostname + m_rootPath + m_bbsPath + "/";
 
-    switch( m_type ){
+    switch ( m_type ) {
 
-    case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
-       m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + "?BBS=" + m_bbsPath.mid( 1 );
-       break;
+    case Board_MachiBBS:  /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
+        m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + "?BBS=" + m_bbsPath.mid( 1 );
+        break;
 
-    /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+        /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
     default:
-       m_cgiBasePath = m_hostname +  m_rootPath + m_delimiter + m_bbsPath + "/";       
-       break;
+        m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + m_bbsPath + "/";
+        break;
     }
 }
 
@@ -206,12 +206,12 @@ const KURL& BoardData::titleImgURL() const
 void BoardData::setSettingLoaded( bool set )
 {
     m_settingLoaded = set;
-    if( ! set ){
-       m_defaultName = QString::null;
-       m_linenum = 0;
-       m_msgCount = 0;
-       m_titleImgURL = QString::null; 
-    }
+    if ( ! set ) {
+            m_defaultName = QString::null;
+            m_linenum = 0;
+            m_msgCount = 0;
+            m_titleImgURL = QString::null;
+        }
 }
 
 /* public */
@@ -249,28 +249,28 @@ void BoardData::createKeys( const QStringList& keyHostList )
     m_keyBasePathList.clear();
     m_keyCgiBasePathList.clear();
     m_keyHostList.clear();
-   
+
     m_keyHostList = keyHostList;
 
-    /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */    
-    for( unsigned int i = 0; i < m_keyHostList.count(); ++i ){
-       if( m_keyHostList[i].length() > 0 )
-           m_keyBasePathList += m_keyHostList[i] + m_rootPath + m_bbsPath + "/";
+    /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
+    for ( unsigned int i = 0; i < m_keyHostList.count(); ++i ) {
+        if ( m_keyHostList[ i ].length() > 0 )
+            m_keyBasePathList += m_keyHostList[ i ] + m_rootPath + m_bbsPath + "/";
     }
 
-    switch( m_type ){
+    switch ( m_type ) {
 
-    case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
-       for( unsigned int i = 0; i < m_keyHostList.count(); ++i )
-           m_keyCgiBasePathList += m_keyHostList[i] + m_rootPath + m_delimiter
-               + "?BBS=" + m_bbsPath.mid( 1 );
-       break;
+    case Board_MachiBBS:  /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
+        for ( unsigned int i = 0; i < m_keyHostList.count(); ++i )
+            m_keyCgiBasePathList += m_keyHostList[ i ] + m_rootPath + m_delimiter
+                                    + "?BBS=" + m_bbsPath.mid( 1 );
+        break;
 
-    /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+        /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
     default:
-       for( unsigned int i = 0; i < m_keyHostList.count(); ++i )
-           m_keyCgiBasePathList += m_keyHostList[i] +  m_rootPath + m_delimiter + m_bbsPath + "/";
-       break;
+        for ( unsigned int i = 0; i < m_keyHostList.count(); ++i )
+            m_keyCgiBasePathList += m_keyHostList[ i ] + m_rootPath + m_delimiter + m_bbsPath + "/";
+        break;
     }
 }
 
@@ -322,8 +322,8 @@ BoardManager::~BoardManager()
 /* (hostname)/(rootPath)/(bbsPath)/ */ /* public */ /* static */
 const QString BoardManager::boardURL( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
     return bdata->basePath();
 }
@@ -335,25 +335,25 @@ const QStringList BoardManager::allBoardURLList()
     urlList.clear();
 
     for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it )
-       urlList += (*it)->basePath();
-    
+        urlList += ( *it ) ->basePath();
+
     return urlList;
 }
 
 /* (hostname)/(rootPath) */ /* public */ /* static */
 const QString BoardManager::boardRoot( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
-    return bdata->hostName() + bdata->rootPath(); 
+    return bdata->hostName() + bdata->rootPath();
 }
 
 /* (bbspath) */ /* public */ /* static */
 const QString BoardManager::boardPath( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
     return bdata->bbsPath();
 }
@@ -361,8 +361,8 @@ const QString BoardManager::boardPath( const KURL& url )
 /* (ext) */ /* public */ /* static */
 const QString BoardManager::ext( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
     return bdata->ext();
 }
@@ -370,8 +370,8 @@ const QString BoardManager::ext( const KURL& url )
 /* ID of board for writing */ /* public */ /* static */
 const QString BoardManager::boardID( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
     return bdata->bbsPath().mid( 1 ); /* remove "/" */
 }
@@ -380,8 +380,8 @@ const QString BoardManager::boardID( const KURL& url )
 /* (hostname)/(rootPath)/(bbsPath)/subject.txt */ /* public */ /* static */
 const QString BoardManager::subjectURL( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
     return bdata->basePath() + "subject.txt";
 }
@@ -390,8 +390,8 @@ const QString BoardManager::subjectURL( const KURL& url )
 /* public */ /* static */
 const QString BoardManager::boardName( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
 
     return bdata->boardName();
 }
@@ -400,8 +400,8 @@ const QString BoardManager::boardName( const KURL& url )
 /* public */ /* static */
 const int BoardManager::type( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return Board_Unknown;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return Board_Unknown;
 
     return bdata->type();
 }
@@ -414,16 +414,16 @@ const int BoardManager::type( const KURL& url )
 /*  get list of pointers of Thread classes.     */
 /*
   Input:
-
   url:  URL of board.
   oldLogs: If TRUE, search cache and get list of pointer of old threads.
   online: online or offline mode.
-
   Output:
-
   threadList: list of pointers of Thread classes.
   oldLogList: list of pointers of old threads.
-
                                                  */ /* public */ /* static */
 void BoardManager::getThreadList(
 
@@ -431,7 +431,7 @@ void BoardManager::getThreadList(
     const KURL& url,
     bool oldLogs,
     bool online,
-    
+
     /* output */
     QPtrList< Thread >& threadList,
     QPtrList< Thread >& oldLogList )
@@ -442,58 +442,54 @@ void BoardManager::getThreadList(
     /* get all obtained threads list from cache */
     if ( url.prettyURL() == "http://virtual/obtained/" ) {
 
-       QStringList bbslist = allBoardURLList();
+        QStringList bbslist = allBoardURLList();
 
-       /* search all cache dirs */
+        /* search all cache dirs */
         for ( QStringList::iterator it = bbslist.begin() ; it != bbslist.end(); ++it ) {
 
-           getCachedThreadList( ( *it ), threadList );
+            getCachedThreadList( ( *it ), threadList );
         }
 
-        return;
+        return ;
     }
 
     /*-------------------------*/
 
     BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return;
-    
+    if ( bdata == NULL ) return ;
+
     /* download subject.txt */
-    if( online ){
-
-       /* make directory */
-       QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
-       if( !Kita::mkdir( cacheDir ) ) return;
-       
-       KIO::SlaveConfig::self() ->setConfigData( "http",
-                                                 url.host() ,
-                                                 "UserAgent",
-                                                 QString( "Monazilla/1.00 (Kita/%1)" ).arg( VERSION ) );
-       QString subjectPath = Cache::getSubjectPath( url );
-#if KDE_IS_VERSION( 3, 2, 0 )
-       KIO::NetAccess::download( subjectURL( url ), subjectPath, NULL );
-#else
-       KIO::NetAccess::download( subjectURL( url ), subjectPath );
-#endif
-
-       /* download SETTING.TXT */
-       loadBBSSetting( url );
+    if ( online ) {
+
+        /* make directory */
+        QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
+        if ( !Kita::mkdir( cacheDir ) ) return ;
+
+        KIO::SlaveConfig::self() ->setConfigData( "http",
+                url.host() ,
+                "UserAgent",
+                QString( "Monazilla/1.00 (Kita/%1)" ).arg( VERSION ) );
+        QString subjectPath = Cache::getSubjectPath( url );
+        KIO::NetAccess::download( subjectURL( url ), subjectPath, NULL );
+
+        /* download SETTING.TXT */
+        loadBBSSetting( url );
     }
 
     /* open and read subject.txt */
     readSubjectTxt( bdata, url, threadList );
-    
+
     /* get old logs */
-    if( oldLogs ){
-           
-       QPtrList< Thread > tmpList;
-       tmpList.clear();
-       getCachedThreadList( url, tmpList );
-
-       for ( unsigned i = 0; i < tmpList.count(); i++ ) {
-               
-           if( threadList.contains( tmpList.at( i ) ) == 0 ) oldLogList.append( tmpList.at( i ) );
-       }
+    if ( oldLogs ) {
+
+        QPtrList< Thread > tmpList;
+        tmpList.clear();
+        getCachedThreadList( url, tmpList );
+
+        for ( unsigned i = 0; i < tmpList.count(); i++ ) {
+
+            if ( threadList.contains( tmpList.at( i ) ) == 0 ) oldLogList.append( tmpList.at( i ) );
+        }
     }
 }
 
@@ -502,63 +498,63 @@ void BoardManager::getThreadList(
 void BoardManager::getCachedThreadList( const KURL& url, QPtrList< Thread >& threadList )
 {
     QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
-    QDir d( cacheDir );    
+    QDir d( cacheDir );
     if ( d.exists() ) {
-    
-       /* get all file names */
-       QString ext = BoardManager::getBoardData( url )->ext();
-       QString boardURL = BoardManager::getBoardData( url )->basePath();
-       QStringList flist = d.entryList( "*" + ext );
-               
-       for ( QStringList::iterator it = flist.begin(); it != flist.end(); ++it ) {
-           if ( ( *it ) == QString::null ) continue;
-
-           QString datURL = boardURL + "dat/" + ( *it );
-
-           /* read idx file */
-           Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
-           if( thread == NULL ){
-
-               thread = Kita::Thread::getByURL( datURL );
-               if( thread == NULL ) continue;
-               ThreadIndex::loadIndex( thread, datURL, FALSE );
-           }
-
-           if( thread != NULL ) threadList.append( thread );
-       }
+
+        /* get all file names */
+        QString ext = BoardManager::getBoardData( url ) ->ext();
+        QString boardURL = BoardManager::getBoardData( url ) ->basePath();
+        QStringList flist = d.entryList( "*" + ext );
+
+        for ( QStringList::iterator it = flist.begin(); it != flist.end(); ++it ) {
+            if ( ( *it ) == QString::null ) continue;
+
+            QString datURL = boardURL + "dat/" + ( *it );
+
+            /* read idx file */
+            Kita::Thread* thread = Kita::Thread::getByURLNew( datURL );
+            if ( thread == NULL ) {
+
+                thread = Kita::Thread::getByURL( datURL );
+                if ( thread == NULL ) continue;
+                ThreadIndex::loadIndex( thread, datURL, FALSE );
+            }
+
+            if ( thread != NULL ) threadList.append( thread );
+        }
     }
 }
 
 
 
-/* open subject.txt and get list of Thread classes */ /* private */ /* static */ 
+/* open subject.txt and get list of Thread classes */ /* private */ /* static */
 bool BoardManager::readSubjectTxt( BoardData* bdata, const KURL& url, QPtrList< Thread >& threadList )
 {
     /* get all names of cached files to read idx.  */
     QStringList cacheList;
-    if( !bdata->readIdx() ){
-       
-       QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
-       QDir d( cacheDir );    
-       if ( d.exists() ) {
-           QString ext = BoardManager::getBoardData( url )->ext();
-           cacheList = d.entryList( "*" + ext );
-       }
+    if ( !bdata->readIdx() ) {
+
+        QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
+        QDir d( cacheDir );
+        if ( d.exists() ) {
+            QString ext = BoardManager::getBoardData( url ) ->ext();
+            cacheList = d.entryList( "*" + ext );
+        }
     }
 
     /* open subject.txt */
     QString subjectPath = Cache::getSubjectPath( url );
     QIODevice * device = KFilterDev::deviceForFile( subjectPath, "application/x-gzip" );
-    if( !device->open( IO_ReadOnly ) ) return FALSE;
+    if ( !device->open( IO_ReadOnly ) ) return FALSE;
 
     QTextStream stream( device );
 
     if ( BoardManager::type( url ) == Board_JBBS ) {
-       if ( !m_eucJpCodec ) m_eucJpCodec = new QEucJpCodec();  
-       stream.setCodec( m_eucJpCodec );
+        if ( !m_eucJpCodec ) m_eucJpCodec = new QEucJpCodec();
+        stream.setCodec( m_eucJpCodec );
     } else {
-       if ( !m_cp932Codec ) m_cp932Codec = new QCp932Codec();  
-       stream.setCodec( m_cp932Codec );
+        if ( !m_cp932Codec ) m_cp932Codec = new QCp932Codec();
+        stream.setCodec( m_cp932Codec );
     }
 
     // parse subject.txt(only one format...)
@@ -568,47 +564,49 @@ bool BoardManager::readSubjectTxt( BoardData* bdata, const KURL& url, QPtrList<
 
     case Board_MachiBBS:
     case Board_JBBS:
-       regexp.setPattern( "(\\d+\\.cgi),(.*)\\((\\d+)\\)" );
-       break;
+        regexp.setPattern( "(\\d+\\.cgi),(.*)\\((\\d+)\\)" );
+        break;
 
     default:
-       regexp.setPattern( "(\\d+\\.dat)<>(.*)\\((\\d+)\\)" );
-       break;
+        regexp.setPattern( "(\\d+\\.dat)<>(.*)\\((\\d+)\\)" );
+        break;
     }
     QString line;
 
     while ( ( line = stream.readLine() ) != QString::null ) {
-       int pos = regexp.search( line );
-       if ( pos != -1 ) {
-           QString fname = regexp.cap( 1 );
-           QString subject = regexp.cap( 2 );
-           QString num = regexp.cap( 3 );
-
-           /* get pointer of Thread class */
-           QString datURL = boardURL( url ) + "dat/" + fname;
-           Kita::Thread* thread = Kita::Thread::getByURL( datURL );
-           threadList.append( thread );
-
-           /* set thread name */           
-           thread->setThreadName( subject );
-
-           /* load index file */
-           if( !bdata->readIdx() ){
-
-               if( cacheList.contains( fname ) ) ThreadIndex::loadIndex( thread, datURL, FALSE );
-           }
-
-           /* update res num */
-           int newNum = num.toInt();
-           if( thread->readNum() ){ /* cache exists */
-               int oldNum = thread->resNum();
-
-               if( newNum > oldNum ){
-                   Kita::ThreadIndex::setResNum( datURL, newNum );
-               }
-           }
-           thread->setResNum( newNum );
-       }
+        int pos = regexp.search( line );
+        if ( pos != -1 ) {
+            QString fname = regexp.cap( 1 );
+            QString subject = regexp.cap( 2 );
+            QString num = regexp.cap( 3 );
+
+            /* get pointer of Thread class */
+            QString datURL = boardURL( url ) + "dat/" + fname;
+            Kita::Thread* thread = Kita::Thread::getByURL( datURL );
+            if ( threadList.find( thread ) == -1 ) {
+                threadList.append( thread );
+            }
+
+            /* set thread name */
+            thread->setThreadName( subject );
+
+            /* load index file */
+            if ( !bdata->readIdx() ) {
+
+                if ( cacheList.contains( fname ) ) ThreadIndex::loadIndex( thread, datURL, FALSE );
+            }
+
+            /* update res num */
+            int newNum = num.toInt();
+            if ( thread->readNum() ) { /* cache exists */
+                int oldNum = thread->resNum();
+
+                if ( newNum > oldNum ) {
+                    Kita::ThreadIndex::setResNum( datURL, newNum );
+                }
+            }
+            thread->setResNum( newNum );
+        }
     }
 
     device->close();
@@ -621,34 +619,37 @@ bool BoardManager::readSubjectTxt( BoardData* bdata, const KURL& url, QPtrList<
 /* BoardData */
 
 /* reset all BoardData */ /* public */ /* static */
-void  BoardManager::clearBoardData()
+void BoardManager::clearBoardData()
 {
     for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it )
-       delete( *it );
+        delete( *it );
 
     m_boardDataList.clear();
     m_previousBoardData = NULL;
     m_previousBoardURL = QString::null;
 }
 
-/* enroll board        */
-
-/* Input: board, boardName, type, test
-   Output: oldURL
-
-   return: 
-   If board is already enrolled, return Board_enrollEnrolled and oldURL is QString::null.
-   If board is new board, return Board_enrollNew and oldURL is QString::null.
-   If board is moved, return Board_enrollMoved, and oldURL is old URL.
-
-   Note that board is NOT enrolled when board is moved.
-   To enroll new URL, call BoardManager::moveBoard(). 
-
-   "int type" is type of board. It could be "Kita::Board_Unknown". See also parseBoardURL().
-   
-   If "bool test" is TRUE, this function just checks if the board is enrolled (never enroll board).
-
-*/
+/**
+ *
+ * @param[in] board
+ * @param[in] boardName
+ * @param[in] type
+ * @param[in] test
+ *
+ * @param[out] oldURL
+ *
+ * @retval Board_enrollEnrolled if board is already enrolled. oldURL is QString::null.
+ * @retval Board_enrollNew if board is new board. oldURL is QString::null.
+ * @retval Board_enrollMoved if board is moved. oldURL is old URL.
+ *
+ * @note board is NOT enrolled when board is moved.
+ * To enroll new URL, call BoardManager::moveBoard(). 
+ *
+ * "int type" is type of board. It could be "Kita::Board_Unknown". See also parseBoardURL().
+ * 
+ * If "bool test" is TRUE, this function just checks if the board is enrolled (never enroll board).
+ *
+ */ 
 /* public */ /* static */
 int BoardManager::enrollBoard( const KURL& url, const QString& boardName, QString& oldURL, int type, bool test )
 {
@@ -660,29 +661,28 @@ int BoardManager::enrollBoard( const KURL& url, const QString& boardName, QStrin
     type = parseBoardURL( url, type, hostname, rootPath, delimiter, bbsPath, ext );
     oldURL = QString::null;
 
-    if( type == Board_Unknown ) return Board_enrollFailed;
-    
+    if ( type == Board_Unknown ) return Board_enrollFailed;
+
     /* check if the board is enrolled or moved. */
-    for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ){
-       
-       if( ( *it )->boardName() == boardName
-           && ( *it )->type() == type
-           && ( *it )->bbsPath() == bbsPath ){
-           
-           if( ( *it )->hostName() ==  hostname 
-               && ( *it )->rootPath() == rootPath ){ /* enrolled */
-               return Board_enrollEnrolled;
-           }
-           else{ /* moved */
-               oldURL = ( *it )->basePath();
-               return Board_enrollMoved;
-           }
-       }
+    for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ) {
+
+        if ( ( *it ) ->boardName() == boardName
+                && ( *it ) ->type() == type
+                && ( *it ) ->bbsPath() == bbsPath ) {
+
+            if ( ( *it ) ->hostName() == hostname
+                    && ( *it ) ->rootPath() == rootPath ) { /* enrolled */
+                return Board_enrollEnrolled;
+            } else { /* moved */
+                oldURL = ( *it ) ->basePath();
+                return Board_enrollMoved;
+            }
+        }
     }
 
     /* test only */
-    if( test ) return Board_enrollNew;
-    
+    if ( test ) return Board_enrollNew;
+
     /* enroll new board */
     BoardData* bdata = new BoardData( boardName, hostname, rootPath, delimiter, bbsPath, ext, type );
     m_boardDataList.append( bdata );
@@ -697,7 +697,7 @@ int BoardManager::parseBoardURL(
 
     /* input */
     const KURL& url,
-    int type,  /* If type = Board_Unknown, type will be decided according to url. */
+    int type,   /* If type = Board_Unknown, type will be decided according to url. */
 
     /* output */
     QString& hostname,
@@ -713,57 +713,57 @@ int BoardManager::parseBoardURL(
     ext = QString::null;
 
     /* decide type */
-    if( type == Board_Unknown ){
-       
-       if( url.host().contains( "machi.to" ) ) type = Board_MachiBBS;  
-       else if( url.host().contains( "jbbs.livedoor.jp" ) ) type = Board_JBBS;
-       else type = Board_2ch;
+    if ( type == Board_Unknown ) {
+
+        if ( url.host().contains( "machi.to" ) ) type = Board_MachiBBS;
+        else if ( url.host().contains( "jbbs.livedoor.jp" ) ) type = Board_JBBS;
+        else type = Board_2ch;
     }
 
     /* parse */
-    switch( type ){
-
-    case Board_MachiBBS:    /* MACHI : http:// *.machi.to/(bbsPath)/ */
-       
-       delimiter = "/bbs/read.pl";
-       bbsPath = url.filename();
-       ext = ".cgi";
-       break;
-
-    case Board_JBBS:  /* JBBS : http://jbbs.livedoor.jp/(bbsPath)/ */
-       
-       delimiter = "/bbs/read.cgi";
-       bbsPath = url.prettyURL().remove( hostname );
-       type = Board_JBBS;
-       ext = ".cgi";
-       break;
-
-    case Board_FlashCGI: /* test for Flash CGI/Mini Thread  */
-       
-       delimiter = "/test/read.cgi";
-       bbsPath = url.filename();
-       rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
-       if( rootPath.length() == 0 ) rootPath = QString::null;
-       ext = ".dat";
-       break;
-
-    default:  /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
-       
-       delimiter = "/test/read.cgi";
-       bbsPath = url.filename();
-       rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
-       if( rootPath.length() == 0 ) rootPath = QString::null;
-       ext = ".dat";
-       type = Board_2ch;
-       break;
+    switch ( type ) {
+
+    case Board_MachiBBS:     /* MACHI : http:// *.machi.to/(bbsPath)/ */
+
+        delimiter = "/bbs/read.pl";
+        bbsPath = url.filename();
+        ext = ".cgi";
+        break;
+
+    case Board_JBBS:   /* JBBS : http://jbbs.livedoor.jp/(bbsPath)/ */
+
+        delimiter = "/bbs/read.cgi";
+        bbsPath = url.prettyURL().remove( hostname );
+        type = Board_JBBS;
+        ext = ".cgi";
+        break;
+
+    case Board_FlashCGI:  /* test for Flash CGI/Mini Thread  */
+
+        delimiter = "/test/read.cgi";
+        bbsPath = url.filename();
+        rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
+        if ( rootPath.length() == 0 ) rootPath = QString::null;
+        ext = ".dat";
+        break;
+
+    default:   /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
+
+        delimiter = "/test/read.cgi";
+        bbsPath = url.filename();
+        rootPath = url.prettyURL().remove( hostname + "/" ).remove( bbsPath + "/" );
+        if ( rootPath.length() == 0 ) rootPath = QString::null;
+        ext = ".dat";
+        type = Board_2ch;
+        break;
     }
 
     /* For example, if bbsPath = "linux/", then m_bbsPath = "/linux" */
     const QRegExp exp( "/$" );
     rootPath.remove( exp );
     bbsPath.remove( exp );
-    if( rootPath != QString::null && rootPath.at( 0 ) != '/' ) rootPath = "/" + rootPath;
-    if( bbsPath != QString::null && bbsPath.at( 0 ) != '/' ) bbsPath = "/" + bbsPath;
+    if ( rootPath != QString::null && rootPath.at( 0 ) != '/' ) rootPath = "/" + rootPath;
+    if ( bbsPath != QString::null && bbsPath.at( 0 ) != '/' ) bbsPath = "/" + bbsPath;
 
     return type;
 }
@@ -772,7 +772,7 @@ int BoardManager::parseBoardURL(
 /* public */ /* static */
 bool BoardManager::isEnrolled( const KURL& url )
 {
-    if( getBoardData( url ) == NULL ) return FALSE;
+    if ( getBoardData( url ) == NULL ) return FALSE;
     return TRUE;
 }
 
@@ -780,28 +780,28 @@ bool BoardManager::isEnrolled( const KURL& url )
 /* public */ /* static */
 BoardData* BoardManager::getBoardData( const KURL& url )
 {
-    if( url.isEmpty() ) return NULL;
+    if ( url.isEmpty() ) return NULL;
     QString urlstr = url.prettyURL();
 
     /* cache */
-    if( m_previousBoardData != NULL && m_previousBoardURL == urlstr ) return m_previousBoardData;
-    
-    for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ){
-
-       int count = (*it)->keyBasePathList().count();
-       for( int i = 0; i < count ; ++i ){
-           if( urlstr.contains( (*it)->keyBasePathList()[i] )
-               || urlstr.contains( (*it)->keyCgiBasePathList()[i] ) ){
-
-            /* cache */
-           m_previousBoardData = (*it);
-           m_previousBoardURL = urlstr;
-           
-           return (*it);
-           }
-       }
+    if ( m_previousBoardData != NULL && m_previousBoardURL == urlstr ) return m_previousBoardData;
+
+    for ( BoardDataList::Iterator it = m_boardDataList.begin(); it != m_boardDataList.end(); ++it ) {
+
+        int count = ( *it ) ->keyBasePathList().count();
+        for ( int i = 0; i < count ; ++i ) {
+            if ( urlstr.contains( ( *it ) ->keyBasePathList() [ i ] )
+                    || urlstr.contains( ( *it ) ->keyCgiBasePathList() [ i ] ) ) {
+
+                /* cache */
+                m_previousBoardData = ( *it );
+                m_previousBoardURL = urlstr;
+
+                return ( *it );
+            }
+        }
     }
-    
+
     return NULL;
 }
 
@@ -812,42 +812,42 @@ BoardData* BoardManager::getBoardData( const KURL& url )
 
 
 /* load the bbs history file ( BBSHISTORY ), and create keys of Data Base.  */
-/* Before calling this, enroll the board by enrollBoard().                  */ 
+/* Before calling this, enroll the board by enrollBoard().                  */
 /*
     ex) If the host of board moved like :
-
     http:://aaa.com -> http://bbb.com -> http://ccc.com -> http://ddd.com
     
     then, BBSHISTORY is
-
     http://ccc.com
     http://bbb.com
     http://aaa.com
-
 */ /* public */ /* static */
 bool BoardManager::loadBBSHistory( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return FALSE;
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return FALSE;
+
+    QStringList keyHosts = bdata->hostName();
 
-    QStringList keyHosts = bdata->hostName();  
-    
     QFile file( Cache::getBBSHistoryPath( url ) );
-    if ( file.open( IO_ReadOnly ) ){
+    if ( file.open( IO_ReadOnly ) ) {
 
-       QTextStream ts( &file );
+        QTextStream ts( &file );
 
-       QString line;
-       while( !ts.eof() ){
+        QString line;
+        while ( !ts.eof() ) {
 
-           line = ts.readLine();
-           keyHosts += line;
-       }
+            line = ts.readLine();
+            keyHosts += line;
+        }
 
-       bdata->createKeys( keyHosts );
-       file.close();
+        bdata->createKeys( keyHosts );
+        file.close();
 
-       return TRUE;
+        return TRUE;
     }
 
     return FALSE;
@@ -857,7 +857,7 @@ bool BoardManager::loadBBSHistory( const KURL& url )
 /* public */ /* static */
 bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
 {
-    QString oldhost = fromURL.protocol() + "://" + fromURL.host();    
+    QString oldhost = fromURL.protocol() + "://" + fromURL.host();
     QString newhost = toURL.protocol() + "://" + toURL.host();
 
     const QRegExp exp( "/$" );
@@ -867,16 +867,16 @@ bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
     newURL.remove( exp );
     oldURL += "/";
     newURL += "/";
-    
-    if( oldURL == newURL ) return FALSE;
-    
+
+    if ( oldURL == newURL ) return FALSE;
+
     /* Is oldURL enrolled? */
-    BoardData* bdata = getBoardData( oldURL ); 
-    if( bdata == NULL ){
+    BoardData* bdata = getBoardData( oldURL );
+    if ( bdata == NULL ) {
 
-       /* Is newURL enrolled? */
-       bdata = getBoardData( newURL ); 
-       if( bdata == NULL ) return FALSE;
+        /* Is newURL enrolled? */
+        bdata = getBoardData( newURL );
+        if ( bdata == NULL ) return FALSE;
     }
 
 
@@ -888,13 +888,13 @@ bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
     QStringList keyHosts = bdata->keyHostList();
     keyHosts.remove( oldhost );
     keyHosts.prepend( oldhost );
-    bdata->createKeys( keyHosts );    
+    bdata->createKeys( keyHosts );
     QString oldCachePath = Cache::baseDir() + Cache::serverDir( bdata->basePath() )
-       + Cache::boardDir( bdata->basePath() );
+                           + Cache::boardDir( bdata->basePath() );
 
     /* update URL */
     bdata->setHostName( newhost );
-    
+
     /* update keys */
     /* The order of keyHosts will be like this:
        
@@ -915,31 +915,30 @@ bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
     bdata->setReadIdx( FALSE );
     bdata->setSettingLoaded( FALSE );
 
-    
+
     /*---------------------------*/
     /* move cache dir */
-    
+
     QDir qdir;
-    if( ! qdir.exists( oldCachePath ) ) return TRUE;
-    
+    if ( ! qdir.exists( oldCachePath ) ) return TRUE;
+
     /* mkdir new server dir */
-    QString newCachePath = Cache::baseDir() + Cache::serverDir( bdata->basePath() );    
+    QString newCachePath = Cache::baseDir() + Cache::serverDir( bdata->basePath() );
     Kita::mkdir( newCachePath );
-    
+
     /* backup old dir */
-    newCachePath += Cache::boardDir( bdata->basePath() );    
-    if( qdir.exists ( newCachePath ) ){
-       QString bkupPath = newCachePath;
-       bkupPath.truncate( bkupPath.length() -1 ); /* remove '/' */
-       bkupPath += "." + QString().setNum( QDateTime::currentDateTime().toTime_t() );
-       qdir.rename( newCachePath, bkupPath  );
+    newCachePath += Cache::boardDir( bdata->basePath() );
+    if ( qdir.exists ( newCachePath ) ) {
+        QString bkupPath = newCachePath;
+        bkupPath.truncate( bkupPath.length() - 1 ); /* remove '/' */
+        bkupPath += "." + QString().setNum( QDateTime::currentDateTime().toTime_t() );
+        qdir.rename( newCachePath, bkupPath );
     }
 
     /* move cache dir */
-    if( qdir.exists( oldCachePath ) ){
-       qdir.rename( oldCachePath, newCachePath );
-    }
-    else Kita::mkdir( newCachePath );
+    if ( qdir.exists( oldCachePath ) ) {
+        qdir.rename( oldCachePath, newCachePath );
+    } else Kita::mkdir( newCachePath );
 
     /* make old dir */
     if ( ! qdir.exists( oldCachePath ) ) {
@@ -956,21 +955,21 @@ bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
 
     /*---------------------------*/
     /* update BBSHISTRY */
-    
+
     QFile file( Cache::getBBSHistoryPath( bdata->basePath() ) );
-    if ( file.open( IO_WriteOnly ) ){
+    if ( file.open( IO_WriteOnly ) ) {
+
+        QTextStream ts( &file );
 
-       QTextStream ts( &file );
-       
-       keyHosts.remove( newhost );
-       for ( QStringList::iterator it = keyHosts.begin() ; it != keyHosts.end(); ++it ) {
-           ts << (*it) << endl;
-       }
+        keyHosts.remove( newhost );
+        for ( QStringList::iterator it = keyHosts.begin() ; it != keyHosts.end(); ++it ) {
+            ts << ( *it ) << endl;
+        }
 
-       file.close();
+        file.close();
     }
 
-    
+
     /*---------------------------*/
     /* update other information */
     FavoriteThreads::replace( oldURL, newURL );
@@ -990,26 +989,26 @@ bool BoardManager::moveBoard( const KURL& fromURL, const KURL& toURL )
 bool BoardManager::loadBBSSetting( const KURL& url, bool reload )
 {
     /* Is board enrolled ? */
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return FALSE;
-    if( bdata->type() != Board_2ch ) return FALSE;
-    
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return FALSE;
+    if ( bdata->type() != Board_2ch ) return FALSE;
+
     KURL settingURL = bdata->settingURL();
     QString path = Cache::getSettingPath( url );
-    
+
     /* now loading */
-    if( DownloadManager::isLoadingNow( settingURL ) ) return FALSE;
+    if ( DownloadManager::isLoadingNow( settingURL ) ) return FALSE;
 
     /* already loaded */
-    if( bdata->settingLoaded() && !reload ) return TRUE;
+    if ( bdata->settingLoaded() && !reload ) return TRUE;
 
     /* reset names, linenum, etc. */
     bdata->setSettingLoaded( FALSE );
-    
+
     /* download SETTING.TXT.*/
     DownloadManager::download( settingURL, path );
     bdata->setSettingLoaded( TRUE );
-    
+
     return TRUE;
 }
 
@@ -1017,10 +1016,10 @@ bool BoardManager::loadBBSSetting( const KURL& url, bool reload )
 /* public */ /* static */
 QString BoardManager::getBBSDefaultName( const KURL& url )
 {
-    BoardData* bdata = openSettingTxt( url );
-    if( bdata == NULL ) bdata = getBoardData( url );
-    if( bdata == NULL ) return "(default name)";
-    if( bdata->defaultName() == QString::null ) return "(default name)";
+    BoardData * bdata = openSettingTxt( url );
+    if ( bdata == NULL ) bdata = getBoardData( url );
+    if ( bdata == NULL ) return "(default name)";
+    if ( bdata->defaultName() == QString::null ) return "(default name)";
     return bdata->defaultName();
 }
 
@@ -1028,18 +1027,18 @@ QString BoardManager::getBBSDefaultName( const KURL& url )
 /* public */ /* static */
 int BoardManager::getBBSMaxLine( const KURL& url )
 {
-    BoardData* bdata = openSettingTxt( url );
-    if( bdata == NULL ) bdata = getBoardData( url );
-    if( bdata == NULL ) return 0;
+    BoardData * bdata = openSettingTxt( url );
+    if ( bdata == NULL ) bdata = getBoardData( url );
+    if ( bdata == NULL ) return 0;
     return bdata->lineNum();
 }
 
 /* public */ /* static */
 int BoardManager::getBBSMsgCount( const KURL& url )
 {
-    BoardData* bdata = openSettingTxt( url );
-    if( bdata == NULL ) bdata = getBoardData( url );
-    if( bdata == NULL ) return 0;
+    BoardData * bdata = openSettingTxt( url );
+    if ( bdata == NULL ) bdata = getBoardData( url );
+    if ( bdata == NULL ) return 0;
     return bdata->msgCount();
 }
 
@@ -1047,62 +1046,62 @@ int BoardManager::getBBSMsgCount( const KURL& url )
 /* public */ /* static */
 const KURL BoardManager::titleImgURL( const KURL& url )
 {
-    BoardData* bdata = openSettingTxt( url );
-    if( bdata == NULL ) bdata = getBoardData( url );
-    if( bdata == NULL ) return QString::null;
+    BoardData * bdata = openSettingTxt( url );
+    if ( bdata == NULL ) bdata = getBoardData( url );
+    if ( bdata == NULL ) return QString::null;
     return bdata->titleImgURL();
 }
 
 /* open local SETTING.TXT, then get names, linenum, etc. */ /* private */ /* static */
 BoardData* BoardManager::openSettingTxt( const KURL& url )
 {
-    BoardData* bdata = getBoardData( url );
-    if( bdata == NULL ) return NULL;
-    if( !bdata->settingLoaded() ) return NULL;
-    if( DownloadManager::isLoadingNow( bdata->settingURL() ) ) return NULL;
-    if( bdata->defaultName() != QString::null ) return bdata;
-    
+    BoardData * bdata = getBoardData( url );
+    if ( bdata == NULL ) return NULL;
+    if ( !bdata->settingLoaded() ) return NULL;
+    if ( DownloadManager::isLoadingNow( bdata->settingURL() ) ) return NULL;
+    if ( bdata->defaultName() != QString::null ) return bdata;
+
     QFile file( Cache::getSettingPath( url ) );
-    if ( file.open( IO_ReadOnly ) ){
-
-       QTextStream ts( &file );
-       if( m_cp932Codec == NULL) m_cp932Codec = new QCp932Codec();
-       ts.setCodec( m_cp932Codec );
-
-       QString line;
-       while( !ts.eof() ){
-
-           line = ts.readLine();
-
-           /* default name */
-           QString key = "BBS_NONAME_NAME=";
-           if( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
-
-           /* 0ch type */
-           key = "NANASI_NAME=";
-           if( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
-
-           /* line number */
-           key = "BBS_LINE_NUMBER=";
-           if( line.find( key ) != -1 ) bdata->setLineNum( line.remove( key ).toInt() * 2 );
-
-           /* msg count */
-           key = "BBS_MESSAGE_COUNT=";
-           if( line.find( key ) != -1 ) bdata->setMsgCount( line.remove( key ).toInt() );
-           
-           /* title image */
-           key = "BBS_TITLE_PICTURE=";
-           if( line.find( key ) != -1 ){
-               QString path = line.remove( key );
-               KURL titleImgURL = KURL( bdata->basePath(), path );
-               bdata->setTitleImgURL( titleImgURL );
-           }
-       }
-           
-       file.close();
+    if ( file.open( IO_ReadOnly ) ) {
+
+        QTextStream ts( &file );
+        if ( m_cp932Codec == NULL ) m_cp932Codec = new QCp932Codec();
+        ts.setCodec( m_cp932Codec );
+
+        QString line;
+        while ( !ts.eof() ) {
+
+            line = ts.readLine();
+
+            /* default name */
+            QString key = "BBS_NONAME_NAME=";
+            if ( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
+
+            /* 0ch type */
+            key = "NANASI_NAME=";
+            if ( line.find( key ) != -1 ) bdata->setDefaultName( line.remove( key ) );
+
+            /* line number */
+            key = "BBS_LINE_NUMBER=";
+            if ( line.find( key ) != -1 ) bdata->setLineNum( line.remove( key ).toInt() * 2 );
+
+            /* msg count */
+            key = "BBS_MESSAGE_COUNT=";
+            if ( line.find( key ) != -1 ) bdata->setMsgCount( line.remove( key ).toInt() );
+
+            /* title image */
+            key = "BBS_TITLE_PICTURE=";
+            if ( line.find( key ) != -1 ) {
+                QString path = line.remove( key );
+                KURL titleImgURL = KURL( bdata->basePath(), path );
+                bdata->setTitleImgURL( titleImgURL );
+            }
+        }
+
+        file.close();
     }
 
-    if( bdata->defaultName() == QString::null ) bdata->setDefaultName( "(default name)" );
-    
+    if ( bdata->defaultName() == QString::null ) bdata->setDefaultName( "(default name)" );
+
     return bdata;
 }