changeset 392:df5127560034

[gaim-migrate @ 402] More updates to plugins committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 12 Jun 2000 13:07:53 +0000
parents be408b41c172
children bbff7d508593
files plugins/ChangeLog plugins/Makefile.am plugins/SIGNALS plugins/error.c src/aim.c src/oscar.c src/plugins.c
diffstat 7 files changed, 111 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog	Mon Jun 12 11:30:05 2000 +0000
+++ b/plugins/ChangeLog	Mon Jun 12 13:07:53 2000 +0000
@@ -9,9 +9,9 @@
 	plugins do not have to be recompiled in order for them to still work.
 
 	The big thing to note is that gaim_plugin_init no longer returns void,
-	but int.  If it returns 0, gaim interprets this as there being no
+	but int.  If it returns 1, gaim interprets this as there being no
 	error, and continues with loading as normal. (This should be backwards-
-	compatible: returning 0 is the equivalent of returning void.) If it
+	compatible: returning 1 is the equivalent of returning void.) If it
 	returns a non-zero number, there was an error loading detected by the
 	plugin. At that point, gaim will try to clean things up by removing any
 	callbacks that have been added by the plugin. It will then try to call
@@ -21,3 +21,25 @@
 	message.  The plugin is then unloaded and closed and life goes back to
 	normal. If any of that was confusing, it was confusing to me, too. I
 	added a plugin, error.c, which should help clear things up.
+
+	There is a new event, event_quit, which signifies that gaim has exited
+	correctly (i.e. didn't segfault). Also, after this event is called, all
+	plugins are removed, and their gaim_plugin_init function is called.
+	This behavior is different from previous versions; however, it is the
+	proper way of doing things, and should have no effect on current
+	plugins. The reason event_quit exists despite plugins being removed at
+	quit is because a plugin can be removed without gaim quitting. They are
+	distinctly separate events.
+
+	The new events mean that some versions of gaim have certain events,
+	others don't. The thing I find fascinating though is that even if a
+	plugin is compiled for a later version, it will still be backwards-
+	compatible, even if it makes use of the newer events. The reason why
+	is the names of the events are stored as integers, and those integers
+	will never match an event in a prior version. This means you don't
+	have to worry about which version the person is using, only which
+	version the person is compiling against. For simplicity's sake, please
+	assume people are compiling against the latest version. For
+	practicality's sake, VERSION is #define'd to be the version you're
+	compiling against, starting with 0.9.20. Prior versions do not have
+	this defined in the standard plugin Makefile.
--- a/plugins/Makefile.am	Mon Jun 12 11:30:05 2000 +0000
+++ b/plugins/Makefile.am	Mon Jun 12 13:07:53 2000 +0000
@@ -1,18 +1,28 @@
-SUFFIXES = .c .so
 if GNOMEAPPLET
 CFLAGS += $(GTK_CFLAGS) $(GNOME_INCLUDEDIR) -I../src -DUSE_APPLET
 else
 CFLAGS += $(GTK_CFLAGS) -I../src
 endif
+
+
+
 LDFLAGS += -ggdb $(GTK_LIBS) -shared
+SUFFIXES = .c .so
 .c.so:
-	$(CC) $(CFLAGS) -fPIC -DPIC -o $@ $< $(LDFLAGS)
+	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -fPIC -DPIC -o $@ $< $(LDFLAGS)
+
+
+
 if PLUGINS
 plugin_DATA = autorecon.so iconaway.so notify.so spellchk.so
 plugindir = $(libdir)/gaim
+
 clean distclean clean-recursive distclean-recursive:
 	$(RM) $(plugin_DATA)
 endif
+
+
+
 EXTRA_DIST = ChangeLog CRAZY HOWTO SIGNALS autorecon.c error.c filectl.c \
 	gaiminc.c iconaway.c lagmeter.c notify.c simple.c spellchk.c \
 	toc_commands.c
--- a/plugins/SIGNALS	Mon Jun 12 11:30:05 2000 +0000
+++ b/plugins/SIGNALS	Mon Jun 12 13:07:53 2000 +0000
@@ -180,5 +180,9 @@
 event_quit:
 	(none)
 
-	Called when gaim quits normally. If gaim dies or is killed, this won't
-	be called. It's not my fault, it's Seg's.
+	Called when gaim quits normally.  This can be called from either the
+	signed on state or the signed off state (from either the Cancel button
+	in the login window or the Quit option in the File menu on the buddy
+	list). Note that for the applet, this will never be called. If gaim
+	dies or is murdered, this won't be called. It's not my fault, it's
+	Seg's.
--- a/plugins/error.c	Mon Jun 12 11:30:05 2000 +0000
+++ b/plugins/error.c	Mon Jun 12 13:07:53 2000 +0000
@@ -36,7 +36,7 @@
 }
 
 char *name() {
-	return "Error Tester";
+	return "Error Tester" VERSION ;
 }
 
 char *description() {
--- a/src/aim.c	Mon Jun 12 11:30:05 2000 +0000
+++ b/src/aim.c	Mon Jun 12 13:07:53 2000 +0000
@@ -78,6 +78,40 @@
         AppletCancelLogon();
         gtk_widget_hide(mainwindow);
 #else
+#ifdef GAIM_PLUGINS
+	GList *c;
+	struct gaim_callback *g;
+	struct gaim_plugin *p;
+	void (*function)(void *);
+	void (*gaim_plugin_remove)();
+	char *error;
+
+	/* first we tell those who have requested it we're quitting */
+	c = callbacks;
+	while (c) {
+		g = (struct gaim_callback *)c->data;
+		if (g->event == event_quit && g->function != NULL) {
+			function = g->function;
+			(*function)(g->data);
+		}
+		c = c->next;
+	}
+
+	/* then we remove everyone in a mass suicide */
+	c = plugins;
+	while (c) {
+		p = (struct gaim_plugin *)c->data;
+		gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove");
+		if ((error = (char *)dlerror()) == NULL)
+			(*gaim_plugin_remove)();
+		/* we don't need to worry about removing callbacks since
+		 * there won't be any more chance to call them back :) */
+		dlclose(p->handle);
+		g_free(p->filename); /* why do i bother? */
+		g_free(p);
+	}
+#endif /* GAIM_PLUGINS */
+
 	exit(0);
 #endif /* USE_APPLET */
 }
