~ubuntu-branches/ubuntu/quantal/colord/quantal-proposed

« back to all changes in this revision

Viewing changes to src/cd-device.c

  • Committer: Package Import Robot
  • Author(s): Sjoerd Simons
  • Date: 2011-10-25 16:21:20 UTC
  • mto: (2.1.1 sid) (1.1.2)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: package-import@ubuntu.com-20111025162120-0aypjqn1zx9n6vgf
Tags: upstream-0.1.13
ImportĀ upstreamĀ versionĀ 0.1.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
        gchar                           *kind;
65
65
        gchar                           *object_path;
66
66
        GDBusConnection                 *connection;
67
 
        GPtrArray                       *profiles;
68
 
        GPtrArray                       *profiles_soft;
69
 
        GPtrArray                       *profiles_hard;
 
67
        GPtrArray                       *profiles; /* of CdDeviceProfileItem */
70
68
        guint                            registration_id;
71
69
        guint                            watcher_id;
72
70
        guint64                          created;
73
71
        guint64                          modified;
 
72
        gboolean                         require_modified_signal;
74
73
        gboolean                         is_virtual;
75
74
        GHashTable                      *metadata;
 
75
        guint                            owner;
76
76
};
77
77
 
78
78
enum {
87
87
        PROP_LAST
88
88
};
89
89
 
 
90
typedef struct {
 
91
        CdProfile               *profile;
 
92
        CdDeviceRelation         relation;
 
93
        guint64                  timestamp;
 
94
} CdDeviceProfileItem;
 
95
 
90
96
static guint signals[SIGNAL_LAST] = { 0 };
91
97
G_DEFINE_TYPE (CdDevice, cd_device, G_TYPE_OBJECT)
92
98
 
 
99
#if !GLIB_CHECK_VERSION (2, 25, 0)
 
100
static guint64
 
101
g_get_real_time (void)
 
102
{
 
103
        struct timeval tm;
 
104
        gettimeofday (&tm, NULL);
 
105
        return tm.tv_sec;
 
106
}
 
107
#endif
 
108
 
93
109
/**
94
110
 * cd_device_get_scope:
95
111
 **/
111
127
}
112
128
 
113
129
/**
 
130
 * cd_device_set_owner:
 
131
 **/
 
132
void
 
133
cd_device_set_owner (CdDevice *device, guint owner)
 
134
{
 
135
        g_return_if_fail (CD_IS_DEVICE (device));
 
136
        device->priv->owner = owner;
 
137
}
 
138
 
 
139
/**
114
140
 * cd_device_mode_to_string:
115
141
 **/
116
142
static const gchar *
124
150
}
125
151
 
126
152
/**
 
153
 * _cd_device_mode_from_string:
 
154
 **/
 
155
static CdDeviceMode
 
156
_cd_device_mode_from_string (const gchar *device_mode)
 
157
{
 
158
        if (g_strcmp0 (device_mode, "physical") == 0)
 
159
                return CD_DEVICE_MODE_PHYSICAL;
 
160
        if (g_strcmp0 (device_mode, "virtual") == 0)
 
161
                return CD_DEVICE_MODE_VIRTUAL;
 
162
        return CD_DEVICE_MODE_UNKNOWN;
 
163
}
 
164
 
 
165
/**
127
166
 * cd_device_set_mode:
128
167
 **/
129
168
void
135
174
}
136
175
 
137
176
/**
 
177
 * cd_device_get_mode:
 
178
 **/
 
179
CdDeviceMode
 
180
cd_device_get_mode (CdDevice *device)
 
181
{
 
182
        g_return_val_if_fail (CD_IS_DEVICE (device), CD_DEVICE_MODE_UNKNOWN);
 
183
        return _cd_device_mode_from_string (device->priv->mode);
 
184
}
 
185
 
 
186
/**
138
187
 * cd_device_get_object_path:
139
188
 **/
140
189
const gchar *
205
254
#if !GLIB_CHECK_VERSION (2, 25, 0)
206
255
        device->priv->modified = g_get_real_time ();
207
256
#endif
208
 
        cd_device_dbus_emit_property_changed (device,
209
 
                                              "Modified",
210
 
                                              g_variant_new_uint64 (device->priv->modified));
 
257
        device->priv->require_modified_signal = TRUE;
211
258
}
212
259
 
