aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-07-25 18:42:24 +0100
committerConor Curran <conor.curran@canonical.com>2011-07-25 18:42:24 +0100
commit6dce39846999951353c2e866019a79d568c99dfa (patch)
tree80e5c881b57f25be08b6e4991421281ac662447c /src
parenta1a7357b58d182e077ebfe8fb11c083e5eb18839 (diff)
downloadayatana-indicator-session-6dce39846999951353c2e866019a79d568c99dfa.tar.gz
ayatana-indicator-session-6dce39846999951353c2e866019a79d568c99dfa.tar.bz2
ayatana-indicator-session-6dce39846999951353c2e866019a79d568c99dfa.zip
the beginnings of the udev work
Diffstat (limited to 'src')
-rw-r--r--src/device-menu-mgr.c8
-rw-r--r--src/udev-mgr.c68
-rw-r--r--src/udev-mgr.h14
3 files changed, 78 insertions, 12 deletions
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index 324b3f1..063045e 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;
@@ -214,7 +215,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,
@@ -681,7 +681,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 (webcam_menuitem, scanners_menuitem);
}
diff --git a/src/udev-mgr.c b/src/udev-mgr.c
index 6575ca5..b5c1936 100644
--- a/src/udev-mgr.c
+++ b/src/udev-mgr.c
@@ -18,21 +18,63 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "udev-mgr.h"
+#include <gudev/gudev.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);
+struct _UdevMgr
+{
+ GObject parent_instance;
+ DbusmenuMenuitem* scanner_item;
+ DbusmenuMenuitem* webcam_item;
+ GUdevClient* client;
+};
G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT);
static void
-udev_mgr_init (UdevMgr *object)
+udev_mgr_init (UdevMgr* self)
+{
+ self->client = NULL;
+ const gchar *subsystems[1] = {"usb"};
+ self->client = g_udev_client_new (subsystems);
+ const gchar* usb_subsystem = "usb";
+
+ GList* devices_available = g_udev_client_query_by_subsystem (self->client,
+ usb_subsystem);
+
+ if (FALSE){
+ g_list_foreach (devices_available, udevice_mgr_device_list_iterator, self);
+ }
+ //g_list_free (devices_available);
+ if (FALSE){
+ g_signal_connect (G_OBJECT (self->client),
+ "u-event",
+ G_CALLBACK (udev_mgr_uevent_cb),
+ self);
+ }
+}
+
+static void
+udevice_mgr_device_list_iterator (gpointer data, gpointer userdata)
{
- /* TODO: Add initialization code here */
+ g_return_if_fail (G_UDEV_IS_DEVICE (data));
+ GUdevDevice* device = G_UDEV_DEVICE (data);
+ const gchar* name = g_udev_device_get_name (device);
+
+ g_debug ("UDEV MGR - the name of the device = %s", name);
+ // for now tidy up here.
+ g_object_unref (device);
}
static void
udev_mgr_finalize (GObject *object)
{
- /* TODO: Add deinitalization code here */
-
G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object);
}
@@ -40,7 +82,23 @@ static void
udev_mgr_class_init (UdevMgrClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
-
object_class->finalize = udev_mgr_finalize;
}
+static void udev_mgr_uevent_cb (GUdevClient *client,
+ gchar *action,
+ GUdevDevice *device,
+ gpointer user_data)
+{
+ g_debug ("just received a UEVENT with an action : %s", action);
+ g_return_if_fail (UDEV_IS_MGR (user_data));
+}
+
+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;
+ return mgr;
+}
diff --git a/src/udev-mgr.h b/src/udev-mgr.h
index 1c5ae73..323364a 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,10 @@ 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);
G_END_DECLS