evolution r36064 - branches/mail-dbus-remoting/mail



Author: sragavan
Date: Tue Aug 26 04:23:04 2008
New Revision: 36064
URL: http://svn.gnome.org/viewvc/evolution?rev=36064&view=rev

Log:
Merge Bharath's changes...


Modified:
   branches/mail-dbus-remoting/mail/camel-session-remote-impl.c
   branches/mail-dbus-remoting/mail/camel-session-remote.c

Modified: branches/mail-dbus-remoting/mail/camel-session-remote-impl.c
==============================================================================
--- branches/mail-dbus-remoting/mail/camel-session-remote-impl.c	(original)
+++ branches/mail-dbus-remoting/mail/camel-session-remote-impl.c	Tue Aug 26 04:23:04 2008
@@ -7,19 +7,19 @@
 #include "mail-dbus.h"
 #include <camel/camel-session.h>
 #include <camel/camel-store.h>
+#include <camel/camel.h>
 
 #define CAMEL_SESSION_OBJECT_PATH "/org/gnome/evolution/camel/session"
 
 static gboolean session_setup = FALSE;
 
+extern GHashTable *store_hash = NULL;
+
 static DBusHandlerResult
 dbus_listener_message_handler (DBusConnection *connection,
                                     DBusMessage    *message,
                                     void           *user_data);
 
