Thu, 28 Sep 2017 20:33:59 -0500
closing merged branch
| 9130 | 1 | /** |
| 2 | * @file cmds.h Commands API | |
| 3 | * @ingroup core | |
|
23555
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
4 | * @see @ref cmd-signals |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
7 | /* Copyright (C) 2003 Timothy Ringenbach <omarvo@hotmail.com> |
| 9130 | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify | |
| 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | * the Free Software Foundation; either version 2 of the License, or | |
| 12 | * (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | * GNU General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15884
diff
changeset
|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 9130 | 22 | * |
| 23 | */ | |
| 15884 | 24 | #ifndef _PURPLE_CMDS_H_ |
| 25 | #define _PURPLE_CMDS_H_ | |
| 9130 | 26 | |
| 27 | #include "conversation.h" | |
| 28 | ||
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10052
diff
changeset
|
29 | /**************************************************************************/ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10052
diff
changeset
|
30 | /** @name Structures */ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10052
diff
changeset
|
31 | /**************************************************************************/ |
| 9130 | 32 | /*@{*/ |
| 33 | ||
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
34 | typedef struct _PurpleCmd PurpleCmd; |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
35 | |
|
23510
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
36 | /** The possible results of running a command with purple_cmd_do_command(). */ |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
37 | typedef enum _PurpleCmdStatus { |
| 15884 | 38 | PURPLE_CMD_STATUS_OK, |
| 39 | PURPLE_CMD_STATUS_FAILED, | |
| 40 | PURPLE_CMD_STATUS_NOT_FOUND, | |
| 41 | PURPLE_CMD_STATUS_WRONG_ARGS, | |
| 42 | PURPLE_CMD_STATUS_WRONG_PRPL, | |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
23555
diff
changeset
|
43 | PURPLE_CMD_STATUS_WRONG_TYPE |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
44 | } PurpleCmdStatus; |
| 9130 | 45 | |
|
23510
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
46 | /** Commands registered with the core return one of these values when run. |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
47 | * Normally, a command will want to return one of the first two; in some |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
48 | * unusual cases, you might want to have several functions called for a |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
49 | * particular command; in this case, they should return |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
50 | * #PURPLE_CMD_RET_CONTINUE to cause the core to fall through to other |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
51 | * commands with the same name. |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
52 | */ |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
53 | typedef enum _PurpleCmdRet { |
|
23510
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
54 | PURPLE_CMD_RET_OK, /**< Everything's okay; Don't look for another command to call. */ |
| 15884 | 55 | PURPLE_CMD_RET_FAILED, /**< The command failed, but stop looking.*/ |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
23555
diff
changeset
|
56 | PURPLE_CMD_RET_CONTINUE /**< Continue, looking for other commands with the same name to call. */ |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
57 | } PurpleCmdRet; |
| 9130 | 58 | |
| 15884 | 59 | #define PURPLE_CMD_FUNC(func) ((PurpleCmdFunc)func) |
| 9597 | 60 | |
|
23510
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
61 | /** A function implementing a command, as passed to purple_cmd_register(). |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
62 | * |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
63 | * @todo document the arguments to these functions. |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
64 | * */ |
| 15884 | 65 | typedef PurpleCmdRet (*PurpleCmdFunc)(PurpleConversation *, const gchar *cmd, |
| 9597 | 66 | gchar **args, gchar **error, void *data); |
|
23510
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
67 | /** A unique integer representing a command registered with |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
68 | * purple_cmd_register(), which can subsequently be passed to |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
69 | * purple_cmd_unregister() to unregister that command. |
|
d4f5493b1c26
Document a few types in cmds, partly to make doxygen links to those types work.
Will Thompson <resiak@pidgin.im>
parents:
23420
diff
changeset
|
70 | */ |
| 15884 | 71 | typedef guint PurpleCmdId; |
| 9130 | 72 | |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
73 | typedef enum _PurpleCmdPriority { |
| 15884 | 74 | PURPLE_CMD_P_VERY_LOW = -1000, |
| 75 | PURPLE_CMD_P_LOW = 0, | |
| 76 | PURPLE_CMD_P_DEFAULT = 1000, | |
| 77 | PURPLE_CMD_P_PRPL = 2000, | |
| 78 | PURPLE_CMD_P_PLUGIN = 3000, | |
| 79 | PURPLE_CMD_P_ALIAS = 4000, | |
| 80 | PURPLE_CMD_P_HIGH = 5000, | |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
23555
diff
changeset
|
81 | PURPLE_CMD_P_VERY_HIGH = 6000 |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
82 | } PurpleCmdPriority; |
| 9130 | 83 | |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
84 | /** Flags used to set various properties of commands. Every command should |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
85 | * have at least one of #PURPLE_CMD_FLAG_IM and #PURPLE_CMD_FLAG_CHAT set in |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
86 | * order to be even slighly useful. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
87 | * |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
88 | * @see purple_cmd_register |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
89 | */ |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
90 | typedef enum _PurpleCmdFlag { |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
91 | /** Command is usable in IMs. */ |
| 15884 | 92 | PURPLE_CMD_FLAG_IM = 0x01, |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
93 | /** Command is usable in multi-user chats. */ |
| 15884 | 94 | PURPLE_CMD_FLAG_CHAT = 0x02, |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
95 | /** Command is usable only for a particular prpl. */ |
| 15884 | 96 | PURPLE_CMD_FLAG_PRPL_ONLY = 0x04, |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
97 | /** Incorrect arguments to this command should be accepted anyway. */ |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
23555
diff
changeset
|
98 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS = 0x08 |
|
22051
61dc80506e49
C++ doesn't really allow forward declarations of enums, and we
Mark Doliner <markdoliner@pidgin.im>
parents:
20370
diff
changeset
|
99 | } PurpleCmdFlag; |
| 9130 | 100 | |
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
101 | /** |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
102 | * Command UI operations; UIs should implement this if they want to handle |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
103 | * commands themselves, rather than relying on the core. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
104 | * |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
105 | * @see @ref ui-ops |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
106 | */ |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
107 | typedef struct |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
108 | { |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
109 | /** If implemented, the UI is responsible for handling commands. */ |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
110 | /* @see purple_cmd_register for the argument values. */ |
|
37686
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
111 | void (*register_command)(const gchar *name, PurpleCmdPriority priority, |
|
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
112 | PurpleCmdFlag flags, const gchar *prpl_id, |
|
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
113 | const gchar *help, PurpleCmd *cmd); |
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
114 | |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
115 | /** Should be implemented if register_command is implemented. |
|
37686
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
116 | * name and prpl_id will have the same value that were used |
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
117 | * for the register_command call. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
118 | */ |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
119 | void (*unregister_command)(const gchar *name, const gchar *prpl_id); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
120 | |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
121 | void (*_purple_reserved1)(void); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
122 | void (*_purple_reserved2)(void); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
123 | void (*_purple_reserved3)(void); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
124 | void (*_purple_reserved4)(void); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
125 | } PurpleCommandsUiOps; |
| 9130 | 126 | |
| 127 | /*@}*/ | |
| 128 | ||
| 129 | #ifdef __cplusplus | |
| 130 | extern "C" { | |
| 131 | #endif | |
| 132 | ||
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10052
diff
changeset
|
133 | /**************************************************************************/ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10052
diff
changeset
|
134 | /** @name Commands API */ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10052
diff
changeset
|
135 | /**************************************************************************/ |
| 9130 | 136 | /*@{*/ |
| 137 | ||
| 138 | /** | |
| 139 | * Register a new command with the core. | |
| 140 | * | |
| 141 | * The command will only happen if commands are enabled, | |
| 142 | * which is a UI pref. UIs don't have to support commands at all. | |
| 143 | * | |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
144 | * @param cmd The command. This should be a UTF-8 (or ASCII) string, with no spaces |
| 9130 | 145 | * or other white space. |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
146 | * @param args A string of characters describing to libpurple how to parse this |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
147 | * command's arguments. If what the user types doesn't match this |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
148 | * pattern, libpurple will keep looking for another command, unless |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
149 | * the flag #PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS is passed in @a f. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
150 | * This string should contain no whitespace, and use a single |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
151 | * character for each argument. The recognized characters are: |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
152 | * <ul> |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
153 | * <li><tt>'w'</tt>: Matches a single word.</li> |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
154 | * <li><tt>'W'</tt>: Matches a single word, with formatting.</li> |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
155 | * <li><tt>'s'</tt>: Matches the rest of the arguments after this |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
156 | * point, as a single string.</li> |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
157 | * <li><tt>'S'</tt>: Same as <tt>'s'</tt> but with formatting.</li> |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
158 | * </ul> |
| 9130 | 159 | * If args is the empty string, then the command accepts no arguments. |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
160 | * The args passed to the callback @a func will be a @c NULL |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
161 | * terminated array of @c NULL terminated strings, and will always |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
162 | * match the number of arguments asked for, unless |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
163 | * #PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS is passed. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
164 | * @param p This is the priority. Higher priority commands will be run first, |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
165 | * and usually the first command will stop any others from being |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
166 | * called. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
167 | * @param f Flags specifying various options about this command, combined with |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
168 | * <tt>|</tt> (bitwise OR). You need to at least pass one of |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
169 | * #PURPLE_CMD_FLAG_IM or #PURPLE_CMD_FLAG_CHAT (you may pass both) in |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
170 | * order for the command to ever actually be called. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
171 | * @param prpl_id If the #PURPLE_CMD_FLAG_PRPL_ONLY flag is set, this is the id |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
172 | * of the prpl to which the command applies (such as |
|
38082
63975292a852
Remove comment and docstring mentions of MSN
Mike Ruprecht <cmaiku@gmail.com>
parents:
37686
diff
changeset
|
173 | * <tt>"prpl-aim"</tt>). If the flag is not set, this parameter |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
174 | * is ignored; pass @c NULL (or a humourous string of your |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
175 | * choice!). |
| 9130 | 176 | * @param func This is the function to call when someone enters this command. |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
177 | * @param helpstr a whitespace sensitive, UTF-8, HTML string describing how to |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
178 | * use the command. The preferred format of this string is the |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
179 | * command's name, followed by a space and any arguments it |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
180 | * accepts (if it takes any arguments, otherwise no space), |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
181 | * followed by a colon, two spaces, and a description of the |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
182 | * command in sentence form. Do not include a slash before the |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
183 | * command name. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
184 | * @param data User defined data to pass to the #PurpleCmdFunc @a f. |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
185 | * @return A #PurpleCmdId, which is only used for calling |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
186 | * #purple_cmd_unregister, or @a 0 on failure. |
| 9130 | 187 | */ |
| 15884 | 188 | PurpleCmdId purple_cmd_register(const gchar *cmd, const gchar *args, PurpleCmdPriority p, PurpleCmdFlag f, |
| 189 | const gchar *prpl_id, PurpleCmdFunc func, const gchar *helpstr, void *data); | |
| 9130 | 190 | |
| 191 | /** | |
| 192 | * Unregister a command with the core. | |
| 193 | * | |
| 194 | * All registered commands must be unregistered, if they're registered by a plugin | |
| 195 | * or something else that might go away. Normally this is called when the plugin | |
| 196 | * unloads itself. | |
| 197 | * | |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
198 | * @param id The #PurpleCmdId to unregister, as returned by #purple_cmd_register. |
| 9130 | 199 | */ |
| 15884 | 200 | void purple_cmd_unregister(PurpleCmdId id); |
| 9130 | 201 | |
| 202 | /** | |
| 203 | * Do a command. | |
| 204 | * | |
| 205 | * Normally the UI calls this to perform a command. This might also be useful | |
| 206 | * if aliases are ever implemented. | |
| 207 | * | |
| 208 | * @param conv The conversation the command was typed in. | |
| 9175 | 209 | * @param cmdline The command the user typed (including all arguments) as a single string. |
| 9130 | 210 | * The caller doesn't have to do any parsing, except removing the command |
| 9597 | 211 | * prefix, which the core has no knowledge of. cmd should not contain any |
|
37686
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
212 | * formatting, and should be in plain text (no HTML entities). |
| 9175 | 213 | * @param markup This is the same as cmd, but is the formatted version. It should be in |
|
37686
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
214 | * HTML, with < > and &, at least, escaped to HTML entities, and should |
| 9175 | 215 | * include both the default formatting and any extra manual formatting. |
|
10788
79d6a09303e7
[gaim-migrate @ 12429]
Richard Laager <rlaager@pidgin.im>
parents:
10231
diff
changeset
|
216 | * @param errormsg If the command failed errormsg is filled in with the appropriate error |
|
79d6a09303e7
[gaim-migrate @ 12429]
Richard Laager <rlaager@pidgin.im>
parents:
10231
diff
changeset
|
217 | * message. It must be freed by the caller with g_free(). |
|
23420
ef0e6e2f4adc
A few character comment change.
Mark Doliner <markdoliner@pidgin.im>
parents:
22051
diff
changeset
|
218 | * @return A #PurpleCmdStatus indicating if the command succeeded or failed. |
| 9130 | 219 | */ |
| 15884 | 220 | PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline, |
| 9175 | 221 | const gchar *markup, gchar **errormsg); |
| 9130 | 222 | |
| 223 | /** | |
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
224 | * Execute a specific command. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
225 | * |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
226 | * The UI calls this to execute a command, after parsing the |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
227 | * command name. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
228 | * |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
229 | * @param c The command to execute. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
230 | * @param conv The conversation the command was typed in. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
231 | * @param cmdline The command the user typed (only the arguments). |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
232 | * The caller should remove the prefix and the command name. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
233 | * It should not contain any formatting, and should be |
|
37686
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
234 | * in plain text (no HTML entities). |
|
403b13cb3a47
PurpleCommandsUiOps: minor naming/docs fixes
dx <dx@dxzone.com.ar>
parents:
37685
diff
changeset
|
235 | * @return TRUE if the command handled the @a cmdline, FALSE otherwise. |
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
236 | */ |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
237 | gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv, |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
238 | const gchar *cmdline); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
239 | |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
240 | /** |
| 9130 | 241 | * List registered commands. |
| 242 | * | |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
243 | * Returns a <tt>GList</tt> (which must be freed by the caller) of all commands |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
244 | * that are valid in the context of @a conv, or all commands, if @a conv is @c |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
245 | * NULL. Don't keep this list around past the main loop, or anything else that |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
246 | * might unregister a command, as the <tt>const char *</tt>'s used get freed |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
247 | * then. |
| 9130 | 248 | * |
| 249 | * @param conv The conversation, or @c NULL. | |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
250 | * @return A @c GList of <tt>const char *</tt>, which must be freed with |
|
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
251 | * <tt>g_list_free()</tt>. |
| 9130 | 252 | */ |
| 15884 | 253 | GList *purple_cmd_list(PurpleConversation *conv); |
| 9130 | 254 | |
| 255 | /** | |
| 256 | * Get the help string for a command. | |
| 257 | * | |
| 258 | * Returns the help strings for a given command in the form of a GList, | |
| 259 | * one node for each matching command. | |
| 260 | * | |
| 261 | * @param conv The conversation, or @c NULL for no context. | |
| 262 | * @param cmd The command. No wildcards accepted, but returns help for all | |
| 263 | * commands if @c NULL. | |
|
20370
f24b280e0c29
Let's document more of cmds.h!
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
264 | * @return A <tt>GList</tt> of <tt>const char *</tt>s, which is the help string |
| 9130 | 265 | * for that command. |
| 266 | */ | |
| 15884 | 267 | GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd); |
| 9130 | 268 | |
|
23555
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
269 | /** |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
270 | * Get the handle for the commands API |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
271 | * @return The handle |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
272 | * @since 2.5.0 |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
273 | */ |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
274 | gpointer purple_cmds_get_handle(void); |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
275 | |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
276 | /** |
|
37685
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
277 | * Sets the UI operations structure to be used when registering and |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
278 | * unregistering commands. The UI operations need only be set if the |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
279 | * UI wants to handle the commands itself; otherwise, leave it as NULL. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
280 | * |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
281 | * @param ops The UI operations structure. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
282 | */ |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
283 | void purple_cmds_set_ui_ops(PurpleCommandsUiOps *ops); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
284 | |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
285 | /** |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
286 | * Returns the UI operations structure to be used when registering and |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
287 | * unregistering commands. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
288 | * |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
289 | * @return The UI operations structure. |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
290 | */ |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
291 | PurpleCommandsUiOps *purple_cmds_get_ui_ops(void); |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
292 | |
|
ef161f30f8bc
Add PurpleCommandsUiOps API from instantbird
Florian Quèze <florian@instantbird.org>
parents:
25105
diff
changeset
|
293 | /** |
|
23555
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
294 | * Initialize the commands subsystem. |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
295 | * @since 2.5.0 |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
296 | */ |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
297 | void purple_cmds_init(void); |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
298 | |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
299 | /** |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
300 | * Uninitialize the commands subsystem. |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
301 | * @since 2.5.0 |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
302 | */ |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
303 | void purple_cmds_uninit(void); |
|
82dab41b4163
cmd-added and cmd-removed signals to emit when commands are registered/unregistered.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23510
diff
changeset
|
304 | |
| 9130 | 305 | /*@}*/ |
| 306 | ||
| 307 | #ifdef __cplusplus | |
| 308 | } | |
| 309 | #endif | |
| 310 | ||
| 15884 | 311 | #endif /* _PURPLE_CMDS_H_ */ |