2004-05-28 Padraig O'Briain <padraig.obriain@sun.com>
authorpadraigo <padraigo@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Fri, 28 May 2004 10:54:11 +0000 (10:54 +0000)
committerpadraigo <padraigo@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Fri, 28 May 2004 10:54:11 +0000 (10:54 +0000)
* libloginhelper-1.0.pc.in:
* idl/Accessibility_LoginHelper.idl:
* login-helper/Makefile.am:
* login-helper/login-helper.[ch]:
* test/login-helper-client-test.c:
* test/login-helper-server-test.c: Added files missing from CVS.
Files obtained from at-spi-1.5.2 tarball.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@672 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
idl/Accessibility_LoginHelper.idl [new file with mode: 0644]
libloginhelper-1.0.pc.in [new file with mode: 0644]
login-helper/Makefile.am [new file with mode: 0644]
login-helper/login-helper.c [new file with mode: 0644]
login-helper/login-helper.h [new file with mode: 0644]
test/login-helper-client-test.c [new file with mode: 0644]
test/login-helper-server-test.c [new file with mode: 0644]

index 38533ca..29701a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-05-28  Padraig O'Briain <padraig.obriain@sun.com>
+
+       * libloginhelper-1.0.pc.in:
+       * idl/Accessibility_LoginHelper.idl: 
+       * login-helper/Makefile.am:
+       * login-helper/login-helper.[ch]:
+       * test/login-helper-client-test.c:
+       * test/login-helper-server-test.c: Added files missing from CVS.
+       Files obtained from at-spi-1.5.2 tarball.
+
 2004-05-27  Bill Haneman <bill.haneman@sun.com>
 
        * configure.in: Create login-helper/Makefile.  
