svnno****@sourc*****
svnno****@sourc*****
2009年 7月 29日 (水) 23:20:46 JST
Revision: 2495 http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2495 Author: nogu Date: 2009-07-29 23:20:46 +0900 (Wed, 29 Jul 2009) Log Message: ----------- add Bbs class as a super class of JBBS, FlashCGI, MachiBBS and K2ch Modified Paths: -------------- kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.cpp kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.h kita/branches/KITA-KDE4/kita/src/libkita/jbbs.cpp kita/branches/KITA-KDE4/kita/src/libkita/jbbs.h kita/branches/KITA-KDE4/kita/src/libkita/k2ch.cpp kita/branches/KITA-KDE4/kita/src/libkita/k2ch.h kita/branches/KITA-KDE4/kita/src/libkita/machibbs.cpp kita/branches/KITA-KDE4/kita/src/libkita/machibbs.h kita/branches/KITA-KDE4/kita/src/writeview.cpp kita/branches/KITA-KDE4/kita/src/writeview.h Added Paths: ----------- kita/branches/KITA-KDE4/kita/src/libkita/bbs.cpp kita/branches/KITA-KDE4/kita/src/libkita/bbs.h Added: kita/branches/KITA-KDE4/kita/src/libkita/bbs.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/bbs.cpp (rev 0) +++ kita/branches/KITA-KDE4/kita/src/libkita/bbs.cpp 2009-07-29 14:20:46 UTC (rev 2495) @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2006 by Kita Developers * + * ikemo****@users***** * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "k2ch.h" + +#include <QtCore/QTextCodec> + +#include "kita_misc.h" + +using namespace Kita; + +K2ch::K2ch() +{ +} + + +K2ch::~K2ch() +{ +} + +QString K2ch::buildPostStr(const QString& name, const QString& mail, + const QString& body, const QString& boardID, + const QString& threadID, int serverTime, + const QString& sessionID) +{ + QString ret; + QTextCodec* codec = QTextCodec::codecForName("Shift-JIS"); + + int mib = codec->mibEnum(); + + (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */ + + /* from, mail, message, bbs */ + (ret += "&FROM=") += encode_string(name, mib); + (ret += "&mail=") += encode_string(mail, mib); + (ret += "&MESSAGE=") += encode_string(body, mib); + (ret += "&bbs=") += boardID; + (ret += "&tepo=don"); + + /* key */ + (ret += "&key=") += threadID; + + /* time */ + (ret += "&time=") += QString::number(serverTime); + + /* login */ + if (! sessionID.isEmpty()) { + (ret += "&sid=") += sessionID; + } + + return ret; +} Added: kita/branches/KITA-KDE4/kita/src/libkita/bbs.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/bbs.h (rev 0) +++ kita/branches/KITA-KDE4/kita/src/libkita/bbs.h 2009-07-29 14:20:46 UTC (rev 2495) @@ -0,0 +1,26 @@ +/*************************************************************************** + * Copyright (C) 2006 by Kita Developers * + * ikemo****@users***** * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef BBS_H +#define BBS_H + +#include <kdemacros.h> + + +namespace Kita { + class PostData; + + class KDE_EXPORT Bbs { + public: + virtual ~Bbs() { } + virtual QString buildPostStr(const PostData& data) = 0; + }; +} + +#endif Modified: kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.cpp 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.cpp 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,30 +12,22 @@ #include <QtCore/QTextCodec> #include "kita_misc.h" +#include "postdata.h" using namespace Kita; -FlashCGI::FlashCGI() +QString FlashCGI::buildPostStr(const PostData& data) { -} - - -FlashCGI::~FlashCGI() -{ -} - -QString FlashCGI::buildPostStr(const QString & name, const QString & mail, const QString & body, const QString & boardID, const QString & threadID) -{ QString ret; QTextCodec* codec = QTextCodec::codecForName("Shift-JIS"); int mib = codec->mibEnum(); (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */ - (ret += "&FROM=") += encode_string(name, mib); - (ret += "&mail=") += encode_string(mail, mib); - (ret += "&MESSAGE=") += encode_string(body, mib); - (ret += "&bbs=") += boardID; - (ret += "&key=") += threadID; + (ret += "&FROM=") += encode_string(data.name(), mib); + (ret += "&mail=") += encode_string(data.mail(), mib); + (ret += "&MESSAGE=") += encode_string(data.body(), mib); + (ret += "&bbs=") += data.boardId(); + (ret += "&key=") += data.threadId(); return ret; } Modified: kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.h 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/flashcgi.h 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,19 +12,17 @@ #include <QtCore/QString> -#include <kdemacros.h> +#include "bbs.h" -/** - @author Hideki Ikemoto <ikemo****@users*****> -*/ -class KDE_EXPORT FlashCGI { -public: - static QString buildPostStr(const QString& name, const QString& mail, const QString& body, const QString& boardID, const QString& threadID); +namespace Kita { + /** + @author Hideki Ikemoto <ikemo****@users*****> + */ + class KDE_EXPORT FlashCGI : public Bbs { + public: + QString buildPostStr(const PostData& data); -private: - FlashCGI(); - ~FlashCGI(); + }; +} -}; - #endif Modified: kita/branches/KITA-KDE4/kita/src/libkita/jbbs.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/jbbs.cpp 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/jbbs.cpp 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,32 +12,24 @@ #include <QtCore/QTextCodec> #include "kita_misc.h" +#include "postdata.h" using namespace Kita; -JBBS::JBBS() +QString JBBS::buildPostStr(const PostData& data) { -} - - -JBBS::~JBBS() -{ -} - -QString JBBS::buildPostStr(const QString& name, const QString& mail, const QString& body, const QString& boardID, const QString& threadID, int serverTime) -{ QString ret; QTextCodec* codec = QTextCodec::codecForName("Shift-JIS"); int mib = codec->mibEnum(); (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */ - (ret += "&NAME=") += encode_string(name, mib); - (ret += "&MAIL=") += encode_string(mail, mib); - (ret += "&MESSAGE=") += encode_string(body, mib).replace(';', "%3B"); - (ret += "&BBS=") += boardID.section('/', 1, 1); - (ret += "&DIR=") += boardID.section('/', 0, 0); - (ret += "&KEY=") += threadID; - (ret += "&TIME=") += QString::number(serverTime); + (ret += "&NAME=") += encode_string(data.name(), mib); + (ret += "&MAIL=") += encode_string(data.mail(), mib); + (ret += "&MESSAGE=") += encode_string(data.body(), mib).replace(';', "%3B"); + (ret += "&BBS=") += data.boardId().section('/', 1, 1); + (ret += "&DIR=") += data.boardId().section('/', 0, 0); + (ret += "&KEY=") += data.threadId(); + (ret += "&TIME=") += QString::number(data.serverTime()); return ret; } Modified: kita/branches/KITA-KDE4/kita/src/libkita/jbbs.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/jbbs.h 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/jbbs.h 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,19 +12,16 @@ #include <QtCore/QString> -#include <kdemacros.h> +#include "bbs.h" -/** - @author Hideki Ikemoto <ikemo****@users*****> -*/ -class KDE_EXPORT JBBS { -public: - static QString buildPostStr(const QString& name, const QString& mail, const QString& body, const QString& boardID, const QString& threadID, int serverTime); +namespace Kita { + /** + @author Hideki Ikemoto <ikemo****@users*****> + */ + class KDE_EXPORT JBBS : public Bbs { + public: + QString buildPostStr(const PostData& data); + }; +} -private: - JBBS(); - ~JBBS(); - -}; - #endif Modified: kita/branches/KITA-KDE4/kita/src/libkita/k2ch.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/k2ch.cpp 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/k2ch.cpp 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,23 +12,12 @@ #include <QtCore/QTextCodec> #include "kita_misc.h" +#include "postdata.h" using namespace Kita; -K2ch::K2ch() +QString K2ch::buildPostStr(const PostData& data) { -} - - -K2ch::~K2ch() -{ -} - -QString K2ch::buildPostStr(const QString& name, const QString& mail, - const QString& body, const QString& boardID, - const QString& threadID, int serverTime, - const QString& sessionID) -{ QString ret; QTextCodec* codec = QTextCodec::codecForName("Shift-JIS"); @@ -37,21 +26,21 @@ (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */ /* from, mail, message, bbs */ - (ret += "&FROM=") += encode_string(name, mib); - (ret += "&mail=") += encode_string(mail, mib); - (ret += "&MESSAGE=") += encode_string(body, mib); - (ret += "&bbs=") += boardID; + (ret += "&FROM=") += encode_string(data.name(), mib); + (ret += "&mail=") += encode_string(data.mail(), mib); + (ret += "&MESSAGE=") += encode_string(data.body(), mib); + (ret += "&bbs=") += data.boardId(); (ret += "&tepo=don"); /* key */ - (ret += "&key=") += threadID; + (ret += "&key=") += data.threadId(); /* time */ - (ret += "&time=") += QString::number(serverTime); + (ret += "&time=") += QString::number(data.serverTime()); /* login */ - if (! sessionID.isEmpty()) { - (ret += "&sid=") += sessionID; + if (!data.sessionId().isEmpty()) { + (ret += "&sid=") += data.sessionId(); } return ret; Modified: kita/branches/KITA-KDE4/kita/src/libkita/k2ch.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/k2ch.h 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/k2ch.h 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,19 +12,16 @@ #include <QtCore/QString> -#include <kdemacros.h> +#include "bbs.h" -/** - @author Hideki Ikemoto <ikemo****@users*****> -*/ -class KDE_EXPORT K2ch { -public: - static QString buildPostStr(const QString& name, const QString& mail, const QString& body, const QString& boardID, const QString& threadID, int serverTime, const QString& sessionID); +namespace Kita { + /** + @author Hideki Ikemoto <ikemo****@users*****> + */ + class KDE_EXPORT K2ch : public Bbs { + public: + QString buildPostStr(const PostData& data); + }; +} -private: - K2ch(); - ~K2ch(); - -}; - #endif Modified: kita/branches/KITA-KDE4/kita/src/libkita/machibbs.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/machibbs.cpp 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/machibbs.cpp 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,31 +12,23 @@ #include <QtCore/QTextCodec> #include "kita_misc.h" +#include "postdata.h" using namespace Kita; -MachiBBS::MachiBBS() +QString MachiBBS::buildPostStr(const PostData& data) { -} - - -MachiBBS::~MachiBBS() -{ -} - -QString MachiBBS::buildPostStr(const QString& name, const QString& mail, const QString& body, const QString& boardID, const QString& threadID, int serverTime) -{ QString ret; QTextCodec* codec = QTextCodec::codecForName("Shift-JIS"); int mib = codec->mibEnum(); (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */ - (ret += "&NAME=") += encode_string(name, mib); - (ret += "&MAIL=") += encode_string(mail, mib); - (ret += "&MESSAGE=") += encode_string(body, mib); - (ret += "&BBS=") += boardID; - (ret += "&KEY=") += threadID; - (ret += "&TIME=") += QString::number(serverTime); + (ret += "&NAME=") += encode_string(data.name(), mib); + (ret += "&MAIL=") += encode_string(data.mail(), mib); + (ret += "&MESSAGE=") += encode_string(data.body(), mib); + (ret += "&BBS=") += data.boardId(); + (ret += "&KEY=") += data.threadId(); + (ret += "&TIME=") += QString::number(data.serverTime()); return ret; } Modified: kita/branches/KITA-KDE4/kita/src/libkita/machibbs.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/machibbs.h 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/libkita/machibbs.h 2009-07-29 14:20:46 UTC (rev 2495) @@ -12,19 +12,17 @@ #include <QtCore/QString> -#include <kdemacros.h> +#include "bbs.h" -/** - @author Hideki Ikemoto <ikemo****@users*****> -*/ -class KDE_EXPORT MachiBBS { -public: - static QString buildPostStr(const QString& name, const QString& mail, const QString& body, const QString& boardID, const QString& threadID, int serverTime); +namespace Kita { + /** + @author Hideki Ikemoto <ikemo****@users*****> + */ + class KDE_EXPORT MachiBBS : public Bbs { + public: + virtual QString buildPostStr(const PostData& data); -private: - MachiBBS(); - ~MachiBBS(); + }; +} -}; - #endif Modified: kita/branches/KITA-KDE4/kita/src/writeview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/writeview.cpp 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/writeview.cpp 2009-07-29 14:20:46 UTC (rev 2495) @@ -31,6 +31,7 @@ #include "libkita/kita-utf8.h" #include "libkita/k2ch.h" #include "libkita/machibbs.h" +#include "libkita/postdata.h" #include "libkita/writeconfig.h" using namespace Kita; @@ -177,16 +178,24 @@ QString WriteView::buildPostMessage() { + PostData postData(m_datURL, name(), mail(), body(), boardID()); QString postStr; switch (m_bbstype) { + case Board_JBBS: + postStr = JBBS().buildPostStr(postData); + break; - case Board_JBBS: postStr = getJBBSPostStr(); break; + case Board_FlashCGI: + postStr = FlashCGI().buildPostStr(postData); + break; - case Board_FlashCGI: postStr = getFlashCGIPostStr(); break; + case Board_MachiBBS: + postStr = MachiBBS().buildPostStr(postData); + break; - case Board_MachiBBS: postStr = getMachiBBSPostStr(); break; - - default: postStr = getPostStr(); break; + default: + postStr = K2ch().buildPostStr(postData); + break; } return postStr; @@ -355,60 +364,6 @@ return true; } -/* create posting message for 2ch */ /* private */ -QString WriteView::getPostStr() -{ - QString sessionID; - QString threadID = DatManager::threadID(m_datURL); - int serverTime = DatManager::getServerTime(m_datURL); - - /* login */ - if (DatManager::is2chThread(m_datURL) && Account::isLogged()) { - sessionID = KUrl::toPercentEncoding(Account::getSessionID()); - } - - return K2ch::buildPostStr(name(), mail(), - body(), boardID(), - threadID, serverTime, - sessionID); -} - -QString WriteView::getMachiBBSPostStr() -{ - QString threadID = DatManager::threadID(m_datURL); - int serverTime = DatManager::getServerTime(m_datURL); - - return MachiBBS::buildPostStr(name(), mail(), - body(), boardID(), - threadID, serverTime); -} - - -/* create posting message for JBBS */ /* private */ /* private */ -QString WriteView::getJBBSPostStr() -{ - QString threadID = DatManager::threadID(m_datURL); - int serverTime = DatManager::getServerTime(m_datURL); - - return JBBS::buildPostStr(name(), mail(), - body(), boardID(), - threadID, serverTime); -} - - -/* create posting message for Flash CGI */ /* private */ /* private */ -QString WriteView::getFlashCGIPostStr() -{ - QString threadID = DatManager::threadID(m_datURL); - - QString ret; - - return FlashCGI::buildPostStr(name(), mail(), - body(), boardID(), - threadID); -} - - /* save post log */ /* private */ void WriteView::logPostMessage() { Modified: kita/branches/KITA-KDE4/kita/src/writeview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/writeview.h 2009-07-29 13:53:03 UTC (rev 2494) +++ kita/branches/KITA-KDE4/kita/src/writeview.h 2009-07-29 14:20:46 UTC (rev 2495) @@ -41,11 +41,6 @@ WriteTabWidget* m_parent; - QString getPostStr(); - QString getMachiBBSPostStr(); - QString getJBBSPostStr(); - QString getFlashCGIPostStr(); - WriteView(const WriteView&); WriteView& operator=(const WriteView&);