Mercurial > pidgin.yaz
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/protocols/yahoo/buddy.c Tue Jul 31 01:00:39 2001 +0000 @@ -0,0 +1,154 @@ +/* + * libyay + * + * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "internal.h" + +int yahoo_add_buddy(struct yahoo_session *session, const char *active_id, + const char *group, const char *buddy, const char *message) +{ + struct yahoo_conn *conn; + char *send; + char *grp, *bdy, *id, *msg = "", *usr; + + if (!session || !active_id || !group || !buddy) + return 0; + + if (!(grp = yahoo_urlencode(group))) + return 0; + if (!(bdy = yahoo_urlencode(buddy))) { + g_free(grp); + return 0; + } + if (!(id = yahoo_urlencode(active_id))) { + g_free(grp); + g_free(bdy); + return 0; + } + if (!(usr = yahoo_urlencode(session->name))) { + g_free(grp); + g_free(bdy); + g_free(id); + return 0; + } + if (message && strlen(message) && !(msg = yahoo_urlencode(message))) { + g_free(grp); + g_free(bdy); + g_free(id); + g_free(usr); + return 0; + } + + send = g_strconcat("GET ", + session->proxy_type ? "http://" : "", + session->proxy_type ? session->auth_host : "", + "/config/set_buddygrp?.bg=", grp, + "&.src=bl&.cmd=a&.bdl=", bdy, + "&.id=", id, + "&.l=", usr, + "&.amsg=", msg, + " HTTP/1.0\r\n", + "User-Agent: " YAHOO_USER_AGENT "\r\n" + "Host: ", session->auth_host, "\r\n" + "Cookie: ", session->cookie, + "\r\n\r\n", NULL); + g_free(grp); + g_free(bdy); + g_free(id); + g_free(usr); + if (message && strlen(message)) + g_free(msg); + + if (!send) + return 0; + + if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, NULL, 0))) + return 0; + + conn->txqueue = send; + + return 1; +} + +int yahoo_remove_buddy(struct yahoo_session *session, const char *active_id, + const char *group, const char *buddy, const char *message) +{ + struct yahoo_conn *conn; + char *send; + char *grp, *bdy, *id, *msg = "", *usr; + + if (!session || !active_id || !group || !buddy) + return 0; + + if (!(grp = yahoo_urlencode(group))) + return 0; + if (!(bdy = yahoo_urlencode(buddy))) { + g_free(grp); + return 0; + } + if (!(id = yahoo_urlencode(active_id))) { + g_free(grp); + g_free(bdy); + return 0; + } + if (!(usr = yahoo_urlencode(session->name))) { + g_free(grp); + g_free(bdy); + g_free(id); + return 0; + } + if (message && strlen(message) && !(msg = yahoo_urlencode(message))) { + g_free(grp); + g_free(bdy); + g_free(id); + g_free(usr); + return 0; + } + + send = g_strconcat("GET ", + session->proxy_type ? "http://" : "", + session->proxy_type ? session->auth_host : "", + "/config/set_buddygrp?.bg=", grp, + "&.src=bl&.cmd=d&.bdl=", bdy, + "&.id=", id, + "&.l=", usr, + "&.amsg=", msg, + " HTTP/1.0\r\n", + "User-Agent: " YAHOO_USER_AGENT "\r\n" + "Host: ", session->auth_host, "\r\n" + "Cookie: ", session->cookie, + "\r\n\r\n", NULL); + g_free(grp); + g_free(bdy); + g_free(id); + g_free(usr); + if (message && strlen(message)) + g_free(msg); + + if (!send) + return 0; + + if (!(conn = yahoo_new_conn(session, YAHOO_CONN_TYPE_DUMB, NULL, 0))) + return 0; + + conn->txqueue = send; + + return 1; +}