# HG changeset patch # User Myhailo Danylenko # Date 1270668463 -10800 # Node ID f4c15ad3cf93967686cf2d9040ce266e5b8d98a9 # Parent 9f7256ede8fc3882916e917d807661eb4c858008 Use new commands interface * Use id to delete commands * Add commands to safe list diff -r 9f7256ede8fc -r f4c15ad3cf93 config.h.in --- a/config.h.in Sun Apr 04 16:48:22 2010 +0300 +++ b/config.h.in Wed Apr 07 22:27:43 2010 +0300 @@ -2,6 +2,15 @@ #ifndef LOCAL_CONFIG_H #define LOCAL_CONFIG_H +#include + +#if MCABBER_BRANCH_EXPERIMENTAL && MCABBER_API_VERSION >= 23 +# define HAVE_CMD_ID +# if MCABBER_API_VERSION >= 24 +# define HAVE_CMD_SAFE +# endif +#endif + #define PROJECT_VERSION ( "${PROJECT_VERSION}" ) #endif diff -r 9f7256ede8fc -r f4c15ad3cf93 yaubil.c --- a/yaubil.c Sun Apr 04 16:48:22 2010 +0300 +++ b/yaubil.c Wed Apr 07 22:27:43 2010 +0300 @@ -38,7 +38,13 @@ static module_info_t info_yaubil_experimental = { .branch = "experimental", - .api = 15, +#ifndef HAVE_CMD_ID + .api = 20, +#elif defined HAVE_CMD_SAFE + .api = 24, +#else + .api = 23, +#endif .version = PROJECT_VERSION, .description = DESCRIPTION, .requires = NULL, @@ -58,6 +64,23 @@ .next = &info_yaubil_experimental, }; +#ifdef HAVE_CMD_ID +static gpointer yaubil_multi_cmid = NULL; +static gpointer yaubil_if_cmid = NULL; +static gpointer yaubil_then_cmid = NULL; +static gpointer yaubil_else_cmid = NULL; +static gpointer yaubil_eval_cmid = NULL; +static gpointer yaubil_let_cmid = NULL; +#ifdef HAVE_CMD_SAFE +static gboolean yaubil_multi_set_safe = FALSE; +static gboolean yaubil_if_set_safe = FALSE; +static gboolean yaubil_then_set_safe = FALSE; +static gboolean yaubil_else_set_safe = FALSE; +static gboolean yaubil_eval_set_safe = FALSE; +static gboolean yaubil_let_set_safe = FALSE; +#endif +#endif + static gboolean ifresult = TRUE; #define MSGPREFIX "yaubil: " @@ -921,22 +944,68 @@ static void yaubil_init (void) { +#ifndef HAVE_CMD_ID cmd_add ("multi", "", COMPL_CMD, COMPL_CMD, do_multi, NULL); cmd_add ("if", "", 0, 0, do_if, NULL); cmd_add ("then", "", COMPL_CMD, COMPL_CMD, do_then, NULL); cmd_add ("else", "", COMPL_CMD, COMPL_CMD, do_else, NULL); cmd_add ("eval", "", 0, 0, do_eval, NULL); cmd_add ("let", "", 0, 0, do_let, NULL); +#else + yaubil_multi_cmid = cmd_add ("multi", "", COMPL_CMD, COMPL_CMD, do_multi, NULL); + yaubil_if_cmid = cmd_add ("if", "", 0, 0, do_if, NULL); + yaubil_then_cmid = cmd_add ("then", "", COMPL_CMD, COMPL_CMD, do_then, NULL); + yaubil_else_cmid = cmd_add ("else", "", COMPL_CMD, COMPL_CMD, do_else, NULL); + yaubil_eval_cmid = cmd_add ("eval", "", 0, 0, do_eval, NULL); + yaubil_let_cmid = cmd_add ("let", "", 0, 0, do_let, NULL); +#ifdef HAVE_CMD_SAFE + yaubil_multi_set_safe = cmd_set_safe ("multi", TRUE); + yaubil_if_set_safe = cmd_set_safe ("if", TRUE); + yaubil_then_set_safe = cmd_set_safe ("then", TRUE); + yaubil_else_set_safe = cmd_set_safe ("else", TRUE); + yaubil_eval_set_safe = cmd_set_safe ("eval", TRUE); + yaubil_let_set_safe = cmd_set_safe ("let", TRUE); +#endif +#endif } static void yaubil_uninit (void) { +#ifndef HAVE_CMD_ID cmd_del ("multi"); cmd_del ("if"); cmd_del ("then"); cmd_del ("else"); cmd_del ("eval"); cmd_del ("let"); +#else + if (yaubil_multi_cmid) + cmd_del (yaubil_multi_cmid); + if (yaubil_if_cmid) + cmd_del (yaubil_if_cmid); + if (yaubil_then_cmid) + cmd_del (yaubil_then_cmid); + if (yaubil_else_cmid) + cmd_del (yaubil_else_cmid); + if (yaubil_eval_cmid) + cmd_del (yaubil_eval_cmid); + if (yaubil_let_cmid) + cmd_del (yaubil_let_cmid); +#ifdef HAVE_CMD_SAFE + if (yaubil_multi_set_safe) + cmd_set_safe ("multi", FALSE); + if (yaubil_if_set_safe) + cmd_set_safe ("if", FALSE); + if (yaubil_then_set_safe) + cmd_set_safe ("then", FALSE); + if (yaubil_else_set_safe) + cmd_set_safe ("else", FALSE); + if (yaubil_eval_set_safe) + cmd_set_safe ("eval", FALSE); + if (yaubil_let_set_safe) + cmd_set_safe ("let", FALSE); +#endif +#endif } /* The End */