void timer_test(void) { prof_cons_show("c-test: timer fired."); char *recipient = prof_get_current_recipient(); if (recipient != NULL) { char *start = " current recipient = "; char buf[strlen(start) + strlen(recipient) + 1]; sprintf(buf, "%s%s", start, recipient); prof_cons_show(buf); } prof_cons_alert(); }
void cmd_c(char **args) { if (args[0] != NULL) { char *start = "c-test: /c command called, arg = "; char buf[strlen(start) + strlen(args[0]) + 1]; sprintf(buf, "%s%s", start, args[0]); prof_cons_show(buf); } else { prof_cons_show("c-test: /c command called with no arg"); } prof_cons_alert(); prof_notify("c-test: notify", 2000, "Plugins"); prof_send_line("/about"); prof_cons_show("c-test: sent \"/about\" command"); }
void prof_on_connect(const char * const account_name, const char * const fulljid) { char *start = "c-test: on_connect, "; char buf[strlen(start) + strlen(account_name) + 2 + strlen(fulljid) + 1]; sprintf(buf, "%s%s, %s", start, account_name, fulljid); prof_cons_show(buf); }
void prof_on_start(void) { prof_cons_show("c-test: on_start"); prof_log_debug("c-test: logged debug"); prof_log_info("c-test: logged info"); prof_log_warning("c-test: logged warning"); prof_log_error("c-test: logged error"); }
char * prof_on_room_message_send(const char * const room, const char *message) { char *start = "c-test: on_room_message_send, "; char buf[strlen(start) + strlen(room) + 2 + strlen(message) + 1]; sprintf(buf, "%s%s, %s", start, room, message); prof_cons_show(buf); prof_cons_alert(); char *result = malloc(strlen(message) + 4); sprintf(result, "%s%s", message, "[C]"); return result; }
char * prof_on_message_received(const char * const jid, const char *message) { char *start = "c-test: on_message_received, "; char buf[strlen(start) + strlen(jid) + 2 + strlen(message) + 1]; sprintf(buf, "%s%s, %s", start, jid, message); prof_cons_show(buf); prof_cons_alert(); char *result = malloc(strlen(message) + 4); sprintf(result, "%s%s", message, "[C]"); return result; }
void prof_init(const char * const version, const char * const status) { char *start = "c-test: init. "; char buf[strlen(start) + strlen(version) + 2 + strlen(status) + 1]; sprintf(buf, "%s%s, %s", start, version, status); prof_cons_show(buf); prof_register_command("/c", 0, 1, "/c", "c test", "c test", cmd_c); prof_register_command("/reverse", 0, 1, "/reverse", "Reverse input string", "Reverse input string", cmd_reverse); char *arg_ac[] = { "one", "two", "three", NULL }; prof_register_ac("/ccomplete", arg_ac); char *arg_one_ac[] = { "james", "bob", "jenny", "steven", NULL }; prof_register_ac("/ccomplete one", arg_one_ac); prof_register_command("/ccomplete", 0, 2, "/ccomplete", "C completion", "C completion", cmd_reverse); prof_register_timed(timer_test, 10); }
void cmd_ctest(char **args) { if (strcmp(args[0], "consalert") == 0) { create_win(); prof_win_focus(plugin_win); prof_cons_alert(); prof_win_show(plugin_win, "called -> prof_cons_alert"); } else if (strcmp(args[0], "consshow") == 0) { if (args[1]) { create_win(); prof_win_focus(plugin_win); prof_cons_show(args[1]); char *str = "called -> prof_cons_show: "; char buf[strlen(str) + strlen(args[1])]; sprintf(buf, "%s%s", str, args[1]); prof_win_show(plugin_win, buf); } else { prof_cons_bad_cmd_usage("/c-test"); } } else if (strcmp(args[0], "consshow_t") == 0) { if (args[1] == NULL || args[2] == NULL || args[3] == NULL || args[4] == NULL) { prof_cons_bad_cmd_usage("/c-test"); } else { char *group = strcmp(args[1], "none") == 0 ? NULL : args[1]; char *key = strcmp(args[2], "none") == 0 ? NULL : args[2]; char *def = strcmp(args[3], "none") == 0 ? NULL : args[3]; char *message = args[4]; create_win(); prof_win_focus(plugin_win); prof_cons_show_themed(group, key, def, message); char *str = "called -> prof_cons_show_themed: "; char buf[strlen(str) + strlen(args[1]) + 2 + strlen(args[2]) + 2 + strlen(args[3]) + 2 + strlen(args[4])]; sprintf(buf, "%s%s, %s, %s, %s", str, args[1], args[2], args[3], args[4]); prof_win_show(plugin_win, buf); } } else if (strcmp(args[0], "constest") == 0) { int res = prof_current_win_is_console(); create_win(); prof_win_focus(plugin_win); if (res) { prof_win_show(plugin_win, "called -> prof_current_win_is_console: true"); } else { prof_win_show(plugin_win, "called -> prof_current_win_is_console: false"); } } else if (strcmp(args[0], "winshow") == 0) { if (args[1]) { create_win(); prof_win_focus(plugin_win); prof_win_show(plugin_win, args[1]); char *str = "called -> prof_win_show: "; char buf[strlen(str) + strlen(args[1])]; sprintf(buf, "%s%s", str, args[1]); prof_win_show(plugin_win, buf); } else { prof_cons_bad_cmd_usage("/c-test"); } } else if (strcmp(args[0], "winshow_t") == 0) { if (args[1] == NULL || args[2] == NULL || args[3] == NULL || args[4] == NULL) { prof_cons_bad_cmd_usage("/c-test"); } else { char *group = strcmp(args[1], "none") == 0 ? NULL : args[1]; char *key = strcmp(args[2], "none") == 0 ? NULL : args[2]; char *def = strcmp(args[3], "none") == 0 ? NULL : args[3]; char *message = args[4]; create_win(); prof_win_focus(plugin_win); prof_win_show_themed(plugin_win, group, key, def, message); char *str = "called -> prof_win_show_themed: "; char buf[strlen(str) + strlen(args[1]) + 2 + strlen(args[2]) + 2 + strlen(args[3]) + 2 + strlen(args[4])]; sprintf(buf, "%s%s, %s, %s, %s", str, args[1], args[2], args[3], args[4]); prof_win_show(plugin_win, buf); } } else if (strcmp(args[0], "sendline") == 0) { if (args[1]) { create_win(); prof_win_focus(plugin_win); prof_send_line(args[1]); char *str = "called -> prof_send_line: "; char buf[strlen(str) + strlen(args[1])]; sprintf(buf, "%s%s", str, args[1]); prof_win_show(plugin_win, buf); } else { prof_cons_bad_cmd_usage("/c-test"); } } else if (strcmp(args[0], "notify") == 0) { if (args[1]) { create_win(); prof_win_focus(plugin_win); prof_notify(args[1], 5000, "c-test plugin"); char *str = "called -> prof_notify: "; char buf[strlen(str) + strlen(args[1])]; sprintf(buf, "%s%s", str, args[1]); prof_win_show(plugin_win, buf); } else { prof_cons_bad_cmd_usage("/c-test"); } } else if (strcmp(args[0], "get") == 0) { if (!args[1]) { prof_cons_bad_cmd_usage("/c-test"); } else if (strcmp(args[1], "recipient") == 0) { create_win(); char *recipient = prof_get_current_recipient(); if (recipient) { prof_win_focus(plugin_win); char *str = "called -> prof_get_current_recipient: "; char buf[strlen(str) + strlen(recipient)]; sprintf(buf, "%s%s", str, recipient); prof_win_show(plugin_win, buf); } else { prof_win_focus(plugin_win); prof_win_show(plugin_win, "called -> prof_get_current_recipient: <none>"); } } else if (strcmp(args[1], "room") == 0) { create_win(); char *room = prof_get_current_muc(); if (room) { prof_win_focus(plugin_win); char *str = "called -> prof_get_current_muc: "; char buf[strlen(str) + strlen(room)]; sprintf(buf, "%s%s", str, room); prof_win_show(plugin_win, buf); } else { prof_win_focus(plugin_win); prof_win_show(plugin_win, "called -> prof_get_current_muc: <none>"); } } else { prof_cons_bad_cmd_usage("/c-test"); } } else if (strcmp(args[0], "log") == 0) { if (!args[1]) { prof_cons_bad_cmd_usage("/c-test"); } else if (strcmp(args[1], "debug") == 0) { if (!args[2]) { prof_cons_bad_cmd_usage("/c-test"); } else { create_win(); prof_win_focus(plugin_win); prof_log_debug(args[2]); char *str = "called -> prof_log_debug: "; char buf[strlen(str) + strlen(args[2])]; sprintf(buf, "%s%s", str, args[2]); prof_win_show(plugin_win, buf); } } else if (strcmp(args[1], "info") == 0) { if (!args[2]) { prof_cons_bad_cmd_usage("/c-test"); } else { create_win(); prof_win_focus(plugin_win); prof_log_info(args[2]); char *str = "called -> prof_log_info: "; char buf[strlen(str) + strlen(args[2])]; sprintf(buf, "%s%s", str, args[2]); prof_win_show(plugin_win, buf); } } else if (strcmp(args[1], "warning") == 0) { if (!args[2]) { prof_cons_bad_cmd_usage("/c-test"); } else { create_win(); prof_win_focus(plugin_win); prof_log_warning(args[2]); char *str = "called -> prof_log_warning: "; char buf[strlen(str) + strlen(args[2])]; sprintf(buf, "%s%s", str, args[2]); prof_win_show(plugin_win, buf); } } else if (strcmp(args[1], "error") == 0) { if (!args[2]) { prof_cons_bad_cmd_usage("/c-test"); } else { create_win(); prof_win_focus(plugin_win); prof_log_error(args[2]); char *str = "called -> prof_log_error: "; char buf[strlen(str) + strlen(args[2])]; sprintf(buf, "%s%s", str, args[2]); prof_win_show(plugin_win, buf); } } else { prof_cons_bad_cmd_usage("/c-test"); } } else if (strcmp(args[0], "count") == 0) { create_win(); prof_win_focus(plugin_win); char buf[100]; sprintf(buf, "Count: %d", count); prof_win_show(plugin_win, buf); } else { prof_cons_bad_cmd_usage("/c-test"); } }