|
|
@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#include "asterisk/cli.h"
|
|
|
|
#include "asterisk/cli.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
|
|
|
|
#include "asterisk/paths.h"
|
|
|
|
|
|
|
|
|
|
|
|
AST_MUTEX_DEFINE_STATIC(verb_lock);
|
|
|
|
AST_MUTEX_DEFINE_STATIC(verb_lock);
|
|
|
|
|
|
|
|
|
|
|
@ -53,8 +54,6 @@ static int inuse=0;
|
|
|
|
static int clipipe[2];
|
|
|
|
static int clipipe[2];
|
|
|
|
static int cleanupid = -1;
|
|
|
|
static int cleanupid = -1;
|
|
|
|
|
|
|
|
|
|
|
|
static char *dtext = "Asterisk PBX Console (GTK Version)";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *window;
|
|
|
|
static GtkWidget *window;
|
|
|
|
static GtkWidget *quit;
|
|
|
|
static GtkWidget *quit;
|
|
|
|
static GtkWidget *closew;
|
|
|
|
static GtkWidget *closew;
|
|
|
@ -71,7 +70,7 @@ static void update_statusbar(char *msg)
|
|
|
|
gtk_statusbar_push(GTK_STATUSBAR(statusbar), 1, msg);
|
|
|
|
gtk_statusbar_push(GTK_STATUSBAR(statusbar), 1, msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int unload_module(void *mod)
|
|
|
|
static int unload_module(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (inuse) {
|
|
|
|
if (inuse) {
|
|
|
|
/* Kill off the main thread */
|
|
|
|
/* Kill off the main thread */
|
|
|
@ -97,7 +96,7 @@ static int cleanup(void *useless)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void __verboser(const char *stuff, int opos, int replacelast, int complete)
|
|
|
|
static void __verboser(const char *stuff)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *s2[2];
|
|
|
|
char *s2[2];
|
|
|
|
struct timeval tv;
|
|
|
|
struct timeval tv;
|
|
|
@ -105,8 +104,6 @@ static void __verboser(const char *stuff, int opos, int replacelast, int complet
|
|
|
|
s2[0] = (char *)stuff;
|
|
|
|
s2[0] = (char *)stuff;
|
|
|
|
s2[1] = NULL;
|
|
|
|
s2[1] = NULL;
|
|
|
|
gtk_clist_freeze(GTK_CLIST(verb));
|
|
|
|
gtk_clist_freeze(GTK_CLIST(verb));
|
|
|
|
if (replacelast)
|
|
|
|
|
|
|
|
gtk_clist_remove(GTK_CLIST(verb), GTK_CLIST(verb)->rows - 1);
|
|
|
|
|
|
|
|
gtk_clist_append(GTK_CLIST(verb), s2);
|
|
|
|
gtk_clist_append(GTK_CLIST(verb), s2);
|
|
|
|
if (!ast_tvzero(last)) {
|
|
|
|
if (!ast_tvzero(last)) {
|
|
|
|
gdk_threads_leave();
|
|
|
|
gdk_threads_leave();
|
|
|
@ -127,11 +124,11 @@ static void __verboser(const char *stuff, int opos, int replacelast, int complet
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void verboser(const char *stuff, int opos, int replacelast, int complete)
|
|
|
|
static void verboser(const char *stuff)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ast_mutex_lock(&verb_lock);
|
|
|
|
ast_mutex_lock(&verb_lock);
|
|
|
|
/* Lock appropriately if we're really being called in verbose mode */
|
|
|
|
/* Lock appropriately if we're really being called in verbose mode */
|
|
|
|
__verboser(stuff, opos, replacelast, complete);
|
|
|
|
__verboser(stuff);
|
|
|
|
ast_mutex_unlock(&verb_lock);
|
|
|
|
ast_mutex_unlock(&verb_lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -156,7 +153,7 @@ static void cliinput(void *data, int source, GdkInputCondition ic)
|
|
|
|
c++;
|
|
|
|
c++;
|
|
|
|
n = *c;
|
|
|
|
n = *c;
|
|
|
|
*c = '\0';
|
|
|
|
*c = '\0';
|
|
|
|
__verboser(l, 0, 0, 1);
|
|
|
|
__verboser(l);
|
|
|
|
*(c - 1) = '\0';
|
|
|
|
*(c - 1) = '\0';
|
|
|
|
*c = n;
|
|
|
|
*c = n;
|
|
|
|
l = c;
|
|
|
|
l = c;
|
|
|
@ -173,14 +170,13 @@ static void cliinput(void *data, int source, GdkInputCondition ic)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void remove_module(void)
|
|
|
|
static void remove_module(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
char *module;
|
|
|
|
char *module;
|
|
|
|
char buf[256];
|
|
|
|
char buf[256];
|
|
|
|
if (GTK_CLIST(modules)->selection) {
|
|
|
|
if (GTK_CLIST(modules)->selection) {
|
|
|
|
module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
|
|
|
|
module = (char *) gtk_clist_get_row_data(GTK_CLIST(modules), (long) GTK_CLIST(modules)->selection->data);
|
|
|
|
gdk_threads_leave();
|
|
|
|
gdk_threads_leave();
|
|
|
|
res = ast_unload_resource(module, 0);
|
|
|
|
res = ast_unload_resource(module, 0);
|
|
|
|
gdk_threads_enter();
|
|
|
|
gdk_threads_enter();
|
|
|
@ -193,13 +189,14 @@ static void remove_module(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static int reload_module(void *mod)
|
|
|
|
|
|
|
|
|
|
|
|
static int reload(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int res, x;
|
|
|
|
int res, x;
|
|
|
|
char *module;
|
|
|
|
char *module;
|
|
|
|
char buf[256];
|
|
|
|
char buf[256];
|
|
|
|
if (GTK_CLIST(modules)->selection) {
|
|
|
|
if (GTK_CLIST(modules)->selection) {
|
|
|
|
module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
|
|
|
|
module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (long) GTK_CLIST(modules)->selection->data);
|
|
|
|
module = strdup(module);
|
|
|
|
module = strdup(module);
|
|
|
|
if (module) {
|
|
|
|
if (module) {
|
|
|
|
gdk_threads_leave();
|
|
|
|
gdk_threads_leave();
|
|
|
@ -287,7 +284,7 @@ static int mod_update(void)
|
|
|
|
char *module= NULL;
|
|
|
|
char *module= NULL;
|
|
|
|
/* Update the mod stuff */
|
|
|
|
/* Update the mod stuff */
|
|
|
|
if (GTK_CLIST(modules)->selection) {
|
|
|
|
if (GTK_CLIST(modules)->selection) {
|
|
|
|
module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
|
|
|
|
module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (long) GTK_CLIST(modules)->selection->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_clist_freeze(GTK_CLIST(modules));
|
|
|
|
gtk_clist_freeze(GTK_CLIST(modules));
|
|
|
|
gtk_clist_clear(GTK_CLIST(modules));
|
|
|
|
gtk_clist_clear(GTK_CLIST(modules));
|
|
|
@ -413,7 +410,7 @@ static int show_console(void)
|
|
|
|
gtk_signal_connect(GTK_OBJECT(add), "clicked",
|
|
|
|
gtk_signal_connect(GTK_OBJECT(add), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (add_module), window);
|
|
|
|
GTK_SIGNAL_FUNC (add_module), window);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(reloadw), "clicked",
|
|
|
|
gtk_signal_connect(GTK_OBJECT(reloadw), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (reload_module), window);
|
|
|
|
GTK_SIGNAL_FUNC (reload), window);
|
|
|
|
|
|
|
|
|
|
|
|
bbox = gtk_vbox_new(FALSE, 5);
|
|
|
|
bbox = gtk_vbox_new(FALSE, 5);
|
|
|
|
gtk_widget_show(bbox);
|
|
|
|
gtk_widget_show(bbox);
|
|
|
@ -469,7 +466,7 @@ static int show_console(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int load_module(void *mod)
|
|
|
|
static int load_module(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pipe(clipipe)) {
|
|
|
|
if (pipe(clipipe)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to create CLI pipe\n");
|
|
|
|
ast_log(LOG_WARNING, "Unable to create CLI pipe\n");
|
|
|
@ -492,14 +489,8 @@ static int load_module(void *mod)
|
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char *description(void)
|
|
|
|
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "GTK Console",
|
|
|
|
{
|
|
|
|
.load = load_module,
|
|
|
|
return dtext;
|
|
|
|
.unload = unload_module,
|
|
|
|
}
|
|
|
|
.reload = reload,
|
|
|
|
|
|
|
|
);
|
|
|
|
static const char *key(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return ASTERISK_GPL_KEY;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STD_MOD(MOD_0, reload_module, NULL, NULL);
|
|
|
|
|
|
|
|