Beispiel #1
0
/**
 * @brief Initializes the config system
 * @return Returns true if initialization was successful, false otherwise
 */
Etk_Bool etk_config_init(void)
{
   char     *home;
   char      buf[PATH_MAX];

   home = getenv("HOME");
   if (!home)
   {
      ETK_WARNING("Cant find home directory!");
      return ETK_FALSE;
   }

   /* 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))
      {
	 ETK_WARNING("Cant create config path!");
	 return ETK_FALSE;
      }

      if (!ecore_file_mkdir(buf))
      {
	 ETK_WARNING("Cant create config path!");
	 return ETK_FALSE;
      }
   }

   /* make sure ~/.e/etk exists and is a dir */
   snprintf(buf, sizeof(buf), "%s/.e/etk", home);
   if (!ecore_file_is_dir(buf))
   {
      if (ecore_file_exists(buf))
      {
	 ETK_WARNING("Cant create config path!");
	 return ETK_FALSE;
      }

      if (!ecore_file_mkdir(buf))
      {
	 ETK_WARNING("Cant create config path!");
	 return ETK_FALSE;
      }
   }

   _etk_config_gen_edd = NEWD("Etk_Config_General", Etk_Config_General);
   CFG_GEN_NEWI("wmt", wm_theme, EET_T_STRING);
   CFG_GEN_NEWI("wt", widget_theme, EET_T_STRING);
   CFG_GEN_NEWI("fn", font, EET_T_STRING);
   CFG_GEN_NEWI("en", engine, EET_T_STRING);

   _etk_config_ver_edd = NEWD("Etk_Config_Version", Etk_Config_Version);
   CFG_VER_NEWI("mj", major, EET_T_INT);
   CFG_VER_NEWI("mn", minor, EET_T_INT);
   CFG_VER_NEWI("pa", patch, EET_T_INT);
   CFG_VER_NEWI("sp", subpatch, EET_T_INT);

   return ETK_TRUE;
}
Beispiel #2
0
EINTERN int
e_deskenv_init(void)
{
   char buf[PATH_MAX], buf2[4096];

   // run xdrb -load .Xdefaults & .Xresources
   // NOTE: one day we should replace this with an e based config + service
   if (e_config->deskenv.load_xrdb)
     {
        e_user_homedir_concat(buf, sizeof(buf), ".Xdefaults");
        if (ecore_file_exists(buf))
          {
             snprintf(buf2, sizeof(buf2), "xrdb -load %s", buf);
             ecore_exe_run(buf2, NULL);
          }
        e_user_homedir_concat(buf, sizeof(buf), ".Xresources");
        if (ecore_file_exists(buf))
          {
             snprintf(buf2, sizeof(buf2), "xrdb -load %s", buf);
             ecore_exe_run(buf2, NULL);
          }
     }

   // load ~/.Xmodmap
   // NOTE: one day we should replace this with an e based config + service
   if (e_config->deskenv.load_xmodmap)
     {
        e_user_homedir_concat(buf, sizeof(buf), ".Xmodmap");
        if (ecore_file_exists(buf))
          {
             snprintf(buf2, sizeof(buf2), "xmodmap %s", buf);
             ecore_exe_run(buf2, NULL);
          }
     }

   // make gnome apps happy
   // NOTE: one day we should replace this with an e based config + service
   if (e_config->deskenv.load_gnome)
     {
        ecore_exe_run("gnome-settings-daemon", NULL);
     }

   // make kde apps happy
   // NOTE: one day we should replace this with an e based config + service ??
   if (e_config->deskenv.load_kde)
     {
        ecore_exe_run("kdeinit", NULL);
     }
   return 1;
}
static Evas_Object *
gl_content_get(void *data, Evas_Object * obj, const char *part)
{
	struct _recipient_pack *pack = (struct _recipient_pack *)data;
	if (!strcmp(part, "elm.swallow.icon")) {
		const char *photo_file = NULL;
		GVariant *tmp = g_hash_table_lookup(pack->recipient, "Photo");
		if (tmp) {
			photo_file = g_variant_get_string(tmp, NULL);
		}

		if (!photo_file || !ecore_file_exists(photo_file))
			photo_file = CONTACT_DEFAULT_PHOTO;

		Evas_Object *photo = elm_icon_add(obj);
		elm_image_file_set(photo, photo_file, NULL);
		evas_object_size_hint_aspect_set(photo,
						 EVAS_ASPECT_CONTROL_VERTICAL,
						 1, 1);
		return (photo);
	}

	if (!strcmp(part, "elm.swallow.end")) {
		Evas_Object *ico = elm_icon_add(obj);
		elm_icon_standard_set(ico, "delete");
		evas_object_smart_callback_add(ico, "clicked",
					       _recipients_button_remove_clicked,
					       pack);
		return ico;
	}

	return (NULL);
}
Beispiel #4
0
int
_e_util_menu_item_edje_icon_set(E_Menu_Item *mi, const char *name, Eina_Bool fallback)
{
   const char *file;
   char buf[4096];

   if ((!name) || (!name[0])) return 0;

   if ((!fallback) && (name[0] == '/') && ecore_file_exists(name))
     {
        e_menu_item_icon_edje_set(mi, name, "icon");
        return 1;
     }
   snprintf(buf, sizeof(buf), "e/icons/%s", name);

   if (fallback)
     file = e_theme_edje_icon_fallback_file_get(buf);
   else
     file = e_theme_edje_file_get("base/theme/icons", buf);

   if (file[0])
     {
        e_menu_item_icon_edje_set(mi, file, buf);
        return 1;
     }
   return 0;
}
Ecore_File_Monitor *
ecore_file_monitor_backend_add(const char *path,
                            void (*func) (void *data, Ecore_File_Monitor *em,
                                          Ecore_File_Event event,
                                          const char *path),
                            void *data)
{
   Ecore_File_Monitor *em;
   size_t len;

   if (!path) return NULL;
   if (!func) return NULL;

   em = calloc(1, sizeof(Ecore_File_Monitor_Poll));
   if (!em) return NULL;

   if (!_timer)
     _timer = ecore_timer_add(_interval, _ecore_file_monitor_poll_handler, NULL);
   else
     ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);

   em->path = strdup(path);
   len = strlen(em->path);
   if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
     em->path[len - 1] = 0;

   em->func = func;
   em->data = data;

   ECORE_FILE_MONITOR_POLL(em)->mtime = ecore_file_mod_time(em->path);
   _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));

   if (ecore_file_exists(em->path))
     {
        if (ecore_file_is_dir(em->path))
          {
             /* Check for subdirs */
             Eina_List *files;
             char *file;

             files = ecore_file_ls(em->path);
             EINA_LIST_FREE(files, file)
                    {
                       Ecore_File *f;
                       char buf[PATH_MAX];

                       f = calloc(1, sizeof(Ecore_File));
                       if (!f)
                    {
                       free(file);
                         continue;
                    }

                       snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
                       f->name = file;
                       f->mtime = ecore_file_mod_time(buf);
                       f->is_dir = ecore_file_is_dir(buf);
                       em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
                    }
          }
Beispiel #6
0
char *
url_from_user_input(const char *arg)
{
    /* If it is already a URL, return the argument as is. */
    if (has_scheme(arg) || !strcasecmp(arg, "about:blank"))
        return strdup(arg);

    Eina_Strbuf *buf = eina_strbuf_manage_new(eina_file_path_sanitize(arg));

    /* Check if the path exists. */
    if (ecore_file_exists(eina_strbuf_string_get(buf))) {
        /* File exists, convert local path to a URL. */
        eina_strbuf_prepend(buf, "file://");
    } else {
        /* The path does not exist, convert it to a URL by
           prepending http:// scheme:
           www.google.com -> http://www.google.com */
         eina_strbuf_string_free(buf);
         eina_strbuf_append_printf(buf, "http://%s", arg);
    }
    char *url = eina_strbuf_string_steal(buf);
    eina_strbuf_free(buf);

    return url;
}
static char *
uri_sanitize(const char *uri)
{
   char *fixed_uri;
   char *schema;
   char *tmp;

   if (!uri || !*uri) return NULL;

   tmp = strstr(uri, "://");
   if (!tmp || (tmp == uri) || (tmp > (uri + 15)))
     {
        char *new_uri = NULL;
        if (ecore_file_exists(uri))
          {
             schema = "file";
             new_uri = ecore_file_realpath(uri);
          }
        else
          schema = "http";

        if (asprintf(&fixed_uri, "%s://%s", schema, new_uri ? new_uri : uri) >
            0)
          {
             free(new_uri);
             return fixed_uri;
          }
        free(new_uri);
     }
   else
     return strdup(uri);

   return NULL;
}
Beispiel #8
0
const char *
ems_config_cache_dirname_get(void)
{
	static const char *dir_name = NULL;
	char tmp[PATH_MAX];

	if (dir_name)
		return dir_name;

	if (!ems_config)
		return NULL;

	/* cache path is not set or doesn't exist : save cache in $HOME/.cache/enna-media-server */
	if (!ems_config->cache_path || !ems_config->cache_path[0] || !ecore_file_exists(ems_config->cache_path))
	{
		snprintf(tmp, sizeof(tmp), "%s/.cache/enna-media-server", getenv("HOME"));
		WRN("Cache directory is not set, save cache data in %s", tmp);
	}
	else
	{
		/* create a directory enna-media-server into cache specified in config */
		snprintf(tmp, sizeof(tmp), "%s/enna-media-server", ems_config->cache_path);
		INF("Save cache data in %s\n", tmp);
	}

	if (!ecore_file_is_dir(tmp))
		ecore_file_mkpath(tmp);

	dir_name = eina_stringshare_add(tmp);
	return dir_name;
}
Beispiel #9
0
void
enna_panel_infos_set_cover(Evas_Object *obj, Enna_Metadata *m)
{
    Evas_Object *cover;
    char *file = NULL;
    int from_vfs = 1;
    const char *cv;
    Smart_Data *sd = evas_object_data_get(obj, "sd");

    if (!sd)
        return;

    if (!m)
    {
        file = strdup(VIDEO_DEFAULT_COVER);
        from_vfs = 0;
    }

    cv = enna_metadata_meta_get(m, "cover", 1);
    if (!file && cv)
    {
        char dst[1024] = { 0 };

        snprintf(dst, sizeof(dst), "%s/covers/%s",
                 enna_util_data_home_get(), cv);
        if (ecore_file_exists(dst))
            file = strdup(dst);
    }

    if (!file)
    {
        file = strdup(VIDEO_DEFAULT_COVER);
        from_vfs = 0;
    }

    if (from_vfs)
    {
        cover = elm_icon_add(sd->o_edje);
        elm_image_file_set(cover, file, NULL);
    }
    else
    {
        cover = edje_object_add(evas_object_evas_get(sd->o_edje));
        edje_object_file_set(cover, enna_config_theme_get(), file);
    }


    ENNA_OBJECT_DEL(sd->o_cover);
    sd->o_cover = cover;
    edje_object_part_swallow(sd->o_edje,
                             "panel.cover.swallow", sd->o_cover);

    /* hide underlying shadows with default movie poster cover */
    edje_object_signal_emit(sd->o_edje,
                            (!strcmp(file, VIDEO_DEFAULT_COVER)) ?
                            "shadow,hide" : "shadow,show", "enna");

    eina_stringshare_del(cv);
    eina_stringshare_del(file);
}
Beispiel #10
0
static char *
_on_cover_retrieve( xmmsv_t *value, const char *picture_front )
{
	unsigned int bl;
	const unsigned char *bc;
	char *tmp_buf;
	
	if( xmmsv_get_bin( value, &bc, &bl ) )
	{

		int fd,ret;
		char buf[4096];
		snprintf(buf, sizeof(buf), "%s/.e-music/cache/%s", getenv("HOME"), picture_front);
	
		if ( ecore_file_exists(buf) != 1 )
		{
			fd = open(buf, O_WRONLY|O_CREAT, 0777);
			ret = write(fd, bc, bl);
			close(fd);

			if (ret != -1)
			{
				ERR("False to write album cover picture");
				return NULL;
			}
		}
		
		return (char *)eina_stringshare_add( buf );
	}

	return NULL;
}
Beispiel #11
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;
}
Beispiel #12
0
EAPI Efreet_Desktop *
efreet_desktop_uncached_new(const char *file)
{
    Efreet_Desktop *desktop = NULL;
    char *tmp;

    EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
    if (!ecore_file_exists(file)) return NULL;

    tmp = eina_file_path_sanitize(file);
    if (!tmp) return NULL;

    desktop = NEW(Efreet_Desktop, 1);
    if (!desktop)
    {
        free(tmp);
        return NULL;
    }
    desktop->orig_path = tmp;
    desktop->ref = 1;
    if (!efreet_desktop_read(desktop))
    {
        efreet_desktop_free(desktop);
        return NULL;
    }

    return desktop;
}
Beispiel #13
0
static Evas_Object *
_e_util_icon_add(const char *path, Evas *evas, int size)
{
   Evas_Object *o = NULL;
   const char *ext;

   if (!path) return NULL;
   if (!ecore_file_exists(path)) return NULL;

   o = e_icon_add(evas);
   e_icon_scale_size_set(o, size);
   e_icon_preload_set(o, 1);
   ext = strrchr(path, '.');
   if (ext)
     {
        if (!strcmp(ext, ".edj"))
          e_icon_file_edje_set(o, path, "icon");
        else
          e_icon_file_set(o, path);
     }
   else
     e_icon_file_set(o, path);
   e_icon_fill_inside_set(o, 1);

   return o;
}
Beispiel #14
0
/**
 * @param file The path to the theme file
 * @return Return an Eina_List* of Exchange_Theme*
 * @brief Get the list of all the themes in the given directory
 */
