Mercurial > pidgin.yaz
view libpurple/protocols/oscar/authorization.c @ 30818:9d386bf63eab
Stop using custom encodings (and LATIN-1, for that matter) for sending
OSCAR messages (ICBM, chat, Direct IM). Now, we use ASCII if a message
contains ASCII characters only, and UTF-16 in all other cases.
That fixes #10833 (offline messages now will be sent as UTF-16)
and also a whole bunch of potential problems we can get
with charset 0x3. Different clients tend to interpret this
charset differently; for instance, the official client
always interprets it as LATIN-1, while alternative
clients may decode it as some other user-specified
8-bit encoding. On the other hand, ASCII messages
(charset 0x0) and UTF-16 messages (charset 0x2) are understood
uniformly by all clients.
I also cleaned-up the code a little (got rid of code paths that were
never executed, flags that were always set, unused struct members, etc.)
author | ivan.komarov@soc.pidgin.im |
---|---|
date | Tue, 27 Jul 2010 21:17:01 +0000 |
parents | 9881f18b95b1 |
children | a8cc50c2279f |
line wrap: on
line source
/* * Purple's oscar protocol plugin * This file is the legal property of its developers. * Please see the AUTHORS file distributed alongside this file. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ /* * Everything related to OSCAR authorization requests. */ #include "oscar.h" #include "request.h" static void oscar_auth_request(struct name_data *data, char *msg) { PurpleConnection *gc; OscarData *od; PurpleAccount *account; PurpleBuddy *buddy; PurpleGroup *group; const char *bname, *gname; gc = data->gc; od = purple_connection_get_protocol_data(gc); account = purple_connection_get_account(gc); buddy = purple_find_buddy(account, data->name); if (buddy != NULL) group = purple_buddy_get_group(buddy); else group = NULL; if (group != NULL) { bname = purple_buddy_get_name(buddy); gname = purple_group_get_name(group); purple_debug_info("oscar", "ssi: adding buddy %s to group %s\n", bname, gname); aim_ssi_sendauthrequest(od, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); if (!aim_ssi_itemlist_finditem(od->ssi.local, gname, bname, AIM_SSI_TYPE_BUDDY)) { aim_ssi_addbuddy(od, bname, gname, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, TRUE); /* Mobile users should always be online */ if (bname[0] == '+') { purple_prpl_got_user_status(account, purple_buddy_get_name(buddy), OSCAR_STATUS_ID_AVAILABLE, NULL); purple_prpl_got_user_status(account, purple_buddy_get_name(buddy), OSCAR_STATUS_ID_MOBILE, NULL); } } } oscar_free_name_data(data); } static void oscar_auth_grant(gpointer cbdata) { struct name_data *data = cbdata; PurpleConnection *gc = data->gc; OscarData *od = purple_connection_get_protocol_data(gc); aim_ssi_sendauthreply(od, data->name, 0x01, NULL); oscar_free_name_data(data); } static void oscar_auth_dontgrant(struct name_data *data, char *msg) { PurpleConnection *gc = data->gc; OscarData *od = purple_connection_get_protocol_data(gc); aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given.")); oscar_free_name_data(data); } static void oscar_auth_dontgrant_msgprompt(gpointer cbdata) { struct name_data *data = cbdata; purple_request_input(data->gc, NULL, _("Authorization Denied Message:"), NULL, _("No reason given."), TRUE, FALSE, NULL, _("_OK"), G_CALLBACK(oscar_auth_dontgrant), _("_Cancel"), G_CALLBACK(oscar_free_name_data), purple_connection_get_account(data->gc), data->name, NULL, data); } /* When you ask other people for authorization */ void oscar_auth_sendrequest(PurpleConnection *gc, const char *name) { struct name_data *data; data = g_new0(struct name_data, 1); data->gc = gc; data->name = g_strdup(name); purple_request_input(data->gc, NULL, _("Authorization Request Message:"), NULL, _("Please authorize me!"), TRUE, FALSE, NULL, _("_OK"), G_CALLBACK(oscar_auth_request), _("_Cancel"), G_CALLBACK(oscar_free_name_data), purple_connection_get_account(gc), name, NULL, data); } void oscar_auth_sendrequest_menu(PurpleBlistNode *node, gpointer ignored) { PurpleBuddy *buddy; PurpleConnection *gc; g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; gc = purple_account_get_connection(purple_buddy_get_account(buddy)); oscar_auth_sendrequest(gc, purple_buddy_get_name(buddy)); } /* When other people ask you for authorization */ void oscar_auth_recvrequest(PurpleConnection *gc, gchar *name, gchar *nick, gchar *reason) { PurpleAccount* account = purple_connection_get_account(gc); struct name_data *data = g_new(struct name_data, 1); data->gc = gc; data->name = name; data->nick = nick; purple_account_request_authorization(account, data->name, NULL, data->nick, reason, purple_find_buddy(account, data->name) != NULL, oscar_auth_grant, oscar_auth_dontgrant_msgprompt, data); }