- Timestamp:
- 2015-06-17T22:47:26Z (9 years ago)
- Children:
- b441614
- Parents:
- d832164 (diff), 2f99f23 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
otr.c
rd832164 rb75671d 193 193 void show_general_otr_info(irc_t *irc); 194 194 195 /* show info about a given OTR context */ 196 void show_otr_context_info(irc_t *irc, ConnContext *ctx); 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); 197 199 198 200 /* show the list of fingerprints associated with a given context */ … … 1102 1104 char *arg = g_strdup(args[1]); 1103 1105 char *myhandle, *handle = NULL, *protocol; 1104 ConnContext * ctx;1106 ConnContext *bestctx = NULL, *ctx; 1105 1107 1106 1108 /* interpret arg as 'user/protocol/account' if possible */ … … 1135 1137 return; 1136 1138 } 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); 1137 1142 } 1138 1143 1139 1144 /* show how we resolved the (nick) argument, if we did */ 1140 1145 if (handle != arg) { 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); 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); 1145 1151 g_free(arg); 1146 1152 } … … 1549 1555 int count = 0; 1550 1556 1551 for (fp = &ctx->fingerprint_root; fp; fp = fp->next) { 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) { 1552 1565 if (!fp->fingerprint) { 1566 fp = fp->next; 1553 1567 continue; 1554 1568 } … … 1561 1575 } 1562 1576 if (fp == ctx->active_fingerprint) { 1563 irc_rootmsg(irc, " \x02%s (%s)\x02", human, trust);1577 irc_rootmsg(irc, " \x02%s (%s)\x02", human, trust); 1564 1578 } else { 1565 irc_rootmsg(irc, " %s (%s)", human, trust); 1566 } 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; 1567 1587 } 1568 1588 if (count == 0) { 1569 irc_rootmsg(irc, " (none)");1589 irc_rootmsg(irc, " (none)"); 1570 1590 } 1571 1591 } … … 1755 1775 /* list all contexts */ 1756 1776 /* XXX remove this, or split off as its own command */ 1757 /* XXX show instags? */1758 1777 irc_rootmsg(irc, "%s", ""); 1759 1778 irc_rootmsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)"); 1760 for (ctx = irc->otr->us->context_root; ctx; ctx = ctx->next) { \ 1779 1780 ctx = irc->otr->us->context_root; 1781 while (ctx) { 1782 ConnContext *subctx; 1761 1783 irc_user_t *u; 1762 1784 char *userstring; 1785 char encrypted = 0; 1763 1786 1764 1787 u = peeruser(irc, ctx->username, ctx->protocol); … … 1771 1794 } 1772 1795 1773 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 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) { 1774 1805 irc_rootmsg(irc, " \x02%s\x02", userstring); 1775 1806 } else { … … 1777 1808 } 1778 1809 1810 /* Skip subcontexts/instances from output */ 1811 ctx = subctx; 1812 1779 1813 g_free(userstring); 1780 1814 } 1815 1781 1816 if (ctx == irc->otr->us->context_root) { 1782 1817 irc_rootmsg(irc, " (none)"); … … 1784 1819 } 1785 1820 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); 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 } 1823 1863 } 1824 1864
Note: See TracChangeset
for help on using the changeset viewer.