summaryrefslogtreecommitdiffstats
path: root/src/modules/tmphighlight/libkvitmphighlight.cpp
blob: b69b79984c9912765580fbda9bd5bd78fb2c686b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//   File : libkvitmphighlight.cpp
//   Creation date :  Oct 10 01:06:09 CEST 2002 by Juanjo �varez
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2002 Juanjo �varez (juanjux@yahoo.es)
//   Copyright (C) 2002 Szymon Stefanek (kvirc@tin.it)
//
//   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 opinion) 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 02110-1301, USA.
//


#include "kvi_module.h"

#include "kvi_locale.h"
#include "kvi_channel.h"

//-------------------------------------------------
/*
	@doc: tmphighlight.add
	@type:
		command
	@title:
		tmphighlight.add
	@short:
		Adds a user to the channel temporary highlight list
	@syntax:
		tmphighlight.add <nick:string>
	@description:
		This command adds a user to the channel temporary highlight list, so that user messages[br]
		will be highlighted until you close the channel. This is useful when you are in a very crowded [br]
		channel with lots of conversations running in parallel and you want to follow one of them.[br]
	@seealso:
		[fnc]$tmphighlight.remove[/fnc]
		[fnc]$tmphighlight.ishighlighted[/fnc]
*/
//-------------------------------------------
// tmphighlight.add
//-------------------------------------------
static bool tmphighlight_kvs_cmd_add(KviKvsModuleCommandCall * c)
{ 
	
	TQString szNick;
	KVSM_PARAMETERS_BEGIN(c)
		KVSM_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick)
	KVSM_PARAMETERS_END(c)
	if( ( !c->window()->console()) || c->window()->console()->isNotConnected() )return c->context()->errorNoIrcContext();
	if(!c->window()->type() == KVI_WINDOW_TYPE_CHANNEL)
	{
		c->warning(__tr2qs("Current window is not a channel"));
		return false;
	}
	
	((KviChannel *)c->window())->addHighlightedUser(szNick);

	return true;
}
//-------------------------------------------------
/*
	@doc: tmphighlight.remove
	@type:
		command
	@title:
		tmphighlight.remove
	@short:
		Remove a user from the channel temporary highlight list
	@syntax:
		tmphighlight.remove <nick:string>
	@description:
		This command remove a user from the channel temporary highlight list, so that user messages[br]
		stop being highlighted.
	@seealso:
		[fnc]$tmphighlight.add[/fnc]
		[fnc]$tmphighlight.ishighlighted[/fnc]
*/
//-------------------------------------------
// tmphighlight.remove
//-------------------------------------------

static bool tmphighlight_kvs_cmd_remove(KviKvsModuleCommandCall * c)
{
	TQString szNick;
	KVSM_PARAMETERS_BEGIN(c)
		KVSM_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick)
	KVSM_PARAMETERS_END(c)
	if( ( !c->window()->console()) || c->window()->console()->isNotConnected() )return c->context()->errorNoIrcContext();
		if(!c->window()->type() == KVI_WINDOW_TYPE_CHANNEL)
	{
		c->warning(__tr2qs("Current window is not a channel"));
		return false;
	}

	((KviChannel *)c->window())->removeHighlightedUser(szNick);
	return true;
}
//-------------------------------------------------
/*
	@doc: tmphighlight.ishighlighted
	@type:
		function
	@title:
		$tmphighlight.ishighlighted
	@short:
		Returns 1 if the user is highlighted on this channel, 0 otherwise
	@syntax:
		<boolean> $tmphighlight.ishighlighted <nick:string>
	@description:
		This command returns 1 if the user is highlighted on this channel and on this session of 0 otherwise.
	@seealso:
		[fnc]$tmphighlight.add[/fnc]
		[fnc]$tmphighlight.remove[/fnc]

*/
//-------------------------------------------
// tmphighlight.ishighlighted
//-------------------------------------------

static bool tmphighlight_kvs_fnc_ishighlighted(KviKvsModuleFunctionCall * c)
{
	TQString szNick;
	KVSM_PARAMETERS_BEGIN(c)
		KVSM_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick)
	KVSM_PARAMETERS_END(c)
	if( ( !c->window()->console()) || c->window()->console()->isNotConnected() )return c->context()->errorNoIrcContext();
		if(!c->window()->type() == KVI_WINDOW_TYPE_CHANNEL)
	{
		c->warning(__tr2qs("Current window is not a channel"));
		return false;
	}
	c->returnValue()->setBoolean(((KviChannel *)c->window())->isHighlightedUser(szNick));
	return true;
}

//-------------------------------------------------    
static bool tmphighlight_module_init(KviModule * m)
{
	KVSM_REGISTER_SIMPLE_COMMAND(m,"add",tmphighlight_kvs_cmd_add);
	KVSM_REGISTER_SIMPLE_COMMAND(m,"remove",tmphighlight_kvs_cmd_remove);
	KVSM_REGISTER_FUNCTION(m,"isHighVisible",tmphighlight_kvs_fnc_ishighlighted);
	KVSM_REGISTER_FUNCTION(m,"isHighLighted",tmphighlight_kvs_fnc_ishighlighted);
	return true;
}
//-------------------------------------------------
static bool tmphighlight_module_cleanup(KviModule *m)
{
	return true;
}
//-------------------------------------------------
static bool tmphighlight_module_can_unload(KviModule *m)
{
	return true;
}
//-------------------------------------------------
KVIRC_MODULE(
	"TmpHighlight",                                                 // module name
	"1.0.0",                                                // module version
	"          (C) 2002 Juanjo Alvarez (juanjux@yahoo.es)", // author & (C)
	"Temporal Highlightining of channel users",
	tmphighlight_module_init,
	tmphighlight_module_can_unload,
	0,
	tmphighlight_module_cleanup
)