comparison src/protocols/yahoo/buddy.c @ 2086:424a40f12a6c

[gaim-migrate @ 2096] moving protocols from plugins/ to src/protocols. making it so that you can select which protocols are compiled statically. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 31 Jul 2001 01:00:39 +0000
parents
children 704a07ed9481
comparison
equal deleted inserted replaced
2085:7ebb4322f89b 2086:424a40f12a6c
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 }
51 if (message && strlen(message) && !(msg = yahoo_urlencode(message))) {
52 g_free(grp);
53 g_free(bdy);
54 g_free(id);
55 g_free(usr);
56 return 0;
57 }
58
59 send = g_strconcat("GET ",
60 session->proxy_type ? "http://" : "",
61 session->proxy_type ? session->auth_host : "",
62 "/config/set_buddygrp?.bg=", grp,
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: ", session->auth_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);
76 if (message && strlen(message))
77 g_free(msg);
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 }
117 if (message && strlen(message) && !(msg = yahoo_urlencode(message))) {
118 g_free(grp);
119 g_free(bdy);
120 g_free(id);
121 g_free(usr);
122 return 0;
123 }
124
125 send = g_strconcat("GET ",
126 session->proxy_type ? "http://" : "",
127 session->proxy_type ? session->auth_host : "",
128 "/config/set_buddygrp?.bg=", grp,
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: ", session->auth_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);
142 if (message && strlen(message))
143 g_free(msg);
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 }