-
-
-
 static DBusHandlerResult
 dbus_listener_message_handler (DBusConnection *connection,
                                     DBusMessage    *message,
@@ -29,7 +29,7 @@
 	DBusMessage *return_val;
 
 	CamelSession *session = NULL;
-	CamelStore *store = NULL;
+	CamelStore *store;
 
   	printf ("D-Bus message: obj_path = '%s' interface = '%s' method = '%s' destination = '%s'\n",
            dbus_message_get_path (message),
@@ -40,7 +40,7 @@
 	
 	return_val = dbus_message_new_method_return (message);
 
-	if (strcmp(dbus_message_get_member (message), "camel_session_construct") == 0) {
+	if (strcmp(method, "camel_session_construct") == 0) {
 		char *storage_path;
 		char *session_str;
 		gboolean ret;
@@ -53,8 +53,8 @@
 		camel_session_construct (session, storage_path);
 		dbus_message_append_args (return_val, DBUS_TYPE_INVALID);
 	
-	} else if (strcmp(dbus_message_get_member (message), "camel_session_get_password") == 0) {
-		char *session_str, *store_str, *domain, *prompt, *item, *err;
+	} else if (strcmp(method, "camel_session_get_password") == 0) {
+		char *session_str, *store_hash_key, *domain, *prompt, *item, *err;
 		const char *passwd;
 		guint32 flags;
 		gboolean ret;
@@ -62,13 +62,19 @@
 
 		ret = dbus_message_get_args(message, NULL,
 				DBUS_TYPE_STRING, &session_str,
-				DBUS_TYPE_STRING, &store_str,
+				DBUS_TYPE_STRING, &store_hash_key,
 				DBUS_TYPE_STRING, &domain,
 				DBUS_TYPE_STRING, &prompt,
 				DBUS_TYPE_STRING, &item,
 				DBUS_TYPE_UINT32, &flags,
 				DBUS_TYPE_INVALID);
 
+		store = g_hash_table_lookup (store_hash, store_hash_key);
+		if (!store) {
+			dbus_message_append_args (return_val, DBUS_TYPE_STRING, "", DBUS_TYPE_STRING, _("Store not found"), DBUS_TYPE_INVALID);
+			goto fail;
+		}
+
 		camel_exception_init (ex);
 		
 		passwd = camel_session_get_password (session, store, domain, prompt, item, flags, ex);
@@ -81,8 +87,152 @@
 			
 		dbus_message_append_args (return_val, DBUS_TYPE_STRING, passwd, DBUS_TYPE_STRING, err, DBUS_TYPE_INVALID);
 		g_free (err);
+	} else if (strcmp (method, "camel_session_get_storage_path") == 0) {
+		char *session_str, *store_hash_key, *storage_path, *err;
+		gboolean ret;
+		CamelException *ex;
+
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &session_str,
+				DBUS_TYPE_STRING, &store_hash_key,
+				DBUS_TYPE_INVALID);
+		
+		store = g_hash_table_lookup (store_hash, store_hash_key);
+		if (!store) {
+			dbus_message_append_args (return_val, DBUS_TYPE_STRING, "", DBUS_TYPE_STRING, _("Store not found"), DBUS_TYPE_INVALID);
+			goto fail;
+		}
+
+		camel_exception_init (ex);
+		
+		storage_path = camel_session_get_storage_path (session, store, ex);
+
+		if (ex)
+			err = g_strdup (camel_exception_get_description (ex));
+		else
+			err = g_strdup ("");
+
+		camel_exception_free (ex);
+			
+		dbus_message_append_args (return_val, DBUS_TYPE_STRING, storage_path, DBUS_TYPE_STRING, err, DBUS_TYPE_INVALID);
+		g_free (err);
+	} else if (strcmp (method, "camel_session_forget_password") == 0) {
+		char *session_str, *store_hash_key, *domain, *item, *err;
+		gboolean ret;
+		CamelException *ex;
+
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &session_str,
+				DBUS_TYPE_STRING, &store_hash_key,
+				DBUS_TYPE_STRING, &domain,
+				DBUS_TYPE_STRING, &item,				
+				DBUS_TYPE_INVALID);
+		
+		store = g_hash_table_lookup (store_hash, store_hash_key);
+		if (!store) {
+			dbus_message_append_args (return_val, DBUS_TYPE_STRING, _("Store not found"), DBUS_TYPE_INVALID);
+			goto fail;
+		}
+
+		camel_exception_init (ex);
+		
+		camel_session_forget_password (session, store, domain, item, ex);
+
+		if (ex)
+			err = g_strdup (camel_exception_get_description (ex));
+		else
+			err = g_strdup ("");
+
+		camel_exception_free (ex);
+			
+		dbus_message_append_args (return_val, DBUS_TYPE_STRING, err, DBUS_TYPE_INVALID);
+		g_free (err);
+	} else if (strcmp (method, "camel_session_get_service") == 0) {
+		char *session_str, *url_string, *err;
+		CamelProviderType type;
+		CamelService *service;
+		gboolean ret;
+		CamelException *ex;
+
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &session_str,
+				DBUS_TYPE_STRING, &url_string,
+				DBUS_TYPE_INT32, &type,
+				DBUS_TYPE_INVALID);
+		
+		camel_exception_init (ex);
+		
+		service = camel_session_get_service (session, url_string, type, ex);
+
+		if (ex)
+			err = g_strdup (camel_exception_get_description (ex));
+		else
+			err = g_strdup ("");
+
+		camel_exception_free (ex);
+			
+/*verify and fix this*/	
+		dbus_message_append_args (return_val, DBUS_TYPE_STRING, "", DBUS_TYPE_STRING, err, DBUS_TYPE_INVALID);
+		g_free (err);
+	} else if (strcmp (method, "camel_session_alert_user") == 0) {
+		char *session_str, *prompt, *err;
+		gboolean ret, cancel, response;
+		int alert;
+
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &session_str,
+				DBUS_TYPE_INT32, &alert,
+				DBUS_TYPE_STRING, &prompt,
+				DBUS_TYPE_BOOLEAN, &cancel,
+				DBUS_TYPE_INVALID);
+		
+		response = camel_session_alert_user (session, alert, prompt, cancel);
+
+		dbus_message_append_args (return_val, DBUS_TYPE_BOOLEAN, response, DBUS_TYPE_INVALID);
+		g_free (err);
+	} else if (strcmp (method, "camel_session_build_password_prompt") == 0) {
+		gboolean ret;
+		char *type, *user, *host, *prompt, *err;
+		
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &type,
+				DBUS_TYPE_STRING, &user,
+				DBUS_TYPE_STRING, &host,
+				DBUS_TYPE_INVALID);
+		
+		prompt = camel_session_build_password_prompt (type, user, host);
+
+		dbus_message_append_args (return_val, DBUS_TYPE_STRING, prompt, DBUS_TYPE_INVALID);
+		g_free (err);
+	} else if (strcmp (method, "camel_session_is_online") == 0) {
+		gboolean ret, is_online;
+		char *session_str, *err;
+		
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &session_str,
+				DBUS_TYPE_INVALID);
+		
+		is_online = camel_session_is_online (session);
+
+		dbus_message_append_args (return_val, DBUS_TYPE_BOOLEAN, is_online, DBUS_TYPE_INVALID);
+		g_free (err);
+	} else if (strcmp (method, "camel_session_set_online") == 0) {
+		gboolean ret, set;
+		char *session_str, *err;
+		
+		ret = dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &session_str,
+				DBUS_TYPE_BOOLEAN, &set,
+				DBUS_TYPE_INVALID);
+		
+		camel_session_set_online (session, set);
+
+		dbus_message_append_args (return_val, DBUS_TYPE_INVALID);
+		g_free (err);
 	}
 
+
+fail:
 	dbus_connection_send (connection, return_val, NULL);
 	dbus_message_unref (return_val);
 	dbus_connection_flush(connection);

Modified: branches/mail-dbus-remoting/mail/camel-session-remote.c
==============================================================================
--- branches/mail-dbus-remoting/mail/camel-session-remote.c	(original)
+++ branches/mail-dbus-remoting/mail/camel-session-remote.c	Tue Aug 26 04:23:04 2008
@@ -6,13 +6,24 @@
 #include <mail-dbus.h>
 #include "camel-session-remote.h"
 #include "camel-store-remote.h"
-#include "camel/camel-types.h"
 
 #define CAMEL_SESSION_INTERFACE	"org.gnome.evolution.camel.session.mail"
 #define CAMEL_SESSION_OBJECT_PATH "/org/gnome/evolution/camel/session"
 #define CAMEL_DBUS_NAME "org.gnome.evolution.camel"
 
 
