| 16 * |
16 * |
| 17 */ |
17 */ |
| 18 |
18 |
| 19 #ifndef PURPLE_CMDS_H |
19 #ifndef PURPLE_CMDS_H |
| 20 #define PURPLE_CMDS_H |
20 #define PURPLE_CMDS_H |
| |
21 |
| 21 /** |
22 /** |
| 22 * SECTION:cmds |
23 * SECTION:cmds |
| 23 * @section_id: libpurple-cmds |
24 * @section_id: libpurple-cmds |
| 24 * @short_description: <filename>cmds.h</filename> |
25 * @short_description: <filename>cmds.h</filename> |
| 25 * @title: Commands API |
26 * @title: Commands API |
| 26 * @see_also: <link linkend="chapter-signals-cmd">Command signals</link> |
27 * @see_also: <link linkend="chapter-signals-cmd">Command signals</link> |
| 27 */ |
28 */ |
| 28 |
29 |
| 29 #include "conversation.h" |
30 #include "conversation.h" |
| 30 |
31 |
| 31 /**************************************************************************/ |
32 /****************************************************************************** |
| 32 /* Structures */ |
33 * Structures |
| 33 /**************************************************************************/ |
34 *****************************************************************************/ |
| 34 |
35 |
| 35 /** |
36 /** |
| 36 * PurpleCmdStatus: |
37 * PurpleCmdStatus: |
| |
38 * @PURPLE_CMD_STATUS_OK: The command executed successfully. |
| |
39 * @PURPLE_CMD_STATUS_FAILED: The command failed to execute. |
| |
40 * @PURPLE_CMD_STATUS_NOT_FOUND: The command was not found. |
| |
41 * @PURPLE_CMD_STATUS_WRONG_ARGS: The wrong number of arguments were passed. |
| |
42 * @PURPLE_CMD_STATUS_WRONG_PROTOCOL: The command was wrong with the wrong |
| |
43 * protocol. |
| |
44 * @PURPLE_CMD_STATUS_WRONG_TYPE: Command was ran against the wrong type of |
| |
45 * conversation. |
| 37 * |
46 * |
| 38 * The possible results of running a command with purple_cmd_do_command(). |
47 * The possible results of running a command with purple_cmd_do_command(). |
| 39 */ |
48 */ |
| 40 typedef enum { |
49 typedef enum { |
| 41 PURPLE_CMD_STATUS_OK, |
50 PURPLE_CMD_STATUS_OK, |
| 69 |
78 |
| 70 #define PURPLE_CMD_FUNC(func) ((PurpleCmdFunc)func) |
79 #define PURPLE_CMD_FUNC(func) ((PurpleCmdFunc)func) |
| 71 |
80 |
| 72 /** |
81 /** |
| 73 * PurpleCmdFunc: |
82 * PurpleCmdFunc: |
| |
83 * @conversation: The #PurpleConversation where the command is being run. |
| |
84 * @cmd: The name of the command. |
| |
85 * @args: The arguments to the command. |
| |
86 * @error: (out): A return address for a #GError. |
| |
87 * @data: User data to pass to the function. |
| 74 * |
88 * |
| 75 * A function implementing a command, as passed to purple_cmd_register(). |
89 * A function implementing a command, as passed to purple_cmd_register(). |
| 76 */ |
90 */ |
| 77 /* TODO document the arguments to these functions. */ |
|
| 78 typedef PurpleCmdRet (*PurpleCmdFunc)(PurpleConversation *conversation, const gchar *cmd, |
91 typedef PurpleCmdRet (*PurpleCmdFunc)(PurpleConversation *conversation, const gchar *cmd, |
| 79 gchar **args, gchar **error, void *data); |
92 gchar **args, gchar **error, void *data); |
| 80 /** |
93 /** |
| 81 * PurpleCmdId: |
94 * PurpleCmdId: |
| 82 * |
95 * |
| 84 * purple_cmd_register(), which can subsequently be passed to |
97 * purple_cmd_register(), which can subsequently be passed to |
| 85 * purple_cmd_unregister() to unregister that command. |
98 * purple_cmd_unregister() to unregister that command. |
| 86 */ |
99 */ |
| 87 typedef guint PurpleCmdId; |
100 typedef guint PurpleCmdId; |
| 88 |
101 |
| |
102 /** |
| |
103 * PurpleCmdPriority: |
| |
104 * @PURPLE_CMD_P_VERY_LOW: Lowest priority. |
| |
105 * @PURPLE_CMD_P_LOW: Low priority. |
| |
106 * @PURPLE_CMD_P_DEFAULT: Default priority. |
| |
107 * @PURPLE_CMD_P_PROTOCOL: Priority for protocol plugins. |
| |
108 * @PURPLE_CMD_P_PLUGIN: Priority for plugins. |
| |
109 * @PURPLE_CMD_P_ALIAS: Priority for aliasing commands. |
| |
110 * @PURPLE_CMD_P_HIGH: High priority. |
| |
111 * @PURPLE_CMD_P_VERY_HIGH: Highest priority. |
| |
112 * |
| |
113 * Commands are registered from multiple locations which leads to name |
| |
114 * collisions. PurpleCmdPriority is used to determine which command to will |
| |
115 * be run. |
| |
116 */ |
| 89 typedef enum { |
117 typedef enum { |
| 90 PURPLE_CMD_P_VERY_LOW = -1000, |
118 PURPLE_CMD_P_VERY_LOW = -1000, |
| 91 PURPLE_CMD_P_LOW = 0, |
119 PURPLE_CMD_P_LOW = 0, |
| 92 PURPLE_CMD_P_DEFAULT = 1000, |
120 PURPLE_CMD_P_DEFAULT = 1000, |
| 93 PURPLE_CMD_P_PROTOCOL = 2000, |
121 PURPLE_CMD_P_PROTOCOL = 2000, |