aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-08-10 18:04:18 +0100
committerConor Curran <conor.curran@canonical.com>2011-08-10 18:04:18 +0100
commit5663f0199537a1a221ebe3bf35b5026144498b72 (patch)
tree54119c1f7fa2efd82db91aa6a5ba13e51a77ef40
parent357374acb2a641a9c5d70cb6149293a0a07770f3 (diff)
parentddd4474c7cf18706f5ea43e0319488f4d0358226 (diff)
downloadayatana-indicator-session-5663f0199537a1a221ebe3bf35b5026144498b72.tar.gz
ayatana-indicator-session-5663f0199537a1a221ebe3bf35b5026144498b72.tar.bz2
ayatana-indicator-session-5663f0199537a1a221ebe3bf35b5026144498b72.zip
merge the gudev work
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/device-menu-mgr.c70
-rw-r--r--src/sane-rules.h778
-rw-r--r--src/udev-mgr.c420
-rw-r--r--src/udev-mgr.h19
-rw-r--r--src/user-menu-mgr.c20
7 files changed, 1285 insertions, 27 deletions
diff --git a/configure.ac b/configure.ac
index 369f12b..e32ac4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,12 +58,14 @@ AS_IF([test "x$with_gtk" = x3],
[PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
dbus-glib-1
+ gudev-1.0
gio-unix-2.0
indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION)
],
[test "x$with_gtk" = x2],
[PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ gudev-1.0
dbus-glib-1
gio-unix-2.0
indicator-0.4 >= $INDICATOR_REQUIRED_VERSION)
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/device-menu-mgr.c b/src/device-menu-mgr.c
index 324b3f1..e9143f7 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -27,7 +27,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "lock-helper.h"
#include "upower-client.h"
#include "apt-watcher.h"
-
+#include "udev-mgr.h"
#define UP_ADDRESS "org.freedesktop.UPower"
#define UP_OBJECT "/org/freedesktop/UPower"
@@ -41,6 +41,7 @@ struct _DeviceMenuMgr
DbusmenuMenuitem* root_item;
SessionDbus* session_dbus_interface;
AptWatcher* apt_watcher;
+ UdevMgr* udev_mgr;
};
static GConfClient *gconf_client = NULL;
@@ -80,8 +81,15 @@ static void machine_sleep_with_context (DeviceMenuMgr* self,
gchar* type);
static void show_system_settings_with_context (DbusmenuMenuitem * mi,
guint timestamp,
- gchar * type);
-
+ gchar * type);
+
+static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi,
+ guint timestamp,
+ gchar * type);
+static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi,
+ guint timestamp,
+ gchar * type);
+
static void
machine_sleep_from_hibernate (DbusmenuMenuitem * mi,
guint timestamp,
@@ -214,7 +222,6 @@ machine_sleep_with_context (DeviceMenuMgr* self, gchar* type)
screensaver_throttle(type);
lock_if_possible (self);
-
dbus_g_proxy_begin_call(up_main_proxy,
type,
sleep_response,
@@ -460,6 +467,43 @@ show_system_settings_with_context (DbusmenuMenuitem * mi,
g_free(control_centre_command);
}
+// TODO: refactor both of these down to the one method.
+static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi,
+ guint timestamp,
+ gchar * type)
+{
+ GError * error = NULL;
+ if (!g_spawn_command_line_async("simple-scan", &error))
+ {
+ g_warning("Unable to launch simple-scan: %s", error->message);
+ g_error_free(error);
+ if (!g_spawn_command_line_async("software-center simple-scan", &error))
+ {
+ g_warning ("Unable to launch software-centre simple-scan: %s",
+ error->message);
+ g_error_free(error);
+ }
+ }
+}
+
+static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi,
+ guint timestamp,
+ gchar * type)
+{
+ GError * error = NULL;
+ if (!g_spawn_command_line_async("cheese", &error))
+ {
+ g_warning("Unable to launch cheese: %s", error->message);
+ g_error_free(error);
+ if (!g_spawn_command_line_async("software-center cheese", &error))
+ {
+ g_warning ("Unable to launch software-centre cheese: %s",
+ error->message);
+ g_error_free(error);
+ }
+ }
+}
+
static void
device_menu_mgr_build_static_items (DeviceMenuMgr* self)
{
@@ -547,15 +591,14 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self)
scanners_menuitem = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (scanners_menuitem,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("HP Scanners"));
+ _("Scanners"));
g_signal_connect (G_OBJECT(scanners_menuitem),
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(show_system_settings_with_context),
- "scanners");
+ G_CALLBACK(device_menu_mgr_show_simple_scan),
+ NULL);
dbusmenu_menuitem_child_add_position (self->root_item,
scanners_menuitem,
8);
- //tmp
dbusmenu_menuitem_property_set_bool (scanners_menuitem,
DBUSMENU_MENUITEM_PROP_VISIBLE,
FALSE);
@@ -563,15 +606,14 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self)
webcam_menuitem = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (webcam_menuitem,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("HP Webcam"));
+ _("Webcam"));
g_signal_connect (G_OBJECT(webcam_menuitem),
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(show_system_settings_with_context),
- "HP Webcam");
+ G_CALLBACK(device_menu_mgr_show_cheese),
+ NULL);
dbusmenu_menuitem_child_add_position (self->root_item,
webcam_menuitem,
10);
- //tmp
dbusmenu_menuitem_property_set_bool (webcam_menuitem,
DBUSMENU_MENUITEM_PROP_VISIBLE,
FALSE);
@@ -681,7 +723,9 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self)
restart_shutdown_logout_mi->logout_mi = logout_mi;
restart_shutdown_logout_mi->shutdown_mi = shutdown_mi;
- update_menu_entries(restart_shutdown_logout_mi);
+ update_menu_entries(restart_shutdown_logout_mi);
+ // Time to create the udev mgr and hand it the static relevant items.
+ self->udev_mgr = udev_mgr_new (scanners_menuitem, webcam_menuitem);
}
diff --git a/src/sane-rules.h b/src/sane-rules.h
new file mode 100644
index 0000000..0b72e52
--- /dev/null
+++ b/src/sane-rules.h
@@ -0,0 +1,778 @@
+void populate_scsi_scanners (GHashTable* scanners)
+{
+ GList* epson = NULL;
+ epson = g_list_append (epson, g_strdup ("GT-9700"));
+ epson = g_list_append (epson, g_strdup ("GT-9800"));
+ epson = g_list_append (epson, g_strdup ("Perfection1200"));
+ epson = g_list_append (epson, g_strdup ("Perfection636"));
+ epson = g_list_append (epson, g_strdup ("SCANNER GT-7000"));
+ g_hash_table_insert (scanners,
+ g_strdup("EPSON"),
+ epson);
+
+
+ GList* hp = NULL;
+ hp = g_list_append (hp, g_strdup ("C1130A"));
+ hp = g_list_append (hp, g_strdup ("C1750A"));
+ hp = g_list_append (hp, g_strdup ("C1790A"));
+ hp = g_list_append (hp, g_strdup ("C2500A"));
+ hp = g_list_append (hp, g_strdup ("C2520A"));
+ hp = g_list_append (hp, g_strdup ("C5110A"));
+ hp = g_list_append (hp, g_strdup ("C6270A"));
+ hp = g_list_append (hp, g_strdup ("C7670A"));
+ g_hash_table_insert (scanners,
+ g_strdup("HP"),
+ hp);
+}
+
+
+
+void populate_usb_scanners (GHashTable* scanners)
+{
+ GList* hp = NULL;
+
+ hp = g_list_append (hp, g_strdup ("0101"));
+ hp = g_list_append (hp, g_strdup ("0105"));
+ hp = g_list_append (hp, g_strdup ("0201"));
+ hp = g_list_append (hp, g_strdup ("0205"));
+ hp = g_list_append (hp, g_strdup ("0305"));
+ hp = g_list_append (hp, g_strdup ("0401"));
+ hp = g_list_append (hp, g_strdup ("0405"));
+ hp = g_list_append (hp, g_strdup ("0505"));
+ hp = g_list_append (hp, g_strdup ("0601"));
+ hp = g_list_append (hp, g_strdup ("0605"));
+ hp = g_list_append (hp, g_strdup ("0701"));
+ hp = g_list_append (hp, g_strdup ("0705"));
+ hp = g_list_append (hp, g_strdup ("0801"));
+ hp = g_list_append (hp, g_strdup ("0805"));
+ hp = g_list_append (hp, g_strdup ("0901"));
+ hp = g_list_append (hp, g_strdup ("0a01"));
+ hp = g_list_append (hp, g_strdup ("0b01"));
+ hp = g_list_append (hp, g_strdup ("1005"));
+ hp = g_list_append (hp, g_strdup ("1105"));
+ hp = g_list_append (hp, g_strdup ("1205"));
+ hp = g_list_append (hp, g_strdup ("1305"));
+ hp = g_list_append (hp, g_strdup ("1405"));
+ hp = g_list_append (hp, g_strdup ("1705"));
+ hp = g_list_append (hp, g_strdup ("1805"));
+ hp = g_list_append (hp, g_strdup ("2005"));
+ hp = g_list_append (hp, g_strdup ("2205"));
+ hp = g_list_append (hp, g_strdup ("2305"));
+ hp = g_list_append (hp, g_strdup ("2405"));
+ hp = g_list_append (hp, g_strdup ("2605"));
+ hp = g_list_append (hp, g_strdup ("2805"));
+ hp = g_list_append (hp, g_strdup ("3805"));
+ hp = g_list_append (hp, g_strdup ("3905"));
+ hp = g_list_append (hp, g_strdup ("3B17"));
+ hp = g_list_append (hp, g_strdup ("4105"));
+ hp = g_list_append (hp, g_strdup ("4205"));
+ hp = g_list_append (hp, g_strdup ("4305"));
+ hp = g_list_append (hp, g_strdup ("4505"));
+ hp = g_list_append (hp, g_strdup ("4605"));
+ hp = g_list_append (hp, g_strdup ("5617"));
+ hp = g_list_append (hp, g_strdup ("5717"));
+
+ g_hash_table_insert (scanners,
+ g_strdup("03f0"),
+ hp);
+
+ GList* mustek_2 = NULL;
+ mustek_2 = g_list_append (mustek_2, g_strdup ("1000"));
+ mustek_2 = g_list_append (mustek_2, g_strdup ("1001"));
+ g_hash_table_insert (scanners,
+ g_strdup("0400"),
+ mustek_2);
+
+ GList* kodak = NULL;
+ kodak = g_list_append (kodak, g_strdup ("6001"));
+ kodak = g_list_append (kodak, g_strdup ("6002"));
+ kodak = g_list_append (kodak, g_strdup ("6003"));
+ kodak = g_list_append (kodak, g_strdup ("6004"));
+ kodak = g_list_append (kodak, g_strdup ("6005"));
+ g_hash_table_insert (scanners,
+ g_strdup("040a"),
+ kodak);
+
+ GList* creative = NULL;
+
+ creative = g_list_append (creative, g_strdup ("4007"));
+
+ g_hash_table_insert (scanners,
+ g_strdup("041e"),
+ creative);
+
+ GList* lexmark = NULL;
+
+ lexmark = g_list_append (lexmark, g_strdup("002d"));
+ lexmark = g_list_append (lexmark, g_strdup("0060"));
+ lexmark = g_list_append (lexmark, g_strdup("007c"));
+ lexmark = g_list_append (lexmark, g_strdup("007d"));
+
+ g_hash_table_insert (scanners,
+ g_strdup("043d"),
+ lexmark);
+
+
+ GList* genius = NULL;
+ genius = g_list_append (genius, g_strdup("2004"));
+ genius = g_list_append (genius, g_strdup("2007"));
+ genius = g_list_append (genius, g_strdup("2008"));
+ genius = g_list_append (genius, g_strdup("2009"));
+ genius = g_list_append (genius, g_strdup("2011"));
+ genius = g_list_append (genius, g_strdup("2013"));
+ genius = g_list_append (genius, g_strdup("2014"));
+ genius = g_list_append (genius, g_strdup("2015"));
+ genius = g_list_append (genius, g_strdup("2016"));
+ genius = g_list_append (genius, g_strdup("2017"));
+ genius = g_list_append (genius, g_strdup("201a"));
+ genius = g_list_append (genius, g_strdup("201b"));
+ genius = g_list_append (genius, g_strdup("201d"));
+ genius = g_list_append (genius, g_strdup("201e"));
+ genius = g_list_append (genius, g_strdup("201f"));
+ genius = g_list_append (genius, g_strdup("20c1"));
+ g_hash_table_insert (scanners,
+ g_strdup("0458"),
+ genius);
+
+ GList* medion = NULL;
+ medion = g_list_append (medion, g_strdup("0377"));
+ g_hash_table_insert (scanners,
+ g_strdup("0461"),
+ medion);
+
+ GList* trust = NULL;
+ trust = g_list_append (trust, g_strdup("1000"));
+ trust = g_list_append (trust, g_strdup("1002"));
+ g_hash_table_insert (scanners,
+ g_strdup("047b"),
+ trust);
+
+ GList* kyocera = NULL;
+ kyocera = g_list_append (kyocera, g_strdup("0335"));
+ g_hash_table_insert (scanners,
+ g_strdup("0482"),
+ kyocera);
+
+ GList* compaq = NULL;
+ compaq = g_list_append (compaq, g_strdup("001a"));
+ g_hash_table_insert (scanners,
+ g_strdup("049f"),
+ compaq);
+ GList* benq = NULL;
+ benq = g_list_append (benq, g_strdup("1a20"));
+ benq = g_list_append (benq, g_strdup("1a2a"));
+ benq = g_list_append (benq, g_strdup("2022"));
+ benq = g_list_append (benq, g_strdup("2040"));
+ benq = g_list_append (benq, g_strdup("2060"));
+ benq = g_list_append (benq, g_strdup("207e"));
+ benq = g_list_append (benq, g_strdup("20b0"));
+ benq = g_list_append (benq, g_strdup("20be"));
+ benq = g_list_append (benq, g_strdup("20c0"));
+ benq = g_list_append (benq, g_strdup("20de"));
+ benq = g_list_append (benq, g_strdup("20f8"));
+ benq = g_list_append (benq, g_strdup("20fc"));
+ benq = g_list_append (benq, g_strdup("20fe"));
+ benq = g_list_append (benq, g_strdup("2137"));
+ benq = g_list_append (benq, g_strdup("2211"));
+ g_hash_table_insert (scanners,
+ g_strdup("04a5"),
+ benq);
+
+ GList* visioneer = NULL;
+ visioneer = g_list_append (visioneer, g_strdup("0229"));
+ visioneer = g_list_append (visioneer, g_strdup("0390"));
+ visioneer = g_list_append (visioneer, g_strdup("0420"));
+ visioneer = g_list_append (visioneer, g_strdup("0421"));
+ visioneer = g_list_append (visioneer, g_strdup("0422"));
+ visioneer = g_list_append (visioneer, g_strdup("0423"));
+ visioneer = g_list_append (visioneer, g_strdup("0424"));
+ visioneer = g_list_append (visioneer, g_strdup("0426"));
+ visioneer = g_list_append (visioneer, g_strdup("0427"));
+ visioneer = g_list_append (visioneer, g_strdup("0444"));
+ visioneer = g_list_append (visioneer, g_strdup("0446"));
+ visioneer = g_list_append (visioneer, g_strdup("0447"));
+ visioneer = g_list_append (visioneer, g_strdup("0448"));
+ visioneer = g_list_append (visioneer, g_strdup("0449"));
+ visioneer = g_list_append (visioneer, g_strdup("044c"));
+ visioneer = g_list_append (visioneer, g_strdup("0474"));
+ visioneer = g_list_append (visioneer, g_strdup("0475"));
+ visioneer = g_list_append (visioneer, g_strdup("0477"));
+ visioneer = g_list_append (visioneer, g_strdup("0478"));
+ visioneer = g_list_append (visioneer, g_strdup("0479"));
+ visioneer = g_list_append (visioneer, g_strdup("047a"));
+ visioneer = g_list_append (visioneer, g_strdup("047b"));
+ visioneer = g_list_append (visioneer, g_strdup("047c"));
+ visioneer = g_list_append (visioneer, g_strdup("048c"));
+ visioneer = g_list_append (visioneer, g_strdup("048d"));
+ visioneer = g_list_append (visioneer, g_strdup("048e"));
+ visioneer = g_list_append (visioneer, g_strdup("048f"));
+ visioneer = g_list_append (visioneer, g_strdup("0490"));
+ visioneer = g_list_append (visioneer, g_strdup("0491"));
+ visioneer = g_list_append (visioneer, g_strdup("0492"));
+ visioneer = g_list_append (visioneer, g_strdup("0493"));
+ visioneer = g_list_append (visioneer, g_strdup("0494"));
+ visioneer = g_list_append (visioneer, g_strdup("0495"));
+ visioneer = g_list_append (visioneer, g_strdup("0497"));
+ visioneer = g_list_append (visioneer, g_strdup("0498"));
+ visioneer = g_list_append (visioneer, g_strdup("0499"));
+ visioneer = g_list_append (visioneer, g_strdup("049a"));
+ visioneer = g_list_append (visioneer, g_strdup("049b"));
+ visioneer = g_list_append (visioneer, g_strdup("049c"));
+ visioneer = g_list_append (visioneer, g_strdup("049d"));
+ visioneer = g_list_append (visioneer, g_strdup("04a7"));
+ visioneer = g_list_append (visioneer, g_strdup("04ac"));
+ g_hash_table_insert (scanners,
+ g_strdup("04a7"),
+ visioneer);
+ GList* canon = NULL;
+ canon = g_list_append (canon, g_strdup("1601"));
+ canon = g_list_append (canon, g_strdup("1602"));
+ canon = g_list_append (canon, g_strdup("1603"));
+ canon = g_list_append (canon, g_strdup("1604"));
+ canon = g_list_append (canon, g_strdup("1606"));
+ canon = g_list_append (canon, g_strdup("1607"));
+ canon = g_list_append (canon, g_strdup("1608"));
+ canon = g_list_append (canon, g_strdup("1609"));
+ canon = g_list_append (canon, g_strdup("160a"));
+ canon = g_list_append (canon, g_strdup("160b"));
+ canon = g_list_append (canon, g_strdup("1706"));
+ canon = g_list_append (canon, g_strdup("1707"));
+ canon = g_list_append (canon, g_strdup("1708"));
+ canon = g_list_append (canon, g_strdup("1709"));
+ canon = g_list_append (canon, g_strdup("170a"));
+ canon = g_list_append (canon, g_strdup("170b"));
+ canon = g_list_append (canon, g_strdup("170c"));
+ canon = g_list_append (canon, g_strdup("170d"));
+ canon = g_list_append (canon, g_strdup("170e"));
+ canon = g_list_append (canon, g_strdup("1712"));
+ canon = g_list_append (canon, g_strdup("1713"));
+ canon = g_list_append (canon, g_strdup("1714"));
+ canon = g_list_append (canon, g_strdup("1715"));
+ canon = g_list_append (canon, g_strdup("1716"));
+ canon = g_list_append (canon, g_strdup("1717"));
+ canon = g_list_append (canon, g_strdup("1718"));
+ canon = g_list_append (canon, g_strdup("1719"));
+ canon = g_list_append (canon, g_strdup("171a"));
+ canon = g_list_append (canon, g_strdup("171b"));
+ canon = g_list_append (canon, g_strdup("171c"));
+ canon = g_list_append (canon, g_strdup("1721"));
+ canon = g_list_append (canon, g_strdup("1722"));
+ canon = g_list_append (canon, g_strdup("1723"));
+ canon = g_list_append (canon, g_strdup("1724"));
+ canon = g_list_append (canon, g_strdup("1725"));
+ canon = g_list_append (canon, g_strdup("1726"));
+ canon = g_list_append (canon, g_strdup("1727"));
+ canon = g_list_append (canon, g_strdup("1728"));
+ canon = g_list_append (canon, g_strdup("1729"));
+ canon = g_list_append (canon, g_strdup("172b"));
+ canon = g_list_append (canon, g_strdup("172c"));
+ canon = g_list_append (canon, g_strdup("172d"));
+ canon = g_list_append (canon, g_strdup("172e"));
+ canon = g_list_append (canon, g_strdup("172f"));
+ canon = g_list_append (canon, g_strdup("1730"));
+ canon = g_list_append (canon, g_strdup("1731"));
+ canon = g_list_append (canon, g_strdup("1732"));
+ canon = g_list_append (canon, g_strdup("1733"));
+ canon = g_list_append (canon, g_strdup("1734"));
+ canon = g_list_append (canon, g_strdup("1735"));
+ canon = g_list_append (canon, g_strdup("1736"));
+ canon = g_list_append (canon, g_strdup("173a"));
+ canon = g_list_append (canon, g_strdup("173b"));
+ canon = g_list_append (canon, g_strdup("173c"));
+ canon = g_list_append (canon, g_strdup("173d"));
+ canon = g_list_append (canon, g_strdup("173e"));
+ canon = g_list_append (canon, g_strdup("173f"));
+ canon = g_list_append (canon, g_strdup("1740"));
+ canon = g_list_append (canon, g_strdup("1741"));
+ canon = g_list_append (canon, g_strdup("1742"));
+ canon = g_list_append (canon, g_strdup("1901"));
+ canon = g_list_append (canon, g_strdup("1904"));
+ canon = g_list_append (canon, g_strdup("1905"));
+ canon = g_list_append (canon, g_strdup("1909"));
+ canon = g_list_append (canon, g_strdup("190a"));
+ canon = g_list_append (canon, g_strdup("2204"));
+ canon = g_list_append (canon, g_strdup("2206"));
+ canon = g_list_append (canon, g_strdup("2207"));
+ canon = g_list_append (canon, g_strdup("2208"));
+ canon = g_list_append (canon, g_strdup("220d"));
+ canon = g_list_append (canon, g_strdup("220e"));
+ canon = g_list_append (canon, g_strdup("2213"));
+ canon = g_list_append (canon, g_strdup("221c"));
+ canon = g_list_append (canon, g_strdup("2220"));
+ canon = g_list_append (canon, g_strdup("2222"));
+ canon = g_list_append (canon, g_strdup("262f"));
+ canon = g_list_append (canon, g_strdup("2630"));
+ canon = g_list_append (canon, g_strdup("263c"));
+ canon = g_list_append (canon, g_strdup("263d"));
+ canon = g_list_append (canon, g_strdup("263e"));
+ canon = g_list_append (canon, g_strdup("263f"));
+ canon = g_list_append (canon, g_strdup("264c"));
+ canon = g_list_append (canon, g_strdup("264d"));
+ canon = g_list_append (canon, g_strdup("264e"));
+ canon = g_list_append (canon, g_strdup("264f"));
+ canon = g_list_append (canon, g_strdup("2659"));
+ canon = g_list_append (canon, g_strdup("265d"));
+ canon = g_list_append (canon, g_strdup("265e"));
+ canon = g_list_append (canon, g_strdup("265f"));
+ canon = g_list_append (canon, g_strdup("2660"));
+ canon = g_list_append (canon, g_strdup("2684"));
+ canon = g_list_append (canon, g_strdup("2686"));
+ canon = g_list_append (canon, g_strdup("26a3"));
+ canon = g_list_append (canon, g_strdup("26b0"));
+ canon = g_list_append (canon, g_strdup("26b4"));
+ canon = g_list_append (canon, g_strdup("26b5"));
+ canon = g_list_append (canon, g_strdup("26ec"));
+ canon = g_list_append (canon, g_strdup("26ed"));
+ canon = g_list_append (canon, g_strdup("26ee"));
+ g_hash_table_insert (scanners,
+ g_strdup("04a9"),
+ canon);
+
+ GList* nikon = NULL;
+ nikon = g_list_append (nikon, g_strdup ("4000"));
+ nikon = g_list_append (nikon, g_strdup ("4001"));
+ nikon = g_list_append (nikon, g_strdup ("4002"));
+ g_hash_table_insert (scanners,
+ g_strdup("04b0"),
+ nikon);
+
+ GList* epson = NULL;
+
+ // for testing (its a printer not a scanner!)
+ //epson = g_list_append (epson, g_strdup ("0001"));
+
+ 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"));
+ epson = g_list_append (epson, g_strdup("010c"));
+ epson = g_list_append (epson, g_strdup("010e"));
+ epson = g_list_append (epson, g_strdup("010f"));
+ epson = g_list_append (epson, g_strdup("0110"));
+ epson = g_list_append (epson, g_strdup("0112"));
+ epson = g_list_append (epson, g_strdup("0114"));
+ epson = g_list_append (epson, g_strdup("011b"));
+ epson = g_list_append (epson, g_strdup("011c"));
+ epson = g_list_append (epson, g_strdup("011d"));
+ epson = g_list_append (epson, g_strdup("011e"));
+ epson = g_list_append (epson, g_strdup("011f"));
+ epson = g_list_append (epson, g_strdup("0120"));
+ epson = g_list_append (epson, g_strdup("0121"));
+ epson = g_list_append (epson, g_strdup("0122"));
+ epson = g_list_append (epson, g_strdup("0126"));
+ epson = g_list_append (epson, g_strdup("0128"));
+ epson = g_list_append (epson, g_strdup("0129"));
+ epson = g_list_append (epson, g_strdup("012a"));
+ epson = g_list_append (epson, g_strdup("012b"));
+ epson = g_list_append (epson, g_strdup("012c"));
+ epson = g_list_append (epson, g_strdup("0135"));
+ epson = g_list_append (epson, g_strdup("0801"));
+ epson = g_list_append (epson, g_strdup("0802"));
+ epson = g_list_append (epson, g_strdup("0805"));
+ epson = g_list_append (epson, g_strdup("0806"));
+ epson = g_list_append (epson, g_strdup("0807"));
+ epson = g_list_append (epson, g_strdup("0808"));
+ epson = g_list_append (epson, g_strdup("080c"));
+ epson = g_list_append (epson, g_strdup("080d"));
+ epson = g_list_append (epson, g_strdup("080e"));
+ epson = g_list_append (epson, g_strdup("080f"));
+ epson = g_list_append (epson, g_strdup("0810"));
+ epson = g_list_append (epson, g_strdup("0811"));
+ epson = g_list_append (epson, g_strdup("0813"));
+ epson = g_list_append (epson, g_strdup("0814"));
+ epson = g_list_append (epson, g_strdup("0815"));
+ epson = g_list_append (epson, g_strdup("0817"));
+ epson = g_list_append (epson, g_strdup("0818"));
+ epson = g_list_append (epson, g_strdup("0819"));
+ epson = g_list_append (epson, g_strdup("081a"));
+ epson = g_list_append (epson, g_strdup("081c"));
+ epson = g_list_append (epson, g_strdup("081d"));
+ epson = g_list_append (epson, g_strdup("081f"));
+ epson = g_list_append (epson, g_strdup("0820"));
+ epson = g_list_append (epson, g_strdup("0827"));
+ epson = g_list_append (epson, g_strdup("0828"));
+ epson = g_list_append (epson, g_strdup("0829"));
+ epson = g_list_append (epson, g_strdup("082a"));
+ epson = g_list_append (epson, g_strdup("082b"));
+ epson = g_list_append (epson, g_strdup("082e"));
+ epson = g_list_append (epson, g_strdup("082f"));
+ epson = g_list_append (epson, g_strdup("0830"));
+ epson = g_list_append (epson, g_strdup("0833"));
+ epson = g_list_append (epson, g_strdup("0834"));
+ epson = g_list_append (epson, g_strdup("0835"));
+ epson = g_list_append (epson, g_strdup("0836"));
+ epson = g_list_append (epson, g_strdup("0837"));
+ epson = g_list_append (epson, g_strdup("0838"));
+ epson = g_list_append (epson, g_strdup("0839"));
+ epson = g_list_append (epson, g_strdup("083a"));
+ epson = g_list_append (epson, g_strdup("083c"));
+ epson = g_list_append (epson, g_strdup("0841"));
+ epson = g_list_append (epson, g_strdup("0843"));
+ epson = g_list_append (epson, g_strdup("0844"));
+ epson = g_list_append (epson, g_strdup("0846"));
+ epson = g_list_append (epson, g_strdup("0847"));
+ epson = g_list_append (epson, g_strdup("0848"));
+ epson = g_list_append (epson, g_strdup("0849"));
+ epson = g_list_append (epson, g_strdup("084a"));
+ epson = g_list_append (epson, g_strdup("084c"));
+ epson = g_list_append (epson, g_strdup("084d"));
+ epson = g_list_append (epson, g_strdup("084f"));
+ epson = g_list_append (epson, g_strdup("0851"));
+ epson = g_list_append (epson, g_strdup("0854"));
+ epson = g_list_append (epson, g_strdup("0856"));
+ g_hash_table_insert (scanners,
+ g_strdup("04b8"),
+ epson);
+
+ GList* fujitsu = NULL;
+ fujitsu = g_list_append (fujitsu, g_strdup ("1029"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1041"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1042"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1078"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1095"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1096"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1097"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10ad"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10ae"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10af"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10c7"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10cf"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10e0"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10e1"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10e2"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10e6"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10e7"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10ef"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10f2"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("10fe"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1135"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("114a"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("114d"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("114e"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("114f"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1150"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1155"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1156"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("116f"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1174"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1175"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1176"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1177"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("1178"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("117f"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("119d"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("119e"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("119f"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11a0"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11a2"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11ed"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11ee"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11ef"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11f1"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11f2"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11f3"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11f4"));
+ fujitsu = g_list_append (fujitsu, g_strdup ("11fc"));
+ g_hash_table_insert (scanners,
+ g_strdup("04c5"),
+ fujitsu);
+ GList* konica = NULL;
+ konica = g_list_append (konica, g_strdup ("0722"));
+ g_hash_table_insert (scanners,
+ g_strdup("04c8"),
+ konica);
+ GList* panasonic = NULL;
+ panasonic = g_list_append (panasonic, g_strdup ("1000"));
+ panasonic = g_list_append (panasonic, g_strdup ("1001"));
+ panasonic = g_list_append (panasonic, g_strdup ("1006"));
+ panasonic = g_list_append (panasonic, g_strdup ("1007"));
+ panasonic = g_list_append (panasonic, g_strdup ("1009"));
+ panasonic = g_list_append (panasonic, g_strdup ("100a"));
+ panasonic = g_list_append (panasonic, g_strdup ("100f"));
+ panasonic = g_list_append (panasonic, g_strdup ("1010"));
+ g_hash_table_insert (scanners,
+ g_strdup("04da"),
+ panasonic);
+
+ GList* samsung = NULL;
+
+ samsung = g_list_append (samsung, g_strdup ("341b"));
+ samsung = g_list_append (samsung, g_strdup ("341f"));
+ samsung = g_list_append (samsung, g_strdup ("3426"));
+ samsung = g_list_append (samsung, g_strdup ("342a"));
+ samsung = g_list_append (samsung, g_strdup ("342b"));
+ samsung = g_list_append (samsung, g_strdup ("342c"));
+ samsung = g_list_append (samsung, g_strdup ("3433"));
+ samsung = g_list_append (samsung, g_strdup ("3434"));
+ samsung = g_list_append (samsung, g_strdup ("343c"));
+ samsung = g_list_append (samsung, g_strdup ("3434"));
+ g_hash_table_insert (scanners,
+ g_strdup("04e8"),
+ samsung);
+
+ GList* pentax = NULL;
+ pentax = g_list_append (pentax, g_strdup ("2038"));
+ g_hash_table_insert (scanners,
+ g_strdup("04f9"),
+ pentax);
+
+ GList* apitek = NULL;
+ apitek = g_list_append (apitek, g_strdup ("0202"));
+ g_hash_table_insert (scanners,
+ g_strdup("0553"),
+ apitek);
+
+ GList* mustek = NULL;
+ mustek = g_list_append (mustek, g_strdup ("0001"));
+ mustek = g_list_append (mustek, g_strdup ("0002"));
+ mustek = g_list_append (mustek, g_strdup ("0006"));
+ mustek = g_list_append (mustek, g_strdup ("0008"));
+ mustek = g_list_append (mustek, g_strdup ("0010"));
+ mustek = g_list_append (mustek, g_strdup ("0210"));
+ mustek = g_list_append (mustek, g_strdup ("0218"));
+ mustek = g_list_append (mustek, g_strdup ("0219"));
+ mustek = g_list_append (mustek, g_strdup ("021a"));
+ mustek = g_list_append (mustek, g_strdup ("021b"));
+ mustek = g_list_append (mustek, g_strdup ("021c"));
+ mustek = g_list_append (mustek, g_strdup ("021d"));
+ mustek = g_list_append (mustek, g_strdup ("021e"));
+ mustek = g_list_append (mustek, g_strdup ("021f"));
+ mustek = g_list_append (mustek, g_strdup ("0409"));
+ g_hash_table_insert (scanners,
+ g_strdup("055f"),
+ mustek);
+ GList* artec = NULL;
+ artec = g_list_append (artec, g_strdup ("4002"));
+ artec = g_list_append (artec, g_strdup ("4003"));
+ artec = g_list_append (artec, g_strdup ("4004"));
+ artec = g_list_append (artec, g_strdup ("4005"));
+ artec = g_list_append (artec, g_strdup ("4006"));
+ artec = g_list_append (artec, g_strdup ("4007"));
+ artec = g_list_append (artec, g_strdup ("4009"));
+ artec = g_list_append (artec, g_strdup ("4010"));
+ artec = g_list_append (artec, g_strdup ("4011"));
+ g_hash_table_insert (scanners,
+ g_strdup("05d8"),
+ artec);
+
+ GList* microtek = NULL;
+ microtek = g_list_append (microtek, g_strdup ("0099"));
+ microtek = g_list_append (microtek, g_strdup ("009a"));
+ microtek = g_list_append (microtek, g_strdup ("00a3"));
+ microtek = g_list_append (microtek, g_strdup ("00b6"));
+ microtek = g_list_append (microtek, g_strdup ("30cf"));
+ microtek = g_list_append (microtek, g_strdup ("30d4"));
+ microtek = g_list_append (microtek, g_strdup ("40b3"));
+ microtek = g_list_append (microtek, g_strdup ("40b8"));
+ microtek = g_list_append (microtek, g_strdup ("40ca"));
+ microtek = g_list_append (microtek, g_strdup ("40cb"));
+ microtek = g_list_append (microtek, g_strdup ("40dd"));
+ microtek = g_list_append (microtek, g_strdup ("40ff"));
+ microtek = g_list_append (microtek, g_strdup ("80a3"));
+ g_hash_table_insert (scanners,
+ g_strdup("05da"),
+ microtek);
+
+ GList* avision = NULL;
+ avision = g_list_append (avision, g_strdup ("0268"));
+ avision = g_list_append (avision, g_strdup ("026a"));
+ avision = g_list_append (avision, g_strdup ("0a13"));
+ avision = g_list_append (avision, g_strdup ("0a15"));
+ avision = g_list_append (avision, g_strdup ("0a16"));
+ avision = g_list_append (avision, g_strdup ("0a18"));
+ avision = g_list_append (avision, g_strdup ("0a19"));
+ avision = g_list_append (avision, g_strdup ("0a23"));
+ avision = g_list_append (avision, g_strdup ("0a24"));
+ avision = g_list_append (avision, g_strdup ("0a25"));
+ avision = g_list_append (avision, g_strdup ("0a27"));
+ avision = g_list_append (avision, g_strdup ("0a2a"));
+ avision = g_list_append (avision, g_strdup ("0a2b"));
+ avision = g_list_append (avision, g_strdup ("0a2c"));
+ avision = g_list_append (avision, g_strdup ("0a2d"));
+ avision = g_list_append (avision, g_strdup ("0a2e"));
+ avision = g_list_append (avision, g_strdup ("0a2f"));
+ avision = g_list_append (avision, g_strdup ("0a33"));
+ avision = g_list_append (avision, g_strdup ("0a3a"));
+ avision = g_list_append (avision, g_strdup ("0a3c"));
+ avision = g_list_append (avision, g_strdup ("0a40"));
+ avision = g_list_append (avision, g_strdup ("0a41"));
+ avision = g_list_append (avision, g_strdup ("0a45"));
+ avision = g_list_append (avision, g_strdup ("0a4d"));
+ avision = g_list_append (avision, g_strdup ("0a4e"));
+ avision = g_list_append (avision, g_strdup ("0a4f"));
+ avision = g_list_append (avision, g_strdup ("0a5e"));
+ avision = g_list_append (avision, g_strdup ("0a61"));
+ avision = g_list_append (avision, g_strdup ("0a65"));
+ avision = g_list_append (avision, g_strdup ("0a66"));
+ avision = g_list_append (avision, g_strdup ("0a68"));
+ avision = g_list_append (avision, g_strdup ("0a82"));
+ avision = g_list_append (avision, g_strdup ("0a84"));
+ avision = g_list_append (avision, g_strdup ("0a93"));
+ avision = g_list_append (avision, g_strdup ("0a94"));
+ avision = g_list_append (avision, g_strdup ("0aa1"));
+ avision = g_list_append (avision, g_strdup ("1a35"));
+ g_hash_table_insert (scanners,
+ g_strdup("0638"),
+ avision);
+ GList* minolta = NULL;
+ minolta = g_list_append (minolta, g_strdup ("4004"));
+ minolta = g_list_append (minolta, g_strdup ("400d"));
+ minolta = g_list_append (minolta, g_strdup ("400e"));
+ g_hash_table_insert (scanners,
+ g_strdup("0686"),
+ minolta);
+
+ GList* agfa = NULL;
+ agfa = g_list_append (agfa, g_strdup ("0001"));
+ agfa = g_list_append (agfa, g_strdup ("0002"));
+ agfa = g_list_append (agfa, g_strdup ("0100"));
+ agfa = g_list_append (agfa, g_strdup ("2061"));
+ agfa = g_list_append (agfa, g_strdup ("208d"));
+ agfa = g_list_append (agfa, g_strdup ("208f"));
+ agfa = g_list_append (agfa, g_strdup ("2091"));
+ agfa = g_list_append (agfa, g_strdup ("2093"));
+ agfa = g_list_append (agfa, g_strdup ("2095"));
+ agfa = g_list_append (agfa, g_strdup ("2097"));
+ agfa = g_list_append (agfa, g_strdup ("20fd"));
+ agfa = g_list_append (agfa, g_strdup ("20ff"));
+ g_hash_table_insert (scanners,
+ g_strdup("06bd"),
+ minolta);
+
+ GList* umax_2 = NULL;
+ umax_2 = g_list_append (umax_2, g_strdup ("0020"));
+ g_hash_table_insert (scanners,
+ g_strdup("06dc"),
+ umax_2);
+
+ GList* plustek = NULL;
+
+ plustek = g_list_append (plustek, g_strdup ("0001"));
+ plustek = g_list_append (plustek, g_strdup ("0010"));
+ plustek = g_list_append (plustek, g_strdup ("0011"));
+ plustek = g_list_append (plustek, g_strdup ("0013"));
+ plustek = g_list_append (plustek, g_strdup ("0015"));
+ plustek = g_list_append (plustek, g_strdup ("0017"));
+ plustek = g_list_append (plustek, g_strdup ("0400"));
+ plustek = g_list_append (plustek, g_strdup ("0401"));
+ plustek = g_list_append (plustek, g_strdup ("0402"));
+ plustek = g_list_append (plustek, g_strdup ("0403"));
+ plustek = g_list_append (plustek, g_strdup ("040b"));
+ plustek = g_list_append (plustek, g_strdup ("040e"));
+ plustek = g_list_append (plustek, g_strdup ("0412"));
+ plustek = g_list_append (plustek, g_strdup ("0413"));
+ plustek = g_list_append (plustek, g_strdup ("0422"));
+ plustek = g_list_append (plustek, g_strdup ("0454"));
+ plustek = g_list_append (plustek, g_strdup ("045f"));
+ plustek = g_list_append (plustek, g_strdup ("0462"));
+ plustek = g_list_append (plustek, g_strdup ("0900"));
+ g_hash_table_insert (scanners,
+ g_strdup("07b3"),
+ plustek);
+
+ GList* corex = NULL;
+ corex = g_list_append (corex, g_strdup ("0002"));
+ corex = g_list_append (corex, g_strdup ("0005"));
+ g_hash_table_insert (scanners,
+ g_strdup("08f0"),
+ corex);
+
+ GList* xerox = NULL;
+ xerox = g_list_append (xerox, g_strdup ("3d5d"));
+ xerox = g_list_append (xerox, g_strdup ("3da4"));
+ xerox = g_list_append (xerox, g_strdup ("420c"));
+ xerox = g_list_append (xerox, g_strdup ("4265"));
+ xerox = g_list_append (xerox, g_strdup ("4293"));
+ xerox = g_list_append (xerox, g_strdup ("4294"));
+ g_hash_table_insert (scanners,
+ g_strdup("0924"),
+ xerox);
+
+ GList* pentax_2 = NULL;
+ pentax_2 = g_list_append (pentax_2, g_strdup ("3210"));
+ g_hash_table_insert (scanners,
+ g_strdup("0a17"),
+ pentax_2);
+
+ GList* portable = NULL;
+ portable = g_list_append (portable, g_strdup ("1000"));
+ g_hash_table_insert (scanners,
+ g_strdup("0a53"),
+ portable);
+
+ GList* syscan = NULL;
+ syscan = g_list_append (syscan, g_strdup ("4600"));
+ syscan = g_list_append (syscan, g_strdup ("4802"));
+ syscan = g_list_append (syscan, g_strdup ("4803"));
+ syscan = g_list_append (syscan, g_strdup ("480c"));
+ syscan = g_list_append (syscan, g_strdup ("4810"));
+ syscan = g_list_append (syscan, g_strdup ("6620"));
+ g_hash_table_insert (scanners,
+ g_strdup("0a82"),
+ syscan);
+
+ GList* canon_2 = NULL;
+ canon_2 = g_list_append (canon_2, g_strdup ("160c"));
+ canon_2 = g_list_append (canon_2, g_strdup ("160f"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1614"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1617"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1618"));
+ canon_2 = g_list_append (canon_2, g_strdup ("161a"));
+ canon_2 = g_list_append (canon_2, g_strdup ("161b"));
+ canon_2 = g_list_append (canon_2, g_strdup ("161d"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1620"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1622"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1623"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1624"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1626"));
+ canon_2 = g_list_append (canon_2, g_strdup ("162b"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1638"));
+ canon_2 = g_list_append (canon_2, g_strdup ("1639"));
+ g_hash_table_insert (scanners,
+ g_strdup("1083"),
+ canon_2);
+
+ GList* digital = NULL;
+ digital = g_list_append (digital, g_strdup ("0001"));
+ g_hash_table_insert (scanners,
+ g_strdup("1183"),
+ digital);
+
+ GList* konica_2 = NULL;
+ konica_2 = g_list_append (konica_2, g_strdup ("2089"));
+ g_hash_table_insert (scanners,
+ g_strdup("132b"),
+ konica_2);
+
+ GList* umax = NULL;
+ umax = g_list_append (umax, g_strdup ("0010"));
+ umax = g_list_append (umax, g_strdup ("0030"));
+ umax = g_list_append (umax, g_strdup ("0050"));
+ umax = g_list_append (umax, g_strdup ("0060"));
+ umax = g_list_append (umax, g_strdup ("0070"));
+ umax = g_list_append (umax, g_strdup ("0130"));
+ umax = g_list_append (umax, g_strdup ("0160"));
+ umax = g_list_append (umax, g_strdup ("0230"));
+ g_hash_table_insert (scanners,
+ g_strdup("1606"),
+ umax);
+
+ GList* docketport = NULL;
+ docketport = g_list_append (docketport, g_strdup ("4810"));
+ g_hash_table_insert (scanners,
+ g_strdup("1dcc"),
+ docketport);
+
+ GList* dell = NULL;
+ dell = g_list_append (dell, g_strdup ("5105"));
+ dell = g_list_append (dell, g_strdup ("5124"));
+ dell = g_list_append (dell, g_strdup ("5250"));
+ g_hash_table_insert (scanners,
+ g_strdup("413c"),
+ dell);
+}
diff --git a/src/udev-mgr.c b/src/udev-mgr.c
index 6575ca5..e3328ec 100644
--- a/src/udev-mgr.c
+++ b/src/udev-mgr.c
@@ -17,22 +17,120 @@ 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 <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);
+static void udev_mgr_update_menuitems (UdevMgr* self);
+static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self,
+ GUdevDevice *device,
+ UdevMgrDeviceAction action);
+static void udev_mgr_handle_webcam (UdevMgr* self,
+ GUdevDevice* device,
+ UdevMgrDeviceAction action);
+static void udev_mgr_handle_scsi_device (UdevMgr* self,
+ GUdevDevice* device,
+ UdevMgrDeviceAction action);
+
+static void udev_mgr_cleanup_lists(gpointer data, gpointer self);
+static void udev_mgr_cleanup_entries(gpointer data, gpointer self);
+
+
+static void debug_device (UdevMgr* self,
+ GUdevDevice* device,
+ UdevMgrDeviceAction action);
+
+
+struct _UdevMgr
+{
+ GObject parent_instance;
+ DbusmenuMenuitem* scanner_item;
+ DbusmenuMenuitem* webcam_item;
+ GUdevClient* client;
+ GHashTable* supported_usb_scanners;
+ GHashTable* supported_scsi_scanners;
+ GHashTable* scanners_present;
+ GHashTable* webcams_present;
+};
+
+const char *subsystems[3] = {"usb", "scsi", "video4linux"};
+const gchar* usb_subsystem = "usb";
+const gchar* scsi_subsystem = "scsi";
+const gchar* video4linux_subsystem = "video4linux";
G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT);
static void
-udev_mgr_init (UdevMgr *object)
+udev_mgr_init (UdevMgr* self)
{
- /* TODO: Add initialization code here */
+ self->client = NULL;
+ self->supported_usb_scanners = NULL;
+ self->scanners_present = NULL;
+ self->webcams_present = NULL;
+ self->client = g_udev_client_new (subsystems);
+ self->supported_usb_scanners = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify)udev_mgr_cleanup_lists);
+ self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify)udev_mgr_cleanup_lists);
+ self->scanners_present = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_free);
+ self->webcams_present = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_free);
+
+ // load into memory all supported scanners ...
+ populate_usb_scanners (self->supported_usb_scanners);
+ populate_scsi_scanners (self->supported_scsi_scanners);
+ g_signal_connect (G_OBJECT (self->client),
+ "uevent",
+ G_CALLBACK (udev_mgr_uevent_cb),
+ self);
}
static void
-udev_mgr_finalize (GObject *object)
+udev_mgr_cleanup_lists(gpointer data, gpointer self)
{
- /* TODO: Add deinitalization code here */
+ GList* scanners = (GList*)data;
+ g_list_foreach (scanners, udev_mgr_cleanup_entries, NULL);
+ g_list_free(scanners);
+}
+
+static void
+udev_mgr_cleanup_entries(gpointer data, gpointer self)
+{
+ gchar* entry = (gchar*)data;
+ g_free(entry);
+}
+static void
+udev_mgr_finalize (GObject *object)
+{
+ UdevMgr* self = UDEV_MGR (object);
+ g_hash_table_destroy (self->supported_scsi_scanners);
+ g_hash_table_destroy (self->supported_usb_scanners);
+ g_hash_table_destroy (self->scanners_present);
+ g_hash_table_destroy (self->webcams_present);
G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object);
}
@@ -40,7 +138,319 @@ static void
udev_mgr_class_init (UdevMgrClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
-
object_class->finalize = udev_mgr_finalize;
}
+static void
+udevice_mgr_device_list_iterator (gpointer data, gpointer userdata)
+{
+ g_return_if_fail (G_UDEV_IS_DEVICE (data));
+ g_return_if_fail (UDEV_IS_MGR (userdata));
+
+ UdevMgr* self = UDEV_MGR (userdata);
+
+ GUdevDevice* device = G_UDEV_DEVICE (data);
+
+ const gchar* subsystem = NULL;
+ subsystem = g_udev_device_get_subsystem (device);
+
+ if (g_strcmp0 (subsystem, "usb") == 0){
+ udev_mgr_check_if_usb_device_is_supported (self, device, ADD);
+ }
+ else if (g_strcmp0 (subsystem, "video4linux") == 0){
+ udev_mgr_handle_webcam (self, device, ADD);
+ }
+ else if (g_strcmp0 (subsystem, "scsi") == 0){
+ udev_mgr_handle_scsi_device (self, device, ADD);
+ }
+
+ g_object_unref (device);
+}
+
+
+static void udev_mgr_update_menuitems (UdevMgr* self)
+{
+ dbusmenu_menuitem_property_set_bool (self->scanner_item,
+ DBUSMENU_MENUITEM_PROP_VISIBLE,
+ g_hash_table_size (self->scanners_present) > 0);
+
+ dbusmenu_menuitem_property_set_bool (self->webcam_item,
+ DBUSMENU_MENUITEM_PROP_VISIBLE,
+ g_hash_table_size (self->webcams_present) > 0);
+
+}
+
+static void udev_mgr_uevent_cb (GUdevClient *client,
+ gchar *action,
+ GUdevDevice *device,
+ gpointer user_data)
+{
+ g_return_if_fail (UDEV_IS_MGR (user_data));
+ UdevMgr* self = UDEV_MGR (user_data);
+ g_return_if_fail (device != NULL);
+
+ g_debug ("just received a UEVENT with an action : %s", action);
+
+ UdevMgrDeviceAction udev_mgr_action = ADD;
+
+ if (g_strcmp0 (action, "remove") == 0){
+ udev_mgr_action = REMOVE;
+ }
+
+ const gchar* subsystem = NULL;
+ subsystem = g_udev_device_get_subsystem (device);
+
+ if (g_strcmp0 (subsystem, "usb") == 0){
+ udev_mgr_check_if_usb_device_is_supported (self,
+ device,
+ udev_mgr_action);
+ }
+ else if (g_strcmp0 (subsystem, "video4linux") == 0){
+ udev_mgr_handle_webcam (self, device, udev_mgr_action);
+ }
+ else if (g_strcmp0 (subsystem, "scsi") == 0){
+ udev_mgr_handle_scsi_device (self, device, udev_mgr_action);
+ }
+}
+
+
+static void
+udev_mgr_handle_webcam (UdevMgr* self,
+ GUdevDevice* device,
+ UdevMgrDeviceAction action)
+{
+ if (FALSE)
+ debug_device (self, device, action);
+
+ const gchar* vendor;
+ const gchar* product;
+
+ vendor = g_udev_device_get_property (device, "ID_VENDOR_ID");
+ product = g_udev_device_get_property (device, "ID_MODEL_ID");
+
+ if (action == REMOVE){
+ if (g_hash_table_lookup (self->webcams_present, product) == NULL){
+ g_warning ("Got a remove event on a webcam device but we don't have that device in our webcam cache");
+ return;
+ }
+ g_hash_table_remove (self->webcams_present,
+ product);
+
+ }
+ else {
+ if (g_hash_table_lookup (self->webcams_present, product) != NULL){
+ g_warning ("Got an ADD event on a webcam device but we already have that device in our webcam cache");
+ return;
+ }
+ g_hash_table_insert (self->webcams_present,
+ g_strdup (product),
+ g_strdup (vendor));
+ }
+ udev_mgr_update_menuitems (self);
+}
+
+static void
+debug_device (UdevMgr* self,
+ GUdevDevice* device,
+ UdevMgrDeviceAction action)
+{
+ const gchar* vendor;
+ const gchar* product;
+ const gchar* number;
+ const gchar* name;
+
+ vendor = g_udev_device_get_property (device, "ID_VENDOR_ID");
+ product = g_udev_device_get_property (device, "ID_MODEL_ID");
+ number = g_udev_device_get_number (device);
+ name = g_udev_device_get_name (device);
+
+ g_debug ("device vendor id %s , product id of %s , number of %s and name of %s",
+ g_strdup(vendor),
+ g_strdup(product),
+ g_strdup(number),
+ g_strdup(name));
+
+ const gchar *const *list;
+ const gchar *const *iter;
+ char propstr[500];
+ guint32 namelen = 0, i;
+
+ list = g_udev_device_get_property_keys(device);
+
+ for (iter = list; iter && *iter; iter++) {
+ if (strlen(*iter) > namelen)
+ namelen = strlen(*iter);
+ }
+ namelen++;
+
+ for (iter = list; iter && *iter; iter++) {
+ strcpy(propstr, *iter);
+ strcat(propstr, ":");
+ for (i = 0; i < namelen - strlen(*iter); i++)
+ strcat(propstr, " ");
+ strcat(propstr, g_udev_device_get_property(device, *iter));
+ g_debug("%s", propstr);
+ }
+}
+
+static void udev_mgr_handle_scsi_device (UdevMgr* self,
+ GUdevDevice* device,
+ UdevMgrDeviceAction action)
+{
+ const gchar* type = NULL;
+ type = g_udev_device_get_property (device, "TYPE");
+ // apparently anything thats type 3 and SCSI is a Scanner
+ if (g_strcmp0 (type, "6") == 0){
+ gchar* random_scanner_name = g_strdup_printf("%p--scanner", self);
+ g_hash_table_insert (self->scanners_present,
+ random_scanner_name,
+ g_strdup("Scanner"));
+ udev_mgr_update_menuitems (self);
+ return;
+ }
+
+ // We only care about type 3 for the special cases below
+ if (g_strcmp0 (type, "3") != 0){
+ return;
+ }
+
+ const gchar* vendor = NULL;
+ vendor = g_udev_device_get_property (device, "VENDOR");
+
+ if (vendor == NULL)
+ return;
+
+ GList* vendor_list = NULL;
+ vendor_list = g_hash_table_lookup (self->supported_scsi_scanners,
+ (gpointer)vendor);
+ if (vendor_list == NULL)
+ return;
+
+ const gchar* model_id = NULL;
+ model_id = g_udev_device_get_property (device, "MODEL");
+
+ if (model_id == NULL)
+ return;
+
+ GList* model_entry = NULL;
+ model_entry = g_list_find_custom (vendor_list,
+ model_id,
+ (GCompareFunc)g_strcmp0);
+
+ if (model_entry != NULL){
+ if (action == REMOVE){
+ if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){
+ g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache");
+ }
+ else{
+ g_hash_table_remove (self->scanners_present, vendor);
+ }
+ }
+ else{
+ if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){
+ g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache");
+ }
+ else{
+ g_hash_table_insert (self->scanners_present,
+ g_strdup(vendor),
+ g_strdup(model_id));
+ }
+ }
+ udev_mgr_update_menuitems (self);
+ }
+}
+
+static void
+udev_mgr_check_if_usb_device_is_supported (UdevMgr* self,
+ GUdevDevice *device,
+ UdevMgrDeviceAction action)
+{
+ const gchar* vendor = NULL;
+ debug_device (self, device, action);
+
+ vendor = g_udev_device_get_property (device, "ID_VENDOR_ID");
+
+ if (vendor == NULL)
+ return;
+
+ //g_debug ("vendor = %s", vendor);
+
+ GList* vendor_list = NULL;
+ vendor_list = g_hash_table_lookup (self->supported_usb_scanners,
+ (gpointer)vendor);
+ if (vendor_list == NULL)
+ return;
+
+ const gchar* model_id = NULL;
+ model_id = g_udev_device_get_property (device, "ID_MODEL_ID");
+
+ if (model_id == NULL)
+ return;
+
+ GList* model_entry = NULL;
+ model_entry = g_list_find_custom(vendor_list, model_id, (GCompareFunc)g_strcmp0);
+
+ if (model_entry != NULL){
+ if (action == REMOVE){
+ if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){
+ g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache");
+ }
+ else{
+ g_hash_table_remove (self->scanners_present, vendor);
+ }
+ }
+ else{
+ if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){
+ g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache");
+ }
+ else{
+ g_hash_table_insert (self->scanners_present,
+ g_strdup(vendor),
+ g_strdup(model_id));
+ }
+ }
+ udev_mgr_update_menuitems (self);
+ }
+}
+
+UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner,
+ DbusmenuMenuitem* webcam)
+{
+ UdevMgr* mgr = g_object_new (UDEV_TYPE_MGR, NULL);
+ mgr->scanner_item = scanner;
+ mgr->webcam_item = webcam;
+
+ // Check for USB devices
+ GList* usb_devices_available = NULL;
+ usb_devices_available = g_udev_client_query_by_subsystem (mgr->client,
+ usb_subsystem);
+ if (usb_devices_available != NULL){
+ g_list_foreach (usb_devices_available,
+ udevice_mgr_device_list_iterator,
+ mgr);
+
+ g_list_free (usb_devices_available);
+ }
+ // Check for webcams
+ GList* video_devices_available = NULL;
+ video_devices_available = g_udev_client_query_by_subsystem (mgr->client,
+ video4linux_subsystem);
+ if (video_devices_available != NULL){
+ g_list_foreach (video_devices_available,
+ udevice_mgr_device_list_iterator,
+ mgr);
+
+ g_list_free (video_devices_available);
+ }
+ // Check for SCSI devices
+ GList* scsi_devices_available = NULL;
+ scsi_devices_available = g_udev_client_query_by_subsystem (mgr->client,
+ scsi_subsystem);
+ if (scsi_devices_available != NULL){
+ g_list_foreach (scsi_devices_available,
+ udevice_mgr_device_list_iterator,
+ mgr);
+ g_list_free (scsi_devices_available);
+ }
+ return mgr;
+}
diff --git a/src/udev-mgr.h b/src/udev-mgr.h
index 1c5ae73..5119803 100644
--- a/src/udev-mgr.h
+++ b/src/udev-mgr.h
@@ -21,6 +21,14 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define _UDEV_MGR_H_
#include <glib-object.h>
+#include <libdbusmenu-glib/client.h>
+
+#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+#include <libdbusmenu-gtk3/menuitem.h>
+#else
+#include <libdbusmenu-gtk/menuitem.h>
+#endif
G_BEGIN_DECLS
@@ -39,12 +47,15 @@ struct _UdevMgrClass
GObjectClass parent_class;
};
-struct _UdevMgr
-{
- GObject parent_instance;
-};
GType udev_mgr_get_type (void) G_GNUC_CONST;
+UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner_item,
+ DbusmenuMenuitem* webcam_item);
+
+typedef enum {
+ ADD,
+ REMOVE
+}UdevMgrDeviceAction;
G_END_DECLS
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 611bcc7..bf3b77f 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -149,10 +149,9 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
for (u = users; u != NULL; u = g_list_next (u)) {
user = u->data;
+ g_debug ("%p: %s", user, user->real_name);
user->service = self->users_dbus_interface;
- g_debug ("%i %s", (gint)user->uid, user->user_name);
-
if (g_strcmp0(user->user_name, "guest") == 0) {
/* Check to see if the guest has sessions and so therefore should
get a check mark. */
@@ -171,13 +170,26 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) {
mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
+ dbusmenu_menuitem_property_set (mi,
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ USER_ITEM_TYPE);
if (user->real_name_conflict) {
gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name);
dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname);
g_free(conflictedname);
} else {
- dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name);
+ //g_debug ("%i %s", (gint)user->uid, user->real_name);
+ //g_debug ("users uid = %i", (gint)user->uid);
+ //g_debug ("users real name = %s", user->real_name);
+ if (user == NULL){
+ g_debug ("USER pointer is NULL");
+ return;
+ }
+ g_debug ("%p: %s", user, user->real_name);
+
+ dbusmenu_menuitem_property_set (mi,
+ USER_ITEM_PROP_NAME,
+ user->real_name);
}
dbusmenu_menuitem_property_set_bool (mi,
USER_ITEM_PROP_LOGGED_IN,