~ubuntu-branches/debian/stretch/colord/stretch

« back to all changes in this revision

Viewing changes to src/plugins/cd-plugin-scanner.c

  • Committer: Package Import Robot
  • Author(s): Christopher James Halse Rogers
  • Date: 2015-08-13 08:56:11 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20150813085611-946sqkendiafealo
Tags: 1.2.11-1
* Add missing GFDL licence for documentation
* Merge new upstream 1.2.11 release. (Closes: 782477)
* Cherry pick commit to check for, and prefer, libsystemd over
  libsystemd-login. (Closes: 779777)
* debian/libcolorhug2.symbols: Add new ch_device_close symbol.
* Remove no-longer-used colord.conf (Closes: 751212)
* Add new symbols to libcolord-private symbols file
* Add new functions to libcolorhug2 symbols file
* Add newly-introduced symbols to symbols file
* Update DEP8 control for libtool-bin split
* Output better logs on DEP8 failures
* Add colord-sensor-argyll package
* Disable strangely-failing DEP8 test

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <gudev/gudev.h>
26
26
#include <cd-device.h>
27
27
 
 
28
#include "cd-cleanup.h"
 
29
 
28
30
struct CdPluginPrivate {
29
31
        GUdevClient             *udev_client;
30
32
        GHashTable              *devices;
85
87
static void
86
88
cd_plugin_add (CdPlugin *plugin, GUdevDevice *udev_device)
87
89
{
88
 
        CdDevice *device = NULL;
89
90
        const gchar *devclass;
90
91
        const gchar *seat;
91
 
        gboolean ret;
92
 
        gchar *id = NULL;
93
 
        gchar *model = NULL;
94
 
        gchar *vendor = NULL;
 
92
        _cleanup_free_ gchar *id = NULL;
 
93
        _cleanup_free_ gchar *model = NULL;
 
94
        _cleanup_free_ gchar *vendor = NULL;
 
95
        _cleanup_object_unref_ CdDevice *device = NULL;
95
96
 
96
97
        /* is a scanner? */
97
 
        ret = g_udev_device_has_property (udev_device, "libsane_matched");
98
 
        if (!ret)
99
 
                goto out;
 
98
        if (!g_udev_device_has_property (udev_device, "libsane_matched"))
 
99
                return;
100
100
 
101
101
        /* skip hubs */
102
102
        devclass = g_udev_device_get_sysfs_attr (udev_device, "bDeviceClass");
103
103
        if (devclass == NULL || g_strcmp0 (devclass, "09") == 0)
104
 
                goto out;
 
104
                return;
105
105
 
106
106
        /* replace underscores with spaces */
107
107
        model = g_strdup (g_udev_device_get_property (udev_device,
170
170
 
171
171
        g_debug ("CdPlugin: emit add: %s", id);
172
172
        cd_plugin_device_added (plugin, device);
173
 
out:
174
 
        if (device != NULL)
175
 
                g_object_unref (device);
176
 
        g_free (id);
177
 
        g_free (model);
178
 
        g_free (vendor);
179
173
}
180
174
 
181
175
/**
197
191
                sysfs_path = g_udev_device_get_sysfs_path (udev_device);
198
192
                device = g_hash_table_lookup (plugin->priv->devices, sysfs_path);
199
193
                if (device == NULL)
200
 
                        goto out;
 
194
                        return;
201
195
 
202
196
                g_debug ("CdPlugin: remove %s", sysfs_path);
203
197
                cd_plugin_device_removed (plugin, device);
204
198
                g_hash_table_remove (plugin->priv->devices, sysfs_path);
205
 
                goto out;
 
199
                return;
206
200
        }
207
201
 
208
202
        /* add */
209
203
        if (g_strcmp0 (action, "add") == 0) {
210
204
                cd_plugin_add (plugin, udev_device);
211
 
                goto out;
 
205
                return;
212
206
        }
213
 
out:
214
 
        return;
215
207
}
216
208
 
217
209
/**