diff --git a/src/common.c b/src/common.c index 477c41b4..009c6f41 100644 --- a/src/common.c +++ b/src/common.c @@ -921,7 +921,7 @@ prof_date_time_format_iso8601(GDateTime* dt) return ret; } -/* build profanity version string. +/* build CProof version string. * example: 0.13.1dev.master.69d8c1f9 */ gchar* diff --git a/src/config/preferences.c b/src/config/preferences.c index 04d3dda5..cf79d01b 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -2689,7 +2689,6 @@ _get_default_boolean(preference_t pref) case PREF_STATUSBAR_SHOW_NUMBER: case PREF_STATUSBAR_SHOW_READ: case PREF_STATUSBAR_SHOW_DBBACKEND: - case PREF_REVEAL_OS: case PREF_CORRECTION_ALLOW: case PREF_RECEIPTS_SEND: case PREF_CARBONS: @@ -2704,6 +2703,7 @@ _get_default_boolean(preference_t pref) case PREF_STROPHE_SM_RESEND: case PREF_AUTOPING_WARNING: return TRUE; + case PREF_REVEAL_OS: case PREF_SPELLCHECK_ENABLE: case PREF_PGP_PUBKEY_AUTOIMPORT: case PREF_FORCE_ENCRYPTION: diff --git a/src/main.c b/src/main.c index 5e65b45f..29f2c532 100644 --- a/src/main.c +++ b/src/main.c @@ -77,7 +77,7 @@ main(int argc, char** argv) if (version == TRUE) { auto_gchar gchar* prof_version = prof_get_version(); - g_print("Profanity, version %s\n", prof_version); + g_print("CProof, version %s\n", prof_version); // lets use fixed email instead of PACKAGE_BUGREPORT g_print("Copyright (C) 2012 - 2019 James Booth .\n"); diff --git a/src/profanity.c b/src/profanity.c index 4477d6a9..1214d1fc 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -253,7 +253,7 @@ _init(char* log_level, char* config_file, char* log_file, char* theme_name) log_stderr_init(PROF_LEVEL_ERROR); auto_gchar gchar* prof_version = prof_get_version(); - log_info("Starting Profanity (%s)…", prof_version); + log_info("Starting CProof (%s)…", prof_version); chatlog_init(); accounts_load(); diff --git a/src/ui/console.c b/src/ui/console.c index de565d38..02a8b2a4 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2830,8 +2830,7 @@ cons_privacy_setting(void) if (account->client) { cons_show("Client name (/account set clientid) : %s", account->client); } else { - auto_gchar gchar* prof_version = prof_get_version(); - cons_show("Client name (/account set clientid) : Profanity %s", prof_version); + cons_show("Client name (/account set clientid) : Pidgin"); } if (account->max_sessions > 0) { cons_show("Max sessions alarm (/account set session_alarm) : %d", account->max_sessions); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index ffcf200f..2a472bcf 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1681,7 +1681,7 @@ _version_get_handler(xmpp_stanza_t* const stanza) xmpp_stanza_t* name = xmpp_stanza_new(ctx); xmpp_stanza_set_name(name, "name"); xmpp_stanza_t* name_txt = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(name_txt, is_custom_client ? client : "Profanity"); + xmpp_stanza_set_text(name_txt, is_custom_client ? client : "Pidgin"); xmpp_stanza_add_child(name, name_txt); xmpp_stanza_add_child(query, name); bool include_os = prefs_get_boolean(PREF_REVEAL_OS) && !is_custom_client; @@ -1690,7 +1690,7 @@ _version_get_handler(xmpp_stanza_t* const stanza) xmpp_stanza_t* version = xmpp_stanza_new(ctx); xmpp_stanza_set_name(version, "version"); xmpp_stanza_t* version_txt = xmpp_stanza_new(ctx); - auto_gchar gchar* prof_version = prof_get_version(); + auto_gchar gchar* prof_version = g_strdup(""); if (!is_custom_client) { xmpp_stanza_set_text(version_txt, prof_version); diff --git a/src/xmpp/jid.c b/src/xmpp/jid.c index 1a191dcf..d16b2cb0 100644 --- a/src/xmpp/jid.c +++ b/src/xmpp/jid.c @@ -280,9 +280,13 @@ jid_fulljid_or_barejid(Jid* jid) gchar* jid_random_resource(void) { - auto_gchar gchar* rand = get_random_string(4); + gchar* rand = g_malloc0(29); + const gchar* digits = "0123456789"; - gchar* result = g_strdup_printf("profanity.%s", rand); + for (int i = 0; i < 28; i++) { + rand[i] = digits[g_random_int_range(0, 10)]; + } + rand[28] = '\0'; - return result; + return rand; } diff --git a/src/xmpp/session.c b/src/xmpp/session.c index 1cf46554..01a5b08b 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -178,7 +178,7 @@ session_connect_with_details(const char* const jid, const char* const passwd, co saved_details.auth_policy = NULL; } - // use 'profanity' when no resourcepart in provided jid + // use random string when no resourcepart in provided jid auto_jid Jid* jidp = jid_create(jid); if (jidp->resourcepart == NULL) { auto_gchar gchar* resource = jid_random_resource(); diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 4fde3ce0..cfe42335 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -32,6 +32,7 @@ static void _stanza_add_unique_id(xmpp_stanza_t* stanza); static gchar* _stanza_create_sha1_hash(char* str); +static const char* _stanza_get_caps_node(const char* const client); #if 0 xmpp_stanza_t* @@ -930,23 +931,22 @@ stanza_create_caps_query_element(xmpp_ctx_t* ctx) xmpp_stanza_t* identity = xmpp_stanza_new(ctx); xmpp_stanza_set_name(identity, "identity"); + xmpp_stanza_set_type(identity, "pc"); xmpp_stanza_set_attribute(identity, "category", "client"); ProfAccount* account = accounts_get_account(session_get_account_name()); - gchar* client = account->client; - bool is_custom_client = client != NULL; - GString* name_str = g_string_new(is_custom_client ? client : "Profanity "); - if (!is_custom_client) { - xmpp_stanza_set_type(identity, "console"); - auto_gchar gchar* prof_version = prof_get_version(); - g_string_append(name_str, prof_version); + auto_gchar gchar* name = g_strdup(account->client ? account->client : "Pidgin"); + + if (account->client) { + gchar* space = strchr(name, ' '); + if (space) { + *space = '\0'; + } } - account_free(account); - xmpp_stanza_set_attribute(identity, "name", name_str->str); - g_string_free(name_str, TRUE); + xmpp_stanza_set_attribute(identity, "name", name); xmpp_stanza_add_child(query, identity); xmpp_stanza_release(identity); @@ -1994,6 +1994,42 @@ stanza_attach_last_activity(xmpp_ctx_t* const ctx, xmpp_stanza_release(query); } +static const char* +_stanza_get_caps_node(const char* const client) +{ + if (!client || g_strcmp0(client, "") == 0) { + return "http://pidgin.im"; + } + + auto_gchar gchar* lower = g_ascii_strdown(client, -1); + + if (g_str_has_prefix(lower, "pidgin")) { + return "http://pidgin.im"; + } + + if (g_str_has_prefix(lower, "gajim")) { + return "https://gajim.org"; + } + + if (g_str_has_prefix(lower, "conversations")) { + return "https://conversations.im"; + } + + if (g_str_has_prefix(lower, "psi+")) { + return "http://psi-plus.com"; + } + + if (g_str_has_prefix(lower, "psi")) { + return "http://psi-im.org"; + } + + if (g_str_has_prefix(lower, "profanity")) { + return "http://profanity-im.github.io"; + } + + return ""; +} + void stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence) { @@ -2002,9 +2038,13 @@ stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence) xmpp_stanza_set_ns(caps, STANZA_NS_CAPS); xmpp_stanza_t* query = stanza_create_caps_query_element(ctx); + ProfAccount* account = accounts_get_account(session_get_account_name()); + const char* node = _stanza_get_caps_node(account->client); + account_free(account); + char* sha1 = caps_get_my_sha1(ctx); xmpp_stanza_set_attribute(caps, STANZA_ATTR_HASH, "sha-1"); - xmpp_stanza_set_attribute(caps, STANZA_ATTR_NODE, "http://profanity-im.github.io"); + xmpp_stanza_set_attribute(caps, STANZA_ATTR_NODE, node); xmpp_stanza_set_attribute(caps, STANZA_ATTR_VER, sha1); xmpp_stanza_add_child(presence, caps); xmpp_stanza_release(caps); diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c index 4b202c26..e4bfcca0 100644 --- a/tests/functionaltests/proftest.c +++ b/tests/functionaltests/proftest.c @@ -601,11 +601,11 @@ prof_connect_with_roster(const char* roster) assert_true(prof_output_regex(".+online.+ \\(priority 0\\)\\.")); expect_timeout = EXPECT_TIMEOUT_CONNECT; - // Wait for presence stanza to be sent (content-based, not ID-based) + // Wait for presence stanza to be sent // Match the actual attribute order from stanza_attach_caps assert_true(stbbr_received( "" - "" + "" "")); } diff --git a/tests/functionaltests/test_connect.c b/tests/functionaltests/test_connect.c index 984f52bf..b10bb029 100644 --- a/tests/functionaltests/test_connect.c +++ b/tests/functionaltests/test_connect.c @@ -25,7 +25,7 @@ connect_jid_sends_presence_after_receiving_roster(void **state) assert_true(stbbr_received( "" - "" + "" "" )); } diff --git a/tests/functionaltests/test_export_import.c b/tests/functionaltests/test_export_import.c index 8475cb9d..5117423e 100644 --- a/tests/functionaltests/test_export_import.c +++ b/tests/functionaltests/test_export_import.c @@ -1289,7 +1289,7 @@ _join_muc(const char* room) snprintf(presence, sizeof(presence), "" "" + "node='*' ver='*'/>" "" "" "" diff --git a/tests/functionaltests/test_muc.c b/tests/functionaltests/test_muc.c index 0b618ab3..68c8714a 100644 --- a/tests/functionaltests/test_muc.c +++ b/tests/functionaltests/test_muc.c @@ -26,7 +26,7 @@ sends_room_join(void **state) assert_true(stbbr_received( "" "" - "" + "" "" )); } @@ -41,7 +41,7 @@ sends_room_join_with_nick(void **state) assert_true(stbbr_received( "" "" - "" + "" "" )); } @@ -58,7 +58,7 @@ sends_room_join_with_password(void **state) "" "testpassword" "" - "" + "" "" )); } @@ -75,7 +75,7 @@ sends_room_join_with_nick_and_password(void **state) "" "testpassword" "" - "" + "" "" )); } @@ -87,7 +87,7 @@ shows_role_and_affiliation_on_join(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -107,7 +107,7 @@ shows_subject_on_join(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -135,7 +135,7 @@ shows_history_message(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -170,7 +170,7 @@ shows_occupant_join(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -200,7 +200,7 @@ shows_message(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -227,7 +227,7 @@ shows_me_message_from_occupant(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -254,7 +254,7 @@ shows_me_message_from_self(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -281,7 +281,7 @@ shows_all_messages_in_console_when_window_not_focussed(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -322,7 +322,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -369,7 +369,7 @@ shows_no_message_in_console_when_window_not_focussed(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -401,7 +401,7 @@ sends_affiliation_list_request(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" @@ -434,7 +434,7 @@ sends_kick_request(void **state) stbbr_for_presence_to("testroom@conference.localhost/stabber", "" - "" + "" "" "" "" diff --git a/tests/functionaltests/test_presence.c b/tests/functionaltests/test_presence.c index 488c07ac..8cb05a36 100644 --- a/tests/functionaltests/test_presence.c +++ b/tests/functionaltests/test_presence.c @@ -19,7 +19,7 @@ presence_online(void **state) assert_true(stbbr_received( "" "online" - "" + "" "" )); } @@ -36,7 +36,7 @@ presence_online_with_message(void **state) assert_true(stbbr_received( "" "Hi there" - "" + "" "" )); } @@ -54,7 +54,7 @@ presence_away(void **state) "" "away" "away" - "" + "" "" )); } @@ -72,7 +72,7 @@ presence_away_with_message(void **state) "" "away" "I'm not here for a bit" - "" + "" "" )); } @@ -90,7 +90,7 @@ presence_xa(void **state) "" "xa" "xa" - "" + "" "" )); } @@ -108,7 +108,7 @@ presence_xa_with_message(void **state) "" "xa" "Gone to the shops" - "" + "" "" )); } @@ -126,7 +126,7 @@ presence_dnd(void **state) "" "dnd" "dnd" - "" + "" "" )); } @@ -144,7 +144,7 @@ presence_dnd_with_message(void **state) "" "dnd" "Working" - "" + "" "" )); } @@ -162,7 +162,7 @@ presence_chat(void **state) "" "chat" "chat" - "" + "" "" )); } @@ -180,7 +180,7 @@ presence_chat_with_message(void **state) "" "chat" "Free to talk" - "" + "" "" )); } @@ -197,7 +197,7 @@ presence_set_priority(void **state) assert_true(stbbr_received( "" "25" - "" + "" "" )); } @@ -212,7 +212,7 @@ presence_includes_priority(void **state) assert_true(stbbr_received( "" "25" - "" + "" "" )); @@ -223,7 +223,7 @@ presence_includes_priority(void **state) "25" "chat" "Free to talk" - "" + "" "" )); } @@ -239,7 +239,7 @@ presence_keeps_status(void **state) "" "chat" "Free to talk" - "" + "" "" )); @@ -250,7 +250,7 @@ presence_keeps_status(void **state) "chat" "Free to talk" "25" - "" + "" "" )); }