diff options
author | Sven Moritz Hallberg <sm@khjk.org> | 2008-02-14 22:01:21 +0100 |
---|---|---|
committer | Sven Moritz Hallberg <sm@khjk.org> | 2008-02-14 22:01:21 +0100 |
commit | f3597a161cd13e076db626fed3d833cac0d62d6c (patch) | |
tree | babefcebd211607b9b7b8f8011d57eb6a9f5a6e0 | |
parent | ef93a2f828b62e74f62638e7fbbe63e47f92194f (diff) |
revert keygen behaviour to old (lax) behavior
-rw-r--r-- | otr.c | 32 | ||||
-rw-r--r-- | root_commands.c | 4 |
2 files changed, 21 insertions, 15 deletions
@@ -164,9 +164,6 @@ Fingerprint *match_fingerprint(irc_t *irc, ConnContext *ctx, const char **args); /* find a private key by fingerprint prefix (given as any number of hex strings) */ OtrlPrivKey *match_privkey(irc_t *irc, const char **args); -/* to log out accounts during keygen */ -extern void cmd_account(irc_t *irc, char **cmd); - /*** routines declared in otr.h: ***/ @@ -300,7 +297,14 @@ char *otr_handle_message(struct im_connection *ic, const char *handle, const cha char *colormsg; if(!g_static_rec_mutex_trylock(&ic->irc->otr_mutex)) { - irc_usermsg(ic->irc, "otr keygen in progress - msg from %s dropped", + user_t *u = user_findhandle(ic, handle); + + /* fallback for non-otr clients */ + if(u && !u->encrypted) { + return g_strdup(msg); + } + + irc_usermsg(ic->irc, "encrypted msg from %s during keygen - dropped", peernick(ic->irc, handle, ic->acc->prpl->name)); return NULL; } @@ -349,7 +353,15 @@ int otr_send_message(struct im_connection *ic, const char *handle, const char *m ConnContext *ctx = NULL; if(!g_static_rec_mutex_trylock(&ic->irc->otr_mutex)) { - irc_usermsg(ic->irc, "otr keygen in progress - msg to %s not sent", + user_t *u = user_findhandle(ic, handle); + + /* Fallback for non-otr clients. + Yes, this better shouldn't send private stuff in the clear... */ + if(u && !u->encrypted) { + return ic->acc->prpl->buddy_msg(ic, (char *)handle, (char *)msg, flags); + } + + irc_usermsg(ic->irc, "encrypted message to %s during keygen - not sent", peernick(ic->irc, handle, ic->acc->prpl->name)); return 1; } @@ -1465,12 +1477,13 @@ void show_otr_context_info(irc_t *irc, ConnContext *ctx) void otr_keygen(irc_t *irc, const char *handle, const char *protocol) { - char *account_off[] = {"account", "off", NULL}; GError *err; GThread *thr; struct kgdata *kg; gint ev; + irc_usermsg(irc, "generating new private key for %s/%s...", handle, protocol); + kg = g_new0(struct kgdata, 1); if(!kg) { irc_usermsg(irc, "otr keygen failed: out of memory"); @@ -1508,13 +1521,6 @@ void otr_keygen(irc_t *irc, const char *handle, const char *protocol) return; } - /* tell the user what's happening, go comatose, and start the keygen */ - irc_usermsg(irc, "going comatose for otr key generation, this will take a moment"); - irc_usermsg(irc, "all accounts logging out, user commands disabled"); - cmd_account(irc, account_off); - irc_usermsg(irc, "generating new otr privkey for %s/%s...", - handle, protocol); - thr = g_thread_create(&otr_keygen_thread_func, kg, FALSE, &err); if(!thr) { irc_usermsg(irc, "otr keygen failed: %s", err->message); diff --git a/root_commands.c b/root_commands.c index 03b579a1..04c62fea 100644 --- a/root_commands.c +++ b/root_commands.c @@ -135,7 +135,7 @@ static void cmd_help( irc_t *irc, char **cmd ) } } -void cmd_account( irc_t *irc, char **cmd ); +static void cmd_account( irc_t *irc, char **cmd ); static void cmd_identify( irc_t *irc, char **cmd ) { @@ -212,7 +212,7 @@ static void cmd_drop( irc_t *irc, char **cmd ) } } -void cmd_account( irc_t *irc, char **cmd ) +static void cmd_account( irc_t *irc, char **cmd ) { account_t *a; |