1 /*
2  * Copyright (C) 2001-2008 Jacek Sieka, arnetheduck on gmail point com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 #ifndef DCPLUSPLUS_DCPP_USER_COMMAND_H
20 #define DCPLUSPLUS_DCPP_USER_COMMAND_H
21 
22 #include "Util.h"
23 #include "Flags.h"
24 
25 namespace dcpp {
26 
27 class UserCommand : public Flags {
28 public:
29 	typedef vector<UserCommand> List;
30 
31 	enum {
32 		TYPE_SEPARATOR,
33 		TYPE_RAW,
34 		TYPE_RAW_ONCE,
35 		TYPE_REMOVE,
36 		TYPE_CLEAR = 255		// In a momentary lapse of reason, 255 was chosen in the nmdc version of usercommand for clearing them all
37 	};
38 
39 	enum {
40 		CONTEXT_HUB = 0x01,
41 		CONTEXT_CHAT = 0x02,
42 		CONTEXT_SEARCH = 0x04,
43 		CONTEXT_FILELIST = 0x08,
44 		CONTEXT_MASK = CONTEXT_HUB | CONTEXT_CHAT | CONTEXT_SEARCH | CONTEXT_FILELIST
45 	};
46 
47 	enum {
48 		FLAG_NOSAVE = 0x01
49 	};
50 
UserCommand()51 	UserCommand() : cid(0), type(0), ctx(0) { }
UserCommand(int aId,int aType,int aCtx,int aFlags,const string & aName,const string & aCommand,const string & aHub)52 	UserCommand(int aId, int aType, int aCtx, int aFlags, const string& aName, const string& aCommand, const string& aHub) throw()
53 		: Flags(aFlags), cid(aId), type(aType), ctx(aCtx), name(aName), command(aCommand), hub(aHub) { }
54 
UserCommand(const UserCommand & rhs)55 	UserCommand(const UserCommand& rhs) : Flags(rhs), cid(rhs.cid), type(rhs.type),
56 		ctx(rhs.ctx), name(rhs.name), command(rhs.command), hub(rhs.hub)
57 	{
58 
59 	}
60 
61 	UserCommand& operator=(const UserCommand& rhs) {
62 		cid = rhs.cid; type = rhs.type; ctx = rhs.ctx;
63 		name = rhs.name; command = rhs.command; hub = rhs.hub;
64 		*((Flags*)this) = rhs;
65 		return *this;
66 	}
67 
68 	GETSET(int, cid, Id);
69 	GETSET(int, type, Type);
70 	GETSET(int, ctx, Ctx);
71 	GETSET(string, name, Name);
72 	GETSET(string, command, Command);
73 	GETSET(string, hub, Hub);
74 };
75 
76 } // namespace dcpp
77 
78 #endif // !defined(DCPLUSPLUS_DCPP_USER_COMMAND_H)
79