changeset 14542:8ed6ef220b2d

[gaim-migrate @ 17263] send_raw() prpl function allows plugins with knowledge of a protocol to send its own custom packets. Not practical for all protocols, but should be super useful on Jabber when coupled with Nathan's signals. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 12 Sep 2006 21:57:15 +0000
parents 33e748a2df15
children ad44ab4442b1
files libgaim/protocols/bonjour/bonjour.c libgaim/protocols/gg/gg.c libgaim/protocols/irc/irc.c libgaim/protocols/jabber/jabber.c libgaim/protocols/msn/msn.c libgaim/protocols/novell/novell.c libgaim/protocols/oscar/oscar.c libgaim/protocols/qq/qq.c libgaim/protocols/sametime/sametime.c libgaim/protocols/silc/silc.c libgaim/protocols/simple/simple.c libgaim/protocols/toc/toc.c libgaim/protocols/yahoo/yahoo.c libgaim/protocols/zephyr/zephyr.c libgaim/prpl.h
diffstat 15 files changed, 51 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/bonjour/bonjour.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/bonjour/bonjour.c	Tue Sep 12 21:57:15 2006 +0000
@@ -414,6 +414,7 @@
 	NULL,                                                    /* new_xfer */
 	NULL,                                                    /* offline_message */
 	NULL,                                                    /* whiteboard_prpl_ops */
+	NULL,							 /* send_raw */
 };
 
 static GaimPluginInfo info =
--- a/libgaim/protocols/gg/gg.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/gg/gg.c	Tue Sep 12 21:57:15 2006 +0000
@@ -2112,6 +2112,7 @@
 	NULL,				/* new_xfer */
 	ggp_offline_message,		/* offline_message */
 	NULL,				/* whiteboard_prpl_ops */
+	NULL,				/* send_raw */
 };
 /* }}} */
 
--- a/libgaim/protocols/irc/irc.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/irc/irc.c	Tue Sep 12 21:57:15 2006 +0000
@@ -99,6 +99,12 @@
 	return ret;
 }
 
+static int irc_send_raw(GaimConnection *gc, const char *buf, int len)
+{
+	struct irc_conn *irc = (struct irc_conn*)gc->proto_data;
+	return do_send(irc, buf, len);
+}
+
 static void
 irc_send_cb(gpointer data, gint source, GaimInputCondition cond)
 {
@@ -860,6 +866,7 @@
 	irc_dccsend_new_xfer,	/* new_xfer */
 	NULL,					/* offline_message */
 	NULL,					/* whiteboard_prpl_ops */
+	irc_send_raw,				/* send_raw */
 };
 
 
--- a/libgaim/protocols/jabber/jabber.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/jabber/jabber.c	Tue Sep 12 21:57:15 2006 +0000
@@ -325,7 +325,14 @@
 		gaim_circ_buffer_append(js->write_buffer,
 			data + ret, len - ret);
 	}
+	return;
+}
 
+int jabber_prpl_send_raw(GaimConnection *gc, const char *buf, int len)
+{
+	JabberStream *js = (JabberStream*)gc->proto_data;
+	jabber_send_raw(js, buf, len);
+	return len;
 }
 
 void jabber_send(JabberStream *js, xmlnode *packet)
@@ -1884,6 +1891,7 @@
 	jabber_si_new_xfer,				/* new_xfer */
 	jabber_offline_message,			/* offline_message */
 	NULL,							/* whiteboard_prpl_ops */
+	jabber_send_raw,			/* send_raw */
 };
 
 static gboolean load_plugin(GaimPlugin *plugin)
--- a/libgaim/protocols/msn/msn.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/msn/msn.c	Tue Sep 12 21:57:15 2006 +0000
@@ -881,6 +881,14 @@
 	return MSN_TYPING_SEND_TIMEOUT;
 }
 
+static int 
+msn_send_raw(GaimConnection *gc, const char *buf, int len)
+{
+	MsnServConn *servconn = (MsnServConn*)gc->proto_data;
+	return msn_servconn_write(servconn, buf, len);
+}
+	
+
 static void
 msn_set_status(GaimAccount *account, GaimStatus *status)
 {
@@ -2012,6 +2020,7 @@
 	msn_new_xfer,			/* new_xfer */
 	NULL,					/* offline_message */
 	NULL,					/* whiteboard_prpl_ops */
+	msn_send_raw,				/* send_raw */
 };
 
 static GaimPluginInfo info =
--- a/libgaim/protocols/novell/novell.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/novell/novell.c	Tue Sep 12 21:57:15 2006 +0000
@@ -3529,6 +3529,7 @@
 	NULL,						/* new_xfer */
 	NULL,						/* offline_message */
 	NULL,						/* whiteboard_prpl_ops */
+	NULL,						/* send_raw */
 };
 
 static GaimPluginInfo info = {
--- a/libgaim/protocols/oscar/oscar.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/oscar/oscar.c	Tue Sep 12 21:57:15 2006 +0000
@@ -6485,6 +6485,7 @@
 	oscar_new_xfer,			/* new_xfer */
 	oscar_offline_message,	/* offline_message */
 	NULL,					/* whiteboard_prpl_ops */
+	NULL,				/* send_raw */
 };
 
 static GaimPluginInfo info =
