kimixi0_4
・文字化けを解決(要テスト)
・無限ループによる応答停止を排除
・ログインできなかった時にSetting画面をイモーダルに生成
・起動時にSetting画面を最初に生成する
@@ -0,0 +1,87 @@ | ||
1 | +#ifndef KIMIXIDIALOG_H | |
2 | +#define KIMIXIDIALOG_H | |
3 | + | |
4 | +#include <QtGui/QWidget> | |
5 | +#include <QSystemTrayIcon> | |
6 | +#include <QFile> | |
7 | +#include <QBuffer> | |
8 | +#include <QTextCodec> | |
9 | +#include <QSemaphore> | |
10 | +#include "dialogSetting.h" | |
11 | +#include "../ui_kimixiDialog.h" | |
12 | +#include "kimixiCore.h" | |
13 | + | |
14 | +class kimixiDialog : public QWidget, public Ui::kimixiDialog | |
15 | +{ | |
16 | + Q_OBJECT | |
17 | + | |
18 | +public: | |
19 | + kimixiDialog(QWidget *parent = 0); | |
20 | + ~kimixiDialog(); | |
21 | + QString UserName; | |
22 | + QString Password; | |
23 | + QBuffer dataBuf; | |
24 | + //QFile *stream; | |
25 | +private: | |
26 | + | |
27 | + void createTrayIcon(); | |
28 | + QString commentPage; | |
29 | + QTextCodec *codec; | |
30 | + QSystemTrayIcon *trayIcon; | |
31 | + QMenu *trayIconMenu; | |
32 | + QAction *openAction; | |
33 | + QAction *quitAction; | |
34 | + QTimer *timer; | |
35 | + int i_interval; | |
36 | + bool readyReadNext; | |
37 | +/* | |
38 | + QUrl *url; | |
39 | + QFile *file; | |
40 | + QByteArray *ignitData; | |
41 | + QNetworkAccessManager *manager; | |
42 | + QNetworkRequest *req; | |
43 | + QNetworkReply *rep; | |
44 | +*/ | |
45 | + | |
46 | + void createActions(); | |
47 | + dialogSetting *SettingDialog; | |
48 | + kimixiCore *core; | |
49 | + | |
50 | +signals: | |
51 | + void authFailure(); | |
52 | + void newMessageComes(); | |
53 | + void newInvitationComes(); | |
54 | + void newCommentComes(); | |
55 | + | |
56 | + void get(QString); | |
57 | + void readHomeEnd(); | |
58 | + void readCommentEnd(); | |
59 | + void readDiaryEnd(); | |
60 | + void readBbsEnd(); | |
61 | + | |
62 | +private slots: | |
63 | + void setIcon(); | |
64 | + void iconActivated(QSystemTrayIcon::ActivationReason reason); | |
65 | + void openSettingDialog(); | |
66 | + void readHome(QBuffer&); | |
67 | + void readDiary(QBuffer&); | |
68 | + void readComment(QBuffer&); | |
69 | + void readBbs(QBuffer&); | |
70 | + | |
71 | + void itemActivated(QTreeWidgetItem *item); | |
72 | + | |
73 | + void login(); | |
74 | + void reqDiary(); | |
75 | + void reqComment(); | |
76 | + void reqBbs(); | |
77 | + | |
78 | + void newMessage(); | |
79 | + void newInvitation(); | |
80 | + void newComment(); | |
81 | + | |
82 | + void chckMessaeg(); | |
83 | + void chckInvitation(); | |
84 | + void chckComment(); | |
85 | +}; | |
86 | + | |
87 | +#endif // KIMIXIDIALOG_H |
@@ -0,0 +1,18 @@ | ||
1 | +#ifndef DIALOGSETTING_H | |
2 | +#define DIALOGSETTING_H | |
3 | + | |
4 | +#include "../ui_dialogSetting.h" | |
5 | +#include <QDialog> | |
6 | + | |
7 | +class dialogSetting : public QDialog, public Ui::dialogSetting | |
8 | +{ | |
9 | + Q_OBJECT | |
10 | + | |
11 | + public: | |
12 | + | |
13 | + dialogSetting(QWidget *parent = 0); | |
14 | + ~dialogSetting(); | |
15 | + | |
16 | +}; | |
17 | + | |
18 | +#endif // DIALOGSETTING_H |
@@ -0,0 +1,56 @@ | ||
1 | +#include "kimixiCore.h" | |
2 | + | |
3 | +kimixiCore::kimixiCore(QObject *parent, QBuffer &Buf) | |
4 | +{ | |
5 | + buf.setData(Buf.data()); | |
6 | + url = new QUrl( "http://mixi.jp/login.pl" ); | |
7 | + ignitData = new QByteArray; | |
8 | + manager = new QNetworkAccessManager(this ); | |
9 | + | |
10 | + req = new QNetworkRequest (*url); | |
11 | + //file = new QFile("gotHttp.txt"); | |
12 | + //file = new QBuffer; | |
13 | +} | |
14 | +void kimixiCore::login(QString temp) | |
15 | +{ | |
16 | + page = temp; | |
17 | + QSettings setting("Kimixi Team", "Kimixi"); | |
18 | + QString name = setting.value("UserName", "xxx@yy.zz").toString(); | |
19 | + QString pass = setting.value("Password", "password").toString(); | |
20 | + QString postStream = "next_url=/"+page+"&email=" + name +"&password=" + pass + "&x=50&y=10" /*+"ログイン"*/; | |
21 | + *ignitData = QUrl::toPercentEncoding(postStream,"=&","/@"); | |
22 | + //qDebug() << *ignitData; | |
23 | + rep = manager->post(*req, *ignitData); | |
24 | + connect(rep, SIGNAL(finished()), this, SLOT(getNew()) ); | |
25 | +} | |
26 | +void kimixiCore::getNew() | |
27 | +{ | |
28 | + rep=manager->get(QNetworkRequest(QUrl("http://mixi.jp/"+page))); | |
29 | + connect( rep, SIGNAL(finished()), this, SLOT(writeOut())); | |
30 | +} | |
31 | +void kimixiCore::writeOut() | |
32 | +{ | |
33 | + | |
34 | + buf.open(QIODevice::ReadWrite); | |
35 | + buf.write( rep->readAll() ); | |
36 | + //buf.close(); | |
37 | + //Buf.setData( buf->data() ); | |
38 | + if(page=="home.pl"){ | |
39 | + writeHomeEnd(buf); | |
40 | + }else if( page=="new_friend_diary.pl" ){ | |
41 | + writeDiaryEnd(buf); | |
42 | + }else if( page=="new_comment.pl"){ | |
43 | + writeCommentEnd(buf); | |
44 | + }else if( page=="new_bbs.pl"){ | |
45 | + writeBbsEnd(buf); | |
46 | + } | |
47 | + | |
48 | +} | |
49 | +kimixiCore::~kimixiCore(){ | |
50 | + delete url; | |
51 | + delete ignitData; | |
52 | + delete manager; | |
53 | + delete req; | |
54 | +// delete file; | |
55 | + //delete buf; | |
56 | +} |
@@ -0,0 +1,12 @@ | ||
1 | +#include <QtGui/QApplication> | |
2 | +#include "kimixiDialog.h" | |
3 | + | |
4 | +int main(int argc, char *argv[]) | |
5 | +{ | |
6 | + Q_INIT_RESOURCE(systray); | |
7 | + | |
8 | + QApplication a(argc, argv); | |
9 | + kimixiDialog w; | |
10 | + w.show(); | |
11 | + return a.exec(); | |
12 | +} |
@@ -0,0 +1,48 @@ | ||
1 | +#ifndef KIMIXICORE_H | |
2 | +#define KIMIXICORE_H | |
3 | + | |
4 | +#include <QAuthenticator> | |
5 | +#include <QHttp> | |
6 | +#include <QTextStream> | |
7 | +#include <QUrl> | |
8 | +#include <QFile> | |
9 | +#include <QByteArray> | |
10 | +#include <QNetworkAccessManager> | |
11 | +#include <QNetworkRequest> | |
12 | +#include <QNetworkReply> | |
13 | +#include <QSettings> | |
14 | +#include <QBuffer> | |
15 | +class kimixiCore : public QObject | |
16 | +{ | |
17 | +Q_OBJECT | |
18 | + | |
19 | +public: | |
20 | + kimixiCore(QObject *,QBuffer&); | |
21 | + ~kimixiCore(); | |
22 | + QBuffer buf; | |
23 | + QBuffer Buf; | |
24 | + | |
25 | +public slots: | |
26 | + void login(QString); | |
27 | + void getNew(); | |
28 | + void writeOut(); | |
29 | + | |
30 | +signals: | |
31 | + void writeHomeEnd(QBuffer&); | |
32 | + void writeDiaryEnd(QBuffer&); | |
33 | + void writeCommentEnd(QBuffer&); | |
34 | + void writeBbsEnd(QBuffer&); | |
35 | + | |
36 | + | |
37 | +private: | |
38 | + | |
39 | + QUrl *url; | |
40 | + QFile *file; | |
41 | + QByteArray *ignitData; | |
42 | + QNetworkAccessManager *manager; | |
43 | + QNetworkRequest *req; | |
44 | + QNetworkReply *rep; | |
45 | + QString page; | |
46 | +}; | |
47 | + | |
48 | +#endif // KIMIXICORE_H |
@@ -0,0 +1,542 @@ | ||
1 | +#include "kimixiDialog.h" | |
2 | +#include "dialogSetting.h" | |
3 | + | |
4 | +#include <QtGui> | |
5 | + | |
6 | +kimixiDialog::kimixiDialog(QWidget *parent) | |
7 | + : QWidget(parent) | |
8 | +{ | |
9 | + | |
10 | + //file = new QFile("gotHttp.txt"); | |
11 | + //file = new QBuffer; | |
12 | + QTextCodec *codec = QTextCodec::codecForName("UTF8"); | |
13 | + QTextCodec::setCodecForTr(codec); | |
14 | + timer = new QTimer(this); | |
15 | + setupUi(this); | |
16 | + treeWidget->setColumnHidden(2, true); | |
17 | + treeWidget->setHeaderLabels( QStringList() <<tr("Name")<<tr("Title") ); | |
18 | + createActions(); | |
19 | + createTrayIcon(); | |
20 | + pushButtonReload->setDisabled(true); | |
21 | + openSettingDialog(); | |
22 | + | |
23 | + core = new kimixiCore(this, dataBuf); | |
24 | + readyReadNext = true; | |
25 | + | |
26 | + connect( pushButtonSetting, SIGNAL( clicked() ) , this, SLOT( openSettingDialog() ) ); | |
27 | + connect( pushButtonHide, SIGNAL( clicked() ), this, SLOT(hide()) ); | |
28 | + connect( pushButtonReload, SIGNAL(clicked()), this, SLOT(login()) ); | |
29 | + connect( this, SIGNAL(get(QString)), core, SLOT(login(QString)) ); | |
30 | + connect( timer, SIGNAL(timeout()), core, SLOT( login() ) ); | |
31 | + | |
32 | + connect( core, SIGNAL(writeHomeEnd(QBuffer&)), this, SLOT(readHome(QBuffer&)) ); | |
33 | + connect( this, SIGNAL(readHomeEnd()), this, SLOT(reqDiary()) ); | |
34 | + connect( core, SIGNAL(writeDiaryEnd(QBuffer&)), this, SLOT(readDiary(QBuffer&)) ); | |
35 | + connect( this, SIGNAL(readDiaryEnd()), this, SLOT(reqComment()) ); | |
36 | + connect( core, SIGNAL(writeCommentEnd(QBuffer&)), this, SLOT(readComment(QBuffer&)) ); | |
37 | + connect( this, SIGNAL(readCommentEnd()), this, SLOT(reqBbs()) ); | |
38 | + connect( core, SIGNAL(writeBbsEnd(QBuffer&)), this, SLOT(readBbs(QBuffer&)) ); | |
39 | + | |
40 | + connect( treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*)) ); | |
41 | + connect( this, SIGNAL(authFailure()), this, SLOT(openSettingDialog()) ); | |
42 | + | |
43 | + connect( this, SIGNAL(newMessageComes()), this, SLOT(newMessage()) ); | |
44 | + connect( pushButtonMail, SIGNAL(clicked()), this, SLOT(chckMessaeg()) ); | |
45 | + connect( this, SIGNAL(newInvitationComes()), this, SLOT(newInvitation()) ); | |
46 | + connect( pushButtonInvite, SIGNAL(clicked()), this, SLOT(chckInvitation()) ); | |
47 | + connect( this, SIGNAL(newCommentComes()), this, SLOT(newComment()) ); | |
48 | + connect( pushButtonComment, SIGNAL(clicked()), this, SLOT(chckComment()) ); | |
49 | +} | |
50 | + | |
51 | +kimixiDialog::~kimixiDialog() | |
52 | +{ | |
53 | + delete timer; | |
54 | + delete core; | |
55 | + | |
56 | + | |
57 | +} | |
58 | + | |
59 | + void kimixiDialog::setIcon() | |
60 | + { | |
61 | + QIcon icon(":images/kimixiIcon.png"); | |
62 | + this->setWindowIcon( icon ); | |
63 | + trayIcon->setIcon(icon); | |
64 | + setWindowIcon(icon); | |
65 | + | |
66 | + } | |
67 | + | |
68 | + void kimixiDialog::iconActivated(QSystemTrayIcon::ActivationReason reason) | |
69 | + { | |
70 | + switch (reason) { | |
71 | + case QSystemTrayIcon::Trigger:/* | |
72 | + case QSystemTrayIcon::DoubleClick: | |
73 | + iconComboBox->setCurrentIndex((iconComboBox->currentIndex() + 1) | |
74 | + % iconComboBox->count()); | |
75 | + break;*/ | |
76 | + case QSystemTrayIcon::MiddleClick: | |
77 | + //showMessage(); | |
78 | + break; | |
79 | + default: | |
80 | + ; | |
81 | + } | |
82 | + } | |
83 | + | |
84 | + void kimixiDialog::createTrayIcon() | |
85 | + { | |
86 | + | |
87 | + trayIconMenu = new QMenu(this); | |
88 | + trayIconMenu->addAction( openAction ); | |
89 | + trayIconMenu->addAction( quitAction ); | |
90 | + | |
91 | + trayIcon = new QSystemTrayIcon(this); | |
92 | + setIcon(); | |
93 | + trayIcon->setContextMenu(trayIconMenu); | |
94 | + trayIcon->setVisible(true); | |
95 | + } | |
96 | + void kimixiDialog::createActions() | |
97 | + { | |
98 | + quitAction = new QAction(tr("&Quit"), this); | |
99 | + connect( quitAction, SIGNAL(triggered()), qApp, SLOT(quit()) ); | |
100 | + | |
101 | + openAction = new QAction( tr("&Open"), this); | |
102 | + connect( openAction, SIGNAL(triggered() ), this, SLOT(show() ) ); | |
103 | + } | |
104 | +void kimixiDialog::openSettingDialog() | |
105 | +{ | |
106 | + | |
107 | + SettingDialog = new dialogSetting(this); | |
108 | + | |
109 | + if(SettingDialog->exec() ){ | |
110 | + QSettings setting("Kimixi Team", "Kimixi"); | |
111 | + setting.setValue("UserName", SettingDialog->lineEditUserName->text() ); | |
112 | + setting.setValue("Password", SettingDialog->lineEditPassword->text() ); | |
113 | + setting.setValue("NewDiary", SettingDialog->spinBoxNewDiary->value() ); | |
114 | + setting.setValue("NewComment", SettingDialog->spinBoxNewComment->value() ); | |
115 | + setting.setValue("NewCommunity", SettingDialog->spinBoxNewCommunity->value() ); | |
116 | + setting.setValue("CroalInterval", SettingDialog->spinBoxCroal->value() ); | |
117 | + } | |
118 | + pushButtonReload->setEnabled(true); | |
119 | +// core->getNew(); | |
120 | + delete SettingDialog; | |
121 | +} | |
122 | +void kimixiDialog::readHome(QBuffer &a) | |
123 | +{ | |
124 | + QSettings setting("Kimixi Team", "Kimixi"); | |
125 | + i_interval = setting.value("CroalInterval", 15 ).toInt(); | |
126 | + timer->start(i_interval*60*1000); | |
127 | + | |
128 | + //codec = QTextCodec::codecForName("EUC-JP"); | |
129 | + dataBuf.setData(a.data()); | |
130 | + QString buf; | |
131 | + QTextStream strm( &dataBuf ); | |
132 | + strm.setCodec("EUC-JP"); | |
133 | + | |
134 | + QStringList splitList; | |
135 | + QString linkString; | |
136 | + QString titleString; | |
137 | + QString nameString; | |
138 | + //view_diary.pl?id=1176587204&owner_id=835016" | |
139 | + QRegExp diaryID("view_diary*"); | |
140 | + | |
141 | + if( !dataBuf.isReadable() ){ | |
142 | + dataBuf.open(QIODevice::ReadOnly); | |
143 | + }else{ | |
144 | + readHomeEnd(); | |
145 | + return; | |
146 | + } | |
147 | + //message html will be: | |
148 | + //<li class="redTxt"><a href="list_message.pl">新着メッセージが1件あります!</a></li> | |
149 | + | |
150 | + //qDebug() << strm; | |
151 | + | |
152 | + while( buf != "<!--[mixiInfo]-->"){ | |
153 | + buf=strm.readLine(200); | |
154 | + qDebug() << buf; | |
155 | + if( strm.atEnd() ){ | |
156 | + dataBuf.close(); | |
157 | + qDebug() << "error at searching mixiInfo"; | |
158 | + readyReadNext = true; | |
159 | + return; | |
160 | + }else if( buf == "<div id=\"login_all\">" ){ | |
161 | + //authenticate failure code here | |
162 | + dataBuf.close(); | |
163 | + readyReadNext = true; | |
164 | + authFailure(); | |
165 | + } | |
166 | + //qDebug() << buf; | |
167 | + } | |
168 | + while( buf != "<!--/[mixiInfo]-->"){ | |
169 | + buf = strm.readLine(100); | |
170 | + if( buf=="" ){ | |
171 | + continue; | |
172 | + } | |
173 | + splitList = buf.split(">"); | |
174 | + if( splitList[0] == "<li" ){ | |
175 | + continue; | |
176 | + }else if( splitList[0] == "<li class=\"redTxt\"" ){ | |
177 | + //new arrival code here | |
178 | + splitList = splitList[1].split("\""); | |
179 | + if( splitList[1] == "list_request.pl" ){ | |
180 | + qDebug() << "new invitation"; | |
181 | + newInvitationComes(); | |
182 | + } | |
183 | + if( splitList[1] == "list_message.pl"){ | |
184 | + qDebug() << "new message"; | |
185 | + newMessageComes(); | |
186 | + } | |
187 | + if( splitList[1].contains(diaryID) ){ | |
188 | + qDebug() << "new comment"; | |
189 | + commentPage = splitList[1]; | |
190 | + newCommentComes(); | |
191 | + } | |
192 | + | |
193 | + } | |
194 | + } | |
195 | + dataBuf.close(); | |
196 | + readHomeEnd(); | |
197 | +} | |
198 | +void kimixiDialog::readDiary(QBuffer &a) | |
199 | +{ | |
200 | + QSettings setting("Kimixi Team", "Kimixi"); | |
201 | + int DiaryLimit = setting.value("NewDiary", 5).toInt(); | |
202 | + dataBuf.setData(a.data()); | |
203 | + QString buf; | |
204 | + QTextStream strm( &dataBuf ); | |
205 | + strm.setCodec("EUC-JP"); | |
206 | + | |
207 | + QStringList splitList; | |
208 | + QString linkString; | |
209 | + QString titleString; | |
210 | + QString nameString; | |
211 | + //view_diary.pl?id=1176587204&owner_id=835016" | |
212 | + QRegExp outerBlog("url="); | |
213 | + | |
214 | + if( !dataBuf.isReadable() ){ | |
215 | + dataBuf.open(QIODevice::ReadOnly); | |
216 | + }else{ | |
217 | + return; | |
218 | + } | |
219 | + | |
220 | + while( buf != "<ul class=\"entryList01\">"){ | |
221 | + buf = strm.readLine(100); | |
222 | + qDebug() << buf; | |
223 | + if( strm.atEnd() ){ | |
224 | + dataBuf.close(); | |
225 | + readDiaryEnd(); | |
226 | + qDebug() << "error at primary newListBox01" ; | |
227 | + return; | |
228 | + } | |
229 | + } | |
230 | + QTreeWidgetItem *diaryTop = new QTreeWidgetItem; | |
231 | + diaryTop->setText(0, tr("新着日記")); | |
232 | + diaryTop->setText(1, ""); | |
233 | + diaryTop->setText(2, "new_friend_diary.pl"); | |
234 | + treeWidget->addTopLevelItem(diaryTop); | |
235 | + | |
236 | + for(int i=0; i<DiaryLimit; i++){ | |
237 | + int j = 5; | |
238 | + while(j--){ | |
239 | + buf=strm.readLine(200); | |
240 | + splitList = buf.split(">"); | |
241 | + if( splitList[0] == "</ul" ){ | |
242 | + dataBuf.close(); | |
243 | + readDiaryEnd(); | |
244 | + return; | |
245 | + } | |
246 | + } | |
247 | + | |
248 | + qDebug() <<"loopStrtCntr=" <<i; | |
249 | + //link | |
250 | + buf=strm.readLine(); | |
251 | + //buf like this: | |
252 | + //<dd><a href="URL">TITLE</a> (NAME)<div style="visibility: hidden;" class="diary_pop" id="xxx"></div> | |
253 | + | |
254 | + splitList = buf.split("\""); | |
255 | + linkString = splitList[1]; | |
256 | + buf=splitList[2]; | |
257 | + //buf like this: | |
258 | + //>TITLE</a> (NAME)<div style= | |
259 | + qDebug() << "link" << i << linkString ; | |
260 | + //title | |
261 | + splitList = buf.split("<"); | |
262 | + buf = splitList[1]; | |
263 | + //buf like this: | |
264 | + ///a> (NAME) | |
265 | + splitList = splitList[0].split(">"); | |
266 | + titleString = splitList[1]; | |
267 | + qDebug() << "title" << i << titleString; | |
268 | + //name | |
269 | + splitList = buf.split(")"); | |
270 | + splitList = splitList[0].split("("); | |
271 | + nameString = splitList[1]; | |
272 | + qDebug() << "name" << i << nameString; | |
273 | + | |
274 | + QTreeWidgetItem *item = new QTreeWidgetItem(diaryTop); | |
275 | + item->setText(0, nameString); | |
276 | + item->setText(1, titleString); | |
277 | + item->setText(2, linkString); | |
278 | + //item[2].setHidden(true); | |
279 | + | |
280 | + if(linkString.contains(outerBlog)){ | |
281 | + buf = strm.readLine(); | |
282 | + buf = strm.readLine(); | |
283 | + qDebug() << "outerBlog skips:" << buf; | |
284 | + }else{ | |
285 | + j=5; | |
286 | + while(j--){ | |
287 | + buf = strm.readLine(); | |
288 | + } | |
289 | + } | |
290 | + nameString.clear(); | |
291 | + titleString.clear(); | |
292 | + linkString.clear(); | |
293 | + splitList.clear(); | |
294 | + | |
295 | + //qDebug() << "loopEndCntr=" << i ; | |
296 | + } | |
297 | + dataBuf.close(); | |
298 | + readDiaryEnd(); | |
299 | +} | |
300 | +void kimixiDialog::readComment(QBuffer &a) | |
301 | +{ | |
302 | + QSettings setting("Kimixi Team", "Kimixi"); | |
303 | + int CommentLimit = setting.value("NewComment", 5).toInt(); | |
304 | + dataBuf.setData(a.data()); | |
305 | + QString buf; | |
306 | + QTextStream strm( &dataBuf ); | |
307 | + strm.setCodec("EUC-JP"); | |
308 | + | |
309 | + QStringList splitList; | |
310 | + QString linkString; | |
311 | + QString titleString; | |
312 | + QString nameString; | |
313 | + //view_diary.pl?id=1176587204&owner_id=835016" | |
314 | + QRegExp diaryID("view_diary*"); | |
315 | + | |
316 | + if( !dataBuf.isReadable() ){ | |
317 | + dataBuf.open(QIODevice::ReadOnly); | |
318 | + }else{ | |
319 | + readCommentEnd(); | |
320 | + return; | |
321 | + } | |
322 | + | |
323 | + while( buf != "<ul class=\"entryList01\">"){ | |
324 | + buf = strm.readLine(100); | |
325 | + qDebug() << buf; | |
326 | + if( strm.atEnd() ){ | |
327 | + dataBuf.close(); | |
328 | + readCommentEnd(); | |
329 | + qDebug() << "error at primary newListBox01" ; | |
330 | + return; | |
331 | + } | |
332 | + } | |
333 | + QTreeWidgetItem *commentTop = new QTreeWidgetItem; | |
334 | + commentTop->setText(0, tr("記入したコメント")); | |
335 | + commentTop->setText(1, ""); | |
336 | + commentTop->setText(2, "new_comment.pl"); | |
337 | + treeWidget->addTopLevelItem(commentTop); | |
338 | + | |
339 | + //new comment | |
340 | + for(int i=0; i<CommentLimit; i++){ | |
341 | + int j=5; | |
342 | + while( j-- ){ | |
343 | + buf = strm.readLine(); | |
344 | + splitList = buf.split(">"); | |
345 | + if( splitList[0] == "</ul" ){ | |
346 | + dataBuf.close(); | |
347 | + readCommentEnd(); | |
348 | + return; | |
349 | + } | |
350 | + } | |
351 | + //buf like this: | |
352 | + //<dd><a href="URL">TITLE</a> (NAME)</dd> | |
353 | + splitList = buf.split( "\"" ); | |
354 | + linkString = splitList[1]; | |
355 | + qDebug() << "link" << i << linkString; | |
356 | + | |
357 | + buf = splitList[2]; | |
358 | + //buf like this: | |
359 | + //>TITLE</a> (NAME)</dd> | |
360 | + splitList = buf.split("<"); | |
361 | + buf = splitList[1]; | |
362 | + //buf like this: | |
363 | + ///a> (NAME)</dd> | |
364 | + splitList = splitList[0].split(">"); | |
365 | + titleString = splitList[1]; | |
366 | + qDebug() << "title" << i << titleString; | |
367 | + | |
368 | + splitList = buf.split(")"); | |
369 | + splitList = splitList[0].split("("); | |
370 | + nameString = splitList[1]; | |
371 | + qDebug() << "name" << i << titleString; | |
372 | + | |
373 | + QTreeWidgetItem *item = new QTreeWidgetItem(commentTop); | |
374 | + item->setText(0, nameString); | |
375 | + item->setText(1, titleString); | |
376 | + item->setText(2, linkString); | |
377 | + | |
378 | + buf = strm.readLine(10); | |
379 | + buf = strm.readLine(10); | |
380 | + | |
381 | + } | |
382 | + dataBuf.close(); | |
383 | + readCommentEnd(); | |
384 | +} | |
385 | +void kimixiDialog::readBbs(QBuffer &a) | |
386 | +{ | |
387 | + QSettings setting("Kimixi Team", "Kimixi"); | |
388 | + int BbsLimit = setting.value("NewCommunity", 5).toInt(); | |
389 | + dataBuf.setData(a.data()); | |
390 | + QString buf; | |
391 | + QTextStream strm( &dataBuf ); | |
392 | + strm.setCodec("EUC-JP"); | |
393 | + | |
394 | + QStringList splitList; | |
395 | + QString linkString; | |
396 | + QString titleString; | |
397 | + QString nameString; | |
398 | + //view_diary.pl?id=1176587204&owner_id=835016" | |
399 | + QRegExp diaryID("view_diary*"); | |
400 | + | |
401 | + if( !dataBuf.isReadable() ){ | |
402 | + dataBuf.open(QIODevice::ReadOnly); | |
403 | + }else{ | |
404 | + return; | |
405 | + } | |
406 | + QTreeWidgetItem *communityTop = new QTreeWidgetItem; | |
407 | + communityTop->setText(0, tr("コミュニティ")); | |
408 | + communityTop->setText(1, "" ); | |
409 | + communityTop->setText(2, "new_bbs.pl"); | |
410 | + treeWidget->addTopLevelItem(communityTop); | |
411 | + while( buf != "<ul class=\"entryList01\">"){ | |
412 | + buf = strm.readLine(100); | |
413 | + qDebug() << buf; | |
414 | + if( strm.atEnd() ){ | |
415 | + dataBuf.close(); | |
416 | + readDiaryEnd(); | |
417 | + qDebug() << "error at primary newListBox01" ; | |
418 | + return; | |
419 | + } | |
420 | + } | |
421 | + for( int i=0; i<BbsLimit; i++ ){ | |
422 | + int j=5; | |
423 | + while(j--){ | |
424 | + buf = strm.readLine(); | |
425 | + //qDebug() << "com runover:" << j; | |
426 | + //qDebug() << " :" << buf; | |
427 | + splitList = buf.split(">"); | |
428 | + if( splitList[0] == "</dl" ){ | |
429 | + dataBuf.close(); | |
430 | + return; | |
431 | + } | |
432 | + } | |
433 | + buf = strm.readLine(); | |
434 | + //buf like this: | |
435 | + //<dd><a href="URL">TITLE</a> (NAME)</dd> | |
436 | + qDebug() << "com read-in:" << i; | |
437 | + qDebug() << buf; | |
438 | + splitList = buf.split("\""); | |
439 | + linkString = splitList[1]; | |
440 | + buf = splitList[2]; | |
441 | + //buf like this: | |
442 | + //>TITLE</a> (NAME)</dd> | |
443 | + qDebug() << "link " << i << linkString; | |
444 | + | |
445 | + splitList = buf.split("<"); | |
446 | + buf = splitList[1]; | |
447 | + //buf like this: | |
448 | + // /a> (NAME) | |
449 | + splitList = splitList[0].split(">"); | |
450 | + titleString = splitList[1]; | |
451 | + qDebug() << "title " << i << titleString; | |
452 | + | |
453 | + | |
454 | + splitList = buf.split(")"); | |
455 | + splitList = splitList[0].split("("); | |
456 | +// splitList = splitList[1].split("\n"); | |
457 | + nameString = splitList[1]; | |
458 | + qDebug() << "name " << i << nameString; | |
459 | + | |
460 | + QTreeWidgetItem *item = new QTreeWidgetItem(communityTop); | |
461 | + item->setText(0, nameString); | |
462 | + item->setText(1, titleString); | |
463 | + item->setText(2, linkString); | |
464 | + | |
465 | + buf = strm.readLine(); | |
466 | + } | |
467 | + | |
468 | + /* | |
469 | + buf = dataBuf.readLine(100); | |
470 | + qDebug() << buf; | |
471 | + buf = dataBuf.readLine(100); | |
472 | + qDebug() << buf; | |
473 | + */ | |
474 | + dataBuf.close(); | |
475 | + readyReadNext=true; | |
476 | +} | |
477 | +void kimixiDialog::itemActivated( QTreeWidgetItem *item ) | |
478 | +{ | |
479 | + QString url; | |
480 | + url = "http://mixi.jp/" + item->text(2); | |
481 | + QDesktopServices::openUrl(QUrl(url)); | |
482 | +} | |
483 | +void kimixiDialog::newMessage() | |
484 | +{ | |
485 | + pushButtonMail->setText(tr("1 messages")); | |
486 | + //pushButtonMail->setEnabled(true); | |
487 | +} | |
488 | +void kimixiDialog::chckMessaeg() | |
489 | +{ | |
490 | + QString url; | |
491 | + url = "http://mixi.jp/list_message.pl"; | |
492 | + QDesktopServices::openUrl(QUrl(url)); | |
493 | + pushButtonMail->setText(tr("Message(0)")); | |
494 | +} | |
495 | +void kimixiDialog::newInvitation() | |
496 | +{ | |
497 | + pushButtonInvite->setText(tr("1 request")); | |
498 | +} | |
499 | +void kimixiDialog::chckInvitation() | |
500 | +{ | |
501 | + QString url("http://mixi.jp/list_request.pl"); | |
502 | + QDesktopServices::openUrl(QUrl(url)); | |
503 | + pushButtonInvite->setText(tr("Request(0)")); | |
504 | +} | |
505 | +void kimixiDialog::newComment() | |
506 | +{ | |
507 | + pushButtonComment->setText(tr("1 comment")); | |
508 | +} | |
509 | +void kimixiDialog::chckComment() | |
510 | +{ | |
511 | + QString url("http://mixi.jp/"); | |
512 | + QDesktopServices::openUrl(QUrl(url+commentPage)); | |
513 | + pushButtonComment->setText(tr("Comment(0)")); | |
514 | +} | |
515 | +void kimixiDialog::login() | |
516 | +{ | |
517 | + QString home("home.pl"); | |
518 | + QString bbs("new_bbs.pl"); | |
519 | + | |
520 | + | |
521 | + | |
522 | + if( readyReadNext ){ | |
523 | + readyReadNext=false; | |
524 | + treeWidget->clear(); | |
525 | + get(home); | |
526 | + } | |
527 | +} | |
528 | +void kimixiDialog::reqDiary() | |
529 | +{ | |
530 | + QString diary("new_friend_diary.pl"); | |
531 | + get(diary); | |
532 | +} | |
533 | +void kimixiDialog::reqComment() | |
534 | +{ | |
535 | + QString comment("new_comment.pl"); | |
536 | + get(comment); | |
537 | +} | |
538 | +void kimixiDialog::reqBbs() | |
539 | +{ | |
540 | + QString bbs("new_bbs.pl"); | |
541 | + get(bbs); | |
542 | +} |
@@ -0,0 +1,18 @@ | ||
1 | +#include "dialogSetting.h" | |
2 | +#include <QtGui> | |
3 | + | |
4 | +dialogSetting::dialogSetting(QWidget *parent) : QDialog(parent) | |
5 | +{ | |
6 | + setupUi(this); | |
7 | + QSettings setting("Kimixi Team", "Kimixi"); | |
8 | + lineEditUserName->setText( setting.value("UserName").toString() ); | |
9 | + lineEditPassword->setText( setting.value("Password").toString() ); | |
10 | + spinBoxNewDiary->setValue( setting.value("NewDiary").toInt() ); | |
11 | + spinBoxNewCommunity->setValue( setting.value("NewCommunity").toInt() ); | |
12 | + spinBoxNewComment->setValue( setting.value("NewComment").toInt() ); | |
13 | + spinBoxCroal->setValue( setting.value("CroalInterval").toInt() ); | |
14 | +} | |
15 | + | |
16 | +dialogSetting::~dialogSetting() | |
17 | +{ | |
18 | +} |