Esempio n. 1
0
static int
_evas_gl_common_shader_binary_init(Evas_GL_Shared *shared)
{
   Eet_File *ef = NULL;
   char bin_dir_path[PATH_MAX];
   char bin_file_path[PATH_MAX];

   if (!shared || !shared->info.bin_program)
     return 1;

   if (shared->shaders_cache)
     return 1;

   if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path)))
     return 0;

   if (!evas_gl_common_file_cache_file_check(bin_dir_path, SHADER_EET_CACHENAME,
                                             bin_file_path, sizeof(bin_dir_path)))
     return 0;

   if (!eet_init()) return 0;
   ef = eet_open(bin_file_path, EET_FILE_MODE_READ);
   if (!_evas_gl_common_shader_binary_checksum_check(shared, ef))
     goto error;

   shared->shaders_cache = ef;
   return 1;

error:
   if (ef) eet_close(ef);
   eet_shutdown();
   return 0;
}
Esempio n. 2
0
void _show_hs(void *data, Evas_Object *obj, void *event_info)
{
	elm_genlist_clear(highscores_genlist);
	if(!_itc)
	{
		_itc = elm_genlist_item_class_new();
        _itc->item_style = "default";
        _itc->func.text_get = _item_label_get;
        _itc->func.content_get = NULL;
        _itc->func.state_get = NULL;
        _itc->func.del = NULL;
	}

	Eet_File *eef = eet_open(RESULTS_FILE, EET_FILE_MODE_READ);
	int game_type = (int)(uintptr_t)(data);
	int j = 0;
	for(; j < 10; ++j)
	{
		char buf[50];
		int *res;
		sprintf(buf, "%d%d", game_type, j);
			
		res = eet_read(eef, buf, NULL);
		if(res && res[0] != -1)
		{
			elm_genlist_item_append(highscores_genlist, _itc, res, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
		}
	}
		//free(res); //MEMORY LEAK?
	
	eet_close(eef);
}
void
on_btn_save_clicked(Etk_Object *object, void *data)
{
  Cover_Entry *ce;
  Eet_File *ef;
  Eina_List *list;
  char *cover_file;

  list = cover_changed;
  asprintf(&cover_file, "%s/.e/apps/emphasis/cover.eet", getenv("HOME"));
  ef = eet_open(cover_file, EET_FILE_MODE_READ_WRITE);
  if (!ef)
    {
      fprintf(stderr, "can't open %s\n", cover_file);
      free(cover_file);
      return;
    }

  while (cover_changed)
    {
      ce = eina_list_data_get(cover_changed);
      eet_write(ef, ce->key, ce->path, strlen(ce->path)+1, 0);
      eet_clearcache();
      free(ce->key);
      free(ce->path);
      free(ce);
      cover_changed = eina_list_next(cover_changed);
    }
  eina_list_free(list);
  eet_close(ef);
  free(cover_file);
}
Esempio n. 4
0
static My_Conf_Type *
_my_conf_load(const char *filename)
{
   My_Conf_Type *my_conf;
   Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
   if (!ef)
     {
        fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
        return NULL;
     }

   my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
   if (!my_conf)
     goto end;

   if (my_conf->version < 0x112233)
     {
        fprintf(stderr,
                "WARNING: version %#x was too old, upgrading it to %#x\n",
                my_conf->version, 0x112233);

        my_conf->version = 0x112233;
        my_conf->enabled = EINA_TRUE;
     }

end:
   eet_close(ef);
   return my_conf;
} /* _my_conf_load */
static int
_ephoto_config_load(Ephoto *ephoto)
{
   Eet_File *ef;
   char buf[4096], buf2[4096];

   snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME"));
   ecore_file_mkpath(buf2);
   snprintf(buf, sizeof(buf), "%s/ephoto.cfg", buf2);

   ef = eet_open(buf, EET_FILE_MODE_READ);
   if (!ef)
     {
        ephoto_config_free(ephoto);
        ephoto->config = calloc(1, sizeof(Ephoto_Config));
        return 0;
     }

   ephoto->config = eet_data_read(ef, edd, "config");
   eet_close(ef);

   if (!ephoto->config || ephoto->config->config_version > CONFIG_VERSION)
     {
        ephoto_config_free(ephoto);
        ephoto->config = calloc(1, sizeof(Ephoto_Config));
        return 0;
     }

   if (ephoto->config->config_version < CONFIG_VERSION)
     return -1;

   return 1;
}
Esempio n. 6
0
char *
emphasis_cover_db_search(const char *artist, const char *album)
{
  char *config_path;
  char *cover_path = NULL;
  char *key;
  int size;
  void *cover = NULL;
  Eet_File *ef;

  asprintf(&config_path, "%s/.e/apps/emphasis/cover.eet", getenv("HOME"));

  ef = eet_open(config_path, EET_FILE_MODE_READ);

  asprintf(&key, "/%s/%s", artist, album);

  cover_path = eet_read(ef, key, &size);
  eet_close(ef);

  if (!cover_path)
    {
      cover = emphasis_cover_file_get_from_amazon(artist, album, &size);
      cover_path = emphasis_cover_db_add(artist, album, cover, size);
    }
  if (cover_path && !strcmp(cover_path, "not found"))
    {
      free(cover_path);
      cover_path = NULL;
    }

  free(config_path);
  free(key);

  return cover_path;
}
void Config::saveStateCache()
{
    Eet_File *ef;
    std::string file = Utils::getCacheFile("iostates.cache");
    std::string tmp = file + "_tmp";
    ConfigStateCache *cache;

    cache = new ConfigStateCache;
    cache->version = CONFIG_STATES_CACHE_VERSION;
    cache->states = cache_states;

    ef = eet_open(tmp.c_str(), EET_FILE_MODE_WRITE);
    if (!ef)
    {
        cWarning() <<  "Could not open iostates.cache for write !";
        delete cache;
        return;
    }

    Eina_Bool ret = eet_data_write(ef, edd_cache, "calaos/states/cache", cache, EINA_TRUE);

    eet_close(ef);
    delete cache;

    if (ret)
    {
        ecore_file_unlink(file.c_str());
        ecore_file_mv(tmp.c_str(), file.c_str());
    }

    cInfo() <<  "State cache file written successfully (" << file << ")";
}
Esempio n. 8
0
/**
 * @brief Saves Etk's config to disk
 * @return Returns ETK_TRUE on a successful save, ETK_FALSE otherwise.
 */
Etk_Bool etk_config_save(void)
{
   Eet_File *ef;
   char buf[PATH_MAX];
   char *home;
   Etk_Bool ret;

   home = getenv("HOME");
   if (!home)
     return 0;

   snprintf(buf, sizeof(buf), "%s/.e/etk/config.eet", home);

   ef = eet_open(buf, EET_FILE_MODE_WRITE);
   if (!ef)
     return 0;

   ret = eet_data_write(ef, _etk_config_ver_edd, "config/version",
			_etk_config->version, 1);
   if (!ret)
     ETK_WARNING("Problem saving config!");

   ret = eet_data_write(ef, _etk_config_gen_edd, "config/general",
			_etk_config->general, 1);
   if (!ret)
     ETK_WARNING("Problem saving config/stickies!");

   eet_close(ef);
   return ret;
}
Esempio n. 9
0
/* check if old and new caches contain the same number of entries,
 * and are the same version */
static int
check_changed(const char *old_name, Eet_File *new_ef,
              unsigned char major, unsigned char minor)
{
   Eet_File *old_ef;
   Efreet_Cache_Version *old_version = NULL;

   old_ef = eet_open(old_name, EET_FILE_MODE_READ);
   if (!old_ef) return 1;
   if (eet_num_entries(old_ef) != eet_num_entries(new_ef))
     goto changed;

   old_version = eet_data_read(old_ef, efreet_version_edd(), EFREET_CACHE_VERSION);
   if (!old_version)
     goto changed;

   if ((old_version->major != major) ||
       (old_version->minor != minor))
     goto changed;

   free(old_version);
   eet_close(old_ef);
   return 0;

changed:
   free(old_version);
   eet_close(old_ef);
   return 1;
}
Esempio n. 10
0
static Eet_File *
_open_temp_eet(Eina_Tmpstr **path, const char *rel)
{
   Eet_File *ef;
   int tmpfd;
   char buffer[PATH_MAX];

   {
      char *tmp;

      tmp = strdup(rel);
      snprintf(buffer, sizeof(buffer), "%s/efreet/%s.XXXXXX.cache",
               efreet_cache_home_get(), basename(tmp));
      free(tmp);
   }

   tmpfd = eina_file_mkstemp(buffer, path);
   if (tmpfd < 0) return NULL;
   close(tmpfd);

   ef = eet_open(*path, EET_FILE_MODE_READ_WRITE);
   if (!ef) goto on_error;

   return ef;

 on_error:
   eina_tmpstr_del(*path);
   *path = NULL;

   return NULL;
}
Esempio n. 11
0
static void
_open_era(const char *era)
{
   char my_getcwd[1024];
   char my_path2[1024];
   char my_path[1024];

   if (_export_type == EET)
     {
#ifdef HAVE_EET
        snprintf(my_path2, sizeof(my_path2),
                 "%s/tiles/eet", getcwd(my_getcwd, sizeof(my_getcwd)));
        ecore_file_mkpath(my_path2);
        snprintf(my_path, sizeof(my_path), "%s/%s.eet", my_path2, era);
        _ef = eet_open(my_path, EET_FILE_MODE_WRITE);
#endif
     }
   else if (_export_type == ATLAS)
     {
#ifdef HAVE_CAIRO
        _cairo.img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
                                                0x10 * TILE_H,
                                                14 * 9 * TILE_W + 0xc * TILE_W);
        _cairo.cr = cairo_create(_cairo.img);

        snprintf(my_path2, sizeof(my_path2),
                 "%s/tiles/atlas", getcwd(my_getcwd, sizeof(my_getcwd)));
        ecore_file_mkpath(my_path2);
        snprintf(my_path, sizeof(my_path), "%s/%s.png", my_path2, era);
        _cairo.png = strdup(my_path);
#endif
     }
}
Esempio n. 12
0
File: config.c Progetto: 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);
}
Esempio n. 13
0
/*
 * @brief load the list of interfaces from a file
 * @param file the configuration file
 * @return Returns the list of interfaces
 */
