Contents of /trunk/kdebase/patches/kdebase-3.5.5-dbus060.patch
Parent Directory | Revision Log
Revision 144 -
(show annotations)
(download)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 39619 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 39619 byte(s)
-import
1 | diff -Naur kdebase-3.5.5/kioslave/media/configure.in.in kdebase-3.5.5.patched/kioslave/media/configure.in.in |
2 | --- kdebase-3.5.5/kioslave/media/configure.in.in 2006-10-01 19:31:54.000000000 +0200 |
3 | +++ kdebase-3.5.5.patched/kioslave/media/configure.in.in 2006-10-19 11:47:41.000000000 +0200 |
4 | @@ -97,70 +97,6 @@ |
5 | |
6 | AC_SUBST(DBUS_INCS) |
7 | AC_SUBST(DBUS_LIBS) |
8 | - |
9 | -########### Check for DBus-Qt3 bindings |
10 | - |
11 | - AC_MSG_CHECKING(for DBus-Qt3 bindings) |
12 | - |
13 | - dbusqt_inc=NOTFOUND |
14 | - dbusqt_lib=NOTFOUND |
15 | - dbusqt=NOTFOUND |
16 | - |
17 | - search_incs="$kde_includes $kde_extra_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0" |
18 | - AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir) |
19 | - |
20 | - if test -r $dbusqt_incdir/dbus/connection.h ; then |
21 | - have_qt_patch=0 |
22 | - grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \ |
23 | - > /dev/null 2>&1 && have_qt_patch=1 |
24 | - if test $have_qt_patch = 1 ; then |
25 | - DBUSQT_INCS="-I$dbusqt_incdir" |
26 | - dbusqt_inc=FOUND |
27 | - fi |
28 | - fi |
29 | - |
30 | - search_libs="$kde_libraries $kde_extra_libs /usr/lib$kdelibsuff /usr/local/lib$kdelibsuff" |
31 | - AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir) |
32 | - |
33 | - if test -r $dbusqt_libdir/libdbus-qt-1.so ; then |
34 | - DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1" |
35 | - dbusqt_lib=FOUND |
36 | - fi |
37 | - |
38 | - if test $dbusqt_inc != FOUND || test $dbusqt_lib != FOUND ; then |
39 | - |
40 | - search_incs="`pkg-config --cflags dbus-1 |sed 's/-I//g'`" |
41 | - AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir) |
42 | - if test -r $dbusqt_incdir/dbus/connection.h ; then |
43 | - have_qt_patch=0 |
44 | - grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \ |
45 | - > /dev/null 2>&1 && have_qt_patch=1 |
46 | - if test $have_qt_patch = 1 ; then |
47 | - DBUSQT_INCS="-I$dbusqt_incdir" |
48 | - dbusqt_inc=FOUND |
49 | - fi |
50 | - fi |
51 | - |
52 | - search_libs="`pkg-config --libs dbus-1 --libs-only-L | sed 's/-L//g'`" |
53 | - AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir) |
54 | - |
55 | - if test -r $dbusqt_libdir/libdbus-qt-1.so ; then |
56 | - DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1" |
57 | - dbusqt_lib=FOUND |
58 | - fi |
59 | - |
60 | - fi |
61 | - |
62 | - |
63 | - if test $dbusqt_inc = FOUND && test $dbusqt_lib = FOUND ; then |
64 | - AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir) |
65 | - dbusqt=FOUND |
66 | - else |
67 | - AC_MSG_RESULT(searched but not found) |
68 | - fi |
69 | - |
70 | - AC_SUBST(DBUSQT_INCS) |
71 | - AC_SUBST(DBUSQT_LIBS) |
72 | fi |
73 | |
74 | ########### Check if media HAL backend sould be compiled |
75 | @@ -168,7 +104,7 @@ |
76 | AC_MSG_CHECKING(if the HAL backend for media:/ should be compiled) |
77 | |
78 | HALBACKEND=no |
79 | -if test "x$hal" = "xFOUND" && test "x$dbus" = "xFOUND" && test "x$dbusqt" = "xFOUND" ; then |
80 | +if test "x$hal" = "xFOUND" && test "x$dbus" = "xFOUND" ; then |
81 | AC_DEFINE_UNQUOTED([COMPILE_HALBACKEND],1, [media HAL backend compilation]) |
82 | HALBACKEND=yes |
83 | AC_SUBST(HALBACKEND) |
84 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/connection.cpp kdebase-3.5.5.patched/kioslave/media/mediamanager/connection.cpp |
85 | --- kdebase-3.5.5/kioslave/media/mediamanager/connection.cpp 1970-01-01 01:00:00.000000000 +0100 |
86 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/connection.cpp 2006-10-19 11:37:12.000000000 +0200 |
87 | @@ -0,0 +1,168 @@ |
88 | +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- |
89 | +/* connection.cpp: Qt wrapper for DBusConnection |
90 | + * |
91 | + * Copyright (C) 2003 Zack Rusin <zack@kde.org> |
92 | + * |
93 | + * Licensed under the Academic Free License version 2.0 |
94 | + * |
95 | + * This program is free software; you can redistribute it and/or modify |
96 | + * it under the terms of the GNU General Public License as published by |
97 | + * the Free Software Foundation; either version 2 of the License, or |
98 | + * (at your option) any later version. |
99 | + * |
100 | + * This program is distributed in the hope that it will be useful, |
101 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
102 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
103 | + * GNU General Public License for more details. |
104 | + * |
105 | + * You should have received a copy of the GNU General Public License |
106 | + * along with this program; if not, write to the Free Software |
107 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
108 | + * |
109 | + */ |
110 | +#include "connection.h" |
111 | + |
112 | +using namespace DBusQt; |
113 | + |
114 | +#include "integrator.h" |
115 | +using Internal::Integrator; |
116 | + |
117 | +struct Connection::Private |
118 | +{ |
119 | + Private( Connection *qq ); |
120 | + void setConnection( DBusConnection *c ); |
121 | + DBusConnection *connection; |
122 | + int connectionSlot; |
123 | + DBusError error; |
124 | + Integrator *integrator; |
125 | + int timeout; |
126 | + Connection *q; |
127 | +}; |
128 | + |
129 | +Connection::Private::Private( Connection *qq ) |
130 | + : connection( 0 ), connectionSlot( 0 ), integrator( 0 ), |
131 | + timeout( -1 ), q( qq ) |
132 | +{ |
133 | + dbus_error_init( &error ); |
134 | +} |
135 | + |
136 | +void Connection::Private::setConnection( DBusConnection *c ) |
137 | +{ |
138 | + if (!c) { |
139 | + qDebug( "error: %s, %s", error.name, error.message ); |
140 | + dbus_error_free( &error ); |
141 | + return; |
142 | + } |
143 | + connection = c; |
144 | + integrator = new Integrator( c, q ); |
145 | + connect( integrator, SIGNAL(readReady()), q, SLOT(dispatchRead()) ); |
146 | +} |
147 | + |
148 | +Connection::Connection( QObject *parent ) |
149 | + : QObject( parent ) |
150 | +{ |
151 | + d = new Private( this ); |
152 | +} |
153 | + |
154 | +Connection::Connection( const QString& host, QObject *parent ) |
155 | + : QObject( parent ) |
156 | +{ |
157 | + d = new Private( this ); |
158 | + |
159 | + if ( !host.isEmpty() ) |
160 | + init( host ); |
161 | +} |
162 | + |
163 | +Connection::Connection( DBusBusType type, QObject* parent ) |
164 | + : QObject( parent ) |
165 | +{ |
166 | + d = new Private( this ); |
167 | + d->setConnection( dbus_bus_get(type, &d->error) ); |
168 | +} |
169 | + |
170 | +void Connection::init( const QString& host ) |
171 | +{ |
172 | + d->setConnection( dbus_connection_open( host.ascii(), &d->error) ); |
173 | + //dbus_connection_allocate_data_slot( &d->connectionSlot ); |
174 | + //dbus_connection_set_data( d->connection, d->connectionSlot, 0, 0 ); |
175 | +} |
176 | + |
177 | +bool Connection::isConnected() const |
178 | +{ |
179 | + return dbus_connection_get_is_connected( d->connection ); |
180 | +} |
181 | + |
182 | +bool Connection::isAuthenticated() const |
183 | +{ |
184 | + return dbus_connection_get_is_authenticated( d->connection ); |
185 | +} |
186 | + |
187 | +void Connection::open( const QString& host ) |
188 | +{ |
189 | + if ( host.isEmpty() ) return; |
190 | + |
191 | + init( host ); |
192 | +} |
193 | + |
194 | +void Connection::close() |
195 | +{ |
196 | + dbus_connection_close( d->connection ); |
197 | +} |
198 | + |
199 | +void Connection::flush() |
200 | +{ |
201 | + dbus_connection_flush( d->connection ); |
202 | +} |
203 | + |
204 | +void Connection::dispatchRead() |
205 | +{ |
206 | + while ( dbus_connection_dispatch( d->connection ) == DBUS_DISPATCH_DATA_REMAINS ) |
207 | + ; |
208 | +} |
209 | + |
210 | +DBusConnection* Connection::connection() const |
211 | +{ |
212 | + return d->connection; |
213 | +} |
214 | + |
215 | +Connection::Connection( DBusConnection *connection, QObject *parent ) |
216 | + : QObject( parent ) |
217 | +{ |
218 | + d = new Private(this); |
219 | + d->setConnection(connection); |
220 | +} |
221 | + |
222 | +void Connection::send( const Message &m ) |
223 | +{ |
224 | + dbus_connection_send(d->connection, m.message(), 0); |
225 | +} |
226 | + |
227 | +void Connection::sendWithReply( const Message& ) |
228 | +{ |
229 | +} |
230 | + |
231 | +Message Connection::sendWithReplyAndBlock( const Message &m ) |
232 | +{ |
233 | + DBusMessage *reply; |
234 | + reply = dbus_connection_send_with_reply_and_block( d->connection, m.message(), d->timeout, &d->error ); |
235 | + if (dbus_error_is_set(&d->error)) { |
236 | + qDebug("error: %s, %s", d->error.name, d->error.message); |
237 | + dbus_error_free(&d->error); |
238 | + } |
239 | + return Message( reply ); |
240 | +} |
241 | + |
242 | +void* Connection::virtual_hook( int, void* ) |
243 | +{ |
244 | +} |
245 | + |
246 | +void Connection::dbus_connection_setup_with_qt_main (DBusConnection *connection) |
247 | +{ |
248 | + d->setConnection( connection ); |
249 | +} |
250 | + |
251 | + |
252 | + |
253 | +///////////////////////////////////////////////////////// |
254 | + |
255 | +#include "connection.moc" |
256 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/connection.h kdebase-3.5.5.patched/kioslave/media/mediamanager/connection.h |
257 | --- kdebase-3.5.5/kioslave/media/mediamanager/connection.h 1970-01-01 01:00:00.000000000 +0100 |
258 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/connection.h 2006-10-19 11:37:12.000000000 +0200 |
259 | @@ -0,0 +1,86 @@ |
260 | +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- |
261 | +/* connection.h: Qt wrapper for DBusConnection |
262 | + * |
263 | + * Copyright (C) 2003 Zack Rusin <zack@kde.org> |
264 | + * |
265 | + * Licensed under the Academic Free License version 2.1 |
266 | + * |
267 | + * This program is free software; you can redistribute it and/or modify |
268 | + * it under the terms of the GNU General Public License as published by |
269 | + * the Free Software Foundation; either version 2 of the License, or |
270 | + * (at your option) any later version. |
271 | + * |
272 | + * This program is distributed in the hope that it will be useful, |
273 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
274 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
275 | + * GNU General Public License for more details. |
276 | + * |
277 | + * You should have received a copy of the GNU General Public License |
278 | + * along with this program; if not, write to the Free Software |
279 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
280 | + * |
281 | + */ |
282 | +#ifndef DBUS_QT_CONNECTION_H |
283 | +#define DBUS_QT_CONNECTION_H |
284 | + |
285 | +/* We acknowledge the the dbus API is unstable */ |
286 | +#define DBUS_API_SUBJECT_TO_CHANGE |
287 | + |
288 | +#include "message.h" |
289 | + |
290 | +#include <qobject.h> |
291 | +#include <qstring.h> |
292 | + |
293 | +#include "dbus/dbus.h" |
294 | + |
295 | +namespace DBusQt { |
296 | + namespace Internal { |
297 | + class Integrator; |
298 | + } |
299 | + |
300 | + class Connection : public QObject |
301 | + { |
302 | + Q_OBJECT |
303 | + public: |
304 | + Connection( QObject *parent =0 ); |
305 | + Connection( const QString& host, |
306 | + QObject *parent = 0 ); |
307 | + Connection( DBusBusType type, QObject* parent = 0 ); |
308 | + |
309 | + bool isConnected() const; |
310 | + bool isAuthenticated() const; |
311 | + |
312 | + Message borrowMessage(); |
313 | + Message popMessage(); |
314 | + void stealBorrowMessage( const Message& ); |
315 | + void dbus_connection_setup_with_qt_main (DBusConnection *connection); |
316 | + |
317 | + public slots: |
318 | + void open( const QString& ); |
319 | + void close(); |
320 | + void flush(); |
321 | + void send( const Message& ); |
322 | + void sendWithReply( const Message& ); |
323 | + Message sendWithReplyAndBlock( const Message& ); |
324 | + |
325 | + protected slots: |
326 | + void dispatchRead(); |
327 | + |
328 | + protected: |
329 | + void init( const QString& host ); |
330 | + virtual void *virtual_hook( int id, void *data ); |
331 | + |
332 | + private: |
333 | + friend class Internal::Integrator; |
334 | + DBusConnection *connection() const; |
335 | + Connection( DBusConnection *connection, QObject *parent ); |
336 | + |
337 | + private: |
338 | + struct Private; |
339 | + Private *d; |
340 | + }; |
341 | + |
342 | +} |
343 | + |
344 | + |
345 | +#endif |
346 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/halbackend.h kdebase-3.5.5.patched/kioslave/media/mediamanager/halbackend.h |
347 | --- kdebase-3.5.5/kioslave/media/mediamanager/halbackend.h 2006-07-22 10:15:45.000000000 +0200 |
348 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/halbackend.h 2006-10-19 11:37:12.000000000 +0200 |
349 | @@ -40,7 +40,7 @@ |
350 | /* We acknowledge the the dbus API is unstable */ |
351 | #define DBUS_API_SUBJECT_TO_CHANGE |
352 | /* DBus-Qt bindings */ |
353 | -#include <dbus/connection.h> |
354 | +#include <connection.h> |
355 | /* HAL libraries */ |
356 | #include <libhal.h> |
357 | #include <libhal-storage.h> |
358 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/integrator.cpp kdebase-3.5.5.patched/kioslave/media/mediamanager/integrator.cpp |
359 | --- kdebase-3.5.5/kioslave/media/mediamanager/integrator.cpp 1970-01-01 01:00:00.000000000 +0100 |
360 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/integrator.cpp 2006-10-19 11:37:12.000000000 +0200 |
361 | @@ -0,0 +1,244 @@ |
362 | +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- |
363 | +/* integrator.h: integrates D-BUS into Qt event loop |
364 | + * |
365 | + * Copyright (C) 2003 Zack Rusin <zack@kde.org> |
366 | + * |
367 | + * Licensed under the Academic Free License version 2.0 |
368 | + * |
369 | + * This program is free software; you can redistribute it and/or modify |
370 | + * it under the terms of the GNU General Public License as published by |
371 | + * the Free Software Foundation; either version 2 of the License, or |
372 | + * (at your option) any later version. |
373 | + * |
374 | + * This program is distributed in the hope that it will be useful, |
375 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
376 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
377 | + * GNU General Public License for more details. |
378 | + * |
379 | + * You should have received a copy of the GNU General Public License |
380 | + * along with this program; if not, write to the Free Software |
381 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
382 | + * |
383 | + */ |
384 | +#include "integrator.h" |
385 | +#include "connection.h" |
386 | + |
387 | +#include <qtimer.h> |
388 | +#include <qsocketnotifier.h> |
389 | +#include <qintdict.h> |
390 | +#include <qptrlist.h> |
391 | + |
392 | +namespace DBusQt |
393 | +{ |
394 | +namespace Internal { |
395 | + |
396 | +struct Watch { |
397 | + Watch(): readSocket( 0 ), writeSocket( 0 ) { } |
398 | + |
399 | + DBusWatch *watch; |
400 | + QSocketNotifier *readSocket; |
401 | + QSocketNotifier *writeSocket; |
402 | +}; |
403 | + |
404 | +////////////////////////////////////////////////////////////// |
405 | +dbus_bool_t dbusAddWatch( DBusWatch *watch, void *data ) |
406 | +{ |
407 | + Integrator *con = static_cast<Integrator*>( data ); |
408 | + con->addWatch( watch ); |
409 | + return true; |
410 | +} |
411 | +void dbusRemoveWatch( DBusWatch *watch, void *data ) |
412 | +{ |
413 | + Integrator *con = static_cast<Integrator*>( data ); |
414 | + con->removeWatch( watch ); |
415 | +} |
416 | + |
417 | +void dbusToggleWatch( DBusWatch *watch, void *data ) |
418 | +{ |
419 | + Integrator *itg = static_cast<Integrator*>( data ); |
420 | + if ( dbus_watch_get_enabled( watch ) ) |
421 | + itg->addWatch( watch ); |
422 | + else |
423 | + itg->removeWatch( watch ); |
424 | +} |
425 | + |
426 | +dbus_bool_t dbusAddTimeout( DBusTimeout *timeout, void *data ) |
427 | +{ |
428 | + if ( !dbus_timeout_get_enabled(timeout) ) |
429 | + return true; |
430 | + |
431 | + Integrator *itg = static_cast<Integrator*>( data ); |
432 | + itg->addTimeout( timeout ); |
433 | + return true; |
434 | +} |
435 | + |
436 | +void dbusRemoveTimeout( DBusTimeout *timeout, void *data ) |
437 | +{ |
438 | + Integrator *itg = static_cast<Integrator*>( data ); |
439 | + itg->removeTimeout( timeout ); |
440 | +} |
441 | + |
442 | +void dbusToggleTimeout( DBusTimeout *timeout, void *data ) |
443 | +{ |
444 | + Integrator *itg = static_cast<Integrator*>( data ); |
445 | + |
446 | + if ( dbus_timeout_get_enabled( timeout ) ) |
447 | + itg->addTimeout( timeout ); |
448 | + else |
449 | + itg->removeTimeout( timeout ); |
450 | +} |
451 | + |
452 | +void dbusWakeupMain( void* ) |
453 | +{ |
454 | +} |
455 | + |
456 | +void dbusNewConnection( DBusServer *server, |
457 | + DBusConnection *new_connection, |
458 | + void *data ) |
459 | +{ |
460 | + Integrator *itg = static_cast<Integrator*>( data ); |
461 | + itg->handleConnection( new_connection ); |
462 | +} |
463 | +///////////////////////////////////////////////////////////// |
464 | + |
465 | +Timeout::Timeout( QObject *parent, DBusTimeout *t ) |
466 | + : QObject( parent ), m_timeout( t ) |
467 | +{ |
468 | + m_timer = new QTimer( this ); |
469 | + connect( m_timer, SIGNAL(timeout()), |
470 | + SLOT(slotTimeout()) ); |
471 | +} |
472 | + |
473 | +void Timeout::slotTimeout() |
474 | +{ |
475 | + emit timeout( m_timeout ); |
476 | +} |
477 | + |
478 | +void Timeout::start() |
479 | +{ |
480 | + m_timer->start( dbus_timeout_get_interval( m_timeout ) ); |
481 | +} |
482 | + |
483 | +Integrator::Integrator( DBusConnection *conn, QObject *parent ) |
484 | + : QObject( parent ), m_connection( conn ) |
485 | +{ |
486 | + m_timeouts.setAutoDelete( true ); |
487 | + |
488 | + dbus_connection_set_watch_functions( m_connection, |
489 | + dbusAddWatch, |
490 | + dbusRemoveWatch, |
491 | + dbusToggleWatch, |
492 | + this, 0 ); |
493 | + dbus_connection_set_timeout_functions( m_connection, |
494 | + dbusAddTimeout, |
495 | + dbusRemoveTimeout, |
496 | + dbusToggleTimeout, |
497 | + this, 0 ); |
498 | + dbus_connection_set_wakeup_main_function( m_connection, |
499 | + dbusWakeupMain, |
500 | + this, 0 ); |
501 | +} |
502 | + |
503 | +Integrator::Integrator( DBusServer *server, QObject *parent ) |
504 | + : QObject( parent ), m_server( server ) |
505 | +{ |
506 | + m_connection = reinterpret_cast<DBusConnection*>( m_server ); |
507 | + m_timeouts.setAutoDelete( true ); |
508 | + |
509 | + dbus_server_set_watch_functions( m_server, |
510 | + dbusAddWatch, |
511 | + dbusRemoveWatch, |
512 | + dbusToggleWatch, |
513 | + this, 0 ); |
514 | + dbus_server_set_timeout_functions( m_server, |
515 | + dbusAddTimeout, |
516 | + dbusRemoveTimeout, |
517 | + dbusToggleTimeout, |
518 | + this, 0 ); |
519 | + dbus_server_set_new_connection_function( m_server, |
520 | + dbusNewConnection, |
521 | + this, 0 ); |
522 | +} |
523 | + |
524 | +void Integrator::slotRead( int fd ) |
525 | +{ |
526 | + QIntDictIterator<Watch> it( m_watches ); |
527 | + for ( ; it.current(); ++it ) |
528 | + dbus_watch_handle ( it.current()->watch, DBUS_WATCH_READABLE ); |
529 | + |
530 | + emit readReady(); |
531 | +} |
532 | + |
533 | +void Integrator::slotWrite( int fd ) |
534 | +{ |
535 | + QIntDictIterator<Watch> it( m_watches ); |
536 | + for ( ; it.current(); ++it ) |
537 | + dbus_watch_handle ( it.current()->watch, DBUS_WATCH_WRITABLE ); |
538 | +} |
539 | + |
540 | +void Integrator::slotTimeout( DBusTimeout *timeout ) |
541 | +{ |
542 | + dbus_timeout_handle( timeout ); |
543 | +} |
544 | + |
545 | +void Integrator::addWatch( DBusWatch *watch ) |
546 | +{ |
547 | + if ( !dbus_watch_get_enabled( watch ) ) |
548 | + return; |
549 | + |
550 | + Watch *qtwatch = new Watch; |
551 | + qtwatch->watch = watch; |
552 | + |
553 | + int flags = dbus_watch_get_flags( watch ); |
554 | + int fd = dbus_watch_get_fd( watch ); |
555 | + |
556 | + if ( flags & DBUS_WATCH_READABLE ) { |
557 | + qtwatch->readSocket = new QSocketNotifier( fd, QSocketNotifier::Read, this ); |
558 | + QObject::connect( qtwatch->readSocket, SIGNAL(activated(int)), SLOT(slotRead(int)) ); |
559 | + } |
560 | + |
561 | + if (flags & DBUS_WATCH_WRITABLE) { |
562 | + qtwatch->writeSocket = new QSocketNotifier( fd, QSocketNotifier::Write, this ); |
563 | + QObject::connect( qtwatch->writeSocket, SIGNAL(activated(int)), SLOT(slotWrite(int)) ); |
564 | + } |
565 | + |
566 | + m_watches.insert( fd, qtwatch ); |
567 | +} |
568 | + |
569 | +void Integrator::removeWatch( DBusWatch *watch ) |
570 | +{ |
571 | + int key = dbus_watch_get_fd( watch ); |
572 | + |
573 | + Watch *qtwatch = m_watches.take( key ); |
574 | + |
575 | + if ( qtwatch ) { |
576 | + delete qtwatch->readSocket; qtwatch->readSocket = 0; |
577 | + delete qtwatch->writeSocket; qtwatch->writeSocket = 0; |
578 | + delete qtwatch; |
579 | + } |
580 | +} |
581 | + |
582 | +void Integrator::addTimeout( DBusTimeout *timeout ) |
583 | +{ |
584 | + Timeout *mt = new Timeout( this, timeout ); |
585 | + m_timeouts.insert( timeout, mt ); |
586 | + connect( mt, SIGNAL(timeout(DBusTimeout*)), |
587 | + SLOT(slotTimeout(DBusTimeout*)) ); |
588 | + mt->start(); |
589 | +} |
590 | + |
591 | +void Integrator::removeTimeout( DBusTimeout *timeout ) |
592 | +{ |
593 | + m_timeouts.remove( timeout ); |
594 | +} |
595 | + |
596 | +void Integrator::handleConnection( DBusConnection *c ) |
597 | +{ |
598 | + Connection *con = new Connection( c, this ); |
599 | + emit newConnection( con ); |
600 | +} |
601 | + |
602 | +}//end namespace Internal |
603 | +}//end namespace DBusQt |
604 | + |
605 | +#include "integrator.moc" |
606 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/integrator.h kdebase-3.5.5.patched/kioslave/media/mediamanager/integrator.h |
607 | --- kdebase-3.5.5/kioslave/media/mediamanager/integrator.h 1970-01-01 01:00:00.000000000 +0100 |
608 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/integrator.h 2006-10-19 11:37:12.000000000 +0200 |
609 | @@ -0,0 +1,95 @@ |
610 | +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- |
611 | +/* integrator.h: integrates D-BUS into Qt event loop |
612 | + * |
613 | + * Copyright (C) 2003 Zack Rusin <zack@kde.org> |
614 | + * |
615 | + * Licensed under the Academic Free License version 2.1 |
616 | + * |
617 | + * This program is free software; you can redistribute it and/or modify |
618 | + * it under the terms of the GNU General Public License as published by |
619 | + * the Free Software Foundation; either version 2 of the License, or |
620 | + * (at your option) any later version. |
621 | + * |
622 | + * This program is distributed in the hope that it will be useful, |
623 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
624 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
625 | + * GNU General Public License for more details. |
626 | + * |
627 | + * You should have received a copy of the GNU General Public License |
628 | + * along with this program; if not, write to the Free Software |
629 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
630 | + * |
631 | + */ |
632 | +#ifndef DBUS_QT_INTEGRATOR_H |
633 | +#define DBUS_QT_INTEGRATOR_H |
634 | + |
635 | +/* We acknowledge the the dbus API is unstable */ |
636 | +#define DBUS_API_SUBJECT_TO_CHANGE |
637 | + |
638 | +#include <qobject.h> |
639 | + |
640 | +#include <qintdict.h> |
641 | +#include <qptrdict.h> |
642 | + |
643 | +#include "dbus/dbus.h" |
644 | + |
645 | +class QTimer; |
646 | + |
647 | +namespace DBusQt |
648 | +{ |
649 | + class Connection; |
650 | + |
651 | + namespace Internal |
652 | + { |
653 | + struct Watch; |
654 | + |
655 | + class Timeout : public QObject |
656 | + { |
657 | + Q_OBJECT |
658 | + public: |
659 | + Timeout( QObject *parent, DBusTimeout *t ); |
660 | + public: |
661 | + void start(); |
662 | + signals: |
663 | + void timeout( DBusTimeout* ); |
664 | + protected slots: |
665 | + void slotTimeout(); |
666 | + private: |
667 | + QTimer *m_timer; |
668 | + DBusTimeout *m_timeout; |
669 | + }; |
670 | + |
671 | + class Integrator : public QObject |
672 | + { |
673 | + Q_OBJECT |
674 | + public: |
675 | + Integrator( DBusConnection *connection, QObject *parent ); |
676 | + Integrator( DBusServer *server, QObject *parent ); |
677 | + |
678 | + signals: |
679 | + void readReady(); |
680 | + void newConnection( Connection* ); |
681 | + |
682 | + protected slots: |
683 | + void slotRead( int ); |
684 | + void slotWrite( int ); |
685 | + void slotTimeout( DBusTimeout *timeout ); |
686 | + |
687 | + public: |
688 | + void addWatch( DBusWatch* ); |
689 | + void removeWatch( DBusWatch* ); |
690 | + |
691 | + void addTimeout( DBusTimeout* ); |
692 | + void removeTimeout( DBusTimeout* ); |
693 | + |
694 | + void handleConnection( DBusConnection* ); |
695 | + private: |
696 | + QIntDict<Watch> m_watches; |
697 | + QPtrDict<Timeout> m_timeouts; |
698 | + DBusConnection *m_connection; |
699 | + DBusServer *m_server; |
700 | + }; |
701 | + } |
702 | +} |
703 | + |
704 | +#endif |
705 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/Makefile.am kdebase-3.5.5.patched/kioslave/media/mediamanager/Makefile.am |
706 | --- kdebase-3.5.5/kioslave/media/mediamanager/Makefile.am 2005-09-10 10:25:36.000000000 +0200 |
707 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/Makefile.am 2006-10-19 11:37:12.000000000 +0200 |
708 | @@ -1,17 +1,22 @@ |
709 | kde_module_LTLIBRARIES = kded_mediamanager.la |
710 | |
711 | if include_media_halbackend |
712 | -HALBACKEND_INCS = $(HAL_INCS) $(DBUS_INCS) $(DBUSQT_INCS) |
713 | +HALBACKEND_INCS = $(HAL_INCS) $(DBUS_INCS) |
714 | endif |
715 | |
716 | METASOURCES = AUTO |
717 | INCLUDES = -I$(srcdir)/../libmediacommon -I../libmediacommon $(HALBACKEND_INCS) $(all_includes) |
718 | |
719 | +DBUSQT3BINDING_LIB = libdbusqt3.la |
720 | +libdbusqt3_la_SOURCES = connection.cpp integrator.cpp message.cpp |
721 | +libdbusqt3_la_LDFLAGS = -avoid-version $(all_libraries) -no-undefined |
722 | +libdbusqt3_la_LIBADD = $(HAL_LIBS) $(DBUS_LIBS) |
723 | + |
724 | if include_media_halbackend |
725 | HALBACKEND_LIB = libhalbackend.la |
726 | libhalbackend_la_SOURCES = halbackend.cpp |
727 | libhalbackend_la_LDFLAGS = -avoid-version $(all_libraries) -no-undefined |
728 | -libhalbackend_la_LIBADD = $(HAL_LIBS) $(DBUS_LIBS) $(DBUSQT_LIBS) |
729 | +libhalbackend_la_LIBADD = $(HAL_LIBS) $(DBUS_LIBS) $(DBUSQT3BINDING_LIB) |
730 | endif |
731 | |
732 | if include_media_linuxcdpolling |
733 | @@ -20,7 +25,7 @@ |
734 | liblinuxcdpolling_la_LDFLAGS = -avoid-version $(all_libraries) -no-undefined |
735 | endif |
736 | |
737 | -noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB) $(HALBACKEND_LIB) |
738 | +noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB) $(HALBACKEND_LIB) $(DBUSQT3BINDING_LIB) |
739 | |
740 | kded_mediamanager_la_SOURCES = mediamanager.cpp mediamanager.skel medialist.cpp backendbase.cpp fstabbackend.cpp removablebackend.cpp mediadirnotify.cpp mediadirnotify.skel |
741 | kded_mediamanager_la_LDFLAGS = $(all_libraries) -module -avoid-version |
742 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/message.cpp kdebase-3.5.5.patched/kioslave/media/mediamanager/message.cpp |
743 | --- kdebase-3.5.5/kioslave/media/mediamanager/message.cpp 1970-01-01 01:00:00.000000000 +0100 |
744 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/message.cpp 2006-10-19 11:37:12.000000000 +0200 |
745 | @@ -0,0 +1,551 @@ |
746 | +/* -*- mode: C++; c-file-style: "gnu" -*- */ |
747 | +/* message.cpp: Qt wrapper for DBusMessage |
748 | + * |
749 | + * Copyright (C) 2003 Zack Rusin <zack@kde.org> |
750 | + * |
751 | + * Licensed under the Academic Free License version 2.0 |
752 | + * |
753 | + * This program is free software; you can redistribute it and/or modify |
754 | + * it under the terms of the GNU General Public License as published by |
755 | + * the Free Software Foundation; either version 2 of the License, or |
756 | + * (at your option) any later version. |
757 | + * |
758 | + * This program is distributed in the hope that it will be useful, |
759 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
760 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
761 | + * GNU General Public License for more details. |
762 | + * |
763 | + * You should have received a copy of the GNU General Public License |
764 | + * along with this program; if not, write to the Free Software |
765 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
766 | + * |
767 | + */ |
768 | +#include "message.h" |
769 | + |
770 | +#include <qmap.h> |
771 | + |
772 | +#include <cstdlib> |
773 | + |
774 | +namespace DBusQt { |
775 | + |
776 | +struct Message::iterator::IteratorData { |
777 | + DBusMessageIter *iter; |
778 | + QVariant var; |
779 | + bool end; |
780 | + DBusMessage *mesg; |
781 | +}; |
782 | + |
783 | +/** |
784 | + * Iterator. |
785 | + */ |
786 | +Message::iterator::iterator() |
787 | +{ |
788 | + d = new IteratorData; |
789 | + d->iter = 0; d->end = true; |
790 | +} |
791 | + |
792 | +/** |
793 | + * Constructs iterator for the message. |
794 | + * @param msg message whose fields we want to iterate |
795 | + */ |
796 | +Message::iterator::iterator( DBusMessage* msg ) |
797 | +{ |
798 | + d = new IteratorData; |
799 | + d->mesg = msg; |
800 | + d->iter = static_cast<DBusMessageIter *>( malloc( sizeof(DBusMessageIter) ) ); |
801 | + dbus_message_iter_init( d->mesg, d->iter ); |
802 | + if ( !d->iter ) { |
803 | + qDebug("No iterator??"); |
804 | + } |
805 | + fillVar(); |
806 | + d->end = false; |
807 | +} |
808 | + |
809 | +/** |
810 | + * Copy constructor for the iterator. |
811 | + * @param itr iterator |
812 | + */ |
813 | +Message::iterator::iterator( const iterator& itr ) |
814 | +{ |
815 | + d = new IteratorData; |
816 | + d->iter = itr.d->iter; |
817 | + d->var = itr.d->var; |
818 | + d->end = itr.d->end; |
819 | +} |
820 | + |
821 | +/** |
822 | + * Destructor. |
823 | + */ |
824 | +Message::iterator::~iterator() |
825 | +{ |
826 | + free( d->iter ); |
827 | + delete d; d=0; |
828 | +} |
829 | + |
830 | +/** |
831 | + * Creates an iterator equal to the @p itr iterator |
832 | + * @param itr other iterator |
833 | + * @return |
834 | + */ |
835 | +Message::iterator& |
836 | +Message::iterator::operator=( const iterator& itr ) |
837 | +{ |
838 | + IteratorData *tmp = new IteratorData; |
839 | + tmp->iter = itr.d->iter; |
840 | + tmp->var = itr.d->var; |
841 | + tmp->end = itr.d->end; |
842 | + delete d; d=tmp; |
843 | + return *this; |
844 | +} |
845 | + |
846 | +/** |
847 | + * Returns the constant QVariant held by the iterator. |
848 | + * @return the constant reference to QVariant held by this iterator |
849 | + */ |
850 | +const QVariant& |
851 | +Message::iterator::operator*() const |
852 | +{ |
853 | + return d->var; |
854 | +} |
855 | + |
856 | +/** |
857 | + * Returns the QVariant held by the iterator. |
858 | + * @return reference to QVariant held by this iterator |
859 | + */ |
860 | +QVariant& |
861 | +Message::iterator::operator*() |
862 | +{ |
863 | + return d->var; |
864 | +} |
865 | + |
866 | +/** |
867 | + * Moves to the next field and return a reference to itself after |
868 | + * incrementing. |
869 | + * @return reference to self after incrementing |
870 | + */ |
871 | +Message::iterator& |
872 | +Message::iterator::operator++() |
873 | +{ |
874 | + if ( d->end ) |
875 | + return *this; |
876 | + |
877 | + if ( dbus_message_iter_next( d->iter ) ) { |
878 | + fillVar(); |
879 | + } else { |
880 | + d->end = true; |
881 | + d->var = QVariant(); |
882 | + } |
883 | + return *this; |
884 | +} |
885 | + |
886 | +/** |
887 | + * Moves to the next field and returns self before incrementing. |
888 | + * @return self before incrementing |
889 | + */ |
890 | +Message::iterator |
891 | +Message::iterator::operator++(int) |
892 | +{ |
893 | + iterator itr( *this ); |
894 | + operator++(); |
895 | + return itr; |
896 | +} |
897 | + |
898 | +/** |
899 | + * Compares this iterator to @p it iterator. |
900 | + * @param it the iterator to which we're comparing this one to |
901 | + * @return true if they're equal, false otherwise |
902 | + */ |
903 | +bool |
904 | +Message::iterator::operator==( const iterator& it ) |
905 | +{ |
906 | + if ( d->end == it.d->end ) { |
907 | + if ( d->end == true ) { |
908 | + return true; |
909 | + } else { |
910 | + return d->var == it.d->var; |
911 | + } |
912 | + } else |
913 | + return false; |
914 | +} |
915 | + |
916 | +/** |
917 | + * Compares two iterators. |
918 | + * @param it The other iterator. |
919 | + * @return true if two iterators are not equal, false |
920 | + * otherwise |
921 | + */ |
922 | +bool |
923 | +Message::iterator::operator!=( const iterator& it ) |
924 | +{ |
925 | + return !operator==( it ); |
926 | +} |
927 | + |
928 | +QVariant Message::iterator::marshallBaseType( DBusMessageIter* i ) |
929 | +{ |
930 | + QVariant ret; |
931 | + switch (dbus_message_iter_get_arg_type(i)) { |
932 | + case DBUS_TYPE_INT32: |
933 | + { |
934 | + dbus_int32_t v; |
935 | + dbus_message_iter_get_basic (i, &v); |
936 | + ret = QVariant( v ); |
937 | + } |
938 | + break; |
939 | + case DBUS_TYPE_UINT32: |
940 | + { |
941 | + dbus_uint32_t v; |
942 | + dbus_message_iter_get_basic (i, &v); |
943 | + ret = QVariant( v ); |
944 | + } |
945 | + break; |
946 | + case DBUS_TYPE_DOUBLE: |
947 | + { |
948 | + double v; |
949 | + dbus_message_iter_get_basic (i, &v); |
950 | + ret = QVariant( v ); |
951 | + } |
952 | + break; |
953 | + case DBUS_TYPE_STRING: |
954 | + { |
955 | + const char *v; |
956 | + dbus_message_iter_get_basic (i, &v); |
957 | + ret = QVariant( v ); |
958 | + } |
959 | + break; |
960 | + default: |
961 | + ret = QVariant(); |
962 | + break; |
963 | + } |
964 | + return ret; |
965 | +} |
966 | + |
967 | +/** |
968 | + * Fills QVariant based on what current DBusMessageIter helds. |
969 | + */ |
970 | +void |
971 | +Message::iterator::fillVar() |
972 | +{ |
973 | + switch ( dbus_message_iter_get_arg_type( d->iter ) ) { |
974 | + case DBUS_TYPE_INT32: |
975 | + case DBUS_TYPE_UINT32: |
976 | + case DBUS_TYPE_DOUBLE: |
977 | + case DBUS_TYPE_STRING: |
978 | + d->var = marshallBaseType( d->iter ); |
979 | + break; |
980 | + case DBUS_TYPE_ARRAY: { |
981 | + switch ( dbus_message_iter_get_element_type( d->iter ) ) { |
982 | + case DBUS_TYPE_STRING: { |
983 | + QStringList tempList; |
984 | + DBusMessageIter sub; |
985 | + dbus_message_iter_recurse (d->iter, &sub); |
986 | + while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) |
987 | + { |
988 | + const char *v; |
989 | + dbus_message_iter_get_basic (&sub, &v); |
990 | + tempList.append( QString( v ) ); |
991 | + dbus_message_iter_next (&sub); |
992 | + } |
993 | + d->var = QVariant( tempList ); |
994 | + break; |
995 | + } |
996 | + default: |
997 | + qDebug( "Array of type not implemented" ); |
998 | + d->var = QVariant(); |
999 | + break; |
1000 | + } |
1001 | + break; |
1002 | + } |
1003 | +#if 0 |
1004 | + /* DICT is gone for now, but expected to be reintroduced, or else |
1005 | + * reintroduced as a flag on the introspection data that can |
1006 | + * apply to array of struct of two fields |
1007 | + */ |
1008 | + case DBUS_TYPE_DICT: { |
1009 | + qDebug( "Got a hash!" ); |
1010 | + QMap<QString, QVariant> tempMap; |
1011 | + DBusMessageIter dictIter; |
1012 | + dbus_message_iter_init_dict_iterator( d->iter, &dictIter ); |
1013 | + do { |
1014 | + char *key = dbus_message_iter_get_dict_key( &dictIter ); |
1015 | + tempMap[key] = marshallBaseType( &dictIter ); |
1016 | + dbus_free( key ); |
1017 | + dbus_message_iter_next( &dictIter ); |
1018 | + } while( dbus_message_iter_has_next( &dictIter ) ); |
1019 | + d->var = QVariant( tempMap ); |
1020 | + break; |
1021 | + qDebug( "Hash/Dict type not implemented" ); |
1022 | + d->var = QVariant(); |
1023 | + break; |
1024 | + } |
1025 | +#endif |
1026 | + default: |
1027 | + qDebug( "not implemented" ); |
1028 | + d->var = QVariant(); |
1029 | + break; |
1030 | + } |
1031 | +} |
1032 | + |
1033 | +/** |
1034 | + * Returns a QVariant help by this iterator. |
1035 | + * @return QVariant held by this iterator |
1036 | + */ |
1037 | +QVariant |
1038 | +Message::iterator::var() const |
1039 | +{ |
1040 | + return d->var; |
1041 | +} |
1042 | + |
1043 | +struct Message::Private { |
1044 | + DBusMessage *msg; |
1045 | +}; |
1046 | + |
1047 | +Message::Message( DBusMessage *m ) |
1048 | +{ |
1049 | + d = new Private; |
1050 | + d->msg = m; |
1051 | +} |
1052 | + |
1053 | +/** |
1054 | + * |
1055 | + */ |
1056 | +Message::Message( int messageType ) |
1057 | +{ |
1058 | + d = new Private; |
1059 | + d->msg = dbus_message_new( messageType ); |
1060 | +} |
1061 | + |
1062 | +/** |
1063 | + * Constructs a new Message with the given service and name. |
1064 | + * @param service service service that the message should be sent to |
1065 | + * @param name name of the message |
1066 | + */ |
1067 | +Message::Message( const QString& service, const QString& path, |
1068 | + const QString& interface, const QString& method ) |
1069 | +{ |
1070 | + d = new Private; |
1071 | + d->msg = dbus_message_new_method_call( service.latin1(), path.latin1(), |
1072 | + interface.latin1(), method.latin1() ); |
1073 | +} |
1074 | + |
1075 | +/** |
1076 | + * Constructs a message that is a reply to some other |
1077 | + * message. |
1078 | + * @param name the name of the message |
1079 | + * @param replayingTo original_message the message which the created |
1080 | + * message is a reply to. |
1081 | + */ |
1082 | +Message::Message( const Message& replayingTo ) |
1083 | +{ |
1084 | + d = new Private; |
1085 | + d->msg = dbus_message_new_method_return( replayingTo.d->msg ); |
1086 | +} |
1087 | + |
1088 | +Message:: Message( const QString& path, const QString& interface, |
1089 | + const QString& name ) |
1090 | +{ |
1091 | + d = new Private; |
1092 | + d->msg = dbus_message_new_signal( path.ascii(), interface.ascii(), |
1093 | + name.ascii() ); |
1094 | +} |
1095 | + |
1096 | +Message::Message( const Message& replayingTo, const QString& errorName, |
1097 | + const QString& errorMessage ) |
1098 | +{ |
1099 | + d = new Private; |
1100 | + d->msg = dbus_message_new_error( replayingTo.d->msg, errorName.utf8(), |
1101 | + errorMessage.utf8() ); |
1102 | +} |
1103 | + |
1104 | +Message Message::operator=( const Message& other ) |
1105 | +{ |
1106 | + //FIXME: ref the other.d->msg instead of copying it? |
1107 | +} |
1108 | +/** |
1109 | + * Destructs message. |
1110 | + */ |
1111 | +Message::~Message() |
1112 | +{ |
1113 | + if ( d->msg ) { |
1114 | + dbus_message_unref( d->msg ); |
1115 | + } |
1116 | + delete d; d=0; |
1117 | +} |
1118 | + |
1119 | +int Message::type() const |
1120 | +{ |
1121 | + return dbus_message_get_type( d->msg ); |
1122 | +} |
1123 | + |
1124 | +void Message::setPath( const QString& path ) |
1125 | +{ |
1126 | + dbus_message_set_path( d->msg, path.ascii() ); |
1127 | +} |
1128 | + |
1129 | +QString Message::path() const |
1130 | +{ |
1131 | + return dbus_message_get_path( d->msg ); |
1132 | +} |
1133 | + |
1134 | +void Message::setInterface( const QString& iface ) |
1135 | +{ |
1136 | + dbus_message_set_interface( d->msg, iface.ascii() ); |
1137 | +} |
1138 | + |
1139 | +QString Message::interface() const |
1140 | +{ |
1141 | + return dbus_message_get_interface( d->msg ); |
1142 | +} |
1143 | + |
1144 | +void Message::setMember( const QString& member ) |
1145 | +{ |
1146 | + dbus_message_set_member( d->msg, member.ascii() ); |
1147 | +} |
1148 | + |
1149 | +QString Message::member() const |
1150 | +{ |
1151 | + return dbus_message_get_member( d->msg ); |
1152 | +} |
1153 | + |
1154 | +QString Message::errorName() const |
1155 | +{ |
1156 | + return dbus_message_get_error_name( d->msg ); |
1157 | +} |
1158 | + |
1159 | +QString Message::destination() const |
1160 | +{ |
1161 | + return dbus_message_get_destination( d->msg ); |
1162 | +} |
1163 | + |
1164 | +/** |
1165 | + * Sets the message sender. |
1166 | + * @param sender the sender |
1167 | + * @return false if unsuccessful |
1168 | + */ |
1169 | +bool |
1170 | +Message::setSender( const QString& sender ) |
1171 | +{ |
1172 | + return dbus_message_set_sender( d->msg, sender.latin1() ); |
1173 | +} |
1174 | + |
1175 | +/** |
1176 | + * Returns sender of this message. |
1177 | + * @return sender |
1178 | + */ |
1179 | +QString |
1180 | +Message::sender() const |
1181 | +{ |
1182 | + return dbus_message_get_sender( d->msg ); |
1183 | +} |
1184 | + |
1185 | +QString Message::signature() const |
1186 | +{ |
1187 | + return dbus_message_get_signature( d->msg ); |
1188 | +} |
1189 | + |
1190 | + |
1191 | +/** |
1192 | + * Returns the starting iterator for the fields of this |
1193 | + * message. |
1194 | + * @return starting iterator |
1195 | + */ |
1196 | +Message::iterator |
1197 | +Message::begin() const |
1198 | +{ |
1199 | + return iterator( d->msg ); |
1200 | +} |
1201 | + |
1202 | +/** |
1203 | + * Returns the ending iterator for the fields of this |
1204 | + * message. |
1205 | + * @return ending iterator |
1206 | + */ |
1207 | +Message::iterator |
1208 | +Message::end() const |
1209 | +{ |
1210 | + return iterator(); |
1211 | +} |
1212 | + |
1213 | +/** |
1214 | + * Returns the field at position @p i |
1215 | + * @param i position of the wanted field |
1216 | + * @return QVariant at position @p i or an empty QVariant |
1217 | + */ |
1218 | +QVariant |
1219 | +Message::at( int i ) |
1220 | +{ |
1221 | + iterator itr( d->msg ); |
1222 | + |
1223 | + while ( i-- ) { |
1224 | + if ( itr == end() ) |
1225 | + return QVariant();//nothing there |
1226 | + ++itr; |
1227 | + } |
1228 | + return *itr; |
1229 | +} |
1230 | + |
1231 | +/** |
1232 | + * The underlying DBusMessage of this class. |
1233 | + * @return DBusMessage pointer. |
1234 | + */ |
1235 | +DBusMessage* |
1236 | +Message::message() const |
1237 | +{ |
1238 | + return d->msg; |
1239 | +} |
1240 | + |
1241 | +Message& Message::operator<<( bool b ) |
1242 | +{ |
1243 | + const dbus_bool_t right_size_bool = b; |
1244 | + dbus_message_append_args( d->msg, DBUS_TYPE_BOOLEAN, &right_size_bool, |
1245 | + DBUS_TYPE_INVALID ); |
1246 | +} |
1247 | + |
1248 | +Message& Message::operator<<( Q_INT8 byte ) |
1249 | +{ |
1250 | + dbus_message_append_args( d->msg, DBUS_TYPE_BYTE, &byte, |
1251 | + DBUS_TYPE_INVALID ); |
1252 | +} |
1253 | + |
1254 | +Message& Message::operator<<( Q_INT32 num ) |
1255 | +{ |
1256 | + dbus_message_append_args( d->msg, DBUS_TYPE_INT32, &num, |
1257 | + DBUS_TYPE_INVALID ); |
1258 | +} |
1259 | + |
1260 | +Message& Message::operator<<( Q_UINT32 num ) |
1261 | +{ |
1262 | + dbus_message_append_args( d->msg, DBUS_TYPE_UINT32, &num, |
1263 | + DBUS_TYPE_INVALID ); |
1264 | +} |
1265 | + |
1266 | +Message& Message::operator<<( Q_INT64 num ) |
1267 | +{ |
1268 | + dbus_message_append_args( d->msg, DBUS_TYPE_INT64, &num, |
1269 | + DBUS_TYPE_INVALID ); |
1270 | +} |
1271 | + |
1272 | +Message& Message::operator<<( Q_UINT64 num ) |
1273 | +{ |
1274 | + dbus_message_append_args( d->msg, DBUS_TYPE_UINT64, &num, |
1275 | + DBUS_TYPE_INVALID ); |
1276 | +} |
1277 | + |
1278 | +Message& Message::operator<<( double num ) |
1279 | +{ |
1280 | + dbus_message_append_args( d->msg, DBUS_TYPE_DOUBLE, &num, |
1281 | + DBUS_TYPE_INVALID ); |
1282 | +} |
1283 | + |
1284 | +Message& Message::operator<<( const QString& str ) |
1285 | +{ |
1286 | + const char *u = str.utf8(); |
1287 | + dbus_message_append_args( d->msg, DBUS_TYPE_STRING, &u, |
1288 | + DBUS_TYPE_INVALID ); |
1289 | +} |
1290 | + |
1291 | +Message& Message::operator<<( const QVariant& custom ) |
1292 | +{ |
1293 | + //FIXME: imeplement |
1294 | +} |
1295 | + |
1296 | +} |
1297 | diff -Naur kdebase-3.5.5/kioslave/media/mediamanager/message.h kdebase-3.5.5.patched/kioslave/media/mediamanager/message.h |
1298 | --- kdebase-3.5.5/kioslave/media/mediamanager/message.h 1970-01-01 01:00:00.000000000 +0100 |
1299 | +++ kdebase-3.5.5.patched/kioslave/media/mediamanager/message.h 2006-10-19 11:37:12.000000000 +0200 |
1300 | @@ -0,0 +1,132 @@ |
1301 | +/* -*- mode: C++; c-file-style: "gnu" -*- */ |
1302 | +/* message.h: Qt wrapper for DBusMessage |
1303 | + * |
1304 | + * Copyright (C) 2003 Zack Rusin <zack@kde.org> |
1305 | + * |
1306 | + * Licensed under the Academic Free License version 2.1 |
1307 | + * |
1308 | + * This program is free software; you can redistribute it and/or modify |
1309 | + * it under the terms of the GNU General Public License as published by |
1310 | + * the Free Software Foundation; either version 2 of the License, or |
1311 | + * (at your option) any later version. |
1312 | + * |
1313 | + * This program is distributed in the hope that it will be useful, |
1314 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1315 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1316 | + * GNU General Public License for more details. |
1317 | + * |
1318 | + * You should have received a copy of the GNU General Public License |
1319 | + * along with this program; if not, write to the Free Software |
1320 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1321 | + * |
1322 | + */ |
1323 | +#ifndef DBUS_QT_MESSAGE_H |
1324 | +#define DBUS_QT_MESSAGE_H |
1325 | + |
1326 | +/* We acknowledge the the dbus API is unstable */ |
1327 | +#define DBUS_API_SUBJECT_TO_CHANGE |
1328 | + |
1329 | +#include <qvariant.h> |
1330 | +#include <qstring.h> |
1331 | +#include <qstringlist.h> |
1332 | + |
1333 | +#include "dbus/dbus.h" |
1334 | + |
1335 | +namespace DBusQt { |
1336 | + |
1337 | + class Message |
1338 | + { |
1339 | + public: |
1340 | + class iterator { |
1341 | + public: |
1342 | + iterator(); |
1343 | + iterator( const iterator& ); |
1344 | + iterator( DBusMessage* msg ); |
1345 | + ~iterator(); |
1346 | + |
1347 | + iterator& operator=( const iterator& ); |
1348 | + const QVariant& operator*() const; |
1349 | + QVariant& operator*(); |
1350 | + iterator& operator++(); |
1351 | + iterator operator++(int); |
1352 | + bool operator==( const iterator& it ); |
1353 | + bool operator!=( const iterator& it ); |
1354 | + |
1355 | + QVariant var() const; |
1356 | + protected: |
1357 | + QVariant marshallBaseType( DBusMessageIter* i ); |
1358 | + void fillVar(); |
1359 | + struct IteratorData; |
1360 | + IteratorData *d; |
1361 | + }; |
1362 | + |
1363 | + Message( int messageType ); |
1364 | + Message( DBusMessage * );//hide this one from the public implementation |
1365 | + Message( const QString& service, const QString& path, |
1366 | + const QString& interface, const QString& method ); |
1367 | + Message( const Message& replayingTo ); |
1368 | + Message( const QString& path, const QString& interface, |
1369 | + const QString& name ); |
1370 | + Message( const Message& replayingTo, const QString& errorName, |
1371 | + const QString& errorMessage ); |
1372 | + |
1373 | + Message operator=( const Message& other ); |
1374 | + |
1375 | + virtual ~Message(); |
1376 | + |
1377 | + int type() const; |
1378 | + |
1379 | + void setPath( const QString& ); |
1380 | + QString path() const; |
1381 | + |
1382 | + void setInterface( const QString& ); |
1383 | + QString interface() const; |
1384 | + |
1385 | + void setMember( const QString& ); |
1386 | + QString member() const; |
1387 | + |
1388 | + QString errorName() const; |
1389 | + |
1390 | + QString destination() const; |
1391 | + |
1392 | + bool setSender( const QString& sender ); |
1393 | + QString sender() const; |
1394 | + |
1395 | + QString signature() const; |
1396 | + |
1397 | + iterator begin() const; |
1398 | + iterator end() const; |
1399 | + |
1400 | + QVariant at( int i ); |
1401 | + |
1402 | + |
1403 | + public: |
1404 | + Message& operator<<( bool ); |
1405 | + Message& operator<<( Q_INT8 ); |
1406 | + Message& operator<<( Q_INT32 ); |
1407 | + Message& operator<<( Q_UINT32 ); |
1408 | + Message& operator<<( Q_INT64 ); |
1409 | + Message& operator<<( Q_UINT64 ); |
1410 | + Message& operator<<( double ); |
1411 | + Message& operator<<( const QString& ); |
1412 | + Message& operator<<( const QVariant& ); |
1413 | + //Message& operator<<(); |
1414 | + //Message& operator<<(); |
1415 | + //Message& operator<<(); |
1416 | + //Message& operator<<(); |
1417 | + //Message& operator<<(); |
1418 | + //Message& operator<<(); |
1419 | + //Message& operator<<(); |
1420 | + |
1421 | + protected: |
1422 | + friend class Connection; |
1423 | + DBusMessage* message() const; |
1424 | + |
1425 | + private: |
1426 | + struct Private; |
1427 | + Private *d; |
1428 | + }; |
1429 | + |
1430 | +} |
1431 | + |
1432 | +#endif |