aboutsummaryrefslogtreecommitdiffstats
path: root/root_commands.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2016-11-21 03:40:54 -0300
committerdequis <dx@dxzone.com.ar>2016-11-21 03:58:47 -0300
commit5a8afc3f24a5308799d3960cab5726228345022d (patch)
treedc4569f0190238e20b3ae2c7ddb7feb2db27380d /root_commands.c
parent11d4123fe9a4d88d475bee6c623fb80af8fdbb0b (diff)
Manual merge with wilmer's approach to handling missing protocols
Turns out he already implemented pretty much the same thing in the parson branch... last year. The differences between the two approaches are subtle (there aren't too many ways to do this, some lines are the exact same thing) but I decided I like his version better, so this mostly reverts a handful of my changes while keeping others. The main advantage of his approach is that no fake protocols are registered, no actual prpl functions are called, and the missing prpl is a singleton constant. New things compared to the implementation in the other branch: - The explain_unknown_protocol() function. - Fixed named chatrooms throwing a warning and losing the "account" setting when saving. See changes in irc_im.c - Fixed the "server" setting dropping when saving. See account.c Differences with my previous implementation: - Accounts with missing protocols don't autoconnect - 'account list' marks them as "(missing!)"
Diffstat (limited to 'root_commands.c')
-rw-r--r--root_commands.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/root_commands.c b/root_commands.c
index 1bbd1722..e0c0b7f8 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -497,7 +497,7 @@ static void cmd_account(irc_t *irc, char **cmd)
}
for (a = irc->b->accounts; a; a = a->next) {
- char *con;
+ char *con = NULL, *protocol = NULL;
if (a->ic && (a->ic->flags & OPT_LOGGED_IN)) {
con = " (connected)";
@@ -509,7 +509,14 @@ static void cmd_account(irc_t *irc, char **cmd)
con = "";
}
- irc_rootmsg(irc, "%2d (%s): %s, %s%s", i, a->tag, a->prpl->name, a->user, con);
+ if (a->prpl == &protocol_missing) {
+ protocol = g_strdup_printf("%s (missing!)", set_getstr(&a->set, "_protocol_name"));
+ } else {
+ protocol = g_strdup(a->prpl->name);
+ }
+
+ irc_rootmsg(irc, "%2d (%s): %s, %s%s", i, a->tag, protocol, a->user, con);
+ g_free(protocol);
i++;
}
@@ -523,7 +530,7 @@ static void cmd_account(irc_t *irc, char **cmd)
irc_rootmsg(irc, "Trying to get all accounts connected...");
for (a = irc->b->accounts; a; a = a->next) {
- if (!a->ic && a->auto_connect) {
+ if (!a->ic && a->auto_connect && a->prpl != &protocol_missing) {
if (strcmp(a->pass, PASSWORD_PENDING) == 0) {
irc_rootmsg(irc, "Enter password for account %s "
"first (use /OPER)", a->tag);
@@ -583,6 +590,12 @@ static void cmd_account(irc_t *irc, char **cmd)
} else if (strcmp(a->pass, PASSWORD_PENDING) == 0) {
irc_rootmsg(irc, "Enter password for account %s "
"first (use /OPER)", a->tag);
+ } else if (a->prpl == &protocol_missing) {
+ char *proto = set_getstr(&a->set, "_protocol_name");
+ char *msg = explain_unknown_protocol(proto);
+ irc_rootmsg(irc, "Unknown protocol `%s'", proto);
+ irc_rootmsg(irc, msg);
+ g_free(msg);
} else {
account_on(irc->b, a);
}