1 /***************************************************************************
4 * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
20 ***************************************************************************/
26 #include <plasma/applet.h>
28 #include "notification.h"
33 #include "../protocols/notifications/dbusnotificationprotocol.h"
34 #include "../protocols/fdo/fdoprotocol.h"
35 #include "../protocols/plasmoid/plasmoidtaskprotocol.h"
36 #include "../protocols/jobs/dbusjobprotocol.h"
42 class Manager::Private
45 Private(Manager
*manager
)
48 notificationProtocol(0)
50 setupProtocol(new PlasmoidProtocol(q
));
51 setupProtocol(new SystemTray::FdoProtocol(q
));
54 void setupProtocol(Protocol
*protocol
);
58 QList
<Notification
*> notifications
;
60 Protocol
*jobProtocol
;
61 Protocol
*notificationProtocol
;
66 : d(new Private(this))
76 QList
<Task
*> Manager::tasks() const
81 void Manager::addTask(Task
*task
)
83 connect(task
, SIGNAL(destroyed(SystemTray::Task
*)),
84 this, SLOT(removeTask(SystemTray::Task
*)));
85 connect(task
, SIGNAL(changed(SystemTray::Task
*)),
86 this, SIGNAL(taskChanged(SystemTray::Task
*)));
88 kDebug() << task
->name() << "(" << task
->typeId() << ")";
90 d
->tasks
.append(task
);
95 void Manager::removeTask(Task
*task
)
97 d
->tasks
.removeAll(task
);
98 emit
taskRemoved(task
);
101 void Manager::registerNotificationProtocol()
103 if (!d
->notificationProtocol
) {
104 d
->notificationProtocol
= new DBusNotificationProtocol(this);
105 d
->setupProtocol(d
->notificationProtocol
);
109 void Manager::unregisterNotificationProtocol()
111 if (d
->notificationProtocol
) {
112 delete d
->notificationProtocol
;
113 d
->notificationProtocol
= 0;
117 void Manager::addNotification(Notification
* notification
)
119 connect(notification
, SIGNAL(destroyed(SystemTray::Notification
*)),
120 this, SLOT(removeNotification(SystemTray::Notification
*)));
121 connect(notification
, SIGNAL(changed(SystemTray::Notification
*)),
122 this, SIGNAL(notificationChanged(SystemTray::Notification
*)));
124 d
->notifications
.append(notification
);
125 emit
notificationAdded(notification
);
128 void Manager::removeNotification(Notification
*notification
)
130 d
->notifications
.removeAll(notification
);
131 emit
notificationRemoved(notification
);
134 QList
<Notification
*> Manager::notifications() const
136 return d
->notifications
;
139 void Manager::registerJobProtocol()
141 if (!d
->jobProtocol
) {
142 d
->jobProtocol
= new DBusJobProtocol(this);
143 d
->setupProtocol(d
->jobProtocol
);
147 void Manager::unregisterJobProtocol()
149 if (d
->jobProtocol
) {
150 delete d
->jobProtocol
;
155 void Manager::Private::setupProtocol(Protocol
*protocol
)
157 connect(protocol
, SIGNAL(jobCreated(SystemTray::Job
*)), q
, SLOT(addJob(SystemTray::Job
*)));
158 connect(protocol
, SIGNAL(taskCreated(SystemTray::Task
*)), q
, SLOT(addTask(SystemTray::Task
*)));
159 connect(protocol
, SIGNAL(notificationCreated(SystemTray::Notification
*)),
160 q
, SLOT(addNotification(SystemTray::Notification
*)));
164 void Manager::addJob(Job
*job
)
166 connect(job
, SIGNAL(destroyed(SystemTray::Job
*)), this, SLOT(removeJob(SystemTray::Job
*)));
167 connect(job
, SIGNAL(changed(SystemTray::Job
*)), this, SIGNAL(jobChanged(SystemTray::Job
*)));
173 void Manager::removeJob(Job
*job
)
175 d
->jobs
.removeAll(job
);
176 emit
jobRemoved(job
);
179 QList
<Job
*> Manager::jobs() const
187 #include "manager.moc"