Boot_Process_List *waiting_iface_load(const char* file)
{
    Eet_Data_Descriptor*edd;
    Eet_File *f;
    Boot_Process_List *data;

    edd = waiting_iface_edd_new();
    f = eet_open(file, EET_FILE_MODE_READ);

    EXALT_ASSERT_ADV(f!=NULL,
                            data = malloc(sizeof(Boot_Process_List));
                            data->timeout = 30;
                            data->l=NULL,
                    "f!=NULL failed");

    data = eet_data_read(f, edd, "boot process interface list");
    eet_close(f);
    eet_data_descriptor_free(edd);

    EXALT_ASSERT_ADV(data!=NULL,
                            data = malloc(sizeof(Boot_Process_List));
                            data->timeout = 30;
                            data->l=NULL,
                    "data!=NULL failed");

    return data;
}
Esempio n. 14
0
File: config.c Progetto: 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();
     }
}
Esempio n. 15
0
static Eina_Bool
_ephoto_on_config_save(void *data)
{
   Ephoto *ephoto = data;
   Eet_File *ef;
   char buf[4096], buf2[4096];

   snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME"));
   snprintf(buf2, sizeof(buf2), "%s.tmp", buf);

   ef = eet_open(buf2, EET_FILE_MODE_WRITE);
   if (!ef) goto save_end;

   eet_data_write(ef, edd, "config", ephoto->config, 1);
   if (eet_close(ef)) goto save_end;

   if (!ecore_file_mv(buf2, buf)) goto save_end;

   INF("Config saved");

save_end:
   ecore_file_unlink(buf2);

   if (save_timer)
     {
        ecore_timer_del(save_timer);
        save_timer = NULL;
     }

   return ECORE_CALLBACK_CANCEL;
}
Esempio n. 16
0
/**
 * @brief Save the connection associated to an essid in the configuration file
 * @param file the configuration file
 * @param c the connection
 * @return Returns 1 if success, else 0
 */
