Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:11 2009

## Asterisk developer's documentation

# pbx_gtkconsole.c File Reference

GTK Console monitor -- very kludgy right now. More...

`#include <sys/types.h>`
`#include <stdlib.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <stdarg.h>`
`#include <signal.h>`
`#include <sys/time.h>`
`#include <gtk/gtk.h>`
`#include <glib.h>`
`#include "asterisk.h"`
`#include "asterisk/pbx.h"`
`#include "asterisk/config.h"`
`#include "asterisk/module.h"`
`#include "asterisk/logger.h"`
`#include "asterisk/options.h"`
`#include "asterisk/cli.h"`
`#include "asterisk/utils.h"`

Include dependency graph for pbx_gtkconsole.c:

Go to the source code of this file.

## Functions

static void | __verboser (const char *stuff, int opos, int replacelast, int complete)
static int | add_mod (const char *module, const char *description, int usecount, const char *like)
static void | add_module (void)
| AST_MUTEX_DEFINE_STATIC (verb_lock)
static int | cleanup (void *useless)
static int | cli_activate (void)
static void | cliinput (void *data, int source, GdkInputCondition ic)
static void * | consolethread (void *data)
char * | description (void)
| Provides a description of the module.
static void | exit_completely (GtkWidget *widget, gpointer data)
static void | exit_nicely (GtkWidget *widget, gpointer data)
static void | exit_now (GtkWidget *widget, gpointer data)
static void | file_ok_sel (GtkWidget *w, GtkFileSelection *fs)
char * | key (void)
| Returns the ASTERISK_GPL_KEY.
int | load_module (void)
| Initialize the module.
static int | mod_update (void)
static void | reload_module (void)
static void | remove_module (void)
static int | show_console (void)
int | unload_module (void)
| Cleanup all module structures, sockets, etc.
static void | update_statusbar (char *msg)
int | usecount (void)
| Provides a usecount.
static void | verboser (const char *stuff, int opos, int replacelast, int complete)

## Variables

static int | cleanupid = -1
static GtkWidget * | cli
static int | clipipe [2]
static GtkWidget * | closew
static pthread_t | console_thread
static char * | dtext = "Asterisk PBX Console (GTK Version)"
static int | inuse = 0
static struct timeval | last
static GtkWidget * | modules
static GtkWidget * | quit
static GtkWidget * | statusbar
static GtkWidget * | verb
static GtkWidget * | window

## Detailed Description

GTK Console monitor -- very kludgy right now.

Definition in file pbx_gtkconsole.c.

## Function Documentation

static void __verboser | ( | const char * | stuff,
|  | int | opos,
|  | int | replacelast,
|  | int | complete |
| ) |  |  | `[static]`

Definition at line 110 of file pbx_gtkconsole.c.

References cleanup(), and last.

Referenced by cliinput(), and verboser().

    00111 {
    00112    char *s2[2];
    00113    struct timeval tv;
    00114    int ms;
    00115    s2[0] = (char *)stuff;
    00116    s2[1] = NULL;
    00117    gtk_clist_freeze(GTK_CLIST(verb));
    00118    if (replacelast)
    00119       gtk_clist_remove(GTK_CLIST(verb), GTK_CLIST(verb)->rows - 1);
    00120    gtk_clist_append(GTK_CLIST(verb), s2);
    00121    if (!ast_tvzero(last)) {
    00122       gdk_threads_leave();
    00123       gettimeofday(&tv, NULL);
    00124       if (cleanupid > -1)
    00125          gtk_timeout_remove(cleanupid);
    00126       ms = ast_tvdiff_ms(tv, last);
    00127       if (ms < 100) {
    00128          /* We just got a message within 100ms, so just schedule an update
    00129             in the near future */
    00130          cleanupid = gtk_timeout_add(200, cleanup, NULL);
    00131       } else {
    00132          cleanup(&cleanupid);
    00133       }
    00134       last = tv;
    00135    } else {
    00136       gettimeofday(&last, NULL);
    00137    }
    00138 }

