~ubuntu-branches/debian/stretch/apper/stretch

« back to all changes in this revision

Viewing changes to apperd/ApperdThread.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klumpp
  • Date: 2013-07-30 12:34:46 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130730123446-cgzujaj03pc61drn
Tags: 0.8.1-1
* New upstream release: 0.8.1
* Depend on software-properties-kde instead of suggesting it (Closes: #696583)
* Add patch to make AppStream loading more failsafe

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "DistroUpgrade.h"
25
25
#include "TransactionWatcher.h"
26
26
#include "DBusInterface.h"
 
27
#include "RebootListener.h"
27
28
 
28
29
#include <Enum.h>
29
30
#include <Daemon>
61
62
 
62
63
ApperdThread::ApperdThread(QObject *parent) :
63
64
    QObject(parent),
64
 
    m_proxyChanged(true)
 
65
    m_proxyChanged(true),
 
66
    m_AptRebootListener(new AptRebootListener(this))
65
67
{
66
68
}
67
69
 
101
103
    QString locale(KGlobal::locale()->language() % QLatin1Char('.') % KGlobal::locale()->encoding());
102
104
    Daemon::global()->setHints(QLatin1String("locale=") % locale);
103
105
 
104
 
    // Watch for TransactionListChanged so we start sentinel
105
 
    connect(Daemon::global(), SIGNAL(transactionListChanged(QStringList)),
106
 
            this, SLOT(transactionListChanged(QStringList)));
107
 
 
108
 
    // Watch for UpdatesChanged so we display new updates
109
106
    connect(Daemon::global(), SIGNAL(updatesChanged()),
110
 
            this, SLOT(updatesChanged()));
 
107
            SLOT(updatesChanged()));
111
108
 
112
109
    m_interface = new DBusInterface(this);
113
110
 
128
125
                                      QDBusConnection::systemBus(),
129
126
                                      QDBusServiceWatcher::WatchForRegistration,
130
127
                                      this);
131
 
    connect(watcher, SIGNAL(serviceRegistered(QString)),
132
 
            this, SLOT(setProxy()));
 
128
    connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(setProxy()));
133
129
 
134
130
    // if PackageKit is running check to see if there are running transactons already
135
131
    bool packagekitIsRunning = nameHasOwner(QLatin1String("org.freedesktop.PackageKit"),
136
132
                                            QDBusConnection::systemBus());
137
133
 
138
134
    m_transactionWatcher = new TransactionWatcher(packagekitIsRunning, this);
 
135
 
139
136
    // connect the watch transaction coming from the updater icon to our watcher
140
137
    connect(m_interface, SIGNAL(watchTransaction(QDBusObjectPath)),
141
138
            m_transactionWatcher, SLOT(watchTransaction(QDBusObjectPath)));
142
139
 
 
140
     // listen to Debian/Apt reboot signals from other sources (apt)
 
141
    connect(m_AptRebootListener, SIGNAL(requestReboot()), m_transactionWatcher, SLOT(showRebootNotificationApt()));
 
142
    QTimer::singleShot(2 /*minutes*/ * 60 /*seconds*/ * 1000 /*msec*/, m_AptRebootListener, SLOT(checkForReboot()));
 
143
 
143
144
    if (packagekitIsRunning) {
144
145
        // PackageKit is running set the session Proxy
145
146
        setProxy();
251
252
    }
252
253
}
253
254
 
254
 
void ApperdThread::transactionListChanged(const QStringList &tids)
255
 
{
256
 
    if (tids.isEmpty()) {
257
 
        // update the last time the cache was refreshed
258
 
        QDateTime lastCacheRefresh;
259
 
        lastCacheRefresh = getTimeSinceRefreshCache();
260
 
        if (lastCacheRefresh != m_lastRefreshCache) {
261
 
            m_lastRefreshCache = lastCacheRefresh;
262
 
        }
263
 
    }
264
 
}
265
 
 
266
 
// This is called when the list of updates changes
267
255
void ApperdThread::updatesChanged()
268
256
{
 
257
    // update the last time the cache was refreshed
 
258
    QDateTime lastCacheRefresh;
 
259
    lastCacheRefresh = getTimeSinceRefreshCache();
 
260
    if (lastCacheRefresh != m_lastRefreshCache) {
 
261
        m_lastRefreshCache = lastCacheRefresh;
 
262
    }
 
263
 
269
264
    bool ignoreBattery = m_configs[CFG_INSTALL_UP_BATTERY].value<bool>();
270
265
    bool ignoreMobile = m_configs[CFG_INSTALL_UP_MOBILE].value<bool>();
271
266