mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Add helper function to create version string
And remove all the duplicate code. Depending on the situation prof_get_version() will return: * 0.13.1 * 0.13.1dev * 0.13.1dev.master.69d8c1f9
This commit is contained in:
parent
13af6c96dc
commit
22b1d14b67
21
src/common.c
21
src/common.c
@ -62,6 +62,10 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_GIT_VERSION
|
||||||
|
#include "gitversion.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct curl_data_t
|
struct curl_data_t
|
||||||
{
|
{
|
||||||
char* buffer;
|
char* buffer;
|
||||||
@ -688,3 +692,20 @@ glib_hash_table_free(GHashTable* hash_table)
|
|||||||
g_hash_table_remove_all(hash_table);
|
g_hash_table_remove_all(hash_table);
|
||||||
g_hash_table_unref(hash_table);
|
g_hash_table_unref(hash_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* build profanity version string.
|
||||||
|
* example: 0.13.1dev.master.69d8c1f9
|
||||||
|
*/
|
||||||
|
gchar*
|
||||||
|
prof_get_version(void)
|
||||||
|
{
|
||||||
|
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
||||||
|
#ifdef HAVE_GIT_VERSION
|
||||||
|
return g_strdup_printf("%sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
|
||||||
|
#else
|
||||||
|
return g_strdup_printf("%sdev", PACKAGE_VERSION);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
return g_strdup_printf("%s", PACKAGE_VERSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -180,4 +180,6 @@ gchar* get_expanded_path(const char* path);
|
|||||||
void glib_hash_table_free(GHashTable* hash_table);
|
void glib_hash_table_free(GHashTable* hash_table);
|
||||||
char* basename_from_url(const char* url);
|
char* basename_from_url(const char* url);
|
||||||
|
|
||||||
|
gchar* prof_get_version(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
15
src/main.c
15
src/main.c
@ -39,10 +39,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
#include "otr/otr.h"
|
#include "otr/otr.h"
|
||||||
#endif
|
#endif
|
||||||
@ -104,15 +100,8 @@ main(int argc, char** argv)
|
|||||||
g_option_context_free(context);
|
g_option_context_free(context);
|
||||||
|
|
||||||
if (version == TRUE) {
|
if (version == TRUE) {
|
||||||
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
auto_gchar gchar* prof_version = prof_get_version();
|
||||||
#ifdef HAVE_GIT_VERSION
|
g_print("Profanity, version %s\n", prof_version);
|
||||||
g_print("Profanity, version %sdev.%s.%s\n", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
|
|
||||||
#else
|
|
||||||
g_print("Profanity, version %sdev\n", PACKAGE_VERSION);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
g_print("Profanity, version %s\n", PACKAGE_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lets use fixed email instead of PACKAGE_BUGREPORT
|
// lets use fixed email instead of PACKAGE_BUGREPORT
|
||||||
g_print("Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.\n");
|
g_print("Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.\n");
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_GTK
|
#ifdef HAVE_GTK
|
||||||
#include "ui/tray.h"
|
#include "ui/tray.h"
|
||||||
#endif
|
#endif
|
||||||
@ -180,15 +176,8 @@ _init(char* log_level, char* config_file, char* log_file, char* theme_name)
|
|||||||
log_init(prof_log_level, log_file);
|
log_init(prof_log_level, log_file);
|
||||||
log_stderr_init(PROF_LEVEL_ERROR);
|
log_stderr_init(PROF_LEVEL_ERROR);
|
||||||
|
|
||||||
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
auto_gchar gchar* prof_version = prof_get_version();
|
||||||
#ifdef HAVE_GIT_VERSION
|
log_info("Starting Profanity (%s)…", prof_version);
|
||||||
log_info("Starting Profanity (%sdev.%s.%s)…", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
|
|
||||||
#else
|
|
||||||
log_info("Starting Profanity (%sdev)…", PACKAGE_VERSION);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
log_info("Starting Profanity (%s)…", PACKAGE_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
chat_log_init();
|
chat_log_init();
|
||||||
groupchat_log_init();
|
groupchat_log_init();
|
||||||
|
@ -66,10 +66,6 @@
|
|||||||
#include "xmpp/muc.h"
|
#include "xmpp/muc.h"
|
||||||
#include "xmpp/roster_list.h"
|
#include "xmpp/roster_list.h"
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void _cons_splash_logo(void);
|
static void _cons_splash_logo(void);
|
||||||
static void _show_roster_contacts(GSList* list, gboolean show_groups);
|
static void _show_roster_contacts(GSList* list, gboolean show_groups);
|
||||||
static GList* alert_list;
|
static GList* alert_list;
|
||||||
@ -413,16 +409,8 @@ cons_about(void)
|
|||||||
if (prefs_get_boolean(PREF_SPLASH)) {
|
if (prefs_get_boolean(PREF_SPLASH)) {
|
||||||
_cons_splash_logo();
|
_cons_splash_logo();
|
||||||
} else {
|
} else {
|
||||||
|
auto_gchar gchar* prof_version = prof_get_version();
|
||||||
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", prof_version);
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
|
|
||||||
#else
|
|
||||||
win_println(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev", PACKAGE_VERSION);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", PACKAGE_VERSION);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.");
|
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.");
|
||||||
@ -2778,15 +2766,8 @@ _cons_splash_logo(void)
|
|||||||
win_println(console, THEME_SPLASH, "-", "|_| (____/ ");
|
win_println(console, THEME_SPLASH, "-", "|_| (____/ ");
|
||||||
win_println(console, THEME_SPLASH, "-", "");
|
win_println(console, THEME_SPLASH, "-", "");
|
||||||
|
|
||||||
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
auto_gchar gchar* prof_version = prof_get_version();
|
||||||
#ifdef HAVE_GIT_VERSION
|
win_println(console, THEME_DEFAULT, "-", "Version %s", prof_version);
|
||||||
win_println(console, THEME_DEFAULT, "-", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
|
|
||||||
#else
|
|
||||||
win_println(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
win_println(console, THEME_DEFAULT, "-", "Version %s", PACKAGE_VERSION);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -1627,20 +1623,10 @@ _version_get_handler(xmpp_stanza_t* const stanza)
|
|||||||
xmpp_stanza_t* version = xmpp_stanza_new(ctx);
|
xmpp_stanza_t* version = xmpp_stanza_new(ctx);
|
||||||
xmpp_stanza_set_name(version, "version");
|
xmpp_stanza_set_name(version, "version");
|
||||||
xmpp_stanza_t* version_txt = xmpp_stanza_new(ctx);
|
xmpp_stanza_t* version_txt = xmpp_stanza_new(ctx);
|
||||||
GString* version_str = g_string_new(PACKAGE_VERSION);
|
auto_gchar gchar* prof_version = prof_get_version();
|
||||||
|
|
||||||
if (!is_custom_client) {
|
if (!is_custom_client) {
|
||||||
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
xmpp_stanza_set_text(version_txt, prof_version);
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
g_string_append(version_str, "dev.");
|
|
||||||
g_string_append(version_str, PROF_GIT_BRANCH);
|
|
||||||
g_string_append(version_str, ".");
|
|
||||||
g_string_append(version_str, PROF_GIT_REVISION);
|
|
||||||
#else
|
|
||||||
g_string_append(version_str, "dev");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
xmpp_stanza_set_text(version_txt, version_str->str);
|
|
||||||
xmpp_stanza_add_child(version, version_txt);
|
xmpp_stanza_add_child(version, version_txt);
|
||||||
xmpp_stanza_add_child(query, version);
|
xmpp_stanza_add_child(query, version);
|
||||||
|
|
||||||
@ -1678,7 +1664,6 @@ _version_get_handler(xmpp_stanza_t* const stanza)
|
|||||||
iq_send_stanza(response);
|
iq_send_stanza(response);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
g_string_free(version_str, TRUE);
|
|
||||||
xmpp_stanza_release(version_txt);
|
xmpp_stanza_release(version_txt);
|
||||||
xmpp_stanza_release(name_txt);
|
xmpp_stanza_release(name_txt);
|
||||||
if (!is_custom_client && include_os) {
|
if (!is_custom_client && include_os) {
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
#include "gitversion.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -963,17 +959,8 @@ stanza_create_caps_query_element(xmpp_ctx_t* ctx)
|
|||||||
GString* name_str = g_string_new(is_custom_client ? client : "Profanity ");
|
GString* name_str = g_string_new(is_custom_client ? client : "Profanity ");
|
||||||
if (!is_custom_client) {
|
if (!is_custom_client) {
|
||||||
xmpp_stanza_set_type(identity, "console");
|
xmpp_stanza_set_type(identity, "console");
|
||||||
g_string_append(name_str, PACKAGE_VERSION);
|
auto_gchar gchar* prof_version = prof_get_version();
|
||||||
if (g_strcmp0(PACKAGE_STATUS, "development") == 0) {
|
g_string_append(name_str, prof_version);
|
||||||
#ifdef HAVE_GIT_VERSION
|
|
||||||
g_string_append(name_str, "dev.");
|
|
||||||
g_string_append(name_str, PROF_GIT_BRANCH);
|
|
||||||
g_string_append(name_str, ".");
|
|
||||||
g_string_append(name_str, PROF_GIT_REVISION);
|
|
||||||
#else
|
|
||||||
g_string_append(name_str, "dev");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
account_free(account);
|
account_free(account);
|
||||||
|
Loading…
Reference in New Issue
Block a user