changeset 1409:17e544f8c7fb

[gaim-migrate @ 1419] no more hanging trees. also libyahoo updates. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 16 Jan 2001 02:02:32 +0000
parents 815e3000467e
children 6b083d580184
files Makefile.am plugins/yay/libyahoo-proto.h plugins/yay/libyahoo.c src/aim.c src/buddy.c
diffstat 5 files changed, 95 insertions(+), 127 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Mon Jan 15 23:47:55 2001 +0000
+++ b/Makefile.am	Tue Jan 16 02:02:32 2001 +0000
@@ -1,6 +1,6 @@
 
 EXTRA_DIST = gaim.spec.in gaim_applet.gnorba gaim.desktop gaim_applet.desktop \
-	buddytrans buddytrans2 README.plugins HACKING
+	README.plugins HACKING STATUS
 
 if GNOMEAPPLET
 
--- a/plugins/yay/libyahoo-proto.h	Mon Jan 15 23:47:55 2001 +0000
+++ b/plugins/yay/libyahoo-proto.h	Tue Jan 16 02:02:32 2001 +0000
@@ -8,93 +8,57 @@
 #define CFH_LIBYAHOO_PROTO
 
 unsigned int yahoo_makeint(unsigned char *data);
-char **yahoo_list2array(char *buff);
+char **yahoo_list2array(const char *buff);
 void yahoo_arraykill(char **array);
 char *yahoo_array2list(char **array);
-struct yahoo_context *yahoo_init(char *user, char *password,
-
-	struct yahoo_options *options);
+struct yahoo_context *yahoo_init(const char *user, const char *password, struct yahoo_options *options);
 void yahoo_free_context(struct yahoo_context *ctx);
 char *yahoo_get_status_string(int statuscode);
 char *yahoo_get_status_append(int statuscode);
 char *yahoo_get_service_string(int servicecode);
 int yahoo_fetchcookies(struct yahoo_context *ctx);
-int yahoo_add_buddy(struct yahoo_context *ctx, char *addid, char *active_id,
-	char *group, char *msg);
-int yahoo_remove_buddy(struct yahoo_context *ctx, char *addid,
-	char *active_id, char *group, char *msg);
+int yahoo_add_buddy(struct yahoo_context *ctx, const char *addid, const char *active_id, const char *group, const char *msg);
+int yahoo_remove_buddy(struct yahoo_context *ctx, const char *addid, const char *active_id, const char *group, const char *msg);
 int yahoo_get_config(struct yahoo_context *ctx);
 int yahoo_cmd_logon(struct yahoo_context *ctx, unsigned int initial_status);
 int yahoo_connect(struct yahoo_context *ctx);
-int yahoo_sendcmd_http(struct yahoo_context *ctx,
-
-	struct yahoo_rawpacket *pkt);
-int yahoo_sendcmd(struct yahoo_context *ctx, int service, char *active_nick,
-	char *content, unsigned int msgtype);
+int yahoo_sendcmd_http(struct yahoo_context *ctx, struct yahoo_rawpacket *pkt);
+int yahoo_sendcmd(struct yahoo_context *ctx, int service, const char *active_nick, const char *content, unsigned int msgtype);
 int yahoo_cmd_ping(struct yahoo_context *ctx);
 int yahoo_cmd_idle(struct yahoo_context *ctx);
-int yahoo_cmd_sendfile(struct yahoo_context *ctx, char *active_user,
-	char *touser, char *msg, char *filename);
-int yahoo_cmd_msg(struct yahoo_context *ctx, char *active_user, char *touser,
-
-	char *msg);
-int yahoo_cmd_msg_offline(struct yahoo_context *ctx, char *active_user,
-	char *touser, char *msg);
-int yahoo_cmd_set_away_mode(struct yahoo_context *ctx, int status, char *msg);
-int yahoo_cmd_set_back_mode(struct yahoo_context *ctx, int status, char *msg);
-int yahoo_cmd_activate_id(struct yahoo_context *ctx, char *newid);
+int yahoo_cmd_sendfile(struct yahoo_context *ctx, const char *active_user, const char *touser, const char *msg, const char *filename);
+int yahoo_cmd_msg(struct yahoo_context *ctx, const char *active_user, const char *touser, const char *msg);
+int yahoo_cmd_msg_offline(struct yahoo_context *ctx, const char *active_user, const char *touser, const char *msg);
+int yahoo_cmd_set_away_mode(struct yahoo_context *ctx, int status, const char *msg);
+int yahoo_cmd_set_back_mode(struct yahoo_context *ctx, int status, const char *msg);
+int yahoo_cmd_activate_id(struct yahoo_context *ctx, const char *newid);
 int yahoo_cmd_user_status(struct yahoo_context *ctx);
 int yahoo_cmd_logoff(struct yahoo_context *ctx);
