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.
This commit is contained in:
Paul Fariello
2019-04-12 11:46:01 +02:00
parent 0dfe61c01c
commit 9714d1d867
4 changed files with 27 additions and 3 deletions

View File

@@ -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