Mercurial > pidgin
annotate plugins/yay/buddy.c @ 1891:1c977d995da9
[gaim-migrate @ 1901]
yahoo doesn't have to notify you of mail.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 24 May 2001 21:34:26 +0000 |
parents | 2c66d386be90 |
children | dff412b306b8 |
rev | line source |
---|---|
1546 | 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" | |
23 | |
24 int yahoo_add_buddy(struct yahoo_session *session, const char *active_id, | |
25 const char *group, const char *buddy, const char *message) | |
26 { | |
27 struct yahoo_conn *conn; | |
28 char *send; | |
29 char *grp, *bdy, *id, *msg = "", *usr; | |
30 | |
31 if (!session || !active_id || !group || !buddy) | |
32 return 0; | |
33 | |
34 if (!(grp = yahoo_urlencode(group))) | |
35 return 0; | |
36 if (!(bdy = yahoo_urlencode(buddy))) { | |
37 g_free(grp); | |
38 return 0; | |
39 } | |
40 if (!(id = yahoo_urlencode(active_id))) { | |
41 g_free(grp); | |
42 g_free(bdy); | |
43 return 0; | |
44 } | |
45 if (!(usr = yahoo_urlencode(session->name))) { | |
46 g_free(grp); | |
47 g_free(bdy); | |
48 g_free(id); | |
49 return 0; | |
50 } | |
1553
bf10d0673d34
[gaim-migrate @ 1563]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1546
diff
changeset
|
51 if (message && strlen(message) && !(msg = yahoo_urlencode(message))) { |
1546 | 52 g_free(grp); |
53 g_free(bdy); | |
54 g_free(id); | |
55 g_free(usr); | |
56 return 0; | |
57 } | |
58 | |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
59 send = g_strconcat("GET ", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
60 session->proxy_type ? "http://" : "", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
61 session->proxy_type ? YAHOO_DATA_HOST : "", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
62 "/config/set_buddygrp?.bg=", grp, |
1546 | 63 "&.src=bl&.cmd=a&.bdl=", bdy, |
64 "&.id=", id, | |
65 "&.l=", usr, | |
66 "&.amsg=", msg, | |
67 " HTTP/1.0\r\n", | |
68 "User-Agent: " YAHOO_USER_AGENT "\r\n" | |
69 "Host: " YAHOO_DATA_HOST "\r\n" | |
70 "Cookie: ", session->cookie, | |
71 "\r\n\r\n", NULL); | |
72 g_free(grp); | |
73 g_free(bdy); | |
74 g_free(id); | |
75 g_free(usr); | |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
76 if (message && strlen(message)) |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
77 g_free(msg); |
1546 | 78 |
79 if (!send) | |
80 return 0; | |
81 | |
82 if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, NULL, 0))) | |
83 return 0; | |
84 | |
85 conn->txqueue = send; | |
86 | |
87 return 1; | |
88 } | |
89 | |
90 int yahoo_remove_buddy(struct yahoo_session *session, const char *active_id, | |
91 const char *group, const char *buddy, const char *message) | |
92 { | |
93 struct yahoo_conn *conn; | |
94 char *send; | |
95 char *grp, *bdy, *id, *msg = "", *usr; | |
96 | |
97 if (!session || !active_id || !group || !buddy) | |
98 return 0; | |
99 | |
100 if (!(grp = yahoo_urlencode(group))) | |
101 return 0; | |
102 if (!(bdy = yahoo_urlencode(buddy))) { | |
103 g_free(grp); | |
104 return 0; | |
105 } | |
106 if (!(id = yahoo_urlencode(active_id))) { | |
107 g_free(grp); | |
108 g_free(bdy); | |
109 return 0; | |
110 } | |
111 if (!(usr = yahoo_urlencode(session->name))) { | |
112 g_free(grp); | |
113 g_free(bdy); | |
114 g_free(id); | |
115 return 0; | |
116 } | |
1553
bf10d0673d34
[gaim-migrate @ 1563]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1546
diff
changeset
|
117 if (message && strlen(message) && !(msg = yahoo_urlencode(message))) { |
1546 | 118 g_free(grp); |
119 g_free(bdy); | |
120 g_free(id); | |
121 g_free(usr); | |
122 return 0; | |
123 } | |
124 | |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
125 send = g_strconcat("GET ", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
126 session->proxy_type ? "http://" : "", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
127 session->proxy_type ? YAHOO_DATA_HOST : "", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
128 "/config/set_buddygrp?.bg=", grp, |
1546 | 129 "&.src=bl&.cmd=d&.bdl=", bdy, |
130 "&.id=", id, | |
131 "&.l=", usr, | |
132 "&.amsg=", msg, | |
133 " HTTP/1.0\r\n", | |
134 "User-Agent: " YAHOO_USER_AGENT "\r\n" | |
135 "Host: " YAHOO_DATA_HOST "\r\n" | |
136 "Cookie: ", session->cookie, | |
137 "\r\n\r\n", NULL); | |
138 g_free(grp); | |
139 g_free(bdy); | |
140 g_free(id); | |
141 g_free(usr); | |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
142 if (message && strlen(message)) |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
143 g_free(msg); |
1546 | 144 |
145 if (!send) | |
146 return 0; | |
147 | |
148 if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, NULL, 0))) | |
149 return 0; | |
150 | |
151 conn->txqueue = send; | |
152 | |
153 return 1; | |
154 } |