aboutsummaryrefslogtreecommitdiffstats
path: root/pbx/pbx_kdeconsole_main.cc
blob: 4ca3da5dd8de25eeca1910998b44c427b448cdfe (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
/*
 * Asterisk -- A telephony toolkit for Linux.
 *
 * KDE Console monitor -- Mostly glue code
 * 
 * Copyright (C) 1999, Mark Spencer
 *
 * Mark Spencer <markster@linux-support.net>
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License
 */

#include <asterisk/module.h>
#include <asterisk/channel.h>
#include <asterisk/logger.h>
#include <pthread.h>
#include "pbx_kdeconsole.h"

static char *dtext = "KDE Console Monitor";

static int inuse = 0;

static KAsteriskConsole *w;

static void verboser(char *stuff, int opos, int replacelast, int complete)
{
	const char *s2[2];
	s2[0] = stuff;
	s2[1] = NULL;
	if (replacelast)  {
		printf("Removing %d\n", w->verbose->count());
		w->verbose->removeItem(w->verbose->count());
	}
	w->verbose->insertStrList(s2, 1, -1);
	w->verbose->setBottomItem(w->verbose->count());
}

static int kde_main(int argc, char *argv[])
{
	KApplication a ( argc, argv );
	w = new KAsteriskConsole();
	a.setMainWidget(w);
	w->show();
	ast_register_verbose(verboser);
	return a.exec();
}

static void *kdemain(void *data)
{
	/* It would appear kde really wants to be main */;
	char *argv[1] = { "asteriskconsole" };
	kde_main(1, argv);
	return NULL;
}

extern "C" {

int unload_module(void)
{
	return inuse;
}

int load_module(void)
{
	pthread_t t;
	pthread_create(&t, NULL, kdemain, NULL);
	return 0;
}

int usecount(void)
{
	return inuse;
}

char *description(void)
{
	return dtext;
}

}