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

« back to all changes in this revision

Viewing changes to libcolord/cd-profile.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:
34
34
#include <stdlib.h>
35
35
#include <stdio.h>
36
36
#include <glib.h>
 
37
#include <glib/gstdio.h>
37
38
#include <string.h>
38
39
 
39
40
#include "cd-profile.h"
67
68
        gint64                   created;
68
69
        gboolean                 has_vcgt;
69
70
        gboolean                 is_system_wide;
 
71
        guint                    owner;
70
72
        GHashTable              *metadata;
71
73
};
72
74
 
85
87
        PROP_HAS_VCGT,
86
88
        PROP_IS_SYSTEM_WIDE,
87
89
        PROP_SCOPE,
 
90
        PROP_OWNER,
88
91
        PROP_LAST
89
92
};
90
93
 
167
170
}
168
171
 
169
172
/**
 
173
 * cd_profile_has_access:
 
174
 * @profile: a #CdProfile instance.
 
175
 *
 
176
 * Gets if the current user has access permissions to the profile.
 
177
 *
 
178
 * Return value: A string, or %NULL for invalid
 
179
 *
 
180
 * Since: 0.1.13
 
181
 **/
 
182
gboolean
 
183
cd_profile_has_access (CdProfile *profile)
 
184
{
 
185
        g_return_val_if_fail (CD_IS_PROFILE (profile), FALSE);
 
186
        g_return_val_if_fail (profile->priv->proxy != NULL, FALSE);
 
187
        return g_access (profile->priv->filename, R_OK) == 0;
 
188
}
 
189
 
 
190
/**
170
191
 * cd_profile_get_qualifier:
171
192
 * @profile: a #CdProfile instance.
172
193
 *
257
278
}
258
279
 
259
280
/**
 
281
 * cd_profile_get_owner:
 
282
 * @profile: a #CdProfile instance.
 
283
 *
 
284
 * Gets the profile owner.
 
285
 *
 
286
 * Return value: The UID of the user that created the device
 
287
 *
 
288
 * Since: 0.1.13
 
289
 **/
 
290
guint
 
291
cd_profile_get_owner (CdProfile *profile)
 
292
{
 
293
        g_return_val_if_fail (CD_IS_PROFILE (profile), G_MAXUINT);
 
294
        g_return_val_if_fail (profile->priv->proxy != NULL, G_MAXUINT);
 
295
        return profile->priv->owner;
 
296
}
 
297
 
 
298
/**
260
299
 * cd_profile_get_created:
261
300
 * @profile: a #CdProfile instance.
262
301
 *
558
597
        GVariant *kind = NULL;
559
598
        GVariant *colorspace = NULL;
560
599
        GVariant *scope = NULL;
 
600
        GVariant *owner = NULL;
561
601
        GVariant *created = NULL;
562
602
        GVariant *has_vcgt = NULL;
563
603
        GVariant *is_system_wide = NULL;
585
625
        if (id != NULL)
586
626
                profile->priv->id = g_variant_dup_string (id, NULL);
587
627
 
 
628
        /* if the profile is missing, then fail */
 
629
        if (id == NULL) {
 
630
                g_simple_async_result_set_error (res_source,
 
631
                                                 CD_PROFILE_ERROR,
 
632
                                                 CD_PROFILE_ERROR_FAILED,
 
633
                                                 "Failed to connect to missing profile %s",
 
634
                                                 cd_profile_get_object_path (profile));
 
635
                goto out;
 
636
        }
 
637
 
588
638
        /* get filename */
589
639
        filename = g_dbus_proxy_get_cached_property (profile->priv->proxy,
590
640
                                                     CD_PROFILE_PROPERTY_FILENAME);
627
677
        if (scope != NULL)
628
678
                profile->priv->scope = cd_object_scope_from_string (g_variant_get_string (scope, NULL));
629
679
 
 
680
        /* get owner */
 
681
        owner = g_dbus_proxy_get_cached_property (profile->priv->proxy,
 
682
                                                  CD_PROFILE_PROPERTY_OWNER);
 
683
        if (owner != NULL)
 
684
                profile->priv->owner = g_variant_get_uint32 (owner);
 
685
 
630
686
        /* get created */
631
687
        created = g_dbus_proxy_get_cached_property (profile->priv->proxy,
632
688
                                                    CD_PROFILE_PROPERTY_CREATED);
674
730
                g_variant_unref (colorspace);
675
731
        if (scope != NULL)
676
732
                g_variant_unref (scope);
 
733
        if (owner != NULL)
 
734
                g_variant_unref (owner);
677
735
        if (created != NULL)
678
736
                g_variant_unref (created);
679
737
        if (has_vcgt != NULL)
716
774
        GSimpleAsyncResult *res;
717
775
 
718
776
        g_return_if_fail (CD_IS_PROFILE (profile));
 
777
        g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
719
778
 
720
779
        res = g_simple_async_result_new (G_OBJECT (profile),
721
780
                                         callback,
826
885
        GSimpleAsyncResult *res;
827
886
 
828
887
        g_return_if_fail (CD_IS_PROFILE (profile));
 
888
        g_return_if_fail (key != NULL);
 
889
        g_return_if_fail (value != NULL);
 
890
        g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
829
891
        g_return_if_fail (profile->priv->proxy != NULL);
830
892
 
831
893
        res = g_simple_async_result_new (G_OBJECT (profile),
926
988
        GSimpleAsyncResult *res;
927
989
 
928
990
        g_return_if_fail (CD_IS_PROFILE (profile));
 
991
        g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
929
992
        g_return_if_fail (profile->priv->proxy != NULL);
930
993
 
931
994
        res = g_simple_async_result_new (G_OBJECT (profile),
1091
1154
        case PROP_SCOPE:
1092
1155
                g_value_set_uint (value, profile->priv->scope);
1093
1156
                break;
 
1157
        case PROP_OWNER:
 
1158
                g_value_set_uint (value, profile->priv->owner);
 
1159
                break;
1094
1160
        default:
1095
1161
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1096
1162
                break;
1303
1369
                                                            0,
1304
1370
                                                            G_PARAM_READABLE));
1305
1371
 
 
1372
        /**
 
1373
         * CdProfile:owner:
 
1374
         *
 
1375
         * The profile owner, e.g. %500.
 
1376
         *
 
1377
         * Since: 0.1.13
 
1378
         **/
 
1379
        g_object_class_install_property (object_class,
 
1380
                                         PROP_OWNER,
 
1381
                                         g_param_spec_uint ("owner",
 
1382
                                                            NULL, NULL,
 
1383
                                                            0,
 
1384
                                                            G_MAXUINT,
 
1385
                                                            0,
 
1386
                                                            G_PARAM_READABLE));
 
1387
 
1306
1388
        g_type_class_add_private (klass, sizeof (CdProfilePrivate));
1307
1389
}
1308
1390