#include <gWavMerger.h>
Collaboration diagram for gWavMerger:

Public Methods | |
| gWavMerger () | |
| ~gWavMerger () | |
| virtual void | init (int *argc_, char *argv_[], const char *help_info_) |
| virtual void | initServer () |
| virtual void | processServer () |
| int | get_exit_value () const |
| void | set_exit_value (int v_) |
| MainWindow * | get_main_window () |
| bool | timer_cb () |
| string | wavjoin_options () const |
Private Attributes | |
| int | m_exit_value |
| string | m_gtk_options |
| string | m_wavjoin_options |
| int | m_log_level |
| MainWindow * | m_main_win |
| Gnome::Main * | m_kit |
Static Private Attributes | |
| const int | TIMEOUT = 500 |
|
|
Description: Trim command-line arguments set Definition at line 73 of file gWavMerger.cpp. References m_gtk_options, m_log_level, and m_wavjoin_options.
00074 : m_exit_value (0), 00075 m_log_level (-1), // not set 00076 m_main_win (NULL), 00077 m_kit (NULL) 00078 { 00079 // ---Configuration--- 00080 rm_opt ('f', "config-file" ); 00081 rm_opt ('n', "instance" ); 00082 rm_opt ('p', "port" ); 00083 00084 // ---Process bookkeeping--- 00085 rm_opt ('b', "daemon" ); 00086 rm_opt ('l', "pidfile" ); 00087 m_ommit_pidflock_flag = 0; // skip PID file creation step 00088 00089 /* 00090 * Disable all debugging. You can control these options from 00091 * ~/.gnome/gwavmerger configuration file. 00092 */ 00093 m_debug_mask = 0x0; 00094 m_log_file = "/dev/null"; 00095 00096 add_opt (0, "gtk-options", &m_gtk_options); 00097 add_opt (0, "wavjoin-options", &m_wavjoin_options); 00098 add_opt (0, "log-level", &m_log_level); 00099 } |
|
|
Definition at line 102 of file gWavMerger.cpp. References m_main_win.
00103 {
00104 delete m_main_win;
00105 // delete m_kit;
00106 }
|
|
|
Definition at line 46 of file gWavMerger.h. References m_exit_value. Referenced by main.
00046 { return m_exit_value; }
|
|
|
Definition at line 48 of file gWavMerger.h. References m_main_win.
00048 { return m_main_win; }
|
|
||||||||||||||||
|
Name: init() Description: Read configuration from [options] secion of GNOME configuration file, ~/.gnome[2]/gwavmerger, and populate command-line options. They might be overwritten by command-line arguments supplied in argv_. Call GenServer::init() to start initialization. Note: Gnome configuration directory name depends on its version. For Gnome1.2, the name is ~/.gnome; for Gnome2, it is ~/.gnome2. Definition at line 137 of file gWavMerger.cpp. References m_gtk_options, m_log_level, m_wavjoin_options, and split_pair. Referenced by main.
00138 {
00139 trace ("gWavMerger::init");
00140
00141 register char token;
00142 const int size = 256;
00143 char line [size];
00144 bool parsing_options_section = false;
00145
00146 gchar* s = NULL;
00147 gboolean b = false;
00148 gint i = 0;
00149
00155 string localrc (ASSA::Utils::strenv ("$HOME/.gnome2/gwavmerger"));
00156 string defaultrc (GWMDATADIR);
00157 defaultrc += "/gwavmerger";
00158 std::ifstream infile;
00159
00160 if (::access (localrc.c_str (), R_OK) < 0) {
00161 DL((TRACE,"No ~/.gnome2/gwavmerger found.\n"));
00162 DL((TRACE,"Installing from default.\n"));
00163
00164 if (::access (defaultrc.c_str (), R_OK) == 0) {
00165 string cmd ("cp -p ");
00166 cmd += defaultrc + " " + localrc;
00167 if (::system (cmd.c_str ()) < 0) {
00168 goto done;
00169 }
00170 }
00171 else {
00172 DL((TRACE,"Default configuration file is missing!\n"));
00173 }
00174 }
00175 infile.open (localrc.c_str (), std::ios::in);
00176 if (!infile.is_open ()) {
00177 goto done;
00178 }
00179
00180 for (token = infile.peek (); token != EOF; token = infile.peek ()) {
00181 while (token == '#' || token == '\n') {
00182 infile.getline (line, size, '\n');
00183 token = infile.peek ();
00184 }
00185 if (token == '[') {
00186 infile.getline (line, size, '\n');
00187 parsing_options_section = (line == string ("[options]"));
00188 }
00189 else {
00190 if (parsing_options_section) {
00191 infile.getline (line, size, '\n');
00192 std::string name, value;
00193 split_pair (line, '=', name, value);
00194
00195 if (name == "gtk_options") {
00196 m_gtk_options = value;
00197 }
00198 else if ( name == "wavjoin_options") {
00199 m_wavjoin_options = value;
00200 }
00201 else if ( name == "log_file") {
00202 m_log_file = value;
00203 }
00204 else if ( name == "log_stdout") {
00205 m_log_stdout_flag = (value == "1");
00206 }
00207 else if ( name == "log_size") {
00208 m_log_size = strtol (value.c_str (), NULL, 16); ;
00209 }
00210
00211 else if ( name == "mask") {
00212 m_debug_mask = strtol (value.c_str (), NULL, 16);
00213 }
00214
00215 else if ( name == "log_level") {
00216 m_log_level = strtol (value.c_str (), NULL, 16);
00217 }
00218 }
00219 else {
00220 infile.getline (line, size, '\n');
00221 }
00222 }
00223 }
00224
00225 done:
00226 ASSA::GenServer::init (argc_, argv_, help_info_);
00227
00228 /*
00229 TRACE = 0x01
00230 APP = 0x02
00231 USR1 = 0x04
00232 USR2 = 0x08
00233 USR3 = 0x10
00234 ALL_APPS = 0x1F
00235 ERROR = 0x20
00236 FORK = 0x40000
00237 */
00238
00239 if (m_log_level >= 0) {
00240 switch (m_log_level) {
00241 case 5:
00242 m_debug_mask = ALL; // Log message flood!
00243 case 4:
00244 m_debug_mask = 0x40023; // APP_APPS+FORK+ERRORS
00245 break;
00246 case 3:
00247 m_debug_mask = 0x23; // APP+TRACE+ERRORS
00248 break;
00249 case 2:
00250 m_debug_mask = 0x21; // TRACE+ERRORS
00251 break;
00252 case 1:
00253 m_debug_mask = 0x22; // APP+ERRORS
00254 break;
00255 case 0:
00256 default:
00257 m_debug_mask = 0x0;
00258 }
00259
00260 }
00261
00262 LOGGER->enable_groups (m_debug_mask);
00263 infile.close ();
00264 }
|
|
|
Name: initServer() Description: Perform application-level initialization. All GTK+ options are grouped together with {-g, --gtk-options STRING}. We feed the entire group to Gnome::Main() as command-line arguments. Note: The first argument would always be the program name. Definition at line 279 of file gWavMerger.cpp. References m_gtk_options, m_kit, m_log_level, m_main_win, m_wavjoin_options, PACKAGE, TIMEOUT, timer_cb, and VERSION. Referenced by main.
00280 {
00281 trace("gWavMerger::initServer");
00282 ASSA::Log::disable_timestamp ();
00283
00284 DL((ALL,"gtk_options = \"%s\"\n", m_gtk_options.c_str ()));
00285 DL((ALL,"wavjoin_options = \"%s\"\n", m_wavjoin_options.c_str ()));
00286 DL((ALL,"log_stdout = %s\n", m_log_stdout_flag ? "true" : "false"));
00287 DL((ALL,"log_file = \"%s\"\n", m_log_file.c_str ()));
00288 DL((ALL,"log_size = %d\n", m_log_size));
00289 DL((ALL,"log_level = \"%d\"\n", m_log_level));
00290 DL((ALL,"mask = 0x%X\n", m_debug_mask));
00291
00292 int gtk_argc = 0;
00293 char** gtk_argv = NULL;
00294
00295 ASSA::SigAction old_chld_act;
00296 struct sigaction* sa;
00297
00298 old_chld_act.retrieve_action (SIGCHLD);
00299 sa = old_chld_act;
00300 m_gtk_options = "gwavmerger " + m_gtk_options;
00301
00302 ASSA::CmdLineOpts::str_to_argv (m_gtk_options, gtk_argc, gtk_argv);
00303
00304 /*
00305 gnomemm call
00306
00307 Main::Main(const Glib::ustring& app_id,
00308 const Glib::ustring& app_version,
00309 const ModuleInfo& module_info,
00310 int argc,
00311 char** argv,
00312 const struct poptOption* options, // GNOME_PARAM_POPT_TABLE, ?
00313 int flags,
00314 poptContext* return_ctx);
00315
00316 translates into
00317
00318 GnomeProgram* pProgram =
00319 gnome_program_init(app_id_,
00320 app_version_,
00321 module_info.gobj(),
00322 argc,
00323 argv,
00324 GNOME_PARAM_POPT_TABLE, options,
00325 GNOME_PARAM_POPT_FLAGS, flags,
00326 0);
00327
00328 libgnome manual describes it as:
00329
00330 GnomeProgram*
00331 gnome_program_init(const char *app_id,
00332 const char *app_version,
00333 const GnomeModuleInfo *module_info,
00334 int argc,
00335 char **argv,
00336 const char *first_property_name,
00337 ...);
00338
00339
00340 What I was suggested instead is to call is the following to make
00341 Yelp working:
00342
00343 gnome_program_init (app_id,
00344 version,
00345 LIBGNOMEUI_MODULE,
00346 nargs,
00347 args,
00348 GNOME_PROGRAM_STANDARD_PROPERTIES,
00349 NULL);
00350
00351 or GNOME_PARAM_APP_DATADIR, DATADIR
00352
00353 */
00354
00355 m_kit = new Gnome::Main (PACKAGE, VERSION,
00356 Gnome::UI::module_info_get (),
00357 gtk_argc, gtk_argv);
00358
00359 #if SUSPEND
00360 gnome_program_init (PACKAGE, VERSION,
00361 LIBGNOMEUI_MODULE,
00362 gtk_argc, gtk_argv,
00363 GNOME_PARAM_APP_DATADIR, DATADIR,
00364 NULL);
00365 #endif
00366 ASSA::CmdLineOpts::free_argv (gtk_argv);
00367
00368 DL((APP,"AppModuleName = \"%s\"\n",
00369 Gnome::UI::module_info_get ().get_name ().c_str ()));
00370
00374 ASSA::SigAction ignore (SIG_IGN);
00375 ignore.register_action (SIGCHLD, &old_chld_act);
00376
00377 m_main_win = new MainWindow;
00378
00379 SigC::Slot0<bool> tslot = slot (*this, &gWavMerger::timer_cb);
00380 SigC::Connection conn = Glib::signal_timeout().connect (tslot, TIMEOUT);
00381
00382 DL((APP,"\n= Environment variables set by Autoconfig: =\n"
00383 "\tGWMDATADIR = \"%s\"\n"
00384 "\tDATADIR = \"%s\"\n"
00385 "\tPACKAGE = \"%s\"\n"
00386 "\tVERSION = \"%s\"\n\n",
00387 GWMDATADIR, DATADIR, PACKAGE, VERSION));
00388
00389 #if 0
00390
00392 Glib::ustring ustr;
00393 Glib::ustring file ("gwavmerger.xml");
00394 Glib::RefPtr<Gnome::Program> prog = Gnome::Program::get ();
00395
00396 ustr = prog->locate_file (Gnome::FILE_DOMAIN_DATADIR, file);
00397 DL((APP,"FILE_DOMAIN_DATADIR:gwavmerger = \"%s\"\n", ustr.c_str ()));
00398
00399 ustr = prog->locate_file (Gnome::FILE_DOMAIN_APP_DATADIR, file);
00400 DL((APP,"FILE_DOMAIN_APP_DATADIR:gwavmerger = \"%s\"\n", ustr.c_str ()));
00401 #endif
00402
00403 DL((APP,"Service has been initialized\n"));
00404 }
|
|
|
Name: processServer() Description: Main event loop - runs until user clicks on Exit button. Definition at line 413 of file gWavMerger.cpp. References m_kit, and REACTOR. Referenced by main.
00414 {
00415 trace("gWavMerger::processServer");
00416
00417 m_kit->run (); // Calling Gtk::Main::quit () terminates Gtk event loop
00418 REACTOR->stopReactor ();
00419
00420 /* From Gtk man page:
00421 * "Terminate the program and return the given exit code to the caller.
00422 * This function will shut down the GUI and free all resources allocated
00423 * for GTK."
00424 *
00425 * I don't think that's entirely true. MergeDialog is managed and
00426 * I don't see its detructor being called ever (not that I care).
00427 *
00428 */
00429 gtk_exit (0);
00430 }
|
|
|
Definition at line 47 of file gWavMerger.h. References m_exit_value.
00047 { m_exit_value = v_; }
|
|
|
Name: timer_cb() Description: Run Reactor's event loop. Definition at line 114 of file gWavMerger.cpp. References REACTOR. Referenced by initServer.
00115 {
00116 ASSA::TimeVal timeout (0.01);
00117 REACTOR->waitForEvents (&timeout);
00118 return true;
00119 }
|
|
|
Definition at line 51 of file gWavMerger.h. References m_wavjoin_options.
00051 { return m_wavjoin_options; }
|
|
|
Definition at line 56 of file gWavMerger.h. Referenced by get_exit_value, and set_exit_value. |
|
|
Definition at line 57 of file gWavMerger.h. Referenced by gWavMerger, init, and initServer. |
|
|
Definition at line 62 of file gWavMerger.h. Referenced by initServer, and processServer. |
|
|
Definition at line 59 of file gWavMerger.h. Referenced by gWavMerger, init, and initServer. |
|
|
Definition at line 61 of file gWavMerger.h. Referenced by get_main_window, initServer, and ~gWavMerger. |
|
|
Definition at line 58 of file gWavMerger.h. Referenced by gWavMerger, init, initServer, and wavjoin_options. |
|
|
Definition at line 44 of file gWavMerger.cpp. Referenced by initServer. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002