changeset 2443:7f2432a87376

[gaim-migrate @ 2456] it can send ims. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 06 Oct 2001 04:37:34 +0000
parents 895e2469cb3a
children 13ce96daf30f
files src/core.c src/core.h src/module.c
diffstat 3 files changed, 83 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/core.c	Sat Oct 06 04:05:53 2001 +0000
+++ b/src/core.c	Sat Oct 06 04:37:34 2001 +0000
@@ -90,6 +90,42 @@
 	}
 }
 
+static void plugin_handler(struct UI *ui, guchar subtype, guchar *data)
+{
+	guint id;
+	struct gaim_plugin *p;
+
+	switch (subtype) {
+		/*
+	case CUI_PLUGIN_LIST:
+		break;
+		*/
+	case CUI_PLUGIN_LOAD:
+		p = load_plugin(data);
+		/* XXX need to broadcast to UIs that plugin has been loaded */
+		break;
+	case CUI_PLUGIN_UNLOAD:
+		memcpy(&id, data, sizeof(id));
+		p = g_list_nth_data(plugins, id);
+		if (p) {
+			unload_plugin(p);
+			/* XXX need to broadcast to UIs that plugin has been unloaded */
+		}
+		break;
+	case CUI_PLUGIN_RELOAD:
+		memcpy(&id, data, sizeof(id));
+		p = g_list_nth_data(plugins, id);
+		if (p) {
+			p = reload_plugin(p);
+			/* XXX need to broadcast to UIs that plugin has been reloaded */
+		}
+		break;
+	default:
+		debug_printf("unhandled plugin subtype %d\n", subtype);
+		break;
+	}
+}
+
 static void user_handler(struct UI *ui, guchar subtype, guchar *data)
 {
 	guint id;
@@ -121,6 +157,53 @@
 	}
 }
 
+static void message_handler(struct UI *ui, guchar subtype, guchar *data)
+{
+	switch (subtype) {
+	case CUI_MESSAGE_LIST:
+		break;
+	case CUI_MESSAGE_SEND:
+		if (!data)
+			return;
+		{
+			guint id;
+			struct gaim_connection *gc;
+			guint len;
+			char *who, *msg;
+			gint flags;
+			int pos = 0;
+
+			memcpy(&id, data + pos, sizeof(id));
+			pos += sizeof(id);
+			gc = g_slist_nth_data(connections, id);
+			if (!gc)
+				return;
+
+			memcpy(&len, data + pos, sizeof(len));
+			pos += sizeof(len);
+			who = g_strndup(data + pos, len + 1);
+			pos += len;
+
+			memcpy(&len, data + pos, sizeof(len));
+			pos += sizeof(len);
+			msg = g_strndup(data + pos, len + 1);
+			pos += len;
+
+			memcpy(&flags, data + pos, sizeof(flags));
+			serv_send_im(gc, who, msg, flags);
+
+			g_free(who);
+			g_free(msg);
+		}
+		break;
+	case CUI_MESSAGE_RECV:
+		break;
+	default:
+		debug_printf("unhandled message subtype %d\n", subtype);
+		break;
+	}
+}
+
 static gint gaim_recv(GIOChannel *source, void *buf, gint len)
 {
 	gint total = 0;
--- a/src/core.h	Sat Oct 06 04:05:53 2001 +0000
+++ b/src/core.h	Sat Oct 06 04:37:34 2001 +0000
@@ -187,7 +187,6 @@
 extern void remove_all_plugins();
 #endif
 extern int plugin_event(enum gaim_event, void *, void *, void *, void *);
-extern void plugin_handler(struct UI *, guchar, guchar *);
 
 /* Functions in server.c */
 extern void serv_got_update(struct gaim_connection *, char *, int, int, time_t, time_t, int, gushort);
--- a/src/module.c	Sat Oct 06 04:05:53 2001 +0000
+++ b/src/module.c	Sat Oct 06 04:37:34 2001 +0000
@@ -524,39 +524,3 @@
 	}
 }
 #endif
-
-void plugin_handler(struct UI *ui, guchar subtype, guchar *data)
-{
-	guint id;
-	struct gaim_plugin *p;
-
-	switch (subtype) {
-		/*
-	case CUI_PLUGIN_LIST:
-		break;
-		*/
-	case CUI_PLUGIN_LOAD:
-		p = load_plugin(data);
-		/* XXX need to broadcast to UIs that plugin has been loaded */
-		break;
-	case CUI_PLUGIN_UNLOAD:
-		memcpy(&id, data, sizeof(id));
-		p = g_list_nth_data(plugins, id);
-		if (p) {
-			unload_plugin(p);
-			/* XXX need to broadcast to UIs that plugin has been unloaded */
-		}
-		break;
-	case CUI_PLUGIN_RELOAD:
-		memcpy(&id, data, sizeof(id));
-		p = g_list_nth_data(plugins, id);
-		if (p) {
-			p = reload_plugin(p);
-			/* XXX need to broadcast to UIs that plugin has been reloaded */
-		}
-		break;
-	default:
-		debug_printf("unhandled plugin subtype %d\n", subtype);
-		break;
-	}
-}