1 /* This file is part of the KDE project
3 Copyright (C) 2007 by Javier Goday <jgoday@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
11 #include "kuiserverjobs.h"
13 #include "kgetglobaljob.h"
16 #include <kuiserverjobtracker.h>
18 KUiServerJobs::KUiServerJobs(QObject
*parent
)
19 : QObject(parent
), m_jobs(), m_globalJob(0)
23 KUiServerJobs::~KUiServerJobs()
27 void KUiServerJobs::registerJob(KJob
*job
)
31 if(Settings::enableKUIServerIntegration()) {
32 if(Settings::exportGlobalJob()) {
33 globalJob()->registerJob(job
);
36 KIO::getJobTracker()->registerJob(job
);
41 void KUiServerJobs::unregisterJob(KJob
*job
)
43 m_jobs
.removeAll(job
);
45 if(Settings::enableKUIServerIntegration()) {
46 if(Settings::exportGlobalJob()) {
47 globalJob()->unregisterJob(job
);
50 KIO::getJobTracker()->unregisterJob(job
);
55 // every time the configuration changed, check the registered jobs and the state through the ui server
56 void KUiServerJobs::reload()
58 if(m_globalJob
&& !Settings::exportGlobalJob()) {
59 KIO::getJobTracker()->unregisterJob(globalJob());
64 if(Settings::exportGlobalJob()) {
65 KIO::getJobTracker()->registerJob(globalJob());
67 foreach(KJob
*job
, m_jobs
) {
68 KIO::getJobTracker()->unregisterJob(job
);
72 foreach(KJob
*job
, m_jobs
) {
73 if(Settings::enableKUIServerIntegration() && job
&& job
->percent() < 100) {
74 KIO::getJobTracker()->registerJob(job
);
77 KIO::getJobTracker()->unregisterJob(job
);
83 // get the kget global job
84 KGetGlobalJob
*KUiServerJobs::globalJob()
87 m_globalJob
= new KGetGlobalJob();
89 foreach(KJob
*job
, m_jobs
) {
90 m_globalJob
->registerJob(job
);