summaryrefslogtreecommitdiffstats
path: root/src/modules/links/libkvilinks.cpp
blob: 6486b985957561d42395107bd927c2089101dca4 (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
//
//   File : libkvilinks.cpp
//   Creation date : Thu Dec 21 2000 12:39:12 CEST by Szymon Stefanek
//
//   Copyright (C) 1999-2001 Szymon Stefanek (pragma at kvirc dot net)
//
//   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 "linkswindow.h"

#include "kvi_frame.h"
#include "kvi_window.h"
#include "kvi_locale.h"

#include <qsplitter.h>

KviPointerList<KviLinksWindow> * g_pLinksWindowList = 0;


/*
	@doc: links.open
	@type:
		command
	@title:
		links.open
	@short:
		Opens a Links window
	@syntax:
		links.open
	@description:
		Opens a "links" window attacched to the current irc context.[br]
		The links window handles the RPL_LINKS server replies and shows
		them in a Tree-View form: this is useful in vizualizing the
		current network connections.[br]
		Please note that the total number of links received (and the
		total count of servers displayed when all the links have been received)
		may actually be less than the real number of irc servers in the network.
		Servers that contain a wildcard in their name often act as gateways (hubs)
		for a "local irc network"; if you're requesting links from a server that is
		external to the gateway, the servers internal to the network "behind the gateway"
		will not be shown; in the extreme case you will see the gateway as leaf node (and it isn't).
		To see the internal network server tree you might request LINKS from the gateway server.[br]
*/


static bool links_kvs_cmd_open(KviKvsModuleCommandCall * c)
{
	
	// FIND ME
	if(!c->window()->console())return c->context()->errorNoIrcContext();

	if(!(c->window()->console()->ircContext()->linksWindow()))
	{
		KviLinksWindow *w = new KviLinksWindow(c->window()->frame(),c->window()->console());
		c->window()->frame()->addWindow(w);
	} else {
		c->warning(__tr2qs("Links window alread open for this IRC context"));
	}

	return true;
}




static bool links_module_init(KviModule * m)
{
	g_pLinksWindowList = new KviPointerList<KviLinksWindow>;
	g_pLinksWindowList->setAutoDelete(false);


	KVSM_REGISTER_SIMPLE_COMMAND(m,"open",links_kvs_cmd_open);

	return true;
}

static bool links_module_cleanup(KviModule *m)
{
	while(g_pLinksWindowList->first())g_pLinksWindowList->first()->die();
	delete g_pLinksWindowList;
	g_pLinksWindowList = 0;
	return true;
}

static bool links_module_can_unload(KviModule *m)
{
	return (g_pLinksWindowList->isEmpty());
}

KVIRC_MODULE(
	"Links",                                             // module name
	"1.0.0",                                                // module version
	"Copyright (C) 2000-2001 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
	"Links window extension",
	links_module_init,
	links_module_can_unload,
	0,
	links_module_cleanup
)