Changes in otr.c [2c81d15:098a75b]
Legend:
- Unmodified
- Added
- Removed
-
otr.c
r2c81d15 r098a75b 193 193 void show_general_otr_info(irc_t *irc); 194 194 195 /* show info about a given OTR context and subcontexts/instances. bestctx 196 may be either NULL or preferred destination context (this is hilighted 197 in the output as being the target for a message) */ 198 void show_otr_context_info(irc_t *irc, ConnContext *ctx, ConnContext *bestctx); 195 /* show info about a given OTR context */ 196 void show_otr_context_info(irc_t *irc, ConnContext *ctx); 199 197 200 198 /* show the list of fingerprints associated with a given context */ … … 1104 1102 char *arg = g_strdup(args[1]); 1105 1103 char *myhandle, *handle = NULL, *protocol; 1106 ConnContext * bestctx = NULL, *ctx;1104 ConnContext *ctx; 1107 1105 1108 1106 /* interpret arg as 'user/protocol/account' if possible */ … … 1137 1135 return; 1138 1136 } 1139 /* This does no harm if it returns NULL */1140 bestctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user,1141 u->bu->ic->acc->prpl->name, OTRL_INSTAG_BEST, 0, NULL, NULL, NULL);1142 1137 } 1143 1138 1144 1139 /* show how we resolved the (nick) argument, if we did */ 1145 1140 if (handle != arg) { 1146 irc_rootmsg(irc, "%s:", args[1]); 1147 irc_rootmsg(irc, " they are: %s/%s", ctx->username, ctx->protocol); 1148 irc_rootmsg(irc, " we are: %s/%s", ctx->accountname, ctx->protocol); 1149 } 1150 show_otr_context_info(irc, ctx, bestctx); 1141 irc_rootmsg(irc, "%s is %s/%s; we are %s/%s to them", args[1], 1142 ctx->username, ctx->protocol, ctx->accountname, ctx->protocol); 1143 } 1144 show_otr_context_info(irc, ctx); 1151 1145 g_free(arg); 1152 1146 } … … 1555 1549 int count = 0; 1556 1550 1557 /* Is this a subcontext? If so, only list the active fingerprint */ 1558 if (ctx->m_context != ctx) { 1559 fp = ctx->active_fingerprint; 1560 } else { 1561 fp = &ctx->fingerprint_root; 1562 } 1563 1564 while (fp) { 1551 for (fp = &ctx->fingerprint_root; fp; fp = fp->next) { 1565 1552 if (!fp->fingerprint) { 1566 fp = fp->next;1567 1553 continue; 1568 1554 } … … 1575 1561 } 1576 1562 if (fp == ctx->active_fingerprint) { 1577 irc_rootmsg(irc, " 1563 irc_rootmsg(irc, " \x02%s (%s)\x02", human, trust); 1578 1564 } else { 1579 irc_rootmsg(irc, " %s (%s)", human, trust); 1580 } 1581 1582 /* Break if this is a subcontext - we only print active fp */ 1583 if (ctx->m_context != ctx) { 1584 break; 1585 } 1586 fp = fp->next; 1565 irc_rootmsg(irc, " %s (%s)", human, trust); 1566 } 1587 1567 } 1588 1568 if (count == 0) { 1589 irc_rootmsg(irc, " 1569 irc_rootmsg(irc, " (none)"); 1590 1570 } 1591 1571 } … … 1775 1755 /* list all contexts */ 1776 1756 /* XXX remove this, or split off as its own command */ 1757 /* XXX show instags? */ 1777 1758 irc_rootmsg(irc, "%s", ""); 1778 1759 irc_rootmsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)"); 1779 1780 ctx = irc->otr->us->context_root; 1781 while (ctx) { 1782 ConnContext *subctx; 1760 for (ctx = irc->otr->us->context_root; ctx; ctx = ctx->next) { \ 1783 1761 irc_user_t *u; 1784 1762 char *userstring; 1785 char encrypted = 0;1786 1763 1787 1764 u = peeruser(irc, ctx->username, ctx->protocol); … … 1794 1771 } 1795 1772 1796 subctx = ctx; 1797 while (subctx && subctx->m_context == ctx) { 1798 if (subctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 1799 encrypted = 1; 1800 } 1801 subctx = subctx->next; 1802 } 1803 1804 if(encrypted) { 1773 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 1805 1774 irc_rootmsg(irc, " \x02%s\x02", userstring); 1806 1775 } else { … … 1808 1777 } 1809 1778 1810 /* Skip subcontexts/instances from output */1811 ctx = subctx;1812 1813 1779 g_free(userstring); 1814 1780 } 1815 1816 1781 if (ctx == irc->otr->us->context_root) { 1817 1782 irc_rootmsg(irc, " (none)"); … … 1819 1784 } 1820 1785 1821 void show_otr_context_info(irc_t *irc, ConnContext *ctx, ConnContext *bestctx) 1822 { 1823 ConnContext *subctx; 1824 int instcount = 0; 1825 1826 subctx = ctx; 1827 while (subctx && subctx->m_context == ctx) { 1828 if (subctx->m_context == subctx) { 1829 if (subctx == bestctx) { 1830 irc_rootmsg(irc, " \x02master context (target):\x02"); 1831 } else { 1832 irc_rootmsg(irc, " master context:"); 1833 } 1834 irc_rootmsg(irc, " known fingerprints (bold = active for v1 or v2):"); 1835 } else { 1836 if (subctx == bestctx) { 1837 irc_rootmsg(irc, " \x02instance %d (target):\x02", instcount); 1838 } else { 1839 irc_rootmsg(irc, " instance %d:", instcount); 1840 } 1841 irc_rootmsg(irc, " active fingerprint:"); 1842 instcount++; 1843 } 1844 1845 show_fingerprints(irc, subctx); 1846 1847 switch (subctx->msgstate) { 1848 case OTRL_MSGSTATE_PLAINTEXT: 1849 irc_rootmsg(irc, " connection state: cleartext"); 1850 break; 1851 case OTRL_MSGSTATE_ENCRYPTED: 1852 irc_rootmsg(irc, " connection state: encrypted (v%d)", subctx->protocol_version); 1853 break; 1854 case OTRL_MSGSTATE_FINISHED: 1855 irc_rootmsg(irc, " connection state: shut down"); 1856 break; 1857 default: 1858 irc_rootmsg(irc, " connection state: %d", subctx->msgstate); 1859 } 1860 1861 subctx = subctx->next; 1862 } 1786 void show_otr_context_info(irc_t *irc, ConnContext *ctx) 1787 { 1788 // XXX show all instags/subcontexts 1789 1790 switch (ctx->otr_offer) { 1791 case OFFER_NOT: 1792 irc_rootmsg(irc, " otr offer status: none sent"); 1793 break; 1794 case OFFER_SENT: 1795 irc_rootmsg(irc, " otr offer status: awaiting reply"); 1796 break; 1797 case OFFER_ACCEPTED: 1798 irc_rootmsg(irc, " otr offer status: accepted our offer"); 1799 break; 1800 case OFFER_REJECTED: 1801 irc_rootmsg(irc, " otr offer status: ignored our offer"); 1802 break; 1803 default: 1804 irc_rootmsg(irc, " otr offer status: %d", ctx->otr_offer); 1805 } 1806 1807 switch (ctx->msgstate) { 1808 case OTRL_MSGSTATE_PLAINTEXT: 1809 irc_rootmsg(irc, " connection state: cleartext"); 1810 break; 1811 case OTRL_MSGSTATE_ENCRYPTED: 1812 irc_rootmsg(irc, " connection state: encrypted (v%d)", ctx->protocol_version); 1813 break; 1814 case OTRL_MSGSTATE_FINISHED: 1815 irc_rootmsg(irc, " connection state: shut down"); 1816 break; 1817 default: 1818 irc_rootmsg(irc, " connection state: %d", ctx->msgstate); 1819 } 1820 1821 irc_rootmsg(irc, " fingerprints: (bold=active)"); 1822 show_fingerprints(irc, ctx); 1863 1823 } 1864 1824
Note: See TracChangeset
for help on using the changeset viewer.