diff --git a/idl/Accessibility_LoginHelper.idl b/idl/Accessibility_LoginHelper.idl
new file mode 100644 (file)
index 0000000..4ae2c0d
--- /dev/null
@@ -0,0 +1,104 @@
+/* 
+ * AT-SPI - Assistive Technology Service Provider Interface 
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#include <Bonobo_Unknown.idl>
+
+#ifndef _ACCESSIBILITY_LOGIN_HELPER_IDL_
+#define _ACCESSIBILITY_LOGIN_HELPER_IDL_
+
+module Accessibility {
+
+  interface LoginHelper : Bonobo::Unknown {
+
+      struct WindowInfo {
+         long winID;
+      };       
+
+      typedef sequence<WindowInfo> WindowList;
+
+      enum DeviceReq {
+         GUI_EVENTS,
+         CORE_KEYBOARD,
+         CORE_POINTER,
+         EXT_INPUT,
+         POST_WINDOWS,
+         AUDIO_OUT,
+         AUDIO_IN,
+         NETWORK,
+         LOCALHOST,
+         SERIAL_OUT,
+         SERIAL_IN
+      };
+
+      typedef sequence<DeviceReq> DeviceReqList;
+
+       /**
+         * setSafe:
+         * 
+         * Request a LoginHelper to enter "safe" mode, or
+        *         inform LoginHelper that "safe" mode may be exited.
+        *         If @safe_mode is %TRUE, but the return value is %FALSE,
+        *         the requesting client may wish to deny services to the 
+        *         %LoginHelper, for instance avoid raising its toplevels.
+        *
+         * Returns: whether the %LoginHelper is now "safe" or not.
+        **/
+        boolean setSafe (in boolean safe_mode);
+
+       /**
+         * getDeviceReqs:
+         * 
+         * Query a @LoginHelper for the types of
+        *    device I/O it requires, in order to do its job.
+        *    For instance, a @LoginHelper which needs to receive keyboard
+        *    events will include 
+        *    Accessibility_LoginHelper_CORE_KEYBOARD in this list.
+        *
+         * Returns: A sequence of @LoginHelper_DeviceFlags indicating
+        *    the device I/O required.
+        **/
+        DeviceReqList getDeviceReqs ();
+
+       /**
+         * getRaiseWindows:
+         *
+         * Get a list of window IDs that need raising on login. 
+         *
+        * Returns: a sequence containing window IDS for toplevels which
+        *          need to be raised/made visible during user authentication.
+        **/
+        WindowList getRaiseWindows ();
+
+       /**
+        * unImplemented:
+        *
+        * placeholders for future expansion.
+        */
+       void unImplemented ();
+       void unImplemented2 ();
+       void unImplemented3 ();
+       void unImplemented4 ();
+    };
+
+};
+
+#endif
diff --git a/libloginhelper-1.0.pc.in b/libloginhelper-1.0.pc.in
new file mode 100644 (file)
index 0000000..6d8ccf7
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+idldir=@datadir@/idl/at-spi-1.0
+
+Name: liblogin-helper
+Description: Login-Helper library for assistive technologies
+Requires: libbonobo-2.0 atk gtk+-2.0 libspi-1.0
+Version: @VERSION@
+Libs: -L${libdir} -lloginhelper
+Cflags: -I${includedir}/at-spi-1.0
diff --git a/login-helper/Makefile.am b/login-helper/Makefile.am
new file mode 100644 (file)
index 0000000..e9f5c86
--- /dev/null
@@ -0,0 +1,49 @@
+lib_LTLIBRARIES = libloginhelper.la
+
+LDADD = $(X_LIBS) $(LOGIN_HELPER_LIBS) 
+
+INCLUDES = -I$(top_srcdir)          \
+           -I$(top_builddir)        \
+           $(REGISTRYD_CFLAGS)
+
+IDL_OUT = Accessibility_LoginHelper.h Accessibility_LoginHelper-stubs.c Accessibility_LoginHelper-skels.c Accessibility_LoginHelper-common.c
+
+IDL_DEPS = \
+       $(top_srcdir)/idl/Accessibility_LoginHelper.idl
+
+BUILT_SOURCES = $(IDL_OUT) Accessibility_LoginHelper-imodule.c
+CLEANFILES = $(IDL_OUT) Accessibility_LoginHelper-imodule.c
+
+libloginhelperincludedir = $(includedir)/at-spi-1.0/login-helper
+
+libloginhelperinclude_HEADERS = \
+       Accessibility_LoginHelper.h     \
+       login-helper.h                  
+
+libloginhelper_la_SOURCES =            \
+       $(IDL_OUT)              \
+       login-helper.c
+
+IDLFLAGS = -I$(BONOBO_ACTIVATION_IDL_DIR) \
+          -I$(LIBBONOBO_IDL_DIR)         \
+          -I$(top_srcdir)/idl            \
+          --add-imodule
+
+$(IDL_OUT) Accessibility_LoginHelper-imodule.c : $(IDL_DEPS) $(ORBIT_IDL)
+       $(ORBIT_IDL) $(IDLFLAGS) $(top_srcdir)/idl/Accessibility_LoginHelper.idl
+
+orbittypelibdir = $(libdir)/orbit-2.0
+orbittypelib_LTLIBRARIES = Accessibility_LoginHelper_module.la
+
+Accessibility_LoginHelper_module_la_LDFLAGS = \
+       -export-dynamic -module -avoid-version
+Accessibility_LoginHelper_module_la_SOURCES = \
+       Accessibility_LoginHelper-imodule.c
+
+DONT_DIST_SOURCE = $(IDL_OUT) Accessibility_LoginHelper-imodule.c
+
+dist-hook:
+       for file in $(DONT_DIST_SOURCE) ; do \
+           rm -f $(distdir)/$$file ; \
+       done
+
diff --git a/login-helper/login-helper.c b/login-helper/login-helper.c
new file mode 100644 (file)
index 0000000..748d578
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * LoginHelper interface 
+ * Copyright 2004 Sun Microsystems Inc.,
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+/* login-helper.c: minimal implementation of Accessibility_LoginHelper.idl */
+#include <libbonobo.h>
+#include "login-helper.h"
+
+/* Our parent Gtk object type */
+#define PARENT_TYPE BONOBO_TYPE_OBJECT
+
+/* A pointer to our parent object class */
+static BonoboObjectClass *bonobo_object_parent_class;
+
+static void
+login_helper_finalize (GObject *object)
+{
+  LoginHelper *helper = (LoginHelper *) object;
+  CORBA_Environment ev;
+
+  (G_OBJECT_CLASS (bonobo_object_parent_class))->finalize (object);
+}
+
+gboolean
+login_helper_set_safe (LoginHelper *helper, gboolean safe)
+{
+  LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
+  
+  if (klass->set_safe)
+    return (* klass->set_safe)(helper, safe);
+  else
+    return FALSE;
+}
+
+static CORBA_boolean
+impl_login_helper_set_safe (PortableServer_Servant servant,
+                           const CORBA_boolean safe,
+                           CORBA_Environment *ev)
+{
+  LoginHelper *helper = LOGIN_HELPER (bonobo_object_from_servant (servant));
+
+  return login_helper_set_safe (helper, safe);
+}
+
+LoginHelperDeviceReqFlags
+login_helper_get_device_reqs (LoginHelper *helper)
+{
+  LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
+  
+  if (klass->get_device_reqs)
+    return  (* klass->get_device_reqs)(helper);
+  else
+    return 0;
+}
+
+static Accessibility_LoginHelper_DeviceReqList*
+impl_login_helper_get_device_reqs (PortableServer_Servant servant,
+                                  CORBA_Environment *ev)
+{
+  LoginHelper *helper = LOGIN_HELPER (bonobo_object_from_servant (servant));
+  LoginHelperDeviceReqFlags flags = 0;
+  gint n_reqs = 0, i = 1, j = 1;
+  Accessibility_LoginHelper_DeviceReqList *list;
+
+  flags = login_helper_get_device_reqs (helper);
+
+  while (i <= LOGIN_HELPER_LAST_DEFINED) 
+  {
+      if (flags & i) n_reqs++;
+      i <<= 1;
+  }
+  
+  list = Accessibility_LoginHelper_DeviceReqList__alloc ();
+  list->_length = n_reqs; 
+  list->_buffer = Accessibility_LoginHelper_DeviceReqList_allocbuf (list->_length);
+
+  for (i = 0, j = 1; i < n_reqs; i++) 
+  {
+      Accessibility_LoginHelper_DeviceReq req;
+      while ((flags & j) == 0) {
+         j <<= 1;
+      }
+      switch (j)
+      {
+         case LOGIN_HELPER_GUI_EVENTS:
+             req = Accessibility_LoginHelper_GUI_EVENTS;
+             break;
+         case LOGIN_HELPER_CORE_KEYBOARD:
+             req = Accessibility_LoginHelper_CORE_KEYBOARD;
+             break;
+         case LOGIN_HELPER_CORE_POINTER:
+             req = Accessibility_LoginHelper_CORE_POINTER;
+             break;
+         case LOGIN_HELPER_EXT_INPUT:
+             req = Accessibility_LoginHelper_EXT_INPUT;
+             break;
+         case LOGIN_HELPER_POST_WINDOWS:
+             req = Accessibility_LoginHelper_POST_WINDOWS;
+             break;
+         case LOGIN_HELPER_AUDIO_OUT:
+             req = Accessibility_LoginHelper_AUDIO_OUT;
+             break;
+         case LOGIN_HELPER_AUDIO_IN:
+             req = Accessibility_LoginHelper_AUDIO_IN;
+             break;
+         case LOGIN_HELPER_NETWORK:
+             req = Accessibility_LoginHelper_NETWORK;
+             break;
+         case LOGIN_HELPER_LOCALHOST:
+             req = Accessibility_LoginHelper_LOCALHOST;
+             break;
+         case LOGIN_HELPER_SERIAL_OUT:
+             req = Accessibility_LoginHelper_SERIAL_OUT;
+             break;
+         case LOGIN_HELPER_SERIAL_IN:
+             req = Accessibility_LoginHelper_SERIAL_IN;
+             break;
+         default:
+             req = 0;
+             break;
+      }
+      list->_buffer[i] = req;
+      j <<= 1;
+  }  
+
+  return list;
+}
+
+Window*
+login_helper_get_raise_windows (LoginHelper *helper)
+{
+  LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
+  
+  if (klass->get_raise_windows)
+    return (* klass->get_raise_windows)(helper);
+  else
+    return NULL;
+}
+
+static Accessibility_LoginHelper_WindowList*
+impl_login_helper_get_raise_windows (PortableServer_Servant servant,
+                                    CORBA_Environment *ev)
+{
+  LoginHelper *helper = LOGIN_HELPER (bonobo_object_from_servant (servant));
+  long *wids;
+  Accessibility_LoginHelper_WindowList *windows;
+
+  wids = login_helper_get_raise_windows (helper);
+
+  if (wids && *wids)
+    {
+      gint i, count = 0;
+      while (wids[count])
+       {
+         ++count;
+       }
+      windows = Accessibility_LoginHelper_WindowList__alloc ();
+      windows->_length = count;
+      windows->_buffer = Accessibility_LoginHelper_WindowList_allocbuf (windows->_length);
+      for (i = 0; i < count; ++i)
+       {
+          Accessibility_LoginHelper_WindowInfo winfo;
+         winfo.winID = wids[i];
+         windows->_buffer [i] = winfo;
+       }
+      g_free (wids);
+      return windows;
+    }
+  else
+    {
+      return NULL;
+    }
+}
+
+static void
+login_helper_class_init (LoginHelperClass *klass)
+{
+  GObjectClass * object_class = (GObjectClass *) klass;
+  POA_Accessibility_LoginHelper__epv *epv = &klass->epv;
+
+  bonobo_object_parent_class = g_type_class_peek_parent (klass);
+
+  object_class->finalize = login_helper_finalize;
+  
+  epv->getRaiseWindows = impl_login_helper_get_raise_windows;
+  epv->getDeviceReqs = impl_login_helper_get_device_reqs;
+  epv->setSafe = impl_login_helper_set_safe;
+}
+
+static void
+login_helper_init (GObject *object)
+{
+    LoginHelper *helper = LOGIN_HELPER (object);
+}
+
+BONOBO_TYPE_FUNC_FULL (LoginHelper,
+                      Accessibility_LoginHelper,
+                      PARENT_TYPE, login_helper)
+
diff --git a/login-helper/login-helper.h b/login-helper/login-helper.h
new file mode 100644 (file)
index 0000000..951d7f6
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * LoginHelper
+ *
+ * Copyright 2004 Sun Microsystems Inc.,
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef LOGIN_HELPER_H_
+#define LOGIN_HELPER_H_
+
+#include <login-helper/Accessibility_LoginHelper.h>
+#include <X11/X.h>
+
+G_BEGIN_DECLS
+
+typedef struct _LoginHelper LoginHelper;
+typedef struct _LoginHelperClass LoginHelperClass;
+
+#define LOGIN_HELPER_TYPE        (login_helper_get_type ())
+#define LOGIN_HELPER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), LOGIN_HELPER_TYPE, LoginHelper))
+#define LOGIN_HELPER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), LOGIN_HELPER_TYPE, LoginHelperClass))
+#define LOGIN_HELPER_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS((o), LOGIN_HELPER_TYPE, LoginHelperClass))
+#define IS_LOGIN_HELPER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), LOGIN_HELPER_TYPE))
+#define IS_LOGIN_HELPER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), LOGIN_HELPER_TYPE))
+
+struct _LoginHelper {
+  BonoboObject      parent;
+
+};
+
+typedef unsigned long LoginHelperDeviceReqFlags;
+
+#define LOGIN_HELPER_GUI_EVENTS 1
+#define LOGIN_HELPER_CORE_KEYBOARD 2
+#define LOGIN_HELPER_CORE_POINTER 4
+#define LOGIN_HELPER_EXT_INPUT 8
+#define LOGIN_HELPER_POST_WINDOWS 16
+#define LOGIN_HELPER_AUDIO_OUT 32
+#define LOGIN_HELPER_AUDIO_IN 64
+#define LOGIN_HELPER_NETWORK 128
+#define LOGIN_HELPER_LOCALHOST 256 
+#define LOGIN_HELPER_SERIAL_OUT 512
+#define LOGIN_HELPER_SERIAL_IN 1024
+#define LOGIN_HELPER_LAST_DEFINED 2048
+
+struct _LoginHelperClass {
+  BonoboObjectClass parent_class;
+
+  POA_Accessibility_LoginHelper__epv epv;
+
+  gboolean (*set_safe) (LoginHelper *helper, gboolean safe);
+  LoginHelperDeviceReqFlags (*get_device_reqs) (LoginHelper *helper);
+  Window*  (*get_raise_windows) (LoginHelper *helper); 
+};
+
+GType        login_helper_get_type (void) G_GNUC_CONST;
+LoginHelper *login_helper_new      (void);
+
+G_END_DECLS
+
+#endif /* LOGIN_HELPER_H */
diff --git a/test/login-helper-client-test.c b/test/login-helper-client-test.c
new file mode 100644 (file)
index 0000000..fcbbaec
--- /dev/null
@@ -0,0 +1,216 @@
+/* 
+ * test utility for LoginHelper client API and services.
+ *
+ * Copyright Sun Microsystems 2004
+ *
+ */
+
+#include <X11/X.h>
+#include <libbonobo.h>
+#include <login-helper/Accessibility_LoginHelper.h>
+
+gint main (int argc, char **argv)
+{
+    Bonobo_ServerInfoList *server_list;
+    Accessibility_LoginHelper *helper_list = NULL;
+    CORBA_boolean safe;
+    CORBA_Environment ev;
+    Accessibility_LoginHelper_WindowList *windows;
+    int i;
+
+    CORBA_exception_init (&ev);
+    if (!bonobo_init (&argc, argv))
+    {
+       g_error ("Can't initialize Bonobo");
+    }
+
+    /* bonobo-activation query lists existing instances */
+    server_list = bonobo_activation_query (
+       "(repo_ids.has('IDL:Accessibility/LoginHelper:1.0')) AND _active", 
+       NULL, &ev);
+
+    if (BONOBO_EX (&ev)) 
+    {
+       bonobo_debug_shutdown ();
+       g_error ("LoginHelper query failed : %s",
+                bonobo_exception_get_text (&ev));
+       /* not reached (below) because g_error exits */
+       CORBA_exception_free (&ev);
+    }
+
+    g_message ("%d LoginHelpers are running.", 
+              server_list ? server_list->_length : 0);
+
+    helper_list = g_new0 (Accessibility_LoginHelper, server_list->_length);
+
+    /* for each instance... */
+    for (i = 0; i < server_list->_length; i++)
+    {
+       Accessibility_LoginHelper helper;
+       Bonobo_Unknown server;
+       Bonobo_ServerInfo info = server_list->_buffer[i];
+
+       server = bonobo_activation_activate_from_id (
+           info.iid, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, &ev);
+
+       if (BONOBO_EX (&ev))
+       {
+           g_warning ("Error activating server %d: %s", i, bonobo_exception_get_text (&ev));
+           CORBA_exception_free (&ev);
+           continue;
+       }
+       else if (server == CORBA_OBJECT_NIL)
+       {
+           g_warning ("Activated server %d is NIL!", i);
+           continue;
+       }
+
+       bonobo_activate ();
+
+       helper = Bonobo_Unknown_queryInterface (
+           server, 
+           "IDL:Accessibility/LoginHelper:1.0",
+           &ev);
+
+       if (BONOBO_EX (&ev))
+       {
+           g_warning ("Error performing interface query: %s", bonobo_exception_get_text (&ev));
+           CORBA_exception_free (&ev);
+           continue;
+       }
+       else if (helper == CORBA_OBJECT_NIL)
+       {
+           g_warning ("Activated an object which advertised LoginHelper but does not implement it!");
+           continue;
+       }
+       helper_list[i] = helper;
+       bonobo_object_release_unref (server, &ev);
+
+       if (helper && !BONOBO_EX (&ev))
+       {
+           /* ask the helper to go into safe mode */
+           safe = Accessibility_LoginHelper_setSafe (helper, TRUE, &ev);
+           if (BONOBO_EX (&ev))
+           {
+               g_warning ("setSafe(TRUE) failed: %s", 
+                          bonobo_exception_get_text (&ev));
+               CORBA_exception_free (&ev);
+           }
+           /* get the raise window list (if the program went into safe mode) */
+           if (safe) 
+           {
+               int j;
+               gboolean needs_windows_raised = FALSE;
+               Accessibility_LoginHelper_DeviceReqList *list;
+
+               g_message ("safe");
+
+               /* does this helper need to have windows raised? */
+               list = Accessibility_LoginHelper_getDeviceReqs (helper, &ev);
+
+               if (BONOBO_EX (&ev)) {
+                   g_warning ("Bonobo exception getting Device Requirements: %s",
+                            bonobo_exception_get_text (&ev));
+                   CORBA_exception_free (&ev);
+               }
+               else
+               {
+                   g_message ("LoginHelper device requirements: ");
+                   if (list->_length == 0) 
+                       g_message ("\tNone.");
+
+                   for (j = 0; j < list->_length; j++) 
+                   {
+                       switch (list->_buffer[j])
+                       {
+                           case Accessibility_LoginHelper_GUI_EVENTS:
+                               g_message ("\tNeeds access to the GUI event subsystem (e.g. Xserver)");
+                               break;
+                           case Accessibility_LoginHelper_EXT_INPUT:
+                               g_message ("\tReads XInput extended input devices");
+                               break;
+                           case Accessibility_LoginHelper_POST_WINDOWS:
+                               g_message ("\tPosts windows");
+                               needs_windows_raised = TRUE;
+                               break;
+                           case Accessibility_LoginHelper_AUDIO_OUT:
+                               g_message ("\tWrites to audio device");
+                               break;
+                           case Accessibility_LoginHelper_AUDIO_IN:
+                               g_message ("\tReads from audio device");
+                               break;
+                           case Accessibility_LoginHelper_LOCALHOST:
+                               g_message ("\tNeeds LOCALHOST network connection");
+                               break;
+                           case Accessibility_LoginHelper_SERIAL_OUT:
+                               g_message ("\tNeeds to write to one or more serial ports");
+                               break;
+                           default:
+                               break;
+                       }
+                   }
+                   CORBA_free (list);
+               }
+               if (needs_windows_raised) 
+               {
+                   /* don't raise in this test, but do something with each wid */
+                   windows = Accessibility_LoginHelper_getRaiseWindows (helper, &ev);
+                   if (BONOBO_EX (&ev))
+                   {
+                       g_warning ("getRaiseWindows failed: %s", 
+                                  bonobo_exception_get_text (&ev));
+                       CORBA_exception_free (&ev);
+                   }
+                   g_message ("%d windows need raising", windows->_length);
+                   for (j = 0; j < windows->_length; j++)      
+                   {
+                       Window wid;
+                       wid = windows->_buffer[j].winID;
+                       g_message ("Window ID = %ld", (long) wid);
+                   }    
+               }
+           }
+           else
+           {
+               g_warning ("LoginHelper %d did not go into safe mode", i);
+           }
+       }
+       else
+       {
+           if (BONOBO_EX (&ev))
+           {
+               g_warning ("Error activating %s: %s", 
+                          info.iid, bonobo_exception_get_text (&ev));
+               CORBA_exception_free (&ev);
+           }
+           else
+           {
+               g_warning ("no active instance of %s found", info.iid);
+           }
+       }
+    }
+    
+    /* 
+     * In an actual login/authentication setting, login/authentication 
+     * would take place here, and code below would be executed after 
+     * authentication was complete.
+     */
+    
+    /* now tell the apps they can resume their normal activities */
+    for (i = 0; i < server_list->_length; i++)
+    {
+       Accessibility_LoginHelper helper = helper_list[i];
+       /* really no need to check the return value this time */
+       Accessibility_LoginHelper_setSafe (helper, FALSE, &ev);
+       if (BONOBO_EX (&ev))
+       {
+           g_warning ("setSafe(FALSE) failed: %s", 
+                      bonobo_exception_get_text (&ev));
+           CORBA_exception_free (&ev);
+       }
+       CORBA_Object_release (helper, &ev);
+    }  
+    CORBA_free (server_list);
+
+    return bonobo_debug_shutdown (); /* see if we leaked stuff */
+}
diff --git a/test/login-helper-server-test.c b/test/login-helper-server-test.c
new file mode 100644 (file)
index 0000000..d083404
--- /dev/null
@@ -0,0 +1,105 @@
+#include <libbonobo.h>
+#include <login-helper/login-helper.h>
+
+static void test_init_login_helper_vpointers (LoginHelper *helper, 
+                                             gpointer test_set_safe, 
+                                             gpointer test_get_device_reqs, 
+                                             gpointer test_get_raise_windows);
+
+static gboolean test_set_safe (LoginHelper *helper, gboolean safe);
+
+static LoginHelperDeviceReqFlags test_get_device_reqs (LoginHelper *helper);
+
+static Window* test_get_raise_windows (LoginHelper *helper);
+
+int
+main (int argc, char **argv)
+{
+       int          ret;
+       char        *obj_id, *display_name;
+       BonoboObject *helper;
+       
+       if (!bonobo_init (&argc, argv))
+       {
+               g_error ("Could not initialize oaf / Bonobo");
+       }
+       
+       obj_id = "OAFIID:GNOME_GOK:1.0";  /* just for testing, stolen from GOK */
+       
+       helper = BONOBO_OBJECT (g_object_new (LOGIN_HELPER_TYPE, NULL));
+       
+       ret = bonobo_activation_register_active_server (
+               obj_id,
+               bonobo_object_corba_objref (bonobo_object (helper)),
+               NULL);
+       
+       if (ret != Bonobo_ACTIVATION_REG_SUCCESS)
+       {
+               switch (ret) 
+               {
+               case Bonobo_ACTIVATION_REG_NOT_LISTED:
+                       fprintf (stderr, "OAFIID not listed\n");
+                       break;
+               default:
+                       fprintf (stderr, "Registration Error: %d\n", ret);
+                       break;
+               }
+       }
+       else
+       {
+               CORBA_Environment ev;
+               CORBA_exception_init (&ev);
+               
+               Bonobo_Unknown ret = Bonobo_Unknown_queryInterface (
+                       BONOBO_OBJREF (helper),
+                       "IDL:Accessibility/LoginHelper:1.0", 
+                       &ev);
+               
+               if (BONOBO_EX (&ev))
+               {
+                       fprintf (stderr, "queryInterface error: %s\n", 
+                                bonobo_exception_get_text (&ev));
+               }
+               else
+               {
+                       fprintf (stderr, "query returned %p: objref self = %p\n", 
+                                ret, BONOBO_OBJREF (helper));
+               }
+       }
+
+       /* this is a testing hack - we are changing the LoginHelperClass's vpointers here */
+       
+       test_init_login_helper_vpointers (helper, test_set_safe, test_get_device_reqs, test_get_raise_windows);
+
+       bonobo_main ();
+}
+
+static void
+test_init_login_helper_vpointers (LoginHelper *helper, 
+                                 gpointer set_safe_func, 
+                                 gpointer get_device_reqs_func, 
+                                 gpointer get_raise_windows_func)
+{
+       LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
+       klass->set_safe = set_safe_func;
+       klass->get_device_reqs = get_device_reqs_func;
+       klass->get_raise_windows = get_raise_windows_func;
+}
+
+static gboolean
+test_set_safe (LoginHelper *helper, gboolean safe)
+{
+       return TRUE;
+}
+
+static LoginHelperDeviceReqFlags
+test_get_device_reqs (LoginHelper *helper)
+{
+       return 0;
+}
+
+static Window*
+test_get_raise_windows (LoginHelper *helper)
+{
+       return NULL;
+}