-int yahoo_cmd_start_conf(struct yahoo_context *ctx, char *conf_id,
-	char **userlist, char *msg, int type);
-int yahoo_cmd_conf_logon(struct yahoo_context *ctx, char *conf_id,
-
-	char *host, char **userlist);
-int yahoo_cmd_decline_conf(struct yahoo_context *ctx, char *conf_id,
-	char *host, char **userlist, char *msg);
-int yahoo_cmd_conf_logoff(struct yahoo_context *ctx, char *conf_id,
-
-	char **userlist);
-int yahoo_cmd_conf_invite(struct yahoo_context *ctx, char *conf_id,
-	char **userlist, char *invited_user, char *msg);
-int yahoo_cmd_conf_msg(struct yahoo_context *ctx, char *conf_id,
-	char **userlist, char *msg);
+int yahoo_cmd_start_conf(struct yahoo_context *ctx, const char *conf_id, char **userlist, const char *msg, int type);
+int yahoo_cmd_conf_logon(struct yahoo_context *ctx, const char *conf_id, const char *host, char **userlist);
+int yahoo_cmd_decline_conf(struct yahoo_context *ctx, const char *conf_id, const char *host, char **userlist, const char *msg);
+int yahoo_cmd_conf_logoff(struct yahoo_context *ctx, const char *conf_id, char **userlist);
+int yahoo_cmd_conf_invite(struct yahoo_context *ctx, const char *conf_id, char **userlist, const char *invited_user, const char *msg);
+int yahoo_cmd_conf_msg(struct yahoo_context *ctx, const char *conf_id, char **userlist, const char *msg);
 void yahoo_free_rawpacket(struct yahoo_rawpacket *pkt);
 void yahoo_free_packet(struct yahoo_packet *pkt);
 void yahoo_free_idstatus(struct yahoo_idstatus *idstatus);
