Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 91928 | Differences between
and this patch

Collapse All | Expand All

(-)nautilus-burn-drive.c (-54 / +126 lines)
Lines 88-105 Link Here
88
get_hal_context (void)
88
get_hal_context (void)
89
{
89
{
90
	static LibHalContext *ctx = NULL;
90
	static LibHalContext *ctx = NULL;
91
	LibHalFunctions       hal_functions = {
91
	DBusError error;
92
		NULL, /* mainloop integration */
92
	DBusConnection *dbus_conn;
93
		NULL, /* device_added */
93
94
		NULL, /* device_removed */
94
	if (ctx == NULL) {
95
		NULL, /* device_new_capability */
95
		ctx = libhal_ctx_new ();
96
		NULL, /* device_lost_capability */
96
		if (ctx == NULL) {
97
		NULL, /* property_modified */
97
			g_warning ("Could not create a HAL context\n");
98
		NULL, /* device_condition */
98
		} else { 
99
	};
99
			dbus_error_init (&error);
100
			dbus_conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
101
102
			if (dbus_error_is_set (&error)) {
103
				g_warning ("Could not connect to system bus: %s\n", error.message);
104
				dbus_error_free (&error);
105
				return NULL;
106
			}
107
108
			libhal_ctx_set_dbus_connection (ctx, dbus_conn);
109
110
			if (!libhal_ctx_init (ctx, &error)) {
111
				g_warning ("Could not initalize "
112
					   "the HAL context: %s\n",
113
					   error.message);
114
115
				if (dbus_error_is_set (&error))
116
					dbus_error_free (&error);
100
117
101
	if (ctx == NULL)
118
				libhal_ctx_free (ctx);
102
		ctx = hal_initialize (&hal_functions, FALSE);
119
				ctx = NULL;
120
			}
121
		}
122
	}
103
123
104
	return ctx;
124
	return ctx;
105
}
125
}
Lines 423-465 Link Here
423
		int                   num_devices;
443
		int                   num_devices;
424
		NautilusBurnMediaType type;
444
		NautilusBurnMediaType type;
425
		char                 *hal_type;
445
		char                 *hal_type;
446
		DBusError error;
426
		
447
		
427
		ctx = get_hal_context ();
448
		ctx = get_hal_context ();
449
450
		dbus_error_init (&error);
428
		if (ctx != NULL) {
451
		if (ctx != NULL) {
429
			device_names = hal_manager_find_device_string_match (ctx, 
452
			device_names = libhal_manager_find_device_string_match (ctx, 
430
									     "info.parent",
453
										"info.parent",
431
									     drive->priv->udi,
454
										drive->priv->udi,
432
									     &num_devices);
455
										&num_devices,
433
			if (num_devices == 0) {
456
										&error);
457
458
			if (dbus_error_is_set (&error)) {
459
				g_warning ("%s\n", error.message);
460
				dbus_error_free (&error);
434
				return NAUTILUS_BURN_MEDIA_TYPE_ERROR;
461
				return NAUTILUS_BURN_MEDIA_TYPE_ERROR;
435
			}
462
			}
436
463
464
			if (num_devices == 0)
465
				return NAUTILUS_BURN_MEDIA_TYPE_ERROR;
466
			
467
437
			/* just look at the first child */
468
			/* just look at the first child */
438
			if (hal_device_get_property_bool (ctx, 
469
			if (libhal_device_get_property_bool (ctx, 
439
							  device_names [0],
470
							     device_names [0],
440
							  "volume.is_mounted")) {
471
							     "volume.is_mounted",
472
							     NULL)) {
441
				type = NAUTILUS_BURN_MEDIA_TYPE_BUSY;
473
				type = NAUTILUS_BURN_MEDIA_TYPE_BUSY;
442
			} else {		    
474
			} else {
475
			
443
				if (is_rewritable)
476
				if (is_rewritable)
444
					*is_rewritable = hal_device_get_property_bool (ctx, 
477
					*is_rewritable = libhal_device_get_property_bool (ctx, 
445
										       device_names [0],
478
									 		  device_names [0],
446
										       "volume.disc.is_rewritable");
479
											  "volume.disc.is_rewritable",
480
											  NULL);
481
447
				if (is_blank)
482
				if (is_blank)
448
					*is_blank = hal_device_get_property_bool (ctx, 
483
					*is_blank = libhal_device_get_property_bool (ctx, 
449
										  device_names [0],
484
										     device_names [0],
450
										  "volume.disc.is_blank");
485
										     "volume.disc.is_blank",
486
										     NULL);
487
451
				if (has_data)
488
				if (has_data)
452
					*has_data = hal_device_get_property_bool (ctx, 
489
					*has_data = libhal_device_get_property_bool (ctx, 
453
										  device_names [0],
490
										     device_names [0],
454
										  "volume.disc.has_data");
491
										     "volume.disc.has_data",
492
										     NULL);
493
455
				if (has_audio)
494
				if (has_audio)
456
					*has_audio = hal_device_get_property_bool (ctx, 
495
					*has_audio = libhal_device_get_property_bool (ctx, 
457
										  device_names [0],
496
										      device_names [0],
458
										  "volume.disc.has_audio");
497
										      "volume.disc.has_audio",
498
										      NULL);
499
459
				type = NAUTILUS_BURN_MEDIA_TYPE_BUSY;
500
				type = NAUTILUS_BURN_MEDIA_TYPE_BUSY;
460
				hal_type = hal_device_get_property_string (ctx, 
501
				hal_type = libhal_device_get_property_string (ctx, 
461
									   device_names [0],
502
									      device_names [0],
462
									   "volume.disc.type");
503
									      "volume.disc.type",
504
									      NULL);
505
463
				if (hal_type == NULL || strcmp (hal_type, "unknown") == 0) {
506
				if (hal_type == NULL || strcmp (hal_type, "unknown") == 0) {
464
					type = NAUTILUS_BURN_MEDIA_TYPE_UNKNOWN;
507
					type = NAUTILUS_BURN_MEDIA_TYPE_UNKNOWN;
465
				} else if (strcmp (hal_type, "cd_rom") == 0) {
508
				} else if (strcmp (hal_type, "cd_rom") == 0) {
Lines 485-494 Link Here
485
				}
528
				}
486
				
529
				
487
				if (hal_type != NULL)
530
				if (hal_type != NULL)
488
					hal_free_string (hal_type);
531
					libhal_free_string (hal_type);
489
			}
532
			}
490
533
491
			hal_free_string_array (device_names);
534
			libhal_free_string_array (device_names);
492
535
493
			return type;
536
			return type;
494
		}
537
		}
