Merge lp:~mandel/ubuntu-download-manager/add-client-lib into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 190
Merged at revision: 211
Proposed branch: lp:~mandel/ubuntu-download-manager/add-client-lib
Merge into: lp:ubuntu-download-manager
Diff against target: 303 lines (+242/-2)
9 files modified
debian/control (+12/-1)
debian/ubuntu-download-manager-client-dev.install (+3/-0)
debian/ubuntu-download-manager-client1.install (+1/-0)
download-manager.pro (+2/-1)
ubuntu-download-manager-client/ubuntu-download-manager-client.pc.in (+12/-0)
ubuntu-download-manager-client/ubuntu-download-manager-client.pro (+38/-0)
ubuntu-download-manager-client/ubuntu-download-manager-client_global.h (+12/-0)
ubuntu-download-manager-client/ubuntu/download_manager/manager.cpp (+98/-0)
ubuntu-download-manager-client/ubuntu/download_manager/manager.h (+64/-0)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/add-client-lib
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
Diego Sarmentero (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+200805@code.launchpad.net

Commit message

Adds the client library that allows apps to use the download manager without knowing the dbus api.

Description of the change

Adds the client library that allows apps to use the download manager without knowing the dbus api.

To post a comment you must log in.
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
Mike McCracken (mikemc) wrote :

Looks good. I'm curious about this line:

234 +#include "moc_manager.cpp"

It seems like that shouldn't be necessary, but it's clearly intentional - there's only one other case where you do this.

Why do you have to include the moc there?

review: Approve
Revision history for this message
Manuel de la Peña (mandel) wrote :

> Looks good. I'm curious about this line:
>
> 234 +#include "moc_manager.cpp"
>
> It seems like that shouldn't be necessary, but it's clearly intentional -
> there's only one other case where you do this.
>
> Why do you have to include the moc there?

Correct, is on purpose, I was looking ahead, the idea is to add the moc_ file there so that the Q_PRIVATE_SLOT template works. But that is something that I knew I will have to do for ABI compatibility but the code is not there in the branch (I have a template that generates this kind of files).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-12-03 12:25:56 +0000
3+++ debian/control 2014-01-08 10:56:59 +0000
4@@ -36,7 +36,18 @@
5 Description: Ubuntu Download Manager - shared library
6 Ubuntu Download Manager performs downloads from a centralized location.
7 .
8- This package includes the shared library.
9+ This package includes the private shared library.
10+
11+Package: ubuntu-download-manager-client1
12+Section: libs
13+Architecture: any
14+Depends: ${misc:Depends},
15+ ${shlibs:Depends},
16+ ubuntu-download-manager-common1 (= ${binary:Version}),
17+Description: Ubuntu Download Manager - shared library
18+ Ubuntu Download Manager performs downloads from a centralized location.
19+ .
20+ This package includes the public shared library.
21
22 Package: ubuntu-download-manager
23 Section: net
24
25=== added file 'debian/ubuntu-download-manager-client-dev.install'
26--- debian/ubuntu-download-manager-client-dev.install 1970-01-01 00:00:00 +0000
27+++ debian/ubuntu-download-manager-client-dev.install 2014-01-08 10:56:59 +0000
28@@ -0,0 +1,3 @@
29+usr/include/ubuntu/download_manager/manager.h
30+usr/lib/*/libubuntu-download-manager-client.so
31+usr/lib/*/pkgconfig/ubuntu-download-manager-client.pc
32
33=== added file 'debian/ubuntu-download-manager-client1.install'
34--- debian/ubuntu-download-manager-client1.install 1970-01-01 00:00:00 +0000
35+++ debian/ubuntu-download-manager-client1.install 2014-01-08 10:56:59 +0000
36@@ -0,0 +1,1 @@
37+usr/lib/libubuntu-download-manager-client.so.*
38
39=== modified file 'download-manager.pro'
40--- download-manager.pro 2013-12-03 12:25:56 +0000
41+++ download-manager.pro 2014-01-08 10:56:59 +0000
42@@ -7,7 +7,8 @@
43 ubuntu-download-manager-common \
44 ubuntu-download-manager-priv \
45 ubuntu-download-manager \
46- ubuntu-download-manager-tests
47+ ubuntu-download-manager-tests \
48+ ubuntu-download-manager-client
49
50 ubuntu-download-manager-priv.depends = ubuntu-download-manager-common
51
52
53=== added directory 'ubuntu-download-manager-client'
54=== added directory 'ubuntu-download-manager-client/ubuntu'
55=== added file 'ubuntu-download-manager-client/ubuntu-download-manager-client.pc.in'
56--- ubuntu-download-manager-client/ubuntu-download-manager-client.pc.in 1970-01-01 00:00:00 +0000
57+++ ubuntu-download-manager-client/ubuntu-download-manager-client.pc.in 2014-01-08 10:56:59 +0000
58@@ -0,0 +1,12 @@
59+prefix=$$INSTALL_PREFIX
60+exec_prefix=${prefix}
61+libdir=$$INSTALL_LIBDIR
62+includedir=${prefix}/include/ubuntu/download_manager
63+
64+Name: ubuntu-download-manager-client
65+Description: Client Ubuntu Download Manager lib
66+Version: $$PROJECT_VERSION
67+Libs: -L${libdir} -lubuntu-download-manager-client
68+Requires: Qt5Core Qt5DBus
69+Cflags: -I${includedir}
70+
71
72=== added file 'ubuntu-download-manager-client/ubuntu-download-manager-client.pro'
73--- ubuntu-download-manager-client/ubuntu-download-manager-client.pro 1970-01-01 00:00:00 +0000
74+++ ubuntu-download-manager-client/ubuntu-download-manager-client.pro 2014-01-08 10:56:59 +0000
75@@ -0,0 +1,38 @@
76+include(../common-project-config.pri)
77+include(../common-vars.pri)
78+
79+QT += dbus
80+QT -= gui
81+
82+TARGET = ubuntu-download-manager-client
83+TEMPLATE = lib
84+
85+DEFINES += UBUNTUDOWNLOADMANAGERCLIENT_LIBRARY
86+
87+SOURCES += ubuntu/download_manager/manager.cpp
88+
89+public_headers = \
90+ ubuntu/download_manager/manager.h
91+
92+private_headers = \
93+ ubuntu-download-manager-client_global.h
94+
95+HEADERS +=\
96+ $$public_headers \
97+ $$private_headers
98+
99+OTHER_FILES += \
100+ ubuntu-download-manager-client.pc.in
101+
102+headers.files = $$public_headers
103+
104+include(../common-installs-config.pri)
105+
106+pkgconfig.files = ubuntu-download-manager-client.pc
107+include(../common-pkgconfig.pri)
108+INSTALLS += pkgconfig
109+
110+LIBS += -L$$OUT_PWD/../ubuntu-download-manager-common/ -lubuntu-download-manager-common
111+
112+INCLUDEPATH += $$PWD/../ubuntu-download-manager-common
113+DEPENDPATH += $$PWD/../ubuntu-download-manager-common
114
115=== added file 'ubuntu-download-manager-client/ubuntu-download-manager-client_global.h'
116--- ubuntu-download-manager-client/ubuntu-download-manager-client_global.h 1970-01-01 00:00:00 +0000
117+++ ubuntu-download-manager-client/ubuntu-download-manager-client_global.h 2014-01-08 10:56:59 +0000
118@@ -0,0 +1,12 @@
119+#ifndef UBUNTUDOWNLOADMANAGERCLIENT_GLOBAL_H
120+#define UBUNTUDOWNLOADMANAGERCLIENT_GLOBAL_H
121+
122+#include <QtCore/qglobal.h>
123+
124+#if defined(UBUNTUDOWNLOADMANAGERCLIENT_LIBRARY)
125+# define UBUNTUDOWNLOADMANAGERCLIENTSHARED_EXPORT Q_DECL_EXPORT
126+#else
127+# define UBUNTUDOWNLOADMANAGERCLIENTSHARED_EXPORT Q_DECL_IMPORT
128+#endif
129+
130+#endif // UBUNTUDOWNLOADMANAGERCLIENT_GLOBAL_H
131
132=== added directory 'ubuntu-download-manager-client/ubuntu/download_manager'
133=== added file 'ubuntu-download-manager-client/ubuntu/download_manager/manager.cpp'
134--- ubuntu-download-manager-client/ubuntu/download_manager/manager.cpp 1970-01-01 00:00:00 +0000
135+++ ubuntu-download-manager-client/ubuntu/download_manager/manager.cpp 2014-01-08 10:56:59 +0000
136@@ -0,0 +1,98 @@
137+/*
138+ * Copyright 2013 Canonical Ltd.
139+ *
140+ * This library is free software; you can redistribute it and/or
141+ * modify it under the terms of version 3 of the GNU Lesser General Public
142+ * License as published by the Free Software Foundation.
143+ *
144+ * This program is distributed in the hope that it will be useful,
145+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
146+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
147+ * General Public License for more details.
148+ *
149+ * You should have received a copy of the GNU Lesser General Public
150+ * License along with this library; if not, write to the
151+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
152+ * Boston, MA 02110-1301, USA.
153+ */
154+
155+#include "manager.h"
156+
157+
158+namespace Ubuntu {
159+
160+namespace DownloadManager {
161+
162+/*
163+ * PRIVATE IMPLEMENTATION
164+ */
165+
166+class ManagerPrivate {
167+ Q_DECLARE_PUBLIC(Manager)
168+
169+ public:
170+ explicit ManagerPrivate(Manager* parent)
171+ : q_ptr(parent) {
172+ }
173+
174+ Download* createDownload(DownloadStruct downStruct) {
175+ Q_UNUSED(downStruct);
176+ return NULL;
177+ }
178+
179+ void createDownload(DownloadStruct downStruct, DownloadCreationCb cb) {
180+ Q_UNUSED(downStruct);
181+ Q_UNUSED(cb);
182+ }
183+
184+ GroupDownload* createDownload(GroupDownloadStruct groupStruct) {
185+ Q_UNUSED(groupStruct);
186+ return NULL;
187+ }
188+
189+ void createDownload(GroupDownloadStruct groupStruct, GroupCreationCb cb) {
190+ Q_UNUSED(groupStruct);
191+ Q_UNUSED(cb);
192+ }
193+
194+ private:
195+ Manager* q_ptr;
196+};
197+
198+/*
199+ * PUBLIC IMPLEMENTATION
200+ */
201+
202+Manager::Manager(QObject* parent)
203+ : QObject(parent){
204+}
205+
206+Download*
207+Manager::createDownload(DownloadStruct downStruct) {
208+ Q_D(Manager);
209+ return d->createDownload(downStruct);
210+}
211+
212+void
213+Manager::createDownload(DownloadStruct downStruct, DownloadCreationCb cb) {
214+ Q_D(Manager);
215+ d->createDownload(downStruct, cb);
216+}
217+
218+GroupDownload*
219+Manager::createDownload(GroupDownloadStruct groupStruct) {
220+ Q_D(Manager);
221+ return d->createDownload(groupStruct);
222+}
223+
224+void
225+Manager::createDownload(GroupDownloadStruct groupStruct, GroupCreationCb cb) {
226+ Q_D(Manager);
227+ d->createDownload(groupStruct, cb);
228+}
229+
230+} // DownloadManager
231+
232+} // Ubuntu
233+
234+#include "moc_manager.cpp"
235
236=== added file 'ubuntu-download-manager-client/ubuntu/download_manager/manager.h'
237--- ubuntu-download-manager-client/ubuntu/download_manager/manager.h 1970-01-01 00:00:00 +0000
238+++ ubuntu-download-manager-client/ubuntu/download_manager/manager.h 2014-01-08 10:56:59 +0000
239@@ -0,0 +1,64 @@
240+/*
241+ * Copyright 2013 Canonical Ltd.
242+ *
243+ * This library is free software; you can redistribute it and/or
244+ * modify it under the terms of version 3 of the GNU Lesser General Public
245+ * License as published by the Free Software Foundation.
246+ *
247+ * This program is distributed in the hope that it will be useful,
248+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
249+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
250+ * General Public License for more details.
251+ *
252+ * You should have received a copy of the GNU Lesser General Public
253+ * License along with this library; if not, write to the
254+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
255+ * Boston, MA 02110-1301, USA.
256+ */
257+
258+#ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H
259+#define UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H
260+
261+#include <functional>
262+#include <QObject>
263+#include <ubuntu/download_manager/download_struct.h>
264+#include <ubuntu/download_manager/group_download_struct.h>
265+#include "ubuntu-download-manager-client_global.h"
266+
267+namespace Ubuntu {
268+
269+namespace DownloadManager {
270+
271+class Download;
272+class GroupDownload;
273+
274+typedef std::function<void(Download*)> DownloadCreationCb;
275+typedef std::function<void(GroupDownload*)> GroupCreationCb;
276+
277+class ManagerPrivate;
278+class UBUNTUDOWNLOADMANAGERCLIENTSHARED_EXPORT Manager : public QObject {
279+ Q_DECLARE_PRIVATE(Manager)
280+ Q_OBJECT
281+
282+ public:
283+ explicit Manager(QObject* parent);
284+
285+ virtual Download* createDownload(DownloadStruct downStruct);
286+ virtual void createDownload(DownloadStruct downStruct, DownloadCreationCb cb);
287+ virtual GroupDownload* createDownload(GroupDownloadStruct groupStruct);
288+ virtual void createDownload(GroupDownloadStruct groupStruct, GroupCreationCb cb);
289+
290+ signals:
291+ void downloadCreated(Download* down);
292+ void groupCreated(GroupDownload* down);
293+
294+ private:
295+ // use pimpl pattern so that users do not have to be recompiled
296+ ManagerPrivate* d_ptr;
297+};
298+
299+} // DownloadManager
300+
301+} // Ubuntu
302+
303+#endif // UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H

Subscribers

People subscribed via source and target branches