Mercurial > hg
comparison mcabber/src/commands.c @ 748:53a000411587
Add /event command
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 13 Mar 2006 19:18:20 +0100 |
parents | 1877838d3c27 |
children | 938a8791658c |
comparison
equal
deleted
inserted
replaced
747:9875bc774ddf | 748:53a000411587 |
---|---|
28 #include "compl.h" | 28 #include "compl.h" |
29 #include "hooks.h" | 29 #include "hooks.h" |
30 #include "hbuf.h" | 30 #include "hbuf.h" |
31 #include "utils.h" | 31 #include "utils.h" |
32 #include "settings.h" | 32 #include "settings.h" |
33 #include "events.h" | |
33 | 34 |
34 // Commands callbacks | 35 // Commands callbacks |
35 static void do_roster(char *arg); | 36 static void do_roster(char *arg); |
36 static void do_status(char *arg); | 37 static void do_status(char *arg); |
37 static void do_status_to(char *arg); | 38 static void do_status_to(char *arg); |
54 static void do_rawxml(char *arg); | 55 static void do_rawxml(char *arg); |
55 static void do_room(char *arg); | 56 static void do_room(char *arg); |
56 static void do_authorization(char *arg); | 57 static void do_authorization(char *arg); |
57 static void do_version(char *arg); | 58 static void do_version(char *arg); |
58 static void do_request(char *arg); | 59 static void do_request(char *arg); |
60 static void do_event(char *arg); | |
59 | 61 |
60 // Global variable for the commands list | 62 // Global variable for the commands list |
61 static GSList *Commands; | 63 static GSList *Commands; |
62 | 64 |
63 | 65 |
90 COMPL_BUFFER, 0, &do_buffer); | 92 COMPL_BUFFER, 0, &do_buffer); |
91 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); | 93 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); |
92 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); | 94 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
93 cmd_add("del", "Delete the current buddy", 0, 0, &do_del); | 95 cmd_add("del", "Delete the current buddy", 0, 0, &do_del); |
94 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); | 96 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); |
97 cmd_add("event", "Process an event", 0, 0, &do_event); | |
95 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); | 98 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); |
96 //cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); | 99 //cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); |
97 cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info); | 100 cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info); |
98 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, | 101 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
99 0, &do_move); | 102 0, &do_move); |
1940 } | 1943 } |
1941 } | 1944 } |
1942 free_arg_lst(paramlst); | 1945 free_arg_lst(paramlst); |
1943 } | 1946 } |
1944 | 1947 |
1948 static void do_event(char *arg) | |
1949 { | |
1950 char **paramlst; | |
1951 char *evid, *subcmd; | |
1952 int action = -1; | |
1953 | |
1954 paramlst = split_arg(arg, 2, 0); // id, subcmd | |
1955 evid = *paramlst; | |
1956 subcmd = *(paramlst+1); | |
1957 | |
1958 if (!evid || !subcmd) { | |
1959 // Special case: /event list | |
1960 if (evid && !strcasecmp(evid, "list")) | |
1961 evs_display_list(); | |
1962 else | |
1963 scr_LogPrint(LPRINT_NORMAL, | |
1964 "Missing parameter. Usage: /event num action"); | |
1965 free_arg_lst(paramlst); | |
1966 return; | |
1967 } | |
1968 | |
1969 if (!strcasecmp(subcmd, "reject")) | |
1970 action = 0; | |
1971 else if (!strcasecmp(subcmd, "accept")) | |
1972 action = 1; | |
1973 | |
1974 if (action == -1) { | |
1975 scr_LogPrint(LPRINT_NORMAL, "Wrong action parameter."); | |
1976 } else if (action == 0 || action == 1) { | |
1977 if (evs_callback(evid, EVS_CONTEXT_USER + action) == -1) { | |
1978 scr_LogPrint(LPRINT_NORMAL, "Event %s not found.", evid); | |
1979 } | |
1980 } | |
1981 | |
1982 free_arg_lst(paramlst); | |
1983 } | |
1984 | |
1945 static void do_connect(char *arg) | 1985 static void do_connect(char *arg) |
1946 { | 1986 { |
1947 mcabber_connect(); | 1987 mcabber_connect(); |
1948 } | 1988 } |
1949 | 1989 |