From 8e8a2b83bd5e5f5d293a64bfb5e5a163b80fad0d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 26 Jul 2011 18:23:59 +0100 Subject: pattern established as to how to handle these sane rules --- src/Makefile.am | 3 ++- src/sane-rules.h | 20 ++++++++++++++++++++ src/sane_rules.h | 0 src/udev-mgr.c | 27 +++++++++++++++++++++------ 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/sane-rules.h delete mode 100644 src/sane_rules.h diff --git a/src/Makefile.am b/src/Makefile.am index 83d12bb..36a1d1f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -101,7 +101,8 @@ indicator_session_service_SOURCES = \ apt-transaction.h \ apt-transaction.c \ udev-mgr.h \ - udev-mgr.c + udev-mgr.c \ + sane-rules.h indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/sane-rules.h b/src/sane-rules.h new file mode 100644 index 0000000..fc43e39 --- /dev/null +++ b/src/sane-rules.h @@ -0,0 +1,20 @@ + + +void populate_usb_scanners (GHashTable* scanners) +{ + GList* epson = NULL; + + epson = g_list_append (epson, g_strdup("0101")); + epson = g_list_append (epson, g_strdup("0103")); + epson = g_list_append (epson, g_strdup("0104")); + epson = g_list_append (epson, g_strdup("0105")); + epson = g_list_append (epson, g_strdup("0106")); + epson = g_list_append (epson, g_strdup("0107")); + epson = g_list_append (epson, g_strdup("0109")); + epson = g_list_append (epson, g_strdup("010a")); + epson = g_list_append (epson, g_strdup("010b")); + + g_hash_table_insert (scanners, + g_strdup("04b8"), + g_list_copy(epson)); +} diff --git a/src/sane_rules.h b/src/sane_rules.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 4dde1b8..31ccb63 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -17,27 +17,29 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "udev-mgr.h" #include - +// TEMP #include #include #include #include +#include "udev-mgr.h" +#include "sane-rules.h" + static void udevice_mgr_device_list_iterator (gpointer data, gpointer userdata); static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, - gpointer user_data); - + gpointer user_data); struct _UdevMgr { GObject parent_instance; DbusmenuMenuitem* scanner_item; DbusmenuMenuitem* webcam_item; GUdevClient* client; + GHashTable* supported_scanners; }; const char *subsystems[1] = {"usb"}; @@ -45,12 +47,24 @@ const gchar* usb_subsystem = "usb"; G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); +static void +test_usb_scanners(gpointer data, gpointer user_data) +{ + gchar* model = (gchar*)data; + g_debug ("in hash table for epsom model %s was found", model); +} + static void udev_mgr_init (UdevMgr* self) { self->client = NULL; - self->client = g_udev_client_new (subsystems); - + self->supported_scanners = NULL; + + self->client = g_udev_client_new (subsystems); + self->supported_scanners = g_hash_table_new (g_str_hash, g_str_equal); + populate_usb_scanners(self->supported_scanners); + GList* epsom = g_hash_table_lookup(self->supported_scanners, "04b8"); + g_list_foreach(epsom, test_usb_scanners, NULL); GList* devices_available = g_udev_client_query_by_subsystem (self->client, usb_subsystem); @@ -62,6 +76,7 @@ udev_mgr_init (UdevMgr* self) self); } + static void udev_mgr_finalize (GObject *object) { -- cgit v1.2.3