pidgin: cmds.h Source File

pidgin 2.14.4

Loading...
Searching...
No Matches
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/**************************************************************************/
34typedef 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
44} PurpleCmdStatus;
45
53 typedef enum _PurpleCmdRet {
54 PURPLE_CMD_RET_OK,
55 PURPLE_CMD_RET_FAILED,
56 PURPLE_CMD_RET_CONTINUE
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
73typedef 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 {
92 PURPLE_CMD_FLAG_IM = 0x01,
94 PURPLE_CMD_FLAG_CHAT = 0x02,
96 PURPLE_CMD_FLAG_PRPL_ONLY = 0x04,
98 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS = 0x08
99} 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);
125} PurpleCommandsUiOps;
126
129#ifdef __cplusplus
130extern "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
200 void purple_cmd_unregister(PurpleCmdId id);
201
220 PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline,
221 const gchar *markup, gchar **errormsg);
222
237gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv,
238 const gchar *cmdline);
239
253GList *purple_cmd_list(PurpleConversation *conv);
254
267GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd);
268
274gpointer purple_cmds_get_handle(void);
275
283 void purple_cmds_set_ui_ops(PurpleCommandsUiOps *ops);
284
291 PurpleCommandsUiOps *purple_cmds_get_ui_ops(void);
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_ */
_PurpleCmdRet
_PurpleCmdRet
Commands registered with the core return one of these values when run.
Definition: cmds.h:53
PURPLE_CMD_RET_CONTINUE
@ PURPLE_CMD_RET_CONTINUE
Continue, looking for other commands with the same name to call.
Definition: cmds.h:56
PURPLE_CMD_RET_FAILED
@ PURPLE_CMD_RET_FAILED
The command failed, but stop looking.
Definition: cmds.h:55
PURPLE_CMD_RET_OK
@ PURPLE_CMD_RET_OK
Everything's okay; Don't look for another command to call.
Definition: cmds.h:54
purple_cmd_execute
gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv, const gchar *cmdline)
Execute a specific command.
PurpleCmdRet
enum _PurpleCmdRet PurpleCmdRet
Commands registered with the core return one of these values when run.
purple_cmd_do_command
PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline, const gchar *markup, gchar **errormsg)
Do a command.
PurpleCmdFlag
enum _PurpleCmdFlag PurpleCmdFlag
Flags used to set various properties of commands.
purple_cmd_list
GList * purple_cmd_list(PurpleConversation *conv)
List registered commands.
purple_cmd_help
GList * purple_cmd_help(PurpleConversation *conv, const gchar *cmd)
Get the help string for a command.
purple_cmds_set_ui_ops
void purple_cmds_set_ui_ops(PurpleCommandsUiOps *ops)
Sets the UI operations structure to be used when registering and unregistering commands.
PurpleCmdFunc
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
_PurpleCmdFlag
_PurpleCmdFlag
Flags used to set various properties of commands.
Definition: cmds.h:90
PURPLE_CMD_FLAG_PRPL_ONLY
@ PURPLE_CMD_FLAG_PRPL_ONLY
Command is usable only for a particular prpl.
Definition: cmds.h:96
PURPLE_CMD_FLAG_IM
@ PURPLE_CMD_FLAG_IM
Command is usable in IMs.
Definition: cmds.h:92
PURPLE_CMD_FLAG_CHAT
@ PURPLE_CMD_FLAG_CHAT
Command is usable in multi-user chats.
Definition: cmds.h:94
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS
@ PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS
Incorrect arguments to this command should be accepted anyway.
Definition: cmds.h:98
purple_cmds_get_handle
gpointer purple_cmds_get_handle(void)
Get the handle for the commands API.
purple_cmd_register
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.
PurpleCmdId
guint PurpleCmdId
A unique integer representing a command registered with purple_cmd_register(), which can subsequently...
Definition: cmds.h:71
_PurpleCmdStatus
_PurpleCmdStatus
The possible results of running a command with purple_cmd_do_command().
Definition: cmds.h:37
PurpleCmdStatus
enum _PurpleCmdStatus PurpleCmdStatus
The possible results of running a command with purple_cmd_do_command().
purple_cmds_uninit
void purple_cmds_uninit(void)
Uninitialize the commands subsystem.
purple_cmds_init
void purple_cmds_init(void)
Initialize the commands subsystem.
purple_cmds_get_ui_ops
PurpleCommandsUiOps * purple_cmds_get_ui_ops(void)
Returns the UI operations structure to be used when registering and unregistering commands.
purple_cmd_unregister
void purple_cmd_unregister(PurpleCmdId id)
Unregister a command with the core.
conversation.h
Conversation API.
PurpleCommandsUiOps
Command UI operations; UIs should implement this if they want to handle commands themselves,...
Definition: cmds.h:108
_PurpleConversation
A core representation of a conversation between two or more people.
Definition: conversation.h:339