From fdec3a14c5f1b61aab2047362d9851a115876019 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 24 Oct 2012 21:15:44 +0100 Subject: [PATCH 1/8] Updated for release 0.1.9 --- configure.ac | 2 +- docs/profanity.1 | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 41d59087..c0590d44 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.65]) AC_INIT([profanity], [0.1.9], [boothj5web@gmail.com]) -AC_DEFINE([PACKAGE_STATUS], ["development"], [Status of this build]) +AC_DEFINE([PACKAGE_STATUS], ["release"], [Status of this build]) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/docs/profanity.1 b/docs/profanity.1 index f570b3fc..b4529d80 100644 --- a/docs/profanity.1 +++ b/docs/profanity.1 @@ -78,6 +78,8 @@ typing=true .br remind=15 .br +vercheck=on +.br .PP [colours] .br @@ -152,8 +154,8 @@ was written by James Booth with contributions from: .br .PP -Dolan O'Toole -.br Colin Bradley .br Dmitry Podgorny +.br +Dolan O'Toole From c27fb67b1d6688e0c5933225e3be4e69bd79fcb0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 24 Oct 2012 21:17:30 +0100 Subject: [PATCH 2/8] Updated to 0.1.10 development --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c0590d44..b7774c13 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([profanity], [0.1.9], [boothj5web@gmail.com]) -AC_DEFINE([PACKAGE_STATUS], ["release"], [Status of this build]) +AC_INIT([profanity], [0.1.10], [boothj5web@gmail.com]) +AC_DEFINE([PACKAGE_STATUS], ["development"], [Status of this build]) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_AUX_DIR([build-aux]) From 12b7d70f8307ef3270dbefd82415cdbc8a7f7876 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Oct 2012 17:28:02 +0100 Subject: [PATCH 3/8] Correction in man page --- docs/profanity.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/profanity.1 b/docs/profanity.1 index b4529d80..fc5cd37a 100644 --- a/docs/profanity.1 +++ b/docs/profanity.1 @@ -78,7 +78,7 @@ typing=true .br remind=15 .br -vercheck=on +vercheck=true .br .PP [colours] From 2abd525caec64a252079fce0ea68a62a628848c5 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Oct 2012 17:30:30 +0100 Subject: [PATCH 4/8] Show development version when splash screen enabled --- src/windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windows.c b/src/windows.c index bd06165d..957e90f5 100644 --- a/src/windows.c +++ b/src/windows.c @@ -961,7 +961,7 @@ _cons_splash_logo(void) _win_show_time(_cons_win); wprintw(_cons_win, "\n"); _win_show_time(_cons_win); - if (strcmp(PACKAGE_STATUS, "dev") == 0) { + if (strcmp(PACKAGE_STATUS, "development") == 0) { wprintw(_cons_win, "Version %sdev\n", PACKAGE_VERSION); } else { wprintw(_cons_win, "Version %s\n", PACKAGE_VERSION); From 852112cda81a861e7895de00233ea20b86c80a82 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Oct 2012 17:40:17 +0100 Subject: [PATCH 5/8] Removed _shutdown function in profanity.c --- src/command.c | 2 +- src/profanity.c | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/command.c b/src/command.c index b30e9cae..d5245e0d 100644 --- a/src/command.c +++ b/src/command.c @@ -272,7 +272,7 @@ static struct cmd_t setting_commands[] = "Config file section : [ui]", "Config file value : showsplash=true|false", NULL } } }, - + { "/vercheck", _cmd_vercheck, { "/vercheck [on|off]", "Check for a new release.", diff --git a/src/profanity.c b/src/profanity.c index 1045662b..c13e13a9 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -44,7 +44,6 @@ static void _create_config_directory(); static void _free_roster_entry(jabber_roster_entry *entry); static void _init(const int disable_tls, char *log_level); static void _shutdown_init(void); -static void _shutdown(void); void prof_run(const int disable_tls, char *log_level) @@ -302,12 +301,6 @@ _shutdown_init(void) jabber_free_resources(); } - _shutdown(); -} - -static void -_shutdown(void) -{ contact_list_clear(); gui_close(); chat_log_close(); From 28d388319abd2fc6aafe17ce1d4bc80c2bac5ae5 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Oct 2012 18:12:04 +0100 Subject: [PATCH 6/8] Added /disconnect command --- src/command.c | 31 +++++++++++++++++++++++++++++++ src/jabber.c | 7 +++++++ src/jabber.h | 1 + src/profanity.c | 4 ++-- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index d5245e0d..938142e4 100644 --- a/src/command.c +++ b/src/command.c @@ -65,6 +65,7 @@ static gboolean _cmd_about(const char * const inp, struct cmd_help_t help); static gboolean _cmd_prefs(const char * const inp, struct cmd_help_t help); static gboolean _cmd_who(const char * const inp, struct cmd_help_t help); static gboolean _cmd_connect(const char * const inp, struct cmd_help_t help); +static gboolean _cmd_disconnect(const char * const inp, struct cmd_help_t help); static gboolean _cmd_msg(const char * const inp, struct cmd_help_t help); static gboolean _cmd_tiny(const char * const inp, struct cmd_help_t help); static gboolean _cmd_close(const char * const inp, struct cmd_help_t help); @@ -124,6 +125,15 @@ static struct cmd_t main_commands[] = "Example: /connect myuser@gmail.com", NULL } } }, + { "/disconnect", + _cmd_disconnect, + { "/disconnect", "Logout of current jabber session.", + { "/disconnect", + "------------------", + "Disconnect from the current jabber session.", + "See the /connect command for connecting again.", + NULL } } }, + { "/prefs", _cmd_prefs, { "/prefs", "Show current preferences.", @@ -564,6 +574,27 @@ _cmd_connect(const char * const inp, struct cmd_help_t help) return result; } +static gboolean +_cmd_disconnect(const char * const inp, struct cmd_help_t help) +{ + char *jid = strdup(jabber_get_jid()); + gboolean wait_response = jabber_disconnect(); + + if (wait_response) { + while (jabber_get_connection_status() == JABBER_DISCONNECTING) { + jabber_process_events(); + } + jabber_free_resources(); + } + + contact_list_clear(); + jabber_restart(); + cons_show("%s logged out successfully.", jid); + free(jid); + + return TRUE; +} + static gboolean _cmd_quit(const char * const inp, struct cmd_help_t help) { diff --git a/src/jabber.c b/src/jabber.c index ea7e38c4..2a199676 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -70,6 +70,13 @@ jabber_init(const int disable_tls) jabber_conn.tls_disabled = disable_tls; } +void +jabber_restart(void) +{ + jabber_conn.conn_status = JABBER_STARTED; + jabber_conn.presence = PRESENCE_OFFLINE; +} + jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd) diff --git a/src/jabber.h b/src/jabber.h index b7e3f87c..a03566a7 100644 --- a/src/jabber.h +++ b/src/jabber.h @@ -51,5 +51,6 @@ void jabber_update_presence(jabber_presence_t status, const char * const msg); const char * jabber_get_jid(void); jabber_conn_status_t jabber_get_connection_status(void); void jabber_free_resources(void); +void jabber_restart(void); #endif diff --git a/src/profanity.c b/src/profanity.c index c13e13a9..11270d3e 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -134,7 +134,7 @@ loop_out: void prof_handle_login_success(const char *jid) { - const char *msg = " logged in successfully."; + const char *msg = "logged in successfully."; cons_show("%s %s", jid, msg); title_bar_set_status(PRESENCE_ONLINE); log_info("%s %s", jid, msg); @@ -201,7 +201,7 @@ prof_handle_roster(GSList *roster) } static void -_create_config_directory() +_create_config_directory(void) { GString *dir = g_string_new(getenv("HOME")); g_string_append(dir, "/.profanity"); From d658915740d8681db8ce61bf65aa4647f8007993 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Oct 2012 18:15:26 +0100 Subject: [PATCH 7/8] Renamed shutdown function --- src/profanity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/profanity.c b/src/profanity.c index 11270d3e..22144376 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -43,7 +43,7 @@ static gboolean _process_input(char *inp); static void _create_config_directory(); static void _free_roster_entry(jabber_roster_entry *entry); static void _init(const int disable_tls, char *log_level); -static void _shutdown_init(void); +static void _shutdown(void); void prof_run(const int disable_tls, char *log_level) @@ -286,11 +286,11 @@ _init(const int disable_tls, char *log_level) cmd_init(); log_info("Initialising contact list"); contact_list_init(); - atexit(_shutdown_init); + atexit(_shutdown); } static void -_shutdown_init(void) +_shutdown(void) { gboolean wait_response = jabber_disconnect(); From 847850742c55876676e22e6b7918361dfe086145 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Oct 2012 18:26:57 +0100 Subject: [PATCH 8/8] Refactored disconnect --- src/command.c | 22 +++++++++------------- src/jabber.c | 15 +++++---------- src/jabber.h | 2 +- src/profanity.c | 10 +--------- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/command.c b/src/command.c index 938142e4..361f53b4 100644 --- a/src/command.c +++ b/src/command.c @@ -577,21 +577,17 @@ _cmd_connect(const char * const inp, struct cmd_help_t help) static gboolean _cmd_disconnect(const char * const inp, struct cmd_help_t help) { - char *jid = strdup(jabber_get_jid()); - gboolean wait_response = jabber_disconnect(); - - if (wait_response) { - while (jabber_get_connection_status() == JABBER_DISCONNECTING) { - jabber_process_events(); - } - jabber_free_resources(); + if (jabber_get_connection_status() == JABBER_CONNECTED) { + char *jid = strdup(jabber_get_jid()); + jabber_disconnect(); + contact_list_clear(); + jabber_restart(); + cons_show("%s logged out successfully.", jid); + free(jid); + } else { + cons_show("You are not currently connected."); } - contact_list_clear(); - jabber_restart(); - cons_show("%s logged out successfully.", jid); - free(jid); - return TRUE; } diff --git a/src/jabber.c b/src/jabber.c index 2a199676..e6436f91 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -105,7 +105,7 @@ jabber_connect(const char * const user, return jabber_conn.conn_status; } -gboolean +void jabber_disconnect(void) { // if connected, send end stream and wait for response @@ -113,16 +113,11 @@ jabber_disconnect(void) log_info("Closing connection"); xmpp_disconnect(jabber_conn.conn); jabber_conn.conn_status = JABBER_DISCONNECTING; - return TRUE; - // if disconnected dont wait just shutdown - } else if (jabber_conn.conn_status == JABBER_DISCONNECTED) { - log_info("No connection open"); - return FALSE; - - // any other states, just shutdown - } else { - return FALSE; + while (jabber_get_connection_status() == JABBER_DISCONNECTING) { + jabber_process_events(); + } + jabber_free_resources(); } } diff --git a/src/jabber.h b/src/jabber.h index a03566a7..d12d00b3 100644 --- a/src/jabber.h +++ b/src/jabber.h @@ -43,7 +43,7 @@ typedef enum { void jabber_init(const int disable_tls); jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd); -gboolean jabber_disconnect(void); +void jabber_disconnect(void); void jabber_roster_request(void); void jabber_process_events(void); void jabber_send(const char * const msg, const char * const recipient); diff --git a/src/profanity.c b/src/profanity.c index 22144376..261410ff 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -292,15 +292,7 @@ _init(const int disable_tls, char *log_level) static void _shutdown(void) { - gboolean wait_response = jabber_disconnect(); - - if (wait_response) { - while (jabber_get_connection_status() == JABBER_DISCONNECTING) { - jabber_process_events(); - } - jabber_free_resources(); - } - + jabber_disconnect(); contact_list_clear(); gui_close(); chat_log_close();