static int add_mod | ( | const char * | module,
|  | const char * | description,
|  | int | usecount,
|  | const char * | like |
| ) |  |  | `[static]`

Definition at line 278 of file pbx_gtkconsole.c.

References pass.

Referenced by mod_update().

    00279 {
    00280    char use[10];
    00281    char *pass[4];
    00282    int row;
    00283    snprintf(use, sizeof(use), "%d", usecount);
    00284    pass[0] = module;
    00285    pass[1] = description;
    00286    pass[2] = use;
    00287    pass[3] = NULL;
    00288    row = gtk_clist_append(GTK_CLIST(modules), pass);
    00289    gtk_clist_set_row_data(GTK_CLIST(modules), row, module);
    00290    return 0;
    00291 }

static void add_module | ( | void |  | ) | `[static]`

Definition at line 264 of file pbx_gtkconsole.c.

References ast_config_AST_MODULE_DIR, AST_CONFIG_MAX_PATH, and file_ok_sel().

Referenced by show_console().

    00265 {
    00266    char tmp[AST_CONFIG_MAX_PATH];
    00267    GtkWidget *filew;
    00268    snprintf(tmp, sizeof(tmp), "%s/*.so", ast_config_AST_MODULE_DIR);
    00269    filew = gtk_file_selection_new("Load Module");
    00270    gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(filew)->ok_button),
    00271                "clicked", GTK_SIGNAL_FUNC(file_ok_sel), filew);
    00272    gtk_signal_connect_object(GTK_OBJECT (GTK_FILE_SELECTION(filew)->cancel_button),
    00273                "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(filew));
    00274    gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), (char *)tmp);
    00275    gtk_widget_show(filew);
    00276 }

AST_MUTEX_DEFINE_STATIC | ( | verb_lock |  | ) |

static int cleanup | ( | void * | useless | ) | `[static]`

Definition at line 98 of file pbx_gtkconsole.c.

Referenced by __verboser(), and new_odbc_obj().

    00099 {
    00100    gdk_threads_enter();
    00101    gtk_clist_thaw(GTK_CLIST(verb));
    00102    gtk_widget_queue_resize(verb->parent);
    00103    gtk_clist_moveto(GTK_CLIST(verb), GTK_CLIST(verb)->rows - 1, 0, 0, 0);
    00104    cleanupid = -1;
    00105    gdk_threads_leave();
    00106    return 0;
    00107 }

static int cli_activate | ( | void |  | ) | `[static]`

Definition at line 347 of file pbx_gtkconsole.c.

References ast_cli_command(), and TRUE.

Referenced by show_console().

    00348 {
    00349    char buf[256] = "";
    00350    strncpy(buf, gtk_entry_get_text(GTK_ENTRY(cli)), sizeof(buf) - 1);
    00351    gtk_entry_set_text(GTK_ENTRY(cli), "");
    00352    if (strlen(buf)) {
    00353       ast_cli_command(clipipe[1], buf);
    00354    }
    00355    return TRUE;
    00356 }

static void cliinput | ( | void * | data,
|  | int | source,
|  | GdkInputCondition | ic |
| ) |  |  | `[static]`

Definition at line 148 of file pbx_gtkconsole.c.

References __verboser(), n, and offset.

Referenced by show_console().

    00149 {
    00150    static char buf[256];
    00151    static int offset = 0;
    00152    int res;
    00153    char *c;
    00154    char *l;
    00155    char n;
    00156    /* Read as much stuff is there */
    00157    res = read(source, buf + offset, sizeof(buf) - 1 - offset);
    00158    if (res > -1)
    00159       buf[res + offset] = '\0';
    00160    /* make sure we've null terminated whatever we have so far */
    00161    c = buf;
    00162    l = buf;
    00163    while(*c) {
    00164       if (*c == '\n') {
    00165          /* Keep the trailing \n */
    00166          c++;
    00167          n = *c;
    00168          *c = '\0';
    00169          __verboser(l, 0, 0, 1);
    00170          *(c - 1) = '\0';
    00171          *c = n;
    00172          l = c;
    00173       } else
    00174       c++;
    00175    }
    00176    if (strlen(l)) {
    00177       /* We have some left over */
    00178       memmove(buf, l, strlen(l) + 1);
    00179       offset = strlen(buf);
    00180    } else {
    00181       offset = 0;
    00182    }
    00183
    00184 }