213
260
/**
232
279
                               "{sv}",
233
280
                               property_name,
234
281
                               property_value);
 
282
        if (device->priv->require_modified_signal) {
 
283
                g_variant_builder_add (&builder,
 
284
                                       "{sv}",
 
285
                                       CD_DEVICE_PROPERTY_MODIFIED,
 
286
                                       g_variant_new_uint64 (device->priv->modified));
 
287
                device->priv->require_modified_signal = FALSE;
 
288
        }
235
289
        g_dbus_connection_emit_signal (device->priv->connection,
236
290
                                       NULL,
237
291
                                       device->priv->object_path,
323
377
 * cd_device_find_by_qualifier:
324
378
 **/
325
379
static CdProfile *
326
 
cd_device_find_by_qualifier (const gchar *regex, GPtrArray *array)
 
380
cd_device_find_by_qualifier (const gchar *regex,
 
381
                             GPtrArray *array,
 
382
                             CdDeviceRelation relation)
327
383
{
 
384
        CdDeviceProfileItem *item;
328
385
        CdProfile *profile = NULL;
329
 
        CdProfile *profile_tmp;
330
386
        const gchar *qualifier;
331
387
        gboolean ret;
332
388
        guint i;
333
389
 
334
390
        /* find using a wildcard */
335
391
        for (i=0; i<array->len; i++) {
336
 
                profile_tmp = g_ptr_array_index (array, i);
 
392
                item = g_ptr_array_index (array, i);
 
393
                if (item->relation != relation)
 
394
                        continue;
337
395
 
338
396
                /* '*' matches anything, including a blank qualifier */
339
397
                if (g_strcmp0 (regex, "*") == 0) {
340
398
                        g_debug ("anything matches, returning %s",
341
 
                                 cd_profile_get_id (profile_tmp));
342
 
                        profile = profile_tmp;
 
399
                                 cd_profile_get_id (item->profile));
 
400
                        profile = item->profile;
343
401
                        goto out;
344
402
                }
345
403
 
346
404
                /* match with a regex */
347
 
                qualifier = cd_profile_get_qualifier (profile_tmp);
 
405
                qualifier = cd_profile_get_qualifier (item->profile);
348
406
                if (qualifier == NULL) {
349
407
                        g_debug ("no qualifier for %s, skipping",
350
 
                                 cd_profile_get_id (profile_tmp));
 
408
                                 cd_profile_get_id (item->profile));
351
409
                        continue;
352
410
                }
353
411
                ret = cd_device_match_qualifier (regex,
357
415
                         regex,
358
416
                         qualifier);
359
417
                if (ret) {
360
 
                        profile = profile_tmp;
 
418
                        profile = item->profile;
361
419
                        goto out;
362
420
                }
363
421
        }
371
429
static CdProfile *
372
430
cd_device_find_profile_by_object_path (GPtrArray *array, const gchar *object_path)
373
431
{
 
432
        CdDeviceProfileItem *item;
374
433
        CdProfile *profile = NULL;
375
 
        CdProfile *profile_tmp;
 
434
        gboolean ret;
376
435
        guint i;
377
 
        gboolean ret;
378
436
 
379
437
        /* find using an object path */
380
438
        for (i=0; i<array->len; i++) {
381
 
                profile_tmp = g_ptr_array_index (array, i);
 
439
                item = g_ptr_array_index (array, i);
382
440
                ret = (g_strcmp0 (object_path,
383
 
                                  cd_profile_get_object_path (profile_tmp)) == 0);
 
441
                                  cd_profile_get_object_path (item->profile)) == 0);
384
442
                if (ret) {
385
 
                        profile = profile_tmp;
 
443
                        profile = item->profile;
386
444
                        goto out;
387
445
                }
388
446
        }