--- a/src/oscar.c	Mon Jun 12 11:30:05 2000 +0000
+++ b/src/oscar.c	Mon Jun 12 13:07:53 2000 +0000
@@ -211,13 +211,19 @@
 	if (sess->logininfo.errorcode) {
 		switch (sess->logininfo.errorcode) {
 		case 0x18:
-			do_error_dialog(_("You have been connecting and disconnecting too frequently.  Wait ten minutes and try again.  If you continue to try, you will need to wait even longer."), _("Gaim - Error"));
+			/* connecting too frequently */
+			strtok("983:", ":");
+			show_error_dialog("983");
 			break;
 		case 0x05:
-			do_error_dialog(_("Incorrect nickname or password."), _("Gaim - Error"));
+			/* Incorrect nick/password */
+			strtok("980:", ":");
+			show_error_dialog("980");
 			break;
 		case 0x1c:
-			do_error_dialog(_("AOL has decided your client is too old. Please download a newer version from http://www.marko.net/gaim/"), _("Gaim - Error"));
+			/* client too old */
+			strtok("981:", ":");
+			show_error_dialog("981");
 			break;
 		}
 		sprintf(debug_buff, "Login Error Code 0x%04x\n",
@@ -582,33 +588,39 @@
 	u_short family;
 	u_short subtype;
 
-	char buf[2048], buf2[256];
-	sprintf(buf2, _("Gaim - Error"));
-	buf[0] = 0;
-
 	family  = aimutil_get16(command->data+0);
 	subtype = aimutil_get16(command->data+2);
 
 	switch (family) {
 	case 0x0001:
-		if (subtype == 0x000a)
-			sprintf(buf, _("You are sending messages too fast."));
+		if (subtype == 0x000a) {
+			/* sending messages too fast */
+			/* this also gets sent to us when our warning level
+			 * changes, don't ask me why or how to interpret it */
+			strtok("960:someone", ":");
+			show_error_dialog("960");
+		}
 		break;
 	case 0x0002:
-		if (subtype == 0x0001)
-			sprintf(buf, _("Unknown SNAC error (I'm hungry)"));
+		if (subtype == 0x0001) {
+			/* unknown SNAC error */
+			strtok("970:", ":");
+			show_error_dialog("970");
+		}
 		break;
 	case 0x0004:
-		if (subtype == 0x0001)
-			sprintf(buf, _("User is not online."));
-		else if (subtype == 0x000a)
-			sprintf(buf, _("A message has been dropped."));
+		if (subtype == 0x0001) {
+			/* user is not logged in */
+			strtok("901:User", ":");
+			show_error_dialog("901");
+		} else if (subtype == 0x000a) {
+			/* message has been dropped */
+			strtok("903:", ":");
+			show_error_dialog("903");
+		}
 		break;
 	}
 
-	if (buf[0] != 0)
-		do_error_dialog(buf, buf2);
-
 	return 1;
 }
 
@@ -628,8 +640,9 @@
 	va_end(ap);
 
 	if (prof == NULL || !strlen(prof)) {
-		do_error_dialog(_("User has no info/away message."),
-				_("Gaim - User Info"));
+		/* no info/away message */
+		strtok("977:", ":");
+		show_error_dialog("977");
 		return 1;
 	}
 
--- a/src/plugins.c	Mon Jun 12 11:30:05 2000 +0000
+++ b/src/plugins.c	Mon Jun 12 13:07:53 2000 +0000
@@ -178,7 +178,7 @@
 	retval = (*gaim_plugin_init)(plug->handle);
 	sprintf(debug_buff, "loaded plugin returned %d\n", retval);
 	debug_print(debug_buff);
-	if (retval) {
+	if (retval != 1) {
 		GList *c = callbacks;
 		struct gaim_callback *g;
 		while (c) {