Merge lp:~mandel/ubuntu-download-manager/single-daemon into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 100
Merged at revision: 96
Proposed branch: lp:~mandel/ubuntu-download-manager/single-daemon
Merge into: lp:ubuntu-download-manager
Diff against target: 558 lines (+278/-24)
13 files modified
libubuntudownloadmanager/application.cpp (+65/-0)
libubuntudownloadmanager/application.h (+39/-0)
libubuntudownloadmanager/download_daemon.cpp (+26/-12)
libubuntudownloadmanager/download_daemon.h (+6/-2)
libubuntudownloadmanager/libubuntudownloadmanager.pro (+4/-2)
ubuntu-download-manager-tests/fake.cpp (+20/-0)
ubuntu-download-manager-tests/fake.h (+13/-0)
ubuntu-download-manager-tests/fake_application.cpp (+37/-0)
ubuntu-download-manager-tests/fake_application.h (+35/-0)
ubuntu-download-manager-tests/test_download_daemon.cpp (+24/-4)
ubuntu-download-manager-tests/test_download_daemon.h (+2/-0)
ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro (+4/-2)
ubuntu-download-manager/main.cpp (+3/-2)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/single-daemon
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Diego Sarmentero (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+181280@code.launchpad.net

Commit message

Ensure that a single instance of the daemon can be ran.

Description of the change

Ensure that a single instance of the daemon can be ran.

To post a comment you must log in.
100. By Manuel de la Peña

Fixed broken tests.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

plus one

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'libubuntudownloadmanager/application.cpp'
--- libubuntudownloadmanager/application.cpp 1970-01-01 00:00:00 +0000
+++ libubuntudownloadmanager/application.cpp 2013-08-21 12:22:01 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 2013 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#include <QDebug>
20#include <QCoreApplication>
21#include "./application.h"
22
23/*
24 * PRIVATE IMPLEMENTATION
25 */
26
27class ApplicationPrivate {
28 Q_DECLARE_PUBLIC(Application)
29
30 public:
31 explicit ApplicationPrivate(Application* parent);
32
33 virtual void exit(int returnCode);
34
35 private:
36 Application* q_ptr;
37};
38
39ApplicationPrivate::ApplicationPrivate(Application* parent)
40 : q_ptr(parent) {
41}
42
43void
44ApplicationPrivate::exit(int returnCode) {
45 // get the application instance and exit
46 QCoreApplication* app = QCoreApplication::instance();
47 app->exit(returnCode);
48}
49
50/*
51 * PUBLIC IMPLEMENTATION
52 */
53
54
55Application::Application(QObject *parent)
56 : QObject(parent),
57 d_ptr(new ApplicationPrivate(this)) {
58}
59
60void
61Application::exit(int returnCode) {
62 Q_D(Application);
63 qDebug() << "Exit app" << returnCode;
64 d->exit(returnCode);
65}
066
=== added file 'libubuntudownloadmanager/application.h'
--- libubuntudownloadmanager/application.h 1970-01-01 00:00:00 +0000
+++ libubuntudownloadmanager/application.h 2013-08-21 12:22:01 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2013 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#ifndef DOWNLOADER_LIB_APPLICATION_H
20#define DOWNLOADER_LIB_APPLICATION_H
21
22#include <QObject>
23
24class ApplicationPrivate;
25class Application : public QObject {
26 Q_OBJECT
27 Q_DECLARE_PRIVATE(Application)
28
29 public:
30 explicit Application(QObject *parent = 0);
31
32 virtual void exit(int returnCode = 0);
33
34 private:
35 // use pimpl so that we can mantains ABI compatibility
36 ApplicationPrivate* d_ptr;
37};
38
39#endif // DOWNLOADER_LIB_APPLICATION_H
040
=== modified file 'libubuntudownloadmanager/download_daemon.cpp'
--- libubuntudownloadmanager/download_daemon.cpp 2013-08-12 14:11:21 +0000
+++ libubuntudownloadmanager/download_daemon.cpp 2013-08-21 12:22:01 +0000
@@ -19,6 +19,7 @@
19#include <QtDBus/QDBusConnection>19#include <QtDBus/QDBusConnection>
20#include <QDebug>20#include <QDebug>
21#include <QSharedPointer>21#include <QSharedPointer>
22#include "./application.h"
22#include "./logger.h"23#include "./logger.h"
23#include "./download_manager.h"24#include "./download_manager.h"
24#include "./download_manager_adaptor.h"25#include "./download_manager_adaptor.h"
@@ -33,16 +34,18 @@
3334
34 public:35 public:
35 explicit DownloadDaemonPrivate(DownloadDaemon* parent);36 explicit DownloadDaemonPrivate(DownloadDaemon* parent);
36 explicit DownloadDaemonPrivate(DBusConnection* conn,37 explicit DownloadDaemonPrivate(Application* app,
38 DBusConnection* conn,
37 DownloadDaemon* parent);39 DownloadDaemon* parent);
38 ~DownloadDaemonPrivate();40 ~DownloadDaemonPrivate();
3941
40 bool start();42 void start();
4143
42 private:44 private:
43 void init();45 void init();
4446
45 private:47 private:
48 Application* _app;
46 QSharedPointer<DBusConnection> _conn;49 QSharedPointer<DBusConnection> _conn;
47 DownloadManager* _downInterface;50 DownloadManager* _downInterface;
48 DownloadManagerAdaptor* _downAdaptor;51 DownloadManagerAdaptor* _downAdaptor;
@@ -51,14 +54,17 @@
5154
52DownloadDaemonPrivate::DownloadDaemonPrivate(DownloadDaemon* parent)55DownloadDaemonPrivate::DownloadDaemonPrivate(DownloadDaemon* parent)
53 : q_ptr(parent) {56 : q_ptr(parent) {
57 _app = new Application();
54 _conn = QSharedPointer<DBusConnection>(new DBusConnection());58 _conn = QSharedPointer<DBusConnection>(new DBusConnection());
55 _downInterface = new DownloadManager(_conn, q_ptr);59 _downInterface = new DownloadManager(_conn, q_ptr);
56 init();60 init();
57}61}
5862
59DownloadDaemonPrivate::DownloadDaemonPrivate(DBusConnection* conn,63DownloadDaemonPrivate::DownloadDaemonPrivate(Application* app,
64 DBusConnection* conn,
60 DownloadDaemon* parent)65 DownloadDaemon* parent)
61 : _conn(conn),66 : _app(app),
67 _conn(conn),
62 q_ptr(parent) {68 q_ptr(parent) {
63 _downInterface = new DownloadManager(_conn);69 _downInterface = new DownloadManager(_conn);
64 init();70 init();
@@ -79,12 +85,14 @@
79 // no need to delete the adaptor because the interface is its parent85 // no need to delete the adaptor because the interface is its parent
80 if (_downInterface)86 if (_downInterface)
81 delete _downInterface;87 delete _downInterface;
88 if (_app)
89 delete _app;
8290
83 // stop logging91 // stop logging
84 Logger::setupLogging();92 Logger::setupLogging();
85}93}
8694
87bool95void
88DownloadDaemonPrivate::start() {96DownloadDaemonPrivate::start() {
89 qDebug() << "Starting daemon";97 qDebug() << "Starting daemon";
90 _downAdaptor = new DownloadManagerAdaptor(_downInterface);98 _downAdaptor = new DownloadManagerAdaptor(_downInterface);
@@ -94,10 +102,14 @@
94 << "com.canonical.applications.Downloader";102 << "com.canonical.applications.Downloader";
95 ret = _conn->registerObject("/", _downInterface);103 ret = _conn->registerObject("/", _downInterface);
96 qDebug() << ret;104 qDebug() << ret;
97 return ret;105 if (!ret) {
106 qDebug() << "Could not register interface";
107 _app->exit(-1);
108 }
109 return;
98 }110 }
99 qDebug() << "Could not register";111 qDebug() << "Could not register service";
100 return false;112 _app->exit(-1);
101}113}
102114
103/**115/**
@@ -109,13 +121,15 @@
109 d_ptr(new DownloadDaemonPrivate(this)) {121 d_ptr(new DownloadDaemonPrivate(this)) {
110}122}
111123
112DownloadDaemon::DownloadDaemon(DBusConnection* conn, QObject *parent)124DownloadDaemon::DownloadDaemon(Application* app,
125 DBusConnection* conn,
126 QObject *parent)
113 : QObject(parent),127 : QObject(parent),
114 d_ptr(new DownloadDaemonPrivate(conn, this)) {128 d_ptr(new DownloadDaemonPrivate(app, conn, this)) {
115}129}
116130
117bool131void
118DownloadDaemon::start() {132DownloadDaemon::start() {
119 Q_D(DownloadDaemon);133 Q_D(DownloadDaemon);
120 return d->start();134 d->start();
121}135}
122136
=== modified file 'libubuntudownloadmanager/download_daemon.h'
--- libubuntudownloadmanager/download_daemon.h 2013-07-23 14:39:41 +0000
+++ libubuntudownloadmanager/download_daemon.h 2013-08-21 12:22:01 +0000
@@ -21,6 +21,7 @@
2121
22#include <QObject>22#include <QObject>
23#include "./app-downloader-lib_global.h"23#include "./app-downloader-lib_global.h"
24#include "./application.h"
24#include "./dbus_connection.h"25#include "./dbus_connection.h"
2526
26class DownloadDaemonPrivate;27class DownloadDaemonPrivate;
@@ -30,9 +31,12 @@
3031
31 public:32 public:
32 explicit DownloadDaemon(QObject *parent = 0);33 explicit DownloadDaemon(QObject *parent = 0);
33 explicit DownloadDaemon(DBusConnection* conn, QObject *parent = 0);34 explicit DownloadDaemon(Application* app,
35 DBusConnection* conn,
36 QObject *parent = 0);
3437
35 bool start();38 public slots:
39 void start();
3640
37 private:41 private:
38 // use pimpl so that we can mantains ABI compatibility42 // use pimpl so that we can mantains ABI compatibility
3943
=== modified file 'libubuntudownloadmanager/libubuntudownloadmanager.pro'
--- libubuntudownloadmanager/libubuntudownloadmanager.pro 2013-07-26 15:50:37 +0000
+++ libubuntudownloadmanager/libubuntudownloadmanager.pro 2013-08-21 12:22:01 +0000
@@ -23,7 +23,8 @@
23 xdg_basedir.cpp \23 xdg_basedir.cpp \
24 process.cpp \24 process.cpp \
25 process_factory.cpp \25 process_factory.cpp \
26 logger.cpp26 logger.cpp \
27 application.cpp
2728
28HEADERS +=\29HEADERS +=\
29 app-downloader-lib_global.h \30 app-downloader-lib_global.h \
@@ -42,7 +43,8 @@
42 process.h \43 process.h \
43 process_factory.h \44 process_factory.h \
44 metatypes.h \45 metatypes.h \
45 logger.h46 logger.h \
47 application.h
4648
47OTHER_FILES += \49OTHER_FILES += \
48 generate_adaptors.sh \50 generate_adaptors.sh \
4951
=== modified file 'ubuntu-download-manager-tests/fake.cpp'
--- ubuntu-download-manager-tests/fake.cpp 2013-07-23 16:29:36 +0000
+++ ubuntu-download-manager-tests/fake.cpp 2013-08-21 12:22:01 +0000
@@ -79,6 +79,26 @@
79}79}
8080
81/*81/*
82 * INT WRAPPER
83 */
84
85IntWrapper::IntWrapper(int value, QObject* parent)
86 : QObject(parent),
87 _value(value) {
88}
89
90
91int
92IntWrapper::value() {
93 return _value;
94}
95
96void
97IntWrapper::setValue(int value) {
98 _value = value;
99}
100
101/*
82 * UINT WRAPPER102 * UINT WRAPPER
83 */103 */
84104
85105
=== modified file 'ubuntu-download-manager-tests/fake.h'
--- ubuntu-download-manager-tests/fake.h 2013-07-23 17:45:38 +0000
+++ ubuntu-download-manager-tests/fake.h 2013-08-21 12:22:01 +0000
@@ -66,6 +66,19 @@
66 QStringList _value;66 QStringList _value;
67};67};
6868
69class IntWrapper : public QObject {
70 Q_OBJECT
71
72 public:
73 IntWrapper(int value, QObject* parent = 0);
74
75 int value();
76 void setValue(int value);
77
78 private:
79 int _value;
80};
81
69class UintWrapper : public QObject {82class UintWrapper : public QObject {
70 Q_OBJECT83 Q_OBJECT
7184
7285
=== added file 'ubuntu-download-manager-tests/fake_application.cpp'
--- ubuntu-download-manager-tests/fake_application.cpp 1970-01-01 00:00:00 +0000
+++ ubuntu-download-manager-tests/fake_application.cpp 2013-08-21 12:22:01 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright 2013 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#include "fake_application.h"
20
21FakeApplication::FakeApplication(QObject *parent)
22 : Application(parent),
23 Fake() {
24}
25
26void
27FakeApplication::exit(int returnCode) {
28 if (_recording) {
29 QList<QObject*> inParams;
30 inParams.append(new IntWrapper(returnCode));
31
32 QList<QObject*> outParams;
33 MethodParams params(inParams, outParams);
34 MethodData methodData("exit", params);
35 _called.append(methodData);
36 }
37}
038
=== added file 'ubuntu-download-manager-tests/fake_application.h'
--- ubuntu-download-manager-tests/fake_application.h 1970-01-01 00:00:00 +0000
+++ ubuntu-download-manager-tests/fake_application.h 2013-08-21 12:22:01 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright 2013 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#ifndef FAKE_APPLICATION_H
20#define FAKE_APPLICATION_H
21
22#include <QObject>
23#include <application.h>
24#include "./fake.h"
25
26class FakeApplication : public Application, public Fake {
27 Q_OBJECT
28
29 public:
30 explicit FakeApplication(QObject *parent = 0);
31
32 void exit(int returnCode = 0) override;
33};
34
35#endif // FAKE_APPLICATION_H
036
=== modified file 'ubuntu-download-manager-tests/test_download_daemon.cpp'
--- ubuntu-download-manager-tests/test_download_daemon.cpp 2013-07-24 13:56:44 +0000
+++ ubuntu-download-manager-tests/test_download_daemon.cpp 2013-08-21 12:22:01 +0000
@@ -24,12 +24,15 @@
2424
25void25void
26TestDownloadDaemon::init() {26TestDownloadDaemon::init() {
27 _app = new FakeApplication();
27 _conn = new FakeDBusConnection();28 _conn = new FakeDBusConnection();
28 _daemon = new DownloadDaemon(_conn);29 _daemon = new DownloadDaemon(_app, _conn, this);
29}30}
3031
31void32void
32TestDownloadDaemon::cleanup() {33TestDownloadDaemon::cleanup() {
34 if (_app != NULL)
35 delete _app;
33 if (_conn != NULL)36 if (_conn != NULL)
34 delete _conn;37 delete _conn;
35 if (_daemon != NULL)38 if (_daemon != NULL)
@@ -41,14 +44,19 @@
41 _conn->setRegisterServiceResult(true);44 _conn->setRegisterServiceResult(true);
42 _conn->setRegisterObjectResult(true);45 _conn->setRegisterObjectResult(true);
43 _conn->record();46 _conn->record();
47 _app->record();
4448
45 QVERIFY(_daemon->start());49 _daemon->start();
4650
47 QList<MethodData> calledMethods = _conn->calledMethods();51 QList<MethodData> calledMethods = _conn->calledMethods();
4852
49 QCOMPARE(2, calledMethods.count());53 QCOMPARE(2, calledMethods.count());
50 QCOMPARE(QString("registerService"), calledMethods[0].methodName());54 QCOMPARE(QString("registerService"), calledMethods[0].methodName());
51 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());55 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());
56
57 // assert exit was NOT called
58 calledMethods = _app->calledMethods();
59 QCOMPARE(0, calledMethods.count());
52}60}
5361
54void62void
@@ -56,13 +64,19 @@
56 _conn->setRegisterServiceResult(false);64 _conn->setRegisterServiceResult(false);
57 _conn->setRegisterObjectResult(true);65 _conn->setRegisterObjectResult(true);
58 _conn->record();66 _conn->record();
67 _app->record();
5968
60 QVERIFY(!_daemon->start());69 _daemon->start();
6170
62 QList<MethodData> calledMethods = _conn->calledMethods();71 QList<MethodData> calledMethods = _conn->calledMethods();
6372
64 QCOMPARE(1, calledMethods.count());73 QCOMPARE(1, calledMethods.count());
65 QCOMPARE(QString("registerService"), calledMethods[0].methodName());74 QCOMPARE(QString("registerService"), calledMethods[0].methodName());
75
76 // assert exit was called
77 calledMethods = _app->calledMethods();
78 QCOMPARE(1, calledMethods.count());
79 QCOMPARE(QString("exit"), calledMethods[0].methodName());
66}80}
6781
68void82void
@@ -70,12 +84,18 @@
70 _conn->setRegisterServiceResult(true);84 _conn->setRegisterServiceResult(true);
71 _conn->setRegisterObjectResult(false);85 _conn->setRegisterObjectResult(false);
72 _conn->record();86 _conn->record();
87 _app->record();
7388
74 QVERIFY(!_daemon->start());89 _daemon->start();
7590
76 QList<MethodData> calledMethods = _conn->calledMethods();91 QList<MethodData> calledMethods = _conn->calledMethods();
7792
78 QCOMPARE(2, calledMethods.count());93 QCOMPARE(2, calledMethods.count());
79 QCOMPARE(QString("registerService"), calledMethods[0].methodName());94 QCOMPARE(QString("registerService"), calledMethods[0].methodName());
80 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());95 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());
96
97 // assert exit was called
98 calledMethods = _app->calledMethods();
99 QCOMPARE(1, calledMethods.count());
100 QCOMPARE(QString("exit"), calledMethods[0].methodName());
81}101}
82102
=== modified file 'ubuntu-download-manager-tests/test_download_daemon.h'
--- ubuntu-download-manager-tests/test_download_daemon.h 2013-07-24 13:58:02 +0000
+++ ubuntu-download-manager-tests/test_download_daemon.h 2013-08-21 12:22:01 +0000
@@ -21,6 +21,7 @@
2121
22#include <QObject>22#include <QObject>
23#include <download_daemon.h>23#include <download_daemon.h>
24#include "./fake_application.h"
24#include "./fake_dbus_connection.h"25#include "./fake_dbus_connection.h"
25#include "./test_runner.h"26#include "./test_runner.h"
2627
@@ -39,6 +40,7 @@
39 void testStartFailObjectRegister();40 void testStartFailObjectRegister();
4041
41 private:42 private:
43 FakeApplication* _app;
42 FakeDBusConnection* _conn;44 FakeDBusConnection* _conn;
43 DownloadDaemon* _daemon;45 DownloadDaemon* _daemon;
44};46};
4547
=== modified file 'ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro'
--- ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro 2013-07-21 14:30:42 +0000
+++ ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro 2013-08-21 12:22:01 +0000
@@ -31,7 +31,8 @@
31 fake_uuid_factory.cpp \31 fake_uuid_factory.cpp \
32 fake_system_network_info.cpp \32 fake_system_network_info.cpp \
33 fake_process.cpp \33 fake_process.cpp \
34 fake_process_factory.cpp34 fake_process_factory.cpp \
35 fake_application.cpp
3536
36HEADERS += \37HEADERS += \
37 fake.h \38 fake.h \
@@ -51,7 +52,8 @@
51 fake_uuid_factory.h \52 fake_uuid_factory.h \
52 fake_system_network_info.h \53 fake_system_network_info.h \
53 fake_process.h \54 fake_process.h \
54 fake_process_factory.h55 fake_process_factory.h \
56 fake_application.h
5557
56LIBS += -L$$OUT_PWD/../libubuntudownloadmanager/ -lubuntudownloadmanager58LIBS += -L$$OUT_PWD/../libubuntudownloadmanager/ -lubuntudownloadmanager
5759
5860
=== modified file 'ubuntu-download-manager/main.cpp'
--- ubuntu-download-manager/main.cpp 2013-07-23 16:23:40 +0000
+++ ubuntu-download-manager/main.cpp 2013-08-21 12:22:01 +0000
@@ -16,15 +16,16 @@
16 * Boston, MA 02110-1301, USA.16 * Boston, MA 02110-1301, USA.
17 */17 */
1818
19#include <QTimer>
19#include <QCoreApplication>20#include <QCoreApplication>
20#include <download_daemon.h>21#include <download_daemon.h>
2122
22int main(int argc, char *argv[]) {23int main(int argc, char *argv[]) {
23 QCoreApplication a(argc, argv);24 QCoreApplication a(argc, argv);
2425
25 // TODO(mandel): deal with the fact that we might be already running
26 DownloadDaemon* daemon = new DownloadDaemon();26 DownloadDaemon* daemon = new DownloadDaemon();
27 daemon->start();27 // use a singleShot timer so that we start after exec so that exit works
28 QTimer::singleShot(0, daemon, SLOT(start()));
2829
29 return a.exec();30 return a.exec();
30}31}

Subscribers

People subscribed via source and target branches