not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / systemtray / protocols / plasmoid / plasmoidtaskprotocol.cpp
blobcd248d9c00248c6f3a4627eec5b03361f44aadf2
1 /***************************************************************************
2 * plasmoidprotocol.cpp *
3 * *
4 * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
5 * Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
21 ***************************************************************************/
23 #include "plasmoidtask.h"
24 #include "plasmoidtaskprotocol.h"
26 #include <KDebug>
28 namespace SystemTray
31 PlasmoidProtocol::PlasmoidProtocol(QObject *parent)
32 : Protocol(parent)
37 PlasmoidProtocol::~PlasmoidProtocol()
42 void PlasmoidProtocol::init()
44 // TODO: Load plasmoids from config
45 //newTask("battery");
46 //newTask("notify");
47 //newTask("kuiserver");
48 //newTask("mid_control");
52 void PlasmoidProtocol::newTask(QString appletName)
54 if (m_tasks.contains(appletName)) {
55 kDebug() << "Task " << appletName << "is already in here.";
56 return;
59 kDebug() << "Registering task with the manager" << appletName;
60 PlasmoidTask *task = new PlasmoidTask(appletName);
62 if (!task->isValid()) {
63 // we failed to load our applet *sob*
64 delete task;
65 return;
68 m_tasks[appletName] = task;
69 connect(task, SIGNAL(taskDeleted(QString)), this, SLOT(cleanupTask(QString)));
70 emit taskCreated(task);
74 void PlasmoidProtocol::cleanupTask(QString typeId)
76 kDebug() << "task with typeId" << typeId << "removed";
77 m_tasks.remove(typeId);
82 #include "plasmoidtaskprotocol.moc"