changeset 10005:c892b6dbc341

[gaim-migrate @ 10922] Dear everyone: export CFLAGS=-Wall make 1> /dev/null committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 10 Sep 2004 02:51:22 +0000
parents 690ef036f297
children 9baedaca25c7
files plugins/gaim-remote/remote.c src/account.c src/gaim-remote.c
diffstat 3 files changed, 78 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/gaim-remote/remote.c	Fri Sep 10 02:05:22 2004 +0000
+++ b/plugins/gaim-remote/remote.c	Fri Sep 10 02:51:22 2004 +0000
@@ -36,6 +36,7 @@
 #include "debug.h"
 #include "prpl.h"
 #include "notify.h"
+#include "util.h"
 #include "version.h"
 
 /* XXX */
@@ -374,7 +375,7 @@
 	GaimAccount *account;
 
 	switch (subtype) {
-		/*
+	/*
 	case CUI_USER_LIST:
 		break;
 	case CUI_USER_ADD:
@@ -383,7 +384,8 @@
 		break;
 	case CUI_USER_MODIFY:
 		break;
-		*/
+	*/
+
 	case CUI_USER_SIGNON:
 		if (!data)
 			return;
@@ -393,23 +395,26 @@
 			gaim_account_connect(account);
 		/* don't need to do anything here because the UI will get updates from other handlers */
 		break;
+
 #if 0 /* STATUS */
-       case CUI_USER_AWAY:
-                {
-                    GSList* l;
-                    const char* default_away_name = gaim_prefs_get_string("/core/away/default_message");
+	case CUI_USER_AWAY:
+		{
+			GSList* l;
+			const char* default_away_name = gaim_prefs_get_string("/core/away/default_message");
 
-                    for(l = away_messages; l; l = l->next) {
-                        if(!strcmp(default_away_name, ((struct away_message *)l->data)->name)) {
-                            do_away_message(NULL, l->data);
-                            break;
-                        }
-                    }
-                }
-                break;
-       case CUI_USER_BACK:
-                do_im_back(NULL, NULL);
-                break;
+			for (l = away_messages; l; l = l->next) {
+				if (!strcmp(default_away_name, ((struct away_message *)l->data)->name)) {
+					do_away_message(NULL, l->data);
+					break;
+				}
+			}
+		}
+		break;
+
+	case CUI_USER_BACK:
+		do_im_back(NULL, NULL);
+		break;
+
 #endif /* STATUS */
 	default:
 		gaim_debug_warning("cui", "Unhandled user subtype %d\n", subtype);
@@ -492,7 +497,6 @@
 {
 	const char *resp;
 	char *send;
-
 	GList *c = gaim_connections_get_all();
 	GaimConnection *gc;
 	GaimAccount *account;
@@ -504,51 +508,47 @@
 		if (!data)
 			return;
 		{
-			guint id;
-			GaimConnection *gc;
    			GaimConversation *conv;
-			guint tlen,len,len2,quiet;
+			guint tlen, len, len2, quiet;
 			char *who, *msg;
 			char *tmp, *from, *proto;
-			gint flags;
 			int pos = 0;
-			GList *c = gaim_connections_get_all();
 
 			gaim_debug_info("cui", "Got `gaim-remote send` packet\n",data);
 			gaim_debug_info("cui", "g-r>%s;\n",data);
 
 			tmp = g_strndup(data + pos, 4);
-			tlen=atoi(tmp);
-			pos+=4;
+			tlen = atoi(tmp);
+			pos += 4;
 
-			who=g_strndup(data+pos, tlen);
-			pos+=tlen;
+			who = g_strndup(data+pos, tlen);
+			pos += tlen;
 
 			tmp = g_strndup(data + pos, 4);
-			tlen=atoi(tmp); len=tlen; /*length for 'from' compare*/
-			pos+=4;
+			tlen = atoi(tmp); len=tlen; /* length for 'from' compare */
+			pos += 4;
 
-			from=g_strndup(data+pos, tlen);
-			pos+=tlen;
+			from = g_strndup(data+pos, tlen);
+			pos += tlen;
 
 			tmp = g_strndup(data + pos, 4);
-			tlen=atoi(tmp); len2=tlen; /*length for 'proto' compare*/
-			pos+=4;
+			tlen = atoi(tmp); len2=tlen; /* length for 'proto' compare */
+			pos += 4;
+
+			proto = g_strndup(data+pos, tlen);
+			pos += tlen;
 
-			proto=g_strndup(data+pos, tlen);
-			pos+=tlen;
-			
 			tmp = g_strndup(data + pos, 4);
-			tlen=atoi(tmp);
-			pos+=4;
+			tlen = atoi(tmp);
+			pos += 4;
 
-			msg=g_strndup(data+pos, tlen);
-			pos+=tlen;
+			msg = g_strndup(data+pos, tlen);
+			pos += tlen;
 
 			tmp = g_strndup(data + pos, 1);
-			quiet=atoi(tmp); /*quiet flag - not in use yet*/
+			quiet = atoi(tmp); /* quiet flag - not in use yet */
 
-			/*find acct*/
+			/* find acct */
 	   		while (c) {
 				gc = c->data;
 				account=gaim_connection_get_account(gc);
@@ -558,16 +558,16 @@
 			}
 			if (!gc)
 				return;
-			/*end acct find*/
+			/* end acct find */
 
-			/*gaim_debug_info("cui", "g-r>To: %s; From: %s; Protocol: %s; Message: %s; Quiet: %d\n",who,from,proto,msg,quiet);*/
+			/* gaim_debug_info("cui", "g-r>To: %s; From: %s; Protocol: %s; Message: %s; Quiet: %d\n",who,from,proto,msg,quiet); */
    			conv = gaim_conversation_new(GAIM_CONV_IM, gaim_connection_get_account(gc), who);
    			gaim_conv_im_send(GAIM_CONV_IM(conv), msg);
 
-			/*likely to be used for quiet:
+			/* likely to be used for quiet:
 			serv_send_im(gc, who, msg, -1, 0);
 			*/
-			
+
 			g_free(who);
 			g_free(msg);
 			g_free(from);
@@ -583,6 +583,7 @@
 		g_free(send);
 		/* report error */
 		break;
+
 	default:
 		gaim_debug_warning("cui", "Unhandled remote subtype %d\n", subtype);
 		break;
@@ -593,13 +594,10 @@
 UI_readable(GIOChannel *source, GIOCondition cond, gpointer data)
 {
 	struct UI *ui = data;
-
 	gchar type;
 	gchar subtype;
 	gint len;
-
 	GError *error = NULL;
-
 	gchar *in;
 
 	/* no byte order worries! this'll change if we go to TCP */
@@ -685,10 +683,10 @@
 			chat_handler(ui, subtype, in);
 			break;
 			*/   
-	        case CUI_TYPE_REMOTE:
+		case CUI_TYPE_REMOTE:
 			remote_handler(ui, subtype, in, len);
 			break; 
-        default:
+		default:
 			gaim_debug_warning("cui", "Unhandled type %d\n", type);
 			break;
 	}
@@ -835,9 +833,9 @@
 };
 
 static void
-__init_plugin(GaimPlugin *plugin)
+_init_plugin(GaimPlugin *plugin)
 {
 }
 
 /* This may be horribly wrong. Oh the mayhem! */
-GAIM_INIT_PLUGIN(remote, __init_plugin, info)
+GAIM_INIT_PLUGIN(remote, _init_plugin, info)
--- a/src/account.c	Fri Sep 10 02:05:22 2004 +0000
+++ b/src/account.c	Fri Sep 10 02:51:22 2004 +0000
@@ -520,6 +520,7 @@
 {
 	g_return_if_fail(account != NULL);
 
+	/* Old with the old... */
 	if (account->status_types != NULL)
 	{
 		GList *l;
@@ -530,6 +531,7 @@
 		g_list_free(account->status_types);
 	}
 
+	/* In with the new... */
 	account->status_types = status_types;
 }
 
--- a/src/gaim-remote.c	Fri Sep 10 02:05:22 2004 +0000
+++ b/src/gaim-remote.c	Fri Sep 10 02:51:22 2004 +0000
@@ -27,15 +27,15 @@
 
 #include <gaim-remote/remote.h>
 
-/*To be implemented:
-	     "       info                     Show information about connected accounts\n"
-	     "       list                     Print buddy list\n"
-	     "       ison                     Show presence state of your buddy\n"
-	     "       convo                    Open a new conversation window\n"
-	     "       add                      Add buddy to buddy list\n"
-	     "       remove                   Remove buddy from list\n"
-	     "       -q, --quiet              Send message without showing a conversation\n"
-	     "                                window\n"
+/* To be implemented:
+	"       info                     Show information about connected accounts\n"
+	"       list                     Print buddy list\n"
+	"       ison                     Show presence state of your buddy\n"
+	"       convo                    Open a new conversation window\n"
+	"       add                      Add buddy to buddy list\n"
+	"       remove                   Remove buddy from list\n"
+	"       -q, --quiet              Send message without showing a conversation\n"
+	"                                window\n"
 */
 
 static struct option longopts[] = {
@@ -216,7 +216,7 @@
 send_command_send() {
 	int fd = 0;
 	GaimRemotePacket *p = NULL;
-	char temp[10003]; /*TODO: Future implementation should send packets instead */
+	char temp[10003]; /* TODO: Future implementation should send packets instead */
 
 	fd = gaim_remote_session_connect(0);
 	if (fd < 0) {
@@ -225,16 +225,21 @@
 	}
 	p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_SEND);
 
-	/*Format is as follows:
-	 *Each string has a 4 character 'header' containing the length of the string
-	 *The strings are: To, From, Protocol name, Message
-	 *Following the message is the quiet flag, expressed in a single int (0/1)
-	 *Because the header is 4 characters long, there is a 9999 char limit on any
-	 *given string, though none of these strings should be exceeding this.
-	 *-JBS 
+	/*
+	 * Format is as follows:
+	 * Each string has a 4 character 'header' containing the length of the string
+	 * The strings are: To, From, Protocol name, Message
+	 * Following the message is the quiet flag, expressed in a single int (0/1)
+	 * Because the header is 4 characters long, there is a 9999 char limit on any
+	 * given string, though none of these strings should be exceeding this.
+	 * -JBS 
 	 */
 
-	if(opts.to && *opts.to && opts.from && *opts.from && opts.protocol && *opts.protocol && opts.message && *opts.message  && (strlen(opts.to) <10000) && (strlen(opts.from) <10000) && (strlen(opts.protocol) <20) && (strlen(opts.message) <10000) ){ 
+	if (opts.to && *opts.to && opts.from && *opts.from &&
+		opts.protocol && *opts.protocol && opts.message && *opts.message  &&
+		(strlen(opts.to) < 10000) && (strlen(opts.from) < 10000) &&
+		(strlen(opts.protocol) < 20) && (strlen(opts.message) < 10000) )
+	{
 		sprintf(temp, "%04d%s", strlen(opts.to), opts.to);
 		gaim_remote_packet_append_string(p, temp);
 		sprintf(temp, "%04d%s", strlen(opts.from), opts.from);
@@ -243,20 +248,19 @@
 		gaim_remote_packet_append_string(p, temp);
 		sprintf(temp, "%04d%s", strlen(opts.message), opts.message);
 		gaim_remote_packet_append_string(p, temp);
-		sprintf(temp, "%d", 0);/*quiet flag - off for now*/
+		sprintf(temp, "%d", 0); /* quiet flag - off for now */
 		gaim_remote_packet_append_string(p, temp);
 
 		gaim_remote_session_send_packet (fd, p);
 		close(fd);
 		gaim_remote_packet_free(p);
 		return 0;
-	}else{
+	} else {
 		message(_("Insufficient arguments (-t, -f, -p, & -m are all required) or arguments greater than 9999 chars\n"), 2);
 		close(fd);
 		gaim_remote_packet_free(p);
  		return 1;
  	}
-
 }
 
 static void