xchat-gnome r2715 - in trunk: . plugins plugins/net-monitor plugins/notification plugins/sound-notification src/common



Author: chpe
Date: Sun Mar 15 14:09:02 2009
New Revision: 2715
URL: http://svn.gnome.org/viewvc/xchat-gnome?rev=2715&view=rev

Log:
	Bug 411743 â xchat_print called without valid context

	* plugins/net-monitor/net-monitor.c: (xchat_plugin_init):
	* plugins/notification/notification.c: (xchat_plugin_init):
	* plugins/sound-notification/sound-notification.c:
	(xchat_plugin_init):
	* plugins/xchat-plugin.h:
	* src/common/plugin.c: (plugin_add), (xchat_find_set_context),
	(xchat_find_context):
	* src/common/plugin.h:
	* src/common/xchat-plugin.h: Set the plugin context. Patch by  
	Andreas	Dalsgaard.

Modified:
   trunk/ChangeLog
   trunk/plugins/net-monitor/net-monitor.c
   trunk/plugins/notification/notification.c
   trunk/plugins/sound-notification/sound-notification.c
   trunk/plugins/xchat-plugin.h
   trunk/src/common/plugin.c
   trunk/src/common/plugin.h
   trunk/src/common/xchat-plugin.h

Modified: trunk/plugins/net-monitor/net-monitor.c
==============================================================================
--- trunk/plugins/net-monitor/net-monitor.c	(original)
+++ trunk/plugins/net-monitor/net-monitor.c	Sun Mar 15 14:09:02 2009
@@ -347,8 +347,8 @@
 	if (success) {
 		xchat_hook_print (ph, "Motd",         XCHAT_PRI_NORM, connected_cb, NULL);
 		xchat_hook_print (ph, "MOTD Skipped", XCHAT_PRI_NORM, connected_cb, NULL);
-
-		xchat_set_context (ph, xchat_find_context (ph, NULL, NULL));
+		
+		xchat_find_set_context (ph);
 		xchat_printf (ph, _("%s loaded successfully\n"), NET_MONITOR_NAME);
 	}
 	return success;

Modified: trunk/plugins/notification/notification.c
==============================================================================
--- trunk/plugins/notification/notification.c	(original)
+++ trunk/plugins/notification/notification.c	Sun Mar 15 14:09:02 2009
@@ -183,6 +183,9 @@
 
 	ph = plugin_handle;
 
+	/* Set context on ph*/
+	xchat_find_set_context (ph);
+
 	/* Set the plugin info. */
 	xchat_plugin_get_info (plugin_name, plugin_desc, plugin_version, NULL);
 
@@ -205,7 +208,6 @@
 	xchat_hook_print (ph, "Channel Msg Hilight",		XCHAT_PRI_NORM, new_msg_cb, GUINT_TO_POINTER (NOTIF_NICK));
 	xchat_hook_print (ph, "Channel Action Hilight",		XCHAT_PRI_NORM, new_msg_cb, GUINT_TO_POINTER (NOTIF_NICK));
 	xchat_hook_print (ph, "Private Message to Dialog",	XCHAT_PRI_NORM, new_msg_cb, GUINT_TO_POINTER (NOTIF_NICK));
-
 	gconf_notify_id = gconf_client_notify_add (client, "/apps/xchat/plugins/notification/level", (GConfClientNotifyFunc) level_changed, NULL, NULL, NULL);
 	g_object_unref (client);
 

Modified: trunk/plugins/sound-notification/sound-notification.c
==============================================================================
--- trunk/plugins/sound-notification/sound-notification.c	(original)
+++ trunk/plugins/sound-notification/sound-notification.c	Sun Mar 15 14:09:02 2009
@@ -75,6 +75,9 @@
 {
 	ph = plugin_handle;
 
+	/* Set context on ph*/
+	xchat_find_set_context (ph);
+
 	/* Set the plugin info. */
 	xchat_plugin_get_info (plugin_name, plugin_desc, plugin_version, NULL);
 

Modified: trunk/plugins/xchat-plugin.h
==============================================================================
--- trunk/plugins/xchat-plugin.h	(original)
+++ trunk/plugins/xchat-plugin.h	Sun Mar 15 14:09:02 2009
@@ -82,6 +82,7 @@
 	       const char *s2);
 	int (*xchat_set_context) (xchat_plugin *ph,
 		   xchat_context *ctx);