int _exalt_eet_wireless_conn_save(const char*file, Exalt_Connection* c)
{
    Eet_Data_Descriptor* edd;
    Eet_File* f;
    int res;

    edd = exalt_conn_edd_new();
    f = eet_open(file, EET_FILE_MODE_READ_WRITE);
    if(!f)
        f = eet_open(file, EET_FILE_MODE_WRITE);
    res=eet_data_write(f, edd,exalt_conn_get_essid(c), c, 0);
    EXALT_ASSERT(res!=0);

    eet_close(f);
    eet_data_descriptor_free(edd);
    return res;
}
Esempio n. 17
0
static void
_eio_eet_open_job(void *data, Ecore_Thread *thread)
{
    Eio_Eet_Open *eet = data;

    eet->result = eet_open(eet->filename, eet->mode);
    if (!eet->result) eio_file_thread_error(&eet->common, thread);
}
Esempio n. 18
0
/**
 * @brief Save a Exalt_Eth_Save structure in the configuration file
 * @param file the configuration file
 * @param s the Exalt_Eth_Save strucuture
 * @param udi the hal udi of the interface
 * @return Returns 1 if success, else 0
 */
int _exalt_eet_eth_save(const char* file, Exalt_Eth_Save* s, const char* udi)
{
    Eet_Data_Descriptor *edd;
    Eet_File* f;
    int res;

    edd = _exalt_eth_save_edd_new();
    f = eet_open(file, EET_FILE_MODE_READ_WRITE);
    if(!f)
        f = eet_open(file, EET_FILE_MODE_WRITE);
    res=eet_data_write(f, edd,udi, s, 0);
    EXALT_ASSERT(res!=0);

    eet_close(f);
    eet_data_descriptor_free(edd);
    return res;
}
Esempio n. 19
0
File: config.c Progetto: Limsik/e17
static Eina_Bool
config_save(Eet_Data_Descriptor *descriptor, const char *filename, const char *section, const void *data)
{
  Eet_File *ef;
  FILE *f;
  char buffer[PATH_MAX];
  int i;

  /* human readable version */
  snprintf(buffer, PATH_MAX, "%s.%s", filename, section);
  f = fopen(buffer, "w");
  if (!f) {
    fprintf(stderr, "Not able to open human readable config file.\n");
    goto on_error;
  }

  /* save the configuration */
  snprintf(buffer, PATH_MAX, "%s.eet", filename);
  ef = eet_open(buffer, EET_FILE_MODE_READ_WRITE);
  if (!ef) {
    fprintf(stderr, "Not able to open config file for read write mode.\n");
    goto on_error;
  }
  
  if (!eet_data_write(ef, descriptor, section, data, 1)) {
    fprintf(stderr, "Can't write data inside the config file.\n");
    goto on_write_error;
  }

  if (!eet_data_dump(ef, section, invert_fputs, f)) {
    fprintf(stderr, "Can't dump section `%s`.\n");
    goto on_write_error;
  }

  eet_close(ef);
  sleep(2);
  fclose(f);

  return EINA_TRUE;

 on_write_error:
  eet_close(ef);

  snprintf(buffer, PATH_MAX, "%s.eet", filename);
  unlink(buffer);

 on_error:
  if (f)
    {
      fclose(f);

      snprintf(buffer, PATH_MAX, "%s.%s", filename, section);
      unlink(buffer);
    }

  return EINA_FALSE;
}
Esempio n. 20
0
int
ex_config_write(Extrackt *ex)
{
   Eet_File  *ef;
   char       buf[PATH_MAX];
   char      *home;
   int        ret;
   Eina_List *l;
   
   home = getenv("HOME");
   if(!home)
     return 0;
   
   snprintf(buf, sizeof(buf), "%s/.e/extrackt/config.eet", home);
   
   ef = eet_open(buf, EET_FILE_MODE_WRITE);
   if(!ef) 
     return 0;

   ret = eet_data_write(ef, _ex_config_version_edd, "config/version", ex->config.version, 1);
   if(!ret)
     DEBUG(_("Problem saving config!"));   
   
   ret = eet_data_write(ef, _ex_config_cd_edd, "config/cd", ex->config.cd, 1);
   if(!ret)
     DEBUG(_("Problem saving config!"));
   
   ret = eet_data_write(ef, _ex_config_cddb_edd, "config/cddb", ex->config.cddb, 1);
   if(!ret)
     DEBUG(_("Problem saving config!"));
   
   for(l = ex->config.rippers; l; l = l->next)
     {
	Ex_Config_Exe *ripper;
	char          *buf;
	int            size;
	
	ripper = l->data;
	size = strlen("config/rippers/") + strlen(ripper->name) + 1;
	buf = E_NEW(size, char);
	snprintf(buf, size, "config/rippers/%s", ripper->name);
	
	ret = eet_data_write(ef, _ex_config_exe_edd, buf, ripper, 1);
	if(!ret)
	  DEBUG(_("Problem saving config!"));	
     }
   
   ret = eet_data_write(ef, _ex_config_encode_edd, "config/encode", ex->config.encode, 1);
   if(!ret)
     DEBUG(_("Problem saving config!"));
   
   eet_close(ef);
   return ret;
}
Esempio n. 21
0
/*
 * @brief save the list of interfaces
 * @param l the list
 * @param file the configuration file
 */
