Mercurial > pidgin.yaz
annotate src/protocols/yahoo/buddy.c @ 2162:a464da684307
[gaim-migrate @ 2172]
couple fixes. Max Horn told me about one of them.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 24 Aug 2001 01:36:05 +0000 |
parents | 1779daad8cc3 |
children |
rev | line source |
---|---|
2086 | 1 /* |
2 * libyay | |
3 * | |
4 * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #include "internal.h" | |
2135
1779daad8cc3
[gaim-migrate @ 2145]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2110
diff
changeset
|
23 #include <string.h> |
2086 | 24 |
25 int yahoo_add_buddy(struct yahoo_session *session, const char *active_id, | |
26 const char *group, const char *buddy, const char *message) | |
27 { | |
28 struct yahoo_conn *conn; | |
29 char *send; | |
30 char *grp, *bdy, *id, *msg = "", *usr; | |
31 | |
32 if (!session || !active_id || !group || !buddy) | |
33 return 0; | |
34 | |
35 if (!(grp = yahoo_urlencode(group))) | |
36 return 0; | |
37 if (!(bdy = yahoo_urlencode(buddy))) { | |
38 g_free(grp); | |
39 return 0; | |
40 } | |
41 if (!(id = yahoo_urlencode(active_id))) { | |
42 g_free(grp); | |
43 g_free(bdy); | |
44 return 0; | |
45 } | |
46 if (!(usr = yahoo_urlencode(session->name))) { | |
47 g_free(grp); | |
48 g_free(bdy); | |
49 g_free(id); | |
50 return 0; | |
51 } | |
52 if (message && strlen(message) && !(msg = yahoo_urlencode(message))) { | |
53 g_free(grp); | |
54 g_free(bdy); | |
55 g_free(id); | |
56 g_free(usr); | |
57 return 0; | |
58 } | |
59 | |
60 send = g_strconcat("GET ", | |
61 session->proxy_type ? "http://" : "", | |
62 session->proxy_type ? session->auth_host : "", | |
63 "/config/set_buddygrp?.bg=", grp, | |
64 "&.src=bl&.cmd=a&.bdl=", bdy, | |
65 "&.id=", id, | |
66 "&.l=", usr, | |
67 "&.amsg=", msg, | |
68 " HTTP/1.0\r\n", | |
69 "User-Agent: " YAHOO_USER_AGENT "\r\n" | |
70 "Host: ", session->auth_host, "\r\n" | |
71 "Cookie: ", session->cookie, | |
72 "\r\n\r\n", NULL); | |
73 g_free(grp); | |
74 g_free(bdy); | |
75 g_free(id); | |
76 g_free(usr); | |
77 if (message && strlen(message)) | |
78 g_free(msg); | |
79 | |
80 if (!send) | |
81 return 0; | |
82 | |
2110
704a07ed9481
[gaim-migrate @ 2120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
83 if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, session->auth_host, |
704a07ed9481
[gaim-migrate @ 2120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
84 session->auth_port))) |
2086 | 85 return 0; |
86 | |
87 conn->txqueue = send; | |
88 | |
89 return 1; | |
90 } | |
91 | |
92 int yahoo_remove_buddy(struct yahoo_session *session, const char *active_id, | |
93 const char *group, const char *buddy, const char *message) | |
94 { | |
95 struct yahoo_conn *conn; | |
96 char *send; | |
97 char *grp, *bdy, *id, *msg = "", *usr; | |
98 | |
99 if (!session || !active_id || !group || !buddy) | |
100 return 0; | |
101 | |
102 if (!(grp = yahoo_urlencode(group))) | |
103 return 0; | |
104 if (!(bdy = yahoo_urlencode(buddy))) { | |
105 g_free(grp); | |
106 return 0; | |
107 } | |
108 if (!(id = yahoo_urlencode(active_id))) { | |
109 g_free(grp); | |
110 g_free(bdy); | |
111 return 0; | |
112 } | |
113 if (!(usr = yahoo_urlencode(session->name))) { | |
114 g_free(grp); | |
115 g_free(bdy); | |
116 g_free(id); | |
117 return 0; | |
118 } | |
119 if (message && strlen(message) && !(msg = yahoo_urlencode(message))) { | |
120 g_free(grp); | |
121 g_free(bdy); | |
122 g_free(id); | |
123 g_free(usr); | |
124 return 0; | |
125 } | |
126 | |
127 send = g_strconcat("GET ", | |
128 session->proxy_type ? "http://" : "", | |
129 session->proxy_type ? session->auth_host : "", | |
130 "/config/set_buddygrp?.bg=", grp, | |
131 "&.src=bl&.cmd=d&.bdl=", bdy, | |
132 "&.id=", id, | |
133 "&.l=", usr, | |
134 "&.amsg=", msg, | |
135 " HTTP/1.0\r\n", | |
136 "User-Agent: " YAHOO_USER_AGENT "\r\n" | |
137 "Host: ", session->auth_host, "\r\n" | |
138 "Cookie: ", session->cookie, | |
139 "\r\n\r\n", NULL); | |
140 g_free(grp); | |
141 g_free(bdy); | |
142 g_free(id); | |
143 g_free(usr); | |
144 if (message && strlen(message)) | |
145 g_free(msg); | |
146 | |
147 if (!send) | |
148 return 0; | |
149 | |
2110
704a07ed9481
[gaim-migrate @ 2120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
150 if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, session->auth_host, |
704a07ed9481
[gaim-migrate @ 2120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
151 session->auth_port))) |
2086 | 152 return 0; |
153 | |
154 conn->txqueue = send; | |
155 | |
156 return 1; | |
157 } |