src/protocols/yahoo/yahoo.c

changeset 6847
0fda06bb588a
parent 6840
d4e05db5bccb
child 6982
12f08de92674
equal deleted inserted replaced
6846:f814f02dca87 6847:0fda06bb588a
369 f->idle = 0; 369 f->idle = 0;
370 if (f->status != YAHOO_STATUS_CUSTOM) { 370 if (f->status != YAHOO_STATUS_CUSTOM) {
371 g_free(f->msg); 371 g_free(f->msg);
372 f->msg = NULL; 372 f->msg = NULL;
373 } 373 }
374 if (f->status == YAHOO_STATUS_AVAILABLE) 374
375 f->idle = 0; 375 f->sms = 0;
376 break; 376 break;
377 case 19: /* custom message */ 377 case 19: /* custom message */
378 if (f) { 378 if (f) {
379 if (f->msg) 379 if (f->msg)
380 g_free(f->msg); 380 g_free(f->msg);
1695 gc->away = NULL; 1695 gc->away = NULL;
1696 } 1696 }
1697 1697
1698 if (msg) { 1698 if (msg) {
1699 yd->current_status = YAHOO_STATUS_CUSTOM; 1699 yd->current_status = YAHOO_STATUS_CUSTOM;
1700 gc->away = g_strdup(msg); 1700 gc->away = g_strndup(msg, YAHOO_MAX_STATUS_MESSAGE_LENGTH);
1701 } else if (state) { 1701 } else if (state) {
1702 gc->away = g_strdup(""); 1702 gc->away = g_strdup("");
1703 if (!strcmp(state, _("Available"))) { 1703 if (!strcmp(state, _("Available"))) {
1704 yd->current_status = YAHOO_STATUS_AVAILABLE; 1704 yd->current_status = YAHOO_STATUS_AVAILABLE;
1705 g_free(gc->away);
1706 gc->away = NULL;
1707 } else if (!strcmp(state, _("Be Right Back"))) { 1705 } else if (!strcmp(state, _("Be Right Back"))) {
1708 yd->current_status = YAHOO_STATUS_BRB; 1706 yd->current_status = YAHOO_STATUS_BRB;
1709 } else if (!strcmp(state, _("Busy"))) { 1707 } else if (!strcmp(state, _("Busy"))) {
1710 yd->current_status = YAHOO_STATUS_BUSY; 1708 yd->current_status = YAHOO_STATUS_BUSY;
1711 } else if (!strcmp(state, _("Not At Home"))) { 1709 } else if (!strcmp(state, _("Not At Home"))) {
1722 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; 1720 yd->current_status = YAHOO_STATUS_OUTTOLUNCH;
1723 } else if (!strcmp(state, _("Stepped Out"))) { 1721 } else if (!strcmp(state, _("Stepped Out"))) {
1724 yd->current_status = YAHOO_STATUS_STEPPEDOUT; 1722 yd->current_status = YAHOO_STATUS_STEPPEDOUT;
1725 } else if (!strcmp(state, _("Invisible"))) { 1723 } else if (!strcmp(state, _("Invisible"))) {
1726 yd->current_status = YAHOO_STATUS_INVISIBLE; 1724 yd->current_status = YAHOO_STATUS_INVISIBLE;
1727 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { 1725 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { /* this should never happen? */
1728 if (gc->is_idle) { 1726 if (gc->is_idle) {
1729 yd->current_status = YAHOO_STATUS_IDLE; 1727 yd->current_status = YAHOO_STATUS_IDLE;
1730 } else { 1728 } else {
1731 yd->current_status = YAHOO_STATUS_AVAILABLE; 1729 yd->current_status = YAHOO_STATUS_AVAILABLE;
1732 } 1730 }
1733 g_free(gc->away);
1734 gc->away = NULL;
1735 } 1731 }
1736 } else if (gc->is_idle) { 1732 } else if (gc->is_idle) {
1737 yd->current_status = YAHOO_STATUS_IDLE; 1733 yd->current_status = YAHOO_STATUS_IDLE;
1738 } else { 1734 } else {
1739 yd->current_status = YAHOO_STATUS_AVAILABLE; 1735 yd->current_status = YAHOO_STATUS_AVAILABLE;
1741 1737
1742 if (yd->current_status == YAHOO_STATUS_AVAILABLE) 1738 if (yd->current_status == YAHOO_STATUS_AVAILABLE)
1743 service = YAHOO_SERVICE_ISBACK; 1739 service = YAHOO_SERVICE_ISBACK;
1744 else 1740 else
1745 service = YAHOO_SERVICE_ISAWAY; 1741 service = YAHOO_SERVICE_ISAWAY;
1746 pkt = yahoo_packet_new(service, yd->current_status, 0); 1742
1743 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, 0);
1747 g_snprintf(s, sizeof(s), "%d", yd->current_status); 1744 g_snprintf(s, sizeof(s), "%d", yd->current_status);
1748 yahoo_packet_hash(pkt, 10, s); 1745 yahoo_packet_hash(pkt, 10, s);
1749 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 1746
1750 yahoo_packet_hash(pkt, 19, msg); 1747 if ((yd->current_status == YAHOO_STATUS_CUSTOM) && gc->away)
1748 yahoo_packet_hash(pkt, 19, gc->away);
1749
1750 if ((yd->current_status != YAHOO_STATUS_AVAILABLE) &&
1751 (yd->current_status != YAHOO_STATUS_IDLE)) {
1751 if (gc->is_idle) 1752 if (gc->is_idle)
1752 yahoo_packet_hash(pkt, 47, "2"); 1753 yahoo_packet_hash(pkt, 47, "2");
1753 else 1754 else
1754 yahoo_packet_hash(pkt, 47, "1"); 1755 yahoo_packet_hash(pkt, 47, "1");
1755 } 1756 }
1762 { 1763 {
1763 struct yahoo_data *yd = gc->proto_data; 1764 struct yahoo_data *yd = gc->proto_data;
1764 struct yahoo_packet *pkt = NULL; 1765 struct yahoo_packet *pkt = NULL;
1765 1766
1766 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { 1767 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) {
1767 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); 1768 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
1768 yd->current_status = YAHOO_STATUS_IDLE; 1769 yd->current_status = YAHOO_STATUS_IDLE;
1769 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { 1770 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) {
1770 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); 1771 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
1771 yd->current_status = YAHOO_STATUS_AVAILABLE; 1772 yd->current_status = YAHOO_STATUS_AVAILABLE;
1772 } else if (idle && gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { 1773 } else {
1773 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0);
1774 } else if (!idle && gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) {
1775 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); 1774 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
1776 } 1775 }
1777 1776
1778 if (pkt) { 1777 if (pkt) {
1779 char buf[4]; 1778 char buf[4];
1783 yahoo_packet_hash(pkt, 19, gc->away); 1782 yahoo_packet_hash(pkt, 19, gc->away);
1784 if (idle) 1783 if (idle)
1785 yahoo_packet_hash(pkt, 47, "2"); 1784 yahoo_packet_hash(pkt, 47, "2");
1786 else 1785 else
1787 yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */ 1786 yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */
1788 } 1787 } else if (idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) &&
1788 (yd->current_status != YAHOO_STATUS_IDLE)) {
1789 yahoo_packet_hash(pkt, 47, "2");
1790 } else if (!idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) &&
1791 (yd->current_status != YAHOO_STATUS_IDLE)) {
1792 yahoo_packet_hash(pkt, 47, "1");
1793 }
1794
1789 yahoo_send_packet(yd, pkt); 1795 yahoo_send_packet(yd, pkt);
1790 yahoo_packet_free(pkt); 1796 yahoo_packet_free(pkt);
1791 } 1797 }
1792 } 1798 }
1793 1799

mercurial