mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added /account list command, and added jid property to accounts
This commit is contained in:
parent
0bba09fd04
commit
324a85a2a5
@ -84,14 +84,28 @@ accounts_reset_login_search(void)
|
|||||||
void
|
void
|
||||||
accounts_add_login(const char *jid, const char *altdomain)
|
accounts_add_login(const char *jid, const char *altdomain)
|
||||||
{
|
{
|
||||||
|
// doesn't yet exist
|
||||||
if (!g_key_file_has_group(accounts, jid)) {
|
if (!g_key_file_has_group(accounts, jid)) {
|
||||||
g_key_file_set_boolean(accounts, jid, "enabled", TRUE);
|
g_key_file_set_boolean(accounts, jid, "enabled", TRUE);
|
||||||
|
g_key_file_set_string(accounts, jid, "jid", jid);
|
||||||
if (altdomain != NULL) {
|
if (altdomain != NULL) {
|
||||||
g_key_file_set_string(accounts, jid, "server", altdomain);
|
g_key_file_set_string(accounts, jid, "server", altdomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
_save_accounts();
|
_save_accounts();
|
||||||
|
|
||||||
|
// already exists, update old style accounts
|
||||||
|
} else {
|
||||||
|
g_key_file_set_string(accounts, jid, "jid", jid);
|
||||||
|
_save_accounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar**
|
||||||
|
accounts_get_list(void)
|
||||||
|
{
|
||||||
|
return g_key_file_get_groups(accounts, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -29,5 +29,6 @@ void accounts_close(void);
|
|||||||
char * accounts_find_login(char *prefix);
|
char * accounts_find_login(char *prefix);
|
||||||
void accounts_reset_login_search(void);
|
void accounts_reset_login_search(void);
|
||||||
void accounts_add_login(const char *jid, const char *altdomain);
|
void accounts_add_login(const char *jid, const char *altdomain);
|
||||||
|
gchar** accounts_get_list(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,6 +93,7 @@ static gboolean _cmd_about(gchar **args, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_prefs(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_prefs(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_who(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_who(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_connect(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_connect(gchar **args, struct cmd_help_t help);
|
||||||
|
static gboolean _cmd_account(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_disconnect(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_disconnect(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_sub(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_sub(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_msg(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_msg(gchar **args, struct cmd_help_t help);
|
||||||
@ -175,6 +176,30 @@ static struct cmd_t main_commands[] =
|
|||||||
"Disconnect from the current session session.",
|
"Disconnect from the current session session.",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/account",
|
||||||
|
_cmd_account, parse_args, 1, 4,
|
||||||
|
{ "/account command [account] [property] [value]", "Manage accounts.",
|
||||||
|
{ "/account command [account] [property] [value]",
|
||||||
|
"---------------------------------------------",
|
||||||
|
"Commands for creating and managing accounts.",
|
||||||
|
"list : List all accounts.",
|
||||||
|
"show account : Show information about an account.",
|
||||||
|
"enable account : Enable the account, so it is used for autocomplete.",
|
||||||
|
"disable account : Disable the account.",
|
||||||
|
"new account : Create a new account.",
|
||||||
|
"set account property value : Set 'property' of 'account' to 'value'.",
|
||||||
|
"",
|
||||||
|
"The 'property' may be one of.",
|
||||||
|
"jid : The Jabber ID of the account, the account name will be used if this property is not set.",
|
||||||
|
"server : The chat service server, if different to the domain part of the JID.",
|
||||||
|
"",
|
||||||
|
"Example : /account new work",
|
||||||
|
" : /account set work jid myuser@mycompany.com",
|
||||||
|
" : /account set work server talk.google.com",
|
||||||
|
"",
|
||||||
|
"To log in to this account: '/connect work'",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
{ "/prefs",
|
{ "/prefs",
|
||||||
_cmd_prefs, parse_args, 0, 1,
|
_cmd_prefs, parse_args, 0, 1,
|
||||||
{ "/prefs [area]", "Show configuration.",
|
{ "/prefs [area]", "Show configuration.",
|
||||||
@ -911,6 +936,30 @@ _cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_account(gchar **args, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
char *command = args[0];
|
||||||
|
|
||||||
|
if (strcmp(command, "list") == 0) {
|
||||||
|
gchar **accounts = accounts_get_list();
|
||||||
|
int size = g_strv_length(accounts);
|
||||||
|
|
||||||
|
if (size > 0) {
|
||||||
|
cons_show("Accounts:");
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
cons_show(accounts[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cons_show("No accounts created yet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cons_show("");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_sub(gchar **args, struct cmd_help_t help)
|
_cmd_sub(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user