show.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <glib.h>
00033 #include <stdio.h>
00034 #include <string.h>
00035 #include <stdlib.h>
00036
00037 #include <gconf/gconf-client.h>
00038
00039
00040
00041
00042 #include "log.h"
00043 #include "erconftool.h"
00044
00045 #define UNUSED(x) (void)(x)
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 static void dump_dir (GConfClient *client, const char *path);
00068 void dump_entries (GConfClient *client, const char *path);
00069 void show_key (GConfClient *client, const char *key);
00070
00071
00072
00073
00074
00075
00076 void show_registry(GConfClient *client, const char **paths)
00077 {
00078 gint i;
00079 for (i = 0; paths[i]; i++)
00080 dump_dir(client, paths[i]);
00081 }
00082
00083
00084 void show_entry(GConfClient *client, GConfEntry *entry)
00085 {
00086 UNUSED(client);
00087 GConfValue *value = gconf_entry_get_value(entry);
00088 gboolean is_default = gconf_entry_get_is_default(entry);
00089 gboolean is_writable = gconf_entry_get_is_writable(entry);
00090
00091 g_print("Key %s\t", entry->key);
00092
00093 if (value)
00094 {
00095 g_print("%s%s", (is_default ? " DEFAULT" : ""), (is_writable ? " WRITABLE" : ""));
00096
00097 switch (value->type)
00098 {
00099 case GCONF_VALUE_STRING:
00100 g_print(" STRING\t`%s`", gconf_value_get_string(value));
00101 break;
00102
00103 case GCONF_VALUE_INT:
00104 g_print(" INT\t %d", gconf_value_get_int(value));
00105 break;
00106
00107 case GCONF_VALUE_FLOAT:
00108 g_print(" FLOAT\t %f", gconf_value_get_float(value));
00109 break;
00110
00111 case GCONF_VALUE_BOOL:
00112 g_print(" BOOL\t %s", (gconf_value_get_bool(value) ? "true" : "false"));
00113 break;
00114
00115 case GCONF_VALUE_SCHEMA:
00116 g_print(" SCHEMA (data not shown for this type)");
00117 break;
00118
00119 case GCONF_VALUE_LIST:
00120 {
00121 g_print(" LIST of ");
00122 GSList *valuelist = gconf_value_get_list(value);
00123 gsize len = g_slist_length(valuelist);
00124
00125 switch (gconf_value_get_list_type(value))
00126 {
00127 case GCONF_VALUE_STRING:
00128 g_print("%d STRINGS\t", len);
00129 while (valuelist!=NULL)
00130 {
00131 g_print("%s;", gconf_value_get_string(valuelist->data));
00132 valuelist=valuelist->next;
00133 }
00134 break;
00135
00136 case GCONF_VALUE_INT:
00137 g_print("%d INTS\t", len);
00138 while (valuelist!=NULL)
00139 {
00140 g_print("%d;", gconf_value_get_int(valuelist->data));
00141 valuelist=valuelist->next;
00142 }
00143 break;
00144
00145 case GCONF_VALUE_FLOAT:
00146 g_print("%d FLOATS\t", len);
00147 while (valuelist!=NULL)
00148 {
00149 g_print("%f;", gconf_value_get_float(valuelist->data));
00150 valuelist=valuelist->next;
00151 }
00152 break;
00153
00154 case GCONF_VALUE_BOOL:
00155 g_print("%d BOOLS\t", len);
00156 while (valuelist!=NULL)
00157 {
00158 g_print("%s;", (gconf_value_get_bool(valuelist->data) ? "true" : "false"));
00159 valuelist=valuelist->next;
00160 }
00161 break;
00162
00163 default:
00164 g_print("Unsupported data type %d\n", value->type);
00165 break;
00166 }
00167
00168 g_slist_free(valuelist);
00169 }
00170 break;
00171
00172 case GCONF_VALUE_PAIR:
00173 g_print(" PAIR (data not shown for this type)");
00174 break;
00175
00176 case GCONF_VALUE_INVALID:
00177 default:
00178 g_print(" has invalid type");
00179 break;
00180 }
00181 }
00182 else
00183 {
00184 g_print(" has invalid type");
00185 }
00186
00187 g_print("\n");
00188 }
00189
00190
00191 void show_key(GConfClient *client, const char *key)
00192 {
00193 show_entry(client, gconf_client_get_entry(client, key, NULL, TRUE, NULL));
00194 }
00195
00196
00197 void dump_entries(GConfClient *client, const char *path)
00198 {
00199 GSList *entries = gconf_client_all_entries(client, (char*) path, NULL);
00200 while (entries!=NULL)
00201 {
00202 show_entry(client, (GConfEntry*) entries->data);
00203 entries=entries->next;
00204 }
00205 }
00206
00207
00208 static void dump_dir(GConfClient *client, const char *path)
00209 {
00210 GSList *tmp = gconf_client_all_dirs(client, path, NULL);
00211
00212 dump_entries(client,path);
00213
00214
00215 while (tmp!=NULL)
00216 {
00217 dump_dir(client, (char*) tmp->data);
00218 tmp=tmp->next;
00219 }
00220 }