mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into otr
This commit is contained in:
commit
97f42d515e
@ -315,8 +315,8 @@ static struct cmd_t command_defs[] =
|
|||||||
"--------------------------",
|
"--------------------------",
|
||||||
"Join a chat room at the conference server.",
|
"Join a chat room at the conference server.",
|
||||||
"If nick is specified you will join with this nickname.",
|
"If nick is specified you will join with this nickname.",
|
||||||
"Otherwise the 'localpart' of your JID (before the @) will be used.",
|
"Otherwise the account preference 'muc.nick' will be used which is the localpart of your JID (before the @).",
|
||||||
"If no server is supplied, a default of 'conference.<domain-part>' will be used.",
|
"If no server is supplied, the account preference 'muc.service' is used, which is 'conference.<domain-part>' by default.",
|
||||||
"If the room doesn't exist, and the server allows it, a new one will be created.",
|
"If the room doesn't exist, and the server allows it, a new one will be created.",
|
||||||
"",
|
"",
|
||||||
"Example : /join jdev@conference.jabber.org",
|
"Example : /join jdev@conference.jabber.org",
|
||||||
@ -365,8 +365,7 @@ static struct cmd_t command_defs[] =
|
|||||||
{ "/rooms [conference-service]",
|
{ "/rooms [conference-service]",
|
||||||
"---------------------------",
|
"---------------------------",
|
||||||
"List the chat rooms available at the specified conference service",
|
"List the chat rooms available at the specified conference service",
|
||||||
"If no argument is supplied, the domainpart of the current logged in JID is used,",
|
"If no argument is supplied, the account preference 'muc.service' is used, which is 'conference.<domain-part>' by default.",
|
||||||
"with a prefix of 'conference'.",
|
|
||||||
"",
|
"",
|
||||||
"Example : /rooms conference.jabber.org",
|
"Example : /rooms conference.jabber.org",
|
||||||
"Example : /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)",
|
"Example : /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)",
|
||||||
@ -748,11 +747,15 @@ static struct cmd_t command_defs[] =
|
|||||||
"online|chat|away",
|
"online|chat|away",
|
||||||
"|xa|dnd : Priority for the specified presence.",
|
"|xa|dnd : Priority for the specified presence.",
|
||||||
"resource : The resource to be used.",
|
"resource : The resource to be used.",
|
||||||
|
"muc : The default MUC chat service to use.",
|
||||||
|
"nick : The default nickname to use when joining chat rooms.",
|
||||||
"",
|
"",
|
||||||
"Example : /account add work",
|
"Example : /account add work",
|
||||||
" : /account set work jid myuser@mycompany.com",
|
" : /account set work jid myuser@mycompany.com",
|
||||||
" : /account set work server talk.google.com",
|
" : /account set work server talk.google.com",
|
||||||
" : /account set work resource desktop",
|
" : /account set work resource desktop",
|
||||||
|
" : /account set work muc chatservice.mycompany.com",
|
||||||
|
" : /account set work nick dennis",
|
||||||
" : /account set work status dnd",
|
" : /account set work status dnd",
|
||||||
" : /account set work dnd -1",
|
" : /account set work dnd -1",
|
||||||
" : /account set work online 10",
|
" : /account set work online 10",
|
||||||
@ -1502,6 +1505,14 @@ _cmd_account(gchar **args, struct cmd_help_t help)
|
|||||||
accounts_set_resource(account_name, value);
|
accounts_set_resource(account_name, value);
|
||||||
cons_show("Updated resource for account %s: %s", account_name, value);
|
cons_show("Updated resource for account %s: %s", account_name, value);
|
||||||
cons_show("");
|
cons_show("");
|
||||||
|
} else if (strcmp(property, "muc") == 0) {
|
||||||
|
accounts_set_muc_service(account_name, value);
|
||||||
|
cons_show("Updated muc service for account %s: %s", account_name, value);
|
||||||
|
cons_show("");
|
||||||
|
} else if (strcmp(property, "nick") == 0) {
|
||||||
|
accounts_set_muc_nick(account_name, value);
|
||||||
|
cons_show("Updated muc nick for account %s: %s", account_name, value);
|
||||||
|
cons_show("");
|
||||||
} else if (strcmp(property, "status") == 0) {
|
} else if (strcmp(property, "status") == 0) {
|
||||||
if (!valid_resource_presence_string(value) && (strcmp(value, "last") != 0)) {
|
if (!valid_resource_presence_string(value) && (strcmp(value, "last") != 0)) {
|
||||||
cons_show("Invalid status: %s", value);
|
cons_show("Invalid status: %s", value);
|
||||||
@ -2749,11 +2760,12 @@ _cmd_join(gchar **args, struct cmd_help_t help)
|
|||||||
if (room_arg->localpart != NULL) {
|
if (room_arg->localpart != NULL) {
|
||||||
room = args[0];
|
room = args[0];
|
||||||
|
|
||||||
// server not supplied (room), guess conference.<users-domain-part>
|
// server not supplied (room), use account preference
|
||||||
} else {
|
} else {
|
||||||
|
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
||||||
g_string_append(room_str, args[0]);
|
g_string_append(room_str, args[0]);
|
||||||
g_string_append(room_str, "@conference.");
|
g_string_append(room_str, "@");
|
||||||
g_string_append(room_str, my_jid->domainpart);
|
g_string_append(room_str, account->muc_service);
|
||||||
room = room_str->str;
|
room = room_str->str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2761,9 +2773,10 @@ _cmd_join(gchar **args, struct cmd_help_t help)
|
|||||||
if (num_args == 2) {
|
if (num_args == 2) {
|
||||||
nick = args[1];
|
nick = args[1];
|
||||||
|
|
||||||
// use localpart for nick
|
// otherwise use account preference
|
||||||
} else {
|
} else {
|
||||||
nick = my_jid->localpart;
|
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
||||||
|
nick = account->muc_nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
Jid *room_jid = jid_create_from_bare_and_resource(room, nick);
|
Jid *room_jid = jid_create_from_bare_and_resource(room, nick);
|
||||||
@ -2850,12 +2863,8 @@ _cmd_rooms(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] == NULL) {
|
if (args[0] == NULL) {
|
||||||
Jid *jid = jid_create(jabber_get_fulljid());
|
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
||||||
GString *conference_node = g_string_new("conference.");
|
iq_room_list_request(account->muc_service);
|
||||||
g_string_append(conference_node, jid->domainpart);
|
|
||||||
jid_destroy(jid);
|
|
||||||
iq_room_list_request(conference_node->str);
|
|
||||||
g_string_free(conference_node, TRUE);
|
|
||||||
} else {
|
} else {
|
||||||
iq_room_list_request(args[0]);
|
iq_room_list_request(args[0]);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,15 @@ static GKeyFile *accounts;
|
|||||||
static Autocomplete all_ac;
|
static Autocomplete all_ac;
|
||||||
static Autocomplete enabled_ac;
|
static Autocomplete enabled_ac;
|
||||||
|
|
||||||
static gchar *string_keys[] = {"jid", "server", "resource", "presence.last", "presence.login"};
|
static gchar *string_keys[] = {
|
||||||
|
"jid",
|
||||||
|
"server",
|
||||||
|
"resource",
|
||||||
|
"presence.last",
|
||||||
|
"presence.login",
|
||||||
|
"muc.service",
|
||||||
|
"muc.nick"
|
||||||
|
};
|
||||||
|
|
||||||
static void _fix_legacy_accounts(const char * const account_name);
|
static void _fix_legacy_accounts(const char * const account_name);
|
||||||
static void _save_accounts(void);
|
static void _save_accounts(void);
|
||||||
@ -129,6 +137,19 @@ accounts_add(const char *account_name, const char *altdomain)
|
|||||||
if (altdomain != NULL) {
|
if (altdomain != NULL) {
|
||||||
g_key_file_set_string(accounts, account_name, "server", altdomain);
|
g_key_file_set_string(accounts, account_name, "server", altdomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Jid *jidp = jid_create(barejid);
|
||||||
|
GString *muc_service = g_string_new("conference.");
|
||||||
|
g_string_append(muc_service, jidp->domainpart);
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.service", muc_service->str);
|
||||||
|
g_string_free(muc_service, TRUE);
|
||||||
|
if (jidp->localpart == NULL) {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->domainpart);
|
||||||
|
} else {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->localpart);
|
||||||
|
}
|
||||||
|
jid_destroy(jidp);
|
||||||
|
|
||||||
g_key_file_set_string(accounts, account_name, "presence.last", "online");
|
g_key_file_set_string(accounts, account_name, "presence.last", "online");
|
||||||
g_key_file_set_string(accounts, account_name, "presence.login", "online");
|
g_key_file_set_string(accounts, account_name, "presence.login", "online");
|
||||||
g_key_file_set_integer(accounts, account_name, "priority.online", 0);
|
g_key_file_set_integer(accounts, account_name, "priority.online", 0);
|
||||||
@ -220,6 +241,27 @@ accounts_get_account(const char * const name)
|
|||||||
account->priority_xa = g_key_file_get_integer(accounts, name, "priority.xa", NULL);
|
account->priority_xa = g_key_file_get_integer(accounts, name, "priority.xa", NULL);
|
||||||
account->priority_dnd = g_key_file_get_integer(accounts, name, "priority.dnd", NULL);
|
account->priority_dnd = g_key_file_get_integer(accounts, name, "priority.dnd", NULL);
|
||||||
|
|
||||||
|
gchar *muc_service = g_key_file_get_string(accounts, name, "muc.service", NULL);
|
||||||
|
if (muc_service == NULL) {
|
||||||
|
GString *g_muc_service = g_string_new("conference.");
|
||||||
|
Jid *jidp = jid_create(account->jid);
|
||||||
|
g_string_append(g_muc_service, jidp->domainpart);
|
||||||
|
account->muc_service = strdup(g_muc_service->str);
|
||||||
|
g_string_free(g_muc_service, TRUE);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
} else {
|
||||||
|
account->muc_service = strdup(muc_service);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL);
|
||||||
|
if (muc_nick == NULL) {
|
||||||
|
Jid *jidp = jid_create(account->jid);
|
||||||
|
account->muc_nick = strdup(jidp->localpart);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
} else {
|
||||||
|
account->muc_nick = strdup(muc_nick);
|
||||||
|
}
|
||||||
|
|
||||||
// get room history
|
// get room history
|
||||||
account->room_history = NULL;
|
account->room_history = NULL;
|
||||||
gsize history_size = 0;
|
gsize history_size = 0;
|
||||||
@ -250,6 +292,8 @@ accounts_free_account(ProfAccount *account)
|
|||||||
free(account->server);
|
free(account->server);
|
||||||
free(account->last_presence);
|
free(account->last_presence);
|
||||||
free(account->login_presence);
|
free(account->login_presence);
|
||||||
|
free(account->muc_service);
|
||||||
|
free(account->muc_nick);
|
||||||
free(account);
|
free(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,6 +388,17 @@ accounts_set_jid(const char * const account_name, const char * const value)
|
|||||||
if (jid->resourcepart != NULL) {
|
if (jid->resourcepart != NULL) {
|
||||||
g_key_file_set_string(accounts, account_name, "resource", jid->resourcepart);
|
g_key_file_set_string(accounts, account_name, "resource", jid->resourcepart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GString *muc_service = g_string_new("conference.");
|
||||||
|
g_string_append(muc_service, jid->domainpart);
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.service", muc_service->str);
|
||||||
|
g_string_free(muc_service, TRUE);
|
||||||
|
if (jid->localpart == NULL) {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", jid->domainpart);
|
||||||
|
} else {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", jid->localpart);
|
||||||
|
}
|
||||||
|
|
||||||
_save_accounts();
|
_save_accounts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,6 +422,24 @@ accounts_set_resource(const char * const account_name, const char * const value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
accounts_set_muc_service(const char * const account_name, const char * const value)
|
||||||
|
{
|
||||||
|
if (accounts_account_exists(account_name)) {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.service", value);
|
||||||
|
_save_accounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
accounts_set_muc_nick(const char * const account_name, const char * const value)
|
||||||
|
{
|
||||||
|
if (accounts_account_exists(account_name)) {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", value);
|
||||||
|
_save_accounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
accounts_set_priority_online(const char * const account_name, const gint value)
|
accounts_set_priority_online(const char * const account_name, const gint value)
|
||||||
{
|
{
|
||||||
@ -558,6 +631,27 @@ _fix_legacy_accounts(const char * const account_name)
|
|||||||
_save_accounts();
|
_save_accounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// acounts with no muc service or nick
|
||||||
|
if (!g_key_file_has_key(accounts, account_name, "muc.service", NULL)) {
|
||||||
|
gchar *account_jid = g_key_file_get_string(accounts, account_name, "jid", NULL);
|
||||||
|
Jid *jidp = jid_create(account_jid);
|
||||||
|
GString *muc_service = g_string_new("conference.");
|
||||||
|
g_string_append(muc_service, jidp->domainpart);
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.service", muc_service->str);
|
||||||
|
g_string_free(muc_service, TRUE);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
if (!g_key_file_has_key(accounts, account_name, "muc.nick", NULL)) {
|
||||||
|
gchar *account_jid = g_key_file_get_string(accounts, account_name, "jid", NULL);
|
||||||
|
Jid *jidp = jid_create(account_jid);
|
||||||
|
if (jidp->localpart == NULL) {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->domainpart);
|
||||||
|
} else {
|
||||||
|
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->localpart);
|
||||||
|
}
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ typedef struct prof_account_t {
|
|||||||
gint priority_away;
|
gint priority_away;
|
||||||
gint priority_xa;
|
gint priority_xa;
|
||||||
gint priority_dnd;
|
gint priority_dnd;
|
||||||
|
gchar *muc_service;
|
||||||
|
gchar *muc_nick;
|
||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
GSList *room_history;
|
GSList *room_history;
|
||||||
} ProfAccount;
|
} ProfAccount;
|
||||||
@ -60,6 +62,8 @@ gboolean accounts_account_exists(const char * const account_name);
|
|||||||
void accounts_set_jid(const char * const account_name, const char * const value);
|
void accounts_set_jid(const char * const account_name, const char * const value);
|
||||||
void accounts_set_server(const char * const account_name, const char * const value);
|
void accounts_set_server(const char * const account_name, const char * const value);
|
||||||
void accounts_set_resource(const char * const account_name, const char * const value);
|
void accounts_set_resource(const char * const account_name, const char * const value);
|
||||||
|
void accounts_set_muc_service(const char * const account_name, const char * const value);
|
||||||
|
void accounts_set_muc_nick(const char * const account_name, const char * const value);
|
||||||
void accounts_set_last_presence(const char * const account_name, const char * const value);
|
void accounts_set_last_presence(const char * const account_name, const char * const value);
|
||||||
void accounts_set_login_presence(const char * const account_name, const char * const value);
|
void accounts_set_login_presence(const char * const account_name, const char * const value);
|
||||||
resource_presence_t accounts_get_login_presence(const char * const account_name);
|
resource_presence_t accounts_get_login_presence(const char * const account_name);
|
||||||
|
@ -789,6 +789,12 @@ cons_show_account(ProfAccount *account)
|
|||||||
if (account->server != NULL) {
|
if (account->server != NULL) {
|
||||||
cons_show ("server : %s", account->server);
|
cons_show ("server : %s", account->server);
|
||||||
}
|
}
|
||||||
|
if (account->muc_service != NULL) {
|
||||||
|
cons_show ("muc service : %s", account->muc_service);
|
||||||
|
}
|
||||||
|
if (account->muc_nick != NULL) {
|
||||||
|
cons_show ("muc nick : %s", account->muc_nick);
|
||||||
|
}
|
||||||
if (account->last_presence != NULL) {
|
if (account->last_presence != NULL) {
|
||||||
cons_show ("Last presence : %s", account->last_presence);
|
cons_show ("Last presence : %s", account->last_presence);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user