static void* consolethread | ( | void * | data | ) | `[static]`

Definition at line 338 of file pbx_gtkconsole.c.

    00339 {
    00340    gtk_widget_show(window);
    00341    gdk_threads_enter();
    00342    gtk_main();
    00343    gdk_threads_leave();
    00344    return NULL;
    00345 }

char* description | ( | void |  | ) |

Provides a description of the module.

Returns:
  a short description of your module

Definition at line 510 of file pbx_gtkconsole.c.

    00511 {
    00512    return dtext;
    00513 }

static void exit_completely | ( | GtkWidget * | widget,
|  | gpointer | data |
| ) |  |  | `[static]`

Definition at line 322 of file pbx_gtkconsole.c.

References ast_cli_command().

Referenced by show_console().

    00323 {
    00324 #if 0
    00325    /* Clever... */
    00326    ast_cli_command(clipipe[1], "quit");
    00327 #else
    00328    kill(getpid(), SIGTERM);
    00329 #endif
    00330 }

static void exit_nicely | ( | GtkWidget * | widget,
|  | gpointer | data |
| ) |  |  | `[static]`

Definition at line 332 of file pbx_gtkconsole.c.

Referenced by show_console().

    00333 {
    00334    fflush(stdout);
    00335    gtk_widget_destroy(window);
    00336 }

static void exit_now | ( | GtkWidget * | widget,
|  | gpointer | data |
| ) |  |  | `[static]`

Definition at line 309 of file pbx_gtkconsole.c.

References ast_loader_unregister(), ast_unload_resource(), ast_unregister_verbose(), ast_update_use_count(), ast_verbose(), mod_update(), option_verbose, VERBOSE_PREFIX_2, and verboser.

Referenced by show_console().

    00310 {
    00311    ast_loader_unregister(mod_update);
    00312    gtk_main_quit();
    00313    inuse--;
    00314    ast_update_use_count();
    00315    ast_unregister_verbose(verboser);
    00316    ast_unload_resource("pbx_gtkconsole", 0);
    00317    if (option_verbose > 1)
    00318       ast_verbose(VERBOSE_PREFIX_2 "GTK Console Monitor Exiting\n");
    00319    /* XXX Trying to quit after calling this makes asterisk segfault XXX */
    00320 }

static void file_ok_sel | ( | GtkWidget * | w,
|  | GtkFileSelection * | fs |
| ) |  |  | `[static]`

Definition at line 244 of file pbx_gtkconsole.c.

References ast_config_AST_MODULE_DIR, AST_CONFIG_MAX_PATH, ast_load_resource(), and update_statusbar().

Referenced by add_module().

    00245 {
    00246    char tmp[AST_CONFIG_MAX_PATH];
    00247    char *module = gtk_file_selection_get_filename(fs);
    00248    char buf[256];
    00249    snprintf(tmp, sizeof(tmp), "%s/", ast_config_AST_MODULE_DIR);
    00250    if (!strncmp(module, (char *)tmp, strlen(tmp)))
    00251       module += strlen(tmp);
    00252    gdk_threads_leave();
    00253    if (ast_load_resource(module)) {
    00254       snprintf(buf, sizeof(buf), "Error loading module '%s'.", module);
    00255       update_statusbar(buf);
    00256    } else {
    00257       snprintf(buf, sizeof(buf), "Module '%s' loaded", module);
    00258       update_statusbar(buf);
    00259    }
    00260    gdk_threads_enter();
    00261    gtk_widget_destroy(GTK_WIDGET(fs));
    00262 }

