about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-16 01:11:36 +0000
committerJames Booth <boothj5@gmail.com>2013-12-16 01:11:36 +0000
commit95d08db2925dbaabf5ff88323554ba1afd1fc1cf (patch)
treede13ecab5eaeec7f582df003981e1fe2b94b89ab /src
parent2470f642c73a7b13181bf51a6f3c2ee126e9e733 (diff)
parent52f6ad6fe19149a351fba673aa378508cd7c0558 (diff)
downloadprofani-tty-95d08db2925dbaabf5ff88323554ba1afd1fc1cf.tar.gz
Merge branch 'master' into otr
Conflicts:
	src/command/commands.c
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c28
-rw-r--r--src/config/accounts.c10
-rw-r--r--src/config/accounts.h1
-rw-r--r--src/ui/core.c13
-rw-r--r--src/ui/ui.h1
5 files changed, 29 insertions, 24 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 5babefe8..147ccf42 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -45,7 +45,6 @@
 #include "xmpp/xmpp.h"
 #include "xmpp/bookmark.h"
 
-static char * _ask_password(void);
 static void _update_presence(const resource_presence_t presence,
     const char * const show, gchar **args);
 static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
@@ -74,19 +73,15 @@ cmd_connect(gchar **args, struct cmd_help_t help)
 
         ProfAccount *account = accounts_get_account(lower);
         if (account != NULL) {
-            if (account->resource != NULL) {
-                jid = create_fulljid(account->jid, account->resource);
-            } else {
-                jid = strdup(account->jid);
-            }
-
+            jid = accounts_create_full_jid(account);
             if (account->password == NULL) {
-                account->password = _ask_password();
+                account->password = ui_ask_password();
             }
             cons_show("Connecting with account %s as %s", account->name, jid);
             conn_status = jabber_connect_with_account(account);
+            accounts_free_account(account);
         } else {
-            char *passwd = _ask_password();
+            char *passwd = ui_ask_password();
             jid = strdup(lower);
             cons_show("Connecting as %s", jid);
             conn_status = jabber_connect_with_details(jid, passwd, altdomain);
@@ -99,7 +94,6 @@ cmd_connect(gchar **args, struct cmd_help_t help)
             log_debug("Connection attempt for %s failed", jid);
         }
 
-        accounts_free_account(account);
         free(jid);
 
         result = TRUE;
@@ -2267,20 +2261,6 @@ cmd_otr(gchar **args, struct cmd_help_t help)
 #endif
 }
 
-
-// helper function that asks the user for a password and saves it in passwd
-static char *
-_ask_password(void) {
-  char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1));
-  status_bar_get_password();
-  status_bar_refresh();
-  inp_block();
-  inp_get_password(passwd);
-  inp_non_block();
-
-  return passwd;
-}
-
 // helper function for status change commands
 static void
 _update_presence(const resource_presence_t resource_presence,
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 0422a991..6431cd9e 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -292,6 +292,16 @@ accounts_get_account(const char * const name)
     }
 }
 
+char *
+accounts_create_full_jid(ProfAccount *account)
+{
+    if (account->resource != NULL) {
+        return create_fulljid(account->jid, account->resource);
+    } else {
+        return strdup(account->jid);
+    }
+}
+
 void
 accounts_free_account(ProfAccount *account)
 {
diff --git a/src/config/accounts.h b/src/config/accounts.h
index 96289952..caa8e84c 100644
--- a/src/config/accounts.h
+++ b/src/config/accounts.h
@@ -81,5 +81,6 @@ void accounts_set_priority_all(const char * const account_name, const gint value
 gint accounts_get_priority_for_presence_type(const char * const account_name,
     resource_presence_t presence_type);
 void accounts_clear_password(const char * const account_name);
+char * accounts_create_full_jid(ProfAccount *account);
 
 #endif
diff --git a/src/ui/core.c b/src/ui/core.c
index 507cfb02..1ff41b7d 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1330,6 +1330,19 @@ ui_win_unread(int index)
     }
 }
 
+char *
+ui_ask_password(void)
+{
+  char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1));
+  status_bar_get_password();
+  status_bar_refresh();
+  inp_block();
+  inp_get_password(passwd);
+  inp_non_block();
+
+  return passwd;
+}
+
 static void
 _ui_draw_win_title(void)
 {
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 5ec4debd..f6bb98ac 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -80,6 +80,7 @@ char * ui_recipient(int index);
 void ui_close_win(int index);
 gboolean ui_win_exists(int index);
 int ui_win_unread(int index);
+char * ui_ask_password(void);
 
 // ui events
 void ui_contact_typing(const char * const from);
408'>408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606