EAPI Exchange_Object*
exchange_local_theme_all_data_get(const char *file)
{
   Exchange_Object *td = NULL;
   char *name;

   DBG("0 %s\n", file);

   if (!file || !ecore_file_exists(file)) return NULL;
  //EINA_ERROR_PDBG("1 %s\n", file);
   td = calloc(1, sizeof(Exchange_Object));
   if (!td) return NULL;
   
   td->id = -1;
   
   name = exchange_local_theme_name_get(file);
   if (name) td->name = name;
   else td->name = strdup(ecore_file_file_get(file));
   
   td->author = exchange_local_theme_author_get(file);
   td->license = exchange_local_theme_license_get(file);
   td->version = exchange_local_theme_version_get(file);
   td->description[0] = '\0';
   td->url = NULL;
   td->rating = -1;
   td->user_id = -1;
   td->thumbnail = NULL;
   td->screenshot = NULL;
   td->created_at = NULL;
   td->updated_at = NULL;

   return td;
}
Beispiel #15
0
const char *
elicit_data_file_find(const char *file)
{
  static char buf[PATH_MAX];
  char *datadir;
  datadir = br_find_data_dir(DATADIR);
  snprintf(buf, sizeof(buf), "%s/%s/%s", datadir, PACKAGE, file);
  free(datadir);
  if (ecore_file_exists(buf))
    return buf;

  snprintf(buf, sizeof(buf), "%s/%s/%s", DATADIR, PACKAGE, file);
  if (ecore_file_exists(buf))
    return buf;

  return NULL;
}
void ActionMail::sendMail()
{
    std::string tmpFile;
    int cpt = 0;
    //Get a temporary filename
    do
    {
        tmpFile = "/tmp/calaos_mail_body_";
        tmpFile += Utils::to_string(cpt);
        cpt++;
    }
    while (ecore_file_exists(tmpFile.c_str()));

    //Write body message to a temp file
    std::ofstream ofs;
    ofs.open(tmpFile.c_str(), std::ofstream::trunc);
    ofs << mail_message;
    ofs.close();

    std::stringstream cmd;

    cmd << Prefix::Instance().binDirectoryGet();
    cmd << "/calaos_mail";

    if (ecore_file_exists(cmd.str().c_str()))
    {
        cmd << " ";
        cmd << "--delete "; //force temp file deletion after mail is sent
        if (Utils::get_config_option("smtp_debug") == "true")
            cmd << "--verbose ";
        cmd << "--from \"" << mail_sender << "\" ";
        cmd << "--to \"" << mail_recipients << "\" ";
        cmd << "--subject \"" << mail_subject << "\" ";
        cmd << "--body " << tmpFile << " ";

        if (!mail_attachment_tfile.empty())
            cmd << "--attach " << mail_attachment_tfile;

        cInfo() << "Executing command : " << cmd.str();
        ecore_exe_run(cmd.str().c_str(), NULL);
    }
    else
    {
        cError() << "Command " << cmd.str() << " not found";
    }
}
void EflResources::unloadImage( std::string const& _path )
{
    if( 0 != preloaded_images__.count( _path ) )
    {
        evas_object_del( preloaded_images__[_path] );
        preloaded_images__.erase( _path );
        std::string cached_file( cache_dir + _path );
        if( 1 == ecore_file_exists( cached_file.c_str() ) ) // EINA_TRUE
            ecore_file_remove( cached_file.c_str() );
    }
}
Beispiel #18
0
const char *
elicit_theme_find(Elicit *el, const char *theme)
{
  static char buf[PATH_MAX];

  // check in home dir
  if (el->path.confdir)
  {
    snprintf(buf, sizeof(buf), "%s/themes/%s.edj", el->path.confdir, theme);
    if (ecore_file_exists(buf) && edje_file_group_exists(buf, "elicit.main"))
      return buf;
  }

  // check in sys dir
  snprintf(buf, sizeof(buf), "%s/themes/%s.edj", el->path.datadir, theme);
  if (ecore_file_exists(buf) && edje_file_group_exists(buf, "elicit.main"))
    return buf;

  return NULL;
}
Beispiel #19
0
const char *
enna_config_theme_file_get(const char *s)
{
   char tmp[4096];
   memset(tmp, 0, sizeof(tmp));

   if (!s)
     return NULL;
   if (s[0]=='/')
     snprintf(tmp, sizeof(tmp), "%s", s);

   if (!ecore_file_exists(tmp))
     snprintf(tmp, sizeof(tmp), PACKAGE_DATA_DIR "/enna-explorer/theme/%s.edj", s);
   if (!ecore_file_exists(tmp))
     snprintf(tmp, sizeof(tmp), "%s", PACKAGE_DATA_DIR "/enna-explorer/theme/default.edj");

   if (ecore_file_exists(tmp))
     return strdup(tmp);
   else
     return NULL;
}
bool ActionMail::Execute()
{
    IPCam *camera = NULL;

    if (mail_attachment != "")
        camera = dynamic_cast<IPCam *>(ListeRoom::Instance().get_io(mail_attachment));

    if (camera)
    {
        cInfoDom("rule.action.mail") <<  "Need to download camera ("
                                      << camera->get_param("name")
                                      << ") attachment";

        std::string tmpFile;
        int cpt = 0;

        //Get a temporary filename
        do
        {
            tmpFile = "/tmp/calaos_mail_attachment_";
            tmpFile += Utils::to_string(cpt);
            cpt++;
        }
        while (ecore_file_exists(tmpFile.c_str()));

        // Autodestroy file downloader
        cDebug() << "DL URL: " << camera->getPictureUrl();
        FileDownloader* downloader = new FileDownloader(camera->getPictureUrl(), tmpFile, true);
        downloader->addCallback([=](std::string signal, void *sender_data)
        {
            if (signal == "done")
            {
                mail_attachment_tfile = *(reinterpret_cast<std::string *>(sender_data));
                sendMail();
            }
            else if (signal == "failed" || signal == "aborted")
            {
                mail_attachment_tfile.clear();
                sendMail();
            }
        });
        downloader->Start();
    }
    else
    {
        sendMail();

        cInfoDom("rule.action.mail") <<  "Ok, mail is in queue";
    }

    return true;
}
JsonApiHandlerHttp::JsonApiHandlerHttp(HttpClient *client):
    JsonApi(client)
{
    exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ecore_exe_finished, this);

    int cpt = rand();
    do
    {
        tempfname = "/tmp/calaos_json_temp_" + Utils::to_string(cpt) + ".jpg";
        cpt++;
    }
    while (ecore_file_exists(tempfname.c_str()));
}
int
main(void)
{
   double start;
   Eina_Hash *headers;

   eina_init();
   ecore_init();
   ecore_file_init();

   if (ecore_file_exists(DST))
     ecore_file_unlink(DST);

   start = ecore_time_get();

   if (ecore_file_download(URL, DST, completion_cb, progress_cb, NULL, NULL))
     {
        printf("Download started successfully:\n  URL: %s\n  DEST: %s\n", URL, DST);
        ecore_main_loop_begin();
        printf("\nTime elapsed: %f seconds\n", ecore_time_get() - start);
        printf("Downloaded %lld bytes\n", ecore_file_size(DST));
     }
   else
     {
        printf("Error, can't start download\n");
        goto done;
     }

   headers = eina_hash_string_small_new(NULL);
   eina_hash_add(headers, "Content-type", "application/x-gzip");

   if (ecore_file_download_full(URL, DST_MIME, completion_cb, progress_cb, NULL, NULL, headers))
     {
        printf("Download started successfully:\n  URL: %s\n  DEST: %s\n", URL, DST_MIME);
        ecore_main_loop_begin();
        printf("\nTime elapsed: %f seconds\n", ecore_time_get() - start);
        printf("Downloaded %lld bytes\n", ecore_file_size(DST));
     }
   else
     {
        printf("Error, can't start download\n");
        goto done;
     }

done:
   if (headers) eina_hash_free(headers);
   ecore_file_shutdown();
   ecore_shutdown();
   eina_shutdown();
   return 0;
}
void GenlistItemAlbumHeader::albumItemCoverGet_cb(Params &res)
{
        DELETE_NULL(dltimer);
        if (res["filename"] == "")
                return;

        if (!ecore_file_exists(res["filename"].c_str()))
                return;

        cover_fname = res["filename"];
        cover_downloaded = true;

        elm_genlist_item_fields_update(item, "calaos.cover", ELM_GENLIST_ITEM_FIELD_CONTENT);
}
Beispiel #24
0
/* externally accessible functions */
EAPI void
e_startup(E_Startup_Mode mode)
{
   char buf[PATH_MAX];

   if (mode == E_STARTUP_START)
     {
        e_user_dir_concat_static(buf, "applications/startup/.order");
        if (!ecore_file_exists(buf))
          e_prefix_data_concat_static(buf, "data/applications/startup/.order");
     }
   else if (mode == E_STARTUP_RESTART)
     {
        e_user_dir_concat_static(buf, "applications/restart/.order");
        if (!ecore_file_exists(buf))
          e_prefix_data_concat_static(buf, "data/applications/restart/.order");
     }
   desktop_cache_update_handler =
     ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_BUILD,
                             _e_startup_event_cb,
                             strdup(buf));
   e_init_undone();
}
std::string Utils::getConfigFile(const char *configType)
{
    if (_configBase.empty())
    {
        std::string home;
        if (getenv("HOME"))
        {
            home = getenv("HOME");
        }
        else
        {
            struct passwd *pw = getpwuid(getuid());
            home = pw->pw_dir;
        }

        std::list<std::string> confDirs;
        confDirs.push_back(home + "/" + HOME_CONFIG_PATH);
        confDirs.push_back(ETC_CONFIG_PATH);
        confDirs.push_back(PREFIX_CONFIG_PATH);

        //Check config in that order:
        // - $HOME/.config/calaos/
        // - /etc/calaos
        // - pkg_prefix/etc/calaos
        // - create $HOME/.config/calaos/ if nothing found

        std::list<std::string>::iterator it = confDirs.begin();
        for (;it != confDirs.end();it++)
        {
            std::string conf = *it;
            conf += "/" IO_CONFIG;
            if (ecore_file_exists(conf.c_str()))
            {
                _configBase = *it;
                break;
            }
        }

        if (_configBase.empty())
        {
            //no config dir found, create $HOME/.config/calaos
            ecore_file_mkdir(std::string(home + "/.config").c_str());
            ecore_file_mkdir(std::string(home + "/.config/calaos").c_str());
            _configBase = home + "/" + HOME_CONFIG_PATH;
        }
    }

    return _configBase + "/" + configType;
}
Beispiel #26
0
void
photo_panel_infos_set_text (Evas_Object *obj, const char *filename)
{
    Enna_Metadata *m;
    const char *meta;
    char *meta2 = NULL;

    API_ENTRY return;

    if (!filename || !ecore_file_exists(filename))
    {
        edje_object_part_text_set (sd->o_edje, "infos.panel.textblock",
	    _("No EXIF information found ..."));
        return;
    }

    m = enna_metadata_meta_new (filename);
    meta = enna_metadata_meta_get_all (m);
    if (meta)
    {
        unsigned int i, j;

        meta2 = calloc (2, strlen (meta));
        for (i = 0, j = 0; i < strlen (meta); i++)
        {
            if (meta[i] != '\n')
            {
                meta2[j] = meta[i];
                j++;
            }
            else
            {
                meta2[j]   = '<';
                meta2[j+1] = 'b';
                meta2[j+2] = 'r';
                meta2[j+3] = '>';
                j += 4;
            }
        }
    }

    edje_object_part_text_set (sd->o_edje, "infos.panel.textblock",
                               meta2 ? meta2:
                               _("No EXIF such information found ..."));
    eina_stringshare_del(meta);
    ENNA_FREE (meta2);
    enna_metadata_meta_free (m);
}
Beispiel #27
0
static Enna_File *
_file_get(const char *uri)
{
   Enna_File *f;
   char *path;

   if (strlen(uri) < 7)
     {
        path = malloc(2 * sizeof(char));
        path[0] = '/';
        path[1] = '\0';
     }
   else
     {
        path = malloc((strlen(uri + 7) + 1) * sizeof(char));
        strncpy(path, uri + 7, strlen(uri + 7) + 1);
     }

   if (!ecore_file_exists(path))
     return NULL;

   if (ecore_file_is_dir(path))
     {
        const char *file;
        const char *label;
        file = ecore_file_file_get(path);
        if (!file || file[0] == '\0')
          {
             label = eina_stringshare_add("Root");
             f = enna_file_directory_add(label, "file:///",
                                         path, label,
                                         "icon/directory");
             eina_stringshare_del(label);
          }
        else
          {
             f = enna_file_directory_add(file, uri,
                                         path, file,
                                         "icon/directory");
          }
     }
   else
     f = enna_file_file_add(ecore_file_file_get(path), uri,
                            path, ecore_file_file_get(path),
                            "icon/file");
   free(path);
   return f;
}
Beispiel #28
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);
}
EflResources::~EflResources()
{
    // Prevent any cached photos from hanging around.
    if( 1 == ecore_file_exists( cache_dir.c_str() ) )
    {
        ASSERT( ecore_file_recursive_rm( cache_dir.c_str() )
              , "Could not delete cache." );
    }

    for( auto image_it( preloaded_images__.begin() )
            , end( preloaded_images__.end() );
         image_it != end;
         ++image_it )
    {
        evas_object_del( image_it->second );
    }
}
Beispiel #30
0
char *utils_file_move_in_pres(const char *file)
{
    const char *pres_file = eyelight_object_presentation_file_get(pres);
    char *dir = ecore_file_dir_get(pres_file);
    char *res;
    int ok = 1;
    int i;

    //test if file is in a subdirectory of dir
    for(i=0;i<strlen(dir);i++)
    {
        if(i >= strlen(file)
                || dir[i] != file[i])
        {
            ok = 0;
            break;
        }
        else
            i++;
    }

    if(!ok)
    {
        const char* file_name = ecore_file_file_get(file);
        char buf[PATH_MAX];
        res = calloc(PATH_MAX, sizeof(char));
        snprintf(buf, PATH_MAX, "%s/images/", dir);
        if(!ecore_file_exists(buf))
            ecore_file_mkdir(buf);

        snprintf(buf, PATH_MAX, "%s/images/%s", dir, file_name);
        ecore_file_cp(file, buf);

        snprintf(res,PATH_MAX,"images/%s", file_name);
    }
    else
    {
        const char *_file = file + strlen(dir) + 1;
        res = strdup(_file);
    }

    EYELIGHT_FREE(dir);

    return res;
}