[Kita-svn] [2350] fix a bug related to cache

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 7月 5日 (日) 07:50:35 JST


Revision: 2350
          http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2350
Author:   nogu
Date:     2009-07-05 07:50:35 +0900 (Sun, 05 Jul 2009)

Log Message:
-----------
fix a bug related to cache

Modified Paths:
--------------
    kita/branches/KITA-KDE4/kita/src/libkita/access.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/access.h
    kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.cpp
    kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.h


-------------- next part --------------
Modified: kita/branches/KITA-KDE4/kita/src/libkita/access.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/access.cpp	2009-07-04 03:40:29 UTC (rev 2349)
+++ kita/branches/KITA-KDE4/kita/src/libkita/access.cpp	2009-07-04 22:50:35 UTC (rev 2350)
@@ -38,7 +38,7 @@
     m_bbstype = BoardManager::type( m_datURL );
     m_header = "HTTP/1.1 200 ";  /* dummy header */
     m_dataSize = 0;
-    m_threadData = QString::null;
+    m_threadData.clear();
 }
 
 /* read data from cache, then emit data to DatInfo. */ /* public */
@@ -87,7 +87,7 @@
 void Access::writeCacheData()
 {
     if ( m_invalidDataReceived ) return ;
-    if ( m_threadData.length() == 0 ) return ;
+    if ( m_threadData.isEmpty() ) return ;
 
     m_dataSize += m_threadData.length();
 
@@ -99,7 +99,7 @@
         fwrite( m_threadData.data(), m_threadData.length(), 1, fs );
         fclose( fs );
     }
-    m_threadData = QString::null; /* clear baffer */
+    m_threadData.clear(); /* clear baffer */
 
     return ;
 }
@@ -109,7 +109,7 @@
 {
     /* init */
     m_readNum = readNum;
-    m_threadData = QString::null;
+    m_threadData.clear();
     m_firstReceive = FALSE;
     m_invalidDataReceived = FALSE;
     m_lastLine.clear();
@@ -251,6 +251,7 @@
         if ( ! lineList[ i ].isEmpty() ) {
 
             QString line, line2;
+            QByteArray ba;
             int nextNum = m_readNum + 1;
 
             /* convert line */
@@ -259,34 +260,38 @@
             case Board_MachiBBS:
                 line = Kita::qcpToUnicode( lineList[i] );
                 line2 = Kita::ParseMachiBBSOneLine( line, nextNum );
+                ba = Kita::unicodeToQcp( line2 );
                 break;
 
             case Board_JBBS:
                 line = Kita::eucToUnicode( lineList[i] );
                 line2 = Kita::ParseJBBSOneLine( line, nextNum );
+                ba = Kita::unicodeToEuc( line2 );
                 break;
 
             case Board_FlashCGI:
                 line = Kita::qcpToUnicode( lineList[i] );
                 line2 = Kita::ParseFlashCGIOneLine( line );
+                ba = Kita::unicodeToQcp( line2 );
                 break;
 
             default:
                 line = line2 = Kita::qcpToUnicode( lineList[i] );
+                ba = lineList[i];
             }
 
             if ( line2 == QString::null ) continue;
 
             /* add abone lines */
-            const QString aboneStr = "abone<><><>abone<>";
+            const char aboneStr[] = "abone<><><>abone<>";
             while ( nextNum > m_readNum + 1 ) {
                 datLineList += aboneStr;
-                m_threadData += aboneStr + "\n";
+                m_threadData += aboneStr + '\n';
                 ++m_readNum;
             }
 
             /* save line */
-            if ( m_bbstype == Board_MachiBBS ) m_threadData += line2 + "\n";
+            if ( m_bbstype == Board_MachiBBS ) m_threadData += ba + "\n";
             else m_threadData += lineList[ i ] + "\n";
             ++m_readNum;
 
@@ -364,7 +369,7 @@
     KUrl kgetURL( getURL );
     kgetURL.addQueryItem( "sid", Account::getSessionID() );
 
-    m_threadData = "";
+    m_threadData.clear();
     m_invalidDataReceived = FALSE;
 
     KIO::SlaveConfig::self() ->setConfigData( "http",
@@ -394,7 +399,7 @@
         m_header = job->queryMetaData( "HTTP-Headers" );
     }
 
-    if ( !m_invalidDataReceived && m_threadData.length() ) {
+    if ( !m_invalidDataReceived && !m_threadData.isEmpty() ) {
         KUrl url = m_datURL;
         writeCacheData();
     }

Modified: kita/branches/KITA-KDE4/kita/src/libkita/access.h
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/access.h	2009-07-04 03:40:29 UTC (rev 2349)
+++ kita/branches/KITA-KDE4/kita/src/libkita/access.h	2009-07-04 22:50:35 UTC (rev 2350)
@@ -52,7 +52,7 @@
 
         const KUrl m_datURL;
         KIO::Job* m_currentJob;
-        QString m_threadData;
+        QByteArray m_threadData;
         QString m_header;
         int m_dataSize;
         bool m_firstReceive;

Modified: kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.cpp	2009-07-04 03:40:29 UTC (rev 2349)
+++ kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.cpp	2009-07-04 22:50:35 UTC (rev 2350)
@@ -82,8 +82,19 @@
     return Kita::eucCodec->toUnicode( str );
 }
 
+QByteArray Kita::unicodeToQcp( const QString& str )
+{
+    if ( !Kita::qcpCodec ) Kita::qcpCodec = QTextCodec::codecForName("Shift-JIS"); // TODO
+    return Kita::qcpCodec->fromUnicode( str );
+}
 
+QByteArray Kita::unicodeToEuc( const QString& str )
+{
+    if ( !Kita::eucCodec ) Kita::eucCodec = QTextCodec::codecForName( "eucJP" );
 
+    return Kita::eucCodec->fromUnicode( str );
+}
+
 /*------------------------------------------------------------*/
 /*------------------------------------------------------------*/
 

Modified: kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.h
===================================================================
--- kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.h	2009-07-04 03:40:29 UTC (rev 2349)
+++ kita/branches/KITA-KDE4/kita/src/libkita/kita_misc.h	2009-07-04 22:50:35 UTC (rev 2350)
@@ -38,6 +38,8 @@
     QString qcpToUnicode( const QByteArray& str );
     QString utf8ToUnicode( const QByteArray& str );
     QString eucToUnicode( const QByteArray& str );
+    QByteArray unicodeToQcp( const QString& str );
+    QByteArray unicodeToEuc( const QString& str );
     QString encode_string(const QString &str, int encoding_hint);
 
 



Kita-svn メーリングリストの案内
アーカイブの一覧に戻る