Esempio n. 1
0
static void _activate_file(madshelf_state_t* state, int item_num)
{
    _loc_t* _loc = (_loc_t*)state->loc;
    char* filename = eina_array_data_get(_loc->files, item_num);

    if(!ecore_file_exists(filename))
        return;

    if(ecore_file_is_dir(filename))
    {
        go_to_directory(state, filename);
        return;
    }

    run_default_handler(state, filename);
}
Esempio n. 2
0
static char *
_check_icon(const char *icon, const char *dir, const char *ext)
{
    char tmp[PATH_MAX];
    char *format;
   
    if (ext)
        format = "%s/%s.%s";
    else
        format = "%s/%s";

    snprintf(tmp, sizeof (tmp), format, dir, icon, ext);

    if (!ecore_file_is_dir(tmp) && ecore_file_can_read(tmp))
        return strdup(tmp);
    else
        return NULL;
}
Esempio n. 3
0
static void
bs_gocomics_show (Evas_Object *layout)
{
    char dst[1024] = { 0 };

    mod = calloc (1, sizeof(Bookstore_Service_GoComics));

    /* create comic strips download destination path */
    snprintf(dst, sizeof(dst), "~/.enna/%s",
             GOCOMICS_PATH);
    if (!ecore_file_is_dir(dst))
        if(ecore_file_mkpath(dst)) printf("mkpath true\n");

    mod->path = strdup (dst);
    mod->url = url_new();
    mod->layout = layout;

    gocomics_set_comic_name();
    gocomics_create_menu();
}
Esempio n. 4
0
E_API int
e_util_dir_check(const char *dir)
{
   if (!ecore_file_exists(dir))
     {
        if (!ecore_file_mkpath(dir))
          {
             e_util_dialog_show(_("Error creating directory"), _("Failed to create directory: %s .<br>Check that you have correct permissions set."), dir);
             return 0;
          }
     }
   else
     {
        if (!ecore_file_is_dir(dir))
          {
             e_util_dialog_show(_("Error creating directory"), _("Failed to create directory: %s .<br>A file of that name already exists."), dir);
             return 0;
          }
     }
   return 1;
}
Esempio n. 5
0
ActivityWidgetsView::ActivityWidgetsView(Evas *_e, Evas_Object *_parent):
        ActivityView(_e, _parent, "calaos/page/widgets")
{
        clipper = evas_object_rectangle_add(evas);
        evas_object_color_set(clipper, 0, 0, 0, 0);
        evas_object_show(clipper);

        Swallow(clipper, "widgets.swallow", true);

        //Create a temporary dir for modules
        if (ecore_file_is_dir("/tmp/calaos_widgets"))
                ecore_file_recursive_rm("/tmp/calaos_widgets");

        ecore_file_mkpath("/tmp/calaos_widgets");

        //add search paths for modules
        ModuleManager::Instance().addPath(PACKAGE_LIB_DIR "/calaos/widgets");
        ModuleManager::Instance().addPath("/usr/lib/calaos/widgets");
        ModuleManager::Instance().SearchModules();

        LoadWidgets();
}
Esempio n. 6
0
static void _walle_wall_populate(Walle *walle, const char *directory, const char *theme)
{
    Evas_Object *o;
    Evas_Coord ow, oh, w, h;
    Eina_List *files = NULL;
    char *file = NULL;
    char filename[4096];

    if (!ecore_file_is_dir(directory) && ecore_file_dir_is_empty(directory))
        return;
    files = ecore_file_ls(directory);
    if (!files)
        return;
    EINA_LIST_FREE(files, file)
    {
    	sprintf(filename, "%s/%s", directory, file);
    	o = evas_object_image_add(walle->evas);
    	evas_object_image_file_set(o, filename, NULL);
    	switch(evas_object_image_load_error_get(o))
    	{
    	case EVAS_LOAD_ERROR_NONE:
    	{
    	    evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _walle_picture_cb_resize, o);
    	    evas_object_image_size_get(o, &w, &h);
    	    oh = 200;
    	    ow = oh * (float)w/(float)h;
    	    evas_object_image_load_size_set(o, ow, oh);
    	    evas_object_image_fill_set(o, 0, 0, ow, oh);
    	    evas_object_resize(o, ow, oh);
    	    evas_object_size_hint_min_set(o, ow, oh);
    	    walle_wall_append(walle->o_wall, o);
    	    walle->pictures = eina_list_append(walle->pictures, o);
    	}
    	break;
    	default:
    	    evas_object_del(o);
    	    break;
    	}
    }