396
454
static GVariant *
397
455
cd_device_get_profiles_as_variant (CdDevice *device)
398
456
{
399
 
        CdProfile *profile;
400
457
        guint i;
401
458
        guint idx = 0;
402
459
        GVariant **profiles = NULL;
403
460
        GVariant *value;
 
461
        const gchar *tmp;
 
462
        CdDeviceProfileItem *item;
404
463
 
405
464
        /* copy the object paths, hard then soft */
406
465
        profiles = g_new0 (GVariant *, device->priv->profiles->len + 1);
407
 
        for (i=0; i<device->priv->profiles_hard->len; i++) {
408
 
                profile = g_ptr_array_index (device->priv->profiles_hard, i);
409
 
                profiles[idx++] = g_variant_new_object_path (cd_profile_get_object_path (profile));
 
466
        for (i=0; i<device->priv->profiles->len; i++) {
 
467
                item = g_ptr_array_index (device->priv->profiles, i);
 
468
                if (item->relation == CD_DEVICE_RELATION_SOFT)
 
469
                        continue;
 
470
                tmp = cd_profile_get_object_path (item->profile);
 
471
                profiles[idx++] = g_variant_new_object_path (tmp);
410
472
        }
411
 
        for (i=0; i<device->priv->profiles_soft->len; i++) {
412
 
                profile = g_ptr_array_index (device->priv->profiles_soft, i);
413
 
                profiles[idx++] = g_variant_new_object_path (cd_profile_get_object_path (profile));
 
473
        for (i=0; i<device->priv->profiles->len; i++) {
 
474
                item = g_ptr_array_index (device->priv->profiles, i);
 
475
                if (item->relation == CD_DEVICE_RELATION_HARD)
 
476
                        continue;
 
477
                tmp = cd_profile_get_object_path (item->profile);
 
478
                profiles[idx++] = g_variant_new_object_path (tmp);
414
479
        }
415
480
 
416
481
        /* format the value */
430
495
                          GError **error)
431
496
{
432
497
        CdDevicePrivate *priv = device->priv;
433
 
        CdProfile *profile_tmp;
 
498
        CdDeviceProfileItem *item;
434
499
        gboolean ret = FALSE;
435
500
        guint i;
436
501
 
437
502
        /* check the profile exists on this device */
438
503
        for (i=0; i<priv->profiles->len; i++) {
439
 
                profile_tmp = g_ptr_array_index (priv->profiles, i);
 
504
                item = g_ptr_array_index (priv->profiles, i);
440
505
                if (g_strcmp0 (profile_object_path,
441
 
                               cd_profile_get_object_path (profile_tmp)) == 0) {
 
506
                               cd_profile_get_object_path (item->profile)) == 0) {
442
507
                        ret = TRUE;
443
508
                        break;
444
509
                }
454
519
        }
455
520
 
456
521
        /* remove from the arrays */
457
 
        g_ptr_array_remove (priv->profiles_soft, profile_tmp);
458
 
        g_ptr_array_remove (priv->profiles_hard, profile_tmp);
459
 
        ret = g_ptr_array_remove (priv->profiles, profile_tmp);
 
522
        ret = g_ptr_array_remove (priv->profiles, item);
460
523
        g_assert (ret);
461
524
 
 
525
        /* reset modification time */
 
526
        cd_device_reset_modified (device);
 
527
 
462
528
        /* emit */
463
529
        cd_device_dbus_emit_property_changed (device,
464
530
                                              "Profiles",
465
531
                                              cd_device_get_profiles_as_variant (device));
466
532
 
467
 
        /* reset modification time */
468
 
        cd_device_reset_modified (device);
469
 
 
470
533
        /* emit global signal */
471
534
        cd_device_dbus_emit_device_changed (device);
472
535
out:
481
544
                                 const gchar *profile_object_path)
482
545
{
483
546
        CdDevicePrivate *priv = device->priv;
 
547
        CdDeviceProfileItem *item;
484
548
        CdDeviceRelation relation = CD_DEVICE_RELATION_UNKNOWN;
485
 
        CdProfile *profile_tmp;
486
549
        guint i;
487
550
 
488
 
        /* search hard */
489
 
        for (i=0; i<priv->profiles_hard->len; i++) {
490
 
                profile_tmp = g_ptr_array_index (priv->profiles_hard, i);
491
 
                if (g_strcmp0 (profile_object_path,
492
 
                               cd_profile_get_object_path (profile_tmp)) == 0) {
493
 
                        relation = CD_DEVICE_RELATION_HARD;
494
 
                        goto out;
495
 
                }
496
 
        }
497
 
 
498
 
        /* search soft */
499
 
        for (i=0; i<priv->profiles_soft->len; i++) {
500
 
                profile_tmp = g_ptr_array_index (priv->profiles_soft, i);
501
 
                if (g_strcmp0 (profile_object_path,
502
 
                               cd_profile_get_object_path (profile_tmp)) == 0) {
503
 
                        relation = CD_DEVICE_RELATION_SOFT;
 
551
        /* search profiles */
 
552
        for (i=0; i<priv->profiles->len; i++) {
 
553
                item = g_ptr_array_index (priv->profiles, i);
 
554
                if (g_strcmp0 (profile_object_path,
 
555
                               cd_profile_get_object_path (item->profile)) == 0) {
 
556
                        relation = item->relation;
504
557
                        goto out;
505
558
                }
506
559
        }
521
574
        return "unknown";
522
575
}
523
576
 
524
 
static void
525
 
_g_ptr_array_insert (GPtrArray *array, guint idx, gpointer data)
 
577
/**
 
578
 * cd_device_add_profile:
 
579
 **/
 
580
static gint
 
581
cd_device_profile_item_sort_cb (gconstpointer a, gconstpointer b)
526
582
{
527
 
        g_return_if_fail (idx <= array->len);
 
583
        gint64 tmp;
 
584
        CdDeviceProfileItem **item_a = (CdDeviceProfileItem **) a;
 
585
        CdDeviceProfileItem **item_b = (CdDeviceProfileItem **) b;
528
586
 
529
 
        g_ptr_array_add (array, NULL);
530
 
        g_memmove (&array->pdata[idx+1],
531
 
                   &array->pdata[idx+0],
532
 
                   (array->len - idx - 1) * sizeof (gpointer));
533
 
        array->pdata[idx] = data;
 
587
        tmp = (gint64) (*item_b)->timestamp - (gint64) (*item_a)->timestamp;
 
588
        if (tmp < 0)
 
589
                return -1;
 
590
        if (tmp > 0)
 
591
                return 1;
 
592
        return 0;
534
593
}
535
594
 
536
595
/**
540
599
cd_device_add_profile (CdDevice *device,
541
600
                       CdDeviceRelation relation,
542
601
                       const gchar *profile_object_path,
 
602
                       guint64 timestamp,
543
603
                       GError **error)
544
604
{
545
605
        CdDevicePrivate *priv = device->priv;
 
606
        CdDeviceProfileItem *item;
546
607
        CdProfile *profile;
547
 
        CdProfile *profile_tmp;
548
608
        gboolean ret = TRUE;
549
609
        guint i;
550
610
 
563
623
 
564
624
        /* check it does not already exist */
565
625
        for (i=0; i<priv->profiles->len; i++) {
566
 
                profile_tmp = g_ptr_array_index (priv->profiles, i);
 
626
                item = g_ptr_array_index (priv->profiles, i);
567
627
                if (g_strcmp0 (cd_profile_get_object_path (profile),
568
 
                               cd_profile_get_object_path (profile_tmp)) == 0) {
 
628
                               cd_profile_get_object_path (item->profile)) == 0) {
569
629
                        ret = FALSE;
570
630
                        g_set_error (error,
571
631
                                     CD_MAIN_ERROR,
581
641
                 cd_profile_get_id (profile),
582
642
                 _cd_device_relation_to_string (relation),
583
643
                 device->priv->id);
584
 
        _g_ptr_array_insert (priv->profiles, 0, g_object_ref (profile));
585
 
        if (relation == CD_DEVICE_RELATION_SOFT)
586
 
                _g_ptr_array_insert (priv->profiles_soft, 0, g_object_ref (profile));
587
 
        if (relation == CD_DEVICE_RELATION_HARD)
588
 
                _g_ptr_array_insert (priv->profiles_hard, 0, g_object_ref (profile));
 
644
        item = g_new0 (CdDeviceProfileItem, 1);
 
645
        item->profile = g_object_ref (profile);
 
646
        item->relation = relation;
 
647
        item->timestamp = timestamp;
 
648
        g_ptr_array_add (priv->profiles, item);
 
649
        g_ptr_array_sort (priv->profiles,
 
650
                          cd_device_profile_item_sort_cb);
 
651
 
 
652
        /* reset modification time */
 
653
        cd_device_reset_modified (device);
589
654
 
590
655
        /* emit */
591
656
        cd_device_dbus_emit_property_changed (device,
592
657
                                              "Profiles",
593
658
                                              cd_device_get_profiles_as_variant (device));
594
659
 
595
 
        /* reset modification time */
596
 
        cd_device_reset_modified (device);
597
 
 
598
660
        /* emit global signal */
599
661
        cd_device_dbus_emit_device_changed (device);
600
662
out:
775
837
                                     g_strdup (property),
776
838
                                     g_strdup (value));
777
839
                cd_device_dbus_emit_property_changed (device,
778
 
                                                       CD_DEVICE_PROPERTY_METADATA,
779
 
                                                       cd_device_get_metadata_as_variant (device));
 
840
                                                      CD_DEVICE_PROPERTY_METADATA,
 
841
                                                      cd_device_get_metadata_as_variant (device));
780
842
        }
781
843
 
782
844
        /* set this externally so we can add disk devices at startup
819
881
                        const gchar *profile_object_path,
820
882
                        GError **error)
821
883
{
 
884
        CdDeviceProfileItem *item;
822
885
        CdProfile *profile;
823
 
        CdProfile *profile_tmp;
824
886
        guint i;
825
887
        gboolean ret = FALSE;
826
888
        CdDevicePrivate *priv = device->priv;
837
899
 
838
900
        /* make the profile first in the array */
839
901
        for (i=1; i<priv->profiles->len; i++) {
840
 
                profile_tmp = g_ptr_array_index (priv->profiles, i);
841
 
                if (profile_tmp == profile) {
842
 
                        /* swap [0] and [i] */
843
 
                        g_debug ("CdDevice: making %s the default on %s",
844
 
                                 profile_object_path,
845
 
                                 priv->object_path);
846
 
                        profile_tmp = priv->profiles->pdata[0];
847
 
                        priv->profiles->pdata[0] = profile;
848
 
                        priv->profiles->pdata[i] = profile_tmp;
849
 
                        break;
850
 
                }
851
 
        }
852
 
 
853
 
        /* ensure profile is in the 'hard' relation array */
854
 
        ret = g_ptr_array_remove (priv->profiles_soft, profile);
855
 
        if (ret)
856
 
                g_ptr_array_add (priv->profiles_hard, g_object_ref (profile));
857
 
 
858
 
        /* make the profile first in the hard array */
859
 
        for (i=1; i<priv->profiles_hard->len; i++) {
860
 
                profile_tmp = g_ptr_array_index (priv->profiles_hard, i);
861
 
                if (profile_tmp == profile) {
862
 
                        /* swap [0] and [i] */
863
 
                        profile_tmp = priv->profiles_hard->pdata[0];
864
 
                        priv->profiles_hard->pdata[0] = profile;
865
 
                        priv->profiles_hard->pdata[i] = profile_tmp;
866
 
                        break;
867
 
                }
868
 
        }
 
902
                item = g_ptr_array_index (priv->profiles, i);
 
903
                if (item->profile == profile) {
 
904
                        item->timestamp = g_get_real_time ();
 
905
                        item->relation = CD_DEVICE_RELATION_HARD;
 
906
                        g_ptr_array_sort (priv->profiles,
 
907
                                          cd_device_profile_item_sort_cb);
 
908
                        break;
 
909
                }
 
910
        }
 
911
 
 
912
        /* reset modification time */
 
913
        cd_device_reset_modified (device);
869
914
 
870
915
        /* emit */
871
916
        cd_device_dbus_emit_property_changed (device,
912
957
 
913
958
                /* require auth */
914
959
                ret = cd_main_sender_authenticated (invocation,
915
 
                                                    sender,
916
960
                                                    "org.freedesktop.color-manager.modify-device");
917
961
                if (!ret)
918
962
                        goto out;
944
988
                ret = cd_device_add_profile (device,
945
989
                                             relation,
946
990
                                             profile_object_path,
 
991
                                             g_get_real_time (),
947
992
                                             &error);
948
993
                if (!ret) {
949
994
                        g_dbus_method_invocation_return_error (invocation,
981
1026
 
982
1027
                /* require auth */
983
1028
                ret = cd_main_sender_authenticated (invocation,
984
 
                                                    sender,
985
1029
                                                    "org.freedesktop.color-manager.modify-device");
986
1030
                if (!ret)
987
1031
                        goto out;
1078
1122
                        if (i == 0)
1079
1123
                                g_debug ("searching [hard]");
1080
1124
                        profile = cd_device_find_by_qualifier (regexes[i],
1081
 
                                                               priv->profiles_hard);
 
1125
                                                               priv->profiles,
 
1126
                                                               CD_DEVICE_RELATION_HARD);
1082
1127
                }
1083
1128
                for (i=0; profile == NULL && regexes[i] != NULL; i++) {
1084
1129
                        if (i == 0)
1085
1130
                                g_debug ("searching [soft]");
1086
1131
                        profile = cd_device_find_by_qualifier (regexes[i],
1087
 
                                                               priv->profiles_soft);
 
1132
                                                               priv->profiles,
 
1133
                                                               CD_DEVICE_RELATION_SOFT);
1088
1134
                }
