1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
|
/*
*
* $Id: sourceheader,v 1.3 2005/01/19 13:03:46 trueg Exp $
* Copyright (C) 2005-2007 Sebastian Trueg <trueg@k3b.org>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/
#include "k3bhalconnection.h"
#include "k3bdevice.h"
#include <k3bdebug.h>
#include <klocale.h>
#include <qtimer.h>
// We acknowledge the the dbus API is unstable
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/connection.h>
#include <dbus/dbus.h>
#include <hal/libhal.h>
static char** qstringListToArray( const QStringList& s )
{
char** a = new char*[s.count()];
for( unsigned int i = 0; i < s.count(); ++i ) {
a[i] = new char[s[i].length()+1];
::strncpy( a[i], s[i].local8Bit().data(), s[i].length() );
a[s[i].length()] = '\0';
}
return a;
}
static void freeArray( char** a, unsigned int length )
{
for( unsigned int i = 0; i < length; ++i )
delete [] a[i];
delete a;
}
// CALLBACKS
void halDeviceAdded( LibHalContext* ctx, const char* udi )
{
Q_UNUSED( ctx );
k3bDebug() << "adding udi " << udi << endl;
K3bDevice::HalConnection::instance()->addDevice( udi );
}
void halDeviceRemoved( LibHalContext* ctx, const char* udi )
{
Q_UNUSED( ctx );
k3bDebug() << "removing udi " << udi << endl;
K3bDevice::HalConnection::instance()->removeDevice( udi );
}
K3bDevice::HalConnection* K3bDevice::HalConnection::s_instance = 0;
class K3bDevice::HalConnection::Private
{
public:
Private()
: halContext(0),
dBusQtConnection(0),
bOpen(false) {
}
LibHalContext* halContext;
DBusConnection* connection;
DBusQt::Connection* dBusQtConnection;
bool bOpen;
QMap<QCString, QString> udiDeviceMap;
QMap<QString, QCString> deviceUdiMap;
QMap<QCString, QCString> deviceMediumUdiMap;
};
K3bDevice::HalConnection* K3bDevice::HalConnection::instance()
{
if( s_instance == 0 )
s_instance = new HalConnection( 0 );
if( !s_instance->isConnected() && !s_instance->open() )
k3bDebug() << "(K3bDevice::HalConnection) failed to open connection to HAL." << endl;
return s_instance;
}
K3bDevice::HalConnection::HalConnection( QObject* parent, const char* name )
: QObject( parent, name )
{
d = new Private();
}
K3bDevice::HalConnection::~HalConnection()
{
s_instance = 0;
close();
delete d;
}
bool K3bDevice::HalConnection::isConnected() const
{
return d->bOpen;
}
bool K3bDevice::HalConnection::open()
{
close();
k3bDebug() << "(K3bDevice::HalConnection) initializing HAL >= 0.5" << endl;
d->halContext = libhal_ctx_new();
if( !d->halContext ) {
k3bDebug() << "(K3bDevice::HalConnection) unable to create HAL context." << endl;
return false;
}
DBusError error;
dbus_error_init( &error );
d->connection = dbus_bus_get( DBUS_BUS_SYSTEM, &error );
if( dbus_error_is_set(&error) ) {
k3bDebug() << "(K3bDevice::HalConnection) unable to connect to DBUS: " << error.message << endl;
return false;
}
setupDBusQtConnection( d->connection );
libhal_ctx_set_dbus_connection( d->halContext, d->connection );
libhal_ctx_set_device_added( d->halContext, halDeviceAdded );
libhal_ctx_set_device_removed( d->halContext, halDeviceRemoved );
libhal_ctx_set_device_new_capability( d->halContext, 0 );
libhal_ctx_set_device_lost_capability( d->halContext, 0 );
libhal_ctx_set_device_property_modified( d->halContext, 0 );
libhal_ctx_set_device_condition( d->halContext, 0 );
if( !libhal_ctx_init( d->halContext, 0 ) ) {
k3bDebug() << "(K3bDevice::HalConnection) Failed to init HAL context!" << endl;
return false;
}
d->bOpen = true;
//
// report all devices
//
int numDevices;
char** halDeviceList = libhal_get_all_devices( d->halContext, &numDevices, 0 );
for( int i = 0; i < numDevices; ++i )
addDevice( halDeviceList[i] );
return true;
}
void K3bDevice::HalConnection::close()
{
if( d->halContext ) {
// clear the context
if( isConnected() )
libhal_ctx_shutdown( d->halContext, 0 );
libhal_ctx_free( d->halContext );
// delete the connection (may be 0 if open() failed)
delete d->dBusQtConnection;
d->halContext = 0;
d->dBusQtConnection = 0;
d->bOpen = false;
}
}
QStringList K3bDevice::HalConnection::devices() const
{
return QStringList( d->udiDeviceMap.values() );
}
void K3bDevice::HalConnection::addDevice( const char* udi )
{
// ignore devices that have no property "info.capabilities" to suppress error messages
if( !libhal_device_property_exists( d->halContext, udi, "info.capabilities", 0 ) )
return;
if( libhal_device_query_capability( d->halContext, udi, "storage.cdrom", 0 ) ) {
char* dev = libhal_device_get_property_string( d->halContext, udi, "block.device", 0 );
if( dev ) {
QString s( dev );
libhal_free_string( dev );
if( !s.isEmpty() ) {
k3bDebug() << "Mapping udi " << udi << " to device " << s << endl;
d->udiDeviceMap[udi] = s;
d->deviceUdiMap[s] = udi;
emit deviceAdded( s );
}
}
}
else {
if( libhal_device_property_exists( d->halContext, udi, "block.storage_device", 0 ) ) {
char* deviceUdi = libhal_device_get_property_string( d->halContext, udi, "block.storage_device", 0 );
if( deviceUdi ) {
QCString du( deviceUdi );
libhal_free_string( deviceUdi );
if( d->udiDeviceMap.contains( du ) ) {
//
// A new medium has been inserted. Save this medium's udi so we can reuse it later
// on for the mount/unmount/eject methods
//
d->deviceMediumUdiMap[du] = QCString( udi );
emit mediumChanged( d->udiDeviceMap[du] );
}
}
}
}
}
void K3bDevice::HalConnection::removeDevice( const char* udi )
{
QMapIterator<QCString, QString> it = d->udiDeviceMap.find( udi );
if( it != d->udiDeviceMap.end() ) {
k3bDebug() << "Unmapping udi " << udi << " from device " << it.data() << endl;
emit deviceRemoved( it.data() );
d->udiDeviceMap.erase( it );
d->deviceUdiMap.erase( it.data() );
}
else {
if( libhal_device_property_exists( d->halContext, udi, "block.storage_device", 0 ) ) {
char* deviceUdi = libhal_device_get_property_string( d->halContext, udi, "block.storage_device", 0 );
if( deviceUdi ) {
QCString du( deviceUdi );
libhal_free_string( deviceUdi );
if( d->udiDeviceMap.contains( du ) ) {
//
// A medium has been removed/ejected.
//
d->deviceMediumUdiMap[du] = 0;
emit mediumChanged( d->udiDeviceMap[du] );
}
}
}
}
}
int K3bDevice::HalConnection::lock( Device* dev )
{
//
// The code below is based on the code from kioslave/media/mediamanager/halbackend.cpp in the kdebase package
// Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
//
DBusMessage* dmesg = 0;
DBusMessage* reply = 0;
DBusError error;
if( !d->deviceUdiMap.contains( dev->blockDeviceName() ) ) {
return org_freedesktop_Hal_Device_Volume_NoSuchDevice;
}
QCString udi = d->deviceUdiMap[dev->blockDeviceName()];
if( !( dmesg = dbus_message_new_method_call( "org.freedesktop.Hal", udi.data(),
"org.freedesktop.Hal.Device",
"Lock" ) ) ) {
k3bDebug() << "(K3bDevice::HalConnection) lock failed for " << udi << ": could not create dbus message\n";
return org_freedesktop_Hal_CommunicationError;
}
const char* lockComment = "Locked by the K3b libraries";
if( !dbus_message_append_args( dmesg,
DBUS_TYPE_STRING, &lockComment,
DBUS_TYPE_INVALID ) ) {
k3bDebug() << "(K3bDevice::HalConnection) lock failed for " << udi << ": could not append args to dbus message\n";
dbus_message_unref( dmesg );
return org_freedesktop_Hal_CommunicationError;
}
int ret = org_freedesktop_Hal_Success;
dbus_error_init( &error );
reply = dbus_connection_send_with_reply_and_block( d->connection, dmesg, -1, &error );
if( dbus_error_is_set( &error ) ) {
kdError() << "(K3bDevice::HalConnection) lock failed for " << udi << ": " << error.name << " - " << error.message << endl;
if( !strcmp(error.name, "org.freedesktop.Hal.NoSuchDevice" ) )
ret = org_freedesktop_Hal_NoSuchDevice;
else if( !strcmp(error.name, "org.freedesktop.Hal.DeviceAlreadyLocked" ) )
ret = org_freedesktop_Hal_DeviceAlreadyLocked;
else if( !strcmp(error.name, "org.freedesktop.Hal.PermissionDenied" ) )
ret = org_freedesktop_Hal_PermissionDenied;
dbus_error_free( &error );
}
else
k3bDebug() << "(K3bDevice::HalConnection) lock queued for " << udi << endl;
dbus_message_unref( dmesg );
if( reply )
dbus_message_unref( reply );
return ret;
}
int K3bDevice::HalConnection::unlock( Device* dev )
{
//
// The code below is based on the code from kioslave/media/mediamanager/halbackend.cpp in the kdebase package
// Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
//
DBusMessage* dmesg = 0;
DBusMessage* reply = 0;
DBusError error;
if( !d->deviceUdiMap.contains( dev->blockDeviceName() ) ) {
return org_freedesktop_Hal_Device_Volume_NoSuchDevice;
}
QCString udi = d->deviceUdiMap[dev->blockDeviceName()];
if( !( dmesg = dbus_message_new_method_call( "org.freedesktop.Hal", udi.data(),
"org.freedesktop.Hal.Device",
"Unlock" ) ) ) {
k3bDebug() << "(K3bDevice::HalConnection) unlock failed for " << udi << ": could not create dbus message\n";
return org_freedesktop_Hal_CommunicationError;
}
if( !dbus_message_append_args( dmesg,
DBUS_TYPE_INVALID ) ) {
k3bDebug() << "(K3bDevice::HalConnection) unlock failed for " << udi << ": could not append args to dbus message\n";
dbus_message_unref( dmesg );
return org_freedesktop_Hal_CommunicationError;
}
int ret = org_freedesktop_Hal_Success;
dbus_error_init( &error );
reply = dbus_connection_send_with_reply_and_block( d->connection, dmesg, -1, &error );
if( dbus_error_is_set( &error ) ) {
kdError() << "(K3bDevice::HalConnection) unlock failed for " << udi << ": " << error.name << " - " << error.message << endl;
if( !strcmp(error.name, "org.freedesktop.Hal.NoSuchDevice" ) )
ret = org_freedesktop_Hal_NoSuchDevice;
else if( !strcmp(error.name, "org.freedesktop.Hal.DeviceAlreadyLocked" ) )
ret = org_freedesktop_Hal_DeviceAlreadyLocked;
else if( !strcmp(error.name, "org.freedesktop.Hal.PermissionDenied" ) )
ret = org_freedesktop_Hal_PermissionDenied;
dbus_error_free( &error );
}
else
k3bDebug() << "(K3bDevice::HalConnection) unlock queued for " << udi << endl;
dbus_message_unref( dmesg );
if( reply )
dbus_message_unref( reply );
return ret;
}
int K3bDevice::HalConnection::mount( K3bDevice::Device* dev,
const QString& mountPoint,
const QString& fstype,
const QStringList& options )
{
//
// The code below is based on the code from kioslave/media/mediamanager/halbackend.cpp in the kdebase package
// Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
//
DBusMessage* dmesg = 0;
DBusMessage* reply = 0;
DBusError error;
if( !d->deviceUdiMap.contains( dev->blockDeviceName() ) )
return org_freedesktop_Hal_NoSuchDevice;
if( !d->deviceMediumUdiMap.contains( d->deviceUdiMap[dev->blockDeviceName()] ) )
return org_freedesktop_Hal_Device_Volume_NoSuchDevice;
QCString mediumUdi = d->deviceMediumUdiMap[d->deviceUdiMap[dev->blockDeviceName()]];
if( !( dmesg = dbus_message_new_method_call( "org.freedesktop.Hal", mediumUdi.data(),
"org.freedesktop.Hal.Device.Volume",
"Mount" ) ) ) {
k3bDebug() << "(K3bDevice::HalConnection) mount failed for " << mediumUdi << ": could not create dbus message\n";
return org_freedesktop_Hal_CommunicationError;
}
char** poptions = qstringListToArray( options );
QByteArray strMountPoint = mountPoint.local8Bit();
QByteArray strFstype = fstype.local8Bit();
if( !dbus_message_append_args( dmesg,
DBUS_TYPE_STRING, strMountPoint.data(),
DBUS_TYPE_STRING, strFstype.data(),
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &poptions, options.count(),
DBUS_TYPE_INVALID ) ) {
k3bDebug() << "(K3bDevice::HalConnection) mount failed for " << mediumUdi << ": could not append args to dbus message\n";
dbus_message_unref( dmesg );
freeArray( poptions, options.count() );
return org_freedesktop_Hal_CommunicationError;
}
freeArray( poptions, options.count() );
int ret = org_freedesktop_Hal_Success;
dbus_error_init( &error );
reply = dbus_connection_send_with_reply_and_block( d->connection, dmesg, -1, &error );
if( dbus_error_is_set( &error ) ) {
kdError() << "(K3bDevice::HalConnection) mount failed for " << mediumUdi << ": " << error.name << " - " << error.message << endl;
if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.NoSuchDevice" ) )
ret = org_freedesktop_Hal_Device_Volume_NoSuchDevice;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied" ) )
ret = org_freedesktop_Hal_Device_Volume_PermissionDenied;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.UnknownFilesystemType" ) )
ret = org_freedesktop_Hal_Device_Volume_UnknownFilesystemType;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.MountPointNotAvailable" ) )
ret = org_freedesktop_Hal_Device_Volume_MountPointNotAvailable;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.AlreadyMounted" ) )
ret = org_freedesktop_Hal_Device_Volume_AlreadyMounted;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.InvalidMountpoint" ) )
ret = org_freedesktop_Hal_Device_Volume_InvalidMountpoint;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.InvalidMountOption" ) )
ret = org_freedesktop_Hal_Device_Volume_InvalidMountOption;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDeniedByPolicy" ) )
ret = org_freedesktop_Hal_Device_Volume_PermissionDeniedByPolicy;
dbus_error_free( &error );
}
else
k3bDebug() << "(K3bDevice::HalConnection) mount queued for " << mediumUdi << endl;
dbus_message_unref( dmesg );
if( reply )
dbus_message_unref( reply );
return ret;
}
int K3bDevice::HalConnection::unmount( K3bDevice::Device* dev,
const QStringList& options )
{
//
// The code below is based on the code from kioslave/media/mediamanager/halbackend.cpp in the kdebase package
// Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
//
DBusMessage* dmesg = 0;
DBusMessage* reply = 0;
DBusError error;
if( !d->deviceUdiMap.contains( dev->blockDeviceName() ) )
return org_freedesktop_Hal_NoSuchDevice;
if( !d->deviceMediumUdiMap.contains( d->deviceUdiMap[dev->blockDeviceName()] ) )
return org_freedesktop_Hal_Device_Volume_NoSuchDevice;
QCString mediumUdi = d->deviceMediumUdiMap[d->deviceUdiMap[dev->blockDeviceName()]];
if( !( dmesg = dbus_message_new_method_call( "org.freedesktop.Hal", mediumUdi.data(),
"org.freedesktop.Hal.Device.Volume",
"Unmount" ) ) ) {
k3bDebug() << "(K3bDevice::HalConnection) unmount failed for " << mediumUdi << ": could not create dbus message\n";
return org_freedesktop_Hal_CommunicationError;
}
char** poptions = qstringListToArray( options );
if( !dbus_message_append_args( dmesg,
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &poptions, options.count(),
DBUS_TYPE_INVALID ) ) {
k3bDebug() << "(K3bDevice::HalConnection) unmount failed for " << mediumUdi << ": could not append args to dbus message\n";
dbus_message_unref( dmesg );
freeArray( poptions, options.count() );
return org_freedesktop_Hal_CommunicationError;
}
freeArray( poptions, options.count() );
int ret = org_freedesktop_Hal_Success;
dbus_error_init( &error );
reply = dbus_connection_send_with_reply_and_block( d->connection, dmesg, -1, &error );
if( dbus_error_is_set( &error ) ) {
kdError() << "(K3bDevice::HalConnection) unmount failed for " << mediumUdi << ": " << error.name << " - " << error.message << endl;
if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.NoSuchDevice" ) )
ret = org_freedesktop_Hal_Device_Volume_NoSuchDevice;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied" ) )
ret = org_freedesktop_Hal_Device_Volume_PermissionDenied;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.MountPointNotAvailable" ) )
ret = org_freedesktop_Hal_Device_Volume_MountPointNotAvailable;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.InvalidUnmountOption" ) )
ret = org_freedesktop_Hal_Device_Volume_InvalidUnmountOption;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.InvalidMountpoint" ) )
ret = org_freedesktop_Hal_Device_Volume_InvalidMountpoint;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDeniedByPolicy" ) )
ret = org_freedesktop_Hal_Device_Volume_PermissionDeniedByPolicy;
dbus_error_free( &error );
}
else
k3bDebug() << "(K3bDevice::HalConnection) unmount queued for " << mediumUdi << endl;
dbus_message_unref( dmesg );
if( reply )
dbus_message_unref( reply );
return ret;
}
int K3bDevice::HalConnection::eject( K3bDevice::Device* dev,
const QStringList& options )
{
//
// The code below is based on the code from kioslave/media/mediamanager/halbackend.cpp in the kdebase package
// Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
//
DBusMessage* dmesg = 0;
DBusMessage* reply = 0;
DBusError error;
if( !d->deviceUdiMap.contains( dev->blockDeviceName() ) )
return org_freedesktop_Hal_NoSuchDevice;
if( !d->deviceMediumUdiMap.contains( d->deviceUdiMap[dev->blockDeviceName()] ) )
return org_freedesktop_Hal_Device_Volume_NoSuchDevice;
QCString mediumUdi = d->deviceMediumUdiMap[d->deviceUdiMap[dev->blockDeviceName()]];
if( !( dmesg = dbus_message_new_method_call( "org.freedesktop.Hal", mediumUdi.data(),
"org.freedesktop.Hal.Device.Volume",
"Eject" ) ) ) {
k3bDebug() << "(K3bDevice::HalConnection) eject failed for " << mediumUdi << ": could not create dbus message\n";
return org_freedesktop_Hal_CommunicationError;
}
char** poptions = qstringListToArray( options );
if( !dbus_message_append_args( dmesg,
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &poptions, options.count(),
DBUS_TYPE_INVALID ) ) {
k3bDebug() << "(K3bDevice::HalConnection) eject failed for " << mediumUdi << ": could not append args to dbus message\n";
dbus_message_unref( dmesg );
freeArray( poptions, options.count() );
return org_freedesktop_Hal_CommunicationError;
}
freeArray( poptions, options.count() );
int ret = org_freedesktop_Hal_Success;
dbus_error_init( &error );
reply = dbus_connection_send_with_reply_and_block( d->connection, dmesg, -1, &error );
if( dbus_error_is_set( &error ) ) {
kdError() << "(K3bDevice::HalConnection) eject failed for " << mediumUdi << ": " << error.name << " - " << error.message << endl;
if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.NoSuchDevice" ) )
ret = org_freedesktop_Hal_Device_Volume_NoSuchDevice;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied" ) )
ret = org_freedesktop_Hal_Device_Volume_PermissionDenied;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.InvalidEjectOption" ) )
ret = org_freedesktop_Hal_Device_Volume_InvalidEjectOption;
else if( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDeniedByPolicy" ) )
ret = org_freedesktop_Hal_Device_Volume_PermissionDeniedByPolicy;
dbus_error_free( &error );
}
else
k3bDebug() << "(K3bDevice::HalConnection) eject queued for " << mediumUdi << endl;
dbus_message_unref( dmesg );
if( reply )
dbus_message_unref( reply );
return ret;
}
void K3bDevice::HalConnection::setupDBusQtConnection( DBusConnection* dbusConnection )
{
d->dBusQtConnection = new DBusQt::Connection( this );
d->dBusQtConnection->dbus_connection_setup_with_qt_main( dbusConnection );
}
#include "k3bhalconnection.moc"
|