use daemon()
[lttv.git] / ltt / branches / poly / lttv / modules / gui / tracecontrol / tracecontrol.c
CommitLineData
e7c8534e 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 Mathieu Desnoyers
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
23#include <glib.h>
24#include <string.h>
25#include <gtk/gtk.h>
26#include <gdk/gdk.h>
27#include <gdk/gdkkeysyms.h>
28
29#include <lttv/lttv.h>
30#include <lttv/module.h>
31#include <lttv/hook.h>
e7c8534e 32
33#include <lttvwindow/lttvwindow.h>
34#include <lttvwindow/lttvwindowtraces.h>
35
36#include "hTraceControlInsert.xpm"
381229ee 37#include "TraceControlStart.xpm"
38#include "TraceControlPause.xpm"
39#include "TraceControlStop.xpm"
e7c8534e 40
77ef407f 41#include <sys/types.h>
42#include <unistd.h>
43#include <stdlib.h>
44
f6f6abf0 45#define MAX_ARGS_LEN PATH_MAX * 10
e7c8534e 46
47GSList *g_control_list = NULL ;
48
49/*! \file lttv/modules/gui/tracecontrol/tracecontrol.c
50 * \brief Graphic trace start/stop control interface.
51 *
52 * This plugin interacts with lttctl to start/stop tracing. It needs to take the
53 * root password to be able to interact with lttctl.
54 *
55 */
56
57typedef struct _ControlData ControlData;
58
59/*
60 * Prototypes
61 */
62GtkWidget *guicontrol_get_widget(ControlData *tcd);
63ControlData *gui_control(Tab *tab);
64void gui_control_destructor(ControlData *tcd);
65GtkWidget* h_guicontrol(Tab *tab);
66void control_destroy_walk(gpointer data, gpointer user_data);
67
68/*
69 * Callback functions
70 */
71
77ef407f 72static void start_clicked (GtkButton *button, gpointer user_data);
73static void pause_clicked (GtkButton *button, gpointer user_data);
74static void stop_clicked (GtkButton *button, gpointer user_data);
e7c8534e 75
76/**
77 * @struct _ControlData
78 *
77ef407f 79 * @brief Main structure of gui control
e7c8534e 80 */
81struct _ControlData {
82 Tab *tab; /**< current tab of module */
83
77ef407f 84 GtkWidget *window; /**< window */
e7c8534e 85
77ef407f 86 GtkWidget *main_box; /**< main container */
87 GtkWidget *start_button;
88 GtkWidget *pause_button;
89 GtkWidget *stop_button;
90 GtkWidget *username_label;
91 GtkWidget *username_entry;
92 GtkWidget *password_label;
93 GtkWidget *password_entry;
94 GtkWidget *channel_dir_label;
95 GtkWidget *channel_dir_entry;
96 GtkWidget *trace_dir_label;
97 GtkWidget *trace_dir_entry;
98 GtkWidget *trace_name_label;
99 GtkWidget *trace_name_entry;
100 GtkWidget *trace_mode_label;
101 GtkWidget *trace_mode_combo;
102 GtkWidget *start_daemon_label;
103 GtkWidget *start_daemon_check;
104 GtkWidget *optional_label;
105 GtkWidget *subbuf_size_label;
106 GtkWidget *subbuf_size_entry;
107 GtkWidget *subbuf_num_label;
108 GtkWidget *subbuf_num_entry;
109 GtkWidget *lttctl_path_label;
110 GtkWidget *lttctl_path_entry;
111 GtkWidget *lttd_path_label;
112 GtkWidget *lttd_path_entry;
113 GtkWidget *fac_path_label;
114 GtkWidget *fac_path_entry;
e7c8534e 115};
116
117/**
118 * @fn GtkWidget* guicontrol_get_widget(ControlData*)
119 *
120 * This function returns the current main widget
121 * used by this module
122 * @param tcd the module struct
123 * @return The main widget
124 */
125GtkWidget*
126guicontrol_get_widget(ControlData *tcd)
127{
77ef407f 128 return tcd->window;
e7c8534e 129}
130
131/**
132 * @fn ControlData* gui_control(Tab*)
133 *
134 * Constructor is used to create ControlData data structure.
135 * @param tab The tab structure used by the widget
136 * @return The Filter viewer data created.
137 */
138ControlData*
139gui_control(Tab *tab)
140{
141 g_debug("filter::gui_control()");
142
143 unsigned i;
144 GtkCellRenderer *renderer;
145 GtkTreeViewColumn *column;
146
147 ControlData* tcd = g_new(ControlData,1);
148
149 tcd->tab = tab;
150
77ef407f 151 tcd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
152 gtk_window_set_title(GTK_WINDOW(tcd->window), "LTTng Trace Control");
e7c8534e 153 /*
154 * Initiating GtkTable layout
155 * starts with 2 rows and 5 columns and
156 * expands when expressions added
157 */
77ef407f 158 tcd->main_box = gtk_table_new(14,7,FALSE);
159 gtk_table_set_row_spacings(GTK_TABLE(tcd->main_box),5);
160 gtk_table_set_col_spacings(GTK_TABLE(tcd->main_box),5);
e7c8534e 161
77ef407f 162 gtk_container_add(GTK_CONTAINER(tcd->window), GTK_WIDGET(tcd->main_box));
e7c8534e 163
381229ee 164 /*
165 * start/pause/stop buttons
166 */
167 GdkPixbuf *pixbuf;
168 GtkWidget *image;
169 pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStart_xpm);
170 image = gtk_image_new_from_pixbuf(pixbuf);
77ef407f 171 tcd->start_button = gtk_button_new_with_label("start");
172 gtk_button_set_image(GTK_BUTTON(tcd->start_button), image);
173 gtk_button_set_alignment(GTK_BUTTON(tcd->start_button), 0.0, 0.0);
174 gtk_widget_show (tcd->start_button);
175 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_button,6,7,0,1,GTK_FILL,GTK_FILL,2,2);
381229ee 176
177 pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm);
178 image = gtk_image_new_from_pixbuf(pixbuf);
77ef407f 179 tcd->pause_button = gtk_button_new_with_label("pause");
180 gtk_button_set_image(GTK_BUTTON(tcd->pause_button), image);
181 gtk_button_set_alignment(GTK_BUTTON(tcd->pause_button), 0.0, 0.0);
182 gtk_widget_show (tcd->pause_button);
183 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->pause_button,6,7,1,2,GTK_FILL,GTK_FILL,2,2);
381229ee 184
185 pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm);
186 image = gtk_image_new_from_pixbuf(pixbuf);
77ef407f 187 tcd->stop_button = gtk_button_new_with_label("stop");
188 gtk_button_set_image(GTK_BUTTON(tcd->stop_button), image);
189 gtk_button_set_alignment(GTK_BUTTON(tcd->stop_button), 0.0, 0.0);
190 gtk_widget_show (tcd->stop_button);
191 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->stop_button,6,7,2,3,GTK_FILL,GTK_FILL,2,2);
381229ee 192
e7c8534e 193 /*
194 * First half of the filter window
195 * - textual entry of filter expression
196 * - processing button
197 */
77ef407f 198 tcd->username_label = gtk_label_new("Username:");
199 gtk_widget_show (tcd->username_label);
200 tcd->username_entry = gtk_entry_new();
201 gtk_entry_set_text(GTK_ENTRY(tcd->username_entry),"root");
202 gtk_widget_show (tcd->username_entry);
203 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->username_label,0,2,0,1,GTK_FILL,GTK_FILL,2,2);
204 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->username_entry,2,6,0,1,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
205
206
207
208 tcd->password_label = gtk_label_new("Password:");
209 gtk_widget_show (tcd->password_label);
210 tcd->password_entry = gtk_entry_new();
211 gtk_entry_set_visibility(GTK_ENTRY(tcd->password_entry), FALSE);
212 gtk_widget_show (tcd->password_entry);
213 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->password_label,0,2,1,2,GTK_FILL,GTK_FILL,2,2);
214 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->password_entry,2,6,1,2,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
215
216
217 tcd->channel_dir_label = gtk_label_new("Channel directory:");
218 gtk_widget_show (tcd->channel_dir_label);
219 tcd->channel_dir_entry = gtk_entry_new();
220 gtk_entry_set_text(GTK_ENTRY(tcd->channel_dir_entry),"/mnt/relayfs/ltt");
221 gtk_widget_show (tcd->channel_dir_entry);
222 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->channel_dir_label,0,2,2,3,GTK_FILL,GTK_FILL,2,2);
223 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->channel_dir_entry,2,6,2,3,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
224
225 tcd->trace_dir_label = gtk_label_new("Trace directory:");
226 gtk_widget_show (tcd->trace_dir_label);
227 tcd->trace_dir_entry = gtk_entry_new();
228 gtk_entry_set_text(GTK_ENTRY(tcd->trace_dir_entry),"/tmp/trace1");
229 gtk_widget_show (tcd->trace_dir_entry);
230 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_dir_label,0,2,3,4,GTK_FILL,GTK_FILL,2,2);
231 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_dir_entry,2,6,3,4,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
232
233 tcd->trace_name_label = gtk_label_new("Trace name:");
234 gtk_widget_show (tcd->trace_name_label);
235 tcd->trace_name_entry = gtk_entry_new();
236 gtk_entry_set_text(GTK_ENTRY(tcd->trace_name_entry),"trace");
237 gtk_widget_show (tcd->trace_name_entry);
238 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_name_label,0,2,4,5,GTK_FILL,GTK_FILL,2,2);
239 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_name_entry,2,6,4,5,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
240
241 tcd->trace_mode_label = gtk_label_new("Trace mode ");
242 gtk_widget_show (tcd->trace_mode_label);
243 tcd->trace_mode_combo = gtk_combo_box_new_text();
244 gtk_combo_box_append_text(GTK_COMBO_BOX(tcd->trace_mode_combo),
381229ee 245 "normal");
77ef407f 246 gtk_combo_box_append_text(GTK_COMBO_BOX(tcd->trace_mode_combo),
381229ee 247 "flight recorder");
77ef407f 248 gtk_combo_box_set_active(GTK_COMBO_BOX(tcd->trace_mode_combo), 0);
249 gtk_widget_show (tcd->trace_mode_combo);
250 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_mode_label,0,2,5,6,GTK_FILL,GTK_FILL,2,2);
251 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_mode_combo,2,6,5,6,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
252
253 tcd->start_daemon_label = gtk_label_new("Start daemon ");
254 gtk_widget_show (tcd->start_daemon_label);
255 tcd->start_daemon_check = gtk_check_button_new();
256 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tcd->start_daemon_check), TRUE);
257 gtk_widget_show (tcd->start_daemon_check);
258 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_daemon_label,0,2,6,7,GTK_FILL,GTK_FILL,2,2);
259 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_daemon_check,2,6,6,7,GTK_FILL,GTK_FILL,0,0);
260
261 tcd->optional_label = gtk_label_new("Optional fields ");
262 gtk_widget_show (tcd->optional_label);
263 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->optional_label,0,6,7,8,GTK_FILL,GTK_FILL,2,2);
264
265 tcd->subbuf_size_label = gtk_label_new("Subbuffer size:");
266 gtk_widget_show (tcd->subbuf_size_label);
267 tcd->subbuf_size_entry = gtk_entry_new();
268 gtk_widget_show (tcd->subbuf_size_entry);
269 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_label,0,2,8,9,GTK_FILL,GTK_FILL,2,2);
270 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_entry,2,6,8,9,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
271
272 tcd->subbuf_num_label = gtk_label_new("Number of subbuffers:");
273 gtk_widget_show (tcd->subbuf_num_label);
274 tcd->subbuf_num_entry = gtk_entry_new();
275 gtk_widget_show (tcd->subbuf_num_entry);
276 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_label,0,2,9,10,GTK_FILL,GTK_FILL,2,2);
277 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_entry,2,6,9,10,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
278
279 tcd->lttctl_path_label = gtk_label_new("path to lttctl:");
280 gtk_widget_show (tcd->lttctl_path_label);
281 tcd->lttctl_path_entry = gtk_entry_new();
282 gtk_widget_show (tcd->lttctl_path_entry);
283 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_label,0,2,10,11,GTK_FILL,GTK_FILL,2,2);
284 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_entry,2,6,10,11,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
285
286
287 tcd->lttd_path_label = gtk_label_new("path to lttd:");
288 gtk_widget_show (tcd->lttd_path_label);
289 tcd->lttd_path_entry = gtk_entry_new();
290 gtk_widget_show (tcd->lttd_path_entry);
291 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_label,0,2,11,12,GTK_FILL,GTK_FILL,2,2);
292 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_entry,2,6,11,12,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
381229ee 293
294
77ef407f 295 tcd->fac_path_label = gtk_label_new("path to facilities:");
296 gtk_widget_show (tcd->fac_path_label);
297 tcd->fac_path_entry = gtk_entry_new();
298 gtk_entry_set_text(GTK_ENTRY(tcd->fac_path_entry),PACKAGE_DATA_DIR "/facilities");
299 gtk_widget_set_size_request(tcd->fac_path_entry, 250, -1);
300 gtk_widget_show (tcd->fac_path_entry);
301 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->fac_path_label,0,2,12,13,GTK_FILL,GTK_FILL,2,2);
302 gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->fac_path_entry,2,6,12,13,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0);
303
304 g_signal_connect(G_OBJECT(tcd->start_button), "clicked",
305 (GCallback)start_clicked, tcd);
306 g_signal_connect(G_OBJECT(tcd->pause_button), "clicked",
307 (GCallback)pause_clicked, tcd);
308 g_signal_connect(G_OBJECT(tcd->stop_button), "clicked",
309 (GCallback)stop_clicked, tcd);
e7c8534e 310
311 /*
312 * show main container
313 */
77ef407f 314 gtk_widget_show(tcd->main_box);
315 gtk_widget_show(tcd->window);
e7c8534e 316
317
318 g_object_set_data_full(
77ef407f 319 G_OBJECT(guicontrol_get_widget(tcd)),
320 "control_viewer_data",
e7c8534e 321 tcd,
322 (GDestroyNotify)gui_control_destructor);
323
324 g_control_list = g_slist_append(
325 g_control_list,
326 tcd);
327
328 return tcd;
329}
330
331
332/**
333 * @fn void gui_control_destructor(ControlData*)
334 *
335 * Destructor for the filter gui module
336 * @param tcd The module structure
337 */
338void
339gui_control_destructor(ControlData *tcd)
340{
341 Tab *tab = tcd->tab;
342
343 /* May already been done by GTK window closing */
77ef407f 344 if(GTK_IS_WIDGET(guicontrol_get_widget(tcd))){
e7c8534e 345 g_info("widget still exists");
346 }
347// if(tab != NULL) {
348// lttvwindow_unregister_traceset_notify(tcd->tab,
349// filter_traceset_changed,
350// filter_viewer_data);
351// }
352 lttvwindowtraces_background_notify_remove(tcd);
353
354 g_control_list = g_slist_remove(g_control_list, tcd);
355
356 g_free(tcd);
357}
358
77ef407f 359/* Callbacks */
360
361void start_clicked (GtkButton *button, gpointer user_data)
362{
363 ControlData *tcd = (ControlData*)user_data;
364
365 const gchar *username = gtk_entry_get_text(GTK_ENTRY(tcd->username_entry));
366 const gchar *password = gtk_entry_get_text(GTK_ENTRY(tcd->password_entry));
367 const gchar *channel_dir =
368 gtk_entry_get_text(GTK_ENTRY(tcd->channel_dir_entry));
369 const gchar *trace_dir = gtk_entry_get_text(GTK_ENTRY(tcd->trace_dir_entry));
370 const gchar *trace_name =
371 gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry));
372
373 const gchar *trace_mode_sel =
374 gtk_combo_box_get_active_text(GTK_COMBO_BOX(tcd->trace_mode_combo));
375 const gchar *trace_mode;
376 if(strcmp(trace_mode_sel, "normal") == 0)
377 trace_mode = "normal";
378 else
379 trace_mode = "flight";
380
381 gboolean start_daemon =
f6f6abf0 382 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tcd->start_daemon_check));
77ef407f 383
384 const gchar *subbuf_size =
385 gtk_entry_get_text(GTK_ENTRY(tcd->subbuf_size_entry));
386 const gchar *subbuf_num =
387 gtk_entry_get_text(GTK_ENTRY(tcd->subbuf_num_entry));
388 const gchar *lttctl_path =
389 gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry));
390 const gchar *lttd_path = gtk_entry_get_text(GTK_ENTRY(tcd->lttd_path_entry));
391 const gchar *fac_path = gtk_entry_get_text(GTK_ENTRY(tcd->fac_path_entry));
392
393 pid_t pid = fork();
394
395 if(pid > 0) {
396 /* parent */
397
398
399 } else if(pid == 0) {
400 /* child */
f6f6abf0 401 gchar args[MAX_ARGS_LEN];
402 gint args_left = MAX_ARGS_LEN - 1; /* for \0 */
403
404 /* Setup environment variables */
77ef407f 405 if(strcmp(lttd_path, "") != 0)
406 setenv("LTT_DAEMON", lttd_path, 1);
407 if(strcmp(fac_path, "") != 0)
408 setenv("LTT_FACILITIES", fac_path, 1);
f6f6abf0 409
410 /* Setup arguments to su */
411 if(strcmp(lttctl_path, "") == 0) {
412 strncpy(args, "lttctl", args_left);
413 args_left = MAX_ARGS_LEN - strlen(args) - 1;
414 } else {
415 strncpy(args, lttctl_path, args_left);
416 args_left = MAX_ARGS_LEN - strlen(args) - 1;
417 }
418
419 /* space */
420 strncat(args, " ", args_left);
421 args_left = MAX_ARGS_LEN - strlen(args) - 1;
422
423 /* channel dir */
424 strncat(args, "-l ", args_left);
425 args_left = MAX_ARGS_LEN - strlen(args) - 1;
426 strncat(args, channel_dir, args_left);
427 args_left = MAX_ARGS_LEN - strlen(args) - 1;
428
429 /* space */
430 strncat(args, " ", args_left);
431 args_left = MAX_ARGS_LEN - strlen(args) - 1;
432
433 /* trace dir */
434 strncat(args, "-t ", args_left);
435 args_left = MAX_ARGS_LEN - strlen(args) - 1;
436 strncat(args, trace_dir, args_left);
437 args_left = MAX_ARGS_LEN - strlen(args) - 1;
438
439 /* space */
440 strncat(args, " ", args_left);
441 args_left = MAX_ARGS_LEN - strlen(args) - 1;
442
443 /* name */
444 strncat(args, "-n ", args_left);
445 args_left = MAX_ARGS_LEN - strlen(args) - 1;
446 strncat(args, trace_name, args_left);
447 args_left = MAX_ARGS_LEN - strlen(args) - 1;
448
449 /* space */
450 strncat(args, " ", args_left);
451 args_left = MAX_ARGS_LEN - strlen(args) - 1;
452
453 /* trace mode */
454 strncat(args, "-m ", args_left);
455 args_left = MAX_ARGS_LEN - strlen(args) - 1;
456 strncat(args, trace_mode, args_left);
457 args_left = MAX_ARGS_LEN - strlen(args) - 1;
458
459 /* space */
460 strncat(args, " ", args_left);
461 args_left = MAX_ARGS_LEN - strlen(args) - 1;
462
463 /* Start daemon ? */
464 if(start_daemon) {
465 strncat(args, "-d", args_left);
466 args_left = MAX_ARGS_LEN - strlen(args) - 1;
467 } else {
468 /* Simply create the channel and then start tracing */
469 strncat(args, "-b", args_left);
470 args_left = MAX_ARGS_LEN - strlen(args) - 1;
471 }
472
473 /* space */
474 strncat(args, " ", args_left);
475 args_left = MAX_ARGS_LEN - strlen(args) - 1;
476
477 /* optional arguments */
478 /* subbuffer size */
479 if(strcmp(subbuf_size, "") != 0) {
480 strncat(args, "-z ", args_left);
481 args_left = MAX_ARGS_LEN - strlen(args) - 1;
482 strncat(args, subbuf_size, args_left);
483 args_left = MAX_ARGS_LEN - strlen(args) - 1;
484 }
485
486 /* space */
487 strncat(args, " ", args_left);
488 args_left = MAX_ARGS_LEN - strlen(args) - 1;
489
490 /* number of subbuffers */
491 if(strcmp(subbuf_num, "") != 0) {
492 strncat(args, "-x ", args_left);
493 args_left = MAX_ARGS_LEN - strlen(args) - 1;
494 strncat(args, subbuf_num, args_left);
495 args_left = MAX_ARGS_LEN - strlen(args) - 1;
496 }
497
498 g_message("Executing (as %s) : %s", username, args);
499
500 //execlp("su", "-p", );
501 //exit(-1): /* not supposed to happen! */
502 system(args);
77ef407f 503 exit(0);
504
505 //gint ret = execvp();
506
507 } else {
508 /* error */
509
510 }
511
512}
513
514
515void pause_clicked (GtkButton *button, gpointer user_data)
516{
517 ControlData *tcd = (ControlData*)user_data;
518
519
520}
521
522void stop_clicked (GtkButton *button, gpointer user_data)
523{
524 ControlData *tcd = (ControlData*)user_data;
525
526
527}
528
e7c8534e 529
530/**
531 * @fn GtkWidget* h_guicontrol(Tab*)
532 *
533 * Control Module's constructor hook
534 *
535 * This constructor is given as a parameter to the menuitem and toolbar button
536 * registration. It creates the list.
537 * @param tab A pointer to the parent window.
538 * @return The widget created.
539 */
540GtkWidget *
541h_guicontrol(Tab *tab)
542{
543 ControlData* f = gui_control(tab) ;
544
545 return NULL;
546}
547
548/**
549 * @fn static void init()
550 *
551 * This function initializes the Filter Viewer functionnality through the
552 * gtkTraceSet API.
553 */
554static void init() {
555
556 lttvwindow_register_constructor("guicontrol",
557 "/",
558 "Insert Tracing Control Module",
559 hTraceControlInsert_xpm,
560 "Insert Tracing Control Module",
561 h_guicontrol);
562}
563
564/**
565 * @fn void control_destroy_walk(gpointer,gpointer)
566 *
567 * Initiate the destruction of the current gui module
568 * on the GTK Interface
569 */
570void
571control_destroy_walk(gpointer data, gpointer user_data)
572{
573 ControlData *tcd = (ControlData*)data;
574
575 g_debug("traceontrol.c : control_destroy_walk, %p", tcd);
576
577 /* May already have been done by GTK window closing */
578 if(GTK_IS_WIDGET(guicontrol_get_widget(tcd)))
579 gtk_widget_destroy(guicontrol_get_widget(tcd));
580}
581
582/**
583 * @fn static void destroy()
584 * @brief plugin's destroy function
585 *
586 * This function releases the memory reserved by the module and unregisters
587 * everything that has been registered in the gtkTraceSet API.
588 */
589static void destroy() {
590
591 g_slist_foreach(g_control_list, control_destroy_walk, NULL );
592
593 lttvwindow_unregister_constructor(h_guicontrol);
594
595}
596
597
598LTTV_MODULE("guitracecontrol", "Trace Control Window", \
599 "Graphical module that let user control kernel tracing", \
600 init, destroy, "lttvwindow")
601
This page took 0.046132 seconds and 4 git commands to generate.