]> git.bzium.org/ - embe/overlay.git/blob - x11-misc/colord/files/colord-1.2.11-multiple-users.patch
Podbicie wersji: games-roguelike/adom-60
[embe/overlay.git] / x11-misc / colord / files / colord-1.2.11-multiple-users.patch
1 From eeac836f256fe07004d67e13c3c89532982af9bd Mon Sep 17 00:00:00 2001
2 From: Richard Hughes <richard@hughsie.com>
3 Date: Mon, 20 Jul 2015 10:57:28 +0100
4 Subject: [PATCH] Allow creating devices with the same device ID from different
5  users
6
7 ---
8  src/cd-device-array.c | 13 ++++++++-----
9  src/cd-device-array.h |  9 ++++++++-
10  src/cd-main.c         | 15 ++++++++++-----
11  src/cd-self-test.c    |  7 +++++--
12  4 files changed, 31 insertions(+), 13 deletions(-)
13
14 diff --git a/src/cd-device-array.c b/src/cd-device-array.c
15 index 88d4b2c..41a9597 100644
16 --- a/src/cd-device-array.c
17 +++ b/src/cd-device-array.c
18 @@ -76,7 +76,8 @@ cd_device_array_remove (CdDeviceArray *device_array, CdDevice *device)
19  CdDevice *
20  cd_device_array_get_by_id_owner (CdDeviceArray *device_array,
21                                  const gchar *id,
22 -                                guint owner)
23 +                                guint owner,
24 +                                CdDeviceArrayFlags flags)
25  {
26         CdDeviceArrayPrivate *priv = device_array->priv;
27         CdDevice *device_tmp;
28 @@ -90,10 +91,12 @@ cd_device_array_get_by_id_owner (CdDeviceArray *device_array,
29                 if (g_strcmp0 (cd_device_get_id (device_tmp), id) == 0)
30                         return g_object_ref (device_tmp);
31         }
32 -       for (i = 0; i < priv->array->len; i++) {
33 -               device_tmp = g_ptr_array_index (priv->array, i);
34 -               if (g_strcmp0 (cd_device_get_id (device_tmp), id) == 0)
35 -                       return g_object_ref (device_tmp);
36 +       if (flags & CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL) {
37 +               for (i = 0; i < priv->array->len; i++) {
38 +                       device_tmp = g_ptr_array_index (priv->array, i);
39 +                       if (g_strcmp0 (cd_device_get_id (device_tmp), id) == 0)
40 +                               return g_object_ref (device_tmp);
41 +               }
42         }
43         return NULL;
44  }
45 diff --git a/src/cd-device-array.h b/src/cd-device-array.h
46 index b625dbf..31dc067 100644
47 --- a/src/cd-device-array.h
48 +++ b/src/cd-device-array.h
49 @@ -50,6 +50,12 @@ struct _CdDeviceArrayClass
50         GObjectClass             parent_class;
51  };
52  
53 +typedef enum {
54 +       CD_DEVICE_ARRAY_FLAG_NONE               = 0,
55 +       CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL     = 1,
56 +       CD_DEVICE_ARRAY_FLAG_LAST,
57 +} CdDeviceArrayFlags;
58 +
59  GType           cd_device_array_get_type               (void);
60  CdDeviceArray  *cd_device_array_new                    (void);
61  
62 @@ -59,7 +65,8 @@ void           cd_device_array_remove                 (CdDeviceArray  *device_array,
63                                                          CdDevice       *device);
64  CdDevice       *cd_device_array_get_by_id_owner        (CdDeviceArray  *device_array,
65                                                          const gchar    *id,
66 -                                                        guint           owner);
67 +                                                        guint           owner,
68 +                                                        CdDeviceArrayFlags flags);
69  CdDevice       *cd_device_array_get_by_object_path     (CdDeviceArray  *device_array,
70                                                          const gchar    *object_path);
71  CdDevice       *cd_device_array_get_by_property        (CdDeviceArray  *device_array,
72 diff --git a/src/cd-main.c b/src/cd-main.c
73 index b5b3a4f..37817e3 100644
74 --- a/src/cd-main.c
75 +++ b/src/cd-main.c
76 @@ -720,7 +720,8 @@ cd_main_profile_auto_add_from_db (CdMainPrivate *priv,
77                 device_id_tmp = g_ptr_array_index (array, i);
78                 device_tmp = cd_device_array_get_by_id_owner (priv->devices_array,
79                                                               device_id_tmp,
80 -                                                             cd_profile_get_owner (profile));
81 +                                                             cd_profile_get_owner (profile),
82 +                                                             CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
83                 if (device_tmp == NULL)
84                         continue;
85  
86 @@ -747,7 +748,8 @@ cd_main_profile_auto_add_from_md (CdMainPrivate *priv,
87                 return;
88         device = cd_device_array_get_by_id_owner (priv->devices_array,
89                                                   device_id,
90 -                                                 cd_profile_get_owner (profile));
91 +                                                 cd_profile_get_owner (profile),
92 +                                                 CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
93         if (device == NULL)
94                 return;
95         cd_main_auto_add_from_md (priv, device, profile);
96 @@ -1022,7 +1024,8 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
97                          sender, device_id);
98                 device = cd_device_array_get_by_id_owner (priv->devices_array,
99                                                           device_id,
100 -                                                         uid);
101 +                                                         uid,
102 +                                                         CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
103                 if (device == NULL) {
104                         g_dbus_method_invocation_return_error (invocation,
105                                                                CD_CLIENT_ERROR,
106 @@ -1279,7 +1282,8 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
107                 }
108                 device = cd_device_array_get_by_id_owner (priv->devices_array,
109                                                           device_id,
110 -                                                         uid);
111 +                                                         uid,
112 +                                                         CD_DEVICE_ARRAY_FLAG_NONE);
113                 if (device != NULL) {
114                         /* where we try to manually add an existing
115                          * virtual device, which means promoting it to
116 @@ -1399,7 +1403,8 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
117                          sender, device_id);
118                 device = cd_device_array_get_by_id_owner (priv->devices_array,
119                                                           device_id,
120 -                                                         uid);
121 +                                                         uid,
122 +                                                         CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
123                 if (device == NULL) {
124                         /* fall back to checking the object path */
125                         device = cd_device_array_get_by_object_path (priv->devices_array,
126 diff --git a/src/cd-self-test.c b/src/cd-self-test.c
127 index 4a76d07..6536d3c 100644
128 --- a/src/cd-self-test.c
129 +++ b/src/cd-self-test.c
130 @@ -178,10 +178,13 @@ colord_device_array_func (void)
131         cd_device_array_add (device_array, device);
132         g_object_unref (device);
133  
134 -       device = cd_device_array_get_by_id_owner (device_array, "does not exist", 0);
135 +       device = cd_device_array_get_by_id_owner (device_array, "does not exist", 0, CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
136         g_assert (device == NULL);
137  
138 -       device = cd_device_array_get_by_id_owner (device_array, "dave", 0);
139 +       device = cd_device_array_get_by_id_owner (device_array, "dave", 999, CD_DEVICE_ARRAY_FLAG_NONE);
140 +       g_assert (device == NULL);
141 +
142 +       device = cd_device_array_get_by_id_owner (device_array, "dave", 0, CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
143         g_assert (device != NULL);
144         g_assert_cmpstr (cd_device_get_id (device), ==, "dave");
145         g_object_unref (device);
146 -- 
147 2.4.3
148