Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 10196:760e690a5f30
[gaim-migrate @ 11313]
A few steps closer to being able to set an oscar away message.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 16 Nov 2004 23:29:53 +0000 |
parents | fa4973f356a1 |
children | 7369bf2bf593 |
comparison
equal
deleted
inserted
replaced
10195:fa4973f356a1 | 10196:760e690a5f30 |
---|---|
5547 GaimStatusType *status_type; | 5547 GaimStatusType *status_type; |
5548 GaimStatusPrimitive primitive; | 5548 GaimStatusPrimitive primitive; |
5549 GaimPresence *presence; | 5549 GaimPresence *presence; |
5550 const gchar *status_id; | 5550 const gchar *status_id; |
5551 int charset = 0; | 5551 int charset = 0; |
5552 gchar *text_html = NULL; | 5552 const gchar *text_html = NULL; |
5553 char *msg = NULL; | 5553 char *msg = NULL; |
5554 gsize msglen = 0; | 5554 gsize msglen = 0; |
5555 | 5555 |
5556 status_type = gaim_status_get_type(status); | 5556 status_type = gaim_status_get_type(status); |
5557 primitive = gaim_status_type_get_primitive(status_type); | 5557 primitive = gaim_status_type_get_primitive(status_type); |
5558 status_id = gaim_status_get_id(status); | 5558 status_id = gaim_status_get_id(status); |
5559 presence = gaim_account_get_presence(account); | 5559 presence = gaim_account_get_presence(account); |
5560 | 5560 |
5561 gaim_debug_info("oscar", "Setting status to %s\n", status_id); | |
5562 | |
5561 if (primitive == GAIM_STATUS_HIDDEN) | 5563 if (primitive == GAIM_STATUS_HIDDEN) |
5562 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | 5564 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
5563 else | 5565 else |
5564 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | 5566 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5565 | |
5566 | |
5567 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5568 | 5567 |
5569 if (od->rights.maxawaymsglen == 0) | 5568 if (od->rights.maxawaymsglen == 0) |
5570 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), | 5569 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
5571 _("You have probably requested to set your " | 5570 _("You have probably requested to set your " |
5572 "away message before the login procedure " | 5571 "away message before the login procedure " |
5576 | 5575 |
5577 if (primitive == GAIM_STATUS_AVAILABLE) { | 5576 if (primitive == GAIM_STATUS_AVAILABLE) { |
5578 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); | 5577 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5579 #if 0 | 5578 #if 0 |
5580 /* Set an available message */ | 5579 /* Set an available message */ |
5581 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); | |
5582 aim_srv_setavailmsg(od->sess, text); | 5580 aim_srv_setavailmsg(od->sess, text); |
5583 #endif | 5581 #endif |
5584 return; | 5582 |
5585 } | 5583 } else if (primitive == GAIM_STATUS_AWAY) { |
5586 | 5584 text_html = gaim_status_get_attr_string(status, "message"); |
5587 /* | 5585 |
5588 * XXX - Using status_id below is definitely wrong. We want to get | 5586 if (text_html == NULL) { |
5589 * the away message that the Gaim user just set. We probably want | 5587 text_html = _("Away"); |
5590 * to get a certain attribute from status->attr_values, but I don't | 5588 } |
5591 * think any of that is implemented yet. | 5589 |
5592 * | 5590 charset = oscar_charset_check(text_html); |
5593 * Something like | 5591 if (charset == AIM_CHARSET_UNICODE) { |
5594 * text_html = gaim_status_get_attr_string(status, "message"); | 5592 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5595 */ | 5593 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
5596 status_id = gaim_status_get_name(status); | 5594 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5597 text_html = gaim_strdup_withhtml(status_id); | 5595 g_free(msg); |
5598 | 5596 } else if (charset == AIM_CHARSET_CUSTOM) { |
5599 charset = oscar_charset_check(text_html); | 5597 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5600 if (charset == AIM_CHARSET_UNICODE) { | 5598 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
5601 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | 5599 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5602 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | 5600 g_free(msg); |
5603 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | 5601 } else { |
5604 g_free(msg); | 5602 msglen = strlen(text_html); |
5605 } else if (charset == AIM_CHARSET_CUSTOM) { | 5603 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
5606 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | 5604 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5607 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | 5605 } |
5608 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | 5606 |
5609 g_free(msg); | 5607 if (msglen > od->rights.maxawaymsglen) { |
5608 gchar *errstr; | |
5609 | |
5610 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5611 "has been exceeded. Gaim has truncated it for you.", | |
5612 "The maximum away message length of %d bytes " | |
5613 "has been exceeded. Gaim has truncated it for you.", | |
5614 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5615 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5616 g_free(errstr); | |
5617 } | |
5618 | |
5610 } else { | 5619 } else { |
5611 msglen = strlen(text_html); | 5620 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5612 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | 5621 |
5613 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | 5622 } |
5614 } | |
5615 | |
5616 if (msglen > od->rights.maxawaymsglen) { | |
5617 gchar *errstr; | |
5618 | |
5619 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5620 "has been exceeded. Gaim has truncated it for you.", | |
5621 "The maximum away message length of %d bytes " | |
5622 "has been exceeded. Gaim has truncated it for you.", | |
5623 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5624 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5625 g_free(errstr); | |
5626 } | |
5627 | |
5628 g_free(text_html); | |
5629 | |
5630 return; | |
5631 } | 5623 } |
5632 | 5624 |
5633 static void | 5625 static void |
5634 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | 5626 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) |
5635 { | 5627 { |