Lines 789-795 Link Here
789
832
790
#ifdef USE_HAL
833
#ifdef USE_HAL
791
834
792
#define GET_BOOL_PROP(x) (hal_device_property_exists (ctx, device_names [i], x) && hal_device_get_property_bool (ctx, device_names [i], x))
835
#define GET_BOOL_PROP(x) (libhal_device_property_exists (ctx, device_names [i], x, NULL) && libhal_device_get_property_bool (ctx, device_names [i], x, NULL))
793
836
794
static GList *
837
static GList *
795
hal_scan (gboolean recorder_only)
838
hal_scan (gboolean recorder_only)
Lines 805-812 Link Here
805
		return NULL;
848
		return NULL;
806
	}
849
	}
807
850
808
	device_names = hal_find_device_by_capability (ctx,
851
	device_names = libhal_find_device_by_capability (ctx,
809
						      "storage.cdrom", &num_devices);
852
						         "storage.cdrom", 
853
							 &num_devices,
854
							 NULL);
810
855
811
	if (device_names == NULL)
856
	if (device_names == NULL)
812
		return NULL;
857
		return NULL;
Lines 827-873 Link Here
827
		if (GET_BOOL_PROP ("storage.cdrom.cdrw")) {
872
		if (GET_BOOL_PROP ("storage.cdrom.cdrw")) {
828
			drive->type |= NAUTILUS_BURN_DRIVE_TYPE_CDRW_RECORDER;
873
			drive->type |= NAUTILUS_BURN_DRIVE_TYPE_CDRW_RECORDER;
829
		}
874
		}
875
830
		if (GET_BOOL_PROP ("storage.cdrom.dvd")) {
876
		if (GET_BOOL_PROP ("storage.cdrom.dvd")) {
831
			drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_DRIVE;
877
			drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_DRIVE;
832
878
833
			if (GET_BOOL_PROP ("storage.cdrom.dvdram")) {
879
			if (GET_BOOL_PROP ("storage.cdrom.dvdram")) {
834
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_RAM_RECORDER;
880
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_RAM_RECORDER;
835
			}
881
			}
882
836
			if (GET_BOOL_PROP ("storage.cdrom.dvdr")) {
883
			if (GET_BOOL_PROP ("storage.cdrom.dvdr")) {
837
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_RW_RECORDER;
884
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_RW_RECORDER;
838
			}
885
			}
886
839
			if (GET_BOOL_PROP ("storage.cdrom.dvd")) {
887
			if (GET_BOOL_PROP ("storage.cdrom.dvd")) {
840
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_DRIVE;
888
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_DRIVE;
841
			}
889
			}
890
842
			if (GET_BOOL_PROP ("storage.cdrom.dvdplusr")) {
891
			if (GET_BOOL_PROP ("storage.cdrom.dvdplusr")) {
843
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_PLUS_R_RECORDER;
892
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_PLUS_R_RECORDER;
844
			}
893
			}
894
845
			if (GET_BOOL_PROP ("storage.cdrom.dvdplusrw")) {
895
			if (GET_BOOL_PROP ("storage.cdrom.dvdplusrw")) {
846
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_PLUS_RW_RECORDER;
896
				drive->type |= NAUTILUS_BURN_DRIVE_TYPE_DVD_PLUS_RW_RECORDER;
847
			}
897
			}
898
848
		}
899
		}
