#include "silc-queries.h"
#include "silc-nicklist.h"
+EXPANDO_FUNC old_expando_usermode,
+ old_expando_cumode,
+ old_expando_cumode_space;
+
/* User mode in active server */
static char *expando_usermode(SERVER_REC *server, void *item, int *free_ret)
{
SILC_SERVER_REC *s = SILC_SERVER(server);
+ static char modes[128], stat[128];
+ bool se;
+
+ if (!s) {
+ if (old_expando_usermode)
+ return old_expando_usermode(server, item, free_ret);
+ else
+ return "";
+ }
- if (!s)
- return "";
-
- return (s->umode & SILC_UMODE_SERVER_OPERATOR) ? "Server Operator" :
- (s->umode & SILC_UMODE_ROUTER_OPERATOR) ? "Router Operator" : "";
+ memset(modes, 0, sizeof(modes));
+ memset(stat, 0, sizeof(stat));
+
+ if (s->umode & SILC_UMODE_GONE)
+ strcat(stat, "g");
+ if (s->umode & SILC_UMODE_INDISPOSED)
+ strcat(stat, "i");
+ if (s->umode & SILC_UMODE_BUSY)
+ strcat(stat, "b");
+ if (s->umode & SILC_UMODE_PAGE)
+ strcat(stat, "p");
+ if (s->umode & SILC_UMODE_HYPER)
+ strcat(stat, "h");
+ if (s->umode & SILC_UMODE_ROBOT)
+ strcat(stat, "t");
+ if (s->umode & SILC_UMODE_ANONYMOUS)
+ strcat(stat, "?");
+ if (s->umode & SILC_UMODE_BLOCK_PRIVMSG)
+ strcat(stat, "P");
+ if (s->umode & SILC_UMODE_REJECT_WATCHING)
+ strcat(stat, "w");
+ if (s->umode & SILC_UMODE_BLOCK_INVITE)
+ strcat(stat, "I");
+
+ se = strlen(stat) > 0;
+ snprintf(modes, sizeof(modes) - 1, "%s%s%s%s",
+ ((s->umode & SILC_UMODE_SERVER_OPERATOR) ? "Server Operator" :
+ (s->umode & SILC_UMODE_ROUTER_OPERATOR) ? "Router Operator" : ""),
+ se ? "[" : "", se ? stat : "", se ? "]" : "");
+
+ return modes;
}
/* Expands to your usermode on channel */
static char *expando_cumode(SERVER_REC *server, void *item, int *free_ret)
{
+ SILC_SERVER_REC *s = SILC_SERVER(server);
+
+ if (!s) {
+ if (old_expando_cumode)
+ return old_expando_cumode(server, item, free_ret);
+ else
+ return "";
+ }
+
if (IS_SILC_CHANNEL(item) && CHANNEL(item)->ownnick) {
SILC_NICK_REC *nick = (SILC_NICK_REC *)CHANNEL(item)->ownnick;
return (nick->op && nick->founder) ? "*@" :
static char *expando_cumode_space(SERVER_REC *server, void *item,
int *free_ret)
{
+ SILC_SERVER_REC *s = SILC_SERVER(server);
char *ret;
- if (!IS_SILC_SERVER(server))
- return "";
+ if (!s) {
+ if (old_expando_cumode_space)
+ return old_expando_cumode_space(server, item, free_ret);
+ else
+ return "";
+ }
ret = expando_cumode(server, item, free_ret);
return *ret == '\0' ? " " : ret;
}
+static char *expando_silc_version(SERVER_REC *server, void *item,
+ int *free_ret)
+{
+ return VERSION;
+}
+
void silc_expandos_init(void)
{
+ old_expando_usermode = expando_find_long("usermode");
+ old_expando_cumode = expando_find_long("cumode");
+ old_expando_cumode_space = expando_find_long("cumode_space");
expando_create("usermode", expando_usermode,
"window changed", EXPANDO_ARG_NONE,
"window server changed", EXPANDO_ARG_WINDOW,
"window changed", EXPANDO_ARG_NONE,
"window item changed", EXPANDO_ARG_WINDOW,
"nick mode changed", EXPANDO_ARG_WINDOW_ITEM, NULL);
+ expando_create("j", expando_silc_version, NULL);
}
void silc_expandos_deinit(void)
{
+ expando_destroy("j", expando_silc_version);
expando_destroy("usermode", expando_usermode);
expando_destroy("cumode", expando_cumode);
expando_destroy("cumode_space", expando_cumode_space);
+ if (old_expando_usermode)
+ expando_create("usermode", old_expando_usermode, NULL);
+ if (old_expando_cumode)
+ expando_create("cumode", old_expando_cumode, NULL);
+ if (old_expando_cumode_space)
+ expando_create("cumode_space", old_expando_cumode_space, NULL);
}