char* key | ( | void |  | ) |

Returns the ASTERISK_GPL_KEY.

This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:

     char *key(void) {
             return ASTERISK_GPL_KEY;
     }

Returns:
  ASTERISK_GPL_KEY

Definition at line 515 of file pbx_gtkconsole.c.

References ASTERISK_GPL_KEY.

    00516 {
    00517    return ASTERISK_GPL_KEY;
    00518 }

int load_module | ( | void |  | ) |

Initialize the module.

This function is called at module load time. Put all code in here that needs to set up your module's hardware, software, registrations, etc.

Returns:
  This function should return 0 on success and non-zero on failure. If the module is not loaded successfully, Asterisk will call its unload_module() function.

Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.

Returns:
  int Always 0.

TE STUFF END

Definition at line 481 of file pbx_gtkconsole.c.

References ast_log(), ast_update_use_count(), ast_verbose(), LOG_DEBUG, LOG_WARNING, option_debug, option_verbose, show_console(), and VERBOSE_PREFIX_2.

    00482 {
    00483    if (pipe(clipipe)) {
    00484       ast_log(LOG_WARNING, "Unable to create CLI pipe\n");
    00485       return -1;
    00486    }
    00487    g_thread_init(NULL);
    00488    if (gtk_init_check(NULL, NULL))  {
    00489       if (!show_console()) {
    00490          inuse++;
    00491          ast_update_use_count();
    00492          if (option_verbose > 1)
    00493             ast_verbose( VERBOSE_PREFIX_2 "Launched GTK Console monitor\n");
    00494       } else
    00495          ast_log(LOG_WARNING, "Unable to start GTK console\n");
    00496    } else {
    00497       if (option_debug)
    00498          ast_log(LOG_DEBUG, "Unable to start GTK console monitor -- ignoring\n");
    00499       if (option_verbose > 1)
    00500          ast_verbose( VERBOSE_PREFIX_2 "GTK is not available -- skipping monitor\n");
    00501    }
    00502    return 0;
    00503 }

static int mod_update | ( | void |  | ) | `[static]`

Definition at line 293 of file pbx_gtkconsole.c.

References add_mod(), and ast_update_module_list().

Referenced by exit_now(), and show_console().

    00294 {
    00295    char *module= NULL;
    00296    /* Update the mod stuff */
    00297    if (GTK_CLIST(modules)->selection) {
    00298       module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
    00299    }
    00300    gtk_clist_freeze(GTK_CLIST(modules));
    00301    gtk_clist_clear(GTK_CLIST(modules));
    00302    ast_update_module_list(add_mod, NULL);
    00303    if (module)
    00304       gtk_clist_select_row(GTK_CLIST(modules), gtk_clist_find_row_from_data(GTK_CLIST(modules), module), -1);
    00305    gtk_clist_thaw(GTK_CLIST(modules));
    00306    return 1;
    00307 }

static void reload_module | ( | void |  | ) | `[static]`

Definition at line 206 of file pbx_gtkconsole.c.

References ast_load_resource(), ast_unload_resource(), free, strdup, and update_statusbar().

Referenced by show_console().

    00207 {
    00208    int res, x;
    00209    char *module;
    00210    char buf[256];
    00211    if (GTK_CLIST(modules)->selection) {
    00212       module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
    00213       module = strdup(module);
    00214       if (module) {
    00215          gdk_threads_leave();
    00216          res = ast_unload_resource(module, 0);
    00217          gdk_threads_enter();
    00218          if (res) {
    00219             snprintf(buf, sizeof(buf), "Module '%s' is in use", module);
    00220             update_statusbar(buf);
    00221          } else {
    00222             gdk_threads_leave();
    00223             res = ast_load_resource(module);
    00224             gdk_threads_enter();
    00225             if (res) {
    00226                snprintf(buf, sizeof(buf), "Error reloading module '%s'", module);
    00227             } else {
    00228                snprintf(buf, sizeof(buf), "Module '%s' reloaded", module);
    00229             }
    00230             for (x=0; x < GTK_CLIST(modules)->rows; x++) {
    00231                if (!strcmp((char *)gtk_clist_get_row_data(GTK_CLIST(modules), x), module)) {
    00232                   gtk_clist_select_row(GTK_CLIST(modules), x, -1);
    00233                   break;
    00234                }
    00235             }
    00236             update_statusbar(buf);
    00237
    00238          }
    00239          free(module);
    00240       }
    00241    }
    00242 }