1089
1135
                if (profile == NULL) {
1090
1136
                        g_dbus_method_invocation_return_error (invocation,
1106
1152
 
1107
1153
                /* require auth */
1108
1154
                ret = cd_main_sender_authenticated (invocation,
1109
 
                                                    sender,
1110
1155
                                                    "org.freedesktop.color-manager.modify-device");
1111
1156
                if (!ret)
1112
1157
                        goto out;
1125
1170
                        g_dbus_method_invocation_return_error (invocation,
1126
1171
                                                               CD_MAIN_ERROR,
1127
1172
                                                               CD_MAIN_ERROR_FAILED,
1128
 
                                                               "failed to make profile default",
 
1173
                                                               "failed to make profile default: %s",
1129
1174
                                                               error->message);
1130
1175
                        g_error_free (error);
1131
1176
                        goto out;
1157
1202
 
1158
1203
                /* require auth */
1159
1204
                ret = cd_main_sender_authenticated (invocation,
1160
 
                                                    sender,
1161
1205
                                                    "org.freedesktop.color-manager.modify-device");
1162
1206
                if (!ret)
1163
1207
                        goto out;
1190
1234
 
1191
1235
                /* require auth */
1192
1236
                ret = cd_main_sender_authenticated (invocation,
1193
 
                                                    sender,
1194
1237
                                                    "org.freedesktop.color-manager.device-inhibit");
1195
1238
                if (!ret)
1196
1239
                        goto out;
1347
1390
                retval = g_variant_new_string (cd_object_scope_to_string (priv->object_scope));
1348
1391
                goto out;
1349
1392
        }
 
1393
        if (g_strcmp0 (property_name, CD_DEVICE_PROPERTY_OWNER) == 0) {
 
1394
                retval = g_variant_new_uint32 (priv->owner);
 
1395
                goto out;
 
1396
        }
1350
1397
 
1351
1398
        g_critical ("failed to get property %s", property_name);
1352
1399
out:
1516
1563
}
1517
1564
 
1518
1565
/**
 
1566
 * cd_device_profiles_item_free:
 
1567
 **/
 
1568
static void
 
1569
cd_device_profiles_item_free (CdDeviceProfileItem *item)
 
1570
{
 
1571
        g_object_unref (item->profile);
 
1572
        g_free (item);
 
1573
}
 
1574
 
 
1575
/**
1519
1576
 * cd_device_init:
1520
1577
 **/
1521
1578
static void
1522
1579
cd_device_init (CdDevice *device)
1523
1580
{
1524
1581
        device->priv = CD_DEVICE_GET_PRIVATE (device);
1525
 
        device->priv->profiles = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
1526
 
        device->priv->profiles_soft = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
1527
 
        device->priv->profiles_hard = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 
1582
        device->priv->profiles = g_ptr_array_new_with_free_func ((GDestroyNotify) cd_device_profiles_item_free);
1528
1583
        device->priv->profile_array = cd_profile_array_new ();
1529
 
#if !GLIB_CHECK_VERSION (2, 25, 0)
1530
1584
        device->priv->created = g_get_real_time ();
1531
1585
        device->priv->modified = g_get_real_time ();
1532
 
#else
1533
 
        {
1534
 
                struct timeval tm;
1535
 
                gettimeofday (&tm, NULL);
1536
 
                device->priv->created = tm.tv_sec;
1537
 
                device->priv->modified = tm.tv_sec;
1538
 
        }
1539
 
#endif
1540
1586
        device->priv->mapping_db = cd_mapping_db_new ();
1541
1587
        device->priv->device_db = cd_device_db_new ();
1542
1588
        device->priv->inhibit = cd_inhibit_new ();
1578
1624
        g_free (priv->kind);
1579
1625
        g_free (priv->object_path);
1580
1626
        g_ptr_array_unref (priv->profiles);
1581
 
        g_ptr_array_unref (priv->profiles_soft);
1582
 
        g_ptr_array_unref (priv->profiles_hard);
1583
1627
        g_object_unref (priv->profile_array);
1584
1628
        g_object_unref (priv->mapping_db);
1585
1629
        g_object_unref (priv->device_db);