Merge lp:~mandel/ubuntu-download-manager/system-bus into lp:ubuntu-download-manager
- system-bus
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Manuel de la Peña | ||||
Approved revision: | 117 | ||||
Merged at revision: | 133 | ||||
Proposed branch: | lp:~mandel/ubuntu-download-manager/system-bus | ||||
Merge into: | lp:ubuntu-download-manager | ||||
Prerequisite: | lp:~mandel/ubuntu-download-manager/network-errors-management | ||||
Diff against target: |
423 lines (+159/-55) 13 files modified
debian/ubuntu-download-manager.install (+2/-1) libubuntudownloadmanager/apparmor.cpp (+34/-11) libubuntudownloadmanager/apparmor.h (+3/-0) libubuntudownloadmanager/dbus_connection.cpp (+29/-29) libubuntudownloadmanager/dbus_connection.h (+1/-0) libubuntudownloadmanager/download_daemon.cpp (+4/-2) libubuntudownloadmanager/download_manager.cpp (+1/-1) libubuntudownloadmanager/logger.cpp (+39/-6) libubuntudownloadmanager/logger.h (+10/-0) ubuntu-download-manager-tests/irl_tests.py (+1/-1) ubuntu-download-manager/com.canonical.applications.Downloader.conf (+18/-0) ubuntu-download-manager/com.canonical.applications.Downloader.service (+4/-0) ubuntu-download-manager/ubuntu-download-manager.pro (+13/-4) |
||||
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/system-bus | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Diego Sarmentero (community) | Approve | ||
Mike McCracken (community) | Approve | ||
Review via email: mp+186832@code.launchpad.net |
Commit message
Provide system dbus API to be used by apps such as the image updates.
Description of the change
Provide system dbus API to be used by apps such as the image updates.
Manuel de la Peña (mandel) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:115
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Mike McCracken (mikemc) wrote : | # |
irl_tests.py with system bus seems to work OK for me.
I was a little thrown by the parameters in progress_callback() being
backwards, though :)
really minor note - looks like the added calls to lastError() in
download_daemon.cpp don't add a space before they dump
"QDBUSError(
literal before them.
super nitpicky naming suggestion - initSessionBus() and
initSystemBus() sound like they are initializing the busses. Why not
name them after what they'll do, like openLogFile() and
openSyslogConne
also, a note for the future branch where you add syslog - why not
separate generating the message (which looks the same for both cases)
from sending it to the logfile/syslog? logSystemMessage() and
logSessionMessage share a lot of code.
Mike McCracken (mikemc) wrote : | # |
never mind the note about a space before lastError(). TIL qDebug does some padding of its own.
Mike McCracken (mikemc) wrote : | # |
…and never mind the note about the progress_callback() parameters being flipped, I see the next branch fixes that
Manuel de la Peña (mandel) wrote : | # |
> irl_tests.py with system bus seems to work OK for me.
> I was a little thrown by the parameters in progress_callback() being
> backwards, though :)
>
> really minor note - looks like the added calls to lastError() in
> download_daemon.cpp don't add a space before they dump
> "QDBUSError(
> literal before them.
>
> super nitpicky naming suggestion - initSessionBus() and
> initSystemBus() sound like they are initializing the busses. Why not
> name them after what they'll do, like openLogFile() and
> openSyslogConne
Sure, lets do that is a goof idea and better now than never.
>
> also, a note for the future branch where you add syslog - why not
> separate generating the message (which looks the same for both cases)
> from sending it to the logfile/syslog? logSystemMessage() and
> logSessionMessage share a lot of code.
Lets do it know, same reason as above.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:116
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
- 117. By Manuel de la Peña
-
Merged with trunk.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:117
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'debian/ubuntu-download-manager.install' | |||
2 | --- debian/ubuntu-download-manager.install 2013-07-21 20:16:06 +0000 | |||
3 | +++ debian/ubuntu-download-manager.install 2013-09-24 09:53:05 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | usr/bin/ubuntu-download-manager | 1 | usr/bin/ubuntu-download-manager |
6 | 2 | usr/share/dbus-1/services/ubuntu-download-manager.service | 2 | usr/share/dbus-1/services/ubuntu-download-manager.service |
8 | 3 | 3 | usr/share/dbus-1/system-services/com.canonical.applications.Downloader.service | |
9 | 4 | etc/dbus-1/system.d/com.canonical.applications.Downloader.conf | ||
10 | 4 | 5 | ||
11 | === modified file 'libubuntudownloadmanager/apparmor.cpp' | |||
12 | --- libubuntudownloadmanager/apparmor.cpp 2013-09-18 10:18:24 +0000 | |||
13 | +++ libubuntudownloadmanager/apparmor.cpp 2013-09-24 09:53:05 +0000 | |||
14 | @@ -19,6 +19,8 @@ | |||
15 | 19 | #include <errno.h> | 19 | #include <errno.h> |
16 | 20 | #include <nih/alloc.h> | 20 | #include <nih/alloc.h> |
17 | 21 | #include <libnih-dbus.h> | 21 | #include <libnih-dbus.h> |
18 | 22 | #include <sys/types.h> | ||
19 | 23 | #include <unistd.h> | ||
20 | 22 | #include <QDBusConnection> | 24 | #include <QDBusConnection> |
21 | 23 | #include <QDebug> | 25 | #include <QDebug> |
22 | 24 | #include <QRegExp> | 26 | #include <QRegExp> |
23 | @@ -35,13 +37,21 @@ | |||
24 | 35 | Q_DECLARE_PUBLIC(AppArmor) | 37 | Q_DECLARE_PUBLIC(AppArmor) |
25 | 36 | 38 | ||
26 | 37 | public: | 39 | public: |
28 | 38 | explicit AppArmorPrivate(AppArmor* parent) | 40 | AppArmorPrivate(AppArmor* parent) |
29 | 39 | : q_ptr(parent) { | 41 | : q_ptr(parent) { |
30 | 40 | _dbus = new DBusProxy("org.freedesktop.DBus", "/", | 42 | _dbus = new DBusProxy("org.freedesktop.DBus", "/", |
31 | 41 | QDBusConnection::sessionBus()); | 43 | QDBusConnection::sessionBus()); |
32 | 42 | _uuidFactory = new UuidFactory(); | 44 | _uuidFactory = new UuidFactory(); |
33 | 43 | } | 45 | } |
34 | 44 | 46 | ||
35 | 47 | AppArmorPrivate(QSharedPointer<DBusConnection> connection, | ||
36 | 48 | AppArmor* parent) | ||
37 | 49 | : q_ptr(parent) { | ||
38 | 50 | _dbus = new DBusProxy("org.freedesktop.DBus", "/", | ||
39 | 51 | connection->connection()); | ||
40 | 52 | _uuidFactory = new UuidFactory(); | ||
41 | 53 | } | ||
42 | 54 | |||
43 | 45 | QString getUuidPath(QUuid id, QString path) { | 55 | QString getUuidPath(QUuid id, QString path) { |
44 | 46 | qDebug() << __PRETTY_FUNCTION__ << path; | 56 | qDebug() << __PRETTY_FUNCTION__ << path; |
45 | 47 | QString idString = path + "/" + id.toString().replace( | 57 | QString idString = path + "/" + id.toString().replace( |
46 | @@ -65,17 +75,24 @@ | |||
47 | 65 | } | 75 | } |
48 | 66 | 76 | ||
49 | 67 | QString getLocalPath(const QString& appId) { | 77 | QString getLocalPath(const QString& appId) { |
56 | 68 | QStringList pathComponents; | 78 | // if the service is running as root we will always return /tmp |
57 | 69 | if (!appId.isEmpty()) { | 79 | // as the local path root |
58 | 70 | QStringList appIdInfo = appId.split("_"); | 80 | if (getuid() == 0){ |
59 | 71 | if (appIdInfo.count() > 0) | 81 | qDebug() << "Running as system bus using /tmp for downloads"; |
60 | 72 | pathComponents << appIdInfo[0]; | 82 | return QString("/tmp"); |
61 | 73 | } | 83 | } else { |
62 | 84 | QStringList pathComponents; | ||
63 | 85 | if (!appId.isEmpty()) { | ||
64 | 86 | QStringList appIdInfo = appId.split("_"); | ||
65 | 87 | if (appIdInfo.count() > 0) | ||
66 | 88 | pathComponents << appIdInfo[0]; | ||
67 | 89 | } | ||
68 | 74 | 90 | ||
73 | 75 | pathComponents << "Downloads"; | 91 | pathComponents << "Downloads"; |
74 | 76 | QString localPath = XDGBasedir::saveDataPath(pathComponents); | 92 | QString localPath = XDGBasedir::saveDataPath(pathComponents); |
75 | 77 | qDebug() << "Local path is" << localPath; | 93 | qDebug() << "Local path is" << localPath; |
76 | 78 | return localPath; | 94 | return localPath; |
77 | 95 | } // not root | ||
78 | 79 | } | 96 | } |
79 | 80 | 97 | ||
80 | 81 | void getSecurePath(const QString& connName, | 98 | void getSecurePath(const QString& connName, |
81 | @@ -159,6 +176,12 @@ | |||
82 | 159 | d_ptr(new AppArmorPrivate(this)) { | 176 | d_ptr(new AppArmorPrivate(this)) { |
83 | 160 | } | 177 | } |
84 | 161 | 178 | ||
85 | 179 | AppArmor::AppArmor(QSharedPointer<DBusConnection> connection, | ||
86 | 180 | QObject *parent) | ||
87 | 181 | : QObject(parent), | ||
88 | 182 | d_ptr(new AppArmorPrivate(connection, this)) { | ||
89 | 183 | } | ||
90 | 184 | |||
91 | 162 | void | 185 | void |
92 | 163 | AppArmor::getDBusPath(QUuid& id, QString& dbusPath) { | 186 | AppArmor::getDBusPath(QUuid& id, QString& dbusPath) { |
93 | 164 | Q_D(AppArmor); | 187 | Q_D(AppArmor); |
94 | 165 | 188 | ||
95 | === modified file 'libubuntudownloadmanager/apparmor.h' | |||
96 | --- libubuntudownloadmanager/apparmor.h 2013-09-18 10:18:24 +0000 | |||
97 | +++ libubuntudownloadmanager/apparmor.h 2013-09-24 09:53:05 +0000 | |||
98 | @@ -22,7 +22,9 @@ | |||
99 | 22 | #include <QObject> | 22 | #include <QObject> |
100 | 23 | #include <QPair> | 23 | #include <QPair> |
101 | 24 | #include <QString> | 24 | #include <QString> |
102 | 25 | #include <QSharedPointer> | ||
103 | 25 | #include <QUuid> | 26 | #include <QUuid> |
104 | 27 | #include "./dbus_connection.h" | ||
105 | 26 | 28 | ||
106 | 27 | class AppArmorPrivate; | 29 | class AppArmorPrivate; |
107 | 28 | class AppArmor : public QObject { | 30 | class AppArmor : public QObject { |
108 | @@ -31,6 +33,7 @@ | |||
109 | 31 | 33 | ||
110 | 32 | public: | 34 | public: |
111 | 33 | explicit AppArmor(QObject *parent = 0); | 35 | explicit AppArmor(QObject *parent = 0); |
112 | 36 | AppArmor(QSharedPointer<DBusConnection> connection, QObject *parent = 0); | ||
113 | 34 | 37 | ||
114 | 35 | virtual void getDBusPath(QUuid& id, QString& dbusPath); | 38 | virtual void getDBusPath(QUuid& id, QString& dbusPath); |
115 | 36 | 39 | ||
116 | 37 | 40 | ||
117 | === modified file 'libubuntudownloadmanager/dbus_connection.cpp' | |||
118 | --- libubuntudownloadmanager/dbus_connection.cpp 2013-07-23 15:25:55 +0000 | |||
119 | +++ libubuntudownloadmanager/dbus_connection.cpp 2013-09-24 09:53:05 +0000 | |||
120 | @@ -26,42 +26,37 @@ | |||
121 | 26 | class DBusConnectionPrivate { | 26 | class DBusConnectionPrivate { |
122 | 27 | Q_DECLARE_PUBLIC(DBusConnection) | 27 | Q_DECLARE_PUBLIC(DBusConnection) |
123 | 28 | public: | 28 | public: |
129 | 29 | explicit DBusConnectionPrivate(DBusConnection* parent); | 29 | DBusConnectionPrivate(DBusConnection* parent) |
130 | 30 | 30 | : _conn(QDBusConnection::connectToBus(QDBusConnection::ActivationBus, "DBUS")), | |
131 | 31 | bool registerService(const QString& serviceName); | 31 | q_ptr(parent) { |
132 | 32 | bool registerObject(const QString& path, QObject* object, | 32 | } |
133 | 33 | QDBusConnection::RegisterOptions options = QDBusConnection::ExportAdaptors); // NOLINT(whitespace/line_length) | 33 | |
134 | 34 | bool registerService(const QString& serviceName) { | ||
135 | 35 | return _conn.registerService(serviceName); | ||
136 | 36 | } | ||
137 | 37 | |||
138 | 38 | bool registerObject(const QString& path, | ||
139 | 39 | QObject* object, | ||
140 | 40 | QDBusConnection::RegisterOptions options = | ||
141 | 41 | QDBusConnection::ExportAdaptors) { | ||
142 | 42 | return _conn.registerObject(path, object, options); | ||
143 | 43 | } | ||
144 | 44 | |||
145 | 34 | void unregisterObject(const QString& path, | 45 | void unregisterObject(const QString& path, |
147 | 35 | QDBusConnection::UnregisterMode mode = QDBusConnection::UnregisterNode); | 46 | QDBusConnection::UnregisterMode mode = |
148 | 47 | QDBusConnection::UnregisterNode) { | ||
149 | 48 | return _conn.unregisterObject(path, mode); | ||
150 | 49 | } | ||
151 | 50 | |||
152 | 51 | QDBusConnection connection() { | ||
153 | 52 | return _conn; | ||
154 | 53 | } | ||
155 | 36 | 54 | ||
156 | 37 | private: | 55 | private: |
157 | 38 | QDBusConnection _conn; | 56 | QDBusConnection _conn; |
158 | 39 | DBusConnection* q_ptr; | 57 | DBusConnection* q_ptr; |
159 | 40 | }; | 58 | }; |
160 | 41 | 59 | ||
161 | 42 | DBusConnectionPrivate::DBusConnectionPrivate(DBusConnection* parent) | ||
162 | 43 | : _conn(QDBusConnection::sessionBus()), | ||
163 | 44 | q_ptr(parent) { | ||
164 | 45 | } | ||
165 | 46 | |||
166 | 47 | bool | ||
167 | 48 | DBusConnectionPrivate::registerService(const QString& serviceName) { | ||
168 | 49 | return _conn.registerService(serviceName); | ||
169 | 50 | } | ||
170 | 51 | |||
171 | 52 | bool | ||
172 | 53 | DBusConnectionPrivate::registerObject(const QString& path, | ||
173 | 54 | QObject* object, | ||
174 | 55 | QDBusConnection::RegisterOptions options) { // NOLINT(whitespace/line_length) | ||
175 | 56 | return _conn.registerObject(path, object, options); | ||
176 | 57 | } | ||
177 | 58 | |||
178 | 59 | void | ||
179 | 60 | DBusConnectionPrivate::unregisterObject(const QString& path, | ||
180 | 61 | QDBusConnection::UnregisterMode mode) { | ||
181 | 62 | return _conn.unregisterObject(path, mode); | ||
182 | 63 | } | ||
183 | 64 | |||
184 | 65 | /* | 60 | /* |
185 | 66 | * PUBLIC IMPLEMENTATION | 61 | * PUBLIC IMPLEMENTATION |
186 | 67 | */ | 62 | */ |
187 | @@ -92,3 +87,8 @@ | |||
188 | 92 | d->unregisterObject(path, mode); | 87 | d->unregisterObject(path, mode); |
189 | 93 | } | 88 | } |
190 | 94 | 89 | ||
191 | 90 | QDBusConnection | ||
192 | 91 | DBusConnection::connection() { | ||
193 | 92 | Q_D(DBusConnection); | ||
194 | 93 | return d->connection(); | ||
195 | 94 | } | ||
196 | 95 | 95 | ||
197 | === modified file 'libubuntudownloadmanager/dbus_connection.h' | |||
198 | --- libubuntudownloadmanager/dbus_connection.h 2013-07-23 14:03:56 +0000 | |||
199 | +++ libubuntudownloadmanager/dbus_connection.h 2013-09-24 09:53:05 +0000 | |||
200 | @@ -34,6 +34,7 @@ | |||
201 | 34 | QDBusConnection::RegisterOptions options = QDBusConnection::ExportAdaptors); // NOLINT(whitespace/line_length) | 34 | QDBusConnection::RegisterOptions options = QDBusConnection::ExportAdaptors); // NOLINT(whitespace/line_length) |
202 | 35 | virtual void unregisterObject(const QString& path, | 35 | virtual void unregisterObject(const QString& path, |
203 | 36 | QDBusConnection::UnregisterMode mode = QDBusConnection::UnregisterNode); | 36 | QDBusConnection::UnregisterMode mode = QDBusConnection::UnregisterNode); |
204 | 37 | virtual QDBusConnection connection(); | ||
205 | 37 | 38 | ||
206 | 38 | private: | 39 | private: |
207 | 39 | DBusConnectionPrivate* d_ptr; | 40 | DBusConnectionPrivate* d_ptr; |
208 | 40 | 41 | ||
209 | === modified file 'libubuntudownloadmanager/download_daemon.cpp' | |||
210 | --- libubuntudownloadmanager/download_daemon.cpp 2013-09-18 10:38:59 +0000 | |||
211 | +++ libubuntudownloadmanager/download_daemon.cpp 2013-09-24 09:53:05 +0000 | |||
212 | @@ -83,12 +83,14 @@ | |||
213 | 83 | ret = _conn->registerObject("/", _downInterface); | 83 | ret = _conn->registerObject("/", _downInterface); |
214 | 84 | qDebug() << ret; | 84 | qDebug() << ret; |
215 | 85 | if (!ret) { | 85 | if (!ret) { |
217 | 86 | qDebug() << "Could not register interface"; | 86 | qDebug() << "Could not register interface" |
218 | 87 | << _conn->connection().lastError(); | ||
219 | 87 | _app->exit(-1); | 88 | _app->exit(-1); |
220 | 88 | } | 89 | } |
221 | 89 | return; | 90 | return; |
222 | 90 | } | 91 | } |
224 | 91 | qDebug() << "Could not register service"; | 92 | qDebug() << "Could not register service" |
225 | 93 | << _conn->connection().lastError(); | ||
226 | 92 | _app->exit(-1); | 94 | _app->exit(-1); |
227 | 93 | } | 95 | } |
228 | 94 | 96 | ||
229 | 95 | 97 | ||
230 | === modified file 'libubuntudownloadmanager/download_manager.cpp' | |||
231 | --- libubuntudownloadmanager/download_manager.cpp 2013-09-17 10:37:08 +0000 | |||
232 | +++ libubuntudownloadmanager/download_manager.cpp 2013-09-24 09:53:05 +0000 | |||
233 | @@ -37,7 +37,7 @@ | |||
234 | 37 | : _throttle(0), | 37 | : _throttle(0), |
235 | 38 | q_ptr(parent) { | 38 | q_ptr(parent) { |
236 | 39 | _conn = connection; | 39 | _conn = connection; |
238 | 40 | _apparmor = QSharedPointer<AppArmor>(new AppArmor()); | 40 | _apparmor = QSharedPointer<AppArmor>(new AppArmor(connection)); |
239 | 41 | _networkInfo = QSharedPointer<SystemNetworkInfo>( | 41 | _networkInfo = QSharedPointer<SystemNetworkInfo>( |
240 | 42 | new SystemNetworkInfo()); | 42 | new SystemNetworkInfo()); |
241 | 43 | QSharedPointer<RequestFactory> nam = QSharedPointer<RequestFactory>( | 43 | QSharedPointer<RequestFactory> nam = QSharedPointer<RequestFactory>( |
242 | 44 | 44 | ||
243 | === modified file 'libubuntudownloadmanager/logger.cpp' | |||
244 | --- libubuntudownloadmanager/logger.cpp 2013-07-26 15:24:30 +0000 | |||
245 | +++ libubuntudownloadmanager/logger.cpp 2013-09-24 09:53:05 +0000 | |||
246 | @@ -16,6 +16,8 @@ | |||
247 | 16 | * Boston, MA 02110-1301, USA. | 16 | * Boston, MA 02110-1301, USA. |
248 | 17 | */ | 17 | */ |
249 | 18 | 18 | ||
250 | 19 | #include <unistd.h> | ||
251 | 20 | #include <sys/types.h> | ||
252 | 19 | #include <QDateTime> | 21 | #include <QDateTime> |
253 | 20 | #include <QDir> | 22 | #include <QDir> |
254 | 21 | #include <QStandardPaths> | 23 | #include <QStandardPaths> |
255 | @@ -37,6 +39,22 @@ | |||
256 | 37 | } | 39 | } |
257 | 38 | 40 | ||
258 | 39 | Logger::Logger(const QString filename) { | 41 | Logger::Logger(const QString filename) { |
259 | 42 | // decide if we are dealing with a system bus (that should use syslog) | ||
260 | 43 | // or a session bus | ||
261 | 44 | _isSystemBus = getuid() == 0; | ||
262 | 45 | if (_isSystemBus) { | ||
263 | 46 | openSyslogConnection(); | ||
264 | 47 | } else { | ||
265 | 48 | openLogFile(filename); | ||
266 | 49 | } | ||
267 | 50 | |||
268 | 51 | qInstallMessageHandler(_realMessageHandler); | ||
269 | 52 | |||
270 | 53 | _initialized = true; | ||
271 | 54 | } | ||
272 | 55 | |||
273 | 56 | void | ||
274 | 57 | Logger::openLogFile(const QString& filename) { | ||
275 | 40 | if (filename == "") { | 58 | if (filename == "") { |
276 | 41 | _logFileName = getLogDir() + "/ubuntu-download-manager.log"; | 59 | _logFileName = getLogDir() + "/ubuntu-download-manager.log"; |
277 | 42 | } else { | 60 | } else { |
278 | @@ -48,10 +66,11 @@ | |||
279 | 48 | _logStream.setDevice(&_logFile); | 66 | _logStream.setDevice(&_logFile); |
280 | 49 | _logStream.flush(); | 67 | _logStream.flush(); |
281 | 50 | } | 68 | } |
286 | 51 | 69 | } | |
287 | 52 | qInstallMessageHandler(_realMessageHandler); | 70 | |
288 | 53 | 71 | void | |
289 | 54 | _initialized = true; | 72 | Logger::openSyslogConnection() { |
290 | 73 | // TODO(mandel): init syslog | ||
291 | 55 | } | 74 | } |
292 | 56 | 75 | ||
293 | 57 | void | 76 | void |
294 | @@ -106,6 +125,17 @@ | |||
295 | 106 | } | 125 | } |
296 | 107 | 126 | ||
297 | 108 | void | 127 | void |
298 | 128 | Logger::logSessionMessage(const QString &message) { | ||
299 | 129 | _logStream << message; | ||
300 | 130 | _logStream.flush(); | ||
301 | 131 | } | ||
302 | 132 | |||
303 | 133 | void | ||
304 | 134 | Logger::logSystemMessage(const QString &message) { | ||
305 | 135 | Q_UNUSED(message); | ||
306 | 136 | } | ||
307 | 137 | |||
308 | 138 | void | ||
309 | 109 | Logger::logMessage(QtMsgType type, | 139 | Logger::logMessage(QtMsgType type, |
310 | 110 | const QMessageLogContext &context, | 140 | const QMessageLogContext &context, |
311 | 111 | const QString &message) { | 141 | const QString &message) { |
312 | @@ -132,8 +162,11 @@ | |||
313 | 132 | } | 162 | } |
314 | 133 | _stdErr.device()->close(); | 163 | _stdErr.device()->close(); |
315 | 134 | 164 | ||
318 | 135 | _logStream << logMessage; | 165 | if (_isSystemBus) { |
319 | 136 | _logStream.flush(); | 166 | logSystemMessage(logMessage); |
320 | 167 | } else { | ||
321 | 168 | logSessionMessage(logMessage); | ||
322 | 169 | } | ||
323 | 137 | 170 | ||
324 | 138 | if (type == QtFatalMsg) | 171 | if (type == QtFatalMsg) |
325 | 139 | abort(); | 172 | abort(); |
326 | 140 | 173 | ||
327 | === modified file 'libubuntudownloadmanager/logger.h' | |||
328 | --- libubuntudownloadmanager/logger.h 2013-07-25 21:15:08 +0000 | |||
329 | +++ libubuntudownloadmanager/logger.h 2013-09-24 09:53:05 +0000 | |||
330 | @@ -45,6 +45,16 @@ | |||
331 | 45 | static QString getLogDir(); | 45 | static QString getLogDir(); |
332 | 46 | 46 | ||
333 | 47 | private: | 47 | private: |
334 | 48 | void openLogFile(const QString& filename); | ||
335 | 49 | |||
336 | 50 | void openSyslogConnection(); | ||
337 | 51 | |||
338 | 52 | void logSessionMessage(const QString &message); | ||
339 | 53 | |||
340 | 54 | void logSystemMessage(const QString &message); | ||
341 | 55 | |||
342 | 56 | private: | ||
343 | 57 | bool _isSystemBus = false; | ||
344 | 48 | bool _initialized = false; | 58 | bool _initialized = false; |
345 | 49 | QString _logFileName; | 59 | QString _logFileName; |
346 | 50 | QFile _logFile; | 60 | QFile _logFile; |
347 | 51 | 61 | ||
348 | === modified file 'ubuntu-download-manager-tests/irl_tests.py' | |||
349 | --- ubuntu-download-manager-tests/irl_tests.py 2013-09-17 09:37:52 +0000 | |||
350 | +++ ubuntu-download-manager-tests/irl_tests.py 2013-09-24 09:53:05 +0000 | |||
351 | @@ -58,7 +58,7 @@ | |||
352 | 58 | 58 | ||
353 | 59 | if __name__ == '__main__': | 59 | if __name__ == '__main__': |
354 | 60 | 60 | ||
356 | 61 | bus = dbus.SessionBus() | 61 | bus = dbus.SystemBus() |
357 | 62 | loop = gobject.MainLoop() | 62 | loop = gobject.MainLoop() |
358 | 63 | manager = bus.get_object('com.canonical.applications.Downloader', | 63 | manager = bus.get_object('com.canonical.applications.Downloader', |
359 | 64 | MANAGER_PATH) | 64 | MANAGER_PATH) |
360 | 65 | 65 | ||
361 | === added file 'ubuntu-download-manager/com.canonical.applications.Downloader.conf' | |||
362 | --- ubuntu-download-manager/com.canonical.applications.Downloader.conf 1970-01-01 00:00:00 +0000 | |||
363 | +++ ubuntu-download-manager/com.canonical.applications.Downloader.conf 2013-09-24 09:53:05 +0000 | |||
364 | @@ -0,0 +1,18 @@ | |||
365 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
366 | 2 | |||
367 | 3 | <!DOCTYPE busconfig PUBLIC | ||
368 | 4 | "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | ||
369 | 5 | "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
370 | 6 | <busconfig> | ||
371 | 7 | <policy user="root"> | ||
372 | 8 | <allow own="com.canonical.applications.Downloader"/> | ||
373 | 9 | <allow send_destination="com.canonical.applications.Downloader"/> | ||
374 | 10 | </policy> | ||
375 | 11 | |||
376 | 12 | <policy context="default"> | ||
377 | 13 | <allow send_destination="com.canonical.applications.Downloader"/> | ||
378 | 14 | <allow send_destination="com.canonical.applications.Downloader" | ||
379 | 15 | send_interface="org.freedesktop.DBus.Introspectable"/> | ||
380 | 16 | </policy> | ||
381 | 17 | |||
382 | 18 | </busconfig> | ||
383 | 0 | 19 | ||
384 | === added file 'ubuntu-download-manager/com.canonical.applications.Downloader.service' | |||
385 | --- ubuntu-download-manager/com.canonical.applications.Downloader.service 1970-01-01 00:00:00 +0000 | |||
386 | +++ ubuntu-download-manager/com.canonical.applications.Downloader.service 2013-09-24 09:53:05 +0000 | |||
387 | @@ -0,0 +1,4 @@ | |||
388 | 1 | [D-BUS Service] | ||
389 | 2 | Name=com.canonical.applications.Downloader | ||
390 | 3 | User=root | ||
391 | 4 | Exec=/usr/bin/ubuntu-download-manager | ||
392 | 0 | 5 | ||
393 | === modified file 'ubuntu-download-manager/ubuntu-download-manager.pro' | |||
394 | --- ubuntu-download-manager/ubuntu-download-manager.pro 2013-08-22 20:49:57 +0000 | |||
395 | +++ ubuntu-download-manager/ubuntu-download-manager.pro 2013-09-24 09:53:05 +0000 | |||
396 | @@ -18,9 +18,17 @@ | |||
397 | 18 | 18 | ||
398 | 19 | SOURCES += main.cpp | 19 | SOURCES += main.cpp |
399 | 20 | 20 | ||
403 | 21 | dbus_activation.path = /usr/share/dbus-1/services/ | 21 | dbus_session_activation.path = /usr/share/dbus-1/services/ |
404 | 22 | dbus_activation.files = ubuntu-download-manager.service | 22 | dbus_session_activation.files = ubuntu-download-manager.service |
405 | 23 | INSTALLS += dbus_activation | 23 | INSTALLS += dbus_session_activation |
406 | 24 | |||
407 | 25 | dbus_system_activation.path = /usr/share/dbus-1/system-services/ | ||
408 | 26 | dbus_system_activation.files = com.canonical.applications.Downloader.service | ||
409 | 27 | INSTALLS += dbus_system_activation | ||
410 | 28 | |||
411 | 29 | dbus_system_conf.path = /etc/dbus-1/system.d/ | ||
412 | 30 | dbus_system_conf.files = com.canonical.applications.Downloader.conf | ||
413 | 31 | INSTALLS += dbus_system_conf | ||
414 | 24 | 32 | ||
415 | 25 | target.path = /usr/bin/ | 33 | target.path = /usr/bin/ |
416 | 26 | INSTALLS += target | 34 | INSTALLS += target |
417 | @@ -31,4 +39,5 @@ | |||
418 | 31 | DEPENDPATH += $$PWD/../libubuntudownloadmanager | 39 | DEPENDPATH += $$PWD/../libubuntudownloadmanager |
419 | 32 | 40 | ||
420 | 33 | OTHER_FILES += \ | 41 | OTHER_FILES += \ |
422 | 34 | ubuntu-download-manager.service | 42 | ubuntu-download-manager.service \ |
423 | 43 | com.canonical.applications.Downloader.conf |
Please allow me to do the global approve, when this branch lands on trunk is very important due to deployment details.