diff options
author | Paul Fariello <paul@fariello.eu> | 2019-04-12 11:46:01 +0200 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2019-04-12 15:49:54 +0200 |
commit | 9714d1d867bac6fdbc3d124f923a36a1dc2ea504 (patch) | |
tree | 9a9b1c2951e91e1cb13a2c85b1b94d6efb2c466b /src/config/accounts.c | |
parent | 0dfe61c01cddf48a0a614927bb29a52625464525 (diff) | |
download | profani-tty-9714d1d867bac6fdbc3d124f923a36a1dc2ea504.tar.gz |
Add random string at the end of the default resource
When connecting for the first time or when creating a new account don't use only 'profanity' as default resource. Some server don't support having 2 connection with same resource. Using profanity as default lead to deconnections.
Diffstat (limited to 'src/config/accounts.c')
-rw-r--r-- | src/config/accounts.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c index f53f53c9..1c6441db 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -124,16 +124,17 @@ accounts_add(const char *account_name, const char *altdomain, const int port, co { // set account name and resource const char *barejid = account_name; - const char *resource = "profanity"; + char *resource = jid_random_resource(); Jid *jid = jid_create(account_name); if (jid) { barejid = jid->barejid; if (jid->resourcepart) { - resource = jid->resourcepart; + resource = g_strdup(jid->resourcepart); } } if (g_key_file_has_group(accounts, account_name)) { + g_free(resource); jid_destroy(jid); return; } @@ -174,6 +175,7 @@ accounts_add(const char *account_name, const char *altdomain, const int port, co autocomplete_add(enabled_ac, account_name); jid_destroy(jid); + g_free(resource); } int |