pidgin  2.14.8
cmds.h
Go to the documentation of this file.
1 
7 /* Copyright (C) 2003 Timothy Ringenbach <omarvo@hotmail.com>
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
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22  *
23  */
24 #ifndef _PURPLE_CMDS_H_
25 #define _PURPLE_CMDS_H_
26 
27 #include "conversation.h"
28 
29 /**************************************************************************/
31 /**************************************************************************/
34 typedef struct _PurpleCmd PurpleCmd;
35 
37 typedef enum _PurpleCmdStatus {
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,
43  PURPLE_CMD_STATUS_WRONG_TYPE
45 
53 typedef enum _PurpleCmdRet {
57 } PurpleCmdRet;
58 
59 #define PURPLE_CMD_FUNC(func) ((PurpleCmdFunc)func)
60 
65 typedef PurpleCmdRet (*PurpleCmdFunc)(PurpleConversation *, const gchar *cmd,
66  gchar **args, gchar **error, void *data);
71 typedef guint PurpleCmdId;
72 
73 typedef enum _PurpleCmdPriority {
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,
81  PURPLE_CMD_P_VERY_HIGH = 6000
82 } PurpleCmdPriority;
83 
90 typedef enum _PurpleCmdFlag {
100 
107 typedef struct
108 {
110  /* @see purple_cmd_register for the argument values. */
111  void (*register_command)(const gchar *name, PurpleCmdPriority priority,
112  PurpleCmdFlag flags, const gchar *prpl_id,
113  const gchar *help, PurpleCmd *cmd);
114 
119  void (*unregister_command)(const gchar *name, const gchar *prpl_id);
120 
121  void (*_purple_reserved1)(void);
122  void (*_purple_reserved2)(void);
123  void (*_purple_reserved3)(void);
124  void (*_purple_reserved4)(void);
126 
129 #ifdef __cplusplus
130 extern "C" {
131 #endif
132 
133 /**************************************************************************/
135 /**************************************************************************/
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);
190 
201 
220 PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline,
221  const gchar *markup, gchar **errormsg);
222 
237 gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv,
238  const gchar *cmdline);
239 
253 GList *purple_cmd_list(PurpleConversation *conv);
254 
267 GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd);
268 
274 gpointer purple_cmds_get_handle(void);
275 
284 
292 
297 void purple_cmds_init(void);
298 
303 void purple_cmds_uninit(void);
304 
307 #ifdef __cplusplus
308 }
309 #endif
310 
311 #endif /* _PURPLE_CMDS_H_ */
void purple_cmds_init(void)
Initialize the commands subsystem.
The command failed, but stop looking.
Definition: cmds.h:55
enum _PurpleCmdRet PurpleCmdRet
Commands registered with the core return one of these values when run.
PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline, const gchar *markup, gchar **errormsg)
Do a command.
PurpleCmdId purple_cmd_register(const gchar *cmd, const gchar *args, PurpleCmdPriority p, PurpleCmdFlag f, const gchar *prpl_id, PurpleCmdFunc func, const gchar *helpstr, void *data)
Register a new command with the core.
guint PurpleCmdId
A unique integer representing a command registered with purple_cmd_register(), which can subsequently...
Definition: cmds.h:71
Command is usable only for a particular prpl.
Definition: cmds.h:96
Conversation API.
_PurpleCmdRet
Commands registered with the core return one of these values when run.
Definition: cmds.h:53
void purple_cmds_set_ui_ops(PurpleCommandsUiOps *ops)
Sets the UI operations structure to be used when registering and unregistering commands.
Command is usable in IMs.
Definition: cmds.h:92
_PurpleCmdStatus
The possible results of running a command with purple_cmd_do_command().
Definition: cmds.h:37
gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv, const gchar *cmdline)
Execute a specific command.
void purple_cmd_unregister(PurpleCmdId id)
Unregister a command with the core.
GList * purple_cmd_help(PurpleConversation *conv, const gchar *cmd)
Get the help string for a command.
Command is usable in multi-user chats.
Definition: cmds.h:94
PurpleCommandsUiOps * purple_cmds_get_ui_ops(void)
Returns the UI operations structure to be used when registering and unregistering commands...
enum _PurpleCmdStatus PurpleCmdStatus
The possible results of running a command with purple_cmd_do_command().
Everything's okay; Don't look for another command to call.
Definition: cmds.h:54
enum _PurpleCmdFlag PurpleCmdFlag
Flags used to set various properties of commands.
Incorrect arguments to this command should be accepted anyway.
Definition: cmds.h:98
GList * purple_cmd_list(PurpleConversation *conv)
List registered commands.
gpointer purple_cmds_get_handle(void)
Get the handle for the commands API.
Command UI operations; UIs should implement this if they want to handle commands themselves, rather than relying on the core.
Definition: cmds.h:107
void purple_cmds_uninit(void)
Uninitialize the commands subsystem.
_PurpleCmdFlag
Flags used to set various properties of commands.
Definition: cmds.h:90
Continue, looking for other commands with the same name to call.
Definition: cmds.h:56
A core representation of a conversation between two or more people.
Definition: conversation.h:338
PurpleCmdRet(* PurpleCmdFunc)(PurpleConversation *, const gchar *cmd, gchar **args, gchar **error, void *data)
A function implementing a command, as passed to purple_cmd_register().
Definition: cmds.h:65