+typedef enum {
+	CAMEL_PROVIDER_STORE,
+	CAMEL_PROVIDER_TRANSPORT,
+	CAMEL_NUM_PROVIDER_TYPES
+} CamelProviderType;
+
+typedef enum {
+	CAMEL_SESSION_ALERT_INFO,
+	CAMEL_SESSION_ALERT_WARNING,
+	CAMEL_SESSION_ALERT_ERROR
+} CamelSessionAlertType;
+
 void
 camel_session_remote_construct	(CamelSessionRemote *session,
 			const char *storage_path)
@@ -45,12 +56,11 @@
 			const char *domain,
 			const char *prompt,
 			const char *item,
-			guint32 flags,
-			CamelException *ex)
+			guint32 flags)
 {
 	gboolean ret;
 	DBusError error;
-	const char *passwd;
+	char *passwd, *ex;
 
 	dbus_error_init (&error);
 	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
@@ -60,7 +70,7 @@
 			CAMEL_SESSION_INTERFACE,
 			"camel_session_get_password",
 			&error, 
-			"sssssu=>ss", session->object_id, service->object_id, domain, prompt, item, flags, &passwd, &ex); /* Just string of base dir */
+			"sssssu=>ss", session->object_id, service->object_id, domain, prompt, item, flags, &passwd, &ex); 
 
 	if (!ret) {
 		g_warning ("Error: Camel session fetching password: %s\n", error.message);
@@ -72,4 +82,201 @@
 	return passwd;
 }
 
+char *
+camel_session_remote_get_storage_path (CamelSessionRemote *session, CamelStoreRemote *service)
+{
+	gboolean ret;
+	DBusError error;
+	char *storage_path, *ex;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_get_storage_path",
+			&error, 
+			"ss=>ss", session->object_id, service->object_id, &storage_path, &ex);
+
+	if (!ret) {
+		g_warning ("Error: Camel session fetching storage path: %s\n", error.message);
+		return NULL;
+	}
+
+	d(printf("Camel session get storage path remotely\n"));
+
+	return storage_path;
+}
+
+void
+camel_session_remote_forget_password (CamelSessionRemote *session, 
+				CamelStoreRemote *service,
+				const char *domain,
+				const char *item)
+{
+	gboolean ret;
+	DBusError error;
+	char *ex;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_forget_password",
+			&error, 
+			"ssss=>s", session->object_id, service->object_id, domain, item, &ex); 
+
+	if (!ret) {
+		g_warning ("Error: Camel session forget password: %s\n", error.message);
+		return;
+	}
+
+	d(printf("Camel session forget password remotely\n"));
+
+	return;
+}
+
+CamelStoreRemote *
+camel_session_remote_get_service (CamelSessionRemote *session, const char *url_string,
+			   CamelProviderType type)
+{
+	gboolean ret;
+	DBusError error;
+	char *service, *ex;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_get_service",
+			&error, 
+			"ssi=>ss", session->object_id, url_string, type, &service, &ex);
+
+	if (!ret) {
+		g_warning ("Error: Camel session get service: %s\n", error.message);
+		return;
+	}
+
+	d(printf("Camel session get service remotely\n"));
+
+	return;
+}
+
+gboolean  
+camel_session_remote_alert_user (CamelSessionRemote *session, 
+					CamelSessionAlertType type,
+					const char *prompt,
+					gboolean cancel)
+{
+	gboolean ret, success;
+	DBusError error;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_alert_user",
+			&error, 
+			"sis(int)b=>(int)b", session->object_id, type, prompt, cancel, &success);
+
+	if (!ret) {
+		g_warning ("Error: Camel session alerting user: %s\n", error.message);
+		return 0;
+	}
+
+	d(printf("Camel session alert user remotely\n"));
+
+	return success;
+}
+
+char *
+camel_session_remote_build_password_prompt (const char *type,
+				     const char *user,
+				     const char *host)
+{
+	gboolean ret;
+	DBusError error;
+	char *prompt;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_build_password_prompt",
+			&error, 
+			"sss=>s", type, user, host, &prompt);
+
+	if (!ret) {
+		g_warning ("Error: Camel session building password prompt: %s\n", error.message);
+		return NULL;
+	}
+
+	d(printf("Camel session build password prompt remotely\n"));
+
+	return prompt;
+}
+
+gboolean           
+camel_session_remote_is_online (CamelSessionRemote *session)
+{
+	gboolean ret, is_online;
+	DBusError error;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_is_online",
+			&error, 
+			"s=>(int)b", session->object_id, &is_online);
+
+	if (!ret) {
+		g_warning ("Error: Camel session check for online: %s\n", error.message);
+		return 0;
+	}
+
+	d(printf("Camel session check for online remotely\n"));
+
+	return is_online;
+
+}
+
+void 
+camel_session_remote_set_online  (CamelSessionRemote *session,
+				gboolean online)
+{
+	gboolean ret;
+	DBusError error;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			CAMEL_SESSION_OBJECT_PATH,
+			CAMEL_SESSION_INTERFACE,
+			"camel_session_set_online",
+			&error, 
+			"ss", session->object_id, online);
+
+	if (!ret) {
+		g_warning ("Error: Camel session set online: %s\n", error.message);
+		return;
+	}
+
+	d(printf("Camel session set online remotely\n"));
+
+	return;
+}
+
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]