Merge lp:~logan/ubuntu/quantal/cagibi/new-upstream into lp:ubuntu/quantal/cagibi

Proposed by Logan Rosen on 2012-06-21
Status: Merged
Merged at revision: 4
Proposed branch: lp:~logan/ubuntu/quantal/cagibi/new-upstream
Merge into: lp:ubuntu/quantal/cagibi
Diff against target: 2273 lines (+1123/-629)
51 files modified
CMakeLists.txt (+31/-3)
Changelog (+13/-0)
README (+38/-0)
TODO (+14/-0)
VERSION (+1/-1)
cagibi.lsm (+0/-19)
daemon/CMakeLists.txt (+21/-9)
daemon/cagibi.pc.cmake (+0/-7)
daemon/cagibid.conf.cmake (+12/-0)
daemon/control.cpp (+42/-0)
daemon/control.h (+51/-0)
daemon/controldbusadaptor.cpp (+39/-0)
daemon/controldbusadaptor.h (+55/-0)
daemon/daemon.cpp (+78/-0)
daemon/daemon.h (+43/-0)
daemon/dbuscodec.cpp (+68/-55)
daemon/dbuscodec.h (+1/-3)
daemon/device.cpp (+1/-1)
daemon/device.h (+1/-1)
daemon/device_p.cpp (+4/-4)
daemon/device_p.h (+1/-1)
daemon/devicedescriptionxmlhandler.cpp (+1/-2)
daemon/devicedescriptionxmlhandler.h (+1/-1)
daemon/devicelist.cpp (+223/-0)
daemon/devicelist.h (+84/-0)
daemon/devicelistdbusadaptor.cpp (+71/-0)
daemon/devicelistdbusadaptor.h (+65/-0)
daemon/icon.cpp (+1/-1)
daemon/icon.h (+1/-1)
daemon/icon_p.cpp (+1/-1)
daemon/icon_p.h (+1/-1)
daemon/main.cpp (+6/-18)
daemon/org.kde.Cagibi.Control.xml (+14/-0)
daemon/org.kde.Cagibi.DeviceList.xml (+96/-0)
daemon/org.kde.Cagibi.conf (+11/-0)
daemon/org.kde.Cagibi.service.cmake (+1/-0)
daemon/org.kde.Cagibi.xml (+0/-78)
daemon/rootdevice.cpp (+2/-2)
daemon/rootdevice.h (+1/-1)
daemon/service.cpp (+1/-1)
daemon/service.h (+1/-1)
daemon/service_p.cpp (+1/-1)
daemon/service_p.h (+1/-1)
daemon/ssdpwatcher.cpp (+12/-8)
daemon/ssdpwatcher.h (+5/-3)
daemon/upnpproxy.cpp (+0/-195)
daemon/upnpproxy.h (+0/-71)
daemon/upnpproxydbusadaptor.cpp (+0/-71)
daemon/upnpproxydbusadaptor.h (+0/-66)
debian/changelog (+7/-0)
debian/control (+1/-1)
To merge this branch: bzr merge lp:~logan/ubuntu/quantal/cagibi/new-upstream
Reviewer Review Type Date Requested Status
Daniel Holbach Approve on 2012-06-26
Ubuntu branches 2012-06-21 Pending
Review via email: mp+111411@code.launchpad.net
To post a comment you must log in.
Daniel Holbach (dholbach) wrote :

Thanks a lot!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2010-08-29 19:29:08 +0000
3+++ CMakeLists.txt 2012-06-21 14:28:20 +0000
4@@ -1,7 +1,9 @@
5 project( Cagibi )
6
7 cmake_minimum_required(VERSION 2.4.5 FATAL_ERROR)
8-
9+# CMP0005: keep escaping behaviour for definitions added via add_definitions()
10+cmake_policy(SET CMP0005 OLD)
11+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
12 set(CMAKE_MODULE_PATH "${Cagibi_SOURCE_DIR}/cmake/modules")
13
14 find_package( Qt4 REQUIRED COMPONENTS QtCore QtXml QtDBus QtNetwork )
15@@ -10,8 +12,34 @@
16 find_package(Automoc4 REQUIRED)
17
18 set(CAGIBI_VERSION_MAJOR "0")
19-set(CAGIBI_VERSION_MINOR "1")
20-set(CAGIBI_VERSION_PATCH "1")
21+set(CAGIBI_VERSION_MINOR "2")
22+set(CAGIBI_VERSION_PATCH "0")
23 set(CAGIBI_VERSION "${CAGIBI_VERSION_MAJOR}.${CAGIBI_VERSION_MINOR}.${CAGIBI_VERSION_PATCH}")
24
25+
26+if (NOT DEFINED SYSCONF_INSTALL_DIR)
27+ if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
28+ set(SYSCONF_INSTALL_DIR "/etc") # conform to LFSH
29+ else("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
30+ set(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
31+ endif("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
32+else (NOT DEFINED SYSCONF_INSTALL_DIR)
33+ set(SYSCONF_INSTALL_DIR "${SYSCONF_INSTALL_DIR}" CACHE STRING "The sysconfig install dir")
34+endif (NOT DEFINED SYSCONF_INSTALL_DIR)
35+
36+
37+if (NOT DEFINED CAGIBI_DAEMON_SHUTDOWN_SECS)
38+ set(CAGIBI_DAEMON_SHUTDOWN_SECS "0" CACHE STRING "Default time without services and activity to trigger shutdown (0 = no shutdown)")
39+endif()
40+
41+if (NOT DEFINED CAGIBI_DAEMON_SEARCH_TIMEOUT_SECS)
42+ set(CAGIBI_DAEMON_SEARCH_TIMEOUT_SECS "3" CACHE STRING "Default search timeout when querying for devices on a new network")
43+endif()
44+
45+add_definitions(
46+ -DCAGIBI_DAEMON_SHUTDOWN_SECS=${CAGIBI_DAEMON_SHUTDOWN_SECS}
47+ -DCAGIBI_DAEMON_SEARCH_TIMEOUT_SECS=${CAGIBI_DAEMON_SEARCH_TIMEOUT_SECS}
48+ -DSYSCONF_INSTALL_DIR=\\"${SYSCONF_INSTALL_DIR}\\"
49+)
50+
51 add_subdirectory( daemon )
52
53=== added file 'Changelog'
54--- Changelog 1970-01-01 00:00:00 +0000
55+++ Changelog 2012-06-21 14:28:20 +0000
56@@ -0,0 +1,13 @@
57+0.2.0
58+* split /org/kde/Cagibi object into DeviceList and Control objects
59+* option to set search timeout
60+* config file to adjust behaviour
61+* option to shutdown on no UPnP activity
62+* running on system D-Bus
63+* deviceDetails as lookuptable, D-Bus signature a{ss}
64+
65+0.1.1
66+* fixed: exec path in D-Bus service file missed subdir bin
67+
68+0.1.0
69+* initial release
70
71=== modified file 'README'
72--- README 2010-07-29 11:43:50 +0000
73+++ README 2012-06-21 14:28:20 +0000
74@@ -20,3 +20,41 @@
75
76
77 * http://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol
78+
79+
80+Building
81+--------
82+The buildsystem is based on cmake, please read the cmake documentation if you
83+are unfamiliar with it.
84+There are currently two parameters you can overwrite on configuring,
85+CAGIBI_DAEMON_SHUTDOWN_SECS and CAGIBI_DAEMON_SEARCH_TIMEOUT_SECS. Look into
86+CMakeLists.txt in the toplevel dir for more information about these.
87+
88+
89+Using
90+-----
91+The Cagibi daemon exposes two object in its D-Bus service org.kde.Cagibi:
92+* /org/kde/Cagibi/DeviceList, with interface org.kde.Cagibi.DeviceList
93+* /org/kde/Cagibi/Control, with interface org.kde.Cagibi.Control
94+
95+The first object does the actual caching of the UPnP device data. The second
96+object is used to control the general behaviour of the daemon.
97+
98+Clients will query the DeviceList for the device data and also listen to its
99+signals about new or disappeared devices. If the Cagibi daemon is shutdown, it
100+will simply signal the disappearing of all known UPnP devices, even if they will
101+stay for longer on the network.
102+On a (not to be expected, but better prepared) crash of the daemon with an
103+automatic restart by the init system (if integrated) or a manually done one it
104+is up to the clients how to deal with that, the Cagibi daemon will just start as
105+usual and search for UPnP devices starting of an empty list and emit
106+signals for any it finds, even if already reported before the crash. A client
107+would e.g. listen to the serviceOwnerChanged D-Bus signal and put all devices it
108+uses to an unknown state if the service disappears from the D-Bus, then on
109+reappearing of it compare all signaled-as-new devices to those with unknown
110+state and after some timeout simply treat those still unknown as disappeared.
111+In a more simple version the client would just treat all devices as disappeared
112+if the Cagibi service is lost, but this could result in quite some unneeded
113+activity even though the services (e.g. MediaServer) are still present and it's
114+just a small drop-out of the discovery proxy.
115+Having said that, so far Cagibi is not reported to crash at all :)
116\ No newline at end of file
117
118=== added file 'TODO'
119--- TODO 1970-01-01 00:00:00 +0000
120+++ TODO 2012-06-21 14:28:20 +0000
121@@ -0,0 +1,14 @@
122+For 0.2:
123+* shutdown really needed in D-Bus api? usecase (besides development)?
124+
125+For some future version:
126+* add log file
127+* react on available networks (e.g. proxy to NetworkManager)
128+ or should init/serviced do this? how to broadcast just on new network?
129+* proper behaviour on reconnection:
130+ (is there a way to discover the network is the same? even with same subnetwork adress could be a different one, so needs to query again, unless there is a proper way)
131+* browser tool which lists current cache
132+* restrict the networks listened on
133+* restrict the type of devices which is listened for (whitelist/blacklist)
134+* option to reparse config while running? triggered on D-Bus? on setting file(s) touched?
135+* add support for broadcasting, both dynamically as by installed files
136
137=== modified file 'VERSION'
138--- VERSION 2010-08-29 19:29:08 +0000
139+++ VERSION 2012-06-21 14:28:20 +0000
140@@ -1,1 +1,1 @@
141-0.1.1
142+0.2.0
143
144=== removed file 'cagibi.lsm'
145--- cagibi.lsm 2010-08-29 19:29:08 +0000
146+++ cagibi.lsm 1970-01-01 00:00:00 +0000
147@@ -1,19 +0,0 @@
148-Begin4
149-Title: Cagibi
150-Version: 0.1.1
151-Entered-date: 2010-08-08
152-Description: an experimental cache/proxy system for the SSDP (Simple Service Discovery Protocol) part of UPnP
153-Cagibi aims to be to SSDP what Avahi is to DNS-SD/Zeroconf:
154-a cache caching all service/device announcements on the network in a local process
155-as well as being a broker serving local announcements to the network.
156-Both should be done by a single daemon process, accessable via D-Bus on the system bus.
157-The cache should offer active queries, so another process is only informed about changes
158-about UPnP devices it is interested in.
159-This is a prototype, active reimplementation (e.g. integration in Avahi) welcome :)
160-Keywords: upnp ssdp proxy cache daemon
161-Author: kossebau@kde.org (Friedrich W. H. Kossebau)
162-Maintained-by: kossebau@kde.org (Friedrich W. H. Kossebau)
163-Primary-site: ftp://ftp.kde.org/pub/kde/stable/cagibi
164-Platforms:
165-Copying-policy: GPL
166-End
167
168=== modified file 'daemon/CMakeLists.txt'
169--- daemon/CMakeLists.txt 2010-08-29 19:29:08 +0000
170+++ daemon/CMakeLists.txt 2012-06-21 14:28:20 +0000
171@@ -11,9 +11,15 @@
172 device.cpp
173 rootdevice.cpp
174 ssdpwatcher.cpp
175- upnpproxy.cpp
176- upnpproxydbusadaptor.cpp
177+
178+ devicelist.cpp
179+ devicelistdbusadaptor.cpp
180 dbuscodec.cpp
181+
182+ control.cpp
183+ controldbusadaptor.cpp
184+
185+ daemon.cpp
186 main.cpp
187 )
188
189@@ -29,10 +35,16 @@
190 install( TARGETS cagibid RUNTIME DESTINATION bin )
191
192 configure_file( org.kde.Cagibi.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Cagibi.service )
193-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Cagibi.service DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dbus-1/services )
194-
195-if (NOT WIN32)
196- configure_file( cagibi.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cagibi.pc )
197- install( FILES ${CMAKE_CURRENT_BINARY_DIR}/cagibi.pc
198- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig )
199-endif (NOT WIN32)
200+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Cagibi.service DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dbus-1/system-services )
201+install( FILES org.kde.Cagibi.conf DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/ )
202+
203+set( cagibid_CONF_NAME cagibid.conf )
204+set( cagibid_CONF ${CMAKE_CURRENT_BINARY_DIR}/${cagibid_CONF_NAME} )
205+configure_file( ${cagibid_CONF_NAME}.cmake ${cagibid_CONF} )
206+install( FILES ${cagibid_CONF} DESTINATION ${SYSCONF_INSTALL_DIR} )
207+
208+set( cagibid_DBUS_API
209+ org.kde.Cagibi.Control.xml
210+ org.kde.Cagibi.DeviceList.xml
211+)
212+install( FILES ${cagibid_DBUS_API} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dbus-1/interfaces )
213
214=== removed file 'daemon/cagibi.pc.cmake'
215--- daemon/cagibi.pc.cmake 2010-08-29 19:29:08 +0000
216+++ daemon/cagibi.pc.cmake 1970-01-01 00:00:00 +0000
217@@ -1,7 +0,0 @@
218-prefix=${CMAKE_INSTALL_PREFIX}
219-exec_prefix=${CMAKE_INSTALL_PREFIX}/bin
220-
221-Name: Cagibi daemon
222-Description: experimental cache/proxy system for the SSDP (Simple Service Discovery Protocol) part of UPnP.
223-Version: ${CAGIBI_VERSION}
224-Requires: QtCore QtXml QtNetwork QtDBus
225
226=== added file 'daemon/cagibid.conf.cmake'
227--- daemon/cagibid.conf.cmake 1970-01-01 00:00:00 +0000
228+++ daemon/cagibid.conf.cmake 2012-06-21 14:28:20 +0000
229@@ -0,0 +1,12 @@
230+[General]
231+# Time (in sec) waited after querying for devices on a new network connection,
232+# before the query is considered done.
233+# Default time is @CAGIBI_DAEMON_SEARCH_TIMEOUT_SECS@.
234+# Uncomment the following line to change this time, in the example to 5 secs:
235+# SearchTimeout = 5
236+
237+# Time (in sec) without any discovered services and any client query
238+# activity after which a shutdown of the daemon is triggered (0 = no shutdown).
239+# Default time is @CAGIBI_DAEMON_SHUTDOWN_SECS@.
240+# Uncomment the following line to change this time, in the example to 23 secs:
241+# ShutDownTimeout = 23
242
243=== added file 'daemon/control.cpp'
244--- daemon/control.cpp 1970-01-01 00:00:00 +0000
245+++ daemon/control.cpp 2012-06-21 14:28:20 +0000
246@@ -0,0 +1,42 @@
247+/*
248+ This file is part of the Cagibi daemon.
249+
250+ Copyright 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
251+
252+ This program is free software; you can redistribute it and/or
253+ modify it under the terms of the GNU General Public License as
254+ published by the Free Software Foundation; either version 2 of
255+ the License or (at your option) version 3 or any later version
256+ accepted by the membership of KDE e.V. (or its successor approved
257+ by the membership of KDE e.V.), which shall act as a proxy
258+ defined in Section 14 of version 3 of the license.
259+
260+ This program is distributed in the hope that it will be useful,
261+ but WITHOUT ANY WARRANTY; without even the implied warranty of
262+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263+ GNU General Public License for more details.
264+
265+ You should have received a copy of the GNU General Public License
266+ along with this program. If not, see <http://www.gnu.org/licenses/>.
267+*/
268+
269+#include "control.h"
270+
271+// program
272+#include "daemon.h"
273+
274+namespace Cagibi
275+{
276+
277+Control::Control( Daemon* daemon )
278+ : QObject(),
279+ mDaemon( daemon )
280+{
281+}
282+
283+void Control::shutDown()
284+{
285+ mDaemon->quit();
286+}
287+
288+}
289
290=== added file 'daemon/control.h'
291--- daemon/control.h 1970-01-01 00:00:00 +0000
292+++ daemon/control.h 2012-06-21 14:28:20 +0000
293@@ -0,0 +1,51 @@
294+/*
295+ This file is part of the Cagibi daemon.
296+
297+ Copyright 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
298+
299+ This program is free software; you can redistribute it and/or
300+ modify it under the terms of the GNU General Public License as
301+ published by the Free Software Foundation; either version 2 of
302+ the License or (at your option) version 3 or any later version
303+ accepted by the membership of KDE e.V. (or its successor approved
304+ by the membership of KDE e.V.), which shall act as a proxy
305+ defined in Section 14 of version 3 of the license.
306+
307+ This program is distributed in the hope that it will be useful,
308+ but WITHOUT ANY WARRANTY; without even the implied warranty of
309+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
310+ GNU General Public License for more details.
311+
312+ You should have received a copy of the GNU General Public License
313+ along with this program. If not, see <http://www.gnu.org/licenses/>.
314+*/
315+
316+#ifndef CONTROL_H
317+#define CONTROL_H
318+
319+// Qt
320+#include <QtCore/QObject>
321+
322+namespace Cagibi
323+{
324+class Daemon;
325+
326+
327+class Control : public QObject
328+{
329+ Q_OBJECT
330+
331+ public:
332+ explicit Control( Daemon* daemon );
333+
334+ public Q_SLOTS:
335+ // shut the proxy server down
336+ void shutDown();
337+
338+ private:
339+ Daemon* mDaemon;
340+};
341+
342+}
343+
344+#endif
345
346=== added file 'daemon/controldbusadaptor.cpp'
347--- daemon/controldbusadaptor.cpp 1970-01-01 00:00:00 +0000
348+++ daemon/controldbusadaptor.cpp 2012-06-21 14:28:20 +0000
349@@ -0,0 +1,39 @@
350+/*
351+ This file is part of the Cagibi daemon.
352+
353+ Copyright 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
354+
355+ This program is free software; you can redistribute it and/or
356+ modify it under the terms of the GNU General Public License as
357+ published by the Free Software Foundation; either version 2 of
358+ the License or (at your option) version 3 or any later version
359+ accepted by the membership of KDE e.V. (or its successor approved
360+ by the membership of KDE e.V.), which shall act as a proxy
361+ defined in Section 14 of version 3 of the license.
362+
363+ This program is distributed in the hope that it will be useful,
364+ but WITHOUT ANY WARRANTY; without even the implied warranty of
365+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
366+ GNU General Public License for more details.
367+
368+ You should have received a copy of the GNU General Public License
369+ along with this program. If not, see <http://www.gnu.org/licenses/>.
370+*/
371+
372+#include "controldbusadaptor.h"
373+
374+namespace Cagibi
375+{
376+
377+ControlDBusAdaptor::ControlDBusAdaptor( Control* parent )
378+ : QDBusAbstractAdaptor( parent )
379+{
380+}
381+
382+void ControlDBusAdaptor::shutDown()
383+{
384+ parent()->shutDown();
385+}
386+
387+
388+}
389
390=== added file 'daemon/controldbusadaptor.h'
391--- daemon/controldbusadaptor.h 1970-01-01 00:00:00 +0000
392+++ daemon/controldbusadaptor.h 2012-06-21 14:28:20 +0000
393@@ -0,0 +1,55 @@
394+/*
395+ This file is part of the Cagibi daemon.
396+
397+ Copyright 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
398+
399+ This program is free software; you can redistribute it and/or
400+ modify it under the terms of the GNU General Public License as
401+ published by the Free Software Foundation; either version 2 of
402+ the License or (at your option) version 3 or any later version
403+ accepted by the membership of KDE e.V. (or its successor approved
404+ by the membership of KDE e.V.), which shall act as a proxy
405+ defined in Section 14 of version 3 of the license.
406+
407+ This program is distributed in the hope that it will be useful,
408+ but WITHOUT ANY WARRANTY; without even the implied warranty of
409+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
410+ GNU General Public License for more details.
411+
412+ You should have received a copy of the GNU General Public License
413+ along with this program. If not, see <http://www.gnu.org/licenses/>.
414+*/
415+
416+#ifndef CONTROLDBUSADAPTOR_H
417+#define CONTROLDBUSADAPTOR_H
418+
419+// program
420+#include "control.h"
421+// Qt
422+#include <QtDBus/QtDBus>
423+
424+
425+namespace Cagibi
426+{
427+
428+class ControlDBusAdaptor: public QDBusAbstractAdaptor
429+{
430+ Q_OBJECT
431+ Q_CLASSINFO("D-Bus Interface", "org.kde.Cagibi.Control")
432+
433+ public:
434+ explicit ControlDBusAdaptor( Control* parent );
435+
436+ public:
437+ Control* parent() const;
438+
439+ public Q_SLOTS:
440+ Q_NOREPLY void shutDown();
441+};
442+
443+
444+inline Control* ControlDBusAdaptor::parent() const { return static_cast<Control*>( QObject::parent() ); }
445+
446+}
447+
448+#endif
449
450=== added file 'daemon/daemon.cpp'
451--- daemon/daemon.cpp 1970-01-01 00:00:00 +0000
452+++ daemon/daemon.cpp 2012-06-21 14:28:20 +0000
453@@ -0,0 +1,78 @@
454+/*
455+ This file is part of the Cagibi daemon.
456+
457+ Copyright 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
458+
459+ This program is free software; you can redistribute it and/or
460+ modify it under the terms of the GNU General Public License as
461+ published by the Free Software Foundation; either version 2 of
462+ the License or (at your option) version 3 or any later version
463+ accepted by the membership of KDE e.V. (or its successor approved
464+ by the membership of KDE e.V.), which shall act as a proxy
465+ defined in Section 14 of version 3 of the license.
466+
467+ This program is distributed in the hope that it will be useful,
468+ but WITHOUT ANY WARRANTY; without even the implied warranty of
469+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
470+ GNU General Public License for more details.
471+
472+ You should have received a copy of the GNU General Public License
473+ along with this program. If not, see <http://www.gnu.org/licenses/>.
474+*/
475+
476+// program
477+#include "devicelistdbusadaptor.h"
478+#include "devicelist.h"
479+#include "controldbusadaptor.h"
480+#include "control.h"
481+#include "daemon.h"
482+// Qt
483+#include <QtCore/QSettings>
484+#include <QtCore/QCoreApplication>
485+
486+
487+namespace Cagibi
488+{
489+
490+static const int defaultShutDownTimeout = CAGIBI_DAEMON_SHUTDOWN_SECS;
491+static const int defaultSearchTimeout = CAGIBI_DAEMON_SEARCH_TIMEOUT_SECS;
492+
493+Daemon::Daemon( int argc, char* argv[] )
494+ : QCoreApplication( argc, argv )
495+{
496+}
497+
498+
499+int Daemon::exec()
500+{
501+ // read settings
502+ QSettings::setPath( QSettings::NativeFormat, QSettings::SystemScope,
503+ QLatin1String(SYSCONF_INSTALL_DIR) );
504+ QSettings settings( QSettings::SystemScope, QLatin1String("cagibid") );
505+ int shutDownTimeout =
506+ settings.value( QLatin1String("ShutDownTimeout"),
507+ defaultShutDownTimeout ).toInt();
508+ const int searchTimeout =
509+ settings.value( QLatin1String("SearchTimeout"),
510+ defaultSearchTimeout ).toInt();
511+
512+ // publish service on D-Bus
513+ QDBusConnection dBusConnection = QDBusConnection::systemBus();
514+ dBusConnection.registerService( QLatin1String("org.kde.Cagibi") );
515+
516+ DeviceList deviceList( searchTimeout, shutDownTimeout );
517+ connect( &deviceList, SIGNAL(gotInactiv()), SLOT(quit()) );
518+ new DeviceListDBusAdaptor( &deviceList );
519+ dBusConnection.registerObject( QLatin1String("/org/kde/Cagibi/DeviceList"), &deviceList );
520+
521+ Control control( this );
522+ new ControlDBusAdaptor( &control );
523+ dBusConnection.registerObject( QLatin1String("/org/kde/Cagibi/Control"), &control );
524+
525+ // do the mainloop
526+ const int result = QCoreApplication::exec();
527+
528+ return result;
529+}
530+
531+}
532
533=== added file 'daemon/daemon.h'
534--- daemon/daemon.h 1970-01-01 00:00:00 +0000
535+++ daemon/daemon.h 2012-06-21 14:28:20 +0000
536@@ -0,0 +1,43 @@
537+/*
538+ This file is part of the Cagibi daemon.
539+
540+ Copyright 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
541+
542+ This program is free software; you can redistribute it and/or
543+ modify it under the terms of the GNU General Public License as
544+ published by the Free Software Foundation; either version 2 of
545+ the License or (at your option) version 3 or any later version
546+ accepted by the membership of KDE e.V. (or its successor approved
547+ by the membership of KDE e.V.), which shall act as a proxy
548+ defined in Section 14 of version 3 of the license.
549+
550+ This program is distributed in the hope that it will be useful,
551+ but WITHOUT ANY WARRANTY; without even the implied warranty of
552+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
553+ GNU General Public License for more details.
554+
555+ You should have received a copy of the GNU General Public License
556+ along with this program. If not, see <http://www.gnu.org/licenses/>.
557+*/
558+
559+#ifndef DAEMON_H
560+#define DAEMON_H
561+
562+// Qt
563+#include <QtCore/QCoreApplication>
564+
565+namespace Cagibi
566+{
567+
568+class Daemon : public QCoreApplication
569+{
570+ public:
571+ Daemon( int argc, char* argv[] );
572+
573+ public:
574+ int exec();
575+};
576+
577+}
578+
579+#endif
580
581=== modified file 'daemon/dbuscodec.cpp'
582--- daemon/dbuscodec.cpp 2010-07-29 11:43:50 +0000
583+++ daemon/dbuscodec.cpp 2012-06-21 14:28:20 +0000
584@@ -1,7 +1,7 @@
585 /*
586- This file is part of the Cagibi library, part of the KDE project.
587+ This file is part of the Cagibi daemon.
588
589- Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
590+ Copyright 2010-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
591
592 This library is free software; you can redistribute it and/or
593 modify it under the terms of the GNU Lesser General Public
594@@ -29,74 +29,87 @@
595 #include <QtDBus/QDBusArgument>
596 #include <QtCore/QUrl>
597
598+static const QString type = QLatin1String( "deviceType" );
599+static const QString friendlyName = QLatin1String( "friendlyName" );
600+static const QString manufacturerName = QLatin1String( "manufacturer" );
601+static const QString modelDescription = QLatin1String( "modelDescription" );
602+static const QString modelName = QLatin1String( "modelName" );
603+static const QString modelNumber = QLatin1String( "modelNumber" );
604+static const QString serialNumber = QLatin1String( "serialNumber" );
605+static const QString udn = QLatin1String( "UDN" );
606+static const QString presentationUrl = QLatin1String( "presentationURL" );
607+static const QString ipAddress = QLatin1String( "ipAddress" );
608+static const QString portNumber = QLatin1String( "ipPortNumber" );
609+static const QString parentDeviceUdn = QLatin1String( "parentDeviceUDN" );
610+
611
612 QDBusArgument& operator<<( QDBusArgument& argument, const Cagibi::Device& device )
613 {
614- const Cagibi::DevicePrivate* devicePrivate = device.d.constData();
615-
616- argument.beginStructure();
617-
618- argument << devicePrivate->type()
619- << devicePrivate->friendlyName()
620- << devicePrivate->manufacturerName()
621+ const Cagibi::DevicePrivate* const devicePrivate = device.d.constData();
622+ const Cagibi::RootDevice* const rootDevice = devicePrivate->rootDevice();
623+ const bool isValid = ( rootDevice != 0 );
624+
625+ argument.beginMap( QVariant::String, QVariant::String );
626+ if( isValid ) // is not valid e.g. if tested for signature
627+ {
628+ argument.beginMapEntry();
629+ argument << type << devicePrivate->type();
630+ argument.endMapEntry();
631+ argument.beginMapEntry();
632+ argument << friendlyName << devicePrivate->friendlyName();
633+ argument.endMapEntry();
634+ argument.beginMapEntry();
635+ argument << manufacturerName << devicePrivate->manufacturerName();
636+ argument.endMapEntry();
637 // const QString& manufacturerUrl() const;
638- << devicePrivate->modelDescription()
639- << devicePrivate->modelName()
640- << devicePrivate->modelNumber()
641- << devicePrivate->serialNumber()
642- << devicePrivate->udn()
643+ argument.beginMapEntry();
644+ argument << modelDescription << devicePrivate->modelDescription();
645+ argument.endMapEntry();
646+ argument.beginMapEntry();
647+ argument << modelName << devicePrivate->modelName();
648+ argument.endMapEntry();
649+ argument.beginMapEntry();
650+ argument << modelNumber << devicePrivate->modelNumber();
651+ argument.endMapEntry();
652+ argument.beginMapEntry();
653+ argument << serialNumber << devicePrivate->serialNumber();
654+ argument.endMapEntry();
655+ argument.beginMapEntry();
656+ argument << udn << devicePrivate->udn();
657+ argument.endMapEntry();
658 // const QString upc() const;
659- << devicePrivate->presentationUrl();
660-
661- Cagibi::RootDevice* rootDevice = devicePrivate->rootDevice();
662- QUrl location = rootDevice ? rootDevice->location() : QUrl();
663- argument << location.host()
664- << location.port();
665-
666- argument << ( devicePrivate->hasParentDevice() ?
667- devicePrivate->parentDevice().udn() :
668- QString() );
669-
670+ argument.beginMapEntry();
671+ argument << presentationUrl << devicePrivate->presentationUrl();
672+ argument.endMapEntry();
673+
674+ const QUrl& location = rootDevice->location();
675+ argument.beginMapEntry();
676+ argument << ipAddress << location.host();
677+ argument.endMapEntry();
678+ argument.beginMapEntry();
679+ argument << portNumber << QString::number(location.port());
680+ argument.endMapEntry();
681+
682+ if( devicePrivate->hasParentDevice() )
683+ {
684+ argument.beginMapEntry();
685+ argument << parentDeviceUdn << devicePrivate->parentDevice().udn();
686+ argument.endMapEntry();
687+ }
688 // const QList<Icon>& icons() const;
689 // const QList<Service>& services() const;
690 // const QList<Device>& devices() const;
691-
692- argument.endStructure();
693+ }
694+ argument.endMap();
695
696 return argument;
697 }
698
699+// not used currently, so noop, but symbol needed for QtDBus integration
700 const QDBusArgument& operator>>( const QDBusArgument& argument,
701 Cagibi::Device& device )
702 {
703- Cagibi::DevicePrivate* devicePrivate = device.d.data();
704-
705- argument.beginStructure();
706-
707- argument >> devicePrivate->mType
708- >> devicePrivate->mFriendlyName
709- >> devicePrivate->mManufacturerName
710-// const QString& manufacturerUrl() const;
711- >> devicePrivate->mModelDescription
712- >> devicePrivate->mModelName
713- >> devicePrivate->mModelNumber
714- >> devicePrivate->mSerialNumber
715- >> devicePrivate->mUdn
716-// const QString upc() const;
717- >> devicePrivate->mPresentationUrl;
718-
719-
720- QString parentDeviceUdn;
721- argument >> parentDeviceUdn;
722-// << ( devicePrivate->hasParentDevice() ?
723-// devicePrivate->parentDevice().udn() :
724-// QString() );
725-
726-// const QList<Icon>& icons() const;
727-// const QList<Service>& services() const;
728-// const QList<Device>& devices() const;
729-
730- argument.endStructure();
731+ Q_UNUSED( device )
732
733 return argument;
734 }
735
736=== modified file 'daemon/dbuscodec.h'
737--- daemon/dbuscodec.h 2010-07-29 11:43:50 +0000
738+++ daemon/dbuscodec.h 2012-06-21 14:28:20 +0000
739@@ -1,5 +1,5 @@
740 /*
741- This file is part of the Cagibi library, part of the KDE project.
742+ This file is part of the Cagibi daemon.
743
744 Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
745
746@@ -27,7 +27,6 @@
747 #include "device.h"
748 // Qt
749 #include <QtCore/QMetaType>
750-// #include <QtCore/QVector>
751
752 class QDBusArgument;
753 QDBusArgument& operator<<( QDBusArgument& argument,
754@@ -36,6 +35,5 @@
755 Cagibi::Device& device );
756
757 Q_DECLARE_METATYPE( Cagibi::Device )
758-// Q_DECLARE_METATYPE( QVector<Cagibi::Device> )
759
760 #endif
761
762=== modified file 'daemon/device.cpp'
763--- daemon/device.cpp 2010-07-29 11:43:50 +0000
764+++ daemon/device.cpp 2012-06-21 14:28:20 +0000
765@@ -1,5 +1,5 @@
766 /*
767- This file is part of the Cagibi library, part of the KDE project.
768+ This file is part of the Cagibi daemon.
769
770 Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
771
772
773=== modified file 'daemon/device.h'
774--- daemon/device.h 2010-07-29 11:43:50 +0000
775+++ daemon/device.h 2012-06-21 14:28:20 +0000
776@@ -1,5 +1,5 @@
777 /*
778- This file is part of the Cagibi library, part of the KDE project.
779+ This file is part of the Cagibi daemon.
780
781 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
782
783
784=== modified file 'daemon/device_p.cpp'
785--- daemon/device_p.cpp 2010-07-29 11:43:50 +0000
786+++ daemon/device_p.cpp 2012-06-21 14:28:20 +0000
787@@ -1,5 +1,5 @@
788 /*
789- This file is part of the Cagibi library, part of the KDE project.
790+ This file is part of the Cagibi daemon.
791
792 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
793
794@@ -45,7 +45,7 @@
795
796 void DevicePrivate::addIcon( const Icon& icon )
797 {
798-qDebug()<<icon.url()<<icon.width()<<"x"<<icon.height();
799+// qDebug()<<icon.url()<<icon.width()<<"x"<<icon.height();
800 mIcons.append( icon );
801 }
802
803@@ -54,7 +54,7 @@
804 const QString& type = service.type();
805 const QString actionId = QString::fromLatin1( "GetStatusInfo" );
806 const QString& url = service.controlUrl();
807-qDebug()<<type<<url;
808+// qDebug()<<type<<url;
809 // TODO
810 #if 0
811 mSoapAgent->sendCommand( type, actionId, url, QVariant::fromValue<Service>(service) );
812@@ -66,7 +66,7 @@
813
814 void DevicePrivate::addDevice( const Device& device )
815 {
816-qDebug()<<device.friendlyName();
817+// qDebug()<<device.friendlyName();
818 device.d.data()->setParentDevicePrivate( this );
819 mDevices.append( device );
820 }
821
822=== modified file 'daemon/device_p.h'
823--- daemon/device_p.h 2010-07-29 11:43:50 +0000
824+++ daemon/device_p.h 2012-06-21 14:28:20 +0000
825@@ -1,5 +1,5 @@
826 /*
827- This file is part of the Cagibi library, part of the KDE project.
828+ This file is part of the Cagibi daemon.
829
830 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
831
832
833=== modified file 'daemon/devicedescriptionxmlhandler.cpp'
834--- daemon/devicedescriptionxmlhandler.cpp 2010-07-29 11:43:50 +0000
835+++ daemon/devicedescriptionxmlhandler.cpp 2012-06-21 14:28:20 +0000
836@@ -1,5 +1,5 @@
837 /*
838- This file is part of the Cagibi library, part of the KDE project.
839+ This file is part of the Cagibi daemon.
840
841 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
842
843@@ -167,7 +167,6 @@
844 mCurrentDevice.setRootDevice( mRootDevice );
845 if( mStatusStack.top() == RootElement )
846 {
847-qDebug()<<mCurrentDevice.friendlyName();
848 mRootDevice->setDevice( mCurrentDevice );
849 }
850 else
851
852=== modified file 'daemon/devicedescriptionxmlhandler.h'
853--- daemon/devicedescriptionxmlhandler.h 2010-07-29 11:43:50 +0000
854+++ daemon/devicedescriptionxmlhandler.h 2012-06-21 14:28:20 +0000
855@@ -1,5 +1,5 @@
856 /*
857- This file is part of the Cagibi library, part of the KDE project.
858+ This file is part of the Cagibi daemon.
859
860 Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
861
862
863=== added file 'daemon/devicelist.cpp'
864--- daemon/devicelist.cpp 1970-01-01 00:00:00 +0000
865+++ daemon/devicelist.cpp 2012-06-21 14:28:20 +0000
866@@ -0,0 +1,223 @@
867+/*
868+ This file is part of the Cagibi daemon.
869+
870+ Copyright 2010-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
871+
872+ This program is free software; you can redistribute it and/or
873+ modify it under the terms of the GNU General Public License as
874+ published by the Free Software Foundation; either version 2 of
875+ the License or (at your option) version 3 or any later version
876+ accepted by the membership of KDE e.V. (or its successor approved
877+ by the membership of KDE e.V.), which shall act as a proxy
878+ defined in Section 14 of version 3 of the license.
879+
880+ This program is distributed in the hope that it will be useful,
881+ but WITHOUT ANY WARRANTY; without even the implied warranty of
882+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
883+ GNU General Public License for more details.
884+
885+ You should have received a copy of the GNU General Public License
886+ along with this program. If not, see <http://www.gnu.org/licenses/>.
887+*/
888+
889+#include "devicelist.h"
890+
891+// program
892+#include "ssdpwatcher.h"
893+#include "rootdevice.h"
894+#include "device.h"
895+// Qt
896+#include <QtCore/QTimer>
897+
898+
899+namespace Cagibi
900+{
901+
902+static void fillMap( DeviceTypeMap& map, const Device& device )
903+{
904+ map.insert( device.udn(), device.type() );
905+ foreach( const Cagibi::Device& subDevice, device.devices() )
906+ fillMap( map, subDevice );
907+}
908+
909+static void fillMapByType( DeviceTypeMap& map, const Device& device,
910+ const QString& type )
911+{
912+ const QString deviceType = device.type();
913+
914+ if( deviceType == type )
915+ map.insert( device.udn(), deviceType );
916+
917+ foreach( const Cagibi::Device& subDevice, device.devices() )
918+ fillMapByType( map, subDevice, type );
919+}
920+
921+static const Device* find( const Device& device, const QString& udn )
922+{
923+ const Device* result = 0;
924+
925+ if( device.udn() == udn )
926+ result = &device;
927+ else
928+ {
929+ foreach( const Cagibi::Device& subDevice, device.devices() )
930+ {
931+ result = find( subDevice, udn );
932+ if( result )
933+ break;
934+ }
935+ }
936+
937+ return result;
938+}
939+
940+
941+DeviceList::DeviceList( int searchTimeout, int inactivityTimeout )
942+ : QObject(),
943+ mSsdpWatcher( new SSDPWatcher(this) ),
944+ mShutDownTimeout( inactivityTimeout )
945+{
946+ // setup timer to shutdown on no UPnP activity
947+ mShutDownTimer = new QTimer( this );
948+ mShutDownTimer->setInterval( mShutDownTimeout * 1000 ); // in msec
949+ mShutDownTimer->setSingleShot( true );
950+ connect( mShutDownTimer, SIGNAL(timeout()),
951+ this, SIGNAL(gotInactiv()) );
952+
953+ // install listener to UPnP changes
954+ connect( mSsdpWatcher, SIGNAL(deviceDiscovered( Cagibi::RootDevice* )),
955+ SLOT(onDeviceDiscovered( Cagibi::RootDevice* )) );
956+ connect( mSsdpWatcher, SIGNAL(deviceRemoved( Cagibi::RootDevice* )),
957+ SLOT(onDeviceRemoved( Cagibi::RootDevice* )) );
958+ connect( mSsdpWatcher, SIGNAL(initialSearchCompleted()),
959+ SLOT(onInitialSearchCompleted()) );
960+
961+ mSsdpWatcher->startDiscover( searchTimeout );
962+}
963+
964+DeviceTypeMap DeviceList::allDevices() const
965+{
966+ DeviceTypeMap result;
967+
968+ const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
969+
970+ foreach( RootDevice* rootDevice, rootDevices )
971+ {
972+ const Device device = rootDevice->device();
973+ fillMap( result, device );
974+ }
975+
976+ // being used, so reset the shutdown timer if active
977+ if( mShutDownTimer->isActive() )
978+ mShutDownTimer->start();
979+
980+ return result;
981+}
982+
983+DeviceTypeMap DeviceList::devicesByParent( const QString& udn ) const
984+{
985+ DeviceTypeMap result;
986+
987+ const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
988+
989+ foreach( RootDevice* rootDevice, rootDevices )
990+ {
991+ const Device device = rootDevice->device();
992+
993+ if( udn.isEmpty() )
994+ result.insert( device.udn(), device.type() );
995+ else
996+ {
997+ const Device* match = find( device, udn );
998+ if( match )
999+ {
1000+ foreach( const Cagibi::Device& subDevice, device.devices() )
1001+ result.insert( subDevice.udn(), subDevice.type() );
1002+ break;
1003+ }
1004+ }
1005+ }
1006+
1007+ // being used, so reset the shutdown timer if active
1008+ if( mShutDownTimer->isActive() )
1009+ mShutDownTimer->start();
1010+
1011+ return result;
1012+}
1013+
1014+DeviceTypeMap DeviceList::devicesByType( const QString& type ) const
1015+{
1016+ DeviceTypeMap result;
1017+
1018+ const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1019+
1020+ foreach( RootDevice* rootDevice, rootDevices )
1021+ {
1022+ const Device device = rootDevice->device();
1023+ fillMapByType( result, device, type );
1024+ }
1025+
1026+ return result;
1027+}
1028+
1029+Device DeviceList::deviceDetails( const QString& udn ) const
1030+{
1031+ Device result;
1032+
1033+ const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1034+
1035+ foreach( RootDevice* rootDevice, rootDevices )
1036+ {
1037+ const Device device = rootDevice->device();
1038+
1039+ const Device* match = find( device, udn );
1040+ if( match )
1041+ {
1042+ result = *match;
1043+ break;
1044+ }
1045+ }
1046+
1047+ return result;
1048+}
1049+
1050+void DeviceList::onInitialSearchCompleted()
1051+{
1052+ if( shutsDownOnNoActivity() && mSsdpWatcher->devicesCount() == 0 )
1053+ mShutDownTimer->start();
1054+}
1055+
1056+void DeviceList::onDeviceDiscovered( RootDevice* rootDevice )
1057+{
1058+ DeviceTypeMap devices;
1059+
1060+ const Device device = rootDevice->device();
1061+ fillMap( devices, device );
1062+
1063+ mShutDownTimer->stop();
1064+
1065+ emit devicesAdded( devices );
1066+}
1067+
1068+void DeviceList::onDeviceRemoved( RootDevice* rootDevice )
1069+{
1070+ DeviceTypeMap devices;
1071+
1072+ const Device device = rootDevice->device();
1073+ fillMap( devices, device );
1074+
1075+ if( shutsDownOnNoActivity() && mSsdpWatcher->devicesCount() == 0 )
1076+ mShutDownTimer->start();
1077+
1078+ emit devicesRemoved( devices );
1079+}
1080+
1081+DeviceList::~DeviceList()
1082+{
1083+ // simulate that all devices are removed
1084+ const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1085+ foreach( RootDevice* rootDevice, rootDevices )
1086+ onDeviceRemoved( rootDevice );
1087+}
1088+
1089+}
1090
1091=== added file 'daemon/devicelist.h'
1092--- daemon/devicelist.h 1970-01-01 00:00:00 +0000
1093+++ daemon/devicelist.h 2012-06-21 14:28:20 +0000
1094@@ -0,0 +1,84 @@
1095+/*
1096+ This file is part of the Cagibi daemon.
1097+
1098+ Copyright 2010-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
1099+
1100+ This program is free software; you can redistribute it and/or
1101+ modify it under the terms of the GNU General Public License as
1102+ published by the Free Software Foundation; either version 2 of
1103+ the License or (at your option) version 3 or any later version
1104+ accepted by the membership of KDE e.V. (or its successor approved
1105+ by the membership of KDE e.V.), which shall act as a proxy
1106+ defined in Section 14 of version 3 of the license.
1107+
1108+ This program is distributed in the hope that it will be useful,
1109+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1110+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111+ GNU General Public License for more details.
1112+
1113+ You should have received a copy of the GNU General Public License
1114+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1115+*/
1116+
1117+#ifndef DEVICELIST_H
1118+#define DEVICELIST_H
1119+
1120+// Qt
1121+#include <QtCore/QObject>
1122+#include <QtCore/QHash>
1123+#include <QtCore/QString>
1124+#include <QtCore/QMetaType>
1125+
1126+class QTimer;
1127+
1128+typedef QHash<QString,QString> DeviceTypeMap;
1129+Q_DECLARE_METATYPE( DeviceTypeMap )
1130+
1131+
1132+namespace Cagibi
1133+{
1134+class SSDPWatcher;
1135+class RootDevice;
1136+class Device;
1137+
1138+
1139+class DeviceList : public QObject
1140+{
1141+ Q_OBJECT
1142+
1143+ public:
1144+ explicit DeviceList( int searchTimeout, int inactivityTimeout );
1145+ virtual ~DeviceList();
1146+
1147+ public:
1148+ DeviceTypeMap allDevices() const;
1149+ DeviceTypeMap devicesByParent( const QString& udn ) const;
1150+ DeviceTypeMap devicesByType( const QString& type ) const;
1151+ Device deviceDetails( const QString& udn ) const;
1152+
1153+ Q_SIGNALS:
1154+ void devicesAdded( const DeviceTypeMap& devices );
1155+ void devicesRemoved( const DeviceTypeMap& devices );
1156+
1157+ void gotInactiv();
1158+
1159+ private Q_SLOTS:
1160+ void onInitialSearchCompleted();
1161+ void onDeviceDiscovered( Cagibi::RootDevice* rootDevice );
1162+ void onDeviceRemoved( Cagibi::RootDevice* rootDevice );
1163+
1164+ private:
1165+ bool shutsDownOnNoActivity() const;
1166+
1167+ private:
1168+ SSDPWatcher* mSsdpWatcher;
1169+ QTimer* mShutDownTimer;
1170+
1171+ int mShutDownTimeout;
1172+};
1173+
1174+inline bool DeviceList::shutsDownOnNoActivity() const { return mShutDownTimeout != 0; }
1175+
1176+}
1177+
1178+#endif
1179
1180=== added file 'daemon/devicelistdbusadaptor.cpp'
1181--- daemon/devicelistdbusadaptor.cpp 1970-01-01 00:00:00 +0000
1182+++ daemon/devicelistdbusadaptor.cpp 2012-06-21 14:28:20 +0000
1183@@ -0,0 +1,71 @@
1184+/*
1185+ This file is part of the Cagibi daemon.
1186+
1187+ Copyright 2010-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
1188+
1189+ This program is free software; you can redistribute it and/or
1190+ modify it under the terms of the GNU General Public License as
1191+ published by the Free Software Foundation; either version 2 of
1192+ the License or (at your option) version 3 or any later version
1193+ accepted by the membership of KDE e.V. (or its successor approved
1194+ by the membership of KDE e.V.), which shall act as a proxy
1195+ defined in Section 14 of version 3 of the license.
1196+
1197+ This program is distributed in the hope that it will be useful,
1198+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1199+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1200+ GNU General Public License for more details.
1201+
1202+ You should have received a copy of the GNU General Public License
1203+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1204+*/
1205+
1206+#include "devicelistdbusadaptor.h"
1207+
1208+// daemon
1209+#include "dbuscodec.h"
1210+// Qt
1211+#include <QtDBus/QDBusMetaType>
1212+
1213+
1214+namespace Cagibi
1215+{
1216+
1217+DeviceListDBusAdaptor::DeviceListDBusAdaptor( DeviceList* parent )
1218+ : QDBusAbstractAdaptor( parent )
1219+{
1220+ connect( parent, SIGNAL(devicesAdded(DeviceTypeMap)),
1221+ SIGNAL(devicesAdded(DeviceTypeMap)) );
1222+ connect( parent, SIGNAL(devicesRemoved(DeviceTypeMap)),
1223+ SIGNAL(devicesRemoved(DeviceTypeMap)) );
1224+
1225+ // TODO: best place to do this?
1226+ qDBusRegisterMetaType<DeviceTypeMap>();
1227+ qDBusRegisterMetaType<Cagibi::Device>();
1228+}
1229+
1230+DeviceTypeMap DeviceListDBusAdaptor::allDevices() const
1231+{
1232+ return parent()->allDevices();
1233+}
1234+
1235+DeviceTypeMap DeviceListDBusAdaptor::devicesByParent( const QString& udn ) const
1236+{
1237+ return parent()->devicesByParent( udn );
1238+}
1239+
1240+DeviceTypeMap DeviceListDBusAdaptor::devicesByType( const QString& type ) const
1241+{
1242+ return parent()->devicesByType( type );
1243+}
1244+
1245+Device DeviceListDBusAdaptor::deviceDetails( const QString& udn ) const
1246+{
1247+ return parent()->deviceDetails( udn );
1248+}
1249+
1250+DeviceListDBusAdaptor::~DeviceListDBusAdaptor()
1251+{
1252+}
1253+
1254+}
1255
1256=== added file 'daemon/devicelistdbusadaptor.h'
1257--- daemon/devicelistdbusadaptor.h 1970-01-01 00:00:00 +0000
1258+++ daemon/devicelistdbusadaptor.h 2012-06-21 14:28:20 +0000
1259@@ -0,0 +1,65 @@
1260+/*
1261+ This file is part of the Cagibi daemon.
1262+
1263+ Copyright 2010-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
1264+
1265+ This program is free software; you can redistribute it and/or
1266+ modify it under the terms of the GNU General Public License as
1267+ published by the Free Software Foundation; either version 2 of
1268+ the License or (at your option) version 3 or any later version
1269+ accepted by the membership of KDE e.V. (or its successor approved
1270+ by the membership of KDE e.V.), which shall act as a proxy
1271+ defined in Section 14 of version 3 of the license.
1272+
1273+ This program is distributed in the hope that it will be useful,
1274+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1275+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1276+ GNU General Public License for more details.
1277+
1278+ You should have received a copy of the GNU General Public License
1279+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1280+*/
1281+
1282+#ifndef DEVICELISTDBUSADAPTOR_H
1283+#define DEVICELISTDBUSADAPTOR_H
1284+
1285+// program
1286+#include "devicelist.h"
1287+#include "dbuscodec.h"
1288+// Qt
1289+#include <QtDBus/QtDBus>
1290+
1291+
1292+namespace Cagibi
1293+{
1294+
1295+class DeviceListDBusAdaptor: public QDBusAbstractAdaptor
1296+{
1297+ Q_OBJECT
1298+ Q_CLASSINFO("D-Bus Interface", "org.kde.Cagibi.DeviceList")
1299+
1300+ public:
1301+ explicit DeviceListDBusAdaptor( DeviceList* parent );
1302+
1303+ virtual ~DeviceListDBusAdaptor();
1304+
1305+ public:
1306+ DeviceList* parent() const;
1307+
1308+ public Q_SLOTS:
1309+ DeviceTypeMap allDevices() const;
1310+ DeviceTypeMap devicesByParent( const QString& udn ) const;
1311+ DeviceTypeMap devicesByType( const QString& type ) const;
1312+ Cagibi::Device deviceDetails( const QString& udn ) const;
1313+
1314+ Q_SIGNALS:
1315+ void devicesAdded( const DeviceTypeMap& devices );
1316+ void devicesRemoved( const DeviceTypeMap& devices );
1317+};
1318+
1319+
1320+inline DeviceList* DeviceListDBusAdaptor::parent() const { return static_cast<DeviceList*>( QObject::parent() ); }
1321+
1322+}
1323+
1324+#endif
1325
1326=== modified file 'daemon/icon.cpp'
1327--- daemon/icon.cpp 2010-07-29 11:43:50 +0000
1328+++ daemon/icon.cpp 2012-06-21 14:28:20 +0000
1329@@ -1,5 +1,5 @@
1330 /*
1331- This file is part of the Cagibi library, part of the KDE project.
1332+ This file is part of the Cagibi daemon.
1333
1334 Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
1335
1336
1337=== modified file 'daemon/icon.h'
1338--- daemon/icon.h 2010-07-29 11:43:50 +0000
1339+++ daemon/icon.h 2012-06-21 14:28:20 +0000
1340@@ -1,5 +1,5 @@
1341 /*
1342- This file is part of the Cagibi library, part of the KDE project.
1343+ This file is part of the Cagibi daemon.
1344
1345 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1346
1347
1348=== modified file 'daemon/icon_p.cpp'
1349--- daemon/icon_p.cpp 2010-07-29 11:43:50 +0000
1350+++ daemon/icon_p.cpp 2012-06-21 14:28:20 +0000
1351@@ -1,5 +1,5 @@
1352 /*
1353- This file is part of the Cagibi library, part of the KDE project.
1354+ This file is part of the Cagibi daemon.
1355
1356 Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
1357
1358
1359=== modified file 'daemon/icon_p.h'
1360--- daemon/icon_p.h 2010-07-29 11:43:50 +0000
1361+++ daemon/icon_p.h 2012-06-21 14:28:20 +0000
1362@@ -1,5 +1,5 @@
1363 /*
1364- This file is part of the Cagibi library, part of the KDE project.
1365+ This file is part of the Cagibi daemon.
1366
1367 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1368
1369
1370=== modified file 'daemon/main.cpp'
1371--- daemon/main.cpp 2010-07-29 11:43:50 +0000
1372+++ daemon/main.cpp 2012-06-21 14:28:20 +0000
1373@@ -1,7 +1,7 @@
1374 /*
1375- This file is part of the Cagibi daemon, part of the KDE project.
1376+ This file is part of the Cagibi daemon.
1377
1378- Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
1379+ Copyright 2009,2011 Friedrich W. H. Kossebau <kossebau@kde.org>
1380
1381 This program is free software; you can redistribute it and/or
1382 modify it under the terms of the GNU General Public License as
1383@@ -21,26 +21,14 @@
1384 */
1385
1386 // program
1387-#include "upnpproxy.h"
1388-// Qt
1389-#include <QtDBus/QDBusConnection>
1390-#include <QtCore/QCoreApplication>
1391+#include "daemon.h"
1392
1393-// #include <KApplication>
1394-// #include <kaboutdata.h>
1395-// #include <kcmdlineargs.h>
1396
1397 int main( int argc, char* argv[] )
1398 {
1399- QCoreApplication programCore( argc, argv );
1400-// KAboutData about("cagibi", "cagibi", ki18n("Cagibi Daemon"), "", ki18n("Cagibi Daemon"), KAboutData::License_GPL, ki18n("Copyright icke"));
1401-
1402-// KCmdLineArgs::init(argc, argv, &about);
1403-// KApplication programCore;
1404-
1405- new Cagibi::UPnPProxy();
1406-
1407- const int result = programCore.exec();
1408+ Cagibi::Daemon daemon( argc, argv );
1409+
1410+ const int result = daemon.exec();
1411
1412 return result;
1413 }
1414
1415=== added file 'daemon/org.kde.Cagibi.Control.xml'
1416--- daemon/org.kde.Cagibi.Control.xml 1970-01-01 00:00:00 +0000
1417+++ daemon/org.kde.Cagibi.Control.xml 2012-06-21 14:28:20 +0000
1418@@ -0,0 +1,14 @@
1419+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
1420+<node xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
1421+<interface name="org.kde.Cagibi.Control">
1422+ <!-- METHODS -->
1423+
1424+ <method name="shutDown">
1425+ <tp:docstring>
1426+ Shuts the proxy server down.
1427+ </tp:docstring>
1428+ <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
1429+ </method>
1430+
1431+</interface>
1432+</node>
1433\ No newline at end of file
1434
1435=== added file 'daemon/org.kde.Cagibi.DeviceList.xml'
1436--- daemon/org.kde.Cagibi.DeviceList.xml 1970-01-01 00:00:00 +0000
1437+++ daemon/org.kde.Cagibi.DeviceList.xml 2012-06-21 14:28:20 +0000
1438@@ -0,0 +1,96 @@
1439+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
1440+<node xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
1441+<interface name="org.kde.Cagibi.DeviceList">
1442+ <!-- METHODS -->
1443+
1444+ <method name="allDevices">
1445+ <tp:docstring>
1446+ Get the list of UPnP devices currently discovered.
1447+ </tp:docstring>
1448+ <arg type="a{ss}" direction="out">
1449+ <tp:docstring>
1450+ A list of the devices as pairs of first udn and second type.
1451+ </tp:docstring>
1452+ </arg>
1453+ <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,QString&gt;" />
1454+ </method>
1455+
1456+ <method name="devicesByParent">
1457+ <tp:docstring>
1458+ Get the list of UPnP devices currently discovered which have the device with
1459+ the given udn as parent device.
1460+ </tp:docstring>
1461+ <arg name="udn" type="s" direction="in"/>
1462+ <arg type="a{ss}" direction="out">
1463+ <tp:docstring>
1464+ A list of the devices as pairs of first udn and second type.
1465+ </tp:docstring>
1466+ </arg>
1467+ <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,QString&gt;" />
1468+ </method>
1469+
1470+ <method name="devicesByType">
1471+ <tp:docstring>
1472+ Get the list of UPnP devices currently discovered which are of the given type.
1473+ </tp:docstring>
1474+ <arg name="type" type="s" direction="in"/>
1475+ <arg type="a{ss}" direction="out">
1476+ <tp:docstring>
1477+ A list of the devices as pairs of first udn and second type.
1478+ </tp:docstring>
1479+ </arg>
1480+ <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,QString&gt;" />
1481+ </method>
1482+
1483+ <method name="deviceDetails">
1484+ <tp:docstring>
1485+ Get the details of the device with the given udn.
1486+ </tp:docstring>
1487+ <arg name="udn" type="s" direction="in"/>
1488+ <arg type="a{ss}" direction="out">
1489+ <tp:docstring>
1490+ Details of the device, passed in a StringStringMap. Keys are:
1491+ deviceType,
1492+ friendlyName,
1493+ manufacturer,
1494+ modelDescription,
1495+ modelName,
1496+ modelNumber,
1497+ serialNumber,
1498+ UDN,
1499+ presentationURL,
1500+ ipAddress,
1501+ ipPortNumber,
1502+ parentDeviceUDN
1503+ </tp:docstring>
1504+ </arg>
1505+ <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,QString&gt;" />
1506+ </method>
1507+
1508+ <!-- SIGNALS -->
1509+
1510+ <signal name="devicesAdded">
1511+ <tp:docstring>
1512+ One or more devices have been discovered on the network.
1513+ </tp:docstring>
1514+ <arg name="devices" type="a{ss}" direction="out">
1515+ <tp:docstring>
1516+ A list of the devices as pairs of first udn and second type.
1517+ </tp:docstring>
1518+ </arg>
1519+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QHash&lt;QString,QString&gt;" />
1520+ </signal>
1521+
1522+ <signal name="devicesRemoved">
1523+ <tp:docstring>
1524+ One or more devices have disappeared from the network.
1525+ </tp:docstring>
1526+ <arg name="devices" type="a{ss}" direction="out">
1527+ <tp:docstring>
1528+ A list of the devices as pairs of first udn and second type.
1529+ </tp:docstring>
1530+ </arg>
1531+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QHash&lt;QString,QString&gt;" />
1532+ </signal>
1533+</interface>
1534+</node>
1535\ No newline at end of file
1536
1537=== added file 'daemon/org.kde.Cagibi.conf'
1538--- daemon/org.kde.Cagibi.conf 1970-01-01 00:00:00 +0000
1539+++ daemon/org.kde.Cagibi.conf 2012-06-21 14:28:20 +0000
1540@@ -0,0 +1,11 @@
1541+<!DOCTYPE busconfig PUBLIC
1542+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
1543+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
1544+<busconfig>
1545+ <policy user="root">
1546+ <allow own="org.kde.Cagibi"/>
1547+ </policy>
1548+ <policy context="default">
1549+ <allow send_destination="org.kde.Cagibi" />
1550+ </policy>
1551+</busconfig>
1552
1553=== modified file 'daemon/org.kde.Cagibi.service.cmake'
1554--- daemon/org.kde.Cagibi.service.cmake 2010-08-29 19:29:08 +0000
1555+++ daemon/org.kde.Cagibi.service.cmake 2012-06-21 14:28:20 +0000
1556@@ -1,3 +1,4 @@
1557 [D-BUS Service]
1558 Name=org.kde.Cagibi
1559 Exec=${CMAKE_INSTALL_PREFIX}/bin/cagibid
1560+User=root
1561
1562=== removed file 'daemon/org.kde.Cagibi.xml'
1563--- daemon/org.kde.Cagibi.xml 2010-07-29 11:43:50 +0000
1564+++ daemon/org.kde.Cagibi.xml 1970-01-01 00:00:00 +0000
1565@@ -1,78 +0,0 @@
1566-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
1567-<node xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
1568-<interface name="org.kde.Cagibi">
1569- <!-- METHODS -->
1570-
1571- <method name="allDevices">
1572- <tp:docstring>
1573- Get the list of UPnP devices currently discovered.
1574- </tp:docstring>
1575- <arg type="a{ss}" direction="out">
1576- <tp:docstring>
1577- A list of the devices as pairs of first udn and second type.
1578- </tp:docstring>
1579- </arg>
1580- </method>
1581-
1582- <method name="devicesByParent">
1583- <tp:docstring>
1584- Get the list of UPnP devices currently discovered which have the device with
1585- the given udn as parent device.
1586- </tp:docstring>
1587- <arg name="udn" type="s" direction="in"/>
1588- <arg type="a{ss}" direction="out">
1589- <tp:docstring>
1590- A list of the devices as pairs of first udn and second type.
1591- </tp:docstring>
1592- </arg>
1593- </method>
1594-
1595- <method name="devicesByType">
1596- <tp:docstring>
1597- Get the list of UPnP devices currently discovered which are of the given type.
1598- </tp:docstring>
1599- <arg name="type" type="s" direction="in"/>
1600- <arg type="a{ss}" direction="out">
1601- <tp:docstring>
1602- A list of the devices as pairs of first udn and second type.
1603- </tp:docstring>
1604- </arg>
1605- </method>
1606-
1607- <method name="deviceDetails">
1608- <tp:docstring>
1609- Get the details of the device with the given udn.
1610- </tp:docstring>
1611- <arg name="udn" type="s" direction="in"/>
1612- <arg type="(ssssssssssis)" direction="out">
1613- <tp:docstring>
1614- Details of the device. TODO: turn into StringVariantMap to be extendable
1615- </tp:docstring>
1616- </arg>
1617- </method>
1618-
1619- <!-- SIGNALS -->
1620-
1621- <signal name="devicesAdded">
1622- <tp:docstring>
1623- One or more devices have been discovered on the network.
1624- </tp:docstring>
1625- <arg name="devices" type="a{ss}" direction="out">
1626- <tp:docstring>
1627- A list of the devices as pairs of first udn and second type.
1628- </tp:docstring>
1629- </arg>
1630- </signal>
1631-
1632- <signal name="devicesRemoved">
1633- <tp:docstring>
1634- One or more devices have disappeared from the network.
1635- </tp:docstring>
1636- <arg name="devices" type="a{ss}" direction="out">
1637- <tp:docstring>
1638- A list of the devices as pairs of first udn and second type.
1639- </tp:docstring>
1640- </arg>
1641- </signal>
1642-</interface>
1643-</node>
1644\ No newline at end of file
1645
1646=== modified file 'daemon/rootdevice.cpp'
1647--- daemon/rootdevice.cpp 2010-07-29 11:43:50 +0000
1648+++ daemon/rootdevice.cpp 2012-06-21 14:28:20 +0000
1649@@ -1,5 +1,5 @@
1650 /*
1651- This file is part of the Cagibi library, part of the KDE project.
1652+ This file is part of the Cagibi daemon.
1653
1654 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1655
1656@@ -86,7 +86,7 @@
1657 else
1658 {
1659 const QByteArray deviceDescriptionData = reply->readAll();
1660-qDebug()<< QString::fromAscii(deviceDescriptionData);
1661+// qDebug()<< QString::fromAscii(deviceDescriptionData);
1662 success = parseDeviceDescription( this, deviceDescriptionData, &mError );
1663 }
1664 reply->deleteLater();
1665
1666=== modified file 'daemon/rootdevice.h'
1667--- daemon/rootdevice.h 2010-07-29 11:43:50 +0000
1668+++ daemon/rootdevice.h 2012-06-21 14:28:20 +0000
1669@@ -1,5 +1,5 @@
1670 /*
1671- This file is part of the Cagibi library, part of the KDE project.
1672+ This file is part of the Cagibi daemon.
1673
1674 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1675
1676
1677=== modified file 'daemon/service.cpp'
1678--- daemon/service.cpp 2010-07-29 11:43:50 +0000
1679+++ daemon/service.cpp 2012-06-21 14:28:20 +0000
1680@@ -1,5 +1,5 @@
1681 /*
1682- This file is part of the Cagibi library, part of the KDE project.
1683+ This file is part of the Cagibi daemon.
1684
1685 Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
1686
1687
1688=== modified file 'daemon/service.h'
1689--- daemon/service.h 2010-07-29 11:43:50 +0000
1690+++ daemon/service.h 2012-06-21 14:28:20 +0000
1691@@ -1,5 +1,5 @@
1692 /*
1693- This file is part of the Cagibi library, part of the KDE project.
1694+ This file is part of the Cagibi daemon.
1695
1696 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1697
1698
1699=== modified file 'daemon/service_p.cpp'
1700--- daemon/service_p.cpp 2010-07-29 11:43:50 +0000
1701+++ daemon/service_p.cpp 2012-06-21 14:28:20 +0000
1702@@ -1,5 +1,5 @@
1703 /*
1704- This file is part of the Cagibi library, part of the KDE project.
1705+ This file is part of the Cagibi daemon.
1706
1707 Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
1708
1709
1710=== modified file 'daemon/service_p.h'
1711--- daemon/service_p.h 2010-07-29 11:43:50 +0000
1712+++ daemon/service_p.h 2012-06-21 14:28:20 +0000
1713@@ -1,5 +1,5 @@
1714 /*
1715- This file is part of the Cagibi library, part of the KDE project.
1716+ This file is part of the Cagibi daemon.
1717
1718 Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1719
1720
1721=== modified file 'daemon/ssdpwatcher.cpp'
1722--- daemon/ssdpwatcher.cpp 2010-07-29 11:43:50 +0000
1723+++ daemon/ssdpwatcher.cpp 2012-06-21 14:28:20 +0000
1724@@ -1,7 +1,7 @@
1725 /*
1726- This file is part of the Cagibi library, part of the KDE project.
1727+ This file is part of the Cagibi daemon.
1728
1729- Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1730+ Copyright 2009-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
1731
1732 This library is free software; you can redistribute it and/or
1733 modify it under the terms of the GNU Lesser General Public
1734@@ -26,6 +26,7 @@
1735 #include "rootdevice.h"
1736 // Qt
1737 #include <QtNetwork/QUdpSocket>
1738+#include <QtCore/QTimer>
1739 #include <QtCore/QUrl>
1740 #include <QtCore/QStringList>
1741 // C
1742@@ -111,22 +112,22 @@
1743 }
1744
1745
1746-void SSDPWatcher::discover()
1747+void SSDPWatcher::startDiscover( int searchTimeout )
1748 {
1749 qDebug() << "Trying to find UPnP devices on the local network";
1750
1751 // send a HTTP M-SEARCH message to 239.255.255.250:1900
1752- const char mSearchMessage[] =
1753+ const QByteArray searchMessage =
1754 "M-SEARCH * HTTP/1.1\r\n"
1755 "HOST: "SSDP_BROADCAST_ADDRESS":"SSDP_PORT"\r\n"
1756 "ST:"ROOTDEVICE"\r\n"
1757 // "ST: ssdp:all\r\n"
1758 "MAN:\"ssdp:discover\"\r\n"
1759- "MX:3\r\n" // max number of seconds to wait for response
1760+ "MX:" + QByteArray::number(searchTimeout) + "\r\n" // max number of seconds to wait for response
1761 "\r\n";
1762- const int mSearchMessageLength = sizeof(mSearchMessage) / sizeof(mSearchMessage[0]);
1763
1764- mUdpSocket->writeDatagram( mSearchMessage, mSearchMessageLength, QHostAddress(SSDPBroadCastAddress), SSDPPortNumber );
1765+ mUdpSocket->writeDatagram( searchMessage.constData(), searchMessage.size(), QHostAddress(SSDPBroadCastAddress), SSDPPortNumber );
1766+ QTimer::singleShot( searchTimeout * 1000, this, SLOT(onSearchTimeout()) );
1767 }
1768
1769
1770@@ -332,7 +333,6 @@
1771 if( bytesRead == -1 )
1772 // TODO: error handling
1773 return;
1774-qDebug()<<QString::fromAscii(message);
1775
1776 handleMessage( message );
1777 }
1778@@ -344,6 +344,10 @@
1779 qDebug() << "SSDPWatcher Error : " << mUdpSocket->errorString();
1780 }
1781
1782+void SSDPWatcher::onSearchTimeout()
1783+{
1784+ emit initialSearchCompleted();
1785+}
1786
1787 SSDPWatcher::~SSDPWatcher()
1788 {
1789
1790=== modified file 'daemon/ssdpwatcher.h'
1791--- daemon/ssdpwatcher.h 2010-07-29 11:43:50 +0000
1792+++ daemon/ssdpwatcher.h 2012-06-21 14:28:20 +0000
1793@@ -1,7 +1,7 @@
1794 /*
1795- This file is part of the Cagibi library, part of the KDE project.
1796+ This file is part of the Cagibi daemon.
1797
1798- Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1799+ Copyright 2009-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
1800
1801 This library is free software; you can redistribute it and/or
1802 modify it under the terms of the GNU Lesser General Public
1803@@ -50,9 +50,10 @@
1804 QList<RootDevice*> devices() const;
1805
1806 public Q_SLOTS:
1807- void discover();
1808+ void startDiscover( int searchTimeout );
1809
1810 Q_SIGNALS:
1811+ void initialSearchCompleted();
1812 void deviceDiscovered( Cagibi::RootDevice* device );
1813 void deviceRemoved( Cagibi::RootDevice* device );
1814
1815@@ -64,6 +65,7 @@
1816 void onUdpSocketError( QAbstractSocket::SocketError error );
1817 void onDeviceDescriptionDownloadDone( RootDevice* device, bool success );
1818 void onCacheTimedOut( RootDevice* device );
1819+ void onSearchTimeout();
1820
1821 protected:
1822 QHash<QString,RootDevice*> mDevices;
1823
1824=== removed file 'daemon/upnpproxy.cpp'
1825--- daemon/upnpproxy.cpp 2010-07-29 11:43:50 +0000
1826+++ daemon/upnpproxy.cpp 1970-01-01 00:00:00 +0000
1827@@ -1,195 +0,0 @@
1828-/*
1829- This file is part of the Cagibi daemon, part of the KDE project.
1830-
1831- Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
1832-
1833- This program is free software; you can redistribute it and/or
1834- modify it under the terms of the GNU General Public License as
1835- published by the Free Software Foundation; either version 2 of
1836- the License or (at your option) version 3 or any later version
1837- accepted by the membership of KDE e.V. (or its successor approved
1838- by the membership of KDE e.V.), which shall act as a proxy
1839- defined in Section 14 of version 3 of the license.
1840-
1841- This program is distributed in the hope that it will be useful,
1842- but WITHOUT ANY WARRANTY; without even the implied warranty of
1843- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1844- GNU General Public License for more details.
1845-
1846- You should have received a copy of the GNU General Public License
1847- along with this program. If not, see <http://www.gnu.org/licenses/>.
1848-*/
1849-
1850-#include "upnpproxy.h"
1851-
1852-// program
1853-#include "upnpproxydbusadaptor.h"
1854-#include "ssdpwatcher.h"
1855-#include "rootdevice.h"
1856-#include "device.h"
1857-
1858-#include <QtCore/QDebug>
1859-
1860-namespace Cagibi
1861-{
1862-
1863-static void fillMap( DeviceTypeMap& map, const Device& device )
1864-{
1865- map.insert( device.udn(), device.type() );
1866- foreach( const Cagibi::Device& subDevice, device.devices() )
1867- fillMap( map, subDevice );
1868-}
1869-
1870-static void fillMapByType( DeviceTypeMap& map, const Device& device,
1871- const QString& type )
1872-{
1873- const QString deviceType = device.type();
1874-
1875- if( deviceType == type )
1876- map.insert( device.udn(), deviceType );
1877-
1878- foreach( const Cagibi::Device& subDevice, device.devices() )
1879- fillMapByType( map, subDevice, type );
1880-}
1881-
1882-static const Device* find( const Device& device, const QString& udn )
1883-{
1884- const Device* result = 0;
1885-
1886- if( device.udn() == udn )
1887- result = &device;
1888- else
1889- {
1890- foreach( const Cagibi::Device& subDevice, device.devices() )
1891- {
1892- result = find( subDevice, udn );
1893- if( result )
1894- break;
1895- }
1896- }
1897-
1898- return result;
1899-}
1900-
1901-
1902-UPnPProxy::UPnPProxy( QObject* parent )
1903- : QObject( parent ),
1904- mSsdpWatcher( new SSDPWatcher(this) )
1905-{
1906- new UPnPProxyDBusAdaptor( this );
1907-
1908- QDBusConnection sessionBus = QDBusConnection::sessionBus();
1909- sessionBus.registerService( QString::fromLatin1("org.kde.Cagibi") );
1910- sessionBus.registerObject( QString::fromLatin1("/org/kde/Cagibi"), this );
1911-
1912- connect( mSsdpWatcher, SIGNAL(deviceDiscovered( Cagibi::RootDevice* )),
1913- SLOT(onDeviceDiscovered( Cagibi::RootDevice* )) );
1914- connect( mSsdpWatcher, SIGNAL(deviceRemoved( Cagibi::RootDevice* )),
1915- SLOT(onDeviceRemoved( Cagibi::RootDevice* )) );
1916-
1917- mSsdpWatcher->discover();
1918-}
1919-
1920-DeviceTypeMap UPnPProxy::allDevices() const
1921-{
1922- DeviceTypeMap result;
1923-
1924- const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1925-
1926- foreach( RootDevice* rootDevice, rootDevices )
1927- {
1928- const Device device = rootDevice->device();
1929- fillMap( result, device );
1930- }
1931-
1932- return result;
1933-}
1934-
1935-DeviceTypeMap UPnPProxy::devicesByParent( const QString& udn ) const
1936-{
1937- DeviceTypeMap result;
1938-
1939- const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1940-
1941- foreach( RootDevice* rootDevice, rootDevices )
1942- {
1943- const Device device = rootDevice->device();
1944-
1945- if( udn.isEmpty() )
1946- result.insert( device.udn(), device.type() );
1947- else
1948- {
1949- const Device* match = find( device, udn );
1950- if( match )
1951- {
1952- foreach( const Cagibi::Device& subDevice, device.devices() )
1953- result.insert( subDevice.udn(), subDevice.type() );
1954- break;
1955- }
1956- }
1957- }
1958-
1959- return result;
1960-}
1961-
1962-DeviceTypeMap UPnPProxy::devicesByType( const QString& type ) const
1963-{
1964- DeviceTypeMap result;
1965-
1966- const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1967-
1968- foreach( RootDevice* rootDevice, rootDevices )
1969- {
1970- const Device device = rootDevice->device();
1971- fillMapByType( result, device, type );
1972- }
1973-
1974- return result;
1975-}
1976-
1977-Device UPnPProxy::deviceDetails( const QString& udn ) const
1978-{
1979- Device result;
1980-
1981- const QList<RootDevice*> rootDevices = mSsdpWatcher->devices();
1982-
1983- foreach( RootDevice* rootDevice, rootDevices )
1984- {
1985- const Device device = rootDevice->device();
1986-
1987- const Device* match = find( device, udn );
1988- if( match )
1989- {
1990- result = *match;
1991- break;
1992- }
1993- }
1994-
1995- return result;
1996-}
1997-
1998-void UPnPProxy::onDeviceDiscovered( RootDevice* rootDevice )
1999-{
2000- DeviceTypeMap devices;
2001-
2002- const Device device = rootDevice->device();
2003- fillMap( devices, device );
2004-
2005- emit devicesAdded( devices );
2006-}
2007-
2008-void UPnPProxy::onDeviceRemoved( RootDevice* rootDevice )
2009-{
2010- DeviceTypeMap devices;
2011-
2012- const Device device = rootDevice->device();
2013- fillMap( devices, device );
2014-
2015- emit devicesRemoved( devices );
2016-}
2017-
2018-UPnPProxy::~UPnPProxy()
2019-{
2020-}
2021-
2022-}
2023
2024=== removed file 'daemon/upnpproxy.h'
2025--- daemon/upnpproxy.h 2010-07-29 11:43:50 +0000
2026+++ daemon/upnpproxy.h 1970-01-01 00:00:00 +0000
2027@@ -1,71 +0,0 @@
2028-/*
2029- This file is part of the Cagibi daemon, part of the KDE project.
2030-
2031- Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
2032-
2033- This program is free software; you can redistribute it and/or
2034- modify it under the terms of the GNU General Public License as
2035- published by the Free Software Foundation; either version 2 of
2036- the License or (at your option) version 3 or any later version
2037- accepted by the membership of KDE e.V. (or its successor approved
2038- by the membership of KDE e.V.), which shall act as a proxy
2039- defined in Section 14 of version 3 of the license.
2040-
2041- This program is distributed in the hope that it will be useful,
2042- but WITHOUT ANY WARRANTY; without even the implied warranty of
2043- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2044- GNU General Public License for more details.
2045-
2046- You should have received a copy of the GNU General Public License
2047- along with this program. If not, see <http://www.gnu.org/licenses/>.
2048-*/
2049-
2050-#ifndef UPNPPROXY_H
2051-#define UPNPPROXY_H
2052-
2053-// Qt
2054-#include <QtCore/QObject>
2055-#include <QtCore/QHash>
2056-#include <QtCore/QString>
2057-#include <QtCore/QMetaType>
2058-
2059-typedef QHash<QString,QString> DeviceTypeMap;
2060-Q_DECLARE_METATYPE( DeviceTypeMap )
2061-
2062-
2063-namespace Cagibi
2064-{
2065-class SSDPWatcher;
2066-class RootDevice;
2067-class Device;
2068-
2069-
2070-class UPnPProxy : public QObject
2071-{
2072- Q_OBJECT
2073-
2074- public:
2075- explicit UPnPProxy( QObject* parent = 0 );
2076- virtual ~UPnPProxy();
2077-
2078- public:
2079- DeviceTypeMap allDevices() const;
2080- DeviceTypeMap devicesByParent( const QString& udn ) const;
2081- DeviceTypeMap devicesByType( const QString& type ) const;
2082- Device deviceDetails( const QString& udn ) const;
2083-
2084- Q_SIGNALS:
2085- void devicesAdded( const DeviceTypeMap& devices );
2086- void devicesRemoved( const DeviceTypeMap& devices );
2087-
2088- private Q_SLOTS:
2089- void onDeviceDiscovered( Cagibi::RootDevice* rootDevice );
2090- void onDeviceRemoved( Cagibi::RootDevice* rootDevice );
2091-
2092- private:
2093- SSDPWatcher* mSsdpWatcher;
2094-};
2095-
2096-}
2097-
2098-#endif
2099
2100=== removed file 'daemon/upnpproxydbusadaptor.cpp'
2101--- daemon/upnpproxydbusadaptor.cpp 2010-07-29 11:43:50 +0000
2102+++ daemon/upnpproxydbusadaptor.cpp 1970-01-01 00:00:00 +0000
2103@@ -1,71 +0,0 @@
2104-/*
2105- This file is part of the Cagibi daemon, part of the KDE project.
2106-
2107- Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
2108-
2109- This program is free software; you can redistribute it and/or
2110- modify it under the terms of the GNU General Public License as
2111- published by the Free Software Foundation; either version 2 of
2112- the License or (at your option) version 3 or any later version
2113- accepted by the membership of KDE e.V. (or its successor approved
2114- by the membership of KDE e.V.), which shall act as a proxy
2115- defined in Section 14 of version 3 of the license.
2116-
2117- This program is distributed in the hope that it will be useful,
2118- but WITHOUT ANY WARRANTY; without even the implied warranty of
2119- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2120- GNU General Public License for more details.
2121-
2122- You should have received a copy of the GNU General Public License
2123- along with this program. If not, see <http://www.gnu.org/licenses/>.
2124-*/
2125-
2126-#include "upnpproxydbusadaptor.h"
2127-
2128-// daemon
2129-#include "dbuscodec.h"
2130-// Qt
2131-#include <QtDBus/QDBusMetaType>
2132-
2133-
2134-namespace Cagibi
2135-{
2136-
2137-UPnPProxyDBusAdaptor::UPnPProxyDBusAdaptor( UPnPProxy* parent )
2138- : QDBusAbstractAdaptor( parent )
2139-{
2140- connect( parent, SIGNAL(devicesAdded(DeviceTypeMap)),
2141- SIGNAL(devicesAdded(DeviceTypeMap)) );
2142- connect( parent, SIGNAL(devicesRemoved(DeviceTypeMap)),
2143- SIGNAL(devicesRemoved(DeviceTypeMap)) );
2144-
2145- // TODO: best place to do this?
2146- qDBusRegisterMetaType<DeviceTypeMap>();
2147- qDBusRegisterMetaType<Cagibi::Device>();
2148-}
2149-
2150-DeviceTypeMap UPnPProxyDBusAdaptor::allDevices() const
2151-{
2152- return parent()->allDevices();
2153-}
2154-
2155-DeviceTypeMap UPnPProxyDBusAdaptor::devicesByParent( const QString& udn ) const
2156-{
2157- return parent()->devicesByParent( udn );
2158-}
2159-
2160-DeviceTypeMap UPnPProxyDBusAdaptor::devicesByType( const QString& type ) const
2161-{
2162- return parent()->devicesByType( type );
2163-}
2164-
2165-Device UPnPProxyDBusAdaptor::deviceDetails( const QString& udn ) const
2166-{
2167- return parent()->deviceDetails( udn );
2168-}
2169-
2170-UPnPProxyDBusAdaptor::~UPnPProxyDBusAdaptor()
2171-{
2172-}
2173-
2174-}
2175
2176=== removed file 'daemon/upnpproxydbusadaptor.h'
2177--- daemon/upnpproxydbusadaptor.h 2010-07-29 11:43:50 +0000
2178+++ daemon/upnpproxydbusadaptor.h 1970-01-01 00:00:00 +0000
2179@@ -1,66 +0,0 @@
2180-/*
2181- This file is part of the Cagibi daemon, part of the KDE project.
2182-
2183- Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
2184-
2185- This program is free software; you can redistribute it and/or
2186- modify it under the terms of the GNU General Public License as
2187- published by the Free Software Foundation; either version 2 of
2188- the License or (at your option) version 3 or any later version
2189- accepted by the membership of KDE e.V. (or its successor approved
2190- by the membership of KDE e.V.), which shall act as a proxy
2191- defined in Section 14 of version 3 of the license.
2192-
2193- This program is distributed in the hope that it will be useful,
2194- but WITHOUT ANY WARRANTY; without even the implied warranty of
2195- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2196- GNU General Public License for more details.
2197-
2198- You should have received a copy of the GNU General Public License
2199- along with this program. If not, see <http://www.gnu.org/licenses/>.
2200-*/
2201-
2202-#ifndef UPNPPROXYDBUSADAPTOR_H
2203-#define UPNPPROXYDBUSADAPTOR_H
2204-
2205-// program
2206-#include "upnpproxy.h"
2207-#include "dbuscodec.h"
2208-// Qt
2209-#include <QtDBus/QtDBus>
2210-#include <QtCore/QObject>
2211-
2212-
2213-namespace Cagibi
2214-{
2215-
2216-class UPnPProxyDBusAdaptor: public QDBusAbstractAdaptor
2217-{
2218- Q_OBJECT
2219- Q_CLASSINFO("D-Bus Interface", "org.kde.Cagibi")
2220-
2221- public:
2222- explicit UPnPProxyDBusAdaptor( UPnPProxy* parent );
2223-
2224- virtual ~UPnPProxyDBusAdaptor();
2225-
2226- public:
2227- UPnPProxy* parent() const;
2228-
2229- public Q_SLOTS:
2230- DeviceTypeMap allDevices() const;
2231- DeviceTypeMap devicesByParent( const QString& udn ) const;
2232- DeviceTypeMap devicesByType( const QString& type ) const;
2233- Cagibi::Device deviceDetails( const QString& udn ) const;
2234-
2235- Q_SIGNALS:
2236- void devicesAdded( const DeviceTypeMap& devices );
2237- void devicesRemoved( const DeviceTypeMap& devices );
2238-};
2239-
2240-
2241-inline UPnPProxy* UPnPProxyDBusAdaptor::parent() const { return static_cast<UPnPProxy*>( QObject::parent() ); }
2242-
2243-}
2244-
2245-#endif
2246
2247=== modified file 'debian/changelog'
2248--- debian/changelog 2010-08-29 19:29:08 +0000
2249+++ debian/changelog 2012-06-21 14:28:20 +0000
2250@@ -1,3 +1,10 @@
2251+cagibi (0.2.0-0ubuntu1) quantal; urgency=low
2252+
2253+ * New upstream release (LP: #1013914).
2254+ * Update Standards-Version to 3.9.3.
2255+
2256+ -- Logan Rosen <logatronico@gmail.com> Thu, 21 Jun 2012 10:15:39 -0400
2257+
2258 cagibi (0.1.1-0ubuntu1) maverick; urgency=low
2259
2260 * New upstream release
2261
2262=== modified file 'debian/control'
2263--- debian/control 2010-08-29 19:29:08 +0000
2264+++ debian/control 2012-06-21 14:28:20 +0000
2265@@ -3,7 +3,7 @@
2266 Maintainer: Kubuntu Developers <kubuntu-devel@lists.ubuntu.com>
2267 XSBC-Original-Maintainer: Jonathan Riddell <jriddell@ubuntu.com>
2268 Build-Depends: debhelper (>= 7.3), cmake, automoc, libqt4-dev, pkg-kde-tools
2269-Standards-Version: 3.9.1
2270+Standards-Version: 3.9.3
2271 Section: kde
2272
2273 Package: cagibi

Subscribers

People subscribed via source and target branches

to all changes: