start writing a SessionMonitor class
authorDavid Zeuthen <davidz@redhat.com>
Tue, 13 Jan 2009 21:27:54 +0000 (16:27 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Tue, 13 Jan 2009 21:27:54 +0000 (16:27 -0500)
src/polkitbackend/Makefile.am
src/polkitbackend/org.freedesktop.ConsoleKit.xml [new file with mode: 0644]
src/polkitbackend/polkitbackend.h
src/polkitbackend/polkitbackendlocalauthority.h
src/polkitbackend/polkitbackendsessionmonitor.c [new file with mode: 0644]
src/polkitbackend/polkitbackendsessionmonitor.h [new file with mode: 0644]
src/polkitbackend/polkitbackendtypes.h

index 6e3e566..29cb6cc 100644 (file)
@@ -15,6 +15,25 @@ INCLUDES =                                                      \
        -DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE              \
         $(NULL)
 
+BUILT_SOURCES =                                                                                \
+       ckmanager.c                             ckmanager.h                             \
+       cksession.c                             cksession.h                             \
+       ckseat.c                                ckseat.h                                \
+       ckdevice.c                              ckdevice.h                              \
+       ckbindings.c                            ckbindings.h                            \
+       ckbindingsmarshal.list                                                          \
+       ckbindingsmarshal.c                     ckbindingsmarshal.h                     \
+       ckbindingstypes.h                                                               \
+       ckerror.c                               ckerror.h                               \
+       $(NULL)
+
+$(BUILT_SOURCES) : Makefile.am $(top_srcdir)/src/polkitbackend/org.freedesktop.ConsoleKit.xml
+       eggdbus-binding-tool                                                                    \
+         --namespace       "Ck"                                                                \
+         --dbus-namespace  "org.freedesktop.ConsoleKit"                                        \
+         --introspection-xml $(top_srcdir)/src/polkitbackend/org.freedesktop.ConsoleKit.xml    \
+         $(NULL)
+
 lib_LTLIBRARIES=libpolkit-backend-1.la
 
 libpolkit_backend_1includedir=$(includedir)/polkit-1/polkitbackend
@@ -27,6 +46,7 @@ libpolkit_backend_1include_HEADERS =                                  \
        polkitbackendactionpool.h                                       \
        polkitbackendpendingcall.h                                      \
        polkitbackendserver.h                                           \
+       polkitbackendsessionmonitor.h                                   \
         $(NULL)
 
 libpolkit_backend_1_la_SOURCES =                                       \
@@ -38,6 +58,8 @@ libpolkit_backend_1_la_SOURCES =                                      \
        polkitbackendactionpool.h       polkitbackendactionpool.c       \
        polkitbackendpendingcall.h      polkitbackendpendingcall.c      \
        polkitbackendserver.h           polkitbackendserver.c           \
+       polkitbackendsessionmonitor.h   polkitbackendsessionmonitor.c   \
+       $(BUILT_SOURCES)                                                \
         $(NULL)
 
 libpolkit_backend_1_la_CFLAGS =                                                \
diff --git a/src/polkitbackend/org.freedesktop.ConsoleKit.xml b/src/polkitbackend/org.freedesktop.ConsoleKit.xml
new file mode 100644 (file)
index 0000000..d0134be
--- /dev/null
@@ -0,0 +1,276 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+
+  <!-- The error domain used for reporting errors -->
+  <annotation name="org.gtk.EggDBus.DeclareErrorDomain" value="Error">
+    <annotation name="org.gtk.EggDBus.ErrorDomain.Member" value="org.freedesktop.ConsoleKit.Manager.GeneralError">
+      <annotation name="org.gtk.EggDBus.ErrorDomain.Member.Value" value="0"/>
+    </annotation>
+    <annotation name="org.gtk.EggDBus.ErrorDomain.Member" value="org.freedesktop.ConsoleKit.Manager.NotPrivileged"/>
+
+    <annotation name="org.gtk.EggDBus.ErrorDomain.Member" value="org.freedesktop.ConsoleKit.Seat.GeneralError">
+      <annotation name="org.gtk.EggDBus.ErrorDomain.Member.Value" value="100"/>
+    </annotation>
+
+    <annotation name="org.gtk.EggDBus.ErrorDomain.Member" value="org.freedesktop.ConsoleKit.Session.GeneralError">
+      <annotation name="org.gtk.EggDBus.ErrorDomain.Member.Value" value="200"/>
+    </annotation>
+  </annotation>
+
+  <!-- Device -->
+  <annotation name="org.gtk.EggDBus.DeclareStruct" value="Device">
+    <annotation name="org.gtk.EggDBus.DocString" value="The #Device type represents devices that are associated with seats."/>
+    <annotation name="org.gtk.EggDBus.DocString.Summary" value="Devices"/>
+
+    <annotation name="org.gtk.EggDBus.Struct.Member"  value="s:id1">
+      <annotation name="org.gtk.EggDBus.DocString" value="The first device identifier"/>
+    </annotation>
+    <annotation name="org.gtk.EggDBus.Struct.Member" value="s:id2">
+      <annotation name="org.gtk.EggDBus.DocString" value="The second device identifier"/>
+    </annotation>
+  </annotation>
+
+  <!-- -->
+
+  <interface name="org.freedesktop.ConsoleKit.Manager">
+
+    <!-- All of these should probably be read-only properties instead of methods -->
+    <method name="GetSystemIdleSinceHint">
+      <arg name="iso8601_datetime" type="s" direction="out"/>
+    </method>
+    <method name="GetSystemIdleHint">
+      <arg name="idle_hint" type="b" direction="out"/>
+    </method>
+    <method name="GetSessions">
+      <arg name="sessions" type="ao" direction="out"/>
+    </method>
+    <method name="GetSeats">
+      <arg name="seats" type="ao" direction="out"/>
+    </method>
+    <method name="GetCurrentSession">
+      <arg name="ssid" type="o" direction="out"/>
+    </method>
+
+    <method name="GetSessionsForUser">
+      <arg name="uid" type="u" direction="in"/>
+      <arg name="sessions" type="ao" direction="out"/>
+    </method>
+    <method name="GetSessionsForUnixUser">
+      <arg name="uid" type="u" direction="in"/>
+      <arg name="sessions" type="ao" direction="out"/>
+    </method>
+    <method name="GetSessionForUnixProcess">
+      <arg name="pid" type="u" direction="in"/>
+      <arg name="ssid" type="o" direction="out"/>
+    </method>
+    <method name="GetSessionForCookie">
+      <arg name="cookie" type="s" direction="in"/>
+      <arg name="ssid" type="o" direction="out"/>
+    </method>
+
+    <method name="CloseSession">
+      <arg name="cookie" type="s" direction="in"/>
+      <arg name="result" type="b" direction="out"/>
+    </method>
+    <method name="OpenSessionWithParameters">
+      <arg name="parameters" type="a(sv)" direction="in"/>
+      <arg name="cookie" type="s" direction="out"/>
+    </method>
+    <method name="OpenSession">
+      <arg name="cookie" type="s" direction="out"/>
+    </method>
+    <method name="Stop">
+    </method>
+    <method name="Restart">
+    </method>
+
+    <!-- If the above Get*() methods are properties and we have org.fd.Properties.Changed() these signals
+         are not needed -->
+    <signal name="SystemIdleHintChanged">
+      <arg type="b"/>
+    </signal>
+    <signal name="SeatRemoved">
+      <arg type="o"/>
+    </signal>
+    <signal name="SeatAdded">
+      <arg type="o"/>
+    </signal>
+  </interface>
+
+  <interface name="org.freedesktop.ConsoleKit.Seat">
+    <method name="ActivateSession">
+      <arg name="ssid" type="o" direction="in"/>
+    </method>
+
+    <!-- All of these should probably be read-only properties instead of Get*() methods -->
+    <method name="CanActivateSessions">
+      <arg name="can_activate" type="b" direction="out"/>
+    </method>
+    <method name="GetActiveSession">
+      <arg name="ssid" type="o" direction="out"/>
+    </method>
+    <method name="GetDevices">
+      <arg name="devices" type="a(ss)" direction="out"/>
+    </method>
+    <method name="GetSessions">
+      <arg name="sessions" type="ao" direction="out"/>
+    </method>
+    <method name="GetId">
+      <arg name="sid" type="o" direction="out"/>
+    </method>
+
+    <signal name="DeviceRemoved">
+      <arg type="(ss)"/>
+    </signal>
+    <signal name="DeviceAdded">
+      <arg type="(ss)"/>
+    </signal>
+
+    <!-- If the above Get*() methods are properties and we have org.fd.Properties.Changed() these signals
+         are not needed -->
+    <signal name="SessionRemoved">
+      <arg type="o"/>
+    </signal>
+    <signal name="SessionAdded">
+      <arg type="o"/>
+    </signal>
+    <signal name="ActiveSessionChanged">
+      <arg type="s"/>
+    </signal>
+  </interface>
+
+  <interface name="org.freedesktop.ConsoleKit.Session">
+    <method name="SetIdleHint">
+      <arg name="idle_hint" type="b" direction="in"/>
+    </method>
+
+    <!-- This should really be a read-only property, not a method -->
+    <method name="GetIdleSinceHint">
+      <arg name="iso8601_datetime" type="s" direction="out"/>
+    </method>
+
+    <!-- superfluous: there's already :idle-hint
+       <method name="GetIdleHint">
+         <arg name="idle_hint" type="b" direction="out"/>
+       </method>
+    -->
+
+    <method name="Unlock">
+    </method>
+    <method name="Lock">
+    </method>
+    <method name="Activate">
+    </method>
+
+    <!-- This should really be a read-only property, not a method -->
+    <method name="GetCreationTime">
+      <arg name="iso8601_datetime" type="s" direction="out"/>
+    </method>
+
+    <!-- superfluous: there's already :is-local
+       <method name="IsLocal">
+         <arg name="local" type="b" direction="out"/>
+       </method>
+     -->
+
+    <!-- superfluous: there's already :is-active
+    <method name="IsActive">
+      <arg name="active" type="b" direction="out"/>
+    </method>
+    -->
+
+    <method name="GetLoginSessionId">
+      <arg name="login_session_id" type="s" direction="out"/>
+    </method>
+
+    <!-- superfluous: there's already :remote-host-name
+      <method name="GetRemoteHostName">
+        <arg name="remote_host_name" type="s" direction="out"/>
+       </method>
+    -->
+
+    <!-- superfluous: there's already :display-device
+      <method name="GetDisplayDevice">
+        <arg name="display_device" type="s" direction="out"/>
+      </method>
+    -->
+
+    <!-- superfluous: there's already :x11-display-device
+    <method name="GetX11DisplayDevice">
+      <arg name="x11_display_device" type="s" direction="out"/>
+    </method>
+    -->
+
+    <!-- superfluous: there's already :x11-display
+    <method name="GetX11Display">
+      <arg name="display" type="s" direction="out"/>
+    </method>
+    -->
+
+    <!-- superfluous: there's already :unix-user
+    <method name="GetUnixUser">
+      <arg name="uid" type="u" direction="out"/>
+    </method>
+    -->
+
+    <!-- superfluous: there's already :user
+    <method name="GetUser">
+      <arg name="uid" type="u" direction="out"/>
+    </method>
+    -->
+
+    <!-- superfluous: there's already :session-type
+    <method name="GetSessionType">
+      <arg name="type" type="s" direction="out"/>
+    </method>
+    -->
+
+    <!-- This should really be a read-only property, not a method -->
+    <method name="GetSeatId">
+      <arg name="sid" type="o" direction="out"/>
+    </method>
+
+    <!-- This should really be a read-only property, not a method -->
+    <method name="GetId">
+      <arg name="ssid" type="o" direction="out"/>
+    </method>
+
+    <!-- This should probably be called Unlocked -->
+    <signal name="Unlock">
+    </signal>
+
+    <!-- This should probably be called Locked -->
+    <signal name="Lock">
+    </signal>
+
+    <!-- superfluous if you have the org.fd.Properties.Changed() signal -->
+    <signal name="IdleHintChanged">
+      <arg type="b"/>
+    </signal>
+
+    <!-- superfluous if you have the org.fd.Properties.Changed() signal -->
+    <signal name="ActiveChanged">
+      <arg type="b"/>
+    </signal>
+
+    <!--
+       Note: ConsoleKit declares these as readwrite but since setting may fail (due to lack
+             of privilege) they shouldn't be properties [1]; instead use Set* methods.
+
+             [1] : most object systems, specifically GObject, don't have a way to return
+                   errors when setting properties
+      -->
+    <property name="idle-hint" type="b" access="read"/>
+    <property name="is-local" type="b" access="read"/>
+    <property name="active" type="b" access="read"/>
+    <property name="x11-display-device" type="s" access="read"/>
+    <property name="x11-display" type="s" access="read"/>
+    <property name="display-device" type="s" access="read"/>
+    <property name="remote-host-name" type="s" access="read"/>
+    <property name="session-type" type="s" access="read"/>
+    <property name="user" type="u" access="read"/>
+    <property name="unix-user" type="u" access="read"/>
+  </interface>
+
+</node>
index 84de7af..b9bb362 100644 (file)
@@ -29,6 +29,7 @@
 #include <polkitbackend/polkitbackendlocalauthority.h>
 #include <polkitbackend/polkitbackendactionpool.h>
 #include <polkitbackend/polkitbackendserver.h>
+#include <polkitbackend/polkitbackendsessionmonitor.h>
 #undef _POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H
 
 #endif /* __POLKIT_BACKEND_H */
index 1bdc50f..6f8e527 100644 (file)
@@ -27,6 +27,7 @@
 #define __POLKIT_BACKEND_LOCAL_AUTHORITY_H
 
 #include <glib-object.h>
+#include <polkitbackend/polkitbackendtypes.h>
 #include <polkitbackend/polkitbackendauthority.h>
 
 G_BEGIN_DECLS
@@ -38,7 +39,10 @@ G_BEGIN_DECLS
 #define POLKIT_BACKEND_IS_LOCAL_AUTHORITY(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_LOCAL_AUTHORITY))
 #define POLKIT_BACKEND_IS_LOCAL_AUTHORITY_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_LOCAL_AUTHORITY))
 
+#if 0
 typedef struct _PolkitBackendLocalAuthority         PolkitBackendLocalAuthority;
+#endif
+
 typedef struct _PolkitBackendLocalAuthorityClass    PolkitBackendLocalAuthorityClass;
 
 struct _PolkitBackendLocalAuthority
diff --git a/src/polkitbackend/polkitbackendsessionmonitor.c b/src/polkitbackend/polkitbackendsessionmonitor.c
new file mode 100644 (file)
index 0000000..ac370f7
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"
+#include <errno.h>
+#include <pwd.h>
+#include <grp.h>
+#include <string.h>
+#include <polkit/polkit.h>
+#include "polkitbackendsessionmonitor.h"
+#include "ckbindings.h"
+
+struct _PolkitBackendSessionMonitor
+{
+  GObject parent_instance;
+
+  EggDBusObjectProxy *ck_manager_object_proxy;
+  CkManager *ck_manager;
+};
+
+struct _PolkitBackendSessionMonitorClass
+{
+  GObjectClass parent_class;
+
+};
+
+G_DEFINE_TYPE (PolkitBackendSessionMonitor, polkit_backend_session_monitor, G_TYPE_OBJECT);
+
+static void
+polkit_backend_session_monitor_init (PolkitBackendSessionMonitor *monitor)
+{
+  EggDBusConnection *system_bus;
+
+  system_bus = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
+
+  monitor->ck_manager_object_proxy = egg_dbus_connection_get_object_proxy (system_bus,
+                                                                           "org.freedesktop.ConsoleKit",
+                                                                           "/org/freedesktop/ConsoleKit/Manager");
+
+  monitor->ck_manager = CK_QUERY_INTERFACE_MANAGER (monitor->ck_manager_object_proxy);
+
+  g_object_unref (system_bus);
+}
+
+static void
+polkit_backend_session_monitor_finalize (GObject *object)
+{
+  PolkitBackendSessionMonitor *monitor = POLKIT_BACKEND_SESSION_MONITOR (object);
+
+  g_object_unref (monitor->ck_manager_object_proxy);
+
+  if (G_OBJECT_CLASS (polkit_backend_session_monitor_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_backend_session_monitor_parent_class)->finalize (object);
+}
+
+static void
+polkit_backend_session_monitor_class_init (PolkitBackendSessionMonitorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_backend_session_monitor_finalize;
+}
+
+PolkitBackendSessionMonitor *
+polkit_backend_session_monitor_new (void)
+{
+  PolkitBackendSessionMonitor *monitor;
+
+  monitor = POLKIT_BACKEND_SESSION_MONITOR (g_object_new (POLKIT_BACKEND_TYPE_SESSION_MONITOR, NULL));
+
+  return monitor;
+}
+
diff --git a/src/polkitbackend/polkitbackendsessionmonitor.h b/src/polkitbackend/polkitbackendsessionmonitor.h
new file mode 100644 (file)
index 0000000..a5a39f9
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#if !defined (_POLKIT_BACKEND_COMPILATION) && !defined(_POLKIT_BACKEND_INSIDE_POLKIT_BACKEND_H)
+#error "Only <polkitbackend/polkitbackend.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __POLKIT_BACKEND_SESSION_MONITOR_H
+#define __POLKIT_BACKEND_SESSION_MONITOR_H
+
+#include <glib-object.h>
+#include <polkitbackend/polkitbackendtypes.h>
+
+G_BEGIN_DECLS
+
+#define POLKIT_BACKEND_TYPE_SESSION_MONITOR         (polkit_backend_session_monitor_get_type ())
+#define POLKIT_BACKEND_SESSION_MONITOR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_SESSION_MONITOR, PolkitBackendSessionMonitor))
+#define POLKIT_BACKEND_SESSION_MONITOR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_SESSION_MONITOR, PolkitBackendSessionMonitorClass))
+#define POLKIT_BACKEND_SESSION_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_SESSION_MONITOR,PolkitBackendSessionMonitorClass))
+#define POLKIT_BACKEND_IS_SESSION_MONITOR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_SESSION_MONITOR))
+#define POLKIT_BACKEND_IS_SESSION_MONITOR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_SESSION_MONITOR))
+
+#if 0
+typedef struct _PolkitBackendSessionMonitor         PolkitBackendSessionMonitor;
+#endif
+typedef struct _PolkitBackendSessionMonitorClass    PolkitBackendSessionMonitorClass;
+
+GType                        polkit_backend_session_monitor_get_type (void) G_GNUC_CONST;
+PolkitBackendSessionMonitor *polkit_backend_session_monitor_new      (void);
+
+G_END_DECLS
+
+#endif /* __POLKIT_BACKEND_SESSION_MONITOR_H */
+
index a1ebd8e..9f3b79a 100644 (file)
 struct _PolkitBackendAuthority;
 typedef struct _PolkitBackendAuthority PolkitBackendAuthority;
 
+struct _PolkitBackendLocalAuthority;
+typedef struct _PolkitBackendLocalAuthority PolkitBackendLocalAuthority;
+
 struct _PolkitBackendPendingCall;
 typedef struct _PolkitBackendPendingCall PolkitBackendPendingCall;
 
 struct _PolkitBackendServer;
 typedef struct _PolkitBackendServer PolkitBackendServer;
 
+struct _PolkitBackendSessionMonitor;
+typedef struct _PolkitBackendSessionMonitor PolkitBackendSessionMonitor;
+
+
 #endif /* __POLKIT_BACKEND_TYPES_H */