Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "core.h"
#include "module.h"
#include "modules.h"
#include "signals.h"
int signal_args[MAX_EXPANDO_SIGNALS];
} EXPANDO_REC;
+const char *current_expando = NULL;
+
static int timer_tag;
static EXPANDO_REC *char_expandos[255];
static GHashTable *expandos;
-static time_t client_start_time;
static char *last_sent_msg, *last_sent_msg_body;
static char *last_privmsg_from, *last_public_from;
static char *sysname, *sysrelease, *sysarch;
/* Destroy expando */
void expando_destroy(const char *key, EXPANDO_FUNC func)
{
- gpointer origkey;
+ gpointer origkey, value;
EXPANDO_REC *rec;
g_return_if_fail(key != NULL || *key == '\0');
char_expandos[(int) (unsigned char) *key] = NULL;
g_free(rec);
}
- } else if (g_hash_table_lookup_extended(expandos, key, &origkey,
- (gpointer *) &rec)) {
+ } else if (g_hash_table_lookup_extended(expandos, key,
+ &origkey, &value)) {
+ rec = value;
if (rec->func == func) {
g_hash_table_remove(expandos, key);
g_free(origkey);
func = arg < funccount ? funcs[arg] : NULL;
if (func == NULL) func = funcs[EXPANDO_ARG_NONE];
- signal_add_to_id(MODULE_NAME, 1, rec->signal_ids[n], func);
+ signal_add_full_id(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT,
+ rec->signal_ids[n], func, NULL);
}
}
func = arg < funccount ? funcs[arg] : NULL;
if (func == NULL) func = funcs[EXPANDO_ARG_NONE];
- signal_remove_id(rec->signal_ids[n], func);
+ signal_remove_id(rec->signal_ids[n], func, NULL);
}
}
return rec == NULL ? NULL : rec->func;
}
+static gboolean free_expando(gpointer key, gpointer value, gpointer user_data)
+{
+ g_free(key);
+ g_free(value);
+ return TRUE;
+}
+
/* last person who sent you a MSG */
static char *expando_lastmsg(SERVER_REC *server, void *item, int *free_ret)
{
return (char *) settings_get_str("cmdchars");
}
+/* first CMDCHAR */
+static char *expando_cmdchar(SERVER_REC *server, void *item, int *free_ret)
+{
+ char str[2] = { 0, 0 };
+
+ str[0] = *settings_get_str("cmdchars");
+
+ *free_ret = TRUE;
+ return g_strdup(str);
+}
+
/* modes of current channel, if any */
static char *expando_chanmode(SERVER_REC *server, void *item, int *free_ret)
-{
- return !IS_CHANNEL(item) ? NULL : CHANNEL(item)->mode;
+{
+ char *cmode;
+
+ *free_ret = FALSE;
+
+ if (!IS_CHANNEL(item))
+ return NULL;
+
+ if (!settings_get_bool("chanmode_expando_strip"))
+ return CHANNEL(item)->mode;
+
+ *free_ret = TRUE;
+ cmode = g_strdup(CHANNEL(item)->mode);
+ if (strchr(cmode, ' ') != NULL)
+ *(strchr(cmode, ' ')) = 0;
+
+ return cmode;
}
/* current nickname */
/* target of current input (channel or QUERY nickname) */
static char *expando_target(SERVER_REC *server, void *item, int *free_ret)
{
- return item == NULL ? "" : ((WI_ITEM_REC *) item)->name;
+ return item == NULL ? "" :
+ (char *) window_item_get_target((WI_ITEM_REC *) item);
}
/* client release date (in YYYYMMDD format) */
return server == NULL ? "" : server->connrec->chatnet;
}
+/* visible_name of current window item */
+static char *expando_itemname(SERVER_REC *server, void *item, int *free_ret)
+{
+ return item == NULL ? "" : ((WI_ITEM_REC *) item)->visible_name;
+}
+
static void sig_message_public(SERVER_REC *server, const char *msg,
const char *nick, const char *address,
const char *target)
struct utsname un;
#endif
settings_add_str("misc", "STATUS_OPER", "*");
- settings_add_str("misc", "timestamp_format", "%H:%M");
+ settings_add_str("lookandfeel", "timestamp_format", "%H:%M");
+ settings_add_bool("lookandfeel", "chanmode_expando_strip", FALSE);
- client_start_time = time(NULL);
last_sent_msg = NULL; last_sent_msg_body = NULL;
last_privmsg_from = NULL; last_public_from = NULL;
last_timestamp = 0;
"", EXPANDO_NEVER, NULL);
expando_create("K", expando_cmdchars,
"setup changed", EXPANDO_ARG_NONE, NULL);
+ expando_create("k", expando_cmdchar,
+ "setup changed", EXPANDO_ARG_NONE, NULL);
expando_create("M", expando_chanmode,
"window changed", EXPANDO_ARG_NONE,
"window item changed", EXPANDO_ARG_WINDOW,
"channel mode changed", EXPANDO_ARG_WINDOW_ITEM, NULL);
expando_create("N", expando_nick,
"window changed", EXPANDO_ARG_NONE,
+ "window connect changed", EXPANDO_ARG_WINDOW,
"window server changed", EXPANDO_ARG_WINDOW,
"server nick changed", EXPANDO_ARG_SERVER, NULL);
expando_create("O", expando_statusoper,
expando_create("W", expando_workdir, NULL);
expando_create("Y", expando_realname,
"window changed", EXPANDO_ARG_NONE,
+ "window connect changed", EXPANDO_ARG_WINDOW,
"window server changed", EXPANDO_ARG_WINDOW, NULL);
expando_create("Z", expando_time,
"time changed", EXPANDO_ARG_NONE, NULL);
"query address changed", EXPANDO_ARG_WINDOW_ITEM, NULL);
expando_create("tag", expando_servertag,
"window changed", EXPANDO_ARG_NONE,
+ "window connect changed", EXPANDO_ARG_WINDOW,
"window server changed", EXPANDO_ARG_WINDOW, NULL);
expando_create("chatnet", expando_chatnet,
"window changed", EXPANDO_ARG_NONE,
+ "window connect changed", EXPANDO_ARG_WINDOW,
"window server changed", EXPANDO_ARG_WINDOW, NULL);
+ expando_create("itemname", expando_itemname,
+ "window changed", EXPANDO_ARG_NONE,
+ "window item changed", EXPANDO_ARG_WINDOW,
+ "window item name changed", EXPANDO_ARG_WINDOW_ITEM,
+ NULL);
read_settings();
for (n = 0; n < sizeof(char_expandos)/sizeof(char_expandos[0]); n++)
g_free_not_null(char_expandos[n]);
- expando_destroy("sysname", expando_sysname);
- expando_destroy("sysrelease", expando_sysrelease);
- expando_destroy("sysarch", expando_sysarch);
- expando_destroy("topic", expando_topic);
- expando_destroy("tag", expando_servertag);
- expando_destroy("chatnet", expando_chatnet);
-
+ g_hash_table_foreach_remove(expandos, free_expando, NULL);
g_hash_table_destroy(expandos);
g_free_not_null(last_sent_msg); g_free_not_null(last_sent_msg_body);