202
202
void oscar_set_info(PurpleConnection *gc, const char *info);
203
203
static void oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, PurpleStatus *status);
204
204
static void oscar_set_extendedstatus(PurpleConnection *gc);
205
static void oscar_format_screenname(PurpleConnection *gc, const char *nick);
205
static void oscar_format_screenname(PurpleConnection *gc, const char *nick);
206
206
static gboolean purple_ssi_rerequestdata(gpointer data);
208
208
static void oscar_free_name_data(struct name_data *data) {
314
314
} else if (!g_ascii_strcasecmp(encoding, "unicode-2-0")) {
315
315
/* Some official ICQ clients are apparently total crack,
316
316
* and have been known to save a UTF-8 string converted
317
* from the locale character set to UCS-2 (not from UTF-8
318
* to UCS-2!) in the away message. This hack should find
317
* from the locale character set to UTF-16 (not from UTF-8
318
* to UTF-16!) in the away message. This hack should find
319
319
* and do something (un)reasonable with that, and not
320
320
* mess up too much else. */
321
321
const gchar *charset = purple_account_get_string(account, "encoding", NULL);
324
utf8 = g_convert(text, textlen, charset, "UCS-2BE", &len, NULL, NULL);
324
utf8 = g_convert(text, textlen, charset, "UTF-16BE", &len, NULL, NULL);
325
325
if (!utf8 || len != textlen || !g_utf8_validate(utf8, -1, NULL)) {
333
utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
333
utf8 = g_convert(text, textlen, "UTF-8", "UTF-16BE", NULL, NULL, NULL);
334
334
} else if (g_ascii_strcasecmp(encoding, "utf-8")) {
335
335
purple_debug_warning("oscar", "Unrecognized character encoding \"%s\", "
336
336
"attempting to convert to UTF-8 anyway\n", encoding);
417
417
gchar *ret = NULL;
418
418
const gchar *charsetstr1, *charsetstr2;
420
purple_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen);
420
purple_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%" G_GSIZE_FORMAT "\n", charset, charsubset, datalen);
422
422
if ((datalen == 0) || (data == NULL))
425
425
if (charset == AIM_CHARSET_UNICODE) {
426
charsetstr1 = "UCS-2BE";
426
charsetstr1 = "UTF-16BE";
427
427
charsetstr2 = "UTF-8";
428
428
} else if (charset == AIM_CHARSET_CUSTOM) {
429
429
if ((sourcesn != NULL) && aim_snvalid_icq(sourcesn))
495
495
* If we're sending to an ICQ user, and they are in our
496
496
* buddy list, and they are advertising the Unicode
497
497
* capability, and they are online, then attempt to send
500
500
if ((destsn != NULL) && aim_snvalid_icq(destsn))
501
501
userinfo = aim_locate_finduserinfo(od, destsn);
506
506
b = purple_find_buddy(account, destsn);
507
507
if ((b != NULL) && (PURPLE_BUDDY_IS_ONLINE(b)))
509
*msg = g_convert(from, -1, "UCS-2BE", "UTF-8", NULL, &msglen, NULL);
509
*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, NULL);
510
510
if (*msg != NULL)
512
512
*charset = AIM_CHARSET_UNICODE;
541
* Nothing else worked, so send as UCS-2BE.
541
* Nothing else worked, so send as UTF-16BE.
543
*msg = g_convert(from, -1, "UCS-2BE", "UTF-8", NULL, &msglen, &err);
543
*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, &err);
544
544
if (*msg != NULL) {
545
545
*charset = AIM_CHARSET_UNICODE;
546
546
*charsubset = 0x0000;
1040
1040
if (conn->type == SNAC_FAMILY_AUTH)
1042
1042
aim_request_login(od, conn, purple_account_get_username(account));
1043
purple_debug_info("oscar", "Screen name sent, waiting for response\n");
1044
purple_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS);
1043
purple_debug_info("oscar", "Username sent, waiting for response\n");
1044
purple_connection_update_progress(gc, _("Username sent"), 1, OSCAR_CONNECT_STEPS);
1047
1047
else if (conn->type == SNAC_FAMILY_LOCATE)
1304
1304
if (!aim_snvalid(purple_account_get_username(account))) {
1306
buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the screen name is invalid. Screen names must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), purple_account_get_username(account));
1306
buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), purple_account_get_username(account));
1307
1307
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, buf);
1384
1384
purple_debug_info("oscar",
1385
"inside auth_resp (Screen name: %s)\n", info->sn);
1385
"inside auth_resp (Username: %s)\n", info->sn);
1387
1387
if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) {
1389
1389
switch (info->errorcode) {
1391
1391
/* Unregistered screen name */
1392
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_USERNAME, _("Invalid screen name."));
1392
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_USERNAME, _("Invalid username."));
1395
1395
/* Incorrect password */
1598
1598
purple_debug_error("oscar", "Tried to write %"
1599
1599
G_GSIZE_FORMAT " bytes to fetch AIM hash data but "
1600
"instead wrote %" G_GSIZE_FORMAT " bytes\n",
1600
"instead wrote %" G_GSSIZE_FORMAT " bytes\n",
1601
1601
strlen(buf), result);
2014
2014
gconstpointer data = purple_imgstore_get_data(img);
2015
2015
size_t len = purple_imgstore_get_size(img);
2016
2016
purple_debug_info("oscar",
2017
"Sending buddy icon to %s (%d bytes)\n",
2017
"Sending buddy icon to %s (%" G_GSIZE_FORMAT " bytes)\n",
2019
2019
aim_im_sendch2_icon(od, userinfo->sn, data, len,
2020
2020
purple_buddy_icons_get_account_icon_timestamp(account),
2021
2021
aimutil_iconsum(data, len));
2955
2955
user_info = purple_notify_user_info_new();
2956
purple_notify_user_info_add_pair(user_info, _("Screen Name"), userinfo->sn);
2956
purple_notify_user_info_add_pair(user_info, _("Username"), userinfo->sn);
2958
2958
tmp = g_strdup_printf("%d", (int)((userinfo->warnlevel/10.0) + 0.5));
2959
2959
purple_notify_user_info_add_pair(user_info, _("Warning Level"), tmp);
3941
3941
gchar *secondary;
3944
char *email, *usernames;
3946
3946
va_start(ap, fr);
3947
3947
email = va_arg(ap, char *);
3948
3948
num = va_arg(ap, int);
3949
SNs = va_arg(ap, char *);
3949
usernames = va_arg(ap, char *);
3952
3952
results = purple_notify_searchresults_new();
3963
3963
secondary = g_strdup_printf(
3964
dngettext(PACKAGE, "The following screen name is associated with %s",
3965
"The following screen names are associated with %s",
3964
dngettext(PACKAGE, "The following username is associated with %s",
3965
"The following usernames are associated with %s",
3969
column = purple_notify_searchresults_column_new(_("Screen name"));
3969
column = purple_notify_searchresults_column_new(_("Username"));
3970
3970
purple_notify_searchresults_column_add(results, column);
3972
3972
for (i = 0; i < num; i++) {
3974
row = g_list_append(row, g_strdup(&SNs[i * (MAXSNLEN + 1)]));
3974
row = g_list_append(NULL, g_strdup(&usernames[i * (MAXSNLEN + 1)]));
3975
3975
purple_notify_searchresults_row_add(results, row);
3977
3977
purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD,
4047
4047
if ((err > 0) && (url != NULL)) {
4048
4048
char *dialog_msg;
4049
char *dialog_top = g_strdup_printf(_("Error Changing Account Info"));
4052
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err);
4055
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because it is invalid."), err);
4058
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err);
4061
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because there is already a request pending for this screen name."), err);
4064
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address has too many screen names associated with it."), err);
4067
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address is invalid."), err);
4070
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err);
4073
purple_notify_error(gc, NULL, dialog_top, dialog_msg);
4051
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format username because the requested name differs from the original."), err);
4052
else if (err == 0x0006)
4053
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format username because it is invalid."), err);
4054
else if (err == 0x00b)
4055
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format username because the requested name is too long."), err);
4056
else if (err == 0x001d)
4057
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because there is already a request pending for this username."), err);
4058
else if (err == 0x0021)
4059
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address has too many usernames associated with it."), err);
4060
else if (err == 0x0023)
4061
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address is invalid."), err);
4063
dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err);
4064
purple_notify_error(gc, NULL,
4065
_("Error Changing Account Info"), dialog_msg);
4075
4066
g_free(dialog_msg);
4446
4437
charset = oscar_charset_check(str);
4447
4438
if (charset == AIM_CHARSET_UNICODE) {
4448
encoded = g_convert(str, -1, "UCS-2BE", "UTF-8", NULL, ret_len, NULL);
4439
encoded = g_convert(str, -1, "UTF-16BE", "UTF-8", NULL, ret_len, NULL);
4449
4440
*encoding = "unicode-2-0";
4450
4441
} else if (charset == AIM_CHARSET_CUSTOM) {
4451
4442
encoded = g_convert(str, -1, "ISO-8859-1", "UTF-8", NULL, ret_len, NULL);
4515
4506
PurpleConnection *gc = purple_account_get_connection(account);
4516
4507
OscarData *od = gc->proto_data;
4517
PurplePresence *presence;
4518
4508
PurpleStatusType *status_type;
4519
4509
PurpleStatusPrimitive primitive;
4681
4670
if (!aim_snvalid(buddy->name)) {
4683
buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name);
4672
buf = g_strdup_printf(_("Could not add the buddy %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name);
4684
4673
if (!purple_conv_present_error(buddy->name, account, buf))
4685
4674
purple_notify_error(gc, NULL, _("Unable To Add"), buf);
4991
4980
switch (curitem->type) {
4992
4981
case 0x0000: { /* Buddy */
4993
4982
if (curitem->name) {
4994
struct aim_ssi_item *groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000);
4995
char *gname = groupitem ? groupitem->name : NULL;
4996
char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
4997
char *alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
4983
struct aim_ssi_item *groupitem;
4984
char *gname, *gname_utf8, *alias, *alias_utf8;
4986
groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000);
4987
gname = groupitem ? groupitem->name : NULL;
4988
if (gname != NULL) {
4989
if (g_utf8_validate(gname, -1, NULL))
4990
gname_utf8 = g_strdup(gname);
4992
gname_utf8 = oscar_utf8_try_convert(gc->account, gname);
5000
4996
g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans"));
5001
4997
if (g == NULL) {
5003
4999
purple_blist_add_group(g, NULL);
5002
alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
5003
if (alias != NULL) {
5008
5004
if (g_utf8_validate(alias, -1, NULL))
5009
5005
alias_utf8 = g_strdup(alias);
5011
5007
alias_utf8 = oscar_utf8_try_convert(account, alias);
5015
5010
alias_utf8 = NULL;
5017
5012
b = purple_find_buddy_in_group(gc->account, curitem->name, g);
5052
5047
case 0x0001: { /* Group */
5053
char *gname = curitem->name;
5054
char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
5051
gname = curitem->name;
5052
if (gname != NULL) {
5053
if (g_utf8_validate(gname, -1, NULL))
5054
gname_utf8 = g_strdup(gname);
5056
gname_utf8 = oscar_utf8_try_convert(gc->account, gname);
5055
5060
if (gname_utf8 != NULL && purple_find_group(gname_utf8) == NULL) {
5056
5061
g = purple_group_new(gname_utf8);
5057
5062
purple_blist_add_group(g, NULL);
6225
6230
if (!aim_sncmp(purple_account_get_username(purple_connection_get_account(gc)), nick)) {
6226
6231
if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) {
6227
6232
od->setnick = TRUE;
6228
6234
od->newsn = g_strdup(nick);
6229
6235
aim_srv_requestnew(od, SNAC_FAMILY_ADMIN);
6234
6240
purple_notify_error(gc, NULL, _("The new formatting is invalid."),
6235
_("Screen name formatting can change only capitalization and whitespace."));
6241
_("Username formatting can change only capitalization and whitespace."));
6518
act = purple_plugin_action_new(_("Set User Info (URL)..."),
6524
act = purple_plugin_action_new(_("Set User Info (web)..."),
6519
6525
oscar_show_set_info_icqurl);
6520
6526
menu = g_list_prepend(menu, act);
6527
6533
if (od->authinfo->chpassurl != NULL)
6529
act = purple_plugin_action_new(_("Change Password (URL)"),
6535
act = purple_plugin_action_new(_("Change Password (web)"),
6530
6536
oscar_show_chpassurl);
6531
6537
menu = g_list_prepend(menu, act);
6533
act = purple_plugin_action_new(_("Configure IM Forwarding (URL)"),
6539
act = purple_plugin_action_new(_("Configure IM Forwarding (web)"),
6534
6540
oscar_show_imforwardingurl);
6535
6541
menu = g_list_prepend(menu, act);
6631
6637
g_return_val_if_fail(str != NULL, NULL);
6633
6639
/* copy str to buf and skip all blanks */
6634
for (i=0, j=0; str[j] && i < BUF_LEN; i++, j++)
6640
for (i=0, j=0; str[j] && i < BUF_LEN - 1; i++, j++)
6636
6642
while (str[j] == ' ')
6652
6658
oscar_offline_message(const PurpleBuddy *buddy)
6654
OscarData *od = NULL;
6655
PurpleAccount *account;
6656
PurpleConnection *gc = NULL;
6658
account = purple_buddy_get_account(buddy);
6659
if (account != NULL) {
6660
gc = purple_account_get_connection(account);
6662
od = (OscarData *)gc->proto_data;
6665
return (od != NULL && od->icq && aim_snvalid_icq(purple_account_get_username(account)));
6668
6663
/* TODO: Find somewhere to put this instead of including it in a bunch of places.