Exemplo n.º 1
0
int
ef_cb_efreet_config_home(void)
{
   const char *tmp;
   int ret = 1;

   efreet_shutdown();
   setenv("XDG_CONFIG_HOME", "/var/tmp", 1);
   efreet_init();

   tmp = efreet_config_home_get();
   if (strcmp(tmp, "/var/tmp"))
     {
        printf("efreet_config_home_get() returned incorrect "
               "value (%s) on XDG_CONFIG_HOME=/var/tmp\n", tmp);
        ret = 0;
     }

   /* reset efreet here so we can set a new home dir */
   efreet_shutdown();
   unsetenv("XDG_CONFIG_HOME");
   setenv("HOME", "/home/tmp", 1);
   efreet_init();

   tmp = efreet_config_home_get();
   if (strcmp(tmp, "/home/tmp/.config"))
     {
        printf("efreet_config_home_get() returned incorrect "
               "value (%s) on blank XDG_CONFIG_HOME\n", tmp);
        ret = 0;
     }

   /* reset efreet here so we can set a new home dir */
   efreet_shutdown();
   unsetenv("XDG_CONFIG_HOME");
   unsetenv("HOME");
#ifdef _WIN32
   unsetenv("USERPROFILE");
#endif
   efreet_init();

   tmp = efreet_config_home_get();
   if (strcmp(tmp, "/tmp/.config"))
     {
        printf("efreet_config_home_get() returned incorrect "
               "value (%s) on blank XDG_CONFIG_HOME and blank HOME\n", tmp);
        ret = 0;
     }

   return ret;
}
Exemplo n.º 2
0
char *_bks_model_path_get(void) {

   char *path = NULL;   
   FILE *fp;
   int c,i;
   path = calloc(MAX_PATH,1);
   fname = calloc(MAX_PATH,1);
   snprintf(fname, (MAX_PATH - 1), "%s/bksystem/" BKS_DB_PATH_FILE, efreet_config_home_get());
   if (!ecore_file_exists(fname))
      ecore_file_mkpath(ecore_file_dir_get(fname));
   fp = fopen(fname, "r");
   i = 0;
   if (fp) {
      c = fgetc(fp);
      while (c != EOF && c != '\n' && i < (MAX_PATH - 1)) {
         *(path + i) = c;
         i++;
         c = fgetc(fp);   
      }
      *(path + i) = '\0';
      fclose(fp);
   } else {
      fprintf(stderr, "cannot open file: %s \n", fname);
      free(path);
      path = NULL;
   }
   return path;
}
Exemplo n.º 3
0
Arquivo: config.c Projeto: Yomi0/jesus
void
config_flush(void)
{
   Eet_File *cf;
   char path[PATH_MAX];

   if (!config)
     return;

   snprintf(path, sizeof(path), "%s/%s", efreet_config_home_get(), "jesus.eet");

   cf = eet_open(path, EET_FILE_MODE_WRITE);

   if (!cf)
     {
        printf("Failed to open config file");
     }


   if (!eet_data_write(cf, edd, CONFIG_KEY, config, 0))
     {
        printf("Failed to write config file");
     }

   eet_close(cf);
}
Exemplo n.º 4
0
static void
_print_config_home(void)
{
   const char *s = efreet_config_home_get();
   if (!s) return;
   fputs(s, stdout);
}
Exemplo n.º 5
0
Arquivo: config.c Projeto: Yomi0/jesus
void
_config_read()
{
   Eet_File *cf;
   char path[PATH_MAX];

   if (config)
     {
        _config_free(config);
        config = NULL;
     }

   snprintf(path, sizeof(path), "%s/%s", efreet_config_home_get(), "jesus.eet");

   cf = eet_open(path, EET_FILE_MODE_READ);

   if (cf)
     {
        config = eet_data_read(cf, edd, CONFIG_KEY);
        eet_close(cf);
     }

   if (!config)
     {
        config = _config_standart_new();
        config_flush();
     }
}
Exemplo n.º 6
0
static void
_wkb_name_acquired_cb(void *data, const Eldbus_Message *msg)
{
   const char *name, *path;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "s", &name))
     {
        ERR("Error reading message arguments");
        return;
     }

   DBG("NameAcquired: '%s'", name);

   if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0)
     {
        wkb_ibus->panel = wkb_ibus_panel_register(wkb_ibus->conn);
        INF("Registering Panel Interface: %s", wkb_ibus->panel ? "Success" : "Fail");
     }
   else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0)
     {
        path = eina_stringshare_printf("%s/wkb-ibus-cfg.eet", efreet_config_home_get());
        wkb_ibus->config = wkb_ibus_config_register(wkb_ibus->conn, path);
        eina_stringshare_del(path);
        INF("Registering Config Interface: %s", wkb_ibus->config ? "Success" : "Fail");
     }
   else
     {
        WRN("Unexpected name %s", name);
     }
}
Exemplo n.º 7
0
Arquivo: utils.c Projeto: GeeXboX/enna
int
enna_util_init()
{
    EVT("enna util init");

    /* Prevent multiple loads */
    if (_util_init_count > 0)
        return ++_util_init_count;

    sd = calloc(1, sizeof(Smart_Data));
    sd->cache = eina_stringshare_printf("%s/%s", efreet_cache_home_get(), "/enna");
    sd->config = eina_stringshare_printf("%s/%s", efreet_config_home_get(), "/enna");
    sd->data = eina_stringshare_printf("%s/%s", efreet_data_home_get(), "/enna");

    if (!ecore_file_is_dir(sd->cache))
        ecore_file_mkdir(sd->cache);

    if (!ecore_file_is_dir(sd->config))
        ecore_file_mkdir(sd->config);

    if (!ecore_file_is_dir(sd->data))
        ecore_file_mkdir(sd->data);


    DBG("Set data directory to %s", sd->data);
    DBG("Set config directory to : %s", sd->config);
    DBG("Set cache directory to : %s", sd->cache);

    _util_init_count = 1;
    EVT("enna util init done");

    return 1;
}
Exemplo n.º 8
0
/**
 * Returns a list of .menu files found in the various config dirs.
 * @return An eina list of menu file paths (const char *). This must be freed with EINA_LIST_FREE.
 */
