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 */
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);
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;
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;
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);
QString datUrl = boardUrl + "dat/" + file;
- /* read idx file */
+ // read idx file
Thread* thread = Thread::getByUrlNew(datUrl);
if (thread == 0) {
/* 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);
}
}
- /* open subject.txt */
+ // open subject.txt
Cache cache(m_url);
QString subjectPath = cache.getSubjectPath();
QIODevice * device = KFilterDev::deviceForFile(subjectPath, "application/x-gzip");
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);
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)) {
}
}
- /* 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) {
}
device->close();
- bdata->setReadIdx(true); /* never read idx files again */
+ bdata->setReadIdx(true); // never read idx files again
return true;
}
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) {
&& 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);
bbsPath.clear();
ext.clear();
- /* decide type */
+ // decide type
if (type == Board_Unknown) {
if (m_url.host().contains("machi.to"))
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);
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();
ext = ".dat";
break;
- default: /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
+ default: // 2ch : http://(hostname)/(rootPath)/(bbsPath)/
delimiter = "/test/read.cgi";
bbsPath = m_url.fileName();
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);
return 0;
QString urlstr = url.prettyUrl();
- /* cache */
+ // cache
if (m_previousBoardData != 0 && m_previousBoardUrl == urlstr)
return m_previousBoardData;
if (urlstr.contains(data->keyBasePathList()[i])
|| urlstr.contains(data->keyCgiBasePathList()[i])) {
- /* cache */
+ // cache
m_previousBoardData = data;
m_previousBoardUrl = urlstr;
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);
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);
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)) {
file.close();
}
- /*---------------------------*/
- /* update BBSHISTRY */
+ //---------------------------
+ // update BBSHISTRY
Cache historyCache(bdata->basePath());
QFile file(historyCache.getBBSHistoryPath());
}
- /*---------------------------*/
- /* update other information */
+ //---------------------------
+ // update other information
FavoriteThreads::replace(oldUrl, newUrl);
Thread::replace(oldUrl, newUrl);
ThreadInfo::replace(oldUrl, newUrl);