-struct yahoo_packet *yahoo_parsepacket(struct yahoo_context *ctx,
-
-	struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_ping(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_newmail(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_grouprename(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_conference_invite(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_conference_decline(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_conference_addinvite(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_conference_msg(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_conference_user(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_filetransfer(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_calendar(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_chatinvite(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_newcontact(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_status(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_message(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
-int yahoo_parsepacket_message_offline(struct yahoo_context *ctx,
-	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+struct yahoo_packet *yahoo_parsepacket(struct yahoo_context *ctx, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_ping(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_newmail(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_grouprename(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_conference_invite(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_conference_decline(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_conference_addinvite(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_conference_msg(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_conference_user(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_filetransfer(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_calendar(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_chatinvite(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_newcontact(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_status(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_message(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
+int yahoo_parsepacket_message_offline(struct yahoo_context *ctx, struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt);
 int yahoo_getdata(struct yahoo_context *ctx);
 struct yahoo_rawpacket *yahoo_getpacket(struct yahoo_context *ctx);
 int yahoo_isbuddy(struct yahoo_context *ctx, const char *id);
--- a/plugins/yay/libyahoo.c	Mon Jan 15 23:47:55 2001 +0000
+++ b/plugins/yay/libyahoo.c	Tue Jan 16 02:02:32 2001 +0000
@@ -269,7 +269,7 @@
 
    allocates a string in here -- caller needs to free it
  */
-char **yahoo_list2array(char *buff)
+char **yahoo_list2array(const char *buff)
 {
 	char **tmp_array = NULL;
 	char *array_elem = NULL;
@@ -480,7 +480,7 @@
 }
 
 #if 0							/* not used at the moment */
-static void yahoo_hexdump(char *label, unsigned char *data, int datalen)
+static void yahoo_hexdump(const char *label, const unsigned char *data, int datalen)
 {
 	int i, j;
 	int val, skipped_last;
@@ -582,7 +582,7 @@
 }
 #endif
 
-static int yahoo_socket_connect(struct yahoo_context *ctx, char *host,
+static int yahoo_socket_connect(struct yahoo_context *ctx, const char *host,
 	int port)
 {
 	struct sockaddr_in serv_addr;
@@ -674,7 +674,7 @@
  */
 
 
-static char *yahoo_urlencode(char *instr)
+static char *yahoo_urlencode(const char *instr)
 {
 	register int ipos, bpos; //input str pos., buffer pos.
 	static unsigned char *str=NULL;
@@ -728,7 +728,7 @@
 }
 
 
-static int yahoo_addtobuffer(struct yahoo_context *ctx, char *data,
+static int yahoo_addtobuffer(struct yahoo_context *ctx, const char *data,
 	int datalen)
 {
 	//yahoo_hexdump("yahoo_addtobuffer", data, datalen);
@@ -807,7 +807,7 @@
 
 /* Initialize interface to yahoo library, sortof like a class object
    creation routine. */
-struct yahoo_context *yahoo_init(char *user, char *password,
+struct yahoo_context *yahoo_init(const char *user, const char *password,
 	struct yahoo_options *options)
 {
 	struct yahoo_context *tmp;
@@ -1070,8 +1070,8 @@
 }
 
 /* Add a buddy to your buddy list */
-int yahoo_add_buddy(struct yahoo_context *ctx, char *addid,
-	char *active_id, char *group, char *msg)
+int yahoo_add_buddy(struct yahoo_context *ctx, const char *addid,
+	const char *active_id, const char *group, const char *msg)
 {
 	char buffer[5000];
 	int servfd;
@@ -1143,8 +1143,8 @@
 }
 
 /* Remove a buddy from your buddy list */
-int yahoo_remove_buddy(struct yahoo_context *ctx, char *addid,
-	char *active_id, char *group, char *msg)
+int yahoo_remove_buddy(struct yahoo_context *ctx, const char *addid,
+	const char *active_id, const char *group, const char *msg)
 {
 	char buffer[5000];
 	int servfd;
@@ -1621,8 +1621,8 @@
 
 /* Send a packet to the server, called by all routines that want to issue
    a command. */
-int yahoo_sendcmd(struct yahoo_context *ctx, int service, char *active_nick,
-	char *content, unsigned int msgtype)
+int yahoo_sendcmd(struct yahoo_context *ctx, int service, const char *active_nick,
+	const char *content, unsigned int msgtype)
 {
 	int size;
 	struct yahoo_rawpacket *pkt;
@@ -1691,15 +1691,15 @@
 	return yahoo_sendcmd(ctx, YAHOO_SERVICE_IDLE, ctx->user, "", 0);
 }
 
-int yahoo_cmd_sendfile(struct yahoo_context *ctx, char *active_user,
-	char *touser, char *msg, char *filename)
+int yahoo_cmd_sendfile(struct yahoo_context *ctx, const char *active_user,
+	const char *touser, const char *msg, const char *filename)
 {
 	yahoo_dbg_Print("libyahoo", "yahoo_cmd_sendfile not implemented yet!");
 	return (0);
 }
 
-int yahoo_cmd_msg(struct yahoo_context *ctx, char *active_user,
-	char *touser, char *msg)
+int yahoo_cmd_msg(struct yahoo_context *ctx, const char *active_user,
+	const char *touser, const char *msg)
 {
 	char *content;
 
@@ -1720,8 +1720,8 @@
 	return (1);
 }
 
-int yahoo_cmd_msg_offline(struct yahoo_context *ctx, char *active_user,
-	char *touser, char *msg)
+int yahoo_cmd_msg_offline(struct yahoo_context *ctx, const char *active_user,
+	const char *touser, const char *msg)
 {
 	char *content;
 
@@ -1744,7 +1744,7 @@
 }
 
 /* appended the " " so that won't trigger yahoo bug - hack for the moment */
-int yahoo_cmd_set_away_mode(struct yahoo_context *ctx, int status, char *msg)
+int yahoo_cmd_set_away_mode(struct yahoo_context *ctx, int status, const char *msg)
 {
 	char statusstring[500];
 
@@ -1770,7 +1770,7 @@
 	return yahoo_sendcmd(ctx, YAHOO_SERVICE_ISAWAY, ctx->user, statusstring, 0);
 }
 
-int yahoo_cmd_set_back_mode(struct yahoo_context *ctx, int status, char *msg)
+int yahoo_cmd_set_back_mode(struct yahoo_context *ctx, int status, const char *msg)
 {
 	char statusstring[500];
 
@@ -1782,7 +1782,7 @@
 	return yahoo_sendcmd(ctx, YAHOO_SERVICE_ISBACK, ctx->user, statusstring, 0);
 }
 
-int yahoo_cmd_activate_id(struct yahoo_context *ctx, char *newid)
+int yahoo_cmd_activate_id(struct yahoo_context *ctx, const char *newid)
 {
 	if (strlen(newid))
 		return yahoo_sendcmd(ctx, YAHOO_SERVICE_IDACT, newid, newid, 0);
@@ -1817,8 +1817,8 @@
 Packet format:
    id^invited-users^msg^0or1
 */
-int yahoo_cmd_start_conf(struct yahoo_context *ctx, char *conf_id,
-	char **userlist, char *msg, int type)
+int yahoo_cmd_start_conf(struct yahoo_context *ctx, const char *conf_id,
+	char **userlist, const char *msg, int type)
 {
 	char ctrlb = 2;
 	char *content;
@@ -1877,8 +1877,8 @@
    id^all-invited-users-and-host
 
 */
-int yahoo_cmd_conf_logon(struct yahoo_context *ctx, char *conf_id,
-	char *host, char **userlist)
+int yahoo_cmd_conf_logon(struct yahoo_context *ctx, const char *conf_id,
+	const char *host, char **userlist)
 {
 	char ctrlb = 2;
 	char *content;
@@ -1938,8 +1938,8 @@
    id^all-invited-users-and-host^msg
 
 */
-int yahoo_cmd_decline_conf(struct yahoo_context *ctx, char *conf_id,
-	char *host, char **userlist, char *msg)
+int yahoo_cmd_decline_conf(struct yahoo_context *ctx, const char *conf_id,
+	const char *host, char **userlist, const char *msg)
 {
 	char ctrlb = 2;
 	char *content;
@@ -1988,7 +1988,7 @@
 
 */
 
-int yahoo_cmd_conf_logoff(struct yahoo_context *ctx, char *conf_id,
+int yahoo_cmd_conf_logoff(struct yahoo_context *ctx, const char *conf_id,
 	char **userlist)
 {
 	char ctrlb = 2;
@@ -2048,8 +2048,8 @@
 
 */
 
-int yahoo_cmd_conf_invite(struct yahoo_context *ctx, char *conf_id,
-	char **userlist, char *invited_user, char *msg)
+int yahoo_cmd_conf_invite(struct yahoo_context *ctx, const char *conf_id,
+	char **userlist, const char *invited_user, const char *msg)
 {
 	char ctrlb = 2;
 	char *content;
@@ -2097,8 +2097,8 @@
    id^all-invited-users^msg
 
 */
-int yahoo_cmd_conf_msg(struct yahoo_context *ctx, char *conf_id,
-	char **userlist, char *msg)
+int yahoo_cmd_conf_msg(struct yahoo_context *ctx, const char *conf_id,
+	char **userlist, const char *msg)
 {
 	char ctrlb = 2;
 	char *content;
@@ -2731,10 +2731,11 @@
 	struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
 {
 	char *content;
-	char *tmp, delim[5];
+	char *tmp = NULL;
+        size_t found = 0, len = yahoo_makeint(inpkt->len);
 
 	/* Make working copy of content */
-	content = strdup(inpkt->content);
+	content = memdup(inpkt->content, len);
 
 	/* init elements to all null */
 	pkt->conf_id = NULL;
@@ -2744,25 +2745,32 @@
 	pkt->conf_inviter = NULL;
 	pkt->conf_msg = NULL;
 
-	tmp = NULL;
-	delim[0] = 2;				/* control-b */
-	delim[1] = 0;
-
 	if (content)
 	{
-		tmp = strtok(content, delim);
+		tmp = memtok(content, len, "\002", 2, &found);
 	}
 
 	if (tmp)					/* got the conference id */
 	{
-		pkt->conf_id = strdup(tmp);
-		tmp = strtok(NULL, delim);
+		pkt->conf_id = memdupasstr(tmp, found);
+		tmp = memtok(0, 0, "\002", 2, &found);
 	}
 
-	if (tmp)					/* conference user */
+	if (tmp)					
 	{
-		pkt->conf_user = strdup(tmp);
-		tmp = strtok(NULL, delim);
+                if ( pkt->msgtype == 1 )                 /* conference user */
+                {
+                        pkt->conf_user = memdupasstr(tmp, found);
+                        tmp = memtok(0, 0, "\002", 2, &found);
+                }
+                else if ( pkt->msgtype == 0 )        /* conference userlist? */
+                {
+                        char *userlist = memdupasstr(tmp, found);
+                        
+                        pkt->conf_userlist = yahoo_list2array(userlist);
+                        tmp = memtok(0, 0, "\002", 2, &found);
+                        FREE(userlist);
+                }
 	}
 
 	FREE(content);
--- a/src/aim.c	Mon Jan 15 23:47:55 2001 +0000
+++ b/src/aim.c	Tue Jan 16 02:02:32 2001 +0000
@@ -197,7 +197,7 @@
 	struct aim_user *u;
 
 	if (!usr)
-		return g_list_append(NULL, "<unknown>");
+		return g_list_append(NULL, "<New User>");
 
 	while (usr) {
 		u = (struct aim_user *)usr->data;
--- a/src/buddy.c	Mon Jan 15 23:47:55 2001 +0000
+++ b/src/buddy.c	Tue Jan 16 02:02:32 2001 +0000
@@ -1640,11 +1640,6 @@
 	gtk_container_add(GTK_CONTAINER(g->item), g->label);
 	gtk_widget_show(g->label);
 
-	g->tree = gtk_tree_new();
-	gtk_tree_item_set_subtree(GTK_TREE_ITEM(g->item), g->tree);
-	gtk_tree_item_expand(GTK_TREE_ITEM(g->item));
-	gtk_widget_show(g->tree);
-
 	shows = g_slist_insert(shows, g, pos);
 	update_num_groups(g);
 	return g;
@@ -1658,6 +1653,13 @@
 	int pos = buddy_number(gs->name, buddy->name);
 	b->sound = 0;
 
+	if (gs->members == NULL) {
+		gs->tree = gtk_tree_new();
+		gtk_tree_item_set_subtree(GTK_TREE_ITEM(gs->item), gs->tree);
+		gtk_tree_item_expand(GTK_TREE_ITEM(gs->item));
+		gtk_widget_show(gs->tree);
+	}
+
 	b->name = g_strdup(buddy->name);
 	b->show = g_strdup(buddy->show);
 
@@ -1703,12 +1705,6 @@
 	 * and is a valid tree afterwards. Otherwise, Bad Things will happen. */
 	gtk_tree_remove_item(GTK_TREE(gs->tree), bs->item);
 	bs->item = NULL;
-	if (gs->members == NULL) {
-		gs->tree = gtk_tree_new();
-		gtk_tree_item_set_subtree(GTK_TREE_ITEM(gs->item), gs->tree);
-		gtk_tree_item_expand(GTK_TREE_ITEM(gs->item));
-		gtk_widget_show(gs->tree);
-	}
 }
 
 static struct group_show *find_gs_by_bs(struct buddy_show *b) {