Changeset 2050
- Timestamp:
- 02/20/10 23:28:51 (5 months ago)
- Files:
-
- 1 modified
-
trunk/src/filesystem/e2_devkit.c (modified) (49 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/filesystem/e2_devkit.c
r1958 r2050 26 26 /* 27 27 TODO 28 confirm that mount-point and -options are effectively hardcoded within devkit mount opration 28 confirm that mount-point is effectively hardcoded in daemon's mount-opration 29 check how to work with detachable devices (udisks) 29 30 */ 30 31 … … 36 37 #include "e2_fs.h" 37 38 38 #define DEVKIT_IFACE_NAME "org.freedesktop.DeviceKit.Disks" 39 #define DEVKIT_PATH_ROOT "/org/freedesktop/DeviceKit/Disks/devices/" 40 41 //subset of all possible device-properties 39 #define DEVKIT_IFACE 40 41 #ifdef DEVKIT_IFACE 42 # define DEVKIT_IFACE_NAME "org.freedesktop.DeviceKit.Disks" 43 # define DEVKIT_BUS_PATH "/org/freedesktop/DeviceKit/Disks" 44 //PATH_ROOT supplied to funcs will be "/org/freedesktop/DeviceKit/Disks/devices/" 45 #endif 46 #define UDISK_IFACE_NAME "org.freedesktop.UDisks" 47 #define UDISK_BUS_PATH "/org/freedesktop/UDisks" 48 //PATH_ROOT supplied to funcs will be "/org/freedesktop/UDisks/devices/" 49 50 //subset of available device-properties 42 51 typedef struct _DeviceProperties 43 52 { 44 53 gchar *device_file; //e.g. /dev/sda 45 // gchar **device_file_by_id; //NULL terminated array of unique target(s) linked to corresponding device(s) 46 //e.g. /dev/disk/by-id/ata-ST910021AS_3MH05AVA-part1 >> /dev/sda1 47 //AND ALSO uid(s) linked to device(s) 48 //e.g. /dev/disk/by-uuid/4165-968D >> /dev/sda1 49 // gchar **device_file_by_path; //NULL terminated array of port/partition(s) linked to corresponding device(s) 50 //e.g. /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:1:0 >> /dev/sda2 51 //i.e. can get a count of mountpoints for the device_file 54 #ifdef DEVKIT_IFACE 52 55 gchar *device_mount_path; //where the device is mounted, valid only if device-is-mounted is TRUE 53 // gchar *device_presentation_name; //device name for UI use 56 #endif 57 //for udisks 58 gchar **device_mount_paths;//NULL terminated array of paths where the device is mounted, 59 //valid only if device-is-mounted is TRUE 60 54 61 gchar *id_usage; //filesystem; crypto; partitiontable; raid; other; blank=(unknown) 55 62 gchar *id_type; //per id-usage: ext3, vfat etc swap blank=(unknown) … … 57 64 // guint64 device_media_detection_time; 58 65 gboolean device_is_removable; 66 gboolean device_is_detachable; //udisks only 59 67 gboolean device_is_media_available; 60 68 gboolean device_is_media_change_detected; … … 72 80 typedef struct _DeviceData 73 81 { 74 gchar *object_path; // DEVKIT_PATH_ROOT"<native-path-cleaned-basename>" i.e. with any '-' >> '_'82 gchar *object_path; //=PATH_ROOT"<native-path-cleaned-basename>" i.e. with any '-' >> '_' 75 83 DBusGProxy *devproxy; //not the same as the session-proxy, per-device to support async usage of the proxy 76 84 DeviceProperties props; … … 78 86 } DeviceData; 79 87 80 typedef struct _SessionDevices 81 { 88 typedef struct _DevicesSession 89 { 90 #ifdef DEVKIT_IFACE 91 gboolean udisks; //TRUE for udisks session, FALSE for devkit-disks (saves parsing daemon_version) 92 #endif 93 gchar *daemon_version; 94 const gchar *iface_name;//DEVKIT_IFACE_NAME or UDISK_IFACE_NAME 82 95 DBusGConnection *bus; //connection to system bus 83 96 DBusGProxy *proxy; //abstracted proxy for interface exported by a connection on bus 84 GHashTable *logged_devices; / *known removable devices, with85 key = (const) device object path, value = the corresponding DeviceData */86 } SessionDevices; 87 88 static SessionDevices devicesdata; 89 90 static void _e2_devkit_device_properties_clear (DeviceProperties *props); 97 GHashTable *logged_devices; //known removable devices, with 98 // key = (const) device object path, 99 // value = the corresponding DeviceData* 100 } DevicesSession; 101 102 static DevicesSession session; 103 91 104 static void _e2_devkit_device_changed_cb (DBusGProxy *proxy, 92 105 const gchar *object_path, gpointer user_data); … … 98 111 99 112 /** 100 @brief cleanup allocated properties data for a device 101 @param props the data struct to be processed 102 @return 103 */ 104 static void _e2_devkit_device_properties_clear (DeviceProperties *props) 105 { 106 g_free (props->device_file); 107 // g_strfreev (props->device_file_by_id); 108 // g_strfreev (props->device_file_by_path); 109 g_free (props->device_mount_path); 110 // g_free (props->device_presentation_name); 111 g_free (props->id_usage); 112 g_free (props->id_type); 113 g_free (props->drive_media); 113 @brief get daemon version 114 Queries the DaemonVersion property on @a iface of @a object_path owned by the 115 well-known name @a iface on the D-Bus system message bus. 116 @param bus pointer to dbus connection object 117 @param iface string like "org.freedesktop.DeviceKit.Disks" 118 @param object_path string like "/org/freedesktop/DeviceKit/Disks" 119 @return newly-allocated string containing version descriptor, or NULL upon error 120 */ 121 static gchar *_e2_devkit_get_version (DBusGConnection *bus, 122 const gchar *iface, const gchar *object_path) 123 { 124 gchar *version; 125 DBusGProxy *prop_proxy; 126 GValue value1 = {0}; 127 GError *error; 128 129 prop_proxy = dbus_g_proxy_new_for_name (bus, 130 iface, 131 object_path, 132 "org.freedesktop.DBus.Properties"); 133 if (prop_proxy == NULL) 134 { 135 // _e2_devkit_advise (_("some warning ..."), NULL); 136 printd (WARN, "Unable to establish dbus connection for daemon interrogation"); 137 return NULL; 138 } 139 error = NULL; 140 if (dbus_g_proxy_call (prop_proxy, 141 "Get", 142 &error, 143 G_TYPE_STRING, 144 iface, 145 G_TYPE_STRING, 146 "DaemonVersion", 147 G_TYPE_INVALID, 148 G_TYPE_VALUE, 149 &value1, 150 G_TYPE_INVALID)) 151 { 152 version = g_strdup (g_value_get_string (&value1)); 153 g_value_unset (&value1); 154 printd (DEBUG,"DaemonVersion property for %s is \"%s\"", object_path, version); 155 } 156 else 157 { 158 version = NULL; 159 printd (DEBUG,"Failed to get DaemonVersion property for %s: %s", 160 object_path, error->message); 161 g_error_free (error); 162 } 163 164 g_object_unref (G_OBJECT(prop_proxy)); 165 return version; 114 166 } 115 167 /** … … 118 170 The property-names conform to the ones used in gnome-disk-utility 2.28 119 171 like "DeviceIsDrive", replacing ones like "device-is-drive" 120 @param bus connection to system busfor this session121 @param object_path DEVKIT_PATH_ROOT etc172 @param sessionptr pointer to connection data struct for this session 173 @param object_path PATH_ROOT... 122 174 @param props pointer to empty (0'd) properties struct to be populated 123 175 @return TRUE if process completes successfully, FALSE upon error 124 176 */ 125 static gboolean _e2_devkit_device_properties_get (D BusGConnection *bus,177 static gboolean _e2_devkit_device_properties_get (DevicesSession *sessionptr, 126 178 const gchar *object_path, DeviceProperties *props) 127 179 { 128 180 gboolean retval; 181 gchar *device_iface; 129 182 DBusGProxy *prop_proxy; 130 183 GValue value1 = {0}; … … 132 185 GHashTable *hash_table; 133 186 134 memset (props, 0, sizeof(DeviceProperties)); //start with clear data135 136 prop_proxy = dbus_g_proxy_new_for_name (bus, DEVKIT_IFACE_NAME,137 object_path,"org.freedesktop.DBus.Properties");187 prop_proxy = dbus_g_proxy_new_for_name (sessionptr->bus, 188 sessionptr->iface_name, 189 object_path, 190 "org.freedesktop.DBus.Properties"); 138 191 if (prop_proxy == NULL) 139 192 { 140 // _e2_devkit_advise (_(" message"), NULL);141 printd (WARN, "Unable to connect to devicekit daemon");193 // _e2_devkit_advise (_("some warning ..."), NULL); 194 printd (WARN, "Unable to establish dbus connection for properties interrogation"); 142 195 return FALSE; 143 196 } 144 197 198 device_iface = g_strconcat (sessionptr->iface_name, ".Device", NULL); 199 memset (props, 0, sizeof(DeviceProperties)); 145 200 error = NULL; 146 201 //no point in doing async interrogations here 147 //since most devices are not relevant, best to do a separate, minmimal,148 //check before getting full set of device properties202 //since most devices are not relevant, best to do some separate, minimal, 203 //checks before getting full set of device properties 149 204 if (dbus_g_proxy_call (prop_proxy, 150 205 "Get", 151 206 &error, 152 207 G_TYPE_STRING, 153 DEVKIT_IFACE_NAME".Device",208 device_iface, 154 209 G_TYPE_STRING, 155 210 "DeviceIsDrive", … … 163 218 else 164 219 { 220 g_value_unset (&value1); 165 221 abort: 166 g_value_unset (&value1); 222 g_free (device_iface); 223 g_object_unref (G_OBJECT(prop_proxy)); 167 224 props->ignored = TRUE; 168 g_object_unref (G_OBJECT(prop_proxy));169 225 return TRUE; 170 226 } … … 172 228 else 173 229 { 174 printd (DEBUG," Get() failed to get propertiesfor %s: %s",175 object_path, error->message);230 printd (DEBUG,"Failed to get DeviceIsDrive property for %s: %s", 231 device_iface, error->message); 176 232 g_error_free (error); 233 g_free (device_iface); 177 234 return FALSE; 178 235 } … … 184 241 &error, 185 242 G_TYPE_STRING, 186 DEVKIT_IFACE_NAME".Device",243 device_iface, 187 244 G_TYPE_STRING, 188 245 "DeviceIsRemovable", … … 192 249 G_TYPE_INVALID)) 193 250 { 194 if (g_value_get_boolean (&value1)) 195 props->device_is_removable = TRUE; 251 props->device_is_removable = g_value_get_boolean (&value1); 252 g_value_unset (&value1); 253 } 254 else 255 { 256 printd (DEBUG,"Failed to get DeviceIsRemovable property for %s: %s", 257 device_iface, error->message); 258 g_error_free (error); 259 g_free (device_iface); 260 return FALSE; 261 } 262 263 #ifdef DEVKIT_IFACE 264 if (sessionptr->udisks) 265 { 266 #endif 267 if (dbus_g_proxy_call (prop_proxy, 268 "Get", 269 &error, 270 G_TYPE_STRING, 271 device_iface, 272 G_TYPE_STRING, 273 "DriveCanDetach", 274 G_TYPE_INVALID, 275 G_TYPE_VALUE, 276 &value1, 277 G_TYPE_INVALID)) 278 { 279 props->device_is_detachable = g_value_get_boolean (&value1); 280 g_value_unset (&value1); 281 } 196 282 else 197 goto abort; 198 } 199 200 g_value_unset (&value1); 283 { 284 printd (DEBUG,"Failed to get DriveCanDetach property for %s: %s", 285 device_iface, error->message); 286 g_error_free (error); 287 g_free (device_iface); 288 return FALSE; 289 } 290 #ifdef DEVKIT_IFACE 291 } 292 #endif 293 if (!(props->device_is_removable || props->device_is_detachable)) 294 goto abort; 201 295 202 296 //populate other properties the slow and lazy way (get all properties then filter them) … … 205 299 &error, 206 300 G_TYPE_STRING, 207 DEVKIT_IFACE_NAME".Device",301 device_iface, 208 302 G_TYPE_INVALID, 209 303 dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), … … 216 310 if (propvalue != NULL) 217 311 props->device_file = g_strdup (g_value_get_string (propvalue)); 218 // propvalue = g_hash_table_lookup (hash_table, "DeviceFileById"); 219 // if (propvalue != NULL) 220 // props->device_file_by_id = g_strdupv (g_value_get_boxed (propvalue)); 221 // propvalue = g_hash_table_lookup (hash_table, "DeviceFileByPath"); 222 // if (propvalue != NULL) 223 // props->device_file_by_path = g_strdupv (g_value_get_boxed (propvalue)); 224 propvalue = g_hash_table_lookup (hash_table, "DeviceMountPath"); 225 if (propvalue != NULL) 226 props->device_mount_path = g_strdup (g_value_get_string (propvalue)); 227 // propvalue = g_hash_table_lookup (hash_table, "DevicePresentationName"); 228 // if (propvalue != NULL) 229 // props->device_presentation_name = g_strdup (g_value_get_string (propvalue)); 312 #ifdef DEVKIT_IFACE 313 if (!sessionptr->udisks) 314 { 315 propvalue = g_hash_table_lookup (hash_table, "DeviceMountPath"); 316 if (propvalue != NULL) 317 props->device_mount_path = g_strdup (g_value_get_string (propvalue)); 318 } 319 else 320 { 321 #endif 322 propvalue = g_hash_table_lookup (hash_table, "DeviceMountPaths"); 323 if (propvalue != NULL) 324 props->device_mount_paths = g_strdupv (g_value_get_boxed (propvalue)); 325 #ifdef DEVKIT_IFACE 326 } 327 #endif 230 328 propvalue = g_hash_table_lookup (hash_table, "IdUsage"); 231 329 if (propvalue != NULL) … … 274 372 else 275 373 { 276 printd (DEBUG," GetAll() failed to getproperties for %s: %s",374 printd (DEBUG,"Failed to get all properties for %s: %s", 277 375 object_path, error->message); 278 376 g_error_free (error); 279 377 retval = FALSE; 280 378 } 379 //CHECKME props->ignored = ? 380 g_free (device_iface); 281 381 g_object_unref (prop_proxy); 282 382 … … 284 384 } 285 385 /** 386 @brief cleanup allocated properties data for a device 387 @param props the data struct to be processed 388 @return 389 */ 390 static void _e2_devkit_device_properties_clear (DeviceProperties *props) 391 { 392 g_free (props->device_file); 393 #ifdef DEVKIT_IFACE 394 g_free (props->device_mount_path); 395 #endif 396 g_strfreev (props->device_mount_paths); 397 g_free (props->id_usage); 398 g_free (props->id_type); 399 g_free (props->drive_media); 400 } 401 /** 286 402 @brief cleanup device-data 287 @param data datafor a device403 @param data pointer to data struct for a device 288 404 @return 289 405 */ … … 296 412 } 297 413 g_free (data->object_path); 414 g_object_unref (G_OBJECT(data->devproxy)); 298 415 _e2_devkit_device_properties_clear (&data->props); 299 g_object_unref(G_OBJECT(data->devproxy));300 416 301 417 DEALLOCATE (DeviceData, data); … … 309 425 { 310 426 //NOTE: ensure this cleanup conforms to the contents of data->props 427 #ifdef DEVKIT_IFACE 311 428 g_free (data->props.device_mount_path); 312 429 data->props.device_mount_path = NULL; 430 #endif 431 g_strfreev (data->props.device_mount_paths); 432 data->props.device_mount_paths = NULL; 313 433 314 434 g_free (data->props.id_usage); … … 327 447 @brief determine whether @a object_path represents a device we're interested in, 328 448 and if so, set up data for it. 329 @param pool330 @param object_path DEVKIT_PATH_ROOT etc449 @param sessionptr pointer to session data struct 450 @param object_path PATH_ROOT... 331 451 @return pointer to device data, or NULL if not wanted or error 332 452 */ 333 static DeviceData *_e2_devkit_device_get ( SessionDevices *pool,453 static DeviceData *_e2_devkit_device_get (DevicesSession *sessionptr, 334 454 const gchar *object_path) 335 455 { 336 456 DeviceProperties props; 337 if (!_e2_devkit_device_properties_get ( pool->bus, object_path, &props))338 { 339 printd (DEBUG, "Dev kit: Cannot determine properties for device %s", object_path);457 if (!_e2_devkit_device_properties_get (sessionptr, object_path, &props)) 458 { 459 printd (DEBUG, "Devices deamon cannot determine properties for device %s", object_path); 340 460 return NULL; 341 461 } … … 343 463 if (props.ignored) 344 464 { 345 // printd (DEBUG, "Dev kit: Not interested in device %s", object_path);465 // printd (DEBUG, "Devices deamon not interested in device %s", object_path); 346 466 return NULL; 347 467 } … … 349 469 { 350 470 //this is a device of interest 471 gchar *device_iface; 351 472 DeviceData *device; 352 473 DBusGProxy *dev_proxy; //CHECKME needed ? … … 355 476 CHECKALLOCATEDWARN (device, _e2_devkit_device_properties_clear (&props);return NULL;) 356 477 357 dev_proxy = dbus_g_proxy_new_for_name (pool->bus, 358 DEVKIT_IFACE_NAME, 478 device_iface = g_strconcat (sessionptr->iface_name, ".Device", NULL); 479 dev_proxy = dbus_g_proxy_new_for_name (sessionptr->bus, 480 sessionptr->iface_name, 359 481 object_path, 360 DEVKIT_IFACE_NAME".Device"); 482 device_iface); 483 g_free (device_iface); 361 484 362 485 if (dev_proxy == NULL) … … 384 507 /** 385 508 @brief log current removable devices 386 @param poolpointer to devkit data struct509 @param sessionptr pointer to devkit data struct 387 510 @return TRUE if enumeration succeeded 388 511 */ 389 static gboolean _e2_devkit_detect_current_removables ( SessionDevices *pool)512 static gboolean _e2_devkit_detect_current_removables (DevicesSession *sessionptr) 390 513 { 391 514 guint i; … … 396 519 error = NULL; 397 520 //CHECKME synchronous process ok ? 398 if (!dbus_g_proxy_call ( pool->proxy, "EnumerateDevices", &error, G_TYPE_INVALID,521 if (!dbus_g_proxy_call (sessionptr->proxy, "EnumerateDevices", &error, G_TYPE_INVALID, 399 522 dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), 400 523 &devices, G_TYPE_INVALID)) … … 405 528 } 406 529 407 // printd (DEBUG, "Dev kit: %d devices reported", devices->len);530 // printd (DEBUG, "Devices daemon reported %u devices", devices->len); 408 531 for (i = 0; i < devices->len; i++) 409 532 { 410 DeviceData *device = _e2_devkit_device_get ( pool, devices->pdata[i]);533 DeviceData *device = _e2_devkit_device_get (sessionptr, devices->pdata[i]); 411 534 if (device != NULL) 412 535 { 413 printd (DEBUG, " Devkit: Logging device %s", devices->pdata[i]);414 g_hash_table_insert ( pool->logged_devices,536 printd (DEBUG, "Logging removable device %s", device->props.device_file); 537 g_hash_table_insert (sessionptr->logged_devices, 415 538 (gpointer) device->object_path, //not another copy, not truncated 416 539 (gpointer) device); 417 540 } 418 541 // else 419 // printd (DEBUG, " Devkit: Skipping device %s @ %x", devices->pdata[i], device);542 // printd (DEBUG, "Skipping device %s @ %x", device->props.device_file, device); 420 543 421 544 g_free (devices->pdata[i]); //CHECKME does the array-data self-destruct (glib >= 2.22) … … 429 552 @brief automount a volume 430 553 This is called from within timer callback i.e. BGL is off 431 @param pool554 @param sessionptr 432 555 @param device 433 556 434 557 @return TRUE if the mount is performed successfully or is not needed 435 558 */ 436 static gboolean _e2_devkit_mount_volume ( SessionDevices *pool, DeviceData *device)559 static gboolean _e2_devkit_mount_volume (DevicesSession *sessionptr, DeviceData *device) 437 560 { 438 561 gboolean optical; … … 447 570 ) 448 571 { 449 printd (DEBUG, "Dev kit: device does not need to be mounted");572 printd (DEBUG, "Device %s does not need to be mounted", device->props.device_file); 450 573 return TRUE; 451 574 } 452 575 453 576 fstype = device->props.id_usage; 454 if (fstype == NULL || strcmp (fstype, "filesystem")) //CHECKME "crypto", "raid", "other" 455 { 456 printd (DEBUG, "Devkit: mounting this device-type is not supported"); 577 if (fstype == NULL || 578 !( strcmp (fstype, "filesystem") == 0 579 || strcmp (fstype, "raid") == 0 //OK ? 580 || strcmp (fstype, "crypto") == 0)) //OK ? //CHECKME "other" 581 { 582 printd (DEBUG, "Unmountable device %s", device->props.device_file); 457 583 return TRUE; //some unmountable sort of device 458 584 } … … 461 587 if (fstype == NULL || *fstype == '\0') 462 588 { 463 printd (DEBUG, " Devkit: device filesystem-type is not recognised");589 printd (DEBUG, "Unrecognised filesystem-type for device %s", device->props.device_file); 464 590 return TRUE; //not a data-medium 465 591 } 466 592 467 #if 0 468 //determine a suitable mountpoint ... apparently unusable if devkit does the mounting 469 470 #define FIRSTOPTIC 10 471 const gchar *disktypes[] = 472 { 473 //for DeviceKit-Disks 004 474 "flash", 475 "flash_cf", 476 "flash_ms", 477 "flash_sm", //aka "smart" 478 479 "flash_sd", 480 "flash_sdhc", 481 "flash_mmc", //aka "sd_mmc" 482 483 "floppy", 484 "floppy_zip", //aka "zip" 485 "floppy_jaz", //aka "jaz" 486 487 "optical_cd", //"cd", index 10 488 "optical_cd_r", //"cdrom" 489 "optical_cd_rw", //"cd" writable, index 12 490 "optical_dvd", //"dvd" 491 "optical_dvd_r", //"dvdrom" 492 "optical_dvd_rw", //"dvd" writable 15 493 "optical_dvd_ram", //writable 16 494 "optical_dvd_plus_r", 495 "optical_dvd_plus_rw", //writable 18 496 "optical_dvd_plus_r_dl", 497 "optical_dvd_plus_rw_dl", //writable 20 498 "optical_bd", 499 "optical_bd_r", 500 "optical_bd_re", 501 "optical_hddvd", //24 502 "optical_hddvd_r", 503 "optical_hddvd_rw", //writable 26 504 "optical_mo", 505 "optical_mrw", 506 "optical_mrw_w", //writable 29 507 }; 508 509 const gchar *last; 510 gboolean readonly; 511 gint i; 512 513 /* check for an available mountpoint 514 mountpoint from lsb spec: 515 /media 516 /floppy Floppy drive (optional) 517 /cdrom CD-ROM drive (optional) 518 /cdrecorder CD writer (optional) 519 /zip Zip drive (optional) 520 Where more than one device exists for mounting a certain type of media, mount 521 directories can be created by appending a digit to the name, starting with 522 '0', but the unqualified name must also exist 523 524 for device names: 525 Partitions or volumes will appear as device-appended numbers, like 526 sda1, sda2 .... 527 Some devices e.g. cdrom are themselves treated as a volume, and will then 528 have no partition number 529 Devices to be mounted may already exist in /dev 530 */ 531 if (optical) 532 { //this volume is, or is part of, an optical disk 533 gint count = sizeof (disktypes) / sizeof (const gchar *); 534 if (device->props.drive_media == NULL || *device->props.drive_media == '\0') 535 i = count; //set defaults 536 else 537 { 538 for (i = FIRSTOPTIC; i < count; i++) 539 { 540 if (!strcmp (disktypes[i], device->props.drive_media)) 541 { 542 switch (i) 543 { 544 case 12: 545 case 15: 546 case 16: 547 case 18: 548 case 20: 549 case 26: 550 case 29: 551 if (i <= 12) 552 last = "cdrecorder"; 553 else if (i <= 20 || i == 24 || i == 25 || i == 26) 554 last = "dvdrecorder"; 555 else 556 last = "recorder"; 557 readonly = FALSE; 558 break; 559 default: 560 if (i <= 12) 561 last = "cdrom"; 562 else if (i <= 20 || i == 24 || i == 25 || i == 26) 563 last = "dvdrom"; 564 else 565 last = "disk"; 566 readonly = TRUE; 567 break; 568 } 569 break; 570 } 571 } 572 } 573 if (i == count) 574 { //defaults 575 last = "cdrom"; 576 readonly = TRUE; 577 } 578 } 579 else //not an optical disk 580 { 581 if (device->props.drive_media == NULL || *device->props.drive_media == '\0') 582 i = FIRSTOPTIC; //set defaults 583 else 584 { 585 for (i = 0; i < FIRSTOPTIC; i++) 586 { 587 last = disktypes[i]; 588 if (!strcmp (last, device->props.drive_media)) 589 { 590 switch (i) 591 { 592 default: 593 last = "disk"; //FIXME 594 break; 595 case 7: 596 last = "floppy"; 597 break; 598 case 8: 599 last = "zip"; 600 break; 601 case 9: 602 last = "jaz"; 603 break; 604 } 605 readonly = FALSE; 606 break; 607 } 608 } 609 } 610 if (i == FIRSTOPTIC) 611 { //defaults 612 last = "disk"; 613 readonly = FALSE; 614 } 615 } 616 617 GList *mounts_now, *member; 618 gchar *str, *utf, *mountpoint; 619 620 mounts_now = e2_fs_mount_get_mounts_list (); 621 mountpoint = g_build_filename (E2_MOUNTPLACE, last, NULL); 622 str = g_strdup (mountpoint); 623 utf = F_FILENAME_FROM_LOCALE (str); //not strictly necessary, the default path is all ASCII 624 guint count = 0; 625 retry: 626 for (member = mounts_now; member != NULL; member = member->next) 627 { 628 if (!strcmp ((gchar*)member->data, utf)) 629 { 630 g_free (str); 631 F_FREE (utf, str); 632 str = g_strdup_printf ("%s%d", mountpoint, count++); 633 utf = F_FILENAME_FROM_LOCALE (str); 634 goto retry; 635 } 636 } 637 638 g_free (mountpoint); 639 F_FREE (utf, str); 640 e2_list_free_with_data (&mounts_now); 641 mountpoint = str; 642 643 //determine mount options from the available ones ... apparently unusable if devkit does the mounting 644 645 gboolean readonly_valid = FALSE; 646 gint freeindex = -1; 647 648 GPtrArray *extra_options = g_ptr_array_sized_new (6); 649 gboolean FIXME; //get suitable options 650 gchar **mountopts = NULL; 651 if (mountopts != NULL) 652 { 653 gchar **thisopt; 654 for (thisopt = mountopts; *thisopt != NULL; thisopt++) 655 { 656 //CHECKME which mount options are most suitable ? 657 //e.g. ro,sync,dirsync,noatime,nodiratime,noexec,quiet,remount,exec,utf8 658 //shortname=,codepage=,iocharset=,umask=,dmask=,fmask=,uid=,flush 659 if (strcmp (*thisopt, "exec") == 0) 660 { 661 g_ptr_array_add (extra_options, *thisopt); 662 } 663 else if (strncmp (*thisopt, "umask=", 6) == 0) 664 { 665 g_ptr_array_add (extra_options, g_strconcat (*thisopt, "0", NULL)); 666 freeindex = extra_options->len - 1; //for leak fix 667 } 668 else if (strcmp (*thisopt, "sync") == 0) 669 { 670 g_ptr_array_add (extra_options, *thisopt); 671 } 672 else if (strcmp (*thisopt, "ro") == 0) 673 { 674 readonly_valid = TRUE; 675 if (readonly) 676 g_ptr_array_add (extra_options, *thisopt); 677 } 678 else if (readonly) 679 { 680 readonly_valid = TRUE; 681 g_ptr_array_add (extra_options, "ro"); 682 } 683 684 } 685 } 686 g_ptr_array_add (extra_options, NULL); //terminate the array 687 #endif //0 688 689 gboolean retval; 690 691 //do it 692 # if 0 //direct 693 gint res = run command 694 retval = (res == 0); 695 /* if (retval) 696 { 697 //"refresh" the filelist(s) if needed 698 gchar *utf = F_FILENAME_FROM_LOCALE (mountpoint); 699 if (g_str_has_prefix (curr_view->dir, utf)) 700 do something 701 if (g_str_has_prefix (other_view->dir, utf)) 702 do something 703 F_FREE (utf, mountpoint); 704 } 705 */ 706 # else //via devkit 707 gpointer cb_data = device; 708 #if 1 709 gchar *options[2]; 710 711 options[0] = NULL; 712 #endif 713 714 retval = 593 //apparently, a mountpoint can't be specified to the daemon 594 //so we don't bother with non-default mount-options, either 595 return 715 596 (dbus_g_proxy_begin_call (device->devproxy, "FilesystemMount", 716 _e2_devkit_mount_async_cb, 717 cb_data, (GDestroyNotify) NULL, 718 G_TYPE_STRING, fstype, 719 # if 0 720 G_TYPE_STRV, extra_options->pdata, 721 # else 722 G_TYPE_STRV, options, //no mount options 723 # endif 724 G_TYPE_INVALID) != NULL); 725 # endif 726 #if 0 727 //cleanup 728 g_free (mountpoint); 729 //CHECKME free all options ? does the array-data self-destruct (glib >= 2.22) 730 if (freeindex != -1) 731 g_free (g_ptr_array_index (extra_options, freeindex)); 732 g_ptr_array_free (extra_options, TRUE); 733 #endif 734 return retval; 597 _e2_devkit_mount_async_cb, 598 device, (GDestroyNotify) NULL, 599 G_TYPE_STRING, fstype, 600 G_TYPE_STRV, NULL, //no mount options 601 G_TYPE_INVALID) 602 != NULL); 603 } 604 605 /** 606 @brief if possible, change CWD out of @mountpoint so we don't ourself block the unmount 607 @param mountpoint a mountpoint path supplied by the daemon, converted to UTF-8 608 609 @return 610 */ 611 static void _e2_devkit_skipaway (const gchar *mountpoint) 612 { 613 gchar *elsewhere, *s; 614 615 if (mountpoint == NULL) 616 return; 617 elsewhere = g_strdup (mountpoint); 618 g_strchug (elsewhere); //just in case ... 619 if (*mountpoint != G_DIR_SEPARATOR) 620 { 621 g_free (elsewhere); 622 return; 623 } 624 if (e2_utils_pass_whitespace ((gchar *)(mountpoint + 1)) == NULL) 625 { 626 g_free (elsewhere); 627 return; //nothing to do 628 } 629 while ((s = strrchr (elsewhere, G_DIR_SEPARATOR)) != NULL) 630 { 631 if (s > elsewhere) //keep the root dir 632 *s = '\0'; 633 if (!g_str_has_prefix (elsewhere, mountpoint)) 634 { 635 e2_fs_get_valid_path (&elsewhere, TRUE E2_ERR_NONE()); 636 e2_pane_change_dir (NULL, elsewhere); 637 break; 638 } 639 else if (s == elsewhere) 640 break; //nowhere to go 641 } 642 g_free (elsewhere); 735 643 } 736 644 … … 738 646 @brief auto-unmount a volume 739 647 This is called from within timer callback i.e. BGL is off 740 @param poolpointer to devkit data struct648 @param sessionptr pointer to devkit data struct 741 649 @param device pointer to data for the device 742 650 743 651 @return TRUE if the unmount is performed successfully or is not needed 744 652 */ 745 static gboolean _e2_devkit_unmount_volume ( SessionDevices *pool, DeviceData *device)653 static gboolean _e2_devkit_unmount_volume (DevicesSession *sessionptr, DeviceData *device) 746 654 { 747 655 //CHECKME upstream check for still-need-unmount is too racy? … … 752 660 } 753 661 754 const gchar *mountpoint = device->props.device_mount_path; 755 if (mountpoint != NULL //should never happen 662 gchar *mountpoint; 663 #ifdef DEVKIT_IFACE 664 mountpoint = device->props.device_mount_path; 665 gboolean moved; 666 if (!sessionptr->udisks && mountpoint != NULL) //this is a devkit-disks session 667 { 668 mountpoint = F_FILENAME_FROM_LOCALE (mountpoint); 669 # ifdef E2_VFSTMP 670 //FIXME dir when not mounted local 671 # endif 672 if (g_str_has_prefix (curr_view->dir, mountpoint)) 673 { 674 _e2_devkit_skipaway (mountpoint); 675 moved = TRUE; 676 } 677 else 678 moved = FALSE; 679 F_FREE (mountpoint, device->props.device_mount_path); 680 } 681 else 682 moved = FALSE; 683 684 if (sessionptr->udisks && !moved) 685 { 686 #endif 687 gchar **allmounts; 688 for (allmounts = device->props.device_mount_paths; 689 (mountpoint = *allmounts) != NULL; 690 allmounts++) 691 { 692 mountpoint = F_FILENAME_FROM_LOCALE (mountpoint); 756 693 #ifdef E2_VFSTMP 757 //FIXME dir when not mounted local 758 #else 759 && g_str_has_prefix (curr_view->dir, mountpoint)) 760 #endif 761 { //if possible, change CWD out of mountpoint so we don't ourself block the unmount 762 gchar *elsewhere; 763 const gchar *s = strrchr (mountpoint, G_DIR_SEPARATOR); //assumes no trailer on mountpoint string 764 if (s > mountpoint + 1) //not doing root dir 765 elsewhere = g_strndup (mountpoint, s - mountpoint); 766 else //can't cd 767 elsewhere = g_strdup (G_DIR_SEPARATOR_S); 768 769 e2_fs_get_valid_path (&elsewhere, TRUE E2_ERR_NONE()); 770 e2_pane_change_dir (NULL, elsewhere); 771 g_free (elsewhere); 772 } 773 694 //FIXME dir when not mounted local 695 #endif 696 if (g_str_has_prefix (curr_view->dir, mountpoint)) 697 { 698 _e2_devkit_skipaway (mountpoint); 699 F_FREE (mountpoint, device->props.device_mount_path); 700 break; 701 } 702 F_FREE (mountpoint, device->props.device_mount_path); 703 } 704 #ifdef DEVKIT_IFACE 705 } 706 #endif 774 707 //do it 775 # if 0 //direct776 gint res = run command708 #if 0 //direct 709 gint res = run unmount command 777 710 retval = (res == 0); 778 711 //do stuff if successful … … 780 713 _e2_devkit_device_data_freshen (device); 781 714 return retval; 782 # else //via devkit 783 gpointer cb_data = device; 784 gchar *options[2]; 785 786 #ifdef DEBUG_MESSAGES 787 gboolean CHECKME; 788 #endif 789 options[0] = NULL; 790 715 #else //via the daemon 716 // gpointer cb_data = device; 717 // gchar *options[2]; 718 // options[0] = NULL; 719 //# ifdef DEBUG_MESSAGES 720 // gboolean CHECKME; 721 //# endif 791 722 return 792 723 (dbus_g_proxy_begin_call (device->devproxy, "FilesystemUnmount", 793 _e2_devkit_unmount_async_cb, 794 cb_data, (GDestroyNotify) NULL, 795 G_TYPE_STRV, options, G_TYPE_INVALID) != NULL); 796 # endif 724 _e2_devkit_unmount_async_cb, 725 device, (GDestroyNotify) NULL, 726 G_TYPE_STRV, /*options*/NULL, G_TYPE_INVALID) 727 != NULL); 728 #endif 797 729 } 798 730 … … 854 786 //do stuff ? 855 787 DeviceData *device = (DeviceData *)user_data; 856 printd (DEBUG, "Device %s unmounted", device-> object_path);788 printd (DEBUG, "Device %s unmounted", device->props.device_file); 857 789 _e2_devkit_device_data_freshen (device); 858 790 } … … 876 808 device->timer_id = 0; //ASAP indicate to any other process 877 809 //but we don't remove this source in case mount fails 878 printd (DEBUG, "Dev kit:mount timer callback, device %s", device->props.device_file);810 printd (DEBUG, "Device-mount timer callback, device %s", device->props.device_file); 879 811 880 812 if (!device->props.device_is_mounted … … 882 814 ) 883 815 { 884 printd (DEBUG, "device needs to bemounted");816 printd (DEBUG, "device still not mounted"); 885 817 #ifdef DEBUG_MESSAGES 886 gboolean retval = !_e2_devkit_mount_volume (& devicesdata, device);818 gboolean retval = !_e2_devkit_mount_volume (&session, device); 887 819 if (retval) 888 820 printd (DEBUG, "mount operation failed"); 889 821 return retval; //try again in case of failure 890 822 #else 891 return (!_e2_devkit_mount_volume (& devicesdata, device));823 return (!_e2_devkit_mount_volume (&session, device)); 892 824 #endif 893 825 } … … 898 830 @brief callback for a device-add event 899 831 @param proxy connection to devkit daemon 900 @param object_path DEVKIT_PATH_ROOT etc832 @param object_path PATH_ROOT... 901 833 @param user_data pointer to device monitor data struct specified when callback was connected 902 834 @return … … 905 837 const gchar *object_path, gpointer user_data) 906 838 { 907 SessionDevices *pool;839 DevicesSession *sessionptr; 908 840 DeviceData *device; 909 841 910 pool = (SessionDevices*)user_data;911 device = g_hash_table_lookup ( pool->logged_devices, object_path);842 sessionptr = (DevicesSession *)user_data; 843 device = g_hash_table_lookup (sessionptr->logged_devices, object_path); 912 844 913 845 if (G_LIKELY(device == NULL)) 914 846 { 915 device = _e2_devkit_device_get ( pool, object_path);847 device = _e2_devkit_device_get (sessionptr, object_path); 916 848 if (device != NULL) 917 849 { 918 850 //new device is one we want 919 printd (DEBUG, " Devkit: Logging device %s @ %x", object_path, device);920 g_hash_table_insert ( pool->logged_devices,851 printd (DEBUG, "Logging device %s @ %x", device->props.device_file, device); 852 g_hash_table_insert (sessionptr->logged_devices, 921 853 (gpointer) device->object_path, //not another copy, not truncated 922 854 (gpointer) device); 923 //CHECKME is 2-sec delay long enough ?855 //CHECKME is 5-sec delay long enough ? 924 856 device->timer_id = 925 857 #ifdef USE_GLIB2_14 926 g_timeout_add_seconds ( 2,858 g_timeout_add_seconds (5, 927 859 #else 928 g_timeout_add ( 2000,860 g_timeout_add (5000, 929 861 #endif 930 862 (GSourceFunc) _e2_devkit_check_mount, device); … … 941 873 device->timer_id = 0; 942 874 } 943 printd (WARN, "Dev kit:add-event for previously added device %s, treat as change",875 printd (WARN, "Devices daemon add-event for previously added device %s, treat as change", 944 876 object_path); 945 877 _e2_devkit_device_changed_cb (proxy, object_path, user_data); … … 964 896 } 965 897 966 printd (DEBUG, "Dev kit: unmount timercallback");898 printd (DEBUG, "Device unmount timer-callback"); 967 899 968 900 if (device->props.device_is_mounted) 969 901 { 970 printd (DEBUG, "device needs to be unmounted");971 retval = !_e2_devkit_unmount_volume (&devicesdata, device);902 printd (DEBUG, "device is still mounted"); 903 retval = !_e2_devkit_unmount_volume (&session, device); 972 904 #ifdef DEBUG_MESSAGES 973 if (retval)974 printd (DEBUG, "but unmount operation failed");905 if (retval) 906 printd (DEBUG, "but unmount operation failed"); 975 907 #endif 976 908 } … … 987 919 @brief callback for a device-remove event 988 920 @param proxy 989 @param object_path DEVKIT_PATH_ROOT etc921 @param object_path PATH_ROOT... 990 922 @param user_data pointer to device monitor data struct specified when callback was connected 991 923 @return … … 994 926 const gchar *object_path, gpointer user_data) 995 927 { 996 SessionDevices *pool;928 DevicesSession *sessionptr; 997 929 DeviceData *device; 998 930 999 pool = (SessionDevices*)user_data;1000 if ( pool->logged_devices == NULL)931 sessionptr = (DevicesSession *)user_data; 932 if (sessionptr->logged_devices == NULL) 1001 933 return; 1002 device = g_hash_table_lookup ( pool->logged_devices, object_path);934 device = g_hash_table_lookup (sessionptr->logged_devices, object_path); 1003 935 1004 936 if (G_LIKELY(device != NULL)) … … 1024 956 This will be called twice when a device is added/removed. The 2nd call does nothing. 1025 957 @param proxy connection to devkit daemon 1026 @param object_path DEVKIT_PATH_ROOT/devicename (e.g. sr0, but with any '-' converted to '_')958 @param object_path PATH_ROOT/devicename (e.g. sr0, but with any '-' converted to '_') 1027 959 @param user_data pointer to session-devices data struct specified when callback was connected 1028 960 @return … … 1031 963 const gchar *object_path, gpointer user_data) 1032 964 { 1033 SessionDevices *pool;965 DevicesSession *sessionptr; 1034 966 DeviceData *device; 1035 967 1036 968 printd (DEBUG,"_e2_devkit_device_changed_cb: device %s", object_path); 1037 pool = (SessionDevices*)user_data;1038 if ( pool->logged_devices == NULL)969 sessionptr = (DevicesSession *)user_data; 970 if (sessionptr->logged_devices == NULL) 1039 971 { 1040 972 #ifdef DEBUG_MESSAGES … … 1044 976 return; 1045 977 } 1046 device = g_hash_table_lookup ( pool->logged_devices, object_path);978 device = g_hash_table_lookup (sessionptr->logged_devices, object_path); 1047 979 1048 980 if (G_LIKELY(device != NULL)) … … 1056 988 } 1057 989 1058 if (_e2_devkit_device_properties_get ( pool->bus, object_path, &new_properties))990 if (_e2_devkit_device_properties_get (sessionptr, object_path, &new_properties)) 1059 991 { 1060 992 if (G_LIKELY(!new_properties.ignored)) … … 1112 1044 This callback happens only at idle-time, and before any device-changed callback. 1113 1045 There is no info on what properties have changed, so we must poll. 1114 @param object UNUSED DEVKIT_DISKS_DEVICEobject1046 @param object UNUSED object 1115 1047 @param user_data pointer to data struct for device that's changed 1116 1048 @return … … 1155 1087 gboolean e2_devkit_device_is_removable (const gchar *devpath) 1156 1088 { 1157 if ( devicesdata.logged_devices != NULL)1158 { 1159 return (g_hash_table_find ( devicesdata.logged_devices,1089 if (session.logged_devices != NULL) 1090 { 1091 return (g_hash_table_find (session.logged_devices, 1160 1092 (GHRFunc) _e2_devkit_check_device_path, 1161 1093 (gpointer)devpath) != NULL); … … 1170 1102 gboolean e2_devkit_device_is_ejectable (const gchar *devpath) 1171 1103 { 1172 if ( devicesdata.logged_devices != NULL)1104 if (session.logged_devices != NULL) 1173 1105 { 1174 1106 DeviceData *dev; 1175 dev = (DeviceData *)g_hash_table_find ( devicesdata.logged_devices,1107 dev = (DeviceData *)g_hash_table_find (session.logged_devices, 1176 1108 (GHRFunc) _e2_devkit_check_device_path, 1177 1109 (gpointer)devpath); … … 1189 1121 void e2_devkit_init (void) 1190 1122 { 1191 SessionDevices *pool;1123 DevicesSession *sessionptr; 1192 1124 GError *error; 1193 1194 pool = &devicesdata; 1125 const gchar *iface_name, *object_path; 1126 gchar *version; 1127 1195 1128 error = NULL; 1196 1197 pool->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); 1198 if (pool->bus == NULL) 1199 { 1200 // _e2_devkit_advise (_("message"), NULL); 1129 object_path = NULL; //warning prevention 1130 1131 session.bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); 1132 if (session.bus == NULL) 1133 { 1134 // _e2_devkit_advise (_("some warning ..."), NULL); 1201 1135 printd (WARN, "Unable to connect to system bus: %s", error->message); 1202 1136 g_error_free (error); 1203 1137 return; 1204 1138 } 1205 pool->proxy = dbus_g_proxy_new_for_name (pool->bus, 1206 DEVKIT_IFACE_NAME, 1207 "/org/freedesktop/DeviceKit/Disks", 1208 DEVKIT_IFACE_NAME); 1209 //CHECKME specifically confirm daemon presence ? 1210 if (pool->proxy == NULL) 1211 { 1212 // _e2_devkit_advise (_("message"), NULL); 1213 printd (WARN, "Unable to connect to devicekit daemon"); 1214 dbus_g_connection_unref (pool->bus); 1139 1140 //check for daemon presence 1141 iface_name = UDISK_IFACE_NAME; 1142 version = _e2_devkit_get_version (session.bus, iface_name, UDISK_BUS_PATH); 1143 if (version != NULL) 1144 { 1145 #ifdef DEVKIT_IFACE 1146 session.udisks = TRUE; 1147 #endif 1148 session.daemon_version = version; 1149 session.iface_name = iface_name; 1150 object_path = UDISK_BUS_PATH; 1151 } 1152 else 1153 { 1154 #ifdef DEVKIT_IFACE 1155 iface_name = DEVKIT_IFACE_NAME; 1156 version = _e2_devkit_get_version (session.bus, iface_name, DEVKIT_BUS_PATH); 1157 if (version != NULL) 1158 { 1159 session.daemon_version = version; 1160 session.iface_name = iface_name; 1161 object_path = DEVKIT_BUS_PATH; 1162 } 1163 else 1164 { 1165 // _e2_devkit_advise (_("some warning ..."), NULL); 1166 printd (WARN, "Unable to connect to any devices daemon"); 1167 dbus_g_connection_unref (session.bus); 1168 session.bus = NULL; 1169 return; 1170 } 1171 #else 1172 // _e2_devkit_advise (_("some warning ..."), NULL); 1173 printd (WARN, "Unable to connect to a udisks daemon"); 1174 dbus_g_connection_unref (session.bus); 1175 session.bus = NULL; 1215 1176 return; 1216 } 1217 1218 //table with key = D-Bus object path, value = the corresponding device data struct 1219 pool->logged_devices = g_hash_table_new_full ( 1220 g_str_hash, g_str_equal, NULL, 1221 (GDestroyNotify)_e2_devkit_device_data_clear); 1222 1223 if (_e2_devkit_detect_current_removables (pool)) 1177 #endif 1178 } 1179 1180 session.proxy = dbus_g_proxy_new_for_name (session.bus, 1181 iface_name, 1182 object_path, 1183 iface_name); 1184 if (session.proxy == NULL) 1185 { 1186 // _e2_devkit_advise (_("some warning ..."), NULL); 1187 printd (WARN, "Unable to create proxy for dbus connection"); 1188 dbus_g_connection_unref (session.bus); 1189 session.bus = NULL; 1190 return; 1191 } 1192 1193 //table with: key = D-Bus object path, value = the corresponding device data struct 1194 session.logged_devices = g_hash_table_new_full ( 1195 g_str_hash, g_str_equal, 1196 NULL, (GDestroyNotify)_e2_devkit_device_data_clear); 1197 1198 sessionptr = &session; 1199 if (_e2_devkit_detect_current_removables (sessionptr)) 1224 1200 { 1225 1201 const gchar *signame; 1226 1202 1227 1203 signame = "DeviceAdded"; 1228 dbus_g_proxy_add_signal ( pool->proxy, signame, DBUS_TYPE_G_OBJECT_PATH,1229 G_TYPE_INVALID);1230 dbus_g_proxy_connect_signal ( pool->proxy, signame,1231 G_CALLBACK (_e2_devkit_device_added_cb), pool, NULL);1204 dbus_g_proxy_add_signal (session.proxy, signame, 1205 DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); 1206 dbus_g_proxy_connect_signal (session.proxy, signame, 1207 G_CALLBACK (_e2_devkit_device_added_cb), sessionptr, NULL); 1232 1208 signame = "DeviceRemoved"; 1233 dbus_g_proxy_add_signal ( pool->proxy, signame, DBUS_TYPE_G_OBJECT_PATH,1234 G_TYPE_INVALID);1235 dbus_g_proxy_connect_signal ( pool->proxy, signame,1236 G_CALLBACK (_e2_devkit_device_removed_cb), pool, NULL);1209 dbus_g_proxy_add_signal (session.proxy, signame, 1210 DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); 1211 dbus_g_proxy_connect_signal (session.proxy, signame, 1212 G_CALLBACK (_e2_devkit_device_removed_cb), sessionptr, NULL); 1237 1213 signame = "DeviceChanged"; 1238 dbus_g_proxy_add_signal ( pool->proxy, signame, DBUS_TYPE_G_OBJECT_PATH,1239 G_TYPE_INVALID);1240 dbus_g_proxy_connect_signal ( pool->proxy, signame,1241 G_CALLBACK (_e2_devkit_device_changed_cb), pool, NULL);1242 } 1243 else 1244 { 1245 // _e2_devkit_advise (_(" message"), NULL);1246 dbus_g_connection_unref ( pool->bus);1247 g_object_unref (G_OBJECT( pool->proxy));1248 g_hash_table_destroy ( pool->logged_devices);1249 memset ( pool, 0, sizeof (SessionDevices));1214 dbus_g_proxy_add_signal (session.proxy, signame, 1215 DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); 1216 dbus_g_proxy_connect_signal (session.proxy, signame, 1217 G_CALLBACK (_e2_devkit_device_changed_cb), sessionptr, NULL); 1218 } 1219 else 1220 { 1221 // _e2_devkit_advise (_("some warning ..."), NULL); 1222 dbus_g_connection_unref (session.bus); 1223 g_object_unref (G_OBJECT(session.proxy)); 1224 g_hash_table_destroy (session.logged_devices); 1225 memset (sessionptr, 0, sizeof (DevicesSession)); 1250 1226 } 1251 1227 } … … 1256 1232 void e2_devkit_disconnect (void) 1257 1233 { 1258 SessionDevices *pool; 1259 1260 pool = &devicesdata; 1261 if (pool->bus != NULL) 1262 dbus_g_connection_unref (pool->bus); 1263 if (pool->proxy != NULL) 1264 g_object_unref (G_OBJECT(pool->proxy)); 1265 if (pool->logged_devices != NULL) 1266 g_hash_table_destroy (pool->logged_devices); 1234 if (session.daemon_version != NULL) 1235 g_free (session.daemon_version); 1236 if (session.bus != NULL) 1237 dbus_g_connection_unref (session.bus); 1238 if (session.proxy != NULL) 1239 g_object_unref (G_OBJECT(session.proxy)); 1240 if (session.logged_devices != NULL) 1241 g_hash_table_destroy (session.logged_devices); 1267 1242 } 1268 1243 #endif //def E2_DEVKIT