void waiting_iface_save(const Boot_Process_List* l, const char* file)
{
    Eet_Data_Descriptor* edd;
    Eet_File* f;

    EXALT_ASSERT_RETURN_VOID(l!=NULL);
    EXALT_ASSERT_RETURN_VOID(file!=NULL);

    edd = waiting_iface_edd_new();
    f = eet_open(file, EET_FILE_MODE_READ_WRITE);

    if(!f)
    {
        f = eet_open(file, EET_FILE_MODE_WRITE);
    }
    eet_data_write(f, edd,"boot process interface list", l, 0);

    eet_close(f);
    eet_data_descriptor_free(edd);
}
int
main(int argc, char **argv)
{
    Eet_File *theme_ef;
    Eina_List *l = NULL;
    Efreet_Icon_Theme *theme;
    int i;

    efreet_cache_update = 0;

    if (!efreet_init()) return -1;

    theme_ef = eet_open(efreet_icon_theme_cache_file(), EET_FILE_MODE_READ);
    if (!theme_ef) return -1;

    if (argc > 1)
    {
        for (i = 1; i < argc; i++)
        {
            theme = eet_data_read(theme_ef, efreet_icon_theme_edd(EINA_FALSE), argv[i]);
            if (theme) l = eina_list_append(l, theme);
        }
    }
    else
    {
        char **keys;
        int num;

        keys = eet_list(theme_ef, "*", &num);
        if (keys)
        {
            for (i = 0; i < num; i++)
            {
                theme = eet_data_read(theme_ef, efreet_icon_theme_edd(EINA_FALSE), keys[i]);
                if (theme) l = eina_list_append(l, theme);
            }
            free(keys);
        }
    }

    EINA_LIST_FREE(l, theme)
    {
        void *data;

        dump(theme);

        /* free theme */
        eina_list_free(theme->paths);
        eina_list_free(theme->inherits);
        EINA_LIST_FREE(theme->directories, data)
        free(data);
        free(theme);
    }
static int
_evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
{
   /* check eet */
   Eet_File *et = NULL; //check eet file
   int tmpfd;
   int res = 0;
   char bin_dir_path[PATH_MAX];
   char bin_file_path[PATH_MAX];
   char tmp_file[PATH_MAX];
   unsigned int i;

   if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path)))
     {
        res = _evas_gl_shader_file_mkpath(bin_dir_path);
        if (!res) return 0; /* we can't make directory */
     }

   _evas_gl_shader_file_check(bin_dir_path, bin_file_path,
                              sizeof(bin_dir_path));

   /* use mkstemp for writing */
   snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path);
   tmpfd = mkstemp(tmp_file);
   if (tmpfd < 0) goto error;
   close(tmpfd);

   /* use eet */
   if (!eet_init()) goto error;

   et = eet_open(tmp_file, EET_FILE_MODE_WRITE);
   if (!et) goto error;

   for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i)
     if (!_evas_gl_common_shader_program_binary_save(&(shared->shader[_shaders_source[i].id]),
                                                     _shaders_source[i].name,
                                                     et))
       goto error;

   if (eet_close(et) != EET_ERROR_NONE) goto error;
   if (rename(tmp_file,bin_file_path) < 0) goto error;
   eet_shutdown();
   return 1;