static void remove_module | ( | void |  | ) | `[static]`

Definition at line 187 of file pbx_gtkconsole.c.

References ast_unload_resource(), and update_statusbar().

Referenced by show_console().

    00188 {
    00189    int res;
    00190    char *module;
    00191    char buf[256];
    00192    if (GTK_CLIST(modules)->selection) {
    00193       module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
    00194       gdk_threads_leave();
    00195       res = ast_unload_resource(module, 0);
    00196       gdk_threads_enter();
    00197       if (res) {
    00198          snprintf(buf, sizeof(buf), "Module '%s' is in use", module);
    00199          update_statusbar(buf);
    00200       } else {
    00201          snprintf(buf, sizeof(buf), "Module '%s' removed", module);
    00202          update_statusbar(buf);
    00203       }
    00204    }
    00205 }

static int show_console | ( | void |  | ) | `[static]`

Definition at line 358 of file pbx_gtkconsole.c.

References add_module(), ast_loader_register(), ast_pthread_create, ast_register_verbose(), cli_activate(), cliinput(), consolethread, exit_completely(), exit_nicely(), exit_now(), FALSE, mod_update(), reload_module(), remove_module(), TRUE, update_statusbar(), and verboser.

Referenced by load_module().

    00359 {
    00360    GtkWidget *hbox;
    00361    GtkWidget *wbox;
    00362    GtkWidget *notebook;
    00363    GtkWidget *sw;
    00364    GtkWidget *bbox, *hbbox, *add, *removew, *reloadw;
    00365    char *modtitles[3] = { "Module", "Description", "Use Count" };
    00366    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    00367
    00368    statusbar = gtk_statusbar_new();
    00369    gtk_widget_show(statusbar);
    00370
    00371    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
    00372          GTK_SIGNAL_FUNC (exit_nicely), window);
    00373    gtk_signal_connect(GTK_OBJECT(window), "destroy",
    00374          GTK_SIGNAL_FUNC (exit_now), window);
    00375    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    00376
    00377    quit = gtk_button_new_with_label("Quit Asterisk");
    00378    gtk_signal_connect(GTK_OBJECT(quit), "clicked",
    00379          GTK_SIGNAL_FUNC (exit_completely), window);
    00380    gtk_widget_show(quit);
    00381
    00382    closew = gtk_button_new_with_label("Close Window");
    00383    gtk_signal_connect(GTK_OBJECT(closew), "clicked",
    00384          GTK_SIGNAL_FUNC (exit_nicely), window);
    00385    gtk_widget_show(closew);
    00386
    00387    notebook = gtk_notebook_new();
    00388    verb = gtk_clist_new(1);
    00389    gtk_clist_columns_autosize(GTK_CLIST(verb));
    00390    sw = gtk_scrolled_window_new(NULL, NULL);
    00391    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
    00392    gtk_container_add(GTK_CONTAINER(sw), verb);
    00393    gtk_widget_show(verb);
    00394    gtk_widget_show(sw);
    00395    gtk_widget_set_usize(verb, 640, 400);
    00396    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, gtk_label_new("Verbose Status"));
    00397
    00398
    00399    modules = gtk_clist_new_with_titles(3, modtitles);
    00400    gtk_clist_columns_autosize(GTK_CLIST(modules));
    00401    gtk_clist_set_column_auto_resize(GTK_CLIST(modules), 0, TRUE);
    00402    gtk_clist_set_column_auto_resize(GTK_CLIST(modules), 1, TRUE);
    00403    gtk_clist_set_column_auto_resize(GTK_CLIST(modules), 2, TRUE);
    00404    gtk_clist_set_sort_column(GTK_CLIST(modules), 0);
    00405    gtk_clist_set_auto_sort(GTK_CLIST(modules), TRUE);
    00406    gtk_clist_column_titles_passive(GTK_CLIST(modules));
    00407    sw = gtk_scrolled_window_new(NULL, NULL);
    00408    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
    00409    gtk_container_add(GTK_CONTAINER(sw), modules);
    00410    gtk_clist_set_selection_mode(GTK_CLIST(modules), GTK_SELECTION_BROWSE);
    00411    gtk_widget_show(modules);
    00412    gtk_widget_show(sw);
    00413
    00414    add = gtk_button_new_with_label("Load...");
    00415    gtk_widget_show(add);
    00416    removew = gtk_button_new_with_label("Unload");
    00417    gtk_widget_show(removew);
    00418    reloadw = gtk_button_new_with_label("Reload");
    00419    gtk_widget_show(reloadw);
    00420    gtk_signal_connect(GTK_OBJECT(removew), "clicked",
    00421          GTK_SIGNAL_FUNC (remove_module), window);
    00422    gtk_signal_connect(GTK_OBJECT(add), "clicked",
    00423          GTK_SIGNAL_FUNC (add_module), window);
    00424    gtk_signal_connect(GTK_OBJECT(reloadw), "clicked",
    00425          GTK_SIGNAL_FUNC (reload_module), window);
    00426
    00427    bbox = gtk_vbox_new(FALSE, 5);
    00428    gtk_widget_show(bbox);
    00429
    00430    gtk_widget_set_usize(bbox, 100, -1);
    00431    gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
    00432    gtk_box_pack_start(GTK_BOX(bbox), removew, FALSE, FALSE, 5);
    00433    gtk_box_pack_start(GTK_BOX(bbox), reloadw, FALSE, FALSE, 5);
    00434
    00435    hbbox = gtk_hbox_new(FALSE, 5);
    00436    gtk_widget_show(hbbox);
    00437
    00438    gtk_box_pack_start(GTK_BOX(hbbox), sw, TRUE, TRUE, 5);
    00439    gtk_box_pack_start(GTK_BOX(hbbox), bbox, FALSE, FALSE, 5);
    00440
    00441    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), hbbox, gtk_label_new("Module Information"));
    00442
    00443    gtk_widget_show(notebook);
    00444
    00445    wbox = gtk_hbox_new(FALSE, 5);
    00446    gtk_widget_show(wbox);
    00447    gtk_box_pack_end(GTK_BOX(wbox), quit, FALSE, FALSE, 5);
    00448    gtk_box_pack_end(GTK_BOX(wbox), closew, FALSE, FALSE, 5);
    00449
    00450    hbox = gtk_vbox_new(FALSE, 0);
    00451    gtk_widget_show(hbox);
    00452
    00453    /* Command line */
    00454    cli = gtk_entry_new();
    00455    gtk_widget_show(cli);
    00456
    00457    gtk_signal_connect(GTK_OBJECT(cli), "activate",
    00458          GTK_SIGNAL_FUNC (cli_activate), NULL);
    00459
    00460    gtk_box_pack_start(GTK_BOX(hbox), notebook, TRUE, TRUE, 5);
    00461    gtk_box_pack_start(GTK_BOX(hbox), wbox, FALSE, FALSE, 5);
    00462    gtk_box_pack_start(GTK_BOX(hbox), cli, FALSE, FALSE, 0);
    00463    gtk_box_pack_start(GTK_BOX(hbox), statusbar, FALSE, FALSE, 0);
    00464    gtk_container_add(GTK_CONTAINER(window), hbox);
    00465    gtk_window_set_title(GTK_WINDOW(window), "Asterisk Console");
    00466    gtk_widget_grab_focus(cli);
    00467    ast_pthread_create(&console_thread, NULL, consolethread, NULL);
    00468    /* XXX Okay, seriously fix me! XXX */
    00469    usleep(100000);
    00470    ast_register_verbose(verboser);
    00471    gtk_clist_freeze(GTK_CLIST(verb));
    00472    ast_loader_register(mod_update);
    00473    gtk_clist_thaw(GTK_CLIST(verb));
    00474    gdk_input_add(clipipe[0], GDK_INPUT_READ, cliinput, NULL);
    00475    mod_update();
    00476    update_statusbar("Asterisk Console Ready");
    00477    return 0;
    00478 }

