cmds.h
Go to the documentation of this file.
/* Copyright (C) 2003 Timothy Ringenbach <omarvo@hotmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#ifndef _PURPLE_CMDS_H_
#define _PURPLE_CMDS_H_
#include "conversation.h"
/**************************************************************************/
/**************************************************************************/
typedef struct _PurpleCmd PurpleCmd;
typedef enum _PurpleCmdStatus {
PURPLE_CMD_STATUS_OK,
PURPLE_CMD_STATUS_FAILED,
PURPLE_CMD_STATUS_NOT_FOUND,
PURPLE_CMD_STATUS_WRONG_ARGS,
PURPLE_CMD_STATUS_WRONG_PRPL,
PURPLE_CMD_STATUS_WRONG_TYPE
} PurpleCmdStatus;
typedef enum _PurpleCmdRet {
PURPLE_CMD_RET_OK,
PURPLE_CMD_RET_FAILED,
PURPLE_CMD_RET_CONTINUE
} PurpleCmdRet;
#define PURPLE_CMD_FUNC(func) ((PurpleCmdFunc)func)
typedef PurpleCmdRet (*PurpleCmdFunc)(PurpleConversation *, const gchar *cmd,
gchar **args, gchar **error, void *data);
typedef guint PurpleCmdId;
typedef enum _PurpleCmdPriority {
PURPLE_CMD_P_VERY_LOW = -1000,
PURPLE_CMD_P_LOW = 0,
PURPLE_CMD_P_DEFAULT = 1000,
PURPLE_CMD_P_PRPL = 2000,
PURPLE_CMD_P_PLUGIN = 3000,
PURPLE_CMD_P_ALIAS = 4000,
PURPLE_CMD_P_HIGH = 5000,
PURPLE_CMD_P_VERY_HIGH = 6000
} PurpleCmdPriority;
typedef enum _PurpleCmdFlag {
PURPLE_CMD_FLAG_IM = 0x01,
PURPLE_CMD_FLAG_CHAT = 0x02,
PURPLE_CMD_FLAG_PRPL_ONLY = 0x04,
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS = 0x08
} PurpleCmdFlag;
typedef struct
{
/* @see purple_cmd_register for the argument values. */
void (*register_command)(const gchar *name, PurpleCmdPriority priority,
PurpleCmdFlag flags, const gchar *prpl_id,
const gchar *help, PurpleCmd *cmd);
void (*unregister_command)(const gchar *name, const gchar *prpl_id);
void (*_purple_reserved1)(void);
void (*_purple_reserved2)(void);
void (*_purple_reserved3)(void);
void (*_purple_reserved4)(void);
} PurpleCommandsUiOps;
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************/
/**************************************************************************/
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);
void purple_cmd_unregister(PurpleCmdId id);
PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline,
const gchar *markup, gchar **errormsg);
gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv,
const gchar *cmdline);
GList *purple_cmd_list(PurpleConversation *conv);
GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd);
gpointer purple_cmds_get_handle(void);
void purple_cmds_set_ui_ops(PurpleCommandsUiOps *ops);
PurpleCommandsUiOps *purple_cmds_get_ui_ops(void);
void purple_cmds_init(void);
void purple_cmds_uninit(void);
#ifdef __cplusplus
}
#endif
#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.
purple_cmd_list
GList * purple_cmd_list(PurpleConversation *conv)
List registered commands.
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_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_cmd_unregister
void purple_cmd_unregister(PurpleCmdId id)
Unregister a command with the core.
purple_cmd_help
GList * purple_cmd_help(PurpleConversation *conv, const gchar *cmd)
Get the help string for a command.
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.
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