242
* cd_main_device_auto_add_profile:
245
cd_main_device_auto_add_profile (CdDevice *device, CdProfile *profile)
247
gboolean ret = FALSE;
248
GError *error = NULL;
251
g_debug ("CdMain: Automatically add %s to %s",
252
cd_profile_get_id (profile),
253
cd_device_get_object_path (device));
254
timestamp = cd_mapping_db_get_timestamp (mapping_db,
255
cd_device_get_id (device),
256
cd_profile_get_id (profile),
258
if (timestamp == G_MAXUINT64) {
259
g_debug ("CdMain: failed to assign, non-fatal: %s",
261
g_error_free (error);
264
ret = cd_device_add_profile (device,
265
CD_DEVICE_RELATION_HARD,
266
cd_profile_get_object_path (profile),
270
g_debug ("CdMain: failed to assign, non-fatal: %s",
272
g_error_free (error);
242
280
* cd_main_device_auto_add_profiles:
268
305
profile_tmp = cd_profile_array_get_by_id (profiles_array,
270
307
if (profile_tmp != NULL) {
271
g_debug ("CdMain: Automatically add %s to %s",
273
cd_device_get_object_path (device));
274
ret = cd_device_add_profile (device,
275
CD_DEVICE_RELATION_HARD,
276
cd_profile_get_object_path (profile_tmp),
279
g_debug ("CdMain: failed to assign, non-fatal: %s",
281
g_clear_error (&error);
308
cd_main_device_auto_add_profile (device, profile_tmp);
283
309
g_object_unref (profile_tmp);
285
311
g_debug ("CdMain: profile %s is not (yet) available",
531
556
device_tmp = cd_device_array_get_by_id (devices_array,
533
558
if (device_tmp != NULL) {
534
g_debug ("CdMain: Automatically add %s to %s",
535
cd_profile_get_object_path (profile),
537
ret = cd_device_add_profile (device_tmp,
538
CD_DEVICE_RELATION_HARD,
539
cd_profile_get_object_path (profile),
542
g_debug ("CdMain: failed to assign, non-fatal: %s",
544
g_clear_error (&error);
559
cd_main_device_auto_add_profile (device_tmp, profile);
546
560
g_object_unref (device_tmp);
548
562
g_debug ("CdMain: device %s is not (yet) available",
871
885
g_debug ("CdMain: %s:CreateDevice(%s)", sender, device_id);
872
886
scope = cd_object_scope_from_string (scope_tmp);
873
887
device = cd_device_array_get_by_id (devices_array, device_id);
874
if (device == NULL) {
875
device = cd_main_create_device (sender,
878
CD_DEVICE_MODE_UNKNOWN,
880
if (device == NULL) {
881
g_warning ("CdMain: failed to create device: %s",
883
g_dbus_method_invocation_return_gerror (invocation,
885
g_error_free (error);
888
if (device != NULL) {
889
889
/* where we try to manually add an existing
890
890
* virtual device, which means promoting it to
891
891
* an actual physical device */
892
cd_device_set_mode (device,
893
CD_DEVICE_MODE_PHYSICAL);
896
register_on_bus = FALSE;
892
if (cd_device_get_mode (device) == CD_DEVICE_MODE_VIRTUAL) {
893
cd_device_set_mode (device,
894
CD_DEVICE_MODE_PHYSICAL);
895
register_on_bus = FALSE;
897
g_dbus_method_invocation_return_error (invocation,
899
CD_MAIN_ERROR_ALREADY_EXISTS,
900
"device id '%s' already exists",
907
device = cd_main_create_device (sender,
910
CD_DEVICE_MODE_UNKNOWN,
912
if (device == NULL) {
913
g_warning ("CdMain: failed to create device: %s",
915
g_dbus_method_invocation_return_gerror (invocation,
917
g_error_free (error);
922
uid = cd_main_get_sender_uid (invocation, &error);
923
if (uid == G_MAXUINT) {
924
g_dbus_method_invocation_return_error (invocation,
926
CD_MAIN_ERROR_FAILED,
927
"failed to get owner: %s",
929
g_error_free (error);
932
cd_device_set_owner (device, uid);
899
934
/* set the properties */
900
935
while (g_variant_iter_next (iter, "{&s&s}",
1022
1054
g_debug ("CdMain: %s:CreateProfile(%s)", sender, device_id);
1023
1055
profile = cd_profile_array_get_by_id (profiles_array,
1057
if (profile != NULL) {
1058
g_dbus_method_invocation_return_error (invocation,
1060
CD_MAIN_ERROR_ALREADY_EXISTS,
1061
"profile id '%s' already exists",
1025
1065
scope = cd_object_scope_from_string (scope_tmp);
1066
profile = cd_main_create_profile (sender,
1026
1070
if (profile == NULL) {
1027
profile = cd_main_create_profile (sender,
1031
if (profile == NULL) {
1032
g_dbus_method_invocation_return_gerror (invocation,
1037
/* not new profile */
1038
register_on_bus = FALSE;
1071
g_dbus_method_invocation_return_gerror (invocation,
1077
uid = cd_main_get_sender_uid (invocation, &error);
1078
if (uid == G_MAXUINT) {
1079
g_dbus_method_invocation_return_error (invocation,
1081
CD_MAIN_ERROR_FAILED,
1082
"failed to get owner: %s",
1084
g_error_free (error);
1087
cd_profile_set_owner (profile, uid);
1041
1089
/* auto add profiles from the database */
1042
1090
cd_main_profile_auto_add_to_device (profile);
1087
1135
/* register on bus */
1088
if (register_on_bus) {
1089
ret = cd_main_profile_register_on_bus (profile, &error);
1091
g_dbus_method_invocation_return_gerror (invocation,
1093
g_error_free (error);
1136
ret = cd_main_profile_register_on_bus (profile, &error);
1138
g_dbus_method_invocation_return_gerror (invocation,
1140
g_error_free (error);
1098
1144
/* format the value */
1178
1224
profile_id = g_strdup_printf ("icc-%s",
1179
1225
cd_profile_get_checksum (profile));
1180
1226
cd_profile_set_id (profile, profile_id);
1181
cd_profile_set_is_system_wide (profile, TRUE);
1182
1227
ret = cd_main_add_profile (profile, &error);
1184
1229
g_warning ("CdMain: failed to add profile: %s",