annotate plugins/yay/libyahoo.c @ 1116:35476475f794

[gaim-migrate @ 1126] always force update; it won't be called unless if one is needed. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 21 Nov 2000 01:11:27 +0000
parents 4416ead31db7
children 903a6d0938c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 Yahoo Pager Client Library
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 This code is based on code by Douglas Winslow. The original info from
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 his code is listed below. This code has taken his code and has been
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 altered to my naming and coding conventions and has been made more
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 usable as a library of routines.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 -- Nathan Neulinger <nneul@umr.edu>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 Yahoo Pager Client Emulator Pro - yppro.c
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 A basic reference implementation
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 Douglas Winslow <douglas@min.net>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 Tue Sep 1 02:28:21 EDT 1998
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 Version 2, Revision 2
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 Known to compile on Linux 2.0, FreeBSD 2.2, and BSDi 3.0.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 hi to aap bdc drw jfn jrc mm mcd [cejn]b #cz and rootshell
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 Finally!
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 Yahoo finally patched their server-side, and things will be getting
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 back to "normal". I will continue to maintain this code as long as
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 there is interest for it. Since Yahoo will be discontinuing YPNS1.1
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 login support shortly, I've upgraded this client to do YPNS1.2. You
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 *must* have a password to pass authentication to the pager server.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 This authentication is done by a weird HTTP cookie method.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 This code is distributed under the GNU General Public License (GPL)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include "config.h"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <stdio.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <netdb.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <fcntl.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <errno.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include <sys/socket.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include <netinet/in.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #if defined(WITH_GTK)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include <gtk/gtk.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #include <unistd.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #if defined(HAVE_STRINGS_H)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include <strings.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #if defined(HAVE_STRING_H)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include <string.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #include <ctype.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #include "libyahoo.h"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #ifdef HAVE_DMALLOC
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #include "dmalloc.h"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #include <stdlib.h>
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #include "memtok.h"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 /* allow libyahoo to be used without gtkyahoo's debug support */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 #ifdef ENABLE_LIBYAHOO_DEBUG
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 #include "libyahoo-debug.h"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 static void yahoo_dbg_Print(char *tmp, ...)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 #define yahoo_dbg_NullCheck(x) ((x)?(x):("[NULL]"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 /* remap functions to gtk versions */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 #if defined(WITH_GTK)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 #define malloc g_malloc
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 #define free g_free
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 #define calloc(x,y) g_malloc0((x)*(y))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 #if (!defined(TRUE) || !defined(FALSE))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 # define TRUE 1
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 # define FALSE 0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 /* Define a quick shortcut function to free a pointer and set it to null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 #define FREE(x) if (x) { free(x); x=NULL; }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 #if defined(WITH_SOCKS4)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 void SOCKSinit(char *argv0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 /* pager server host */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 #define YAHOO_PAGER_HOST "cs.yahoo.com"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 #define YAHOO_PAGER_PORT 5050
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 /* pager server host for http connections */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 #define YAHOO_PAGER_HTTP_HOST "http.pager.yahoo.com"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 #define YAHOO_PAGER_HTTP_PORT 80
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 /* authentication/login host */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 #define YAHOO_AUTH_HOST "msg.edit.yahoo.com"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 #define YAHOO_AUTH_PORT 80
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 /* buddy/identity/config host */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 #define YAHOO_DATA_HOST YAHOO_AUTH_HOST
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 #define YAHOO_DATA_PORT 80
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 /* Address book host */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 #define YAHOO_ADDRESS_HOST "uk.address.yahoo.com"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 #define YAHOO_ADDRESS_PORT 80
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 /* User agent to use for HTTP connections */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 /* It needs to have Mozilla/4 in it, otherwise it fails */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 #ifndef VERSION
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 #define VERSION "1.0"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 #define YAHOO_USER_AGENT "Mozilla/4.6 (libyahoo/" VERSION ")"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 #define YAHOO_PROTOCOL_HEADER "YPNS2.0"
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 * Routines and data private to this library, should not be directly
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 * accessed outside of these routines.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 /* Service code labels for debugging output */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 static struct yahoo_idlabel yahoo_service_codes[] = {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 {YAHOO_SERVICE_LOGON, "Pager Logon"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 {YAHOO_SERVICE_LOGOFF, "Pager Logoff"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 {YAHOO_SERVICE_ISAWAY, "Is Away"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 {YAHOO_SERVICE_ISBACK, "Is Back"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 {YAHOO_SERVICE_IDLE, "Idle"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 {YAHOO_SERVICE_MESSAGE, "Message"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 {YAHOO_SERVICE_IDACT, "Activate Identity"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 {YAHOO_SERVICE_IDDEACT, "Deactivate Identity"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 {YAHOO_SERVICE_MAILSTAT, "Mail Status"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 {YAHOO_SERVICE_USERSTAT, "User Status"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 {YAHOO_SERVICE_NEWMAIL, "New Mail"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 {YAHOO_SERVICE_CHATINVITE, "Chat Invitation"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 {YAHOO_SERVICE_CALENDAR, "Calendar Reminder"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 {YAHOO_SERVICE_NEWPERSONALMAIL, "New Personals Mail"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 {YAHOO_SERVICE_NEWCONTACT, "New Friend"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 {YAHOO_SERVICE_GROUPRENAME, "Group Renamed"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 {YAHOO_SERVICE_ADDIDENT, "Add Identity"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 {YAHOO_SERVICE_ADDIGNORE, "Add Ignore"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 {YAHOO_SERVICE_PING, "Ping"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 {YAHOO_SERVICE_SYSMESSAGE, "System Message"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 {YAHOO_SERVICE_CONFINVITE, "Conference Invitation"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 {YAHOO_SERVICE_CONFLOGON, "Conference Logon"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 {YAHOO_SERVICE_CONFDECLINE, "Conference Decline"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 {YAHOO_SERVICE_CONFLOGOFF, "Conference Logoff"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 {YAHOO_SERVICE_CONFMSG, "Conference Message"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 {YAHOO_SERVICE_CONFADDINVITE, "Conference Additional Invitation"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 {YAHOO_SERVICE_CHATLOGON, "Chat Logon"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 {YAHOO_SERVICE_CHATLOGOFF, "Chat Logoff"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 {YAHOO_SERVICE_CHATMSG, "Chat Message"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 {YAHOO_SERVICE_GAMELOGON, "Game Logon"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 {YAHOO_SERVICE_GAMELOGOFF, "Game Logoff"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 {YAHOO_SERVICE_FILETRANSFER, "File Transfer"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 {YAHOO_SERVICE_PASSTHROUGH2, "Passthrough 2"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 {0, NULL}
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 };
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 /* Status codes */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 static struct yahoo_idlabel yahoo_status_codes[] = {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 {YAHOO_STATUS_AVAILABLE, "I'm Available"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 {YAHOO_STATUS_BRB, "Be Right Back"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 {YAHOO_STATUS_BUSY, "Busy"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 {YAHOO_STATUS_NOTATHOME, "Not at Home"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 {YAHOO_STATUS_NOTATDESK, "Not at my Desk"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 {YAHOO_STATUS_NOTINOFFICE, "Not in the Office"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 {YAHOO_STATUS_ONPHONE, "On the Phone"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 {YAHOO_STATUS_ONVACATION, "On Vacation"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 {YAHOO_STATUS_OUTTOLUNCH, "Out to Lunch"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 {YAHOO_STATUS_STEPPEDOUT, "Stepped Out"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 {YAHOO_STATUS_INVISIBLE, "Invisible"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 {YAHOO_STATUS_IDLE, "Idle"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 {YAHOO_STATUS_CUSTOM, "Custom Message"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 {0, NULL}
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 };
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 /* Status codes */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 static struct yahoo_idlabel yahoo_status_append[] = {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 {YAHOO_STATUS_AVAILABLE, "is now available"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 {YAHOO_STATUS_BRB, "will be right back"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 {YAHOO_STATUS_BUSY, "is now busy"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 {YAHOO_STATUS_NOTATHOME, "is not at home"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 {YAHOO_STATUS_NOTATDESK, "is not at their desk"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 {YAHOO_STATUS_NOTINOFFICE, "is not in the office"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 {YAHOO_STATUS_ONPHONE, "is on the phone"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 {YAHOO_STATUS_ONVACATION, "is on vacation"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 {YAHOO_STATUS_OUTTOLUNCH, "is out to lunch"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 {YAHOO_STATUS_STEPPEDOUT, "has stepped out"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 {YAHOO_STATUS_INVISIBLE, "is now invisible"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 {YAHOO_STATUS_IDLE, "is now idle"},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 {YAHOO_STATUS_CUSTOM, ""},
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 {0, NULL}
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 };
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
193 static int readall(int fd, void *buf, size_t count)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
194 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
195 int left, ret, cur = 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
196
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
197 left = count;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
198
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
199 while (left) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
200 ret = read(fd, ((unsigned char *)buf)+cur, left);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
201 if ((ret == -1) && (errno != EINTR)) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
202 return -1;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
203 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
204 if (ret == 0)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
205 return cur;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
206
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
207 if (ret != -1) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
208 cur += ret;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
209 left -= ret;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
210 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
211 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
212 return cur;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
213 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
214
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
215 static int writeall(int fd, void *buf, size_t count)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
216 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
217 int left, ret, cur = 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
218
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
219 left = count;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
220
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
221 while (left) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
222 ret = write(fd, ((unsigned char *)buf)+cur, left);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
223 if ((ret == -1) && (errno != EINTR)) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
224 return -1;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
225 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
226 if (ret == 0)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
227 return cur;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
228 if (ret != -1) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
229 cur += ret;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
230 left -= ret;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
231 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
232 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
233
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
234 return cur;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
235 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
236
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 /* Take a 4-byte character string in little-endian format and return
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 a unsigned integer */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 unsigned int yahoo_makeint(unsigned char *data)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 if (data)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 return ((data[3] << 24) + (data[2] << 16) + (data[1] << 8) +
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 (data[0]));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 /* Take an integer and store it into a 4 character little-endian string */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 static void yahoo_storeint(unsigned char *data, unsigned int val)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 unsigned int tmp = val;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
255 if (!data)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
256 return;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
257
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
258 for (i = 0; i < 4; i++)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
259 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
260 data[i] = tmp % 256;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
261 tmp >>= 8;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
262 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 converts a comma seperated list to an array of strings
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 used primarily in conference code
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 allocates a string in here -- caller needs to free it
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 char **yahoo_list2array(char *buff)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 char **tmp_array = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 char *array_elem = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 char *tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 char *buffer = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 char *ptr_buffer = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 int sublen = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 int cnt = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 int nxtelem = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 unsigned int i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 unsigned int len = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 if (0 == buff)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
289 if (!(ptr_buffer = buffer = strdup(buff))) /* play with a copy */
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
290 return NULL;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 /* count the number of users (commas + 1) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 for (i = 0; i < strlen(buffer); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 if (buffer[i] == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 if not looking at end of list
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 ( ignore extra pesky comma at end of list)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 if (i != (strlen(buffer) - 1))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 cnt++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 /* add one more name than comma .. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 cnt++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 /* allocate the array to hold the list of buddys */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 /* null terminated array of pointers */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
311 if (!(tmp_array = (char **) malloc(sizeof(char *) * (cnt + 1)))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
312 FREE(buffer);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
313 return NULL;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
314 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 memset(tmp_array, 0, (sizeof(char *) * (cnt + 1)));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 /* Parse through the list and get all the entries */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 while ((ptr_buffer[sublen] != ',') && (ptr_buffer[sublen] != '\0'))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 sublen++;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
321 if (!(tmp = (char *) malloc(sizeof(char) * (sublen + 1)))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
322 FREE(buffer);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
323 FREE(tmp_array);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
324 return NULL;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
325 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 memcpy(tmp, ptr_buffer, sublen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 tmp[sublen] = '\0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 if (ptr_buffer[sublen] != '\0')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 ptr_buffer = &(ptr_buffer[sublen + 1]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 ptr_buffer = &(ptr_buffer[sublen]); /* stay at the null char */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 sublen = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 while (tmp && (strcmp(tmp, "") != 0))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 len = strlen(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 array_elem = (char *) malloc(sizeof(char) * (len + 1));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 strncpy(array_elem, tmp, (len + 1));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 array_elem[len] = '\0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 tmp_array[nxtelem++] = array_elem;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 array_elem = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 FREE(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 while ((ptr_buffer[sublen] != ',') && (ptr_buffer[sublen] != '\0'))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 sublen++;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
351 if (!(tmp = (char *) malloc(sizeof(char) * (sublen + 1)))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
352 FREE(buffer);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
353 FREE(tmp_array);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
354 return NULL;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
355 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 memcpy(tmp, ptr_buffer, sublen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 tmp[sublen] = '\0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 if (ptr_buffer[sublen] != '\0')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 ptr_buffer = &(ptr_buffer[sublen + 1]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 ptr_buffer = &(ptr_buffer[sublen]); /* stay at the null char */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 sublen = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 tmp_array[nxtelem] = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 FREE(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 FREE(buffer);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 return (tmp_array);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 } /* yahoo_list2array() */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 Free's the memory associated with an array generated bu yahoo_list2array
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 void yahoo_arraykill(char **array)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 int nxtelem = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 if (NULL == array)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 while (array[nxtelem] != NULL)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
387 FREE(array[nxtelem++]);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
390 FREE(array);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 } /* yahoo_arraykill() */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 converts an array of strings to a comma seperated list
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 used primarily in conference code
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 allocates a string in here.. needs to be freed by caller program
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 char *yahoo_array2list(char **array)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 char *list = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 int nxtelem = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 int arraylength = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 if (NULL == array)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 while (array[nxtelem] != NULL)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 arraylength += strlen(array[nxtelem++]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 arraylength++; /* comma */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 nxtelem = 0; /* reset array counter */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 /* allocate at least one - for NULL list - and to
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 allow my strcat to write past the end for the
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 last comma which gets converted to NULL */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
419 if (!(list = (char *) malloc(sizeof(char) * (arraylength + 1))))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
420 return NULL;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 memset(list, 0, (arraylength + 1));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 while (array[nxtelem] != NULL)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 strcat(list, array[nxtelem++]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 strcat(list, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 overwrite last ',' with a NULL
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 makes the string end with two null characters, but this way
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 handles empty lists gracefully
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 list[arraylength - 1] = '\0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 return (list);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 } /* yahoo_array2list() */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 /* Free a buddy list */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 static void yahoo_free_buddies(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 if (!ctx->buddies)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 while (ctx->buddies[i])
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 FREE(ctx->buddies[i]->group);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 FREE(ctx->buddies[i]->id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 i++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 FREE(ctx->buddies);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 /* Free a identities list */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 static void yahoo_free_identities(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 if (!ctx->identities)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 while (ctx->identities[i])
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 FREE(ctx->identities[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 i++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 FREE(ctx->identities);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_free_identities: done\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 #if 0 /* not used at the moment */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 static void yahoo_hexdump(char *label, unsigned char *data, int datalen)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 int i, j;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 int val, skipped_last;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 char current[100];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 char last[100];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 char tmp[15];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 char outline[100];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 static int last_datalen = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 static unsigned char *last_data = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 if (last_data)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 if (last_datalen == datalen && !memcmp(data, last_data, datalen))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 printf("\n%s: <same as last dump>\n", label);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 FREE(last_data);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 /* Copy the packet so we can don't duplicate it next time. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 last_datalen = datalen;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
505 if (!(last_data = (unsigned char *) malloc(datalen))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
506 FREE(last_data);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
507 return;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
508 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 memcpy(last_data, data, datalen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 /* Handle printing the full entry out */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 printf("\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513 printf("%s:\n", label);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 skipped_last = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 last[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 for (j = 0; j * 16 < datalen; j++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 current[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 /* Print out in hex */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 for (i = j * 16; i < (j * 16 + 16); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 if (i < datalen)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 val = data[i];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 sprintf(tmp, "%.2X ", val);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 sprintf(tmp, " ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 strcat(current, tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 /* Print out in ascii */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 strcat(current, " ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 for (i = j * 16; i < (j * 16) + 16; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 if (i < datalen)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 if (isprint(data[i]))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 sprintf(tmp, "%c", data[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 sprintf(tmp, ".");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 sprintf(tmp, " ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 strcat(current, tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 outline[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 if (!strcmp(current, last))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 if (!skipped_last)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 strcpy(outline, " ....:\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 skipped_last = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 sprintf(outline, " %.4d: %s\n", j * 16, current);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 skipped_last = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 printf("%s", outline);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 strcpy(last, current);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576 if (skipped_last)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 printf("%s", outline);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 printf("\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584 static int yahoo_socket_connect(struct yahoo_context *ctx, char *host,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 int port)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 struct sockaddr_in serv_addr;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 struct hostent *server;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 int servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
590 int res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
592 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 "[libyahoo] yahoo_socket_connect - starting [%s:%d]\n", host, port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
595 if (!ctx || !host || !port)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 "[libyahoo] yahoo_socket_connect - nulls\n");
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
599 return -1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
602 if (!(server = gethostbyname(host)))
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
604 printf("[libyahoo] failed to look up server (%s:%d): %s\n", host, port, hstrerror(h_errno));
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
605 return -1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
608 if ((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
609 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
610 return -1;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
611 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
612
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
613 memset(&serv_addr, 0, sizeof(serv_addr));
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 serv_addr.sin_family = AF_INET;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
615 memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 serv_addr.sin_port = htons(port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
618 /* XXX should put timeouts on the connect()'s -mid */
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 res = -1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 if (ctx->connect_mode == YAHOO_CONNECT_SOCKS4)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 #if defined(WITH_SOCKS4)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 res =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 Rconnect(servfd, (struct sockaddr *) &serv_addr,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 sizeof(serv_addr));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 else if (ctx->connect_mode == YAHOO_CONNECT_SOCKS5)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 #if defined(WITH_SOCKS5)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 else if (ctx->connect_mode == YAHOO_CONNECT_NORMAL ||
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 ctx->connect_mode == YAHOO_CONNECT_HTTP ||
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 res =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638 connect(servfd, (struct sockaddr *) &serv_addr,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 sizeof(serv_addr));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 printf("[libyahoo] unhandled connect mode (%d).\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 ctx->connect_mode);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
645 close(servfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
646 return -1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 if (res < 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
651 printf("[libyahoo] failed to connect to server (%s:%d): %s\n",
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
652 host, port, strerror(errno));
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 close(servfd);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
654 return -1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 "[libyahoo] yahoo_socket_connect - finished\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 return servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 /* really ugly brute force approach - someone find a GPL'd/free
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 equivalent and replace this p.o.s. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 static char *yahoo_urlencode(char *data)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 static char *tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 char buf[4];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 int i, len;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 len = 3 * strlen(data) + 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
672 if (tmp)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
673 FREE(tmp);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 if (!data)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 /* change this at some point to re-use the buffer, no sense
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 allocating repeatedly */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
680 if (!(tmp = (char *) malloc(len)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
681 return NULL;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 tmp[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 for (i = 0; i < strlen(data); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 if (isdigit((int) (data[i])) ||
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 isalpha((int) data[i]) || data[i] == '_')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 buf[0] = data[i];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 buf[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 strcat(tmp, buf);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 sprintf(buf, "%%%.2X", data[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 strcat(tmp, buf);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 return tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
703 static int yahoo_addtobuffer(struct yahoo_context *ctx, char *data,
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 int datalen)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 //yahoo_hexdump("yahoo_addtobuffer", data, datalen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 /* Check buffer, increase size if necessary */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 if (!ctx->io_buf
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 || ((ctx->io_buf_maxlen - ctx->io_buf_curlen) < (datalen + 100)))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 char *new_io_buf;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 if (datalen < 10240)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 ctx->io_buf_maxlen += 10240;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720 ctx->io_buf_maxlen += datalen;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
722 if (!(new_io_buf = (char *) malloc(ctx->io_buf_maxlen)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
723 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 if (ctx->io_buf)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 memcpy(new_io_buf, ctx->io_buf, ctx->io_buf_curlen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 FREE(ctx->io_buf);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 ctx->io_buf = new_io_buf;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 memcpy(ctx->io_buf + ctx->io_buf_curlen, data, datalen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 ctx->io_buf_curlen += datalen;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
736
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
737 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 static int yahoo_tcp_readline(char *ptr, int maxlen, int fd)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 int n, rc;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743 char c;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 for (n = 1; n < maxlen; n++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 again:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
749 if ((rc = readall(fd, &c, 1)) == 1)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751 *ptr++ = c;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 if (c == '\n')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 else if (rc == 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 if (n == 1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 return (0); /* EOF, no data */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 break; /* EOF, w/ data */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 if (errno == EINTR)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765 goto again;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 printf
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
767 ("Yahoo: Error reading from socket in yahoo_tcp_readline: %s.\n", strerror(errno));
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
768 return -1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 *ptr = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 return (n);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 * Published library interfaces
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 /* Initialize interface to yahoo library, sortof like a class object
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 creation routine. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 struct yahoo_context *yahoo_init(char *user, char *password,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 struct yahoo_options *options)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 struct yahoo_context *tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787 if (!user || !password)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 /* Allocate a new context */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
793 if (!(tmp = (struct yahoo_context *) calloc(1, sizeof(*tmp))))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
794 return NULL;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
796 /* Fill in any available info */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
797 if (!(tmp->user = strdup(user))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
798 yahoo_free_context(tmp);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
799 return NULL;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
800 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
801 if (!(tmp->password = strdup(password))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
802 yahoo_free_context(tmp);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
803 return NULL;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
804 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805 if (options->proxy_host)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
807 if (!(tmp->proxy_host = strdup(options->proxy_host))) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
808 yahoo_free_context(tmp);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
809 return NULL;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
810 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 tmp->proxy_port = options->proxy_port;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 tmp->connect_mode = options->connect_mode;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 #if defined(WITH_SOCKS4)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
816 if (connect_mode == YAHOO_CONNECT_SOCKS4)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 static int did_socks_init = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
820 if (did_socks_init == 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 SOCKSinit("libyahoo");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 did_socks_init = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 /* Fetch the cookies */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 if (!yahoo_fetchcookies(tmp))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831 yahoo_free_context(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 return tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 /* Free a yahoo context */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 void yahoo_free_context(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 FREE(ctx->user);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 FREE(ctx->password);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 FREE(ctx->proxy_host);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 FREE(ctx->io_buf);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 FREE(ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 FREE(ctx->login_cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 FREE(ctx->login_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 yahoo_free_buddies(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 yahoo_free_identities(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 FREE(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
853 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
854
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
855 /* Turn a status code into it's corresponding string */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
856 char *yahoo_get_status_string(int statuscode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 for (i = 0; yahoo_status_codes[i].label; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862 if (yahoo_status_codes[i].id == statuscode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
863 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
864 return yahoo_status_codes[i].label;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
865 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
866 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
868 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870 /* Turn a status code into it's corresponding string */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 char *yahoo_get_status_append(int statuscode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
873 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
874
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875 for (i = 0; yahoo_status_append[i].label; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 if (yahoo_status_append[i].id == statuscode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 return yahoo_status_append[i].label;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
880 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 /* Turn a service code into it's corresponding string */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 char *yahoo_get_service_string(int servicecode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 char *name = "Unknown Service";
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 static char tmp[50];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 for (i = 0; yahoo_service_codes[i].label; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 if (yahoo_service_codes[i].id == servicecode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 name = yahoo_service_codes[i].label;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 snprintf(tmp, 50, "(%d) %s", servicecode, name);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 return tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905 /* Return a malloc()'d copy of the users cookie */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906 int yahoo_fetchcookies(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 char buffer[5000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 int servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911 int res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
912 char *tmpstr;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
913
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
914 if (!ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
915 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
916 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
917 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
918
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
919 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_fetchcookies: starting\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
920
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
921 /* Check for cached cookie */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
922 if (ctx->cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924 FREE(ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 if (ctx->login_cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928 FREE(ctx->login_cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
931 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933 servfd = yahoo_socket_connect(ctx, ctx->proxy_host, ctx->proxy_port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 servfd = yahoo_socket_connect(ctx, YAHOO_AUTH_HOST, YAHOO_AUTH_PORT);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
939 if (servfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 printf("[libyahoo] failed to connect to pager auth server.\n");
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
942 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
944
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
945 strcpy(buffer, "GET ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
946 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948 strcat(buffer, "http://" YAHOO_AUTH_HOST);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
949 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
950 strcat(buffer, "/config/ncclogin?login=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 if (ctx->login_id)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 strcat(buffer, yahoo_urlencode(ctx->login_id));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
957 strcat(buffer, yahoo_urlencode(ctx->user));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
958 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959 strcat(buffer, "&passwd=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960 strcat(buffer, yahoo_urlencode(ctx->password));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 strcat(buffer, "&n=1 HTTP/1.0\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 strcat(buffer, "User-Agent: " YAHOO_USER_AGENT "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 strcat(buffer, "Host: " YAHOO_AUTH_HOST "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
966 if (writeall(servfd, buffer, strlen(buffer)) < strlen(buffer))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
967 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
968 close(servfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
969 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
970 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 "[libyahoo] yahoo_fetchcookies: writing buffer '%s'\n", buffer);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 ctx->cookie = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 while ((res = yahoo_tcp_readline(buffer, 5000, servfd)) > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978 /* strip out any non-alphas */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 for (i = 0; i < strlen(buffer); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 if (!isprint((int) buffer[i]))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 buffer[i] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988 "[libyahoo] yahoo_fetchcookies: read buffer '%s'\n", buffer);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 if (!strcasecmp(buffer, "ERROR: Invalid NCC Login"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 "[libyahoo] yahoo_fetchcookies: password was invalid\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 if (!strncasecmp(buffer, "Set-Cookie: Y=", 14))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999 FREE(ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 ctx->cookie = strdup(buffer + 12);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 tmpstr = strchr(ctx->cookie, ';');
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 if (tmpstr)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 *tmpstr = '\0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 "[libyahoo] yahoo_fetchcookies: closing server connection\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 close(servfd);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 servfd = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 "[libyahoo] yahoo_fetchcookies: closed server connection\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016 if (ctx->cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018 tmpstr = strstr(ctx->cookie, "n=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 if (tmpstr)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 ctx->login_cookie = strdup(tmpstr + 2);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 tmpstr = strchr(ctx->login_cookie, '&');
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 if (tmpstr)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1027 *tmpstr = '\0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 if (ctx->cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 "[libyahoo] yahoo_fetchcookies: cookie (%s)\n", ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 if (ctx->login_cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036 "[libyahoo] yahoo_fetchcookies: login cookie (%s)\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037 ctx->login_cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_fetchcookies: done\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041 return 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044 /* Add a buddy to your buddy list */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045 int yahoo_add_buddy(struct yahoo_context *ctx, char *addid,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1046 char *active_id, char *group, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1047 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048 char buffer[5000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 int servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 if (!ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 "[libyahoo] yahoo_add_buddy - connecting via proxy\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 servfd = yahoo_socket_connect(ctx, ctx->proxy_host, ctx->proxy_port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 "[libyahoo] yahoo_add_buddy - connecting\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 servfd = yahoo_socket_connect(ctx, YAHOO_DATA_HOST, YAHOO_DATA_PORT);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1068 if (servfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 "[libyahoo] yahoo_add_buddy: failed to connect\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1073 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1074
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075 strcpy(buffer, "GET ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1076 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1077 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078 strcat(buffer, "http://" YAHOO_DATA_HOST);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 strcat(buffer, "/config/set_buddygrp?.bg=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081 strcat(buffer, yahoo_urlencode(group));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 strcat(buffer, "&.src=bl&.cmd=a&.bdl=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083 strcat(buffer, yahoo_urlencode(addid));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 strcat(buffer, "&.id=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 strcat(buffer, yahoo_urlencode(active_id));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 strcat(buffer, "&.l=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1087 strcat(buffer, yahoo_urlencode(ctx->user));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 strcat(buffer, "&.amsg=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 strcat(buffer, yahoo_urlencode(msg));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 strcat(buffer, " HTTP/1.0\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092 strcat(buffer, "User-Agent: " YAHOO_USER_AGENT "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 strcat(buffer, "Host: " YAHOO_DATA_HOST "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 strcat(buffer, "Cookie: ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095 strcat(buffer, ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1099 if (writeall(servfd, buffer, strlen(buffer)) < strlen(buffer))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1100 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1101 close(servfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1102 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1103 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1104
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 while (yahoo_tcp_readline(buffer, 5000, servfd) > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 /* just dump the output, I don't care about errors at the moment */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 close(servfd);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 servfd = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 /* indicate success for now with 0 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1113 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_add_buddy: finished\n");
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1114 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117 /* Remove a buddy from your buddy list */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 int yahoo_remove_buddy(struct yahoo_context *ctx, char *addid,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 char *active_id, char *group, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 char buffer[5000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 int servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 if (!ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1125 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 "[libyahoo] yahoo_add_buddy - connecting via proxy\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1133 servfd = yahoo_socket_connect(ctx, ctx->proxy_host, ctx->proxy_port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_add_buddy - connecting\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1138 servfd = yahoo_socket_connect(ctx, YAHOO_DATA_HOST, YAHOO_DATA_PORT);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1140 if (servfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1142 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1143 "[libyahoo] yahoo_add_buddy: failed to connect\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147 strcpy(buffer, "GET ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 strcat(buffer, "http://" YAHOO_DATA_HOST);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 strcat(buffer, "/config/set_buddygrp?.bg=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 strcat(buffer, yahoo_urlencode(group));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 strcat(buffer, "&.src=bl&.cmd=d&.bdl=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 strcat(buffer, yahoo_urlencode(addid));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156 strcat(buffer, "&.id=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 strcat(buffer, yahoo_urlencode(active_id));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 strcat(buffer, "&.l=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 strcat(buffer, yahoo_urlencode(ctx->user));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 strcat(buffer, "&.amsg=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161 strcat(buffer, yahoo_urlencode(msg));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 strcat(buffer, " HTTP/1.0\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164 strcat(buffer, "User-Agent: " YAHOO_USER_AGENT "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 strcat(buffer, "Host: " YAHOO_DATA_HOST "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 strcat(buffer, "Cookie: ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 strcat(buffer, ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1171 if (writeall(servfd, buffer, strlen(buffer)) < strlen(buffer))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1172 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1173 close(servfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1174 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1175 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1176
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177 while (yahoo_tcp_readline(buffer, 5000, servfd) > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 /* just dump the output, I don't care about errors at the moment */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 close(servfd);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 servfd = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1184 /* indicate success for now with 1 */
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1185 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 /* Retrieve the configuration from the server */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 int yahoo_get_config(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 char buffer[5000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 int i, j;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 int servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 int commas;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 int in_section;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 struct yahoo_buddy **buddylist = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 int buddycnt = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 int nextbuddy = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 /* Check for cached cookie */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 if (!ctx || !ctx->cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_get_config: starting\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 servfd = yahoo_socket_connect(ctx, ctx->proxy_host, ctx->proxy_port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 servfd = yahoo_socket_connect(ctx, YAHOO_DATA_HOST, YAHOO_DATA_PORT);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1216 if (servfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219 "[libyahoo] yahoo_get_config: failed to connect\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 strcpy(buffer, "GET ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 strcat(buffer, "http://" YAHOO_DATA_HOST);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 strcat(buffer, "/config/get_buddylist?.src=bl HTTP/1.0\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229 strcat(buffer, "Cookie: ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 strcat(buffer, ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1234 if (writeall(servfd, buffer, strlen(buffer)) < strlen(buffer))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1235 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1236 close(servfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1237 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1238 }
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1239
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_get_config: sending '%s'\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241 buffer);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 in_section = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244 while (yahoo_tcp_readline(buffer, 5000, servfd) > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1245 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 /* strip out any non-alphas */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1247 for (i = 0; i < strlen(buffer); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1248 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 if (!isprint((int) buffer[i]))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1250 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251 for (j = i; j < strlen(buffer); j++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1252 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 buffer[j] = buffer[j + 1];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 "[libyahoo] yahoo_get_config: read '%s'\n", buffer);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261 if (!strcasecmp(buffer, "BEGIN IDENTITIES"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1263 in_section = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1264 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 else if (!strcasecmp(buffer, "END IDENTITIES"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 in_section = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1268 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 else if (!strcasecmp(buffer, "BEGIN BUDDYLIST"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 in_section = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 else if (!strcasecmp(buffer, "END BUDDYLIST"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1275 in_section = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277 else if (in_section == 1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1278 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 char *tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281 /* count the commas */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282 commas = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 for (i = 0; i < strlen(buffer); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1285 if (buffer[i] == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287 commas++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1289 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291 /* make sure we've gotten rid of any previous identities array */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 yahoo_free_identities(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 /* allocate the array to hold the list of identities */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 ctx->identities = (char **) calloc(commas + 2, sizeof(char *));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 /* Parse through the list and get all the entries */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 tmp = strtok(buffer, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300 while (tmp)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303 "[libyahoo] yahoo_get_config: retrieved "
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1304 "identity '%s'\n", tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305 ctx->identities[i++] = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306 tmp = strtok(NULL, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1307 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308 ctx->identities[i] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 else if (in_section == 2)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312 char *group;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313 char *tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 struct yahoo_buddy **tmp_buddylist;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 struct yahoo_buddy *tmpbuddy;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1316 int tmp_buddycnt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1317
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 /* count the buddies on this line */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 tmp_buddycnt = buddycnt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 for (i = 0; i < strlen(buffer); i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322 if (buffer[i] == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324 buddycnt++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1327 buddycnt++; /* always one more than comma count */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1328
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1329 /* allocate the array to hold the list of buddy */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1330 tmp_buddylist = (struct yahoo_buddy **)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1331 malloc(sizeof(struct yahoo_buddy *) * (buddycnt + 1));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1332
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1333 /* Free and copy the old one if necessary */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1334 if (buddylist)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1335 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1336 memcpy(tmp_buddylist, buddylist,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1337
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1338 (tmp_buddycnt + 1) * sizeof(struct yahoo_buddy *));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 FREE(buddylist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342 buddylist = tmp_buddylist;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1343
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1344 /* Parse through the list and get all the entries */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 tmp = strtok(buffer, ",:");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1346 group = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347 while (tmp)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1348 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1349 if (tmp == buffer) /* group name */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1350 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 group = tmp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1355 tmpbuddy = (struct yahoo_buddy *)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1356
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1357 malloc(sizeof(struct yahoo_buddy));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1359 tmpbuddy->id = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360 tmpbuddy->group = strdup(group);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1361 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1362 "[libyahoo] yahoo_get_config: retrieved buddy '%s:%s'\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1363 group, tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1364 buddylist[nextbuddy++] = tmpbuddy;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1365 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1366 tmp = strtok(NULL, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1368 buddylist[nextbuddy] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1369 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1370 else if (!strncasecmp(buffer, "Mail=", strlen("Mail=")))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1371 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1372 ctx->mail = atoi(buffer + strlen("Mail="));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1373 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1374 "[libyahoo] yahoo_get_config: retrieved mail flag '%d'\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1375 ctx->mail);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1376 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1377 else if (!strncasecmp(buffer, "Login=", strlen("Login=")))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1378 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1379 FREE(ctx->login_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1380 ctx->login_id = strdup(buffer + strlen("Login="));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1381 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1382 "[libyahoo] yahoo_get_config: retrieved login id '%s'\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1383 ctx->login_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1384 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1385 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386 close(servfd);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1387 servfd = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1388
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1389 yahoo_free_buddies(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1390 ctx->buddies = buddylist;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1391
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1392 /* fill in a bogus login_in, just in case */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393 if (!ctx->login_id)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1394 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1395 ctx->login_id = strdup(ctx->user);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1396 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1397
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398 /* refetch the cookie if the login_id is different so that
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 it will have the correct info in it */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400 if (strcmp(ctx->login_id, ctx->user))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403 "[libyahoo] yahoo_get_config - refetching cookies\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1404 yahoo_fetchcookies(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1405 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_get_config - finished\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409 return 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 /* Log in, optionally activating other secondary identities */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 int yahoo_cmd_logon(struct yahoo_context *ctx, unsigned int initial_status)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 char login_string[5000]; /* need to change to malloc ASAP */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416 char *tmpid;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1417 char **identities = ctx->identities;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 if (!ctx || !ctx->login_cookie)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 "[libyahoo] yahoo_cmd_logon: logon called without "
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 "context and/or cookie.\n");
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1425 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1427
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 strcpy(login_string, ctx->login_cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 /* testing with new logon code */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 // strcpy(login_string, "$1$_2S43d5f$XXXXXXXXWtRKNclLWyy8C.");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432 login_string[strlen(login_string) + 1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433 login_string[strlen(login_string)] = 1; /* control-A */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 strcat(login_string, ctx->user);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 /* Send all identities */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1438 if (identities)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1441 tmpid = identities[i];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1442 while (tmpid)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 if (strcasecmp(tmpid, ctx->user))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446 strcat(login_string, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 strcat(login_string, tmpid);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 tmpid = identities[i++];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1453 if(!yahoo_sendcmd(ctx, YAHOO_SERVICE_LOGON, ctx->user, login_string,
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1454 initial_status))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1455 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457 /* something that the windows one sends, not sure what it is */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 #if 0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459 login_string[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1460 strcat(login_string, "C=0\002");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461 strcat(login_string, "F=0,P=0,H=0,S=0,W=0,O=0\002");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1462 strcat(login_string, "M=0,P=0,C=0,S=0");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1463 yahoo_sendcmd(ctx, YAHOO_SERVICE_PASSTHROUGH2, ctx->user, login_string,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1464 0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1467 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 int yahoo_connect(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472 int res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1474 res = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1475 ctx->sockfd = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1476
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1477 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_connect - starting\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1478
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479 switch (ctx->connect_mode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1481 case YAHOO_CONNECT_SOCKS4:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1482 case YAHOO_CONNECT_SOCKS5:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 case YAHOO_CONNECT_NORMAL:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485 "[libyahoo] yahoo_connect - establishing socket connection\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1486 ctx->sockfd =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1487 yahoo_socket_connect(ctx, YAHOO_PAGER_HOST, YAHOO_PAGER_PORT);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1488 if (ctx->sockfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1490 printf("[libyahoo] couldn't connect to pager host\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1492 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1493 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1494
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1495 case YAHOO_CONNECT_HTTP:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1496 case YAHOO_CONNECT_HTTPPROXY:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1497 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1498 "[libyahoo] yahoo_connect - no connect for HTTP\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1499 /* no pager connection will be established for this */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1500 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1501
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1502 default:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503 printf("[libyahoo] unhandled connect mode (%d)\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1504 ctx->connect_mode);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1505 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1506
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1507 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_connect - finished\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1508 return (1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1509 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1510
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1511 /* Send a packet to the server via http connection method */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1512 /* at moment only handles regular http connection, once I have that
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1513 working, this code needs to also do http proxy connections as well */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1514 int yahoo_sendcmd_http(struct yahoo_context *ctx, struct yahoo_rawpacket *pkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1515 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1516 int sockfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1517 char buffer[5000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1518 char tmpbuf[1000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1519 int size;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1520 int res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1521
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1522 if (!ctx || !pkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1523 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1524 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1527 size = YAHOO_PACKET_HEADER_SIZE + strlen(pkt->content) + 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1530 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1531 sockfd = yahoo_socket_connect(ctx, ctx->proxy_host, ctx->proxy_port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1534 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1535 sockfd = yahoo_socket_connect(ctx, YAHOO_PAGER_HTTP_HOST,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536 YAHOO_PAGER_HTTP_PORT);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1538 if (sockfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1539 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540 printf("[libyahoo] failed to connect to pager http server.\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544 strcpy(buffer, "POST ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 strcat(buffer, "http://" YAHOO_PAGER_HTTP_HOST);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 strcat(buffer, "/notify HTTP/1.0\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1550
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 strcat(buffer, "User-Agent: " YAHOO_USER_AGENT "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1552 strcat(buffer, "Host: " YAHOO_PAGER_HTTP_HOST "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1553 snprintf(tmpbuf, 1000, "Content-Length: %d\r\n", size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1554 strcat(buffer, tmpbuf);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1556 strcat(buffer, "Pragma: No-Cache\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1557
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1558 strcat(buffer, "Cookie: ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1559 strcat(buffer, ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1560 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1561 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1562
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1563 if ((writeall(sockfd, buffer, strlen(buffer)) < strlen(buffer)) ||
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1564 (writeall(sockfd, pkt, size) < size) ||
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1565 (writeall(sockfd, "\r\n", 2) < 2))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1566 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1567 close(sockfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1568 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1569 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1570
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1571 /* now we need to read the results */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1572 /* I'm taking the cheat approach and just dumping them onto the
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573 buffer, headers and all, the _skip_to_YHOO_ code will handle it
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1574 for now */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1575
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1576 while ((res = readall(sockfd, buffer, sizeof(buffer))) > 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1577 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1578 if (res == -1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1579 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1580 printf("[libyahoo] Error reading data from server.\n");
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1581 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1582 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1583 if (!yahoo_addtobuffer(ctx, buffer, res))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1584 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1585 close(sockfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1586 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1587 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1588 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1589 close(sockfd);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1590
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1591 return (1);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1592 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1593
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1594 /* Send a packet to the server, called by all routines that want to issue
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1595 a command. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596 int yahoo_sendcmd(struct yahoo_context *ctx, int service, char *active_nick,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1597 char *content, unsigned int msgtype)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1599 int size;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1600 struct yahoo_rawpacket *pkt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 int maxcontentsize;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1603 /* why the )&*@#$( did they hardwire the packet size that gets sent
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604 when the size of the packet is included in what is sent, bizarre */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605 size = 4 * 256 + YAHOO_PACKET_HEADER_SIZE;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1606 if (!(pkt = (struct yahoo_rawpacket *) calloc(1, size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1607 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1608
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1609 /* figure out max content length, including trailing null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1610 maxcontentsize = size - sizeof(struct yahoo_rawpacket);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1611
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1612 /* Build the packet */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1613 strcpy(pkt->version, YAHOO_PROTOCOL_HEADER);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1614 yahoo_storeint(pkt->len, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615 yahoo_storeint(pkt->service, service);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 /* not sure if this is valid with YPNS1.4 or if it needs 2.0 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 yahoo_storeint(pkt->msgtype, msgtype);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620 /* Not sure, but might as well send for regular connections as well. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621 yahoo_storeint(pkt->magic_id, ctx->magic_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622 strcpy(pkt->nick1, ctx->login_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 strcpy(pkt->nick2, active_nick);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1624 strncpy(pkt->content, content, maxcontentsize);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1625
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1626 // yahoo_hexdump("send_cmd", (char *) pkt, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1627
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628 switch (ctx->connect_mode)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1629 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1630 case YAHOO_CONNECT_SOCKS4:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1631 case YAHOO_CONNECT_SOCKS5:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1632 case YAHOO_CONNECT_NORMAL:
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1633 if (writeall(ctx->sockfd, pkt, size) < size)
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1634 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1635 printf("sendcmd: writeall failed\n");
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1636 close(ctx->sockfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1637 FREE(pkt);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1638 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1639 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1640 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1641 case YAHOO_CONNECT_HTTP:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1642 case YAHOO_CONNECT_HTTPPROXY:
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1643 if (!yahoo_sendcmd_http(ctx, pkt))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1644 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1645 printf("sendcmd_http failed\n");
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1646 FREE(pkt);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1647 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1648 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1649 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1650 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1651
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1652 FREE(pkt);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1653 return (1);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1654 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1655
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1656 int yahoo_cmd_ping(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1657 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1658 return yahoo_sendcmd(ctx, YAHOO_SERVICE_PING, ctx->user, "", 0);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1659 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1660
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1661 int yahoo_cmd_idle(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1662 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1663 return yahoo_sendcmd(ctx, YAHOO_SERVICE_IDLE, ctx->user, "", 0);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1664 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1665
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1666 int yahoo_cmd_sendfile(struct yahoo_context *ctx, char *active_user,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1667 char *touser, char *msg, char *filename)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1668 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1669 yahoo_dbg_Print("libyahoo", "yahoo_cmd_sendfile not implemented yet!");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1670 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1671 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1672
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1673 int yahoo_cmd_msg(struct yahoo_context *ctx, char *active_user,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674 char *touser, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1675 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1676 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1677
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1678 if (!(content = (char *) malloc(strlen(touser) + strlen(msg) + 5)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1679 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1680
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1681 if (strlen(touser))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1682 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1683 sprintf(content, "%s,%s", touser, msg);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1684 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_MESSAGE, active_user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1685 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1686 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1687 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1688 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1691 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1692 return (1);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1695 int yahoo_cmd_msg_offline(struct yahoo_context *ctx, char *active_user,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 char *touser, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1700 if (!(content = (char *) malloc(strlen(touser) + strlen(msg) + 5)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1701 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1703 if (strlen(touser))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1704 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1705 sprintf(content, "%s,%s", touser, msg);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1706 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_MESSAGE, active_user,
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1707 content, YAHOO_MSGTYPE_KNOWN_USER))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1708 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1709 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1710 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1711 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1715 return (1);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1716 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1717
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718 /* appended the " " so that won't trigger yahoo bug - hack for the moment */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719 int yahoo_cmd_set_away_mode(struct yahoo_context *ctx, int status, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1721 char statusstring[500];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1722
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 "[libyahoo] yahoo_cmd_set_away_mode: set status (%d), msg(%s)\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1725 status, yahoo_dbg_NullCheck(msg));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1726
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1727 if (status == YAHOO_STATUS_CUSTOM)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1728 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1729 if (msg && msg[0] != 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1730 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1731 snprintf(statusstring, 500, "%d%c%s", status, 1, msg);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1735 snprintf(statusstring, 500, "%d%c---", status, 1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1736 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1737 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1738 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1739 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1740 snprintf(statusstring, 500, "%d", status);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1741 }
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1742 return yahoo_sendcmd(ctx, YAHOO_SERVICE_ISAWAY, ctx->user, statusstring, 0);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1743 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1744
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1745 int yahoo_cmd_set_back_mode(struct yahoo_context *ctx, int status, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1746 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1747 char statusstring[500];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1748
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1749 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750 "[libyahoo] yahoo_cmd_set_back_mode: set status (%d), msg(%s)\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1751 status, yahoo_dbg_NullCheck(msg));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1752
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 snprintf(statusstring, 500, "%d%c%s ", status, 1, msg ? msg : "");
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1754 return yahoo_sendcmd(ctx, YAHOO_SERVICE_ISBACK, ctx->user, statusstring, 0);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1755 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1756
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1757 int yahoo_cmd_activate_id(struct yahoo_context *ctx, char *newid)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1758 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1759 if (strlen(newid))
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1760 return yahoo_sendcmd(ctx, YAHOO_SERVICE_IDACT, newid, newid, 0);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1761 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1762 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1763
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1764 int yahoo_cmd_user_status(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1765 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1766 return yahoo_sendcmd(ctx, YAHOO_SERVICE_USERSTAT, ctx->user, "", 0);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1767 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1768
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1769 int yahoo_cmd_logoff(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1770 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1771 return yahoo_sendcmd(ctx, YAHOO_SERVICE_LOGOFF, ctx->user, ctx->user, 0);
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1772 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1773
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1774 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1775
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1776 yahoo_cmd_start_conf()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1777
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1778 Starts a conference. (You create the conference)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1779
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1780 Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1781 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1782 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1783 You create this id to start the conference, but pass it
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1784 along after that.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1785 char **userlist == Users to invite. Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1786 car *msg == Invitiation message.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1787 int type == 0 - normal, 1 - voice (not supported yet)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1788
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1789 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1790 id^invited-users^msg^0or1
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1791 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1792 int yahoo_cmd_start_conf(struct yahoo_context *ctx, char *conf_id,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1793 char **userlist, char *msg, int type)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1794 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1795 char ctrlb = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1796 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1797 char *new_userlist = yahoo_array2list(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1798 int cont_len = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1799
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1800 #ifdef ENABLE_LIBYAHOO_DEBUG
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1801 char *unraw_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802 #endif /* def ENABLE_LIBYAHOO_DEBUG */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 int size = strlen(conf_id) + strlen(msg) + 8 + strlen(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1806 if (!(content = (char *) malloc(size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1807 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 memset(content, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1810 cont_len = snprintf(content,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811 size - 1,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1812 "%s%c%s%c%s%c%d",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1813 conf_id, ctrlb, new_userlist, ctrlb, msg, ctrlb, type);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1814
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 #ifdef ENABLE_LIBYAHOO_DEBUG
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1816 if ((unraw_msg = yahoo_unraw_buffer(content, cont_len)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1817 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1818 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_cmd_start_conf: %s\n",
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1819 unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1820 FREE(unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1821 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822 #endif /* def ENABLE_LIBYAHOO_DEBUG */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1823 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_CONFINVITE, ctx->user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1824 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1825 FREE(new_userlist);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1826 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1827 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1828 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1829
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1830 FREE(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1831 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1832 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1836 yahoo_cmd_conf_logon()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1837
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1838 Reply to a conference invitation, logs you into conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1839
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840 Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1841 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1842 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1843 This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1844 char *host == The person that sent you the invitation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1845 char **userlist == Everyone else invited. This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1846 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1847
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1848 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1849 id^all-invited-users-and-host
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1850
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1851 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1852 int yahoo_cmd_conf_logon(struct yahoo_context *ctx, char *conf_id,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1853 char *host, char **userlist)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1854 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1855 char ctrlb = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1856 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1857 char *new_userlist = yahoo_array2list(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1858 int cont_len = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1859
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1860 #ifdef ENABLE_LIBYAHOO_DEBUG
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1861 char *unraw_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1862 #endif /* def ENABLE_LIBYAHOO_DEBUG */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1863
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1864 int size = strlen(conf_id) + strlen(host) + 8 + strlen(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1865
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1866 if (!(content = (char *) malloc(size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1867 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1868 memset(content, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1869
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1870 cont_len =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1871 sprintf(content, "%s%c%s,%s", conf_id, ctrlb, host, new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 #ifdef ENABLE_LIBYAHOO_DEBUG
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1874 if ((unraw_msg = yahoo_unraw_buffer(content, cont_len)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1875 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1876 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_cmd_conf_logon: %s\n",
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1877 unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1878 FREE(unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1879 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1880 #endif /* def ENABLE_LIBYAHOO_DEBUG */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1881 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_CONFLOGON, ctx->user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1882 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1883 FREE(new_userlist);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1884 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1885 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1886 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1887
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1888 FREE(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1889 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1890 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1891 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1893 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1894
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1895 yahoo_cmd_decline_conf()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1896
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897 Reply to a conference invitation, decline offer.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1898
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1899 Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1900 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1901 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1902 This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1903 char *host == The person that sent you the invitation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1904 char **userlist == Everyone else invited. This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1905 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1906 (Null if replying to a conference additional invite )
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1907 char *msg == Reason for declining.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1908
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1909 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1910 id^all-invited-users-and-host^msg
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1911
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1912 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1913 int yahoo_cmd_decline_conf(struct yahoo_context *ctx, char *conf_id,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1914 char *host, char **userlist, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1915 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1916 char ctrlb = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1917 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1918 char *new_userlist = yahoo_array2list(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1919
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1920 int size =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1921 strlen(conf_id) + strlen(host) + strlen(msg) + 8 +
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1922 strlen(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1923
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1924 if (!(content = (char *) malloc(size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1925 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1926 memset(content, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1927
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1928 sprintf(content, "%s%c%s,%s%c%s", conf_id, ctrlb, host, new_userlist,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1929 ctrlb, msg);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1930
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1931 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_cmd_decline_conf: %s\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1932 content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1933 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_CONFDECLINE, ctx->user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1934 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1935 FREE(new_userlist);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1936 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1937 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1938 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1939
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1940 FREE(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1941 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1942 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1943 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1944
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1945 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1946
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1947 yahoo_cmd_conf_logoff()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949 Logoff of a conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1950
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1951 Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1952 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1953 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1954 This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1955 char **userlist == Everyone in conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1956 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1957
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1958 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1959 id^all-invited-users
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1960
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1961 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1962
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963 int yahoo_cmd_conf_logoff(struct yahoo_context *ctx, char *conf_id,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1964 char **userlist)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1965 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966 char ctrlb = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1967 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 int cont_len = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970 #ifdef ENABLE_LIBYAHOO_DEBUG
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1971 char *unraw_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1972 #endif /* def ENABLE_LIBYAHOO_DEBUG */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973 char *new_userlist = yahoo_array2list(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975 int size = strlen(conf_id) + strlen(new_userlist) + 8;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1977 if (!(content = (char *) malloc(size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1978 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979 memset(content, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 cont_len =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 snprintf(content, size, "%s%c%s", conf_id, ctrlb, new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983 #ifdef ENABLE_LIBYAHOO_DEBUG
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1984 if ((unraw_msg = yahoo_unraw_buffer(content, cont_len)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1985 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1986 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_cmd_conf_logoff: %s\n",
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1987 unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1988 FREE(unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1989 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1990 #endif /* def ENABLE_LIBYAHOO_DEBUG */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1991 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_CONFLOGOFF, ctx->user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1992 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1993 FREE(new_userlist);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1994 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1995 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
1996 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1997
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1998 FREE(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1999 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2000 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2002
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2003 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2004
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2005 yahoo_cmd_conf_invite()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 Invite another user to an already running conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009 Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2010 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2011 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012 This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2013 char *invited_user == The person being invited to conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2014 char **userlist == Everyone else in conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2016 char *msg == Invitation message.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2017
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2019 id^invited-user^who-else-in-conf^who-else-in-conf^msg^0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2020
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2021 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2022
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2023 int yahoo_cmd_conf_invite(struct yahoo_context *ctx, char *conf_id,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2024 char **userlist, char *invited_user, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2025 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2026 char ctrlb = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2027 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2028 char *new_userlist = yahoo_array2list(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2029
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2030 int size = strlen(conf_id) + strlen(invited_user)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2031 + (2 * strlen(new_userlist)) + strlen(msg) + 7;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2032
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2033 if (!(content = (char *) malloc(size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2034 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2035 memset(content, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2036
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2037 sprintf(content, "%s%c%s%c%s%c%s%c%s%c0", conf_id, ctrlb,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2038 invited_user, ctrlb, new_userlist, ctrlb,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2039 new_userlist, ctrlb, msg, ctrlb);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2040 yahoo_dbg_Print("libyahoo", "[libyahoo] yahoo_cmd_conf_invite: %s\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2041 content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2042 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_CONFADDINVITE, ctx->user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2043 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2044 FREE(new_userlist);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2045 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2046 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2047 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2048
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2049 FREE(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2050 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2051 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2052 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2053
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2054 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2055
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2056 yahoo_cmd_conf_msg()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2057
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058 Send a message to everyone in conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060 Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2061 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2062 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063 This comes from the invitiation.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2064 char **userlist == Everyone in conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2065 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2066 char *msg == Message to send.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2067
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2068 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2069 id^all-invited-users^msg
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2070
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2071 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2072 int yahoo_cmd_conf_msg(struct yahoo_context *ctx, char *conf_id,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2073 char **userlist, char *msg)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2074 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2075 char ctrlb = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2076 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2077 int cont_len = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2078
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2079 #ifdef ENABLE_LIBYAHOO_DEBUG
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2080 char *unraw_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2081 #endif /* def ENABLE_LIBYAHOO_DEBUG */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2082 char *new_userlist = yahoo_array2list(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2083
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2084 int size = strlen(conf_id) + strlen(new_userlist) + strlen(msg) + 8;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2085
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2086 if (!(content = (char *) malloc(size)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2087 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2088 memset(content, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2089
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2090 cont_len =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2091 snprintf(content, size, "%s%c%s%c%s", conf_id, ctrlb, new_userlist,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2092 ctrlb, msg);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2093 #ifdef ENABLE_LIBYAHOO_DEBUG
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2094 if ((unraw_msg = yahoo_unraw_buffer(content, cont_len)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2095 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2096 yahoo_dbg_Print("libyahoo", "yahoo_cmd_conf_msg: %s\n", unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2097 FREE(unraw_msg);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2098 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2099 #endif /* def ENABLE_LIBYAHOO_DEBUG */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2100 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_CONFMSG, ctx->user, content, 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2101 {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2102 FREE(new_userlist);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2103 FREE(content);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2104 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2105 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2106
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2107 FREE(new_userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2108 FREE(content);
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2109 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2110 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2111
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2112 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2113 * Free the rawpacket structure - primarily a placeholder
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2114 * since all static elements at the moment
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2115 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2116 void yahoo_free_rawpacket(struct yahoo_rawpacket *pkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2117 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2118 FREE(pkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2119 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2120
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2121 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2122 * Free entire packet structure including string elements
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2123 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2124 void yahoo_free_packet(struct yahoo_packet *pkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2125 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2126 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2127
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2128 if (pkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2129 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2130 FREE(pkt->real_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2131 FREE(pkt->active_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2132 FREE(pkt->conf_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2133 FREE(pkt->conf_host);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2134 FREE(pkt->conf_user);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2135 FREE(pkt->conf_msg);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2136 FREE(pkt->cal_url);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2137 FREE(pkt->cal_timestamp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2138 FREE(pkt->cal_title);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2139 FREE(pkt->cal_description);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2140 FREE(pkt->chat_invite_content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2141 FREE(pkt->msg_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2142 FREE(pkt->msg_timestamp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2143 FREE(pkt->msg);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2144 FREE(pkt->file_from);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2145 FREE(pkt->file_flag);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2146 FREE(pkt->file_url);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2147 FREE(pkt->file_description);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2148 FREE(pkt->group_old);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2149 FREE(pkt->group_new);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2150 if (pkt->idstatus)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2151 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2152 for (i = 0; i < pkt->idstatus_count; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2153 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2154 yahoo_free_idstatus(pkt->idstatus[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2155 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2156 free(pkt->idstatus);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2157 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2158 free(pkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2159 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2160 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2161
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2162 void yahoo_free_idstatus(struct yahoo_idstatus *idstatus)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2163 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2164 if (!idstatus)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2165 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2166
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2167 FREE(idstatus->id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2168 FREE(idstatus->connection_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2169 FREE(idstatus->status_msg);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170 FREE(idstatus);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2171 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2172
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2173 struct yahoo_packet *yahoo_parsepacket(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2174 struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2175 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2176 struct yahoo_packet *pkt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2177
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2178 /* If no valid inpkt passed, return */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2179 if (!inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2180 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2181
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2182 /* Allocate the packet structure, zeroed out */
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2183 if (!(pkt = (struct yahoo_packet *) calloc(sizeof(*pkt), 1)))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
2184 return NULL;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2185
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2186 /* Pull out the standard data */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2187 pkt->service = yahoo_makeint(inpkt->service);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2188 pkt->connection_id = yahoo_makeint(inpkt->connection_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2189 pkt->real_id = strdup(inpkt->nick1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2190 pkt->active_id = strdup(inpkt->nick2);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2191
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2192 pkt->magic_id = yahoo_makeint(inpkt->magic_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2193 pkt->unknown1 = yahoo_makeint(inpkt->unknown1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2194 pkt->msgtype = yahoo_makeint(inpkt->msgtype);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2195
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2196 /* doing this seems like a cleaner approach, but am not sure if it is
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2197 a valid one */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2198 if (pkt->magic_id != 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2199 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2200 ctx->magic_id = pkt->magic_id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2201 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2202 if (pkt->connection_id != 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2203 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2204 ctx->connection_id = pkt->connection_id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2205 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2206
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207 /* Call a particular parse routine to pull out the content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 switch (pkt->service)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2209 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 case YAHOO_SERVICE_LOGON:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2211 case YAHOO_SERVICE_LOGOFF:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2212 case YAHOO_SERVICE_ISAWAY:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2213 case YAHOO_SERVICE_ISBACK:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2214 case YAHOO_SERVICE_USERSTAT:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2215 case YAHOO_SERVICE_CHATLOGON:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2216 case YAHOO_SERVICE_CHATLOGOFF:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2217 case YAHOO_SERVICE_GAMELOGON:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2218 case YAHOO_SERVICE_GAMELOGOFF:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2219 yahoo_parsepacket_status(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2221 case YAHOO_SERVICE_IDACT:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2222 case YAHOO_SERVICE_IDDEACT:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2223 /* nothing needs done, only has main fields */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2224 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2225 case YAHOO_SERVICE_MESSAGE:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2226 case YAHOO_SERVICE_SYSMESSAGE:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2227 case YAHOO_SERVICE_CHATMSG:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2228 yahoo_parsepacket_message(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2229 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2230 case YAHOO_SERVICE_NEWMAIL:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231 case YAHOO_SERVICE_NEWPERSONALMAIL:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2232 yahoo_parsepacket_newmail(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 case YAHOO_SERVICE_CALENDAR:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235 yahoo_parsepacket_calendar(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2237 case YAHOO_SERVICE_CHATINVITE:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238 yahoo_parsepacket_chatinvite(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240 case YAHOO_SERVICE_NEWCONTACT:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 yahoo_parsepacket_newcontact(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2242 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 case YAHOO_SERVICE_GROUPRENAME:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2244 yahoo_parsepacket_grouprename(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2245 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2246 case YAHOO_SERVICE_CONFINVITE:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247 yahoo_parsepacket_conference_invite(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2248 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249 case YAHOO_SERVICE_CONFLOGON:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2250 case YAHOO_SERVICE_CONFLOGOFF:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 yahoo_parsepacket_conference_user(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253 case YAHOO_SERVICE_CONFDECLINE:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2254 yahoo_parsepacket_conference_decline(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2255 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256 case YAHOO_SERVICE_CONFADDINVITE:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 yahoo_parsepacket_conference_addinvite(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2258 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 case YAHOO_SERVICE_CONFMSG:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260 yahoo_parsepacket_conference_msg(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2262 case YAHOO_SERVICE_PING:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2263 yahoo_parsepacket_ping(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2264 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2265 case YAHOO_SERVICE_FILETRANSFER:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266 yahoo_parsepacket_filetransfer(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2267 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2268 default:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2269 yahoo_dbg_Print("libyahoo",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2270 "yahoo_parsepacket: can't parse packet type (%d)\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2271 pkt->service);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 return pkt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2278 int yahoo_parsepacket_ping(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2283 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2284 content = inpkt->content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286 pkt->msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2287 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 pkt->msg = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2292
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 int yahoo_parsepacket_newmail(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297 int len;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300 content = inpkt->content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 len = strlen(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303 if (pkt->service == YAHOO_SERVICE_NEWMAIL)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2304 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 pkt->mail_status = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 if (len > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308 pkt->mail_status = atoi(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 else if (pkt->service == YAHOO_SERVICE_NEWPERSONALMAIL)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2312 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313 pkt->mail_status = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 if (len > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316 pkt->mail_status = atoi(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2317 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 int yahoo_parsepacket_grouprename(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2324 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327 char *tmp, delim[5];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2328
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2329 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2330 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2331
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2332 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333 pkt->group_old = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2334 pkt->group_new = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2336 tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 delim[0] = 1; /* control-a */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338 delim[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2340 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342 tmp = strtok(content, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2343 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2344
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2345 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2346 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347 pkt->group_old = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2348 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2350
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 if (tmp) /* conference host */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2352 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353 pkt->group_new = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2354 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2355 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2358 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2360
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2361 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2362
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2363 yahoo_parsepacket_conference_invite()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2364
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2365 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 id^host^invited-users^msg^0or1
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2367
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368 Parses Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2371 char *conf_host == The person inviting you to conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 char **userlist == Everyone else invited to conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2373 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 char *msg == Invitation message.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375 int conf_type == Type of conference ( 0 = text, 1 = voice )
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2377 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2378 int yahoo_parsepacket_conference_invite(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 char *tmp = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2383 size_t found = 0, len = yahoo_makeint(inpkt->len);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386 content = memdup(inpkt->content, len);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2388 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2389 pkt->conf_id = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2390 pkt->conf_host = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2391 pkt->conf_user = pkt->active_id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2392 pkt->conf_userlist = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393 pkt->conf_inviter = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2394 pkt->conf_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2395
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2396 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 tmp = memtok(content, len, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2402 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2403 pkt->conf_id = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2404 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2407 if (tmp) /* conference host */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2408 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 pkt->conf_host = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2410 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 if (tmp) /* who else is invited */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2414 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2415 char *userlist = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 pkt->conf_userlist = yahoo_list2array(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 FREE(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2421
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2422 if (tmp) /* msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2423 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424 pkt->conf_msg = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2427
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2428 if (tmp) /* 0 == text chat 1 == voice chat */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 char *conftype = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 if (0 != conftype)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433 pkt->conf_type = atoi(conftype);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434 FREE(conftype);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2438 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2440 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2441
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2442 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2443
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2444 yahoo_parsepacket_conference_decline()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2445
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2446 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2447 id^user-who-declined^msg
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2448
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2449 Parses Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2451 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 char *conf_user == User who declined.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 char *msg == Reason for declining.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456 int yahoo_parsepacket_conference_decline(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2457 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2458 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2459 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2460 char *tmp, delim[2];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2463 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2464
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2465 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2466 pkt->conf_id = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2467 pkt->conf_host = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2468 pkt->conf_user = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2469 pkt->conf_userlist = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2470 pkt->conf_inviter = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2471 pkt->conf_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2472
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474 delim[0] = 2; /* control-b */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2475 delim[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2477 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2478 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479 tmp = strtok(content, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2480 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2482 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2483 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2484 pkt->conf_id = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2485 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2486 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2487 if (tmp) /* got the user who declined */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2488 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2489 pkt->conf_user = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2490 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 if (tmp) /* msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 pkt->conf_msg = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2496 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2499 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2500
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2501 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505 yahoo_parsepacket_conference_addinvite()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2506
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2507 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2508 Msgtype == 1
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2509 id^inviter^who-else-invited^who-else-in-conf^msg^0or1
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 Msgtype == 11
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511 id^inviter^invited-user
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2513 Parses Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2514 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516 char *conf_inviter == The person inviting you to conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2517 char **userlist == Everyone else in conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2518 Null terminated array of strings.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519 char *msg == Invitation message.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 int conf_type == Type of conference ( 0 = text, 1 = voice )
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522 char *conf_user == User invited to conference (msgtype == 11)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2523 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524 int yahoo_parsepacket_conference_addinvite(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2525 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2526 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2527 char *content = 0, *tmp = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2528 size_t found = 0, len = yahoo_makeint(inpkt->len);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2529
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2530 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2531 content = memdup(inpkt->content, len);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2532
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2533 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2534 pkt->conf_id = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2535 pkt->conf_host = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2536 pkt->conf_user = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2537 pkt->conf_userlist = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2538 pkt->conf_inviter = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2539 pkt->conf_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2540
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2541 if (pkt->msgtype == 1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2542 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2544 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 tmp = memtok(content, len, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2546 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2547
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2548 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2549 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2550 pkt->conf_id = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2551 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2552 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2553 if (tmp) /* got the inviter */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2554 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 pkt->conf_inviter = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2556 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2557 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558 if (tmp) /* got who-else-invited */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2559 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2560 /* don't use this field, its the same as the next one
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2561 so I'm going to use the second field */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2562 /* pkt->conf_userlist = yahoo_list2array(tmp); */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2563 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2564 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2565 if (tmp) /* got the people in conference
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2566 not counting the inviter */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2567 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2568 char *userlist = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2569
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2570 pkt->conf_userlist = yahoo_list2array(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2571 FREE(userlist);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2572 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2573 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2574 if (tmp) /* got the message */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2575 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2576 pkt->conf_msg = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2577 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2578 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2579 if (tmp) /* 0 at the end */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2580 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2581 char *conftype = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2582
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2583 if (0 != conftype)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2584 pkt->conf_type = atoi(conftype);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2585 FREE(conftype);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2586 /* tmp = memtok (0, 0, "\002", 2, &found); */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2587 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2588 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2589 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2590 /* msgid == 11 (someone else is being invited) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2591 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2592 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2593 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2594 tmp = memtok(content, len, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2595 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2596
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2597 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2598 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2599 pkt->conf_id = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2600 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2601 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2602
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2603 if (tmp) /* got the inviter */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2604 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2605 pkt->conf_inviter = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2606 tmp = memtok(0, 0, "\002", 2, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2607 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2608
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2609 if (tmp) /* got the invited-user */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2610 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2611 pkt->conf_user = memdupasstr(tmp, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2612 /* tmp = memtok (0, 0, "\002", 2, &found); */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2613 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2614 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2615
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2616 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2617 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2618 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2619
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2620 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2621
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2622 yahoo_parsepacket_conference_msg()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2623
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2624 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2625 id^who-from^msg
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2626
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2627 Parses Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2628 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2629 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2630 char *conf_user == User who sent message.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2631 char *msg == Message.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2632
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2633 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2634 int yahoo_parsepacket_conference_msg(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2635 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2636 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2637 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2638 char *tmp, delim[5];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2639
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2640 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2641 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2642
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2643 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2644 pkt->conf_id = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2645 pkt->conf_host = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2646 pkt->conf_user = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2647 pkt->conf_userlist = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2648 pkt->conf_inviter = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2649 pkt->conf_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2650
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2651 tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2652 delim[0] = 2; /* control-b */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2653 delim[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2654
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2655 /* parse error messages first */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2656 if (pkt->msgtype == YAHOO_MSGTYPE_ERROR)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2657 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2658 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2659 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2660 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2661
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2662 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2663 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2664 tmp = strtok(content, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2665 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2666
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2667 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2668 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2669 pkt->conf_id = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2670 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2671 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2672
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2673 if (tmp) /* conference user */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2674 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2675 pkt->conf_user = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2676 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2677 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2678
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2679 if (tmp) /* msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2680 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2681 pkt->conf_msg = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2682 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2683 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2684
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2685 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2686 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2687 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2688
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2689 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2690
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2691 yahoo_parsepacket_conference_user()
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2692 (User logged on/off to conference)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2693 Packet format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2694 id^user_who_logged_on/off
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2695
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2696 Parses Arguments:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2697 char *conf_id == The conference id -- usually of the form name-number,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2698 though it doesn't seem to matter much. ex: jaylubo-123
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2699 char *conf_user == User who logged on to conference.
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2700
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2701 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2702 int yahoo_parsepacket_conference_user(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2703 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2704 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2705 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2706 char *tmp, delim[5];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2707
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2708 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2709 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2710
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2711 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2712 pkt->conf_id = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2713 pkt->conf_host = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2714 pkt->conf_user = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2715 pkt->conf_userlist = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2716 pkt->conf_inviter = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2717 pkt->conf_msg = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2718
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2719 tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2720 delim[0] = 2; /* control-b */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2721 delim[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2722
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2723 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2724 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2725 tmp = strtok(content, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2726 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2727
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2728 if (tmp) /* got the conference id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2729 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2730 pkt->conf_id = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2731 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2732 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2733
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2734 if (tmp) /* conference user */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2735 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2736 pkt->conf_user = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2737 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2738 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2739
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2740 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2741 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2742 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2743
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2744 int yahoo_parsepacket_filetransfer(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2745 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2746 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2747 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2748 char *tmp[5];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2749 int i, j, section;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2750
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2751 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2752 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2753
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2754 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2755 pkt->file_from = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2756 pkt->file_flag = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2757 pkt->file_url = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2758 pkt->file_expires = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2759 pkt->file_description = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2760
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2761 /* overkill allocation, but simple since only temporary use */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2762 tmp[0] = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2763 tmp[1] = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2764 tmp[2] = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2765 tmp[3] = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2766 tmp[4] = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2767
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2768 /* raw data format: from,flag,url,timestamp,description */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2769
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2770 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2771 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2772 section = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2773 tmp[0][0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2774 tmp[1][0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2775 tmp[2][0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2776 tmp[3][0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2777 tmp[4][0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2778
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2779 while (i < strlen(content))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2780 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2781 char ch = content[i];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2782
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2783 if (ch == ',' && section < 4)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2784 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2785 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2786 section++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2787 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2788 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2789 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2790 tmp[section][j++] = ch;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2791 tmp[section][j] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2792 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2793 i++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2794 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2795
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2796 /* do stuff with extracted parts */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2797 pkt->file_from = strdup(tmp[0]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2798 pkt->file_flag = strdup(tmp[1]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2799 pkt->file_url = strdup(tmp[2]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2800 pkt->file_expires = atoi(tmp[3]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2801 pkt->file_description = strdup(tmp[4]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2802
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2803 /* free working variables */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2804 FREE(tmp[0]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2805 FREE(tmp[1]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2806 FREE(tmp[2]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2807 FREE(tmp[3]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2808 FREE(tmp[4]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2809 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2810 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2811 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2812
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2813 int yahoo_parsepacket_calendar(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2814 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2815 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2816 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2817 char *tmp, delim[5];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2818
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2819 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2820 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2821
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2822 /* init elements to all null */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2823 pkt->cal_url = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 pkt->cal_timestamp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2825 pkt->cal_type = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2826 pkt->cal_title = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2827 pkt->cal_description = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2828
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2829 tmp = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2830 delim[0] = 2; /* control-b */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2831 delim[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2832
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2833 if (content)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2834 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2835 tmp = strtok(content, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2836 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2837
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2838 if (tmp) /* got the url */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2839 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2840 pkt->cal_url = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2841 tmp = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2842
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2843 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2844 v= is not the type code
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2845 i= doesn't look like it either
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2846 tmp2 = strstr(pkt->cal_url, "v=");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2847 if ( tmp2 )
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2848 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2849 pkt->cal_type = atoi(tmp2);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2850 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2851 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2852
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2853 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2854
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2855 if (tmp) /* unknown (type code?) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2856 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2857 /* appears this isn't it either, I don't see where it is */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2858 /* pkt->cal_type = atoi(tmp); */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2859 tmp = strtok(NULL, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2860 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2862 if (tmp) /* timestamp */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2863 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2864 pkt->cal_timestamp = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2865 tmp = strtok(NULL, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2866 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2867
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2868 if (tmp) /* title */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2870 pkt->cal_title = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2871 tmp = strtok(NULL, delim); /* use delim since it won't occur again */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2872 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2873
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2874 if (tmp)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2875 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2876 pkt->cal_description = strdup(tmp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2877 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2878
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2879 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2880 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2881 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2882
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2883 int yahoo_parsepacket_chatinvite(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2884 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2885 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2886 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2887 int len;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2888
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2889 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2890 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2891 len = strlen(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2892
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2893 /* do special parsing for invite later on */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2894 pkt->chat_invite_content = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2895
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2896 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2897 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2898
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2899 int yahoo_parsepacket_newcontact(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2900 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2901 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2902 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2903 int len;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2904
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2905 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2906 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2907 len = strlen(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2908
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2909 /* cheat for now, say if first digit is number */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2910 if (len > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2911 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2912 if (isdigit((int) content[0]))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2913 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2914 return yahoo_parsepacket_status(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2915 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2916 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2917 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2918 return yahoo_parsepacket_message(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2919 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2920 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2921
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2922 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2923 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2924
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2925 int yahoo_parsepacket_status(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2926 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2927 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2928 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2929 char *tmpc;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2930 char *tmp1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2931 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2932 int len;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2933 int index;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2934 int realcount;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2935
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2936 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2937 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2938 len = strlen(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2939
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2940 /* Pull off the flag from the initial part of the content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2941 /* this flag indicates the number of buddy that're online */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2942 pkt->flag = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2943 tmpc = content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2944 while (tmpc[0] && isdigit((int) tmpc[0]))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2945 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2946 pkt->flag = pkt->flag * 10 + (content[0] - '0');
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2947 tmpc++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2948 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2949 if (tmpc[0] && tmpc[0] == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2950 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2951 tmpc++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2952 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2953
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2954 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2955 We're receiving either this:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2956 2,buddy1(0,728EE9FB,0,1,0,0),buddy2(0,7AC00000,0,1,0,0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2957 or this:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2958 buddy1(0,728EE9FB,0,1,0,0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2959 hence:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2960 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2961
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2962 if (pkt->flag == 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2963 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2964 pkt->idstatus_count = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2965 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2966 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2967 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2968 pkt->idstatus_count = pkt->flag;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2969 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2970
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2971 /* print an error if I get the was not AWAY */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2972 if (strstr(tmpc, "was not AWAY"))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2973 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2974 pkt->idstatus_count = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2975 yahoo_dbg_Print("libyahoo", "yahoo_parsepacket_status: "
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2976 "got a 'was not AWAY' message\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2977 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2978
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2979 if (pkt->idstatus_count == 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2980 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2981 /* No entries, so no array needed */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2982 pkt->idstatus = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2983 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2984 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2985 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2986 /* Allocate the array */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2987 pkt->idstatus = (struct yahoo_idstatus **)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2988 calloc(sizeof(struct yahoo_idstatus), pkt->idstatus_count);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2989
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2990 for (i = 0; i < pkt->idstatus_count; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2991 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2992 pkt->idstatus[i] = (struct yahoo_idstatus *)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2993
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2994 calloc(1, sizeof(struct yahoo_idstatus));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2995 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2996 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2997
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2998 index = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2999 tmp1 = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3000 realcount = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3001 while (tmpc && tmpc[0] && pkt->idstatus)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3002 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3003 struct yahoo_idstatus *tmpid;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3004
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3005 /* Get pointer to allocated structure to hold status data */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3006 tmpid = pkt->idstatus[index++];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3007 if (!tmpid)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3008 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3009 /* shortcut, we know there can't be any more status entries
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3010 at this point */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3011 /* yahoo_dbg_Print("status", "null tmpid"); */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3012 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3013 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3014
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3015 /* YPNS2.0 nick(status,msg,connection_id,UNK,in_pager,in_chat,in_game) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3016 /* tnneul(99,test,message^A,6AD68325,0,1,0,0) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3017 /* 0 1 2 3 4 5 6 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3018
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3019 /* YPNS1.0 nick(status,connection_id,UNK,in_pager,in_chat,in_game) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3020 /* nneul(0,7081F531,0,1,0,0) */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3021 /* 0 2 3 4 5 6 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3022
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3023 /* rewrite this whole section in a less ugly fashion */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3024 /* first pull off the id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3025
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3026 /* YUCK - YPNS2.0 has variable format status records, if type is 99,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3027 it has 7 fields, second is msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3028
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3029 #if 0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3030 yahoo_dbg_Print("status", "whole string = '%s'\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3031 yahoo_dbg_NullCheck(tmpc));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3032 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3033
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3034 if (tmp1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3035 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3036 tmp1 = strtok(NULL, "(");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3037 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3038 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3039 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3040 tmp1 = strtok(tmpc, "(");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3041 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3042 if (tmp1 && tmp1[0] == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3043 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3044 tmp1++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3045 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3046
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3047 if (tmp1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3048 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3049 tmpid->id = strdup(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3050 realcount++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3051
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3052 for (i = 0; i <= 6 && tmp1; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3053 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3054 #if 0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3055 yahoo_dbg_Print("status", "i==%d\n", i);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3056 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3057
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3058 if (i == 6) /* end of status area */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3059 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3060 tmp1 = strtok(NULL, "),");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3061 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3062 else if (i == 1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3063 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3064 char delim[3];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3065
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3066 if (tmpid->status == YAHOO_STATUS_CUSTOM)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3067 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3068 delim[0] = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3069 delim[1] = ',';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3070 delim[1] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3071 tmp1 = strtok(NULL, delim);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3072 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3073 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3074 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3075 i = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3076 tmp1 = strtok(NULL, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3077 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3078 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3079 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3080 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3081
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3082 tmp1 = strtok(NULL, ",");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3083 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3084
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3085 /* then pull off the particular element of the list */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3086 if (tmp1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3087 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3088 switch (i)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3089 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3090 case 0: /* status */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3091 tmpid->status = atoi(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3092 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3093 case 1: /* msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3094 if (tmpid->status == YAHOO_STATUS_CUSTOM)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3095 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3096 tmpid->status_msg = strdup(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3097 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3098 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3099 case 2: /* session id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3100 tmpid->connection_id = strdup(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3101 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3102 case 3: /* dunno what this is */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3103 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3104 case 4:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3105 tmpid->in_pager = atoi(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3106 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3107 case 5:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3108 tmpid->in_chat = atoi(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3109 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3110 case 6:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3111 tmpid->in_game = atoi(tmp1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3112 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3113 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3114 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3115 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3116 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3117 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3118
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3119 for (i = realcount; i <= pkt->idstatus_count; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3120 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3121 if (pkt->idstatus && pkt->idstatus[i])
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3122 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3123 FREE(pkt->idstatus[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3124 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3125 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3126 pkt->idstatus_count = realcount;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3127
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3128 /* Free working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3129 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3130
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3131 /* Return ok for success */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3132 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3133 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3134
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3135 int yahoo_parsepacket_message(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3136 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3137 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3138 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3139 char *tmp_id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3140 int i, j, section;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3141
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3142 if (pkt->msgtype == YAHOO_MSGTYPE_OFFLINE)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3143 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3144 return yahoo_parsepacket_message_offline(ctx, pkt, inpkt);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3145 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3146
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3147 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3148 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3149 tmp_id = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3150
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3151 /* initialize */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3152 pkt->msg_status = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3153
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3154 /* possible message content formats: */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3155 /* userid(#) *//* msgtype == YAHOO_MSGTYPE_STATUS */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3156 /* userid,,msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3157
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3158 /* this needed butchered */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3159 /* YAHOO_MSGTYPE_OFFLINE */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3160 /* 6,6,tnneul,nneul,Tue Mar 7 12:14:50 2000,test offline msg^A */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3161
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3162 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3163 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3164 section = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3165 tmp_id[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3166 while (i < strlen(content))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3167 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3168 char ch = content[i];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3169
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3170 if (section == 0) /* parsing userid */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3171 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3172 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3173 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3174 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3175 section = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3176 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3177 else if (ch == '(')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3178 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3179 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3180 section = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3181 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3182 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3183 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3184 tmp_id[j++] = ch;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3185 tmp_id[j] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3186 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3187 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3188 else if (section == 1) /* parsing flag */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3189 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3190 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3191 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3192 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3193 section = 3;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3194 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3195 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3196 else if (section == 2) /* parsing status */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3197 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3198 if (ch == ')')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3199 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3200 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3201 section = 3;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3202 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3203 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3204 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3205 if (isdigit((int) ch))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3206 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3207 pkt->msg_status *= 10;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3208 pkt->msg_status += ch - '0';
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3209 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3210 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3211 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3212 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3213 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3214 pkt->msg = strdup(&content[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3215 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3216 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3217
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3218 i++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3219 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3220
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3221 /* do stuff with extracted parts */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3222 pkt->msg_id = strdup(tmp_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3223
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3224 /* handle empty message case */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3225 /* don't pass a message if it's just a status update */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3226 if (!pkt->msg && pkt->msgtype != YAHOO_MSGTYPE_STATUS)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3227 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3228 pkt->msg = strdup("");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3229 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3230
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3231 /* free working variables */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3232 FREE(tmp_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3233 FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3234
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3235 /* Return ok for success */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3236 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3237 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3238
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3239 /* This parses a special format offline message, and is only currently
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3240 called from yahoo_parsepacket_message. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3241 int yahoo_parsepacket_message_offline(struct yahoo_context *ctx,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3242 struct yahoo_packet *pkt, struct yahoo_rawpacket *inpkt)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3243 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3244 char *content;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3245 char *to_id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3246 char *from_id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3247 char *timestamp;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3248 int i, j, section;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3249
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3250 /* Make working copy of content */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3251 content = strdup(inpkt->content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3252 to_id = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3253 from_id = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3254 timestamp = strdup(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3255
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3256 /* initialize */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3257 pkt->msg_status = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3258
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3259 /* 6,6,tnneul,nneul,Tue Mar 7 12:14:50 2000,test offline msg^A */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3260 /* sec0,sec1,sec2=to,sec3=from,sec4=tstamp,sec5=msg */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3261
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3262 i = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3263 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3264 section = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3265 to_id[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3266 from_id[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3267 timestamp[0] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3268
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3269 while (i < strlen(content))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3270 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3271 char ch = content[i];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3272
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3273 if (section == 0) /* parsing first unknown number */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3274 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3275 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3276 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3277 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3278 section = 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3279 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3280 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3281 else if (section == 1) /* parsing second unknown number */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3282 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3283 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3284 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3285 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3286 section = 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3287 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3288 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3289 else if (section == 2) /* parsing to-id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3290 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3291 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3292 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3293 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3294 section = 3;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3295 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3296 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3297 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3298 to_id[j++] = ch;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3299 to_id[j] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3300 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3301 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3302 else if (section == 3) /* parsing from-id */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3303 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3304 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3305 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3306 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3307 section = 4;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3308 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3309 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3310 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3311 from_id[j++] = ch;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3312 from_id[j] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3313 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3314 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3315 else if (section == 4) /* parsing timestamp */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3316 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3317 if (ch == ',')
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3318 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3319 j = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3320 section = 5;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3321 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3322 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3323 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3324 timestamp[j++] = ch;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3325 timestamp[j] = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3326 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3327 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3328 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3329 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3330 pkt->msg = strdup(&content[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3331 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3332 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3333
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3334 i++;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3335 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3336
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3337 /* do stuff with extracted parts */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3338 pkt->msg_id = strdup(from_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3339 pkt->msg_timestamp = strdup(timestamp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3340 if (pkt->active_id)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3341 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3342 FREE(pkt->active_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3343 pkt->active_id = strdup(to_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3344 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3345
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3346 /* free working variables */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3347 FREE(timestamp);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3348 FREE(from_id);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3349 FREE(to_id) FREE(content);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3350
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3351 /* Return ok for success */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3352 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3353 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3354
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3355 int yahoo_getdata(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3356 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3357 char buf[1000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3358 int res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3359
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3360 /* This is a http mode connection, so just send a ping to get any
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3361 new data from the server. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3362 if (ctx->connect_mode == YAHOO_CONNECT_HTTP ||
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3363 ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3364 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3365 if (!yahoo_sendcmd(ctx, YAHOO_SERVICE_PING, ctx->user, "", 0))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3366 return 0;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3367 return (1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3368 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3369
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3370 /* Read as much data as is available. */
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3371 /* XXX: doesnt the protocol contain header information with lengths? */
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3372 do {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3373 res = read(ctx->sockfd, buf, sizeof(buf));
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3374 if ((res == -1) && (errno == EINTR))
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3375 continue;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3376 break;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3377 } while (1);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3378
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3379 if (res == -1)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3380 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3381 printf("yahoo_getdata: error reading data from server: %s\n",
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3382 strerror(errno));
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3383 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3384 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3385 else if (res == 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3386 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3387 yahoo_dbg_Print("io",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3388 "[libyahoo] yahoo_getdata: got zero length read\n", res);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3389 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3390 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3391
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3392 yahoo_addtobuffer(ctx, buf, res);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3393 yahoo_dbg_Print("io", "[libyahoo] yahoo_getdata: read (%d) bytes\n", res);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3394
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3395 return 1;
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3396 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3397
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3398 struct yahoo_rawpacket *yahoo_getpacket(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3399 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3400 struct yahoo_rawpacket *pkt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3401 struct yahoo_rawpacket *retpkt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3402 int *buflen = &ctx->io_buf_curlen;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3403 char *buffer = ctx->io_buf;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3404 unsigned int contentlen;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3405
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3406 /* If buffer doesn't start with YHOO, skip bytes until it
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3407 does. This is to protect against possible packet alignment
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3408 errors if I size something wrong at any time. */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3409
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3410 while ((*buflen >= 4) && (memcmp(buffer, "YHOO", 4)))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3411 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3412 /* making quiet for now so I don't have to work too hard on the HTTP support */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3413 #if 0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3414 printf("\nskipped buffer byte (%d)\n", buffer[0]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3415 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3416 memmove(buffer, buffer + 1, *buflen - 1);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3417 *buflen = *buflen - 1;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3418 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3419
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3420 /* Don't do anything if the buffer doesn't have at least a full
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3421 header */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3422 if (*buflen < YAHOO_PACKET_HEADER_SIZE)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3423 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3424 // printf("returning null cause buffer is too small\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3425 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3426 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3427
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3428 /* print out the beginning of the buffer */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3429 #if 0
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3430 printf("Buffer (buflen = %d):\n", *buflen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3431 for (i = 0; i < *buflen; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3432 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3433 if ((i) % 10 == 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3434 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3435 printf("\n%.4d: ", i);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3436 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3437 if (isprint(buffer[i]))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3438 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3439 printf("%-3d %c ", buffer[i], buffer[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3440 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3441 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3442 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3443 printf("%-3d ", buffer[i]);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3444 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3445 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3446 printf("\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3447 #endif
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3448 /* Make pkt point to buffer for ease of use */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3449 pkt = (struct yahoo_rawpacket *) buffer;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3450
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3451 /* Determine the content size specified by the header */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3452 contentlen = yahoo_makeint(pkt->len) - YAHOO_PACKET_HEADER_SIZE;
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3453 #if 0
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3454 printf("contentlen = %d\n", contentlen);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3455 #endif
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3456
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3457 /* Don't continue if buffer doesn't have full content in it */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3458 if (*buflen < (YAHOO_PACKET_HEADER_SIZE + contentlen))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3459 {
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3460 printf("buffer not big enough for contentlen\n");
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3461 return NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3462 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3463
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3464 /* Copy this packet */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3465 retpkt =
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3466 (struct yahoo_rawpacket *) malloc(YAHOO_PACKET_HEADER_SIZE +
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3467 contentlen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3468 memcpy(retpkt, buffer, YAHOO_PACKET_HEADER_SIZE + contentlen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3469
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3470 /* Shift the buffer */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3471 memmove(buffer, buffer + YAHOO_PACKET_HEADER_SIZE + contentlen,
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3472 *buflen - YAHOO_PACKET_HEADER_SIZE - contentlen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3473
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3474 /* Adjust the buffer length */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3475 *buflen -= (YAHOO_PACKET_HEADER_SIZE + contentlen);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3476
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3477 /* Return the packet */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3478 return retpkt;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3479 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3480
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3481 int yahoo_isbuddy(struct yahoo_context *ctx, const char *id)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3482 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3483 int i;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3484 char *buddy = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3485
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3486 if (!id || !ctx || !ctx->buddies)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3487 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3488 return FALSE;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3489 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3490
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3491 for (i = 0; ctx->buddies[i]; i++)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3492 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3493 buddy = (ctx->buddies[i])->id;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3494 if (!strcasecmp(id, buddy))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3495 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3496 return TRUE;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3497 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3498 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3499
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3500 return FALSE;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3501 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3502
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3503 static void yahoo_free_address (struct yahoo_address *add)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3504 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3505 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3506 "[libyahoo] yahoo_free_address: record at address 0x%08p for user %s (%s %s) being free'd\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3507 add, add->id, add->firstname, add->lastname);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3508
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3509 FREE (add->firstname);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3510 FREE (add->lastname);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3511 FREE (add->emailnickname);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3512 FREE (add->email);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3513 FREE (add->workphone);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3514 FREE (add->homephone);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3515 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3516
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3517 void yahoo_freeaddressbook(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3518 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3519 unsigned int count = ctx->address_count;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3520 struct yahoo_address *add_p = ctx->addresses;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3521
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3522 if (NULL == ctx || NULL == ctx->addresses)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3523 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3524
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3525 while (count-- > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3526 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3527 yahoo_free_address (add_p++);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3528 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3529
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3530 ctx->address_count = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3531 FREE (ctx->addresses);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3532 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3533
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3534 static void yahoo_data_to_addressbook (char *block, struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3535 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3536 char *token = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3537 int record = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3538 struct yahoo_address *add = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3539
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3540 if (NULL == block || NULL == ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3541 return;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3542
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3543 yahoo_freeaddressbook (ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3544
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3545 add = ctx->addresses = calloc (ctx->address_count, sizeof (struct yahoo_address));
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3546
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3547 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3548 Okay!
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3549 At this point we have a char * (block) that has \012 delimited records
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3550 Each record (as a string when retreived with strtok) follows the format:
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3551 <ID>:<FIRSTNAME>\011<LASTNAME>\011<EMAILNICKNAME>\011<EMAIL>\011<HOMEPHONE>\011<WORKPHONE>\011[01]\011<ENTRYID>\000
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3552 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3553
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3554 token = strtok (block, "\012");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3555 while (NULL != token)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3556 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3557 /*
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3558 Here we must use memtok because we'll get some repeated tokens!!!!!
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3559 */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3560 char *field = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3561 size_t token_len = 0, found = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3562
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3563 ++record;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3564 token_len = strlen (token);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3565
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3566 field = memtok(token, token_len, ":", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3567
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3568 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3569 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3570 add->id = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3571 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3572 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3573
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3574 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3575 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3576 add->firstname = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3577 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3578 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3579
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3580 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3581 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3582 add->lastname = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3583 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3584 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3585
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3586 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3587 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3588 add->emailnickname = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3589 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3590 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3591
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3592 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3593 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3594 add->email = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3595 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3596 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3597
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3598 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3599 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3600 add->homephone = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3601 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3602 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3603
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3604 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3605 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3606 add->workphone = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3607 field = memtok(0, 0, "\011", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3608 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3609
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3610 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3611 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3612 add->primary_phone = (*field == '0' ? home : work);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3613 field = memtok(0, 0, "", 1, &found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3614 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3615
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3616 if (NULL != field)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3617 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3618 char *entryid = memdupasstr(field, found);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3619 if (NULL != entryid)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3620 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3621 add->entryid = atoi (entryid);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3622 FREE (entryid);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3623 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3624 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3625
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3626 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3627 "[libyahoo] yahoo_fetchaddressbook: record #%d is for user %s (%s %s)\n",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3628 record, add->id, add->firstname, add->lastname);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3629
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3630 ++add;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3631
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3632 token = strtok (NULL, "\012");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3633 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3634 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3635
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3636 /* retreive the details of the friends in your address book that have a Yahoo! id listed */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3637 int yahoo_fetchaddressbook(struct yahoo_context *ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3638 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3639 char buffer[5000];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3640 int servfd;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3641 int res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3642 int copied = 0, size = 5000;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3643 char *address = NULL, *copy = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3644
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3645 if (!ctx)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3646 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3647 return 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3648 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3649
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3650 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3651 "[libyahoo] yahoo_fetchaddressbook: starting\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3652
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3653 /* Check for cached addresses */
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3654 if (ctx->addresses)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3655 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3656 yahoo_freeaddressbook(ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3657 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3658
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3659 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3660 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3661 servfd = yahoo_socket_connect(ctx, ctx->proxy_host, ctx->proxy_port);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3662 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3663 else
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3664 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3665 servfd = yahoo_socket_connect(ctx, YAHOO_ADDRESS_HOST, YAHOO_ADDRESS_PORT);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3666 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3667
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3668 if (servfd < 0)
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3669 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3670 printf("[libyahoo] failed to connect to address book server.\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3671 return (0);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3672 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3673
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3674 strcpy(buffer, "GET ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3675 if (ctx->connect_mode == YAHOO_CONNECT_HTTPPROXY)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3676 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3677 strcat(buffer, YAHOO_ADDRESS_HOST);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3678 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3679 strcat(buffer, "/yab/uk/yab?v=PG&A=s");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3680 strcat(buffer, " HTTP/1.0\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3681 strcat(buffer, "User-Agent: " YAHOO_USER_AGENT "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3682 strcat(buffer, "Host: " YAHOO_AUTH_HOST "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3683 strcat(buffer, "Cookie: ");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3684 strcat(buffer, ctx->cookie);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3685 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3686 strcat(buffer, "\r\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3687
1099
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3688 if (writeall(servfd, buffer, strlen(buffer)) < strlen(buffer)) {
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3689 close(servfd);
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3690 return 0;
4416ead31db7 [gaim-migrate @ 1109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1054
diff changeset
3691 }
1054
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3692
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3693 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3694 "[libyahoo] yahoo_fetchaddressbook: writing buffer '%s'\n", buffer);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3695
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3696 while ((res = yahoo_tcp_readline(buffer, 5000, servfd)) > 0)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3697 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3698 if ('\012' == buffer[0])
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3699 continue;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3700
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3701 if (0 == strncmp (buffer, "1\011", 2))
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3702 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3703 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3704 "[libyahoo] yahoo_fetchaddressbook: found first line\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3705 if (3 == res)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3706 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3707 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3708 "[libyahoo] yahoo_fetchaddressbook: however there's been a problem\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3709 break;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3710 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3711
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3712 address = &buffer[2];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3713 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3714 else if (NULL != address)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3715 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3716 address = &buffer[0];
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3717 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3718
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3719 if (NULL != address)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3720 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3721 if (NULL == copy)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3722 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3723 copy = malloc (size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3724 memset (copy, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3725 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3726
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3727 if ((copied + res) > size)
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3728 {
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3729 char *newcopy = NULL;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3730
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3731 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3732 "[libyahoo] yahoo_fetchaddressbook: resizing buffer from %d bytes to %d bytes\n", size, size * 2);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3733 size *= 2;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3734 newcopy = malloc (size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3735 memset (newcopy, 0, size);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3736 memcpy (newcopy, copy, copied);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3737 free (copy);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3738 copy = newcopy;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3739 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3740
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3741 copied += res;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3742 strcat (copy, address);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3743 ++ctx->address_count;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3744 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3745 }
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3746
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3747 yahoo_data_to_addressbook (copy, ctx);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3748 FREE (copy);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3749
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3750 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3751 "[libyahoo] yahoo_fetchaddressbook: closing server connection\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3752 close(servfd);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3753 servfd = 0;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3754 yahoo_dbg_Print("addressbook",
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3755 "[libyahoo] yahoo_fetchaddressbook: closed server connection\n");
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3756
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3757 yahoo_dbg_Print("addressbook", "[libyahoo] yahoo_fetchaddressbook: done (%d addresses retreived)\n", ctx->address_count);
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3758
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3759 return ctx->address_count;
0b0b4cb53c17 [gaim-migrate @ 1064]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3760 }