diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-07-26 18:23:59 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-07-26 18:23:59 +0100 |
commit | 8e8a2b83bd5e5f5d293a64bfb5e5a163b80fad0d (patch) | |
tree | dde9cefd7845dd646c38f9e876dcde38aa9bbe9f | |
parent | e3b36473ed5400c60f4f08b8cc88bc4e384f3b32 (diff) | |
download | ayatana-indicator-session-8e8a2b83bd5e5f5d293a64bfb5e5a163b80fad0d.tar.gz ayatana-indicator-session-8e8a2b83bd5e5f5d293a64bfb5e5a163b80fad0d.tar.bz2 ayatana-indicator-session-8e8a2b83bd5e5f5d293a64bfb5e5a163b80fad0d.zip |
pattern established as to how to handle these sane rules
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/sane-rules.h | 20 | ||||
-rw-r--r-- | src/sane_rules.h | 0 | ||||
-rw-r--r-- | src/udev-mgr.c | 27 |
4 files changed, 43 insertions, 7 deletions
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 --- a/src/sane_rules.h +++ /dev/null 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 <http://www.gnu.org/licenses/>. */ -#include "udev-mgr.h" #include <gudev/gudev.h> - +// TEMP #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> +#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"}; @@ -46,11 +48,23 @@ 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) { |