3 kopetecommand.h - Command
5 Copyright (c) 2003 by Jason Keirstead <jason@keirstead.org>
6 Copyright (c) 2005 by Michel Hermier <michel.hermier@wanadoo.fr>
7 Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
9 *************************************************************************
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of the GNU Lesser General Public *
13 * License as published by the Free Software Foundation; either *
14 * version 2 of the License, or (at your option) any later version. *
16 *************************************************************************
19 #ifndef KOPETECOMMAND_H
20 #define KOPETECOMMAND_H
22 #include <QtCore/QObject>
25 #include "kopetecommandhandler.h"
39 * an enum defining the type of a command
44 System
= 1 << 1, // Not removable command
45 Alias
= 1 << 2 // Is an alias
48 Q_DECLARE_FLAGS(Types
, Type
)
51 * Creates a Kopete::Command object
53 * @param parent The plugin who owns this command
54 * @param command The command we want to handle, not including the '/'
55 * @param handlerSlot The slot used to handle the command. This slot must
56 * accept two parameters, a QString of arguments, and a Kopete::ChatSession
57 * pointer to the Manager under which the command was sent.
58 * @param help An optional help string to be shown when the user uses
59 * /help <i>command</i>
60 * @param type If this command is an alias, and what type
61 * @param formatString The formatString of the alias if any
62 * @param minArgs Minimum number of arguments
63 * @param maxArgs Maximum number of arguments
64 * @param cut The shortcut for the command
65 * @param pix The icon to use for the command
67 Command( QObject
*parent
, const QString
&command
, const char* handlerSlot
,
68 const QString
&help
= QString(), CommandHandler::CommandType type
= CommandHandler::Normal
, const QString
&formatString
= QString(),
69 uint minArgs
= 0, int maxArgs
= -1, const KShortcut
&cut
= KShortcut(),
70 const QString
&pix
= QString() );
74 * Process this command
76 void processCommand( const QString
&args
, ChatSession
*manager
, bool gui
= false );
79 * Returns the command this object handles
81 const QString
&command() const { return m_command
; }
84 * Returns the help string for this command
86 const QString
&help() const { return m_help
; }
89 * Returns the type of the command
91 const CommandHandler::CommandType
type() const { return m_type
; }
95 * Emitted whenever a command is handled by this object. When a command
96 * has been handled, all processing on it stops by the command handler
97 * (a command cannot be handled twice)
99 void handleCommand( const QString
&args
, Kopete::ChatSession
*manager
);
103 * Connected to our activated() signal
108 void init( const QString
&command
, const char* slot
, const QString
&help
,
109 CommandHandler::CommandType type
, const QString
&formatString
,
110 uint minArgs
, int maxArgs
);
112 void printError( const QString
&error
, ChatSession
*manager
, bool gui
= false ) const;
116 QString m_formatString
;
120 CommandHandler::CommandType m_type
;
128 Q_DECLARE_OPERATORS_FOR_FLAGS(Kopete::Command::Types
)