Esempio n. 7
0
static Ems_Config *
_config_get(Eet_Data_Descriptor *edd)
{
   Ems_Config *config = NULL;
   Eet_File *file;

   if (!ecore_file_is_dir(ems_config_tmp_dirname_get()))
     ecore_file_mkdir(ems_config_tmp_dirname_get());
   file = eet_open(ems_config_tmp_filename_get(),
                   EET_FILE_MODE_READ_WRITE);

   config = eet_data_read(file, edd, "config");
   if (!config)
     {
        WRN("Warning no configuration found! This must not happen, we will go back to a void configuration");
        return NULL;
     }

   eet_close(file);

   return config;
}
Esempio n. 8
0
static Eina_List *
efreet_util_menus_find_helper(Eina_List *menus, const char *config_dir)
{
    DIR *files = NULL;
    struct dirent *file = NULL;
    char dbuf[PATH_MAX], fbuf[PATH_MAX];

    snprintf(dbuf, sizeof(dbuf), "%s/menus", config_dir);
    files = opendir(dbuf);
    if (!files) return menus;
    while ((file = readdir(files))) {
        const char *exten;
        exten = strrchr(file->d_name, '.');
        if (!exten) continue;
        if (strcmp(".menu", exten)) continue;

        snprintf(fbuf, sizeof(fbuf), "%s/%s", dbuf, file->d_name);
        if (ecore_file_is_dir(fbuf)) continue;

        menus = eina_list_append(menus, strdup(fbuf));
    }
    closedir(files);
    return menus;
}
Esempio n. 9
0
static void _fill_list (Evasxx::Object *obj)
{
  DIR *d;
  struct dirent *de;
  Eina_List *dirs = NULL, *l;
  char *real;

  if (!(d = opendir(getenv("HOME")))) return;
  while ((de = readdir(d)) != NULL)
  {
    char buff[PATH_MAX];

    if (de->d_name[0] == '.') continue;
    snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name);
    if (!ecore_file_is_dir(buff)) continue;
    real = ecore_file_realpath(buff);
    dirs = eina_list_append(dirs, real);
  }
  closedir(d);

  dirs = eina_list_sort(dirs, eina_list_count(dirs), EINA_COMPARE_CB(strcoll));
#if 0
   EINA_LIST_FOREACH(dirs, l, real)
     {
        Eina_Bool result = EINA_FALSE;

        result = _dir_has_subs(real);
        if (!result)
          elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
                                  NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
        else
          elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
                                  NULL, ELM_GENLIST_ITEM_TREE,
                                  NULL, NULL);
        free(real);
     }
