Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r2c81d15 r098a75b  
    193193void show_general_otr_info(irc_t *irc);
    194194
    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 */
     196void show_otr_context_info(irc_t *irc, ConnContext *ctx);
    199197
    200198/* show the list of fingerprints associated with a given context */
     
    11041102                char *arg = g_strdup(args[1]);
    11051103                char *myhandle, *handle = NULL, *protocol;
    1106                 ConnContext *bestctx = NULL, *ctx;
     1104                ConnContext *ctx;
    11071105
    11081106                /* interpret arg as 'user/protocol/account' if possible */
     
    11371135                                return;
    11381136                        }
    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);
    11421137                }
    11431138
    11441139                /* show how we resolved the (nick) argument, if we did */
    11451140                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);
    11511145                g_free(arg);
    11521146        }
     
    15551549        int count = 0;
    15561550
    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) {
    15651552                if (!fp->fingerprint) {
    1566                         fp = fp->next;
    15671553                        continue;
    15681554                }
     
    15751561                }
    15761562                if (fp == ctx->active_fingerprint) {
    1577                         irc_rootmsg(irc, "      \x02%s (%s)\x02", human, trust);
     1563                        irc_rootmsg(irc, "    \x02%s (%s)\x02", human, trust);
    15781564                } 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                }
    15871567        }
    15881568        if (count == 0) {
    1589                 irc_rootmsg(irc, "      (none)");
     1569                irc_rootmsg(irc, "    (none)");
    15901570        }
    15911571}
     
    17751755        /* list all contexts */
    17761756        /* XXX remove this, or split off as its own command */
     1757        /* XXX show instags? */
    17771758        irc_rootmsg(irc, "%s", "");
    17781759        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) { \
    17831761                irc_user_t *u;
    17841762                char *userstring;
    1785                 char encrypted = 0;
    17861763
    17871764                u = peeruser(irc, ctx->username, ctx->protocol);
     
    17941771                }
    17951772
    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) {
    18051774                        irc_rootmsg(irc, "  \x02%s\x02", userstring);
    18061775                } else {
     
    18081777                }
    18091778
    1810                 /* Skip subcontexts/instances from output */
    1811                 ctx = subctx;
    1812 
    18131779                g_free(userstring);
    18141780        }
    1815 
    18161781        if (ctx == irc->otr->us->context_root) {
    18171782                irc_rootmsg(irc, "  (none)");
     
    18191784}
    18201785
    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         }
     1786void 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);
    18631823}
    18641824
Note: See TracChangeset for help on using the changeset viewer.