849
900
850
		drive->device = hal_device_get_property_string (ctx,
901
		drive->device = libhal_device_get_property_string (ctx,
851
								device_names [i], "block.device");
902
								   device_names [i], 
903
								   "block.device",
904
								   NULL);
905
852
		drive->cdrecord_id = g_strdup (drive->device);
906
		drive->cdrecord_id = g_strdup (drive->device);
853
907
854
		string = hal_device_get_property_string (ctx,
908
		string = libhal_device_get_property_string (ctx,
855
							 device_names [i], "storage.model");
909
							    device_names [i], 
910
							    "storage.model",
911
							    NULL);
912
856
		if (string != NULL) {
913
		if (string != NULL) {
857
			drive->display_name = string;
914
			drive->display_name = string;
858
		} else {
915
		} else {
859
			drive->display_name = g_strdup_printf ("Unnamed Drive (%s)", drive->device);
916
			drive->display_name = g_strdup_printf ("Unnamed Drive (%s)", drive->device);
860
		}
917
		}
861
918
862
		drive->max_speed_read = hal_device_get_property_int
919
		drive->max_speed_read = libhal_device_get_property_int
863
			(ctx, device_names [i], "storage.cdrom.read_speed")
920
			(ctx, device_names [i], "storage.cdrom.read_speed", NULL)
864
			/ CD_ROM_SPEED;
921
			/ CD_ROM_SPEED;
865
922
866
		if (hal_device_property_exists (ctx, device_names [i], "storage.cdrom.write_speed")) {
923
		if (libhal_device_property_exists (ctx, device_names [i], "storage.cdrom.write_speed", NULL)) {
867
			drive->max_speed_write = hal_device_get_property_int
924
			drive->max_speed_write = libhal_device_get_property_int
868
				(ctx, device_names [i],
925
				(ctx, device_names [i],
869
				 "storage.cdrom.write_speed")
926
				 "storage.cdrom.write_speed",
927
				 NULL)
870
				/ CD_ROM_SPEED;
928
				/ CD_ROM_SPEED;
929
871
		}
930
		}
872
931
873
		add_whitelist (drive);
932
		add_whitelist (drive);
Lines 881-887 Link Here
881
		drive->priv->udi = g_strdup (device_names [i]);
940
		drive->priv->udi = g_strdup (device_names [i]);
882
	}
941
	}
883
942
884
	hal_free_string_array (device_names);
943
	libhal_free_string_array (device_names);
885
944
886
	drives = g_list_reverse (drives);
945
	drives = g_list_reverse (drives);
887
946
Lines 1848-1860 Link Here
1848
	if (drive->priv->udi != NULL) {
1907
	if (drive->priv->udi != NULL) {
1849
		LibHalContext *ctx;
1908
		LibHalContext *ctx;
1850
		char *dbus_reason;
1909
		char *dbus_reason;
1910
		DBusError error;
1851
		
1911
		
1912
		dbus_error_init (&error);
1852
		ctx = get_hal_context ();
1913
		ctx = get_hal_context ();
1853
		if (ctx != NULL) {
1914
		if (ctx != NULL) {
1854
			res = hal_device_lock (ctx, 
1915
			res = libhal_device_lock (ctx, 
1855
					       drive->priv->udi,
1916
					       drive->priv->udi,
1856
					       reason,
1917
					       reason,
1857
					       &dbus_reason);
1918
					       &dbus_reason,
1919
					       &error);
1920
1921
			if (dbus_error_is_set (&error))
1922
				dbus_error_free (&error);
1923
				
1858
			if (dbus_reason != NULL && 
1924
			if (dbus_reason != NULL && 
1859
			    reason_for_failure != NULL)
1925
			    reason_for_failure != NULL)
1860
				*reason_for_failure = g_strdup (dbus_reason);
1926
				*reason_for_failure = g_strdup (dbus_reason);
Lines 1885-1895 Link Here
1885
#ifdef USE_HAL
1951
#ifdef USE_HAL
1886
	if (drive->priv->udi != NULL) {
1952
	if (drive->priv->udi != NULL) {
1887
		LibHalContext *ctx;
1953
		LibHalContext *ctx;
1954
		DBusError error;
1888
1955
1956
		dbus_error_init (&error);
1889
		ctx = get_hal_context ();
1957
		ctx = get_hal_context ();
1890
		if (ctx != NULL) {
1958
		if (ctx != NULL) {
1891
			res = hal_device_unlock (ctx, 
1959
			res = libhal_device_unlock (ctx, 
1892
						 drive->priv->udi);
1960
						    drive->priv->udi,
1961
						    &error);
1962
1963
			if (dbus_error_is_set (&error))
1964
				dbus_error_free (&error);
1893
		}
1965
		}
1894
	}
1966
	}
1895
#endif
1967
#endif

Return to bug 91928