blob: 682943314a137726e7cd4a6052019f23c52ed02a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <QtCore/QDebug>
#include "board.h"
#include "xmlrpcinterface.h"
#include "xmlrpcreply.h"
#include "fetchforumsaction.h"
#include "markforumreadaction.h"
MarkForumReadAction::MarkForumReadAction(int forumId, Board *board) :
Action(board), _forumId(forumId)
{
}
bool MarkForumReadAction::isSupersetOf(Action *action) const
{
MarkForumReadAction *other = qobject_cast<MarkForumReadAction*>(action);
if (other) {
return _forumId == other->_forumId;
}
return false;
}
void MarkForumReadAction::execute()
{
if (_forumId == 0) {
_call = _board->service()->asyncCall("mark_all_as_read");
} else {
_call = _board->service()->asyncCall("mark_all_as_read", QString(_forumId));
}
_call->setParent(this);
connect(_call, SIGNAL(finished(XmlRpcPendingCall*)), SLOT(handleFinishedCall()));
}
void MarkForumReadAction::handleFinishedCall()
{
XmlRpcReply<QVariantMap> result(_call);
if (result.isValid()) {
QVariantMap map = result;
bool result_ok = map["result"].toBool();
if (result_ok) {
// Must reload forums to see the result!
_board->enqueueAction(new FetchForumsAction(_board));
} else {
qWarning() << "Failed to mark forums: " << map["result_text"].toString();
}
} else {
qWarning() << "Could not fetch board configuration";
// TODO emit error ...
}
emit finished(this);
_call->deleteLater();
}
|