EAPI Eina_List *
efreet_util_menus_find(void)
{
    Eina_List *menus = NULL;
    Eina_List *dirs, *l;
    const char *dir;

    menus = efreet_util_menus_find_helper(menus, efreet_config_home_get());

    dirs = efreet_config_dirs_get();
    EINA_LIST_FOREACH(dirs, l, dir)
        menus = efreet_util_menus_find_helper(menus, dir);

    return menus;
}
Exemplo n.º 9
0
const char *
theme_path_get(const char *name)
{
   static char path1[PATH_MAX] = "";
   static char path2[PATH_MAX] = "";

   /* use the newer file */
   struct stat s2;

   snprintf(path2, sizeof(path2) - 1, "%s/terminology/themes/%s",
            efreet_config_home_get(), name);

   if (stat(path2, &s2) == 0) return path2;
   snprintf(path1, sizeof(path1) - 1, "%s/themes/%s",
            elm_app_data_dir_get(), name);
   return path1;
}
Exemplo n.º 10
0
static void
_wkb_name_acquired_cb(void *data, const Eldbus_Message *msg)
{
   const char *name, *path;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "s", &name))
     {
        ERR("Error reading message arguments");
        return;
     }

   DBG("NameAcquired: '%s'", name);

   if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0)
     {
        wkb_ibus->panel = wkb_ibus_panel_register(wkb_ibus->conn);
        INF("Registering Panel Interface: %s", wkb_ibus->panel ? "Success" : "Fail");
     }
   else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0)
     {
        path = eina_stringshare_printf("%s/wkb-ibus-cfg.eet", efreet_config_home_get());
        wkb_ibus->config = wkb_ibus_config_register(wkb_ibus->conn, path);
        eina_stringshare_del(path);
        INF("Registering Config Interface: %s", wkb_ibus->config ? "Success" : "Fail");
        if (wkb_ibus->config)
          {
             Eldbus_Object *obj = eldbus_object_get(wkb_ibus->conn, IBUS_SERVICE_CONFIG, IBUS_PATH_CONFIG);
             Eldbus_Proxy *config = eldbus_proxy_get(obj, IBUS_INTERFACE_CONFIG);
             eldbus_proxy_signal_handler_add(config, "ValueChanged", _wkb_config_value_changed_cb, wkb_ibus);
          }
     }
   else
     {
        INF("Unexpected name %s, ignoring", name);
     }
}
Exemplo n.º 11
0
E_API char *
e_util_shell_env_path_eval(const char *path)
{
   /* evaluate things like:
    * $HOME/bling -> /home/user/bling
    * $HOME/bin/$HOSTNAME/blah -> /home/user/bin/localhost/blah
    * etc. etc.
    */
   const char *p, *v2, *v1 = NULL;
   char buf[PATH_MAX], *pd, *s, *vp;
   char *v = NULL;
   int esc = 0, invar = 0;

   for (p = path, pd = buf; (pd < (buf + sizeof(buf) - 1)); p++)
     {
        if (invar)
          {
             if (!((isalnum(*p)) || (*p == '_')))
               {
                  v2 = p;
                  invar = 0;
                  if ((v2 - v1) > 1)
                    {
                       s = alloca(v2 - v1);
                       strncpy(s, v1 + 1, v2 - v1 - 1);
                       s[v2 - v1 - 1] = 0;
                       if (strncmp(s, "XDG", 3))
                         v = getenv(s);
                       else
                         {
                            if (!strcmp(s, "XDG_CONFIG_HOME"))
                              v = (char *)efreet_config_home_get();
                            else if (!strcmp(s, "XDG_CACHE_HOME"))
                              v = (char *)efreet_cache_home_get();
                            else if (!strcmp(s, "XDG_DATA_HOME"))
                              v = (char *)efreet_data_home_get();
                            else if (!strcmp(s, "XDG_DESKTOP_DIR"))
                              v = (char *)efreet_desktop_dir_get();
                            else if (!strcmp(s, "XDG_DOWNLOAD_DIR"))
                              v = (char *)efreet_download_dir_get();
                            else if (!strcmp(s, "XDG_TEMPLATES_DIR"))
                              v = (char *)efreet_templates_dir_get();
                            else if (!strcmp(s, "XDG_PUBLICSHARE_DIR"))
                              v = (char *)efreet_public_share_dir_get();
                            else if (!strcmp(s, "XDG_DOCUMENTS_DIR"))
                              v = (char *)efreet_documents_dir_get();
                            else if (!strcmp(s, "XDG_MUSIC_DIR"))
                              v = (char *)efreet_music_dir_get();
                            else if (!strcmp(s, "XDG_PICTURES_DIR"))
                              v = (char *)efreet_pictures_dir_get();
                            else if (!strcmp(s, "XDG_VIDEOS_DIR"))
                              v = (char *)efreet_videos_dir_get();
                            else if (!strcmp(s, "XDG_RUNTIME_DIR"))
                              v = (char *)efreet_runtime_dir_get();
                         }

                       if (v)
                         {
                            vp = v;
                            while ((*vp) && (pd < (buf + sizeof(buf) - 1)))
                              {
                                 *pd = *vp;
                                 vp++;
                                 pd++;
                              }
                         }
                    }
                  if (pd < (buf + sizeof(buf) - 1))
                    {
                       *pd = *p;
                       pd++;
                    }
               }
          }
        else
          {
             if (esc)
               {
                  *pd = *p;
                  pd++;
               }
             else
               {
                  if (*p == '\\') esc = 1;
                  else if (*p == '$')
                    {
                       invar = 1;
                       v1 = p;
                    }
                  else
                    {
                       *pd = *p;
                       pd++;
                    }
               }
          }
        if (*p == 0) break;
     }
   *pd = 0;
   return strdup(buf);
}