Esempio n. 10
0
/* Sets the folder displayed in the iconbox */
static void _etk_test_iconbox_folder_set(Etk_Iconbox *iconbox, const char *folder)
{
   Eina_List *files;
   Eina_List *l;
   char *filename;
   char file_path[PATH_MAX];
   Etk_Iconbox_Icon *iicon;

   if (!iconbox)
      return;
   if (!folder && !(folder = getenv("HOME")))
      return;
   if (!(files = ecore_file_ls(folder)))
      return;

   etk_iconbox_clear(iconbox);
   etk_iconbox_append(iconbox, etk_theme_icon_path_get(), "actions/go-up_48", "..");

   /* First, add the folders */
   EINA_LIST_FOREACH(files, l, filename)
   {
      if (filename[0] == '.')
         continue;

      snprintf(file_path, PATH_MAX, "%s/%s", folder, filename);
      if (!ecore_file_is_dir(file_path))
         continue;

      iicon = etk_iconbox_append(iconbox, etk_theme_icon_path_get(), "places/folder_48", filename);
      
      if (!ecore_file_can_read(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "unreadable");
      else if (!ecore_file_can_write(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "readonly");
   }

   /* Then the files */
   EINA_LIST_FOREACH(files, l, filename)
   {
      const char *ext;
      char *icon = NULL;
      int i;

      if (filename[0] == '.')
         continue;

      snprintf(file_path, PATH_MAX, "%s/%s", folder, filename);
      if (ecore_file_is_dir(file_path))
         continue;

      if ((ext = strrchr(filename, '.')) && (ext = ext + 1))
      {
         for (i = 0; i < _etk_test_iconbox_num_types; i++)
         {
            if (strcasecmp(ext, _etk_test_iconbox_types[i].extension) == 0)
            {
               icon = _etk_test_iconbox_types[i].icon;
               break;
            }
         }
      }

      iicon = etk_iconbox_append(iconbox, etk_theme_icon_path_get(), icon ? icon : "mimetypes/text-x-generic_48", filename);
      if (!ecore_file_can_read(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "unreadable");
      else if (!ecore_file_can_write(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "readonly");
      else if (ecore_file_can_exec(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "system");
   }

   EINA_LIST_FREE(files, filename)
     free(filename);

   if (!_etk_test_iconbox_current_folder)
      _etk_test_iconbox_current_folder = etk_string_new(NULL);
   etk_string_set(_etk_test_iconbox_current_folder, folder);
   etk_window_title_set(ETK_WINDOW(win), folder);
}
Esempio n. 11
0
/*
 * List depends on:
 *  - state->sort
 *  - state->tags
 *  - state->filter
 *  - dir contents on FS
 */
static Eina_Array *
_fill_files(const madshelf_state_t *state, const char *dir, int *old_pos)
{
    char *old_file = curdir_get(dir);
    if(old_pos) *old_pos = -1;

    Eina_Array *files = eina_array_new(10);

    /* HACK: using global variable to pas state into sort function */
    cur_dir = !strcmp(dir, "/") ? "" : dir;

    Eina_List *ls = ecore_file_ls(dir);
    ls = eina_list_sort(ls, eina_list_count(ls),
                        state->sort == MADSHELF_SORT_NAME ? &_name
                        : (state->sort == MADSHELF_SORT_NAMEREV ? &_namerev
                           : &_daterev));

    /* First select directories */
    for (Eina_List *i = ls; i; i = eina_list_next(i)) {
        const char *file = eina_list_data_get(i);
        char *filename = xasprintf("%s/%s", !strcmp(dir, "/") ? "" : dir, file);

        if (!ecore_file_is_dir(filename)) {
            free(filename);
            continue;
        }

        if (!state->show_hidden && is_hidden(state, filename)) {
            free(filename);
            continue;
        }

        if (old_file && old_pos)
            if (!strcmp(old_file, file))
                *old_pos = eina_array_count_get(files);
        eina_array_push(files, filename);
    }

    /* Then files */
    for (Eina_List *i = ls; i; i = eina_list_next(i)) {
        const char *file = eina_list_data_get(i);
        char *filename = xasprintf("%s/%s", !strcmp(dir, "/") ? "" : dir, file);

        if (ecore_file_is_dir(filename)) {
            free(filename);
            continue;
        }

        if (!state->show_hidden && is_hidden(state, filename)) {
            free(filename);
            continue;
        }

        if (old_file && old_pos)
            if (!strcmp(old_file, file))
                *old_pos = eina_array_count_get(files);
        eina_array_push(files, filename);
    }

    char* s;
    EINA_LIST_FREE(ls, s)
        free(s);

    free(old_file);

    return files;
}
Esempio n. 12
0
/**
 * @brief Download the given url to the given destination.
 *
 * @param  url The complete url to download.
 * @param  dst The local file to save the downloaded to.
 * @param  completion_cb A callback called on download complete.
 * @param  progress_cb A callback called during the download operation.
 * @param  data User data passed to both callbacks.
 * @param  job_ret Job used to abort the download.
 * @return EINA_TRUE if the download start or EINA_FALSE on failure
 *
 * This function starts the download of the URL @p url and saves it to
 * @p dst. @p url must provide the protocol, including 'http://',
 * 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to
 * download using http and ftp protocols. If @p dst is ill-formed, or
 * if it already exists, the function returns EINA_FALSE. When the
 * download is complete, the callback @p completion_cb is called and
 * @p data is passed to it. The @p status parameter of @p completion_cb 
 * will be filled with the status of the download (200, 404,...). The
 * @p progress_cb is called during the download operation, each time a
 * packet is received or when CURL wants. It can be used to display the
 * percentage of the downloaded file. Return 0 from this callback, if provided,
 * to continue the operation or anything else to abort the download. The only
 * operations that can be aborted are those with protocol 'http' or 'ftp'. In 
 * that case @p job_ret can be filled. It can be used with
 * ecore_file_download_abort() or ecore_file_download_abort_all() to
 * respectively abort one or all download operations. This function returns
 * EINA_TRUE if the download starts, EINA_FALSE otherwise.
 */
EAPI Eina_Bool
ecore_file_download(const char *url,
                    const char *dst,
                    Ecore_File_Download_Completion_Cb completion_cb,
                    Ecore_File_Download_Progress_Cb progress_cb,
                    void *data,
                    Ecore_File_Download_Job **job_ret)
{
#ifdef BUILD_ECORE_CON
   char *dir = ecore_file_dir_get(dst);

   if (!ecore_file_is_dir(dir))
     {
	EINA_LOG_ERR("%s is not a directory", dir);
        free(dir);
        return EINA_FALSE;
     }
   free(dir);
   if (ecore_file_exists(dst))
     {
	EINA_LOG_ERR("%s already exists", dst);
	return EINA_FALSE;
     }

   if (!strncmp(url, "file://", 7))
     {
        /* FIXME: Maybe fork? Might take a while to copy.
         * Check filesize? */
        /* Just copy it */

        url += 7;
        /* skip hostname */
        url = strchr(url, '/');
        return ecore_file_cp(url, dst);
     }
# ifdef HAVE_CURL
   else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) ||
            (!strncmp(url, "ftp://", 6)))
     {
        /* download */
        Ecore_File_Download_Job *job;

        job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data);
        if(job_ret) *job_ret = job;
        if(job)
          return EINA_TRUE;
        else
          {
             EINA_LOG_ERR("no job returned\n");
             return EINA_FALSE;
          }
        return job ? EINA_TRUE : EINA_FALSE;
     }
# else
   else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) ||
            (!strncmp(url, "ftp://", 6)))
     {
        (void)completion_cb;
        (void)progress_cb;
        (void)data;
        (void)job_ret;
        return EINA_FALSE;
     }
# endif
   else
     {
        return EINA_FALSE;
     }
#else
   completion_cb = NULL;
   progress_cb = NULL;
   data = NULL;
   return EINA_FALSE;
#endif /* BUILD_ECORE_CON */
}
Esempio n. 13
0
static void
_make_config(const char *config_file)
{
	Eet_File *ef;
	FILE *f;
	int textlen;
	char *text;

	/* Create default config path and file */
	if (!config_file)
	{
		conf_filename = eina_stringshare_add(ems_config_filename_default_get());
		if (!ecore_file_is_dir(ems_config_dirname_get()))
			ecore_file_mkpath(ems_config_dirname_get());
	}
	else if (!ecore_file_exists(config_file))
	{
		conf_filename = eina_stringshare_add(config_file);
		ecore_file_mkpath(ecore_file_dir_get(config_file));
	}
	else
	{
		conf_filename = eina_stringshare_add(config_file);
	}

	INF("Config file : %s", conf_filename);

	if (!ecore_file_is_dir(ems_config_tmp_dirname_get()))
		ecore_file_mkdir(ems_config_tmp_dirname_get());
	ef = eet_open(ems_config_tmp_filename_get(),
	              EET_FILE_MODE_READ_WRITE);
	if (!ef)
		ef = eet_open(ems_config_tmp_filename_get(),
		              EET_FILE_MODE_WRITE);

	f = fopen(conf_filename, "rb");
	if (!f)
	{
		WRN("Could not open '%s', setup default config.", ems_config_filename_get());
		if (ecore_file_exists(ems_config_default_filename_get()))
		{
			ecore_file_cp(ems_config_default_filename_get(), ems_config_filename_get());
			f = fopen(ems_config_filename_get(), "rb");
			if (!f)
				return;
		}
		else
			return;
	}

	fseek(f, 0, SEEK_END);
	textlen = ftell(f);
	rewind(f);
	text = (char *)malloc(textlen);
	if (!text)
	{
		fclose(f);
		eet_close(ef);
		return;
	}

	if (fread(text, textlen, 1, f) != 1)
	{
		free(text);
		fclose(f);
		eet_close(ef);
		return;
	}

	fclose(f);
	if (eet_data_undump(ef, "config", text, textlen, 1))
		INF("Updating configuration %s", conf_filename);
	free(text);
	eet_close(ef);
}
Esempio n. 14
0
static Eina_Bool
volume_idler(void *data)
{
   Scan *s;
   DIR *dp;
   struct dirent *de;
   char buf[4096];
   
   s = data;
   if (!s->dirstack)
     {
	ecore_event_add(VOLUME_SCAN_START, strdup(s->vol), NULL, NULL);
	snprintf(s->curdir, sizeof(s->curdir), "%s", s->vol);
	dp = opendir(s->curdir);
	if (dp) s->dirstack = eina_list_append(s->dirstack, dp);
     }
   if (!s->dirstack)
     {
	ecore_event_add(VOLUME_SCAN_STOP, strdup(s->vol), NULL, NULL);
	volume_items_sort(s);
	s->timer = NULL;
	return EINA_FALSE;
     }
   dp = eina_list_data_get(eina_list_last(s->dirstack));
   if (!dp)
     {
	ecore_event_add(VOLUME_SCAN_STOP, strdup(s->vol), NULL, NULL);
	volume_items_sort(s);
	s->timer = NULL;
	return EINA_FALSE;
     }
   de = readdir(dp);
   if (de)
     {
        if (de->d_name[0] != '.')
	  {
	     char *link;
	     
	     snprintf(buf, sizeof(buf), "%s/%s", s->curdir, de->d_name);
	     link = ecore_file_readlink(buf);
	     if (link) free(link);
	     else
	       {
		  Volume_Item *vi;
		       
		  if (ecore_file_is_dir(buf))
		    {
		       ecore_event_add(VOLUME_SCAN_GO, strdup(s->vol), NULL, NULL);
		       vi = volume_dir_scan(buf);
		       if (vi) s->items = eina_list_append(s->items, vi);
		       dp = opendir(buf);
		       if (dp)
			 {
			    snprintf(s->curdir, sizeof(s->curdir), "%s", buf);
			    s->dirstack = eina_list_append(s->dirstack, dp);
			 }
		    }
		  else
		    {
		       ecore_event_add(VOLUME_SCAN_GO, strdup(s->vol), NULL, NULL);
		       vi = volume_file_scan(buf);
		       if (vi)
			 {
			    Eina_List *l;
			    int exists;
			    
			    exists = 0;
			    for (l = items; l; l = l->next)
			      {
				 Volume_Item *vi2;
				 
				 vi2 = l->data;
				 if (!strcmp(vi2->rpath, vi->rpath))
				   {
				      exists = 1;
				      break;
				   }
			      }
			    if (!exists)
			      {
				 for (l = s->items; l; l = l->next)
				   {
				      Volume_Item *vi2;
				      
				      vi2 = l->data;
				      if (!strcmp(vi2->rpath, vi->rpath))
					{
				      printf("%s == %s\n", vi2->rpath, vi->rpath);
					   exists = 1;
					   break;
					}
				   }
			      }
			    if (exists)
			      {
				 if 
				   (!strcmp(vi->type, "video"))
				   video_count--;
				 else if
				   (!strcmp(vi->type, "audio"))
				   audio_count--;
				 else if 
				   (!strcmp(vi->type, "photo"))
				   photo_count--;
				 ecore_event_add(VOLUME_TYPE_DEL, strdup(vi->path), NULL, NULL);
				 free(vi->path);
				 free(vi->rpath);
				 free(vi->name);
				 if (vi->genre) eina_stringshare_del(vi->genre);
				 free(vi);
			      }
			    else
			      s->items = eina_list_append(s->items, vi);
			 }
		    }
	       }
	  }
     }
   else
     {
	char *p;
	
	closedir(dp);
	s->dirstack = eina_list_remove(s->dirstack, dp);
	p = strrchr(s->curdir, '/');
	if (p) *p = 0;
     }
   if (!s->dirstack)
     {
	ecore_event_add(VOLUME_SCAN_STOP, strdup(s->vol), NULL, NULL);
	volume_items_sort(s);
	s->timer = NULL;
	return EINA_FALSE;
     }
   s->timer = ecore_timer_add(SCANSPEED, volume_idler, s);
   return EINA_FALSE;
}
Esempio n. 15
0
Elicit *
elicit_new()
{
  Elicit *el;
  char buf[PATH_MAX];
  char *dir;
  
  el = calloc(sizeof(Elicit), 1);

  el->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 500, 500);
  if (!el->ee)
  {
    fprintf(stderr, "[Elicit] Error creating new ecore evas\n");
    free(el);
    return NULL;
  }
  el->evas = ecore_evas_get(el->ee);

  ecore_evas_title_set(el->ee, "Elicit");
  ecore_evas_name_class_set(el->ee, "Elicit", "Elicit");
  ecore_evas_borderless_set(el->ee, 1);

  // XXX get correct screen number
  if (ecore_x_screen_is_composited(0))
    ecore_evas_alpha_set(el->ee, 1);
  else
    ecore_evas_shaped_set(el->ee, 1);

  ecore_evas_data_set(el->ee, "Elicit", el);
  ecore_evas_callback_resize_set(el->ee, cb_ee_resize);
  ecore_evas_callback_mouse_in_set(el->ee, cb_ee_mouse_in);
  ecore_evas_callback_mouse_out_set(el->ee, cb_ee_mouse_out);

  ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, cb_x_configure, el);

  el->obj.main = edje_object_add(el->evas);

  /* setup paths */
  dir = br_find_data_dir(DATADIR);
  snprintf(buf, sizeof(buf), "%s/%s/", dir, PACKAGE);
  if (!ecore_file_exists(buf))
  {
    fprintf(stderr, "[Elicit] Warning: falling back to hardcoded data dir.\n");
    snprintf(buf, sizeof(buf), "%s/%s/", DATADIR, PACKAGE);
  }
  el->path.datadir = strdup(buf);
  free(dir);

  if (getenv("HOME"))
  {
    snprintf(buf, sizeof(buf), "%s/.e/apps/elicit/", getenv("HOME"));
    if (!ecore_file_is_dir(buf))
      ecore_file_mkpath(buf);
    el->path.confdir = strdup(buf);

    snprintf(buf, sizeof(buf), "%s/.e/apps/elicit/elicit.conf", getenv("HOME"));
    el->path.conffile = strdup(buf);

    snprintf(buf, sizeof(buf), "%s/.e/apps/elicit/elicit.gpl", getenv("HOME"));
    el->path.palette = strdup(buf);
  }

  /* color */
  el->color = color_new();
  color_callback_changed_add(el->color, cb_color_changed, el);

  /* palette */
  el->palette = palette_new();
  palette_load(el->palette, el->path.palette);


  return el;
}
Esempio n. 16
0
int
ex_config_init()
{
   char     *home;
   char      buf[PATH_MAX];
   
   home = getenv("HOME");
   if(!home)
     {
	ERROR(_("Cant find home directory!"));
	return 0;
     }
   
   /* make sure ~/.e exists and is a dir */
   snprintf(buf, sizeof(buf), "%s/.e", home);
   if(!ecore_file_is_dir(buf))
     {
	if(ecore_file_exists(buf))
	  {
	     ERROR(_("Cant create config path!"));
	     return 0;
	  }
	
	if(!ecore_file_mkdir(buf))
	  {
	     ERROR(_("Cant create config path!"));
	     return 0;
	  }
     }
   
   /* make sure ~/.e/extrackt exists and is a dir */
   snprintf(buf, sizeof(buf), "%s/.e/extrackt", home);
   if(!ecore_file_is_dir(buf))
     {
	if(ecore_file_exists(buf))
	  {
	     ERROR(_("Cant create config path!"));
	     return 0;
	  }
	
	if(!ecore_file_mkdir(buf))
	  {
	     ERROR(_("Cant create config path!"));
	     return 0;
	  }
     }   
   
   _ex_config_version_edd = NEWD("Ex_Config_Version", Ex_Config_Version);
   VER_NEWI("mj", major, EET_T_INT);
   VER_NEWI("mn", minor, EET_T_INT);
   VER_NEWI("pa", patch, EET_T_INT);   
   
   _ex_config_cd_edd = NEWD("Ex_Config_Cd", Ex_Config_Cd);
   CD_NEWI("cd", cdrom, EET_T_STRING);
   CD_NEWI("rs", interrupt_playback, EET_T_INT);
   CD_NEWI("rw", rewind_stopped, EET_T_INT);
   CD_NEWI("sf", startup_first_track, EET_T_INT);
   CD_NEWI("ai", autoplay_insert, EET_T_INT);
   CD_NEWI("rp", reshuffle_playback, EET_T_INT);
   CD_NEWI("wf", workaround_eject, EET_T_INT);
   CD_NEWI("pd", poll_drive, EET_T_INT);
   CD_NEWI("pi", poll_interval, EET_T_INT);
   
   _ex_config_cddb_server_edd = NEWD("Ex_Config_Cddb_Server", Ex_Config_Cddb_Server);
   CDDBS_NEWI("nm", name ,EET_T_STRING);
   CDDBS_NEWI("cg", cgi_prog, EET_T_STRING);
   CDDBS_NEWI("pt", port, EET_T_INT);
   CDDBS_NEWI("up", use_proxy, EET_T_INT);
   
   _ex_config_cddb_edd = NEWD("Ex_Config_Cddb", Ex_Config_Cddb);
   CDDB_NEWI("al", automatic_lookup, EET_T_INT);
   CDDB_NEWS("pr", primary, _ex_config_cddb_server_edd);
   CDDB_NEWS("sc", secondary, _ex_config_cddb_server_edd);
   
   _ex_config_exe_edd = NEWD("Ex_Config_Exe", Ex_Config_Exe);
   EXE_NEWI("nm", name, EET_T_STRING);   
   EXE_NEWI("ex", exe, EET_T_STRING);
   EXE_NEWI("cl", command_line_opts, EET_T_STRING);
   EXE_NEWI("ff", file_format, EET_T_STRING);
   EXE_NEWI("df", def, EET_T_INT);
   EXE_NEWI("ty", type, EET_T_INT);

   _ex_config_encode_edd = NEWD("Ex_Config_Encode", Ex_Config_Cddb);
   ENC_NEWL("es", encoders, _ex_config_exe_edd);
   ENC_NEWI("wd", wav_delete, EET_T_INT);
      
   return 1;
}
Esempio n. 17
0
/**
 * @brief Create complete list of sub-directories in a batch (optimized).
 *
 * @param base The base directory to act on.
 * @param subdirs The list of directories, null terminated.
 * @return number of successful directories created, -1 on failure.
 *
 * This function creates all the directories that are in the null
 * terminated array @p dirs in the @p base directory. If @p base does
 * not exist, it will be created. The function loops over the directories
 * and call ecore_file_mkdir(). The whole path of the directories must
 * exist. So if base/a/b/c wants to be created, @p subdirs must
 * contain "a", "a/b" and "a/b/c", in that order. This function
 * returns -1 if @p dirs or @p base are @c NULL, or if @p base is
 * empty ("\0"). It returns 0 is @p base is not a directory or
 * invalid, or if it can't be created. Otherwise if returns the number
 * of suceesfully created directories.
 */
EAPI int
ecore_file_mksubdirs(const char *base, const char **subdirs)
{
#ifndef HAVE_ATFILE_SOURCE
   char buf[PATH_MAX];
   int baselen;
#else
   int fd;
   DIR *dir;
#endif
   int i;

   if (!subdirs) return -1;
   if ((!base) || (base[0] == '\0')) return -1;

   if ((!ecore_file_is_dir(base)) && (!ecore_file_mkpath(base)))
     return 0;

#ifndef HAVE_ATFILE_SOURCE
   baselen = eina_strlcpy(buf, base, sizeof(buf));
   if ((baselen < 1) || (baselen + 1 >= (int)sizeof(buf)))
     return 0;

   if (buf[baselen - 1] != '/')
     {
        buf[baselen] = '/';
        baselen++;
     }
#else
   dir = opendir(base);
   if (!dir)
     return 0;
   fd = dirfd(dir);
#endif

   i = 0;
   for (; *subdirs; subdirs++)
     {
        struct stat st;

#ifndef HAVE_ATFILE_SOURCE
        eina_strlcpy(buf + baselen, *subdirs, sizeof(buf) - baselen);
        if (stat(buf, &st) == 0)
#else
        if (fstatat(fd, *subdirs, &st, 0) == 0)
#endif
          {
             if (S_ISDIR(st.st_mode))
               {
                  i++;
                  continue;
               }
          }
        else
          {
             if (errno == ENOENT)
               {
#ifndef HAVE_ATFILE_SOURCE
                  if (mkdir(buf, default_mode) == 0)
#else
                  if (mkdirat(fd, *subdirs, default_mode) == 0)
#endif
                    {
                       i++;
                       continue;
                    }
                 }
            }
     }

#ifdef HAVE_ATFILE_SOURCE
   closedir(dir);
#endif

   return i;
}
Esempio n. 18
0
void ModuleManager::SearchModules()
{
    for (uint i = 0; i < search_paths.size(); i++)
    {
        cInfoDom("module") << "ModuleManager: searching modules in: " << search_paths[i];
        char *fname = NULL;
        void *data = NULL;
        Eina_List *subdir = ecore_file_ls(search_paths[i].c_str());
        Eina_List *l = NULL;

        EINA_LIST_FOREACH(subdir, l, data)
        {
            fname = (char *)data;
            string p;

            p = search_paths[i];

            if (fname)
            {
                p += "/";
                p += fname;
            }
            if (p[p.length() - 1] != '/') p += "/";

            if (!ecore_file_is_dir(p.c_str()))
                continue;

            p += "module.so";

            if (!ecore_file_exists(p.c_str()))
                continue;

            bool alreadyin = false;
            for (uint im = 0; im < modules.size() && !alreadyin; im++)
            {
                ModuleDef mdef = modules[im];
                if (p == mdef.mod_fname)
                    alreadyin = true;
            }

            if (alreadyin) continue;

            //try to load the module
            void *handle = dlopen(p.c_str(), RTLD_LAZY);

            if (handle)
            {
                //object can be loaded, check version and
                CalaosModuleApi *api = (CalaosModuleApi *)dlsym(handle, "calaos_modapi");
                if (!api)
                {
                    dlclose(handle);
                    cErrorDom("module") << "ModuleManager: module " << p << ". calaos_modapi export not found: " << dlerror();
                    continue;
                }

                if (api->api_version != CALAOS_MODULE_API_VERSION)
                {
                    dlclose(handle);

                    cErrorDom("module") << "ModuleManager: module " << p << ". The API version doesn't match";

                    continue;
                }

                string module_name;
                vector<string> tok;
                Utils::split(p, tok, "/");
                if (tok.size() > 2)
                    module_name = tok[tok.size() - 2];

                string themepath = Prefix::Instance().dataDirectoryGet();
                themepath += "/widgets/" + module_name;

                ModuleDef mdef;
                mdef.mod_name = gettext(api->name);
                mdef.mod_desc = gettext(api->desc);
                mdef.mod_version = api->version;
                mdef.mod_author = api->author;
                mdef.mod_icon = themepath + "/icon.edj";
                mdef.mod_fname = p;
                mdef.handle = handle;
                mdef.inst = NULL;
                mdef.api = api;

                cInfoDom("module") << "ModuleManager: found module: " << mdef.mod_name;

                modules.push_back(mdef);
            }
            else
            {
                cWarningDom("module") << "ModuleManager: file " << p << " : failed to dlopen: " << dlerror();
            }

        }

        EINA_LIST_FREE(subdir, data)
        free(data);
    }