erconftool/src/main.c File Reference

#include "config.h"
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <gconf/gconf-client.h>
#include "log.h"
#include "export.h"
#include "import.h"
#include "show.h"
Include dependency graph for erconftool/src/main.c:

Go to the source code of this file.

Defines

#define UNUSED(x)   (void)(x)
#define INI_FILE_DEFAULT   "/media/mmcblk0p1/System/dr.ini"

Functions

void key_changed_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
int main (int argc, char *argv[])

Define Documentation

#define INI_FILE_DEFAULT   "/media/mmcblk0p1/System/dr.ini"

Definition at line 60 of file erconftool/src/main.c.

Referenced by main().

#define UNUSED (  )     (void)(x)

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 48 of file erconftool/src/main.c.


Function Documentation

void key_changed_callback ( GConfClient *  client,
guint  cnxn_id,
GConfEntry *  entry,
gpointer  user_data 
)

Definition at line 77 of file erconftool/src/main.c.

References show_entry(), and UNUSED.

Referenced by main().

00081 {
00082     UNUSED(cnxn_id);
00083     UNUSED(user_data);
00084     show_entry(client, entry);   
00085 }

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 88 of file erconftool/src/main.c.

References export_registry(), import_registry(), INI_FILE_DEFAULT, key_changed_callback(), and show_registry().

00089 {
00090     GMainLoop      *mainloop       = NULL;
00091     GError         *error          = NULL;
00092     GConfClient    *gconf_client   = NULL;
00093     gboolean       force_defaults  = FALSE;
00094     gboolean       start_monitor   = FALSE;
00095     gchar          *ini_file       = NULL;
00096     gchar          **delete_paths  = NULL;
00097     gchar          **show_paths    = NULL;
00098     gchar          **import_paths  = NULL;
00099     gchar          **export_paths  = NULL;
00100     GOptionContext *context        = NULL;
00101     gint           i               = 0;
00102     
00103     GOptionEntry entries[] =  
00104     {
00105         { "config",    'c', 0, G_OPTION_ARG_STRING,       &ini_file,        "Fully qualified name of config file", "<filename>" },
00106         { "import",    'i', 0, G_OPTION_ARG_STRING_ARRAY, &import_paths,    "Force export of schema defaults", "<paths>" },
00107         { "delete",    'd', 0, G_OPTION_ARG_STRING_ARRAY, &delete_paths,    "Delete GConf preferences (revert to defaults)", "<paths>" },
00108         { "export",    'e', 0, G_OPTION_ARG_STRING_ARRAY, &export_paths,    "Export settings to the config file", "<paths>" },
00109         { "show",      's', 0, G_OPTION_ARG_STRING_ARRAY, &show_paths,      "Show GConf preferences", "<paths>" },
00110         { "monitor",   'm', 0, G_OPTION_ARG_NONE,         &start_monitor,   "Monitor updated GConf preferences", NULL },
00111         { "force",     'f', 0, G_OPTION_ARG_NONE,         &force_defaults,  "Force export of schema defaults", NULL },
00112         { NULL, 0, 0, 0, NULL, NULL, NULL }
00113     };
00114 
00115     if (argc <= 1)
00116     {
00117         g_print("Run with '--help' to see a full list of available command line options.\n");
00118         exit(0);
00119     }
00120     
00121     // init 
00122     g_type_init();
00123     mainloop = g_main_loop_new(NULL, FALSE);
00124     
00125     // parse commandline arguments
00126     context = g_option_context_new("- Tool to manipulate ereader configuration");
00127     g_option_context_add_main_entries(context, entries, NULL);
00128     if (!g_option_context_parse(context, &argc, &argv, &error)) 
00129     {
00130         g_print("Error parsing arguments: %s\n", error->message);
00131         g_error_free(error);
00132         error = NULL;
00133     }
00134     g_option_context_free(context);
00135     
00136     // init GConf for full repository 
00137     gconf_client = gconf_client_get_default();
00138     if (gconf_client==NULL) 
00139     {
00140         g_error("Failed to connect GConf");
00141         return 1;
00142     }   
00143 
00144     gconf_client_add_dir(gconf_client,
00145                          "/",
00146                          GCONF_CLIENT_PRELOAD_NONE,
00147                          NULL);
00148     
00149     if (!ini_file)
00150     {
00151         ini_file = g_strdup(INI_FILE_DEFAULT);
00152     }
00153 
00154     if (import_paths)
00155     {
00156         import_registry(gconf_client, ini_file, (const char**) import_paths);
00157     }
00158     
00159     if (delete_paths)
00160     {
00161         for (i = 0; delete_paths[i]; i++)
00162         {
00163             gconf_client_recursive_unset(gconf_client, delete_paths[i], 0, &error);
00164             if (error != NULL) 
00165             {
00166                 g_print("Error deleting keys for %s\n", error->message);
00167                 g_error_free(error);
00168                 error = NULL;
00169             }     
00170         }
00171     }
00172     
00173     if (export_paths)
00174     {
00175         export_registry(gconf_client, ini_file, (const char**) export_paths, force_defaults);
00176     }
00177     
00178     if (show_paths)
00179     {
00180         show_registry(gconf_client, (const char**) show_paths);
00181     }
00182     
00183     if (start_monitor)
00184     {
00185         gconf_client_notify_add(gconf_client, "/",
00186                                 key_changed_callback,
00187                                 NULL,
00188                                 NULL, &error);
00189         if (error != NULL) 
00190         {
00191             g_print("Error installing monitor for %s\n", error->message);
00192             g_error_free(error);
00193             error = NULL;
00194         }     
00195         else
00196         {
00197             g_main_loop_run(mainloop);
00198         }
00199     }
00200 
00201     return 0;
00202 }

Here is the call graph for this function:

Generated by  doxygen 1.6.2-20100208