#include "libkita/signalcollection.h"
#include "libkita/parsemisc.h"
#include "libkita/datmanager.h"
+#include "libkita/boardmanager.h"
#include <qmap.h>
#include <qapplication.h>
QValueList<QString>::const_iterator it2;
for ( it2 = boardList.begin(); it2 != boardList.end(); ++it2 ) {
- // ³ÆÈĤÎsubject.txt¤ò¼èÆÀ¡£
- Kita::Board::getThreadList( ( *it2 ) );
+
+ bool online = TRUE;
+ QPtrList<Kita::Thread> threadList;
+ QPtrList<Kita::Thread> tmpList;
+ Kita::BoardManager::getThreadList( ( *it2 ), FALSE, online, threadList, tmpList );
}
}
#include "threadlistview.h"
-#include "libkita/board.h"
#include "libkita/thread.h"
/**
/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
+* Copyright (C) 2004 by Kita Developers *
* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
// then, setup our actions
setupActions();
- // load cache
- loadCache();
-
- // load favorites
- loadFavorites();
-
- // load favorite boards;
- loadFavoriteBoards();
-
// load completion
loadCompletion();
}
}
+ // load favorites
+ loadFavorites();
+
+ // load favorite boards;
+ loadFavoriteBoards();
+
// show board dock
m_boardDock->slotShowDock();
saveFavorites();
- saveCache();
-
saveMainWindowSettings( KGlobal::config(), "MainWindow" );
KitaConfig::writeConfig( KGlobal::config() );
}
}
-void KitaMainWindow::loadCache()
-{
- KitaThreadInfo * cache = KitaThreadInfo::getInstance();
- QString cacheConfigPath = locateLocal( "appdata", "cache" );
- QFile file( cacheConfigPath );
- if ( file.open( IO_ReadOnly ) ) {
- QDataStream stream( &file );
- stream >> *cache;
- }
-}
-
-void KitaMainWindow::saveCache()
-{
- KitaThreadInfo * cache = KitaThreadInfo::getInstance();
- QString cacheConfigPath = locateLocal( "appdata", "cache" );
- QFile file( cacheConfigPath );
- if ( file.open( IO_WriteOnly ) ) {
- QDataStream stream( &file );
- stream << *cache;
- }
-}
-
/*!
\fn KitaMainWindow::setFont(QFont& font)
*/
/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
+* Copyright (C) 2004 by Kita Developers *
* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
void setupAccel();
void setupActions();
void setupView();
- void loadCache();
- void saveCache();
void loadFavorites();
void saveFavorites();
void loadFavoriteBoards();
#include <qwidget.h>
#include <kurl.h>
#include "threadlistview.h"
-#include "libkita/board.h"
class KListViewItem;
#include "downloadmanager.h"
#include "cache.h"
#include "favoritethreads.h"
+#include "thread.h"
#include "threadinfo.h"
#include "favoriteboards.h"
-#include "datmanager.h"
#include "kita_misc.h"
+#include "threadindex.h"
#include <config.h> /* VERSION */
const QString& ext,
int boardtype )
{
+ m_readIdx = FALSE;
m_boardName = boardName;
m_rootPath = rootPath;
m_delimiter = delimiter;
/* reset SETTING.TXT */
setSettingLoaded( FALSE );
-/*
- qDebug( "%s (type = %d)", ( const char * ) m_boardName.local8Bit(),m_type );
- qDebug( "basePath: %s", m_basePath.ascii() );
- qDebug( "cgiBasePath: %s", m_cgiBasePath.ascii() );
-*/
}
BoardData::~BoardData()
/* information */
/* public */
+const bool BoardData::readIdx() const
+{
+ return m_readIdx;
+}
+
+/* public */
+void BoardData::setReadIdx( bool idx )
+{
+ m_readIdx = idx;
+}
+
+/* public */
const QString& BoardData::boardName() const
{
return m_boardName;
/*-------------------------*/
+ BoardData* bdata = getBoardData( url );
+ if( bdata == NULL ) return;
+
/* download subject.txt */
if( online ){
/* open and read subject.txt */
readSubjectTxt( url, threadList );
+ /* read idx file */
+ if( !bdata->readIdx() ){
+ getThreadInfoFromIdx( url, threadList );
+ bdata->setReadIdx( TRUE );
+ }
+
/* get old logs */
if( oldLogs ){
}
+/* read idx file and get information */ /* private */ /* static */
+void BoardManager::getThreadInfoFromIdx( const KURL& url, QPtrList< Thread >& threadList )
+{
+ QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
+ QDir d( cacheDir );
+ if ( d.exists() ) {
+ qDebug( "readIndexFile: %s", cacheDir.ascii() );
+
+ /* get all file names */
+ QString ext = BoardManager::getBoardData( url )->ext();
+ QStringList flist = d.entryList( "*" + ext );
+
+ unsigned int count = threadList.count();
+ for ( unsigned i = 0; i < count; i++ ) {
+
+ Kita::Thread* thread = threadList.at( i );
+ QString fname = KURL( thread->datURL() ).filename();
+ if( flist.contains( fname ) ){
+
+ int readNum = QMAX( ThreadIndex::getReadNum( thread->datURL() ), 1 );
+ KitaThreadInfo::setReadNum( thread->datURL(), readNum );
+ qDebug( "%s : %d",(const char*)thread->threadName().local8Bit(), readNum );
+ }
+ }
+ }
+}
+
+
/* read the cache dir & get the list of all threads. */ /* private */ /* static */
void BoardManager::getCachedThreadList( const KURL& url, QPtrList< Thread >& threadList )
QString cacheDir = Cache::baseDir() + Cache::serverDir( url ) + Cache::boardDir( url );
QDir d( cacheDir );
if ( d.exists() ) {
- qDebug( "search: %s", cacheDir.ascii() );
/* get all file names */
QString ext = BoardManager::getBoardData( url )->ext();
if ( ( *it ) == QString::null ) continue;
QString datURL = boardURL + "dat/" + ( *it );
-
- QString subject = DatManager::threadName( datURL );
- if ( subject == QString::null ) Kita::Thread::setName( datURL, "?" );
- else Kita::Thread::setName( datURL, subject );
- int readNum = KitaThreadInfo::readNum( datURL );
- if ( KitaThreadInfo::resNum( datURL ) < readNum ) KitaThreadInfo::setResNum( datURL, readNum );
+ /* read idx file */
+ if( Kita::Thread::getByURLNew( datURL ) == NULL ){
+
+ QString subject = Kita::ThreadIndex::getSubject( datURL );
+ if ( subject == QString::null ) subject = "?";
+ Kita::Thread::setName( datURL, subject );
+
+ int resNum = QMAX( 1, Kita::ThreadIndex::getResNum( datURL ) );
+ KitaThreadInfo::setResNum( datURL, resNum );
+ int readNum = QMAX( 1, Kita::ThreadIndex::getReadNum( datURL ) );
+ KitaThreadInfo::setReadNum( datURL, readNum );
+ }
+
Kita::Thread* thread = Kita::Thread::getByURL( datURL );
threadList.append( thread );
-
-// qDebug( "url: %s : %s", datURL.ascii(), ( const char * ) subject.local8Bit() );
}
}
}
+
/* open subject.txt and get list of Thread classes */ /* private */ /* static */
bool BoardManager::readSubjectTxt( const KURL& url, QPtrList< Thread >& threadList )
{
class BoardData
{
QString m_boardName;
+ bool m_readIdx; /* If TRUE, idx file has been read. */
QString m_hostname; /* latest host name */
QString m_rootPath;
void setHostName( const QString& hostname );
/* information */
+ const bool readIdx() const;
+ void setReadIdx( bool idx );
const QString& boardName() const;
const QString& hostName() const;
const QString& rootPath() const;
/* ThreadList */
+ static void getThreadInfoFromIdx( const KURL& url, QPtrList< Thread >& threadList );
static void getCachedThreadList( const KURL& url, QPtrList< Thread >& threadList );
static bool readSubjectTxt( const KURL& url, QPtrList< Thread >& threadList );
const QString DatManager::threadName( const KURL& url )
{
KURL datURL = Kita::getDatURL( url );
- QString subject = Kita::Thread::getName( datURL );
-
- if( subject == QString::null ){
- subject = Kita::ThreadIndex::getSubject( datURL );
- if( subject != QString::null ) Kita::Thread::setName( datURL.prettyURL(), subject );
- }
-
- return subject;
+ return Kita::Thread::getName( datURL );
}
/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
-* ikemo@wakaba.jp *
+* Copyright (C) 2004 by Kita Developers *
+* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* (at your option) any later version. *
***************************************************************************/
#include "favoriteboards.h"
-
-#include "board.h"
+#include "boardmanager.h"
#include <qdom.h>
void FavoriteBoards::processChildNode( QDomNode& node )
{
QDomNode urlNode = node.namedItem( "url" );
- QDomNode nameNode = node.namedItem( "name" );
- if ( ! urlNode.isElement() || ! nameNode.isElement() ) {
- return ;
- }
+ if ( ! urlNode.isElement() ) return;
QString urlText = urlNode.toElement().text();
- QString nameText = nameNode.toElement().text();
KURL url = KURL( urlText );
if ( url.isValid() ) {
- Kita::Board::setName( urlText, nameText );
//FavoriteBoards::append( url );
if ( !getInstance()->m_list.contains( url ) )
getInstance()->m_list.append( url );
board.appendChild( urlElement );
urlElement.appendChild( document.createTextNode( boardURL ) );
- QString boardName = Kita::Board::getName( boardURL );
+ QString boardName = Kita::BoardManager::boardName( boardURL );
QDomElement nameElement = document.createElement( "name" );
board.appendChild( nameElement );
nameElement.appendChild( document.createTextNode( boardName ) );
/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
+* Copyright (C) 2004 by Kita Developers *
* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
***************************************************************************/
#include "favoritethreads.h"
+#include "thread.h"
+#include "threadinfo.h"
+#include "threadindex.h"
#include <kdebug.h>
#include <qstylesheet.h>
#include <qdom.h>
-#include "threadinfo.h"
-#include "board.h"
-#include "kita_misc.h"
-
FavoriteThreads* FavoriteThreads::instance = 0;
FavoriteThreads::FavoriteThreads()
bool FavoriteThreads::readFromXML( const QString& xml )
{
+ qDebug("readFromXML");
FavoriteThreads * instance = FavoriteThreads::getInstance();
instance->m_threadList.clear();
void FavoriteThreads::processThreadNode( QDomNode& node )
{
QDomNode datURLNode = node.namedItem( "daturl" );
- QDomNode nameNode = node.namedItem( "name" );
- QDomNode resNumNode = node.namedItem( "resnum" );
- QDomNode boardNode = node.namedItem( "board" );
-
- if ( !datURLNode.isElement() || !nameNode.isElement() ||
- !resNumNode.isElement() || !boardNode.isElement() ) {
- return ;
- }
- if ( boardNode.namespaceURI() != QString( "http://kita.sourceforge.jp/ns/board" ) ) {
- return ;
- }
- if ( !processBoardNode( boardNode ) ) {
- return ;
- }
- QString datURLText = datURLNode.toElement().text();
- QString nameText = nameNode.toElement().text();
- int resNum = resNumNode.toElement().text().toInt();
- Kita::Thread::setName( datURLText, QStyleSheet::escape( nameText ) );
- KitaThreadInfo::setResNum( datURLText, resNum );
+ if ( !datURLNode.isElement() ) return;
+
+ QString datURL = datURLNode.toElement().text();
- FavoriteThreads::getInstance() ->insert( datURLText );
-}
+ QString subject = Kita::ThreadIndex::getSubject( datURL );
+ if ( subject == QString::null ) subject = "?";
+ Kita::Thread::setName( datURL, subject );
-bool FavoriteThreads::processBoardNode( QDomNode& node )
-{
- QDomNode urlNode = node.namedItem( "url" );
- QDomNode nameNode = node.namedItem( "name" );
- if ( ! urlNode.isElement() || ! nameNode.isElement() ) {
- return false;
- }
+ int resNum = QMAX( 1, Kita::ThreadIndex::getResNum( datURL ) );
+ KitaThreadInfo::setResNum( datURL, resNum );
- QString urlText = urlNode.toElement().text();
- QString nameText = nameNode.toElement().text();
-
- KURL url = KURL( urlText );
- if ( url.isValid() ) {
- Kita::Board::setName( urlText, nameText );
- return true;
- }
- return false;
+ int readNum = QMAX( 1, Kita::ThreadIndex::getReadNum( datURL ) );
+ KitaThreadInfo::setReadNum( datURL, readNum );
+
+ FavoriteThreads::getInstance() ->insert( datURL );
}
const QString FavoriteThreads::toXML() const
QString threadName = Kita::Thread::getName( datURL );
QDomElement nameElement = document.createElement( "name" );
threadElement.appendChild( nameElement );
- nameElement.appendChild( document.createTextNode( Kita::unescape( threadName ) ) );
-
- QString resNum = QString::number( KitaThreadInfo::resNum( datURL ) );
- QDomElement resNumElement = document.createElement( "resnum" );
- threadElement.appendChild( resNumElement );
- resNumElement.appendChild( document.createTextNode( resNum ) );
-
- // board
- QDomElement board = document.createElementNS( "http://kita.sourceforge.jp/ns/board", "board" );
- threadElement.appendChild( board );
-
- QString boardURL = Kita::datToBoard( datURL );
- QDomElement boardURLElement = document.createElement( "url" );
- board.appendChild( boardURLElement );
- boardURLElement.appendChild( document.createTextNode( boardURL ) );
-
- QString boardName = Kita::Board::getName( boardURL );
- QDomElement boardNameElement = document.createElement( "name" );
- board.appendChild( boardNameElement );
- boardNameElement.appendChild( document.createTextNode( boardName ) );
+ nameElement.appendChild( document.createTextNode( threadName ) );
}
return document.toString( 0 );
}
/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
+* Copyright (C) 2004 by Kita Developers *
* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
#include <qptrlist.h>
#include <qdict.h>
-#include "thread.h"
-
class QDomNode;
/**
const QString toXML() const;
static bool readFromXML( const QString& xml );
static void processThreadNode( QDomNode& node );
- static bool processBoardNode( QDomNode& node );
static void replace( QString fromURL, QString toURL );
};
/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
+* Copyright (C) 2004 by Kita Developers *
* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
***************************************************************************/
#include "thread.h"
+#include "qcp932codec.h"
#include <config.h>
#include <qapplication.h>
#include <qregexp.h>
-#include "board.h"
-#include "kita_misc.h"
-#include "qcp932codec.h"
-#include "threadinfo.h"
using namespace Kita;
m_threadDict->remove( url );
url = url.replace( 0, fromURL.length(), toURL );
thread->m_datURL = url;
- Kita::Board::replace( fromURL, toURL );
m_threadDict->insert( url, thread );
it.toFirst();
}
#include "libkita/kitaconfig.h"
#include "libkita/kita-utf8.h"
-#include "libkita/threadinfo.h"
#include "libkita/qcp932codec.h"
#include "libkita/favoritethreads.h"
#include "libkita/favoriteboards.h"
#include "libkita/datmanager.h"
-#include "libkita/parsemisc.h"
-#include "libkita/board.h"
+#include "libkita/boardmanager.h"
#include "libkita/signalcollection.h"
#include "libkita/kita_misc.h"
void KitaSubjectLabel::popupCopyToClipboard()
{
QClipboard * clipboard = QApplication::clipboard();
- QString text = QString( "%1\n%2" ).arg( Kita::Board::getName( m_popupURL ) ).arg( m_popupURL );
+ QString text = QString( "%1\n%2" ).arg( Kita::BoardManager::boardName( m_popupURL ) ).arg( m_popupURL );
kdDebug() << "popupCopytoClipboard :" << endl << text << endl;
clipboard->setText( text , QClipboard::Clipboard );
clipboard->setText( text , QClipboard::Selection );
/*---------------------------------------*/
/* setup */
- m_datURL = Kita::ParseMisc::parseURLonly( datURL );
+ m_datURL = Kita::getDatURL( datURL );
/* setup HTMLPart */
int partMode = HTMLPART_MODE_MAINPART;
/* reset search direction */
m_revsearch = FALSE;
+
+ /* load SETTING.TXT */
+ Kita::BoardManager::loadBBSSetting( m_datURL, FALSE );
}
setActiveWindow();
if ( m_threadPart->reload( jumpNum ) ) {
- showStatusBar( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_NOWRENEW ) );
+ showStatusBar( Kita::utf8ToUnicode( KITAUTF8_NOWRENEW ) );
}
}
m_serverTime = Kita::DatManager::getServerTime( m_datURL );
/* uptate informations */
- setSubjectLabel( Kita::DatManager::thread_boardName( m_datURL ),
- Kita::DatManager::thread_name( m_datURL )
+ setSubjectLabel( Kita::BoardManager::boardName( m_datURL ),
+ Kita::DatManager::threadName( m_datURL )
+ QString( " (%1)" )
.arg( Kita::DatManager::getReadNum( m_datURL ) ),
- Kita::DatManager::thread_boardURL( m_datURL ) );
+ Kita::BoardManager::boardURL( m_datURL ) );
updateButton();
gotoCombo->clear();
- gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_GOTO ) );
- gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_KOKOYON ) );
+ gotoCombo->insertItem( Kita::utf8ToUnicode( KITAUTF8_GOTO ) );
+ gotoCombo->insertItem( Kita::utf8ToUnicode( KITAUTF8_KOKOYON ) );
for ( int i = 1; i < Kita::DatManager::getReadNum( m_datURL ); i += 100 ) {
gotoCombo->insertItem( QString().setNum( i ) + "-" );
}
- gotoCombo->insertItem( Kita::ParseMisc::utf8ToUnicode( KITAUTF8_SAIGO ) );
+ gotoCombo->insertItem( Kita::utf8ToUnicode( KITAUTF8_SAIGO ) );
gotoCombo->adjustSize();
emit updateSubjectTab( m_datURL );
if ( comboStr != NULL ) SearchCombo->insertItem( comboStr );
if ( labelStr != QString::null ) {
QString str = QString( "<a href=\"%1\">[%2]</a> " )
- .arg( Kita::DatManager::thread_boardURL( m_datURL ) )
- .arg( Kita::DatManager::thread_boardName( m_datURL ) ) + labelStr;
+ .arg( Kita::BoardManager::boardURL( m_datURL ) )
+ .arg( Kita::BoardManager::boardName( m_datURL ) ) + labelStr;
subjectLabel->setText( str );
}