2 * Purple's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 * Everything related to OSCAR authorization requests.
28 /* When you ask other people for authorization */
30 oscar_auth_sendrequest(PurpleConnection
*gc
, const char *bname
, const char *msg
)
33 PurpleAccount
*account
;
38 od
= purple_connection_get_protocol_data(gc
);
39 account
= purple_connection_get_account(gc
);
40 buddy
= purple_blist_find_buddy(account
, bname
);
42 group
= purple_buddy_get_group(buddy
);
48 gname
= purple_group_get_name(group
);
49 purple_debug_info("oscar", "ssi: adding buddy %s to group %s\n",
51 aim_ssi_sendauthrequest(od
, bname
, msg
? msg
: _("Please authorize me so I can add you to my buddy list."));
52 if (!aim_ssi_itemlist_finditem(&od
->ssi
.local
, gname
, bname
, AIM_SSI_TYPE_BUDDY
))
54 aim_ssi_addbuddy(od
, bname
, gname
, NULL
, purple_buddy_get_alias_only(buddy
), NULL
, NULL
, TRUE
);
56 /* Mobile users should always be online */
57 if (bname
[0] == '+') {
58 purple_protocol_got_user_status(account
,
59 purple_buddy_get_name(buddy
),
60 OSCAR_STATUS_ID_AVAILABLE
, NULL
);
61 purple_protocol_got_user_status(account
,
62 purple_buddy_get_name(buddy
),
63 OSCAR_STATUS_ID_MOBILE
, NULL
);
70 oscar_auth_grant(const char *message
, gpointer cbdata
)
72 struct name_data
*data
= cbdata
;
73 PurpleConnection
*gc
= data
->gc
;
74 OscarData
*od
= purple_connection_get_protocol_data(gc
);
76 aim_ssi_sendauthreply(od
, data
->name
, 0x01, NULL
);
78 oscar_free_name_data(data
);
82 oscar_auth_dontgrant(const char *msg
, gpointer cbdata
)
84 struct name_data
*data
= cbdata
;
85 PurpleConnection
*gc
= data
->gc
;
86 OscarData
*od
= purple_connection_get_protocol_data(gc
);
88 aim_ssi_sendauthreply(od
, data
->name
, 0x00, msg
? msg
: _("No reason given."));
90 oscar_free_name_data(data
);
94 oscar_auth_sendrequest_menu(PurpleBlistNode
*node
, gpointer ignored
)
99 g_return_if_fail(PURPLE_IS_BUDDY(node
));
101 buddy
= (PurpleBuddy
*) node
;
102 gc
= purple_account_get_connection(purple_buddy_get_account(buddy
));
103 oscar_auth_sendrequest(gc
, purple_buddy_get_name(buddy
), NULL
);
106 /* When other people ask you for authorization */
108 oscar_auth_recvrequest(PurpleConnection
*gc
, gchar
*name
, gchar
*nick
, gchar
*reason
)
110 PurpleAccount
* account
= purple_connection_get_account(gc
);
111 struct name_data
*data
= g_new(struct name_data
, 1);
117 purple_account_request_authorization(account
, data
->name
, NULL
, data
->nick
,
118 reason
, purple_blist_find_buddy(account
, data
->name
) != NULL
,
119 oscar_auth_grant
, oscar_auth_dontgrant
, data
);