Commit 267f4794 authored by Stefan Walter's avatar Stefan Walter

Added beginnings of a DBUS service.

    * configure.in:
    * daemon/Makefile.am:
    * daemon/seahorse-daemon.c:
    * daemon/seahorse-daemon.h:
    * daemon/seahorse-dbus-bindings.xml:
    * daemon/seahorse-dbus-server.c:
    * daemon/seahorse-service.c:
    * daemon/seahorse-service.h:
    * tests/dbus-test.py: Added beginnings of a DBUS service.
parent 1c0e8693
2005-08-07 Nate Nielsen <nielsen@memberwebs.com>
* autogen.sh: Require automake 1.7
* configure.in:
* daemon/Makefile.am:
* daemon/seahorse-daemon.c:
* daemon/seahorse-daemon.h:
* daemon/seahorse-dbus-bindings.xml:
* daemon/seahorse-dbus-server.c:
* daemon/seahorse-service.c:
* daemon/seahorse-service.h:
* tests/dbus-test.py: Added beginnings of a DBUS service.
2005-08-05 Nate Nielsen <nielsen@memberwebs.com>
* src/seahorse-key-manager.c: Added Jim Pharis to contributors.
......
......@@ -354,6 +354,40 @@ fi
AM_CONDITIONAL(WITH_SHARING, test "$enable_sharing" != "no")
dnl *******************
dnl DBUS
dnl *******************
dnl TODO: Clean this up a bit
DBUS_GLIB_REQUIRED=0.33
PKG_CHECK_MODULES([DBUS], [dbus-glib-1 >= $DBUS_GLIB_REQUIRED],
[enable_dbus=yes],[enable_dbus=no])
AC_SUBST([DBUS_CFLAGS])
AC_SUBST([DBUS_LIBS])
if test "x$enable_dbus" = "xno"; then
AC_MSG_WARN([DBUS support is disabled since dbus $DBUS_GLIB_REQUIRED or higher was not found])
fi
if test "x$enable_dbus" = "xyes" ; then
AC_PATH_PROG([DBUS_BINDING_TOOL], [dbus-binding-tool], [no])
if test x$DBUS_BINDING_TOOL = "xno" ; then
AC_MSG_ERROR([dbus-binding-tool executable not found in your path - should be installed with dbus glib bindings])
fi
AC_DEFINE([WITH_DBUS],[1],[Define if DBUS support is enabled])
DBUS_VERSION=`$PKG_CONFIG --modversion dbus-glib-1 | sed 's/0.\([[0-9]]*\)/\1/'`
AC_DEFINE_UNQUOTED(DBUS_VERSION, $DBUS_VERSION, [DBUS version.])
SEAHORSE_CFLAGS="$SEAHORSE_CFLAGS $DBUS_CFLAGS"
SEAHORSE_LIBS="$SEAHORSE_LIBS $DBUS_LIBS"
fi
AM_CONDITIONAL(WITH_DBUS, test "$enable_dbus" != "no")
dnl *******************
# Debug mode
......@@ -418,6 +452,7 @@ GPGME Version: $gpgme_config_version
Keyserver Support: $with_keyserver
LDAP: $with_ldap
HKP: $enable_hkp
DBUS Support: $enable_dbus
Plugins:
Seahorse Agent: $enable_agent
GEdit: $enable_gedit
......
......@@ -5,3 +5,4 @@ Makefile
*.la
*.lo
seahorse-daemon
seahorse-dbus-bindings.h
......@@ -15,6 +15,8 @@ INCLUDES = -I$(top_builddir) \
bin_PROGRAMS = seahorse-daemon
BUILT_SOURCES =
if WITH_AGENT
AGENT_LIB = $(top_builddir)/agent/libseahorseagent.a
else
......@@ -27,22 +29,35 @@ else
SHARING_SRCS =
endif
if WITH_DBUS
DBUS_SRCS = seahorse-dbus-server.c seahorse-service.c seahorse-service.h
BUILT_SOURCES += seahorse-dbus-bindings.h
else
DBUS_SRCS =
endif
seahorse_daemon_SOURCES = \
seahorse-daemon.c \
seahorse-daemon.h \
$(SHARING_SRCS)
seahorse-daemon.c \
seahorse-daemon.h \
$(DBUS_SRCS) \
$(SHARING_SRCS)
seahorse_daemon_LDADD = \
$(AGENT_LIB) \
$(top_builddir)/libseahorse/libseahorse-internal.la \
$(SEAHORSE_LIBS)
glade_DATA =
EXTRA_DIST = \
$(glade_DATA)
$(glade_DATA) \
seahorse-dbus-bindings.h
CLEANFILES = *.gladep* *.bak
# TODO: Look at evince to see what they did here. Something about --prefix
seahorse-dbus-bindings.h: seahorse-dbus-bindings.xml
dbus-binding-tool --mode=glib-server --output=$@ $(srcdir)/$<
install-exec-hook:
chmod u+s $(bindir)/seahorse-daemon
......@@ -231,22 +231,28 @@ int main(int argc, char* argv[])
prepare_logging ();
/* Initialize the various daemon components */
#ifdef WITH_DBUS
seahorse_dbus_server_init ();
#endif
#ifdef WITH_AGENT
seahorse_agent_init ();
#endif
#ifdef WITH_SHARING
seahorse_sharing_init();
seahorse_sharing_init ();
#endif
gtk_main ();
/* And now clean them all up */
#ifdef WITH_SHARING
seahorse_sharing_cleanup();
seahorse_sharing_cleanup ();
#endif
#ifdef WITH_AGENT
seahorse_agent_uninit ();
#endif
#ifdef WITH_DBUS
seahorse_dbus_server_cleanup ();
#endif
return 0;
}
......@@ -51,4 +51,14 @@ GQuark seahorse_hkp_server_error_domain ();
#endif
/* seahorse-dbus-server.c --------------------------------------------------- */
#ifdef WITH_DBUS
gboolean seahorse_dbus_server_init ();
gboolean seahorse_dbus_server_cleanup ();
#endif
#endif /* _SEAHORSE_DAEMON_H_ */
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/gnome/seahorse/Crypto/Service">
<interface name="org.gnome.seahorse.CryptoService">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="seahorse_service"/>
<method name="GetKeyTypes">
<!-- This is optional, and in this case is redunundant -->
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="seahorse_service_get_key_types"/>
<arg type="s" name="str_ret" direction="out" />
</method>
</interface>
</node>
/*
* Seahorse
*
* Copyright (C) 2005 Nate Nielsen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "seahorse-service.h"
#include "seahorse-dbus-bindings.h"
#include <dbus/dbus-glib-bindings.h>
#define APPLICATION_SERVICE_NAME "org.gnome.seahorse.CryptoService"
/* The main service object */
SeahorseService *the_service = NULL;
void
seahorse_dbus_server_init ()
{
DBusGConnection *connection;
DBusGProxy *driver_proxy;
GError *err = NULL;
guint request_name_result;
connection = dbus_g_bus_get (DBUS_BUS_STARTER, &err);
if (connection == NULL) {
g_warning ("DBUS Service registration failed.");
g_error_free (err);
return;
}
driver_proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (!org_freedesktop_DBus_request_name (driver_proxy, APPLICATION_SERVICE_NAME,
0, &request_name_result, &err)) {
g_warning ("DBUS Service name request failed.");
g_clear_error (&err);
}
if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) {
g_warning ("DBUS Service already started elsewhere");
return;
}
if (!the_service)
the_service = g_object_new (SEAHORSE_TYPE_SERVICE, NULL);
#if DBUS_VERSION == 33
dbus_g_object_class_install_info (G_OBJECT_GET_CLASS (the_service),
&dbus_glib_seahorse_service_object_info);
#else
dbus_g_object_type_install_info (SEAHORSE_TYPE_SERVICE,
&dbus_glib_seahorse_service_object_info);
#endif
dbus_g_connection_register_g_object (connection, "/org/gnome/seahorse/Crypto/Service",
G_OBJECT (the_service));
}
void
seahorse_dbus_server_cleanup ()
{
/* TODO: Cleanup the_service object here. Need to check that DBUS
glib bindings are okay with just destroying the object. */
}
/*
* Seahorse
*
* Copyright (C) 2005 Nate Nielsen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "seahorse-service.h"
G_DEFINE_TYPE (SeahorseService, seahorse_service, G_TYPE_OBJECT);
gboolean
seahorse_service_get_key_types (SeahorseService *svc, gchar** ret,
GError **error)
{
*ret = g_strdup("SeahorseService says: DBus rocks.");
return TRUE;
}
static void
seahorse_service_class_init (SeahorseServiceClass *klass)
{
}
static void
seahorse_service_init (SeahorseService *svc)
{
}
/*
* Seahorse
*
* Copyright (C) 2005 Nate Nielsen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __SEAHORSE_SERVICE_H__
#define __SEAHORSE_SERVICE_H__
#include <glib/gerror.h>
#include <glib-object.h>
G_BEGIN_DECLS
typedef struct _SeahorseService SeahorseService;
typedef struct _SeahorseServiceClass SeahorseServiceClass;
#define SEAHORSE_TYPE_SERVICE (seahorse_service_get_type ())
#define SEAHORSE_SERVICE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SEAHORSE_TYPE_SERVICE, SeahorseService))
#define SEAHORSE_SERVICE_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), SEAHORSE_TYPE_SERVICE, SeahorseServiceClass))
#define SEAHORSE_IS_SERVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SEAHORSE_TYPE_SERVICE))
#define SEAHORSE_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SEAHORSE_TYPE_SERVICE))
#define SEAHORSE_SERVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SEAHORSE_TYPE_SERVICE, SeahorseServiceClass))
struct _SeahorseService {
GObject base;
};
struct _SeahorseServiceClass {
GObjectClass base;
};
GType
seahorse_service_get_type ();
gboolean
seahorse_service_get_key_types (SeahorseService *svc, gchar** ret,
GError **error);
#endif /* __SEAHORSE_SERVICE_H__ */
#!/usr/bin/python
import dbus
bus = dbus.SessionBus()
proxy_obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
dbus_iface = dbus.Interface(proxy_obj, 'org.freedesktop.DBus')
print "\n\nALL DBUS SERVICES -------------------------------------"
print dbus_iface.ListNames()
print "\n\nSEAHORSE DBUS CALL ------------------------------------"
proxy_obj = bus.get_object('org.gnome.seahorse.CryptoService', '/org/gnome/seahorse/Crypto/Service')
iface = dbus.Interface(proxy_obj, 'org.gnome.seahorse.CryptoService')
print iface.GetKeyTypes()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment