diff src/server.c @ 94:9f6ce50ffb78

[gaim-migrate @ 104] Woohoo, the landing of the plugins. Nearly everything necessary is here. The only thing missing is that you can't load a plugin without signing on first (at least, not without some trickery). committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 09 Apr 2000 11:18:25 +0000
parents bfdc427b936d
children a9aa982272f9
line wrap: on
line diff
--- a/src/server.c	Sun Apr 09 08:25:15 2000 +0000
+++ b/src/server.c	Sun Apr 09 11:18:25 2000 +0000
@@ -83,7 +83,7 @@
 
         gettimeofday(&lag_tv, NULL);
 	if (!(general_options & OPT_GEN_SHOW_LAGMETER))
-		serv_send_im(current_user->username, LAGOMETER_STR, 1);
+		serv_send_im(current_user->username, LAGOMETER_STR, 0);
 
 	if (report_idle != IDLE_GAIM)
                 return TRUE;
@@ -137,12 +137,31 @@
 void serv_send_im(char *name, char *message, int away)
 {
 	char buf[MSG_LEN - 7];
+
+#ifdef GAIM_PLUGINS
+	GList *c = callbacks;
+	struct gaim_callback *g;
+	void (*function)(char **, char **, void *);
+	while (c) {
+		g = (struct gaim_callback *)c->data;
+		if (g->event == event_im_send && g->function != NULL) {
+			function = g->function;
+			/* I can guarantee you this is wrong */
+			(*function)(&name, &message, g->data);
+		}
+		c = c->next;
+	}
+	/* make sure no evil plugin is trying to crash gaim */
+	if (message == NULL)
+		return;
+#endif
+
 #ifndef USE_OSCAR
         g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name),
                    message, ((away) ? " auto" : ""));
 	sflap_send(buf, strlen(buf), TYPE_DATA);
 #else
-	aim_send_im(NULL, normalize(name), ((away) ? AIM_IMFLAGS_AWAY : 0), message);
+	aim_send_im(NULL, normalize(name), ((away) ? 0 : AIM_IMFLAGS_AWAY), message);
 #endif
         if (!away)
                 serv_touch_idle();
@@ -451,6 +470,24 @@
         int new_conv = 0;
 	char *nname;
 
+#ifdef GAIM_PLUGINS
+	GList *c = callbacks;
+	struct gaim_callback *g;
+	void (*function)(char **, char **, void *);
+	while (c) {
+		g = (struct gaim_callback *)c->data;
+		if (g->event == event_im_recv && g->function != NULL) {
+			function = g->function;
+			/* I can guarantee you this is wrong */
+			(*function)(&name, &message, g->data);
+		}
+		c = c->next;
+	}
+	/* make sure no evil plugin is trying to crash gaim */
+	if (message == NULL)
+		return;
+#endif
+
 	nname = g_strdup(normalize(name));
 
 	if (!strcasecmp(normalize(name), nname)) {