evolution r36052 - branches/mail-dbus-remoting/mail



Author: sragavan
Date: Mon Aug 25 18:17:56 2008
New Revision: 36052
URL: http://svn.gnome.org/viewvc/evolution?rev=36052&view=rev

Log:
More functions on Mail Session to remote IPC.


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

Modified: branches/mail-dbus-remoting/mail/mail-session-remote-impl.c
==============================================================================
--- branches/mail-dbus-remoting/mail/mail-session-remote-impl.c	(original)
+++ branches/mail-dbus-remoting/mail/mail-session-remote-impl.c	Mon Aug 25 18:17:56 2008
@@ -28,6 +28,7 @@
 {
 	const char *method = dbus_message_get_member (message);
 	DBusMessage *reply;
+	gboolean added = FALSE;
 
 	reply = dbus_message_new_method_return (message);
 
@@ -43,20 +44,77 @@
 		ret = dbus_message_get_args(message, NULL, 
 				DBUS_TYPE_STRING, &path,
 				DBUS_TYPE_INVALID);
-		if (!ret) {
-			g_warning ("Unable to get args\n");
-			return DBUS_HANDLER_RESULT_HANDLED;
-		}
-
 		d(printf("calling mail_session_init with: %s\n", path));
 		mail_session_init (path);
-	}
+	} else if (strcmp(method, "mail_session_get_interactive") == 0) {
+		gboolean interactive = mail_session_get_interactive();
+		dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, interactive, DBUS_TYPE_INVALID);
+		d(printf("%s: %d\n", method, interactive));
+		added = TRUE;
+	} else if (strcmp(method, "mail_session_set_interactive") == 0) {
+		gboolean interactive;
+		gboolean ret;
+
+		ret = dbus_message_get_args(message, NULL, 
+				DBUS_TYPE_BOOLEAN, &interactive,
+				DBUS_TYPE_INVALID);
+		d(printf("mail_session_set_interactive: %d\n", interactive));
+		mail_session_set_interactive (interactive);
+	} else if (strcmp(method, "mail_session_get_password") == 0) {
+		gboolean ret;
+		char *key = NULL, *pass;
+
+		ret = dbus_message_get_args(message, NULL, 
+				DBUS_TYPE_STRING, &key,
+				DBUS_TYPE_INVALID);
+		d(printf("%s: %s\n", method, key));
+		pass = mail_session_get_password (key);
+		added = TRUE;
+		dbus_message_append_args (reply, DBUS_TYPE_STRING, pass, DBUS_TYPE_INVALID);
+	} else if (strcmp(method, "mail_session_add_password") == 0) {
+		gboolean ret;
+		char *key = NULL, *pass = NULL;
+
+		ret = dbus_message_get_args(message, NULL, 
+				DBUS_TYPE_STRING, &key,
+				DBUS_TYPE_STRING, &pass,
+				DBUS_TYPE_INVALID);
+		d(printf("%s: %s\n", method, key));
+		mail_session_add_password (key, pass);
+	} else if (strcmp(method, "mail_session_remember password") == 0) {
+		gboolean ret;
+		char *key = NULL;
+
+		ret = dbus_message_get_args(message, NULL, 
+				DBUS_TYPE_STRING, &key,
+				DBUS_TYPE_INVALID);
+		d(printf("%s: %s\n", method, key));
+		mail_session_remember_password (key);
+	} else if (strcmp(method, "mail_session_forget_password") == 0) {
+		gboolean ret;
+		char *key = NULL;
+
+		ret = dbus_message_get_args(message, NULL, 
+				DBUS_TYPE_STRING, &key,
+				DBUS_TYPE_INVALID);
+		d(printf("%s: %s\n", method, key));
+		mail_session_forget_password (key);
+	} else if (strcmp(method, "mail_session_flush_filter_log") == 0) {
+		gboolean ret;
+
+		d(printf("%s\n", method));
+		mail_session_flush_filter_log ();
+	} 
+
+
+	if (!added)
+		dbus_message_append_args(reply, DBUS_TYPE_INVALID);
 