error:
   if (et) eet_close(et);
   if (_evas_gl_shader_file_exists(tmp_file)) unlink(tmp_file);
   eet_shutdown();
   return 0;
}
Esempio n. 24
0
static void _eli_highscore_write(const char * game)
{
    Eli_Highscore hiscore;
    Eet_File * file;
  
    hiscore.entries = eli_highscore_get(game);

    if (!hiscore.entries) return;
    if (ecore_file_exists(eet_file_name)) {
        file = eet_open(eet_file_name, EET_FILE_MODE_READ_WRITE);
	if (!file) fprintf(stderr, "Could not open file %s!\n", eet_file_name);
    }
    else {
        file = eet_open(eet_file_name, EET_FILE_MODE_WRITE);
        if (!file) fprintf(stderr, "Could not create file %s\n!", 
			eet_file_name);
    }

    if (file) {
	eet_data_write(file, edd_hiscore, game, &hiscore, 1);
	eet_close(file);
    }
}
Esempio n. 25
0
int
main(void)
{
   Eet_File *ef;
   char *ret;
   int size;
   char *entries[] =
   {
      "Entry 1",
      "Big text string here compared to others",
      "Eet is cool"
   };

   eet_init();

   // blindly open an file for output and write strings with their NUL char
   ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
   eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
   eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
   eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
   eet_close(ef);

   // open the file again and blindly get the entries we wrote
   ef = eet_open("test.eet", EET_FILE_MODE_READ);
   ret = eet_read(ef, "Entry 1", &size);
   printf("%s\n", ret);
   free(ret);
   ret = eet_read(ef, "Entry 2", &size);
   printf("%s\n", ret);
   free(ret);
   ret = eet_read(ef, "Entry 3", &size);
   printf("%s\n", ret);
   free(ret);
   eet_close(ef);

   eet_shutdown();
}
Esempio n. 26
0
static void storage_rewrite_all_items(StorageData *sd)
{
	CALLED();
	if (sd->ef)
		eet_close(sd->ef);
	ecore_file_remove(STORAGE_FILEPATH);
	sd->ef = eet_open(STORAGE_FILEPATH, EET_FILE_MODE_READ_WRITE);

	int i;
	for (i = 0; i < STORAGE_ITEM_CNT; i++)
	{
		if ((sd->indexTable[i] != STORAGE_INDEX_ITEM_NONE) && (sd->itemTable[i]))
			item_write(sd->ef, i, sd->itemTable[i]);
	}
	storage_index_write(sd);
}
Esempio n. 27
0
void
fill_tree_with_db(Etk_Tree *tree)
{
  int num, i;
  char **entries;
  char *cover_path;
  Etk_Tree_Col *col;
  Etk_Tree_Row *row;
  Eet_File *ef;
  char *cover_db_path;

  asprintf(&cover_db_path, "%s/.e/apps/emphasis/cover.eet", getenv("HOME"));
  ef = eet_open(cover_db_path, EET_FILE_MODE_READ);
  if (!ef)
    {
      fprintf(stderr, "Can't open %s\n", cover_db_path);
      free(cover_db_path);
      exit(-1);
    }

  col = etk_tree_col_new(tree, "/artist/album", 0, 0.0);
  etk_tree_col_model_add(col, etk_tree_model_text_new());
  etk_tree_build(tree);
  etk_tree_freeze(tree);

  entries = eet_list(ef, "*", &num);

  for (i=0; i<num; i++)
    {
      cover_path = eet_read(ef, entries[i], NULL);
      row = etk_tree_row_append(tree, NULL, col, entries[i], NULL);
      if (strcmp("not found", cover_path))
        {
          etk_tree_row_data_set(row, cover_path);
        }
      else
        {
          etk_tree_row_data_set(row, NULL);
        }
    }

  eet_close(ef);
  free(cover_db_path);

  etk_tree_col_sort_set(etk_tree_nth_col_get(tree, 0), tree_sort, NULL);
  etk_tree_thaw(tree);
}
Esempio n. 28
0
/**
 * @brief Load the information about an interface from the configuration file
 * The information are saved in a Exalt_Eth_Save structure
 * @param file the configuration file
 * @param udi the hal udi of the interface
 * @return Returns the information
 */
Exalt_Eth_Save* _exalt_eet_eth_load(const char* file, const char* udi)
{
    Exalt_Eth_Save *data = NULL;
    Eet_Data_Descriptor *edd;
    Eet_File *f;

    edd = _exalt_eth_save_edd_new();

    f = eet_open(file, EET_FILE_MODE_READ);
    EXALT_ASSERT_RETURN(f!=NULL);

    data = eet_data_read(f, edd, udi);

    eet_close(f);
    eet_data_descriptor_free(edd);
    return data;
}
Esempio n. 29
0
/**
 * @brief Load the connection associated to an essid from the configuration file
 * @param file the configuration file
 * @param essid the essid
 * @return Returns the connection if success, else NULL
 */
Exalt_Connection* _exalt_eet_wireless_conn_load(const char*file, const char* essid)
{
    Exalt_Connection *data = NULL;
    Eet_Data_Descriptor *edd;
    Eet_File *f;

    edd = exalt_conn_edd_new();

    f = eet_open(file, EET_FILE_MODE_READ);
    EXALT_ASSERT_RETURN(f!=NULL);

    data = eet_data_read(f, edd, essid);

    eet_close(f);
    eet_data_descriptor_free(edd);
    return data;
}
void Config::loadStateCache()
{
    ConfigStateCache *cache;
    std::string file = Utils::getCacheFile("iostates.cache");

    Eet_File *ef = eet_open(file.c_str(), EET_FILE_MODE_READ);
    if (!ef)
    {
        cWarning() <<  "Could not open iostates.cache for read !";
        return;
    }

    cache = (ConfigStateCache *)eet_data_read(ef, edd_cache, "calaos/states/cache");
    if (!cache)
    {
        eet_close(ef);
        cWarning() <<  "Could not read iostates.cache, corrupted file?";
        return;
    }

    if (cache->version < CONFIG_STATES_CACHE_VERSION)
    {
        cWarning() <<  "File version too old, upgrading to new format";
        cache->version = CONFIG_STATES_CACHE_VERSION;
    }

    //read all states and put it in cache_states
    Eina_Iterator *it = eina_hash_iterator_tuple_new(cache->states);
    void *data;
    while (eina_iterator_next(it, &data))
    {
        Eina_Hash_Tuple *t = (Eina_Hash_Tuple *)data;
        ConfigStateValue *state = (ConfigStateValue *)t->data;
        std::string skey = state->id;
        std::string svalue = state->value;
        SaveValueIO(skey, svalue, false);
    }
    eina_iterator_free(it);

    eina_hash_free(cache->states);
    free(cache);
    eet_close(ef);

    cInfo() <<  "States cache read successfully.";
}