/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-2009 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
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
+ You should have received a copy of the GNU Affero 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.
- Bacula® is a registered trademark of John Walker.
+ Bacula® is a registered trademark of Kern Sibbald.
The licensor of Bacula is the Free Software Foundation Europe
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
#include "bacula.h"
#include "tray-monitor.h"
-#include "eggstatusicon.h"
-
#include "generic.xpm"
#define TRAY_DEBUG_MEMORY 0
int authenticate_director(JCR *jcr, MONITOR *monitor, DIRRES *director);
int authenticate_file_daemon(JCR *jcr, MONITOR *monitor, CLIENT* client);
int authenticate_storage_daemon(JCR *jcr, MONITOR *monitor, STORE* store);
+extern bool parse_tmon_config(CONFIG *config, const char *configfile, int exit_code);
/* Dummy functions */
int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
static int fullitem = 0; //Item to be display in detailled status window
static int lastupdated = -1; //Last item updated
static monitoritem items[32];
+static CONFIG *config;
/* Data received from DIR/FD/SD */
static char OKqstatus[] = "%c000 OK .status\n";
static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
static guint timerTag;
-static EggStatusIcon *mTrayIcon;
+static GtkStatusIcon *mTrayIcon;
static GtkWidget *mTrayMenu;
static GtkWidget *window;
static GtkWidget *textview;
static GtkTextBuffer *buffer;
static GtkWidget *timeoutspinner;
+static GtkWidget *scrolledWindow;
char** xpm_generic_var;
static gboolean blinkstate = TRUE;
"\nVersion: %s (%s) %s %s %s\n\n"
"Usage: tray-monitor [-c config_file] [-d debug_level]\n"
" -c <file> set configuration file to file\n"
-" -dnn set debug level to nn\n"
+" -d <nn> set debug level to <nn>\n"
+" -dt print timestamp in debug output\n"
" -t test - read configuration and exit\n"
" -? print this message.\n"
"\n"), 2004, VERSION, BDATE, HOST_OS, DISTNAME, DISTVER);
}
static GtkWidget *new_image_button(const gchar *stock_id,
- const gchar *label_text) {
+ const gchar *label_text)
+{
GtkWidget *button;
GtkWidget *box;
GtkWidget *label;
break;
case 'd':
- debug_level = atoi(optarg);
- if (debug_level <= 0) {
- debug_level = 1;
+ if (*optarg == 't') {
+ dbg_timestamp = true;
+ } else {
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
}
break;
configfile = bstrdup(CONFIG_FILE);
}
- parse_config(configfile);
+ config = new_config_parser();
+ parse_tmon_config(config, configfile, M_ERROR_TERM);
LockRes();
nitems = 0;
}
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_xpm_data(generateXPM(warn, warn));
- // This should be ideally replaced by a completely libpr0n-based icon rendering.
- mTrayIcon = egg_status_icon_new_from_pixbuf(pixbuf);
+
+ mTrayIcon = gtk_status_icon_new_from_pixbuf(pixbuf);
+ gtk_status_icon_set_tooltip(mTrayIcon, _("Bacula daemon status monitor"));
g_signal_connect(G_OBJECT(mTrayIcon), "activate", G_CALLBACK(TrayIconActivate), NULL);
g_signal_connect(G_OBJECT(mTrayIcon), "popup-menu", G_CALLBACK(TrayIconPopupMenu), NULL);
g_object_unref(G_OBJECT(pixbuf));
timerTag = g_timeout_add( 1000*monitor->RefreshInterval/nitems, fd_read, NULL );
- g_timeout_add( 1000, blink, NULL );
+ g_timeout_add( 1000, blink, NULL);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
}
gtk_box_pack_start(GTK_BOX(vbox), daemon_table, FALSE, FALSE, 0);
-
+
textview = gtk_text_view_new();
+ scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER (scrolledWindow), textview);
+
buffer = gtk_text_buffer_new(NULL);
gtk_text_buffer_set_text(buffer, "", -1);
gtk_text_view_set_buffer(GTK_TEXT_VIEW(textview), buffer);
- gtk_box_pack_start(GTK_BOX(vbox), textview, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), scrolledWindow, TRUE, TRUE, 0);
GtkWidget* hbox = gtk_hbox_new(FALSE, 10);
break;
}
//writecmd(&items[i], "quit");
- bnet_sig(items[i].D_sock, BNET_TERMINATE); /* send EOF */
- bnet_close(items[i].D_sock);
+ items[i].D_sock->signal(BNET_TERMINATE); /* send EOF */
+ items[i].D_sock->close();
}
}
gtk_object_destroy(GTK_OBJECT(window));
gtk_object_destroy(GTK_OBJECT(mTrayMenu));
+ config->free_resources();
+ free(config);
+ config = NULL;
term_msg();
#if TRAY_DEBUG_MEMORY
return 0;
}
-static void MonitorAbout(GtkWidget *widget, gpointer data) {
+static void MonitorAbout(GtkWidget *widget, gpointer data)
+{
#if HAVE_GTK_2_4
GtkWidget* about = gtk_message_dialog_new_with_markup(GTK_WINDOW(window),GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
"<span size='x-large' weight='bold'>%s</span>\n\n"
gtk_widget_destroy(about);
}
-static void MonitorRefresh(GtkWidget *widget, gpointer data) {
+static void MonitorRefresh(GtkWidget *widget, gpointer data)
+{
for (int i = 0; i < nitems; i++) {
fd_read(NULL);
}
}
-static gboolean delete_event( GtkWidget *widget,
- GdkEvent *event,
- gpointer data ) {
+static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
gtk_widget_hide(window);
return TRUE; /* do not destroy the window */
}
-static void TrayIconActivate(GtkWidget *widget, gpointer data) {
- gtk_widget_show(window);
+/*
+ * Come here when the user right clicks on the icon.
+ * We display the icon menu.
+ */
+static void TrayIconActivate(GtkWidget *widget, gpointer data)
+{
+ gtk_widget_show(window);
}
-static void TrayIconPopupMenu(unsigned int activateTime, unsigned int button) {
- gtk_menu_popup(GTK_MENU(mTrayMenu), NULL, NULL, NULL, NULL, 1, 0);
- gtk_widget_show_all(mTrayMenu);
+/*
+ * Come here when the user left clicks on the icon.
+ * We popup the status window.
+ */
+static void TrayIconPopupMenu(unsigned int activateTime, unsigned int button)
+{
+ gtk_menu_popup(GTK_MENU(mTrayMenu), NULL, NULL, NULL, NULL, button,
+ gtk_get_current_event_time());
+ gtk_widget_show(mTrayMenu);
}
-static void TrayIconExit(unsigned int activateTime, unsigned int button) {
+static void TrayIconExit(unsigned int activateTime, unsigned int button)
+{
gtk_main_quit();
}
-static void IntervalChanged(GtkWidget *widget, gpointer data) {
+static void IntervalChanged(GtkWidget *widget, gpointer data)
+{
g_source_remove(timerTag);
timerTag = g_timeout_add(
(guint)(
), fd_read, NULL );
}
-static void DaemonChanged(GtkWidget *widget, monitoritem* data) {
+static void DaemonChanged(GtkWidget *widget, monitoritem* data)
+{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
fullitem = -1;
for (int i = 0; i < nitems; i++) {
writecmd(item, command);
while(1) {
- if ((stat = bnet_recv(item->D_sock)) >= 0) {
+ if ((stat = item->D_sock->recv()) >= 0) {
*list = g_slist_append(*list, g_string_new(item->D_sock->msg));
}
else if (stat == BNET_SIGNAL) {
//fprintf(stderr, "<< EOD >>\n");
return 1;
}
- else if (item->D_sock->msglen == BNET_PROMPT) {
+ else if (item->D_sock->msglen == BNET_SUB_PROMPT) {
//fprintf(stderr, "<< PROMPT >>\n");
- *list = g_slist_append(*list, g_string_new(_("<< Error: BNET_PROMPT signal received. >>\n")));
+ *list = g_slist_append(*list, g_string_new(_("<< Error: BNET_SUB_PROMPT signal received. >>\n")));
return 0;
}
else if (item->D_sock->msglen == BNET_HEARTBEAT) {
- bnet_sig(item->D_sock, BNET_HB_RESPONSE);
+ item->D_sock->signal(BNET_HB_RESPONSE);
*list = g_slist_append(*list, g_string_new(_("<< Heartbeat signal received, answered. >>\n")));
}
else {
return 0;
}
- if (is_bnet_stop(item->D_sock)) {
+ if (item->D_sock->is_stop()) {
g_string_append_printf(str, _("<STOP>\n"));
item->D_sock = NULL;
item->state = error;
if (item->D_sock) {
item->D_sock->msglen = strlen(command);
pm_strcpy(&item->D_sock->msg, command);
- bnet_send(item->D_sock);
+ item->D_sock->send();
}
}
bvsnprintf(buf, sizeof(buf), (char *)fmt, arg_ptr);
va_end(arg_ptr);
- fprintf(stderr, buf);
+ fprintf(stderr, "%s", buf);
- egg_tray_icon_send_message(egg_status_icon_get_tray_icon(mTrayIcon), 5000, (const char*)&buf, -1);
+// gtk_tray_icon_send_message(gtk_status_icon_get_tray_icon(mTrayIcon), 5000, (const char*)&buf, -1);
}
void changeStatusMessage(monitoritem* item, const char *fmt,...) {
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_xpm_data(xpm);
if (item == NULL) {
- egg_status_icon_set_from_pixbuf(mTrayIcon, pixbuf);
+ gtk_status_icon_set_from_pixbuf(mTrayIcon, pixbuf);
gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
}
else {
}
/* Note: result should not be stored, as it is a reference to xpm_generic_var */
-static const char** generateXPM(stateenum newstate, stateenum oldstate) {
+static const char** generateXPM(stateenum newstate, stateenum oldstate)
+{
char* address = &xpm_generic_var[xpm_generic_first_color][xpm_generic_column];
switch (newstate) {
case error: