| 1590 zephyr->encoding = (char *)purple_account_get_string(purple_connection_get_account(gc), "encoding", ZEPHYR_FALLBACK_CHARSET); |
1630 zephyr->encoding = (char *)purple_account_get_string(purple_connection_get_account(gc), "encoding", ZEPHYR_FALLBACK_CHARSET); |
| 1591 purple_connection_update_progress(gc, _("Connecting"), 0, 8); |
1631 purple_connection_update_progress(gc, _("Connecting"), 0, 8); |
| 1592 |
1632 |
| 1593 /* XXX z_call_s should actually try to report the com_err determined error */ |
1633 /* XXX z_call_s should actually try to report the com_err determined error */ |
| 1594 if (use_tzc(zephyr)) { |
1634 if (use_tzc(zephyr)) { |
| 1595 pid_t pid; |
1635 gboolean found_ps = FALSE; |
| 1596 /* purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "tzc not supported yet"); */ |
1636 gchar **tzc_cmd_array = NULL; |
| 1597 if ((pipe(zephyr->totzc) != 0) || (pipe(zephyr->fromtzc) != 0)) { |
1637 GPollableInputStream *stream = NULL; |
| 1598 purple_debug_error("zephyr", "pipe creation failed. killing\n"); |
1638 gsize bufsize; |
| 1599 exit(-1); |
1639 gchar *buf = NULL; |
| 1600 } |
1640 gchar *bufcur = NULL; |
| 1601 |
1641 gchar *ptr; |
| 1602 pid = fork(); |
1642 gint parenlevel = 0; |
| 1603 |
1643 gchar *tempstr; |
| 1604 if (pid == -1) { |
1644 gint i; |
| 1605 purple_debug_error("zephyr", "forking failed\n"); |
1645 GError *error = NULL; |
| 1606 exit(-1); |
1646 |
| 1607 } |
1647 /* tzc_command should really be of the form |
| 1608 if (pid == 0) { |
1648 path/to/tzc -e %s |
| 1609 unsigned int i=0; |
1649 or |
| 1610 gboolean found_ps = FALSE; |
1650 ssh username@hostname pathtotzc -e %s |
| 1611 gchar ** tzc_cmd_array = g_strsplit(purple_account_get_string(purple_connection_get_account(gc),"tzc_command","/usr/bin/tzc -e %s")," ",0); |
1651 -- this should not require a password, and ideally should be |
| 1612 if (close(1) == -1) { |
1652 kerberized ssh -- |
| 1613 exit(-1); |
1653 or |
| 1614 } |
1654 fsh username@hostname pathtotzc -e %s |
| 1615 if (dup2(zephyr->fromtzc[1], 1) == -1) { |
1655 */ |
| 1616 exit(-1); |
1656 if (!g_shell_parse_argv(purple_account_get_string( |
| 1617 } |
1657 purple_connection_get_account(gc), |
| 1618 if (close(zephyr->fromtzc[1]) == -1) { |
1658 "tzc_command", "/usr/bin/tzc -e %s"), |
| 1619 exit(-1); |
1659 NULL, &tzc_cmd_array, &error)) { |
| 1620 } |
1660 purple_debug_error("zephyr", "Unable to parse tzc_command: %s", |
| 1621 if (close(0) == -1) { |
1661 error->message); |
| 1622 exit(-1); |
1662 purple_connection_error(gc, |
| 1623 } |
1663 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
| 1624 if (dup2(zephyr->totzc[0], 0) == -1) { |
1664 "invalid tzc_command setting"); |
| 1625 exit(-1); |
1665 g_error_free(error); |
| 1626 } |
1666 return; |
| 1627 if (close(zephyr->totzc[0]) == -1) { |
1667 } |
| 1628 exit(-1); |
1668 for (i = 0; tzc_cmd_array[i] != NULL; i++) { |
| 1629 } |
1669 if (g_str_equal(tzc_cmd_array[i], "%s")) { |
| 1630 /* tzc_command should really be of the form |
1670 g_free(tzc_cmd_array); |
| 1631 path/to/tzc -e %s |
1671 tzc_cmd_array[i] = g_strdup(zephyr->exposure); |
| 1632 or |
1672 found_ps = TRUE; |
| 1633 ssh username@hostname pathtotzc -e %s |
1673 } |
| 1634 -- this should not require a password, and ideally should be kerberized ssh -- |
1674 } |
| 1635 or |
1675 |
| 1636 fsh username@hostname pathtotzc -e %s |
1676 if (!found_ps) { |
| 1637 */ |
1677 purple_debug_error("zephyr", "tzc exited early"); |
| 1638 while(tzc_cmd_array[i] != NULL){ |
1678 purple_connection_error( |
| 1639 if (!g_ascii_strncasecmp(tzc_cmd_array[i],"%s",2)) { |
1679 gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1640 /* fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */ |
1680 "invalid output by tzc (or bad parsing code)"); |
| 1641 tzc_cmd_array[i] = g_strdup(zephyr->exposure); |
1681 g_strfreev(tzc_cmd_array); |
| 1642 found_ps = TRUE; |
1682 return; |
| 1643 |
1683 } |
| |
1684 |
| |
1685 zephyr->tzc_proc = g_subprocess_newv( |
| |
1686 (const gchar *const *)tzc_cmd_array, |
| |
1687 G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE, |
| |
1688 &error); |
| |
1689 g_strfreev(tzc_cmd_array); |
| |
1690 if (zephyr->tzc_proc == NULL) { |
| |
1691 purple_debug_error("zephyr", "tzc exited early: %s", |
| |
1692 error->message); |
| |
1693 purple_connection_error( |
| |
1694 gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| |
1695 "invalid output by tzc (or bad parsing code)"); |
| |
1696 g_error_free(error); |
| |
1697 return; |
| |
1698 } |
| |
1699 zephyr->tzc_stdin = g_subprocess_get_stdin_pipe(zephyr->tzc_proc); |
| |
1700 zephyr->tzc_stdout = g_subprocess_get_stdout_pipe(zephyr->tzc_proc); |
| |
1701 |
| |
1702 stream = G_POLLABLE_INPUT_STREAM(zephyr->tzc_stdout); |
| |
1703 bufsize = 2048; |
| |
1704 buf = g_new(gchar, bufsize); |
| |
1705 bufcur = buf; |
| |
1706 parenlevel = 0; |
| |
1707 |
| |
1708 purple_debug_info("zephyr", "about to read from tzc"); |
| |
1709 |
| |
1710 while (TRUE) { |
| |
1711 if (pollable_input_stream_read_with_timeout( |
| |
1712 stream, bufcur, 10 * G_USEC_PER_SEC, &error) < 0) { |
| |
1713 if (error->code == G_IO_ERROR_WOULD_BLOCK || |
| |
1714 error->code == G_IO_ERROR_TIMED_OUT) { |
| |
1715 g_clear_error(&error); |
| |
1716 break; |
| |
1717 } |
| |
1718 purple_debug_error("zephyr", "couldn't read: %s", |
| |
1719 error->message); |
| |
1720 purple_connection_error(gc, |
| |
1721 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| |
1722 "couldn't read"); |
| |
1723 g_error_free(error); |
| |
1724 g_free(buf); |
| |
1725 return; |
| |
1726 } |
| |
1727 bufcur++; |
| |
1728 if ((bufcur - buf) > (bufsize - 1)) { |
| |
1729 if ((buf = g_realloc(buf, bufsize * 2)) == NULL) { |
| |
1730 exit(-1); |
| 1644 } else { |
1731 } else { |
| 1645 /* fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */ |
1732 bufcur = buf + bufsize; |
| |
1733 bufsize *= 2; |
| 1646 } |
1734 } |
| 1647 i++; |
1735 } |
| 1648 } |
1736 } |
| 1649 |
1737 *bufcur = '\0'; |
| 1650 if (!found_ps) { |
1738 ptr = buf; |
| 1651 exit(-1); |
1739 |
| 1652 } |
1740 /* ignore all tzcoutput till we've received the first (*/ |
| 1653 |
1741 while (ptr < bufcur && (*ptr != '(')) { |
| 1654 execvp(tzc_cmd_array[0], tzc_cmd_array); |
1742 ptr++; |
| 1655 exit(-1); |
1743 } |
| 1656 } |
1744 if (ptr >= bufcur) { |
| 1657 else { |
1745 purple_connection_error( |
| 1658 fd_set rfds; |
1746 gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1659 int bufsize = 2048; |
1747 "invalid output by tzc (or bad parsing code)"); |
| 1660 char *buf = (char *)calloc(bufsize, 1); |
1748 g_free(buf); |
| 1661 char *bufcur = buf; |
1749 return; |
| 1662 struct timeval tv; |
1750 } |
| 1663 char *ptr; |
1751 |
| 1664 int parenlevel=0; |
1752 while (ptr < bufcur) { |
| 1665 char* tempstr; |
1753 if (*ptr == '(') { |
| 1666 int tempstridx; |
1754 parenlevel++; |
| 1667 int select_status; |
1755 } else if (*ptr == ')') { |
| 1668 |
1756 parenlevel--; |
| 1669 zephyr->tzc_pid = pid; |
1757 } |
| 1670 /* wait till we have data to read from ssh */ |
1758 purple_debug_info("zephyr", "tzc parenlevel is %d", parenlevel); |
| 1671 FD_ZERO(&rfds); |
1759 switch (parenlevel) { |
| 1672 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
|
| 1673 |
|
| 1674 tv.tv_sec = 10; |
|
| 1675 tv.tv_usec = 0; |
|
| 1676 |
|
| 1677 purple_debug_info("zephyr", "about to read from tzc\n"); |
|
| 1678 |
|
| 1679 if (waitpid(pid, NULL, WNOHANG) == 0) { /* Only select if tzc is still running */ |
|
| 1680 purple_debug_info("zephyr", "about to read from tzc\n"); |
|
| 1681 select_status = select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); |
|
| 1682 } |
|
| 1683 else { |
|
| 1684 purple_debug_info("zephyr", "tzc exited early\n"); |
|
| 1685 select_status = -1; |
|
| 1686 } |
|
| 1687 |
|
| 1688 FD_ZERO(&rfds); |
|
| 1689 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
|
| 1690 while (select_status > 0 && |
|
| 1691 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv) > 0) { |
|
| 1692 if (read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1) != 1) { |
|
| 1693 purple_debug_error("zephyr", "couldn't read\n"); |
|
| 1694 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "couldn't read"); |
|
| 1695 free(buf); |
|
| 1696 return; |
|
| 1697 } |
|
| 1698 bufcur++; |
|
| 1699 if ((bufcur - buf) > (bufsize - 1)) { |
|
| 1700 if ((buf = realloc(buf, bufsize * 2)) == NULL) { |
|
| 1701 exit(-1); |
|
| 1702 } else { |
|
| 1703 bufcur = buf + bufsize; |
|
| 1704 bufsize *= 2; |
|
| 1705 } |
|
| 1706 } |
|
| 1707 FD_ZERO(&rfds); |
|
| 1708 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
|
| 1709 tv.tv_sec = 10; |
|
| 1710 tv.tv_usec = 0; |
|
| 1711 |
|
| 1712 } |
|
| 1713 /* fprintf(stderr, "read from tzc\n"); */ |
|
| 1714 *bufcur = '\0'; |
|
| 1715 ptr = buf; |
|
| 1716 |
|
| 1717 /* ignore all tzcoutput till we've received the first (*/ |
|
| 1718 while (ptr < bufcur && (*ptr !='(')) { |
|
| 1719 ptr++; |
|
| 1720 } |
|
| 1721 if (ptr >=bufcur) { |
|
| 1722 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "invalid output by tzc (or bad parsing code)"); |
|
| 1723 free(buf); |
|
| 1724 return; |
|
| 1725 } |
|
| 1726 |
|
| 1727 while(ptr < bufcur) { |
|
| 1728 if (*ptr == '(') { |
|
| 1729 parenlevel++; |
|
| 1730 } |
|
| 1731 else if (*ptr == ')') { |
|
| 1732 parenlevel--; |
|
| 1733 } |
|
| 1734 purple_debug_info("zephyr","tzc parenlevel is %d\n",parenlevel); |
|
| 1735 switch (parenlevel) { |
|
| 1736 case 0: |
1760 case 0: |
| 1737 break; |
1761 break; |
| 1738 case 1: |
1762 case 1: |
| 1739 /* Search for next beginning (, or for the ending */ |
1763 /* Search for next beginning (, or for the ending */ |
| 1740 ptr++; |
1764 ptr++; |
| 1741 while((*ptr != '(') && (*ptr != ')') && (ptr <bufcur)) |
1765 while ((*ptr != '(') && (*ptr != ')') && (ptr < bufcur)) { |
| 1742 ptr++; |
1766 ptr++; |
| 1743 if (ptr >= bufcur) |
1767 } |
| 1744 purple_debug_error("zephyr","tzc parsing error\n"); |
1768 if (ptr >= bufcur) { |
| |
1769 purple_debug_error("zephyr", "tzc parsing error"); |
| |
1770 } |
| 1745 break; |
1771 break; |
| 1746 case 2: |
1772 case 2: |
| 1747 /* You are probably at |
1773 /* You are probably at |
| 1748 (foo . bar ) or (foo . "bar") or (foo . chars) or (foo . numbers) or (foo . () ) |
1774 (foo . bar ) or (foo . "bar") or (foo . chars) or (foo . numbers) or (foo . () ) |
| 1749 Parse all the data between the first and last f, and move past ) |
1775 Parse all the data between the first and last f, and move past ) |
| 1750 */ |
1776 */ |
| 1751 tempstr = g_malloc0(20000); |
1777 tempstr = g_new0(gchar, 20000); |
| 1752 tempstridx=0; |
1778 i = 0; |
| 1753 while(parenlevel >1) { |
1779 while(parenlevel >1) { |
| 1754 ptr++; |
1780 ptr++; |
| 1755 if (*ptr == '(') |
1781 if (*ptr == '(') |
| 1756 parenlevel++; |
1782 parenlevel++; |
| 1757 if (*ptr == ')') |
1783 if (*ptr == ')') |
| 1758 parenlevel--; |
1784 parenlevel--; |
| 1759 if (parenlevel > 1) { |
1785 if (parenlevel > 1) { |
| 1760 tempstr[tempstridx++]=*ptr; |
1786 tempstr[i++] = *ptr; |
| 1761 } else { |
1787 } else { |
| 1762 ptr++; |
1788 ptr++; |
| 1763 } |
1789 } |
| 1764 } |
1790 } |
| 1765 purple_debug_info("zephyr","tempstr parsed\n"); |
1791 purple_debug_info("zephyr", "tempstr parsed"); |
| 1766 /* tempstr should now be a tempstridx length string containing all characters |
1792 /* tempstr should now be a i-length string containing all |
| 1767 from that after the first ( to the one before the last paren ). */ |
1793 * characters from that after the first ( to the one before |
| 1768 /* We should have the following possible lisp strings but we don't care |
1794 * the last paren ). We should have the following possible |
| 1769 (tzcspew . start) (version . "something") (pid . number)*/ |
1795 * lisp strings but we don't care |
| 1770 /* We care about 'zephyrid . "username@REALM.NAME"' and 'exposure . "SOMETHING"' */ |
1796 * (tzcspew . start) (version . "something") (pid . number) |
| 1771 tempstridx=0; |
1797 * We care about 'zephyrid . "username@REALM.NAME"' and |
| |
1798 * 'exposure . "SOMETHING"' */ |
| |
1799 i = 0; |
| 1772 if (!g_ascii_strncasecmp(tempstr,"zephyrid",8)) { |
1800 if (!g_ascii_strncasecmp(tempstr,"zephyrid",8)) { |
| 1773 gchar* username = g_malloc0(100); |
1801 gchar* username = g_malloc0(100); |
| 1774 int username_idx=0; |
1802 int username_idx=0; |
| 1775 char *realm; |
1803 char *realm; |
| 1776 purple_debug_info("zephyr","zephyrid found\n"); |
1804 purple_debug_info("zephyr", "zephyrid found"); |
| 1777 tempstridx+=8; |
1805 i += 8; |
| 1778 while(tempstr[tempstridx] !='"' && tempstridx < 20000) |
1806 while (i < 20000 && tempstr[i] != '"') { |
| 1779 tempstridx++; |
1807 i++; |
| 1780 tempstridx++; |
1808 } |
| 1781 while(tempstr[tempstridx] !='"' && tempstridx < 20000) |
1809 i++; |
| 1782 username[username_idx++]=tempstr[tempstridx++]; |
1810 while (i < 20000 && tempstr[i] != '"') { |
| |
1811 username[username_idx++] = tempstr[i++]; |
| |
1812 } |
| 1783 |
1813 |
| 1784 zephyr->username = g_strdup_printf("%s",username); |
1814 zephyr->username = g_strdup_printf("%s",username); |
| 1785 if ((realm = strchr(username,'@'))) |
1815 if ((realm = strchr(username,'@'))) |
| 1786 zephyr->realm = g_strdup_printf("%s",realm+1); |
1816 zephyr->realm = g_strdup_printf("%s",realm+1); |
| 1787 else { |
1817 else { |
| 1788 realm = (gchar *)purple_account_get_string(purple_connection_get_account(gc),"realm",""); |
1818 realm = (gchar *)purple_account_get_string(purple_connection_get_account(gc),"realm",""); |
| 1789 if (!*realm) { |
1819 if (!*realm) { |
| 1790 realm = "local-realm"; |
1820 realm = "local-realm"; |
| 1791 } |
1821 } |
| 1792 zephyr->realm = g_strdup(realm); |
1822 zephyr->realm = g_strdup(realm); |
| 1793 g_strlcpy(__Zephyr_realm, (const char*)zephyr->realm, REALM_SZ-1); |
1823 g_strlcpy(__Zephyr_realm, |
| |
1824 (const gchar *)zephyr->realm, |
| |
1825 REALM_SZ - 1); |
| 1794 } |
1826 } |
| 1795 /* else { |
1827 /* else { |
| 1796 zephyr->realm = g_strdup("local-realm"); |
1828 zephyr->realm = g_strdup("local-realm"); |
| 1797 }*/ |
1829 }*/ |
| 1798 |
1830 |
| 1799 g_free(username); |
1831 g_free(username); |
| 1800 } else { |
1832 } else { |
| 1801 purple_debug_info("zephyr", "something that's not zephyr id found %s\n",tempstr); |
1833 purple_debug_info( |
| |
1834 "zephyr", |
| |
1835 "something that's not zephyr id found %s", |
| |
1836 tempstr); |
| 1802 } |
1837 } |
| 1803 |
1838 |
| 1804 /* We don't care about anything else yet */ |
1839 /* We don't care about anything else yet */ |
| 1805 g_free(tempstr); |
1840 g_free(tempstr); |
| 1806 break; |
1841 break; |
| 1807 default: |
1842 default: |
| 1808 purple_debug_info("zephyr","parenlevel is not 1 or 2\n"); |
1843 purple_debug_info("zephyr", "parenlevel is not 1 or 2"); |
| 1809 /* This shouldn't be happening */ |
1844 /* This shouldn't be happening */ |
| 1810 break; |
1845 break; |
| 1811 } |
1846 } |
| 1812 if (parenlevel==0) |
1847 if (parenlevel == 0) { |
| 1813 break; |
1848 break; |
| 1814 } /* while (ptr < bufcur) */ |
1849 } |
| 1815 purple_debug_info("zephyr", "tzc startup done\n"); |
1850 } /* while (ptr < bufcur) */ |
| 1816 free(buf); |
1851 purple_debug_info("zephyr", "tzc startup done"); |
| 1817 } |
1852 g_free(buf); |
| 1818 } |
1853 } |
| 1819 else if ( use_zeph02(zephyr)) { |
1854 else if ( use_zeph02(zephyr)) { |
| 1820 gchar* realm; |
1855 gchar* realm; |
| 1821 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
1856 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
| 1822 z_call_s(ZOpenPort(&(zephyr->port)), "Couldn't open port"); |
1857 z_call_s(ZOpenPort(&(zephyr->port)), "Couldn't open port"); |
| 1984 g_source_remove(zephyr->nottimer); |
2018 g_source_remove(zephyr->nottimer); |
| 1985 zephyr->nottimer = 0; |
2019 zephyr->nottimer = 0; |
| 1986 if (zephyr->loctimer) |
2020 if (zephyr->loctimer) |
| 1987 g_source_remove(zephyr->loctimer); |
2021 g_source_remove(zephyr->loctimer); |
| 1988 zephyr->loctimer = 0; |
2022 zephyr->loctimer = 0; |
| 1989 gc = NULL; |
|
| 1990 if (use_zeph02(zephyr)) { |
2023 if (use_zeph02(zephyr)) { |
| 1991 z_call(ZCancelSubscriptions(0)); |
2024 z_call(ZCancelSubscriptions(0)); |
| 1992 z_call(ZUnsetLocation()); |
2025 z_call(ZUnsetLocation()); |
| 1993 z_call(ZClosePort()); |
2026 z_call(ZClosePort()); |
| 1994 } else { |
2027 } else { |
| 1995 /* assume tzc */ |
2028 /* assume tzc */ |
| 1996 if (kill(tzc_pid,SIGTERM) == -1) { |
2029 #ifdef G_OS_UNIX |
| 1997 int err=errno; |
2030 GError *error = NULL; |
| 1998 if (err==EINVAL) { |
2031 g_subprocess_send_signal(zephyr->tzc_proc, SIGTERM); |
| 1999 purple_debug_error("zephyr","An invalid signal was specified when killing tzc\n"); |
2032 if (!g_subprocess_wait(zephyr->tzc_proc, NULL, &error)) { |
| 2000 } |
2033 purple_debug_error("zephyr", |
| 2001 else if (err==ESRCH) { |
2034 "error while attempting to close tzc: %s", |
| 2002 purple_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n"); |
2035 error->message); |
| 2003 } |
2036 g_error_free(error); |
| 2004 else if (err==EPERM) { |
2037 } |
| 2005 purple_debug_error("zephyr","purple didn't have permission to kill tzc\n"); |
2038 #else |
| 2006 } |
2039 g_subprocess_force_exit(zephyr->tzc_proc); |
| 2007 else { |
2040 #endif |
| 2008 purple_debug_error("zephyr","miscellaneous error while attempting to close tzc\n"); |
2041 zephyr->tzc_stdin = NULL; |
| 2009 } |
2042 zephyr->tzc_stdout = NULL; |
| 2010 } |
2043 g_clear_object(&zephyr->tzc_proc); |
| 2011 } |
2044 } |
| 2012 } |
2045 } |
| 2013 |
2046 |
| 2014 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, |
2047 static gboolean zephyr_send_message(zephyr_account *zephyr, gchar *zclass, |
| 2015 const char *sig, char *opcode) ; |
2048 gchar *instance, gchar *recipient, |
| |
2049 const gchar *im, const gchar *sig, |
| |
2050 gchar *opcode); |
| 2016 |
2051 |
| 2017 static const char * zephyr_get_signature(void) |
2052 static const char * zephyr_get_signature(void) |
| 2018 { |
2053 { |
| 2019 /* XXX add zephyr error reporting */ |
2054 /* XXX add zephyr error reporting */ |
| 2020 const char * sig =ZGetVariable("zwrite-signature"); |
2055 const char * sig =ZGetVariable("zwrite-signature"); |
| 2295 else if (primitive == PURPLE_STATUS_AVAILABLE) { |
2331 else if (primitive == PURPLE_STATUS_AVAILABLE) { |
| 2296 if (use_zeph02(zephyr)) { |
2332 if (use_zeph02(zephyr)) { |
| 2297 ZSetLocation(zephyr->exposure); |
2333 ZSetLocation(zephyr->exposure); |
| 2298 } |
2334 } |
| 2299 else { |
2335 else { |
| 2300 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); |
2336 GError *error = NULL; |
| 2301 len = strlen(zexpstr); |
2337 gchar *zexpstr = g_strdup_printf("((tzcfodder . set-location)" |
| 2302 result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,len); |
2338 " (hostname . \"%s\")" |
| 2303 if (result != len) { |
2339 " (exposure . \"%s\"))\n", |
| 2304 purple_debug_error("zephyr", "Unable to write message: %s\n", g_strerror(errno)); |
2340 zephyr->ourhost, zephyr->exposure); |
| |
2341 if (g_output_stream_write_all(zephyr->tzc_stdin, zexpstr, |
| |
2342 strlen(zexpstr), NULL, NULL, |
| |
2343 &error)) { |
| |
2344 purple_debug_error("zephyr", "Unable to write message: %s", |
| |
2345 error->message); |
| |
2346 g_error_free(error); |
| 2305 } |
2347 } |
| 2306 g_free(zexpstr); |
2348 g_free(zexpstr); |
| 2307 } |
2349 } |
| 2308 } |
2350 } |
| 2309 else if (primitive == PURPLE_STATUS_INVISIBLE) { |
2351 else if (primitive == PURPLE_STATUS_INVISIBLE) { |
| 2310 /* XXX handle errors */ |
2352 /* XXX handle errors */ |
| 2311 if (use_zeph02(zephyr)) { |
2353 if (use_zeph02(zephyr)) { |
| 2312 ZSetLocation(EXPOSE_OPSTAFF); |
2354 ZSetLocation(EXPOSE_OPSTAFF); |
| 2313 } else { |
2355 } else { |
| 2314 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); |
2356 GError *error = NULL; |
| 2315 len = strlen(zexpstr); |
2357 gchar *zexpstr = g_strdup_printf("((tzcfodder . set-location)" |
| 2316 result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,len); |
2358 " (hostname . \"%s\")" |
| 2317 if (result != len) { |
2359 " (exposure . \"%s\"))\n", |
| 2318 purple_debug_error("zephyr", "Unable to write message: %s\n", g_strerror(errno)); |
2360 zephyr->ourhost, EXPOSE_OPSTAFF); |
| |
2361 if (g_output_stream_write_all(zephyr->tzc_stdin, zexpstr, |
| |
2362 strlen(zexpstr), NULL, NULL, |
| |
2363 &error)) { |
| |
2364 purple_debug_error("zephyr", "Unable to write message: %s", |
| |
2365 error->message); |
| |
2366 g_error_free(error); |
| 2319 } |
2367 } |
| 2320 g_free(zexpstr); |
2368 g_free(zexpstr); |
| 2321 } |
2369 } |
| 2322 } |
2370 } |
| 2323 } |
2371 } |