1 /***************************************************************************
2 * Copyright (C) 2003 by Hideki Ikemoto *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
13 #include <kstandarddirs.h>
15 #include "boarddatabase.h"
19 Cache::Cache(const KUrl& url) : m_url(url)
23 QString Cache::baseDir()
25 QString dir = KGlobal::dirs() ->saveLocation("cache", "kita");
26 if (dir[ dir.length() - 1 ] != '/')
33 QString Cache::serverDir() const
35 /* Is board enrolled ? */
36 BoardDatabase db(m_url);
37 BoardData * bdata = db.getBoardData();
38 if (bdata == 0) return QString();
40 QString root = bdata->hostName() + bdata->rootPath();
42 return root.remove("http://").replace('/', '_') + '/';
46 QString Cache::boardDir() const
48 /* Is board enrolled ? */
49 BoardDatabase db(m_url);
50 BoardData * bdata = db.getBoardData();
51 if (bdata == 0) return QString();
53 QString bbs = bdata->bbsPath();
55 return bbs.mid(1).replace('/', '_') + '/';
59 QString Cache::getPath() const
61 QString path = getDirPath();
62 if (path.isEmpty()) return QString();
64 // qDebug("%s -> %s",url.prettyUrl().ascii(),path.ascii());
66 return path + m_url.fileName();
69 QString Cache::getIndexPath() const
71 QString path = getPath();
80 /*------------------------------------*/
81 /* for SETTING.TXT and BBS history */
85 QString Cache::getSettingPath() const
87 QString path = getDirPath();
88 if (path.isEmpty()) return QString();
90 return path + "SETTING.TXT";
94 QString Cache::getBBSHistoryPath() const
96 QString path = getDirPath();
97 if (path.isEmpty()) return QString();
99 return path + "BBSHISTORY";
103 QString Cache::getSubjectPath() const
105 QString path = getDirPath();
106 if (path.isEmpty()) return QString();
108 return path + "subject.txt";
111 QString Cache::getDirPath() const
113 return baseDir() + serverDir() + boardDir();