[gnome-pilot/dbus] Test on the get info method calls(Not finished):
- From: Halton Huo <haltonhuo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-pilot/dbus] Test on the get info method calls(Not finished):
- Date: Thu, 11 Mar 2010 09:18:47 +0000 (UTC)
commit 9dc5465392b2125977e018d9619772a40f9f89b2
Author: Halton Huo <halton huo sun com>
Date: Thu Mar 11 16:55:03 2010 +0800
Test on the get info method calls(Not finished):
org.gnome.GnomePilot.Daemon.GetUserInfo
org.gnome.GnomePilot.Daemon.GetSystemInfo
Solaris has usb problem, I'd like to commit it first to
work on Linux(Ubuntu).
gpilotd/gnome-pilot-client.gob | 20 ++++----
gpilotd/gpilot-daemon.c | 91 +++++++++++++++++++++++++++++++++-------
gpilotd/gpilotd.c | 8 ++--
3 files changed, 90 insertions(+), 29 deletions(-)
---
diff --git a/gpilotd/gnome-pilot-client.gob b/gpilotd/gnome-pilot-client.gob
index 2dff904..836db79 100644
--- a/gpilotd/gnome-pilot-client.gob
+++ b/gpilotd/gnome-pilot-client.gob
@@ -594,7 +594,7 @@ class Gnome:Pilot:Client from Gtk:Object {
G_TYPE_UINT, &survival,
G_TYPE_UINT, &timeout,
G_TYPE_INVALID,
- G_TYPE_ULONG, &val,
+ G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
@@ -696,7 +696,7 @@ error: if (file_copied == FALSE) {
G_TYPE_UINT, &survival,
G_TYPE_UINT, &timeout,
G_TYPE_INVALID,
- G_TYPE_ULONG, &val,
+ G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
@@ -726,10 +726,10 @@ error: if (file_copied == FALSE) {
"GetUserInfo",
&error,
G_TYPE_STRING, cradle_name,
- G_TYPE_UINT, &survival,
- G_TYPE_UINT, &timeout,
+ G_TYPE_UINT, survival,
+ G_TYPE_UINT, timeout,
G_TYPE_INVALID,
- G_TYPE_ULONG, &val,
+ G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
@@ -766,7 +766,7 @@ error: if (file_copied == FALSE) {
G_TYPE_UINT, &(user.userID),
G_TYPE_STRING, user.username,
G_TYPE_INVALID,
- G_TYPE_ULONG, &val,
+ G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
@@ -795,10 +795,10 @@ error: if (file_copied == FALSE) {
"GetSystemInfo",
&error,
G_TYPE_STRING, cradle_name,
- G_TYPE_UINT, &survival,
- G_TYPE_UINT, &timeout,
+ G_TYPE_UINT, survival,
+ G_TYPE_UINT, timeout,
G_TYPE_INVALID,
- G_TYPE_ULONG, &val,
+ G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
@@ -857,7 +857,7 @@ error: if (file_copied == FALSE) {
G_TYPE_UINT, &survival,
G_TYPE_UINT, &timeout,
G_TYPE_INVALID,
- G_TYPE_ULONG, &val,
+ G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index 6ddbe04..695a8fd 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -52,14 +52,16 @@
#include "gpilot-gui.h"
#include "manager.h"
-#ifdef WITH_HAL
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#ifdef WITH_HAL
#include <libhal.h>
#endif
+#define GP_DBUS_NAME "org.gnome.GnomePilot"
#define GP_DBUS_PATH "/org/gnome/GnomePilot/Daemon"
+#define GP_DBUS_INTERFACE "org.gnome.GnomePilot.Daemon"
#define GPILOT_DAEMON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPILOT_TYPE_DAEMON, GpilotDaemonPrivate))
@@ -1705,7 +1707,16 @@ gboolean
gpilot_daemon_reread_config (GpilotDaemon *daemon,
GError **error)
{
- kill(getpid (), SIGHUP);
+ GpilotDaemonPrivate *priv;
+
+ priv = daemon->priv;
+
+ g_message (_("Shutting down devices"));
+ gpilot_context_free (priv->gpilotd_context);
+ g_message (_("Rereading configuration..."));
+ gpilot_context_init_user (priv->gpilotd_context);
+ g_list_foreach (priv->gpilotd_context->devices, (GFunc)monitor_channel, priv->gpilotd_context);
+
return TRUE;
}
@@ -1931,6 +1942,13 @@ gpilot_daemon_remove_request (GpilotDaemon *daemon,
/* information operations */
+/* Example:
+dbus-send --session --dest=org.gnome.GnomePilot \
+--type=method_call --print-reply --reply-timeout=2000 \
+/org/gnome/GnomePilot/Daemon \
+org.gnome.GnomePilot.Daemon.GetSystemInfo \
+string:'Cradle' uint32:0 uint32:0
+*/
gboolean
gpilot_daemon_get_system_info (GpilotDaemon *daemon,
const char *cradle,
@@ -1941,27 +1959,23 @@ gpilot_daemon_get_system_info (GpilotDaemon *daemon,
{
GpilotDaemonPrivate *priv;
GPilotRequest req;
- gchar *client_id;
gboolean ret;
ret = FALSE;
priv = daemon->priv;
- /* TODO
- GET_AND_CHECK_CLIENT_ID(client_id,cb,0);
- */
LOG (("get_system_info(cradle=%s,survival=%d,timeout=%d)",
cradle, survival, timeout));
req.type = GREQ_GET_SYSINFO;
+ req.timeout = survival==GNOME_Pilot_PERSISTENT?0:timeout;
req.pilot_id = 0;
req.cradle = g_strdup (cradle);
- req.client_id = g_strdup (client_id);
+ req.client_id = g_strdup ("");
*handle = gpc_queue_store_request (req);
ret = TRUE;
out:
- g_free(client_id);
return ret;
}
@@ -2273,7 +2287,8 @@ gpilot_daemon_get_databases_from_cache (GpilotDaemon *daemon,
dbus-send --session --dest=org.gnome.GnomePilot \
--type=method_call --print-reply --reply-timeout=2000 \
/org/gnome/GnomePilot/Daemon \
-org.gnome.GnomePilot.Daemon.GetUserInfo
+org.gnome.GnomePilot.Daemon.GetUserInfo \
+string:'Cradle' uint32:0 uint32:0
*/
gboolean
gpilot_daemon_get_user_info (GpilotDaemon *daemon,
@@ -2285,27 +2300,23 @@ gpilot_daemon_get_user_info (GpilotDaemon *daemon,
{
GpilotDaemonPrivate *priv;
GPilotRequest req;
- gchar *client_id;
gboolean ret;
ret = FALSE;
priv = daemon->priv;
- /* TODO
- GET_AND_CHECK_CLIENT_ID(client_id,cb,0);
- */
LOG (("get_user_info(cradle=%s,survival=%d,timeout=%d)",
cradle, survival, timeout));
req.type = GREQ_GET_USERINFO;
+ req.timeout = survival==GNOME_Pilot_PERSISTENT?0:timeout;
req.pilot_id = 0;
req.cradle = g_strdup (cradle);
- req.client_id = g_strdup (client_id);
+ req.client_id = g_strdup ("");
*handle = gpc_queue_store_request (req);
ret = TRUE;
out:
- g_free(client_id);
return ret;
}
@@ -2770,12 +2781,62 @@ dbus_notify_disconnected (const gchar *pilot_id)
void
dbus_notify_completion (GPilotRequest **req)
{
+ DBusMessage *message;
+ DBusConnection *connection;
+ DBusMessageIter iter;
+ gchar *pilot_name;
+
+ GpilotDaemon *daemon;
+
+ daemon = GPILOT_DAEMON (daemon_object);
+ g_return_if_fail(req!=NULL);
+ g_return_if_fail(*req!=NULL);
+
+ /* resolve pilot id */
+ pilot_name = pilot_name_from_id ((*req)->pilot_id,
+ daemon->priv->gpilotd_context);
+
+ message = dbus_message_new_signal (GP_DBUS_PATH,
+ GP_DBUS_INTERFACE,
+ "RequestCompleted");
+
+ dbus_message_set_destination (message, GP_DBUS_NAME);
+
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &pilot_name);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &(*req)->handle);
+
+ connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
+ dbus_connection_send (connection, message, NULL);
+ dbus_connection_unref (connection);
+ dbus_message_unref (message);
+
+ g_free (pilot_name);
}
void
dbus_notify_userinfo (struct PilotUser user_info,
GPilotRequest **req)
{
+ DBusMessage *message;
+ DBusConnection *connection;
+ DBusMessageIter iter;
+
+ message = dbus_message_new_signal (GP_DBUS_PATH,
+ GP_DBUS_INTERFACE,
+ "UserInfoRequested");
+
+ dbus_message_set_destination (message, GP_DBUS_NAME);
+
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &(*req)->cradle);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &user_info.userID);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &user_info.username);
+
+ connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
+ dbus_connection_send (connection, message, NULL);
+ dbus_connection_unref (connection);
+ dbus_message_unref (message);
}
void
diff --git a/gpilotd/gpilotd.c b/gpilotd/gpilotd.c
index 34e72a7..9f95628 100644
--- a/gpilotd/gpilotd.c
+++ b/gpilotd/gpilotd.c
@@ -38,7 +38,7 @@
#include "gpilot-daemon.h"
-#define GPILOTD_DBUS_NAME "org.gnome.GnomePilot"
+#define GP_DBUS_NAME "org.gnome.GnomePilot"
static void remove_pid_file (void);
@@ -191,16 +191,16 @@ dbus_acquire_name (DBusGConnection *connection)
if (!dbus_g_proxy_call (bus_proxy,
"RequestName",
&error,
- G_TYPE_STRING, GPILOTD_DBUS_NAME,
+ G_TYPE_STRING, GP_DBUS_NAME,
G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
G_TYPE_INVALID,
G_TYPE_UINT, &result,
G_TYPE_INVALID)) {
if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", GPILOTD_DBUS_NAME, error->message);
+ g_warning ("Failed to acquire %s: %s", GP_DBUS_NAME, error->message);
g_error_free (error);
} else {
- g_warning ("Failed to acquire %s", GPILOTD_DBUS_NAME);
+ g_warning ("Failed to acquire %s", GP_DBUS_NAME);
}
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]