-	dbus_message_append_args(reply, DBUS_TYPE_INVALID);
 	dbus_connection_send (connection, reply, NULL);
 	dbus_message_unref (reply);
 	dbus_connection_flush  (connection);
-	printf("reply send\n");
+	d(printf("reply send\n"));
+
 	return DBUS_HANDLER_RESULT_HANDLED;
 
 }

Modified: branches/mail-dbus-remoting/mail/mail-session-remote.c
==============================================================================
--- branches/mail-dbus-remoting/mail/mail-session-remote.c	(original)
+++ branches/mail-dbus-remoting/mail/mail-session-remote.c	Mon Aug 25 18:17:56 2008
@@ -34,3 +34,180 @@
 
 	d(printf("Mail session initated remotely\n"));
 }
+
+gboolean
+mail_session_remote_get_interactive (void)
+{
+	gboolean ret;
+	DBusError error;
+	gboolean ret_val;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_get_interactive",
+			&error, 
+			"=>b", &ret_val);
+
+	if (!ret) {
+		g_warning ("Error: mail_session_remote_get_interactive: %s\n", error.message);
+		return FALSE;
+	}
+
+	d(printf("Mail session get interactive : %d\n", ret_val));
+	return ret_val;
+}
+
+void
+mail_session_remote_set_interactive (gboolean interactive)
+{
+	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,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_set_interactive",
+			&error, 
+			"b", interactive); 
+
+	if (!ret) {
+		g_warning ("Error:mail_session_remote_set_interactive : %s\n", error.message);
+		return ;
+	}
+
+	d(printf("Mail session set interactive : %d\n", interactive));
+	return;
+}
+
+char *
+mail_session_remote_get_password (const char *url_string)
+{
+	gboolean ret;
+	DBusError error;
+	char *password = NULL;
+
+	dbus_error_init (&error);
+	/* Invoke the appropriate dbind call to MailSessionRemoteImpl */
+	ret = dbind_context_method_call (evolution_dbus_peek_context(), 
+			CAMEL_DBUS_NAME,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_get_password",
+			&error, 
+			"s=>s", url_string, &password); 
+
+	if (!ret) {
+		g_warning ("Error:mail_session_remote_get_password: %s\n", error.message);
+		return NULL;
+	}
+
+	d(printf("mail_session_get_password : %s\n", password ? "*****" : "NULL"));
+	return password;
+}
+
+void
+mail_session_remote_add_password (const char *url, const char *passwd)
+{
+	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,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_add_password",
+			&error, 
+			"ss", url, passwd); 
+
+	if (!ret) {
+		g_warning ("Error:mail_session_remote_add_password: %s\n", error.message);
+		return;
+	}
+
+	d(printf("mail_session_add_password : %s\n", url));
+	return;
+}
+
+void
+mail_session_remote_remember_password (const char *url_string)
+{
+	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,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_remember_password",
+			&error, 
+			"s", url_string); 
+
+	if (!ret) {
+		g_warning ("Error:mail_session_remote_remember_password: %s\n", error.message);
+		return ;
+	}
+
+	d(printf("mail_session_remember_password : %s\n", url_string ? "*****" : "NULL"));
+	return;
+}
+
+void
+mail_session_remote_forget_password (const char *key)
+{
+	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,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_forget_password",
+			&error, 
+			"s", key); 
+
+	if (!ret) {
+		g_warning ("Error:mail_session_remote_forget_password: %s\n", error.message);
+		return ;
+	}
+
+	d(printf("mail_session_forget_password : %s\n", key));
+	return;
+}
+
+void 
+mail_session_remote_flush_filter_log ()
+{
+	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,
+			MAIL_SESSION_OBJECT_PATH,
+			MAIL_SESSION_INTERFACE,
+			"mail_session_flush_filter_log",
+			&error, 
+			""); 
+
+	if (!ret) {
+		g_warning ("Error:mail_session_remote_flush_filter_log: %s\n", error.message);
+		return ;
+	}
+
+	d(printf("mail_session_flush_filter_log: Success \n"));
+	return;
+}



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