about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-23 19:25:53 +0000
committerJames Booth <boothj5@gmail.com>2014-01-23 19:25:53 +0000
commit3f31c1a4e705a16284464a5798a23a3e0e701e82 (patch)
tree07d1b34e3f9e9c8dfcd9250096d66d5f13e7c99f /src/command
parent21ab18215164fe791ebda7e6158648f63790ed93 (diff)
downloadprofani-tty-3f31c1a4e705a16284464a5798a23a3e0e701e82.tar.gz
Encrypt /tiny command when in OTR session
fixes #292
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c1
-rw-r--r--src/command/commands.c35
2 files changed, 35 insertions, 1 deletions
diff --git a/src/command/command.c b/src/command/command.c
index ceed2e01..fec14032 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1199,6 +1199,7 @@ cmd_execute_default(const char * const inp)
     win_type_t win_type = ui_current_win_type();
     jabber_conn_status_t status = jabber_get_connection_status();
     char *recipient = ui_current_recipient();
+    cons_debug("Recipient: %s", recipient);
 
     switch (win_type)
     {
diff --git a/src/command/commands.c b/src/command/commands.c
index 9c16ef81..7943bfad 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1838,8 +1838,40 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
         if (tiny != NULL) {
             if (win_type == WIN_CHAT) {
                 char *recipient = ui_current_recipient();
-                message_send(tiny, recipient);
+#ifdef HAVE_LIBOTR
+                if (otr_is_secure(recipient)) {
+                    char *encrypted = otr_encrypt_message(recipient, tiny);
+                    if (encrypted != NULL) {
+                        message_send(encrypted, recipient);
+                        otr_free_message(encrypted);
+                        if (prefs_get_boolean(PREF_CHLOG)) {
+                            const char *jid = jabber_get_fulljid();
+                            Jid *jidp = jid_create(jid);
+                            if (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0) {
+                                chat_log_chat(jidp->barejid, recipient, tiny, PROF_OUT_LOG, NULL);
+                            } else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) {
+                                chat_log_chat(jidp->barejid, recipient, "[redacted]", PROF_OUT_LOG, NULL);
+                            }
+                            jid_destroy(jidp);
+                        }
+
+                        ui_outgoing_msg("me", recipient, tiny);
+                    } else {
+                        cons_show_error("Failed to send message.");
+                    }
+                } else {
+                    message_send(tiny, recipient);
+                    if (prefs_get_boolean(PREF_CHLOG)) {
+                        const char *jid = jabber_get_fulljid();
+                        Jid *jidp = jid_create(jid);
+                        chat_log_chat(jidp->barejid, recipient, tiny, PROF_OUT_LOG, NULL);
+                        jid_destroy(jidp);
+                    }
 
+                    ui_outgoing_msg("me", recipient, tiny);
+                }
+#else
+                message_send(tiny, recipient);
                 if (prefs_get_boolean(PREF_CHLOG)) {
                     const char *jid = jabber_get_fulljid();
                     Jid *jidp = jid_create(jid);
@@ -1848,6 +1880,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
                 }
 
                 ui_outgoing_msg("me", recipient, tiny);
+#endif
             } else if (win_type == WIN_PRIVATE) {
                 char *recipient = ui_current_recipient();
                 message_send(tiny, recipient);
'#n281'>281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398