OSDN Git Service

>>42
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 31 Jul 2004 15:47:23 +0000 (15:47 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 31 Jul 2004 15:47:23 +0000 (15:47 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1269 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/kita.cpp
kita/src/libkita/kita_misc.cpp
kita/src/libkita/parsemisc.cpp

index 1de58b9..31b9d51 100644 (file)
@@ -292,9 +292,9 @@ void KitaMainWindow::setupActions()
 
 void KitaMainWindow::slotURLLine()
 {
-    QString text = m_urlLine->text();
-    QString datURL = Kita::threadToDat( text );
-    m_threadTab->showThread( datURL, KitaConfig::alwaysUseTab() );
+    KURL url = m_urlLine->text();
+    KURL datURL = Kita::ParseMisc::parseURLonly( url );
+    m_threadTab->showThread( datURL.prettyURL(), KitaConfig::alwaysUseTab() );
 }
 
 void KitaMainWindow::saveProperties( KConfig* config )
index 8e88405..6273239 100644 (file)
@@ -20,10 +20,10 @@ QString Kita::datToBoard( const QString& datURL )
 
 QString Kita::datToThread( const QString& datURL )
 {
-    // http://<host>/<board>/dat/<datname>.dat
+    // http://<root>/<board>/dat/<datname>.dat
     KURL url( datURL );
     QString protocol = url.protocol();
-    QString host = url.host();
+    QString root = url.host();
 
     QStringList list = QStringList::split( ".", url.fileName() );
     if ( list.size() != 2 ) {
@@ -40,17 +40,15 @@ QString Kita::datToThread( const QString& datURL )
     QString board = url.fileName();
 
     url.cd( ".." );
-    if ( url.fileName() != "" ) {
-        return "";
+    if ( url.path() != "/" ) {
+       root += url.path();
     }
 
-    KURL newURL;
-    newURL.setProtocol( protocol );
-    newURL.setHost( host );
+    KURL newURL = protocol + "://" + root;
 
     // FIXME: TOOOOOOOOOOOOOOOOOOOOOO ugly.
     QRegExp host_machibbs( ".*\\.machi\\.to" );
-    if ( host_machibbs.search( host ) != -1 ) {
+    if ( host_machibbs.search( root ) != -1 ) {
         newURL.addPath( "/bbs/read.pl" );
         newURL.addQueryItem( "BBS", board );
         newURL.addQueryItem( "KEY", datName );
@@ -100,10 +98,9 @@ QString Kita::subjectToBoard( const QString& subjectURL )
 
 QString Kita::datToCache( const QString& datURL )
 {
-    // http://<host>/<board>/dat/<datname>.dat
+    // http://<root>/<board>/dat/<datname>.dat
     KURL url( datURL );
-    QString protocol = url.protocol();
-    QString host = url.host();
+    QString root = url.host();
     QString filename = url.fileName();
 
     url.cd( ".." );
@@ -115,11 +112,11 @@ QString Kita::datToCache( const QString& datURL )
     QString board = url.fileName();
 
     url.cd( ".." );
-    if ( url.fileName() != "" ) {
-        return QString::null;
+    if ( url.path() != "/" ) {
+       root += url.path().replace( "/", "." );
     }
 
-    return QString( "%1/%2/%3" ).arg( host ).arg( board ).arg( filename );
+    return QString( "%1/%2/%3" ).arg( root ).arg( board ).arg( filename );
 }
 
 QString Kita::httpToK2ch( const QString& httpURL )
index 7bf1466..e0a0cc2 100644 (file)
@@ -962,7 +962,8 @@ bool ParseMisc::parseResDat(RESDAT& resdat, QString& subject)
        parseBODYdatText( PARSEMODE_TEXT, resdat.name, resdat.parsedName );
        resdat.address = list[ 1 ];
        parseDateId(list[ 2 ],resdat.id,resdat.dateId,resdat.dateTime );
-       resdat.body = list[ 3 ].mid( 1 ); /* remove space after <> */
+       if( list[ 3 ].at( 0 ) == ' ' ) resdat.body = list[ 3 ].mid( 1 ); /* remove space after <> */
+       else resdat.body = list[ 3 ];
 
        /* get subject */
        if (list[ 4 ] != QString::null ) {
@@ -1054,31 +1055,46 @@ refstr = 1-100                                                */ /* public */
 KURL ParseMisc::parseURL( const KURL& url , QString& refstr )
 {
     KURL newURL = url;
+    QString root;
+    QString board;
+    QString thread;
+    QString refBase;
     refstr = QString::null;
-    
-    if ( url.path().contains( "/test/read.cgi" ) ) {
-        QString tmp = url.path().section( "/test/read.cgi", 1 );
 
-        QString newPath = QString( "/%1/dat/%2.dat" )
-                          .arg( tmp.section( '/', 1, 1 ) )
-                          .arg( tmp.section( '/', 2, 2 ) );
-        newURL.setPath( newPath );
+    if ( url.path().contains( "/read.cgi" ) ) {
 
-        QString refBase = tmp.section( '/', 3 );
-        if ( ! refBase.isEmpty() ) {
+       if ( url.path().contains( "/test/read.cgi" ) ) /* 2ch */
+           root = url.prettyURL().section( "/test/read.cgi", 0, 0 );
+       else root = url.prettyURL().section( "/read.cgi", 0, 0 );
 
-            if ( refBase.at( 0 ) == '-' ) refstr = "1" + refBase;
-            else refstr = refBase;
-        }
+       QString tmp = url.path().section( "/read.cgi", 1 );
+       
+       board = tmp.section( '/', 1, 1 );
+       thread = tmp.section( '/', 2, 2 );
+       refBase = tmp.section( '/', 3, 3 );
+       
+       QRegExp reg( "\\d+" );
+       if( reg.exactMatch( thread ) ){
+       
+           QString newPath = QString( "/%1/dat/%2.dat" ).arg( board ).arg( thread );
+
+           newURL = root + newPath;
+
+           if ( ! refBase.isEmpty() ){
+               if ( refBase.at( 0 ) == '-' ) refstr = "1" + refBase;
+               else refstr = refBase;
+           }
+
+           return newURL;
+       }
     }
-    else
-    {
+    
        if( newURL.hasRef() ) 
        {
            refstr = newURL.ref();
            newURL = newURL.protocol() + "://" + newURL.host() + newURL.path();
        }
-    }
+
 
     kdDebug() << "newURL: " << newURL.url() << endl;
     return newURL;