1
/***************************************************************************
2
* Copyright (C) 2004 by Roberto Virga *
3
* rvirga@users.sf.net *
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. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
23
#include <klibloader.h>
27
#include <kbsboincmonitor.h>
28
#include <kbspanelnode.h>
30
#include "kbstasknode.h"
32
KBSTaskNode::KBSTaskNode(unsigned num, const QString &workunit, KBSTreeNode *parent, const char *name)
33
: KBSWorkunitNode(workunit, parent, name), m_num(num)
38
QString KBSTaskNode::name() const
40
return KBSTaskNode::name(m_num, monitor());
43
QString KBSTaskNode::name(unsigned num, KBSBOINCMonitor *)
45
return i18n("CPU %1").arg(num + 1);
48
int KBSTaskNode::task() const
53
QString KBSTaskNode::result() const
58
void KBSTaskNode::addPlugins()
60
if(NULL == monitor() || project().isEmpty()) return;
62
const BOINCClientState *state = monitor()->state();
63
if(NULL == state) return;
65
m_result = state->workunit[workunit()].result_name;
66
if(m_result.isEmpty()) return;
68
m_task = state->active_task_set.index(m_result);
69
if(m_task < 0) return;
72
KTrader::OfferList offers;
74
constraints = "[X-KDE-Target] == 'Task' and '%1' in [X-KDE-Projects]";
75
offers = KTrader::self()->query("KBSPanelNode", constraints.arg(project()));
77
for(KTrader::OfferListIterator offer = offers.begin(); offer != offers.end(); ++offer)
79
const QString name = (*offer)->name();
81
QStringList args = (*offer)->property("X-KDE-Arguments").toStringList();
82
args.prepend(QString::number(m_task));
84
KLibFactory *factory = KLibLoader::self()->factory((*offer)->library());
85
if(NULL == factory) continue;
87
insertChild(static_cast<KBSPanelNode*>(factory->create(this, name, "KBSPanelNode", args)));
91
#include "kbstasknode.moc"