comparison plugins/yay/buddy.c @ 1546:92b3dd1e4129

[gaim-migrate @ 1556] libyay. no more libyahoo. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 08 Mar 2001 09:18:58 +0000
parents
children bf10d0673d34
comparison
equal deleted inserted replaced
1545:34a5a436d04d 1546:92b3dd1e4129
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 && !(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 /config/set_buddygrp?.bg=", grp,
60 "&.src=bl&.cmd=a&.bdl=", bdy,
61 "&.id=", id,
62 "&.l=", usr,
63 "&.amsg=", msg,
64 " HTTP/1.0\r\n",
65 "User-Agent: " YAHOO_USER_AGENT "\r\n"
66 "Host: " YAHOO_DATA_HOST "\r\n"
67 "Cookie: ", session->cookie,
68 "\r\n\r\n", NULL);
69 g_free(grp);
70 g_free(bdy);
71 g_free(id);
72 g_free(usr);
73
74 if (!send)
75 return 0;
76
77 if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, NULL, 0)))
78 return 0;
79
80 conn->txqueue = send;
81
82 return 1;
83 }
84
85 int yahoo_remove_buddy(struct yahoo_session *session, const char *active_id,
86 const char *group, const char *buddy, const char *message)
87 {
88 struct yahoo_conn *conn;
89 char *send;
90 char *grp, *bdy, *id, *msg = "", *usr;
91
92 if (!session || !active_id || !group || !buddy)
93 return 0;
94
95 if (!(grp = yahoo_urlencode(group)))
96 return 0;
97 if (!(bdy = yahoo_urlencode(buddy))) {
98 g_free(grp);
99 return 0;
100 }
101 if (!(id = yahoo_urlencode(active_id))) {
102 g_free(grp);
103 g_free(bdy);
104 return 0;
105 }
106 if (!(usr = yahoo_urlencode(session->name))) {
107 g_free(grp);
108 g_free(bdy);
109 g_free(id);
110 return 0;
111 }
112 if (message && !(msg = yahoo_urlencode(message))) {
113 g_free(grp);
114 g_free(bdy);
115 g_free(id);
116 g_free(usr);
117 return 0;
118 }
119
120 send = g_strconcat("GET /config/set_buddygrp?.bg=", grp,
121 "&.src=bl&.cmd=d&.bdl=", bdy,
122 "&.id=", id,
123 "&.l=", usr,
124 "&.amsg=", msg,
125 " HTTP/1.0\r\n",
126 "User-Agent: " YAHOO_USER_AGENT "\r\n"
127 "Host: " YAHOO_DATA_HOST "\r\n"
128 "Cookie: ", session->cookie,
129 "\r\n\r\n", NULL);
130 g_free(grp);
131 g_free(bdy);
132 g_free(id);
133 g_free(usr);
134
135 if (!send)
136 return 0;
137
138 if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, NULL, 0)))
139 return 0;
140
141 conn->txqueue = send;
142
143 return 1;
144 }