Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 13231:af3d6c6aee6b
[gaim-migrate @ 15596]
Shuffling some things around--no functionality change
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 11 Feb 2006 18:59:11 +0000 |
parents | 51dd24fd8290 |
children | f2431a7e33aa |
comparison
equal
deleted
inserted
replaced
13230:1841236cb091 | 13231:af3d6c6aee6b |
---|---|
1646 | 1646 |
1647 /***************************************************************************** | 1647 /***************************************************************************** |
1648 * End scary direct im stuff | 1648 * End scary direct im stuff |
1649 *****************************************************************************/ | 1649 *****************************************************************************/ |
1650 | 1650 |
1651 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { | 1651 static void |
1652 aim_conn_t *conn = (aim_conn_t *)data; | 1652 oscar_callback(gpointer data, gint source, GaimInputCondition condition) |
1653 aim_session_t *sess = aim_conn_getsess(conn); | 1653 { |
1654 GaimConnection *gc = sess ? sess->aux_data : NULL; | 1654 aim_conn_t *conn; |
1655 aim_session_t *sess; | |
1656 GaimConnection *gc; | |
1655 OscarData *od; | 1657 OscarData *od; |
1656 | 1658 |
1657 if (!gc) { | 1659 conn = (aim_conn_t *)data; |
1658 gaim_debug_info("oscar", | 1660 sess = aim_conn_getsess(conn); |
1659 "oscar callback for closed connection (1).\n"); | 1661 gc = sess ? sess->aux_data : NULL; |
1662 | |
1663 if (gc == NULL) | |
1664 { | |
1665 gaim_debug_info("oscar", "oscar callback for closed connection (1).\n"); | |
1660 return; | 1666 return; |
1661 } | 1667 } |
1662 | 1668 |
1663 if( !(od = (OscarData *)gc->proto_data) ) { | 1669 od = gc->proto_data; |
1670 if (od == NULL) | |
1671 { | |
1664 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); | 1672 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); |
1665 return; | 1673 return; |
1666 } | 1674 } |
1667 | 1675 |
1668 if (!g_list_find(gaim_connections_get_all(), gc)) { | 1676 if (!g_list_find(gaim_connections_get_all(), gc)) |
1677 { | |
1669 /* oh boy. this is probably bad. i guess the only thing we | 1678 /* oh boy. this is probably bad. i guess the only thing we |
1670 * can really do is return? */ | 1679 * can really do is return? */ |
1671 gaim_debug_info("oscar", | 1680 gaim_debug_info("oscar", |
1672 "oscar callback for closed connection (2).\n"); | 1681 "oscar callback for closed connection (2).\n"); |
1673 gaim_debug_misc("oscar", "gc = %p\n", gc); | 1682 gaim_debug_misc("oscar", "gc = %p\n", gc); |
1674 return; | 1683 return; |
1675 } | 1684 } |
1676 | 1685 |
1677 if (condition & GAIM_INPUT_READ) { | 1686 /* We only care about READ conditions */ |
1678 if (conn->type == AIM_CONN_TYPE_LISTENER) { | 1687 if (!(condition & GAIM_INPUT_READ)) |
1679 gaim_debug_info("oscar", | 1688 return; |
1680 "got information on rendezvous listener\n"); | 1689 |
1681 if (aim_handlerendconnect(od->sess, conn) < 0) { | 1690 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
1682 gaim_debug_error("oscar", | 1691 gaim_debug_info("oscar", |
1683 "connection error (rendezvous listener)\n"); | 1692 "got information on rendezvous listener\n"); |
1684 aim_conn_kill(od->sess, &conn); | 1693 if (aim_handlerendconnect(od->sess, conn) < 0) { |
1685 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ | 1694 gaim_debug_error("oscar", |
1695 "connection error (rendezvous listener)\n"); | |
1696 aim_conn_kill(od->sess, &conn); | |
1697 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ | |
1698 } | |
1699 } else { | |
1700 if (aim_get_command(od->sess, conn) >= 0) { | |
1701 aim_rxdispatch(od->sess); | |
1702 if (od->killme) { | |
1703 gaim_debug_error("oscar", "Waiting to be destroyed\n"); | |
1704 return; | |
1686 } | 1705 } |
1687 } else { | 1706 } else { |
1688 if (aim_get_command(od->sess, conn) >= 0) { | 1707 if ((conn->type == AIM_CONN_TYPE_BOS) || |
1689 aim_rxdispatch(od->sess); | 1708 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1690 if (od->killme) { | 1709 { |
1691 gaim_debug_error("oscar", "Waiting to be destroyed\n"); | 1710 gaim_debug_error("oscar", "Major connection error " |
1692 return; | 1711 "(invalid data was received on the oscar TCP stream).\n"); |
1712 gaim_connection_error(gc, _("Disconnected.")); | |
1713 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
1714 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); | |
1715 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
1716 char *buf; | |
1717 gaim_debug_info("oscar", "Lost connection " | |
1718 "to chat room %s\n", cc->name); | |
1719 | |
1720 buf = g_strdup_printf(_("You have lost your connection " | |
1721 "to chat room %s."), cc->name); | |
1722 if (conv != NULL) | |
1723 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1724 else | |
1725 gaim_notify_error(gc, NULL, buf, NULL); | |
1726 g_free(buf); | |
1727 | |
1728 oscar_chat_kill(gc, cc); | |
1729 | |
1730 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
1731 if (od->cnpa > 0) | |
1732 gaim_input_remove(od->cnpa); | |
1733 od->cnpa = 0; | |
1734 gaim_debug_info("oscar", | |
1735 "removing chatnav input watcher\n"); | |
1736 while (od->create_rooms) { | |
1737 struct create_room *cr = od->create_rooms->data; | |
1738 g_free(cr->name); | |
1739 od->create_rooms = | |
1740 g_slist_remove(od->create_rooms, cr); | |
1741 g_free(cr); | |
1742 gaim_notify_error(gc, NULL, | |
1743 _("Chat is currently unavailable"), | |
1744 NULL); | |
1693 } | 1745 } |
1746 gaim_debug_info("oscar","killing rendezvous connection\n"); | |
1747 aim_conn_kill(od->sess, &conn); | |
1748 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
1749 if (od->paspa > 0) | |
1750 gaim_input_remove(od->paspa); | |
1751 od->paspa = 0; | |
1752 gaim_debug_info("oscar", | |
1753 "removing authconn input watcher\n"); | |
1754 aim_conn_kill(od->sess, &conn); | |
1755 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { | |
1756 if (od->emlpa > 0) | |
1757 gaim_input_remove(od->emlpa); | |
1758 od->emlpa = 0; | |
1759 gaim_debug_info("oscar", | |
1760 "removing email input watcher\n"); | |
1761 aim_conn_kill(od->sess, &conn); | |
1762 } else if (conn->type == AIM_CONN_TYPE_ICON) { | |
1763 if (od->icopa > 0) | |
1764 gaim_input_remove(od->icopa); | |
1765 od->icopa = 0; | |
1766 gaim_debug_info("oscar", | |
1767 "removing icon input watcher\n"); | |
1768 aim_conn_kill(od->sess, &conn); | |
1769 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { | |
1770 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) | |
1771 gaim_odc_disconnect(od->sess, conn); | |
1772 gaim_debug_info("oscar","killing rendezvous connection\n"); | |
1773 aim_conn_kill(od->sess, &conn); | |
1694 } else { | 1774 } else { |
1695 if ((conn->type == AIM_CONN_TYPE_BOS) || | 1775 gaim_debug_error("oscar", |
1696 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) | 1776 "holy crap! generic connection error! %hu\n", |
1697 { | 1777 conn->type); |
1698 gaim_debug_error("oscar", "Major connection error " | 1778 aim_conn_kill(od->sess, &conn); |
1699 "(invalid data was received on the oscar TCP stream).\n"); | |
1700 gaim_connection_error(gc, _("Disconnected.")); | |
1701 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
1702 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); | |
1703 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
1704 char *buf; | |
1705 gaim_debug_info("oscar", "Lost connection " | |
1706 "to chat room %s\n", cc->name); | |
1707 | |
1708 buf = g_strdup_printf(_("You have lost your connection " | |
1709 "to chat room %s."), cc->name); | |
1710 if (conv != NULL) | |
1711 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1712 else | |
1713 gaim_notify_error(gc, NULL, buf, NULL); | |
1714 g_free(buf); | |
1715 | |
1716 oscar_chat_kill(gc, cc); | |
1717 | |
1718 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
1719 if (od->cnpa > 0) | |
1720 gaim_input_remove(od->cnpa); | |
1721 od->cnpa = 0; | |
1722 gaim_debug_info("oscar", | |
1723 "removing chatnav input watcher\n"); | |
1724 while (od->create_rooms) { | |
1725 struct create_room *cr = od->create_rooms->data; | |
1726 g_free(cr->name); | |
1727 od->create_rooms = | |
1728 g_slist_remove(od->create_rooms, cr); | |
1729 g_free(cr); | |
1730 gaim_notify_error(gc, NULL, | |
1731 _("Chat is currently unavailable"), | |
1732 NULL); | |
1733 } | |
1734 gaim_debug_info("oscar","killing rendezvous connection\n"); | |
1735 aim_conn_kill(od->sess, &conn); | |
1736 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
1737 if (od->paspa > 0) | |
1738 gaim_input_remove(od->paspa); | |
1739 od->paspa = 0; | |
1740 gaim_debug_info("oscar", | |
1741 "removing authconn input watcher\n"); | |
1742 aim_conn_kill(od->sess, &conn); | |
1743 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { | |
1744 if (od->emlpa > 0) | |
1745 gaim_input_remove(od->emlpa); | |
1746 od->emlpa = 0; | |
1747 gaim_debug_info("oscar", | |
1748 "removing email input watcher\n"); | |
1749 aim_conn_kill(od->sess, &conn); | |
1750 } else if (conn->type == AIM_CONN_TYPE_ICON) { | |
1751 if (od->icopa > 0) | |
1752 gaim_input_remove(od->icopa); | |
1753 od->icopa = 0; | |
1754 gaim_debug_info("oscar", | |
1755 "removing icon input watcher\n"); | |
1756 aim_conn_kill(od->sess, &conn); | |
1757 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { | |
1758 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) | |
1759 gaim_odc_disconnect(od->sess, conn); | |
1760 gaim_debug_info("oscar","killing rendezvous connection\n"); | |
1761 aim_conn_kill(od->sess, &conn); | |
1762 } else { | |
1763 gaim_debug_error("oscar", | |
1764 "holy crap! generic connection error! %hu\n", | |
1765 conn->type); | |
1766 aim_conn_kill(od->sess, &conn); | |
1767 } | |
1768 } | 1779 } |
1769 } | 1780 } |
1770 } | 1781 } |
1771 } | 1782 } |
1772 | 1783 |