--- a/libgaim/protocols/qq/qq.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/qq/qq.c	Tue Sep 12 21:57:15 2006 +0000
@@ -993,6 +993,7 @@
 	NULL,                           /* new xfer */
 	NULL,				/* offline_message */
 	NULL,				/* GaimWhiteboardPrplOps */
+	NULL,				/* send_raw */
 };
 
 static GaimPluginInfo info = {
--- a/libgaim/protocols/sametime/sametime.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/sametime/sametime.c	Tue Sep 12 21:57:15 2006 +0000
@@ -5063,6 +5063,7 @@
   .new_xfer                  = mw_prpl_new_xfer,
   .offline_message           = NULL,
   .whiteboard_prpl_ops       = NULL,
+  .send_raw                  = NULL
 };
 
 
--- a/libgaim/protocols/silc/silc.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/silc/silc.c	Tue Sep 12 21:57:15 2006 +0000
@@ -1802,6 +1802,7 @@
 	silcgaim_ftp_new_xfer,		/* new_xfer */
 	NULL,						/* offline_message */
 	&silcgaim_wb_ops,			/* whiteboard_prpl_ops */
+	NULL,					/* send_raw */
 };
 
 static GaimPluginInfo info =
--- a/libgaim/protocols/simple/simple.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/simple/simple.c	Tue Sep 12 21:57:15 2006 +0000
@@ -521,6 +521,12 @@
 	}
 }
 
+static void simple_send_raw(GaimConnection *gc, const char *buf, int len)
+{
+	sendout_pkt(gc, buf);
+	return len;
+}
+
 static void sendout_sipmsg(struct simple_account_data *sip, struct sipmsg *msg) {
 	GSList *tmp = msg->headers;
 	gchar *name;
@@ -1792,6 +1798,7 @@
 	NULL,					/* new_xfer */
 	NULL,					/* offline_message */
 	NULL,					/* whiteboard_prpl_ops */
+	simple_send_raw,			/* send_raw */
 };
 
 
--- a/libgaim/protocols/toc/toc.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/toc/toc.c	Tue Sep 12 21:57:15 2006 +0000
@@ -414,6 +414,11 @@
 	return ret;
 }
 
+static int toc_send_raw(GaimConnection *gc, const char *buf, int len)
+{
+	return sflap_send(gc, buf, len, 2);
+}
+
 static int wait_reply(GaimConnection *gc, char *buffer, size_t buflen)
 {
 	struct toc_data *tdt = (struct toc_data *)gc->proto_data;
@@ -2068,7 +2073,7 @@
 	hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2';
 	hdr->hdrlen = htons(256);
 	hdr->hdrtype = htons(0x1108);
-	frombase64(ft->cookie, &buf, NULL);
+	rombase64(ft->cookie, &buf, NULL);
 	g_snprintf(hdr->bcookie, 8, "%s", buf);
 	g_free(buf);
 	hdr->totfiles = htons(1); hdr->filesleft = htons(1);
@@ -2300,6 +2305,7 @@
 	NULL,					/* new_xfer */
 	NULL,					/* offline_message */
 	NULL,					/* whiteboard_prpl_ops */
+	toc_send_raw,				/* send_raw */
 };
 
 static GaimPluginInfo info =
--- a/libgaim/protocols/yahoo/yahoo.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo.c	Tue Sep 12 21:57:15 2006 +0000
@@ -3863,6 +3863,7 @@
 	yahoo_new_xfer,
 	yahoo_offline_message, /* offline_message */
 	&yahoo_whiteboard_prpl_ops,
+	NULL /* send_raw */
 };
 
 static GaimPluginInfo info =
--- a/libgaim/protocols/zephyr/zephyr.c	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/protocols/zephyr/zephyr.c	Tue Sep 12 21:57:15 2006 +0000
@@ -2915,6 +2915,7 @@
 	NULL,					/* new_xfer */
 	NULL,					/* offline_message */
 	NULL,					/* whiteboard_prpl_ops */
+	NULL,					/* send_raw */
 };
 
 static GaimPluginInfo info = {
@@ -2944,7 +2945,7 @@
 	NULL,						  /**< ui_info	      */
 	&prpl_info,					  /**< extra_info     */
 	NULL,
-	zephyr_actions
+	zephyr_actions,
 };
 
 static void init_plugin(GaimPlugin * plugin)
--- a/libgaim/prpl.h	Tue Sep 12 20:11:56 2006 +0000
+++ b/libgaim/prpl.h	Tue Sep 12 21:57:15 2006 +0000
@@ -298,6 +298,9 @@
 	gboolean (*offline_message)(const GaimBuddy *buddy);
 
 	GaimWhiteboardPrplOps *whiteboard_prpl_ops;
+
+	/* For use in plugins that may understand the underlying protocol */
+	int (*send_raw)(GaimConnection *gc, const char *buf, int len);
 };
 
 #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \