示例#1
0
int main(int argc, char** argv)
{
   GConfEngine* conf = gconf_engine_get_default();
         
   gchar* config_system_path = gconf_engine_get_string(conf, "/apps/intel_services_manager/11111111-1111-1111-111111111111/System/config_system_path", NULL);
   gchar* host = gconf_engine_get_string(conf, "/system/http_proxy/host", NULL);
   gint port   = gconf_engine_get_int(conf,    "/system/http_proxy/port", NULL);
   gboolean enabled  = gconf_engine_get_bool(conf,   "/system/http_proxy/use_http_proxy", NULL);

   printf("PROXY SETTINGS\n");
   printf("config_system_path: %s\n", config_system_path ? config_system_path : "");
   printf("host   : %s\n", host ? host : "");
   printf("port   : %i\n", port);
   printf("enabled: %i\n", enabled);

   gconf_engine_unref(conf);

   return 0;
}
示例#2
0
static void
check_string_storage(GConfEngine* conf)
{
  GError* err = NULL;
  const gchar** keyp = NULL;
  const gchar** valp = NULL;

  /* Loop over keys, storing all strings at each key then immediately
     retrieving them */
  
  keyp = keys;

  while (*keyp)
    {
      valp = some_strings;
      while (*valp)
        {
          gchar* gotten;
          
          if (!gconf_engine_set_string(conf, *keyp, *valp, &err))
            {
              fprintf(stderr, "Failed to set key `%s' to `%s': %s\n",
                      *keyp, *valp, err->message);
              g_error_free(err);
              err = NULL;
            }
          else
            {
              sync_and_clear(conf);
              
              gotten = gconf_engine_get_string(conf, *keyp, &err);
              
              if (err != NULL)
                {
                  check(gotten == NULL, "string was returned though there was an error");
                  fprintf(stderr, "Failed to get key `%s': %s\n",
                          *keyp, err->message);
                  g_error_free(err);
                  err = NULL;
                }
              else
                {
                  check (strcmp(gotten, *valp) == 0, "string set/get pair: `%s' set, `%s' got",
                         *valp, gotten);
              
                  g_free(gotten);
                }
            }
          
          ++valp;
        }

      ++keyp;
    }

  /* Now invert the loop and see if that causes problems */
  
  valp = some_strings;
  
  while (*valp)
    {
      keyp = keys;
      while (*keyp)
        {
          gchar* gotten;
          
          if (!gconf_engine_set_string(conf, *keyp, *valp, &err))
            {
              fprintf(stderr, "Failed to set key `%s' to `%s': %s\n",
                      *keyp, *valp, err->message);
              g_error_free(err);
              err = NULL;
            }

          sync_and_clear(conf);
          
          gotten = gconf_engine_get_string(conf, *keyp, &err);

          if (err != NULL)
            {
              check(gotten == NULL, "string was returned though there was an error");
              fprintf(stderr, "Failed to get key `%s': %s\n",
                      *keyp, err->message);
              g_error_free(err);
              err = NULL;
            }
          else if (gotten)
            {
              check (strcmp(gotten, *valp) == 0, "string set/get pair: `%s' set, `%s' got",
                     *valp, null_safe(gotten));
              
              g_free(gotten);
            }
              
          ++keyp;
        }

      ++valp;
    }


  check_unset(conf);
}