+	void (*xchat_find_set_context) (xchat_plugin *ph);
 	xchat_context *(*xchat_find_context) (xchat_plugin *ph,
 		    const char *servname,
 		    const char *channel);
@@ -205,6 +206,9 @@
 xchat_set_context (xchat_plugin *ph,
 		   xchat_context *ctx);
 
+void
+xchat_find_set_context(xchat_plugin *ph);
+
 xchat_context *
 xchat_find_context (xchat_plugin *ph,
 		    const char *servname,
@@ -308,6 +312,7 @@
 #define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf)
 #define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp)
 #define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context)
+#define xchat_find_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_set_context)
 #define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context)
 #define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context)
 #define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info)

Modified: trunk/src/common/plugin.c
==============================================================================
--- trunk/src/common/plugin.c	(original)
+++ trunk/src/common/plugin.c	Sun Mar 15 14:09:02 2009
@@ -239,6 +239,7 @@
 		pl->xchat_commandf = xchat_commandf;
 		pl->xchat_nickcmp = xchat_nickcmp;
 		pl->xchat_set_context = xchat_set_context;
+		pl->xchat_find_set_context = xchat_find_set_context;
 		pl->xchat_find_context = xchat_find_context;
 		pl->xchat_get_context = xchat_get_context;
 		pl->xchat_get_info = xchat_get_info;
@@ -914,6 +915,32 @@
 	return 0;
 }
 
+void xchat_find_set_context(xchat_plugin *ph)
+{
+	xchat_list *channels_list;
+	channels_list = xchat_list_get (ph, "channels");
+
+	if (channels_list == NULL)
+		return;
+
+	while (xchat_list_next (ph, channels_list)) {
+		const gchar *channel, *server;
+		gint type;
+
+		channel = xchat_list_str (ph, channels_list, "channel");
+		server  = xchat_list_str (ph, channels_list, "server");
+		type    = xchat_list_int (ph, channels_list, "type");
+
+		if (type == 1) {
+			xchat_context *context = xchat_find_context (ph, server, channel);
+			if (is_session(context)) {
+				xchat_set_context (ph, context);
+				return;
+			}
+		}
+	}
+}
+
 xchat_context *
 xchat_find_context (xchat_plugin *ph, const char *servname, const char *channel)
 {
@@ -947,12 +974,16 @@
 				{
 					if (rfc_casecmp (channel, sess->channel) == 0)
 					{
-						if (sess->server == ph->context->server)
-						{
-							g_slist_free (sessions);
-							return sess;
-						} else
-						{
+						if (ph->context != NULL) {
+							if (sess->server == ph->context->server)
+							{
+								g_slist_free (sessions);
+								return sess;
+							} else
+							{
+								sessions = g_slist_prepend (sessions, sess);
+							}
+						} else {
 							sessions = g_slist_prepend (sessions, sess);
 						}
 					}

Modified: trunk/src/common/plugin.h
==============================================================================
--- trunk/src/common/plugin.h	(original)
+++ trunk/src/common/plugin.h	Sun Mar 15 14:09:02 2009
@@ -46,6 +46,7 @@
 	       const char *s2);
 	int (*xchat_set_context) (xchat_plugin *ph,
 		   xchat_context *ctx);
+	void (*xchat_find_set_context) (xchat_plugin *ph);
 	xchat_context *(*xchat_find_context) (xchat_plugin *ph,
 		    const char *servname,
 		    const char *channel);

Modified: trunk/src/common/xchat-plugin.h
==============================================================================
--- trunk/src/common/xchat-plugin.h	(original)
+++ trunk/src/common/xchat-plugin.h	Sun Mar 15 14:09:02 2009
@@ -82,6 +82,7 @@
 	       const char *s2);
 	int (*xchat_set_context) (xchat_plugin *ph,
 		   xchat_context *ctx);
+	void (*xchat_find_set_context) (xchat_plugin *ph);
 	xchat_context *(*xchat_find_context) (xchat_plugin *ph,
 		    const char *servname,
 		    const char *channel);
@@ -204,6 +205,8 @@
 int
 xchat_set_context (xchat_plugin *ph,
 		   xchat_context *ctx);
+void
+xchat_find_set_context (xchat_plugin *ph);
 
 xchat_context *
 xchat_find_context (xchat_plugin *ph,



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