cmds.h

Go to the documentation of this file.
00001 
00007 /* Copyright (C) 2003 Timothy Ringenbach <omarvo@hotmail.com>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00022  *
00023  */
00024 #ifndef _PURPLE_CMDS_H_
00025 #define _PURPLE_CMDS_H_
00026 
00027 #include "conversation.h"
00028 
00029 /**************************************************************************/
00031 /**************************************************************************/
00034 typedef struct _PurpleCmd PurpleCmd;
00035 
00037 typedef enum _PurpleCmdStatus {
00038     PURPLE_CMD_STATUS_OK,
00039     PURPLE_CMD_STATUS_FAILED,
00040     PURPLE_CMD_STATUS_NOT_FOUND,
00041     PURPLE_CMD_STATUS_WRONG_ARGS,
00042     PURPLE_CMD_STATUS_WRONG_PRPL,
00043     PURPLE_CMD_STATUS_WRONG_TYPE
00044 } PurpleCmdStatus;
00045 
00053 typedef enum _PurpleCmdRet {
00054     PURPLE_CMD_RET_OK,       
00055     PURPLE_CMD_RET_FAILED,   
00056     PURPLE_CMD_RET_CONTINUE 
00057 } PurpleCmdRet;
00058 
00059 #define PURPLE_CMD_FUNC(func) ((PurpleCmdFunc)func)
00060 
00065 typedef PurpleCmdRet (*PurpleCmdFunc)(PurpleConversation *, const gchar *cmd,
00066                                   gchar **args, gchar **error, void *data);
00071 typedef guint PurpleCmdId;
00072 
00073 typedef enum _PurpleCmdPriority {
00074     PURPLE_CMD_P_VERY_LOW  = -1000,
00075     PURPLE_CMD_P_LOW       =     0,
00076     PURPLE_CMD_P_DEFAULT   =  1000,
00077     PURPLE_CMD_P_PRPL      =  2000,
00078     PURPLE_CMD_P_PLUGIN    =  3000,
00079     PURPLE_CMD_P_ALIAS     =  4000,
00080     PURPLE_CMD_P_HIGH      =  5000,
00081     PURPLE_CMD_P_VERY_HIGH =  6000
00082 } PurpleCmdPriority;
00083 
00090 typedef enum _PurpleCmdFlag {
00092     PURPLE_CMD_FLAG_IM               = 0x01,
00094     PURPLE_CMD_FLAG_CHAT             = 0x02,
00096     PURPLE_CMD_FLAG_PRPL_ONLY        = 0x04,
00098     PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS = 0x08
00099 } PurpleCmdFlag;
00100 
00107 typedef struct
00108 {
00110     /* @see purple_cmd_register for the argument values. */
00111     void (*register_command)(const gchar *name, PurpleCmdPriority priority,
00112                  PurpleCmdFlag flags, const gchar *prpl_id,
00113                  const gchar *help, PurpleCmd *cmd);
00114 
00119     void (*unregister_command)(const gchar *name, const gchar *prpl_id);
00120 
00121     void (*_purple_reserved1)(void);
00122     void (*_purple_reserved2)(void);
00123     void (*_purple_reserved3)(void);
00124     void (*_purple_reserved4)(void);
00125 } PurpleCommandsUiOps;
00126 
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132 
00133 /**************************************************************************/
00135 /**************************************************************************/
00188 PurpleCmdId purple_cmd_register(const gchar *cmd, const gchar *args, PurpleCmdPriority p, PurpleCmdFlag f,
00189                              const gchar *prpl_id, PurpleCmdFunc func, const gchar *helpstr, void *data);
00190 
00200 void purple_cmd_unregister(PurpleCmdId id);
00201 
00220 PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmdline,
00221                                   const gchar *markup, gchar **errormsg);
00222 
00237 gboolean purple_cmd_execute(PurpleCmd *c, PurpleConversation *conv,
00238                 const gchar *cmdline);
00239 
00253 GList *purple_cmd_list(PurpleConversation *conv);
00254 
00267 GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd);
00268 
00274 gpointer purple_cmds_get_handle(void);
00275 
00283 void purple_cmds_set_ui_ops(PurpleCommandsUiOps *ops);
00284 
00291 PurpleCommandsUiOps *purple_cmds_get_ui_ops(void);
00292 
00297 void purple_cmds_init(void);
00298 
00303 void purple_cmds_uninit(void);
00304 
00307 #ifdef __cplusplus
00308 }
00309 #endif
00310 
00311 #endif /* _PURPLE_CMDS_H_ */