[evolution-patches] Fix the lack of message reading signal in new mail notify plugin



Hi,

This patch fix the lack of a D-BUS signal when a message reading event
is fired, this allow the apps to know when the user starts reading their
mail.

Greetings,
Miguel
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/ChangeLog,v
retrieving revision 1.2
diff -u -r1.2 ChangeLog
--- ChangeLog	11 Jan 2005 03:03:07 -0000	1.2
+++ ChangeLog	12 Jan 2005 06:10:05 -0000
@@ -1,3 +1,12 @@
+2005-01-11  Miguel Angel Lopez Hernandez  <miguel gulev org mx>
+
+	* new-mail-notify.[ch]: Fix author's name, changes in code
+	to maintain coding style
+	(org_gnome_message_reading_notify): Add the function
+
+	* org-gnome-new-mail-notify.eplug.in: define the
+	message reading event
+
 2005-01-11  Not Zed  <NotZed Ximian com>
 
 	* new-mail-notify.c (org_gnome_new_mail_config)
Index: new-mail-notify.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/new-mail-notify.c,v
retrieving revision 1.2
diff -u -r1.2 new-mail-notify.c
--- new-mail-notify.c	11 Jan 2005 03:03:07 -0000	1.2
+++ new-mail-notify.c	12 Jan 2005 06:10:05 -0000
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- *  Author: Miguel Angel Lopez Hernandex <miguel gulev org mx>
+ *  Author: Miguel Angel Lopez Hernandez <miguel gulev org mx>
  *
  *  Copyright 2004 Novell, Inc.
  *
@@ -33,6 +33,7 @@
 #include <mail/em-event.h>
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
+#include <camel/camel-folder.h>
 #include "new-mail-notify.h"
 
 static void
@@ -41,7 +42,10 @@
 	EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) config->target;
 	
 	/* Save the new setting to gconf */
-	gconf_client_set_bool (target->gconf, GCONF_KEY, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)), NULL);
+	gconf_client_set_bool (target->gconf,
+			       GCONF_KEY,
+			       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)),
+			       NULL);
 }
 
 GtkWidget *
@@ -55,10 +59,15 @@
 	notify = gtk_check_button_new_with_mnemonic (_("_Generate a D-BUS message when new mail arrives"));
 
 	/* Set the toggle button to the current gconf setting */
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notify), gconf_client_get_bool (target->gconf, GCONF_KEY, NULL));
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notify),
+				      gconf_client_get_bool (target->gconf,
+							     GCONF_KEY, NULL));
 
 	/* Listen for the item being toggled on and off */
-	g_signal_connect (GTK_TOGGLE_BUTTON (notify), "toggled", G_CALLBACK (toggled_cb), hook_data->config);
+	g_signal_connect (GTK_TOGGLE_BUTTON (notify),
+			  "toggled",
+			  G_CALLBACK (toggled_cb),
+			  hook_data->config);
 	
 	/* Pack the checkbox in the parent widget and show it */
 	gtk_box_pack_start (GTK_BOX (hook_data->parent), notify, FALSE, FALSE, 0);
@@ -68,6 +77,51 @@
 }
 
 void
+org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t)
+{
+	if (gconf_client_get_bool(gconf_client_get_default(),
+				  GCONF_KEY,
+				  NULL)) {
+		DBusConnection *bus;
+		DBusError error;
+		DBusMessage *message;
+
+		/* Get a connection to the session bus */
+		dbus_error_init (&error);
+		bus = dbus_bus_get (DBUS_BUS_SESSION,
+				    &error);
+
+		if (!bus) {
+			printf ("Failed to connect to the D-BUS daemon: %s\n", error.message);
+			dbus_error_free (&error);
+		}
+
+		/* Set up this connection to work in a GLib event loop  */
+		dbus_connection_setup_with_g_main (bus, NULL);
+
+		/* Create a new signal "Newmail" on the DBUS_INTERFACE */
+		message = dbus_message_new_signal (DBUS_PATH,
+						   DBUS_INTERFACE,
+						   "MessageReading");
+
+		/* Append the folder uri as an argument */
+		dbus_message_append_args (message,
+					  DBUS_TYPE_STRING, t->folder->name,
+					  DBUS_TYPE_INVALID);
+
+		/* Send the signal */
+		dbus_connection_send (bus,
+				      message,
+				      NULL);
+
+		/* Free the signal */
+		dbus_message_unref (message);
+
+		/* printf("Message reading: '%s'\n", t->folder->name); */
+	}
+}
+
+void
 org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t)
 {
 	if (gconf_client_get_bool(gconf_client_get_default(), GCONF_KEY, NULL)) {
Index: new-mail-notify.h
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/new-mail-notify.h,v
retrieving revision 1.2
diff -u -r1.2 new-mail-notify.h
--- new-mail-notify.h	11 Jan 2005 03:03:07 -0000	1.2
+++ new-mail-notify.h	12 Jan 2005 06:10:05 -0000
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- *  Author: Miguel Angel Lopez Hernandex <miguel gulev org mx>
+ *  Author: Miguel Angel Lopez Hernandez <miguel gulev org mx>
  *
  *  Copyright 2004 Novell, Inc.
  *
@@ -32,5 +32,7 @@
 void
 org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t);
 
+void
+org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t);
 
 #endif /* __NMN_H__ */
Index: org-gnome-new-mail-notify.eplug.in
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in,v
retrieving revision 1.1
diff -u -r1.1 org-gnome-new-mail-notify.eplug.in
--- org-gnome-new-mail-notify.eplug.in	11 Jan 2005 01:46:06 -0000	1.1
+++ org-gnome-new-mail-notify.eplug.in	12 Jan 2005 06:10:05 -0000
@@ -15,6 +15,12 @@
 			target="folder"/>
 		</hook>
 
+		<hook class="org.gnome.evolution.mail.events:1.0">
+			<event id="message.reading"
+			handle="org_gnome_message_reading_notify"
+			target="message"/>
+		</hook>
+
 		<hook class="org.gnome.evolution.mail.config:1.0">
 			<group target="prefs">
 				<item type="item" 


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