int unload_module | ( | void |  | ) |

Cleanup all module structures, sockets, etc.

This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).

Returns:
  Zero on success, or non-zero on error.

Standard module functions ...

Definition at line 84 of file pbx_gtkconsole.c.

    00085 {
    00086    if (inuse) {
    00087       /* Kill off the main thread */
    00088       pthread_cancel(console_thread);
    00089       gdk_threads_enter();
    00090       gtk_widget_destroy(window);
    00091       gdk_threads_leave();
    00092       close(clipipe[0]);
    00093       close(clipipe[1]);
    00094    }
    00095    return 0;
    00096 }

static void update_statusbar | ( | char * | msg | ) | `[static]`

Definition at line 78 of file pbx_gtkconsole.c.

Referenced by file_ok_sel(), reload_module(), remove_module(), and show_console().

    00079 {
    00080    gtk_statusbar_pop(GTK_STATUSBAR(statusbar), 1);
    00081    gtk_statusbar_push(GTK_STATUSBAR(statusbar), 1, msg);
    00082 }

int usecount | ( | void |  | ) |

Provides a usecount.

This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.

Returns:
  The module's usecount.

Definition at line 505 of file pbx_gtkconsole.c.

    00506 {
    00507    return inuse;
    00508 }

static void verboser | ( | const char * | stuff,
|  | int | opos,
|  | int | replacelast,
|  | int | complete |
| ) |  |  | `[static]`

Definition at line 140 of file pbx_gtkconsole.c.

References __verboser(), ast_mutex_lock(), and ast_mutex_unlock().

    00141 {
    00142    ast_mutex_lock(&verb_lock);
    00143    /* Lock appropriately if we're really being called in verbose mode */
    00144    __verboser(stuff, opos, replacelast, complete);
    00145    ast_mutex_unlock(&verb_lock);
    00146 }

## Variable Documentation

int cleanupid = -1`[static]`

Definition at line 64 of file pbx_gtkconsole.c.

GtkWidget* cli`[static]`

Definition at line 74 of file pbx_gtkconsole.c.

int clipipe[2]`[static]`

Definition at line 63 of file pbx_gtkconsole.c.

GtkWidget* closew`[static]`

Definition at line 70 of file pbx_gtkconsole.c.

pthread_t console_thread`[static]`

Definition at line 60 of file pbx_gtkconsole.c.

char* dtext = "Asterisk PBX Console (GTK Version)"`[static]`

Definition at line 66 of file pbx_gtkconsole.c.

int inuse = 0`[static]`

Definition at line 62 of file pbx_gtkconsole.c.

Referenced by ast_extension_state2(), chanavail_exec(), update_call_counter(), and vpb_bridge().

struct timeval last`[static]`

Definition at line 76 of file pbx_gtkconsole.c.

GtkWidget* modules`[static]`

Definition at line 72 of file pbx_gtkconsole.c.

GtkWidget* quit`[static]`

Definition at line 69 of file pbx_gtkconsole.c.

GtkWidget* statusbar`[static]`

Definition at line 73 of file pbx_gtkconsole.c.

GtkWidget* verb`[static]`

Definition at line 71 of file pbx_gtkconsole.c.

GtkWidget* window`[static]`

Definition at line 68 of file pbx_gtkconsole.c.