Esempio n. 1
0
/* 4. PREFIX/evas/modules/ */
void
evas_module_paths_init(void)
{
   char *path;

   /* 1. ~/.evas/modules/ */
   path = eina_module_environment_path_get("HOME", "/.evas/modules");
   evas_module_paths = _evas_module_append(evas_module_paths, path);

   /* 2. $(EVAS_MODULE_DIR)/evas/modules/ */
   path = eina_module_environment_path_get("EVAS_MODULES_DIR", "/evas/modules");
   if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
     free(path);
   else
     evas_module_paths = _evas_module_append(evas_module_paths, path);

   /* 3. libevas.so/../evas/modules/ */
   path = eina_module_symbol_path_get(evas_module_paths_init, "/evas/modules");
   if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
     free(path);
   else
     evas_module_paths = _evas_module_append(evas_module_paths, path);

   /* 4. PREFIX/evas/modules/ */
#ifndef _MSC_VER
   path = PACKAGE_LIB_DIR "/evas/modules";
   if (!eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
     {
	path = strdup(path);
	if (path)
	  evas_module_paths = _evas_module_append(evas_module_paths, path);
     }
#endif
}
Esempio n. 2
0
/* 4. PREFIX/evas/modules/ */
void
evas_module_paths_init(void)
{
   char *libdir, *path;

   /* 1. ~/.evas/modules/ */
   path = eina_module_environment_path_get("HOME", "/.evas/modules");
   evas_module_paths = _evas_module_append(evas_module_paths, path);

   /* 2. $(EVAS_MODULE_DIR)/evas/modules/ */
   path = eina_module_environment_path_get("EVAS_MODULES_DIR", "/evas/modules");
   if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
     free(path);
   else
     evas_module_paths = _evas_module_append(evas_module_paths, path);

   /* 3. libevas.so/../evas/modules/ */
   libdir = (char *)_evas_module_libdir_get();
   if (!libdir)
     path = eina_module_symbol_path_get(evas_module_paths_init, "/evas/modules");
   else
     {
        path = malloc(strlen(libdir) + strlen("/evas/modules") + 1);
        if (path)
          {
             strcpy(path, libdir);
             strcat(path, "/evas/modules");
          }
     }
   if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
     free(path);
   else
     evas_module_paths = _evas_module_append(evas_module_paths, path);

   /* 4. PREFIX/lib/evas/modules/ */
#ifndef _MSC_VER
   path = PACKAGE_LIB_DIR "/evas/modules";
   if (!eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
     {
	path = strdup(path);
	if (path)
	  evas_module_paths = _evas_module_append(evas_module_paths, path);
     }
#endif
}
Esempio n. 3
0
EAPI void
efreet_desktop_category_add(Efreet_Desktop *desktop, const char *category)
{
    if (!desktop) return;

    if (eina_list_search_unsorted(desktop->categories,
                                  EINA_COMPARE_CB(strcmp), category)) return;

    desktop->categories = eina_list_append(desktop->categories,
                        (void *)eina_stringshare_add(category));
}
Esempio n. 4
0
/**
 * @param file: The file to get the Efreet_Desktop from
 * @return Returns a reference to a cached Efreet_Desktop on success, NULL
 * on failure. This reference should not be freed.
 * @brief Gets a reference to an Efreet_Desktop structure representing the
 * contents of @a file or NULL if @a file is not a valid .desktop file.
 *
 * By using efreet_desktop_get the Efreet_Desktop will be saved in an internal
 * cache, and changes will be signalled by events.
 *
 * Efreet will also try to save all files fetched by efreet_desktop_get in a
 * cache to speed up further requests.
 */
EAPI Efreet_Desktop *
efreet_desktop_get(const char *file)
{
    /* TODO: Check if we need to differentiate between desktop_new and desktop_get */
    Efreet_Desktop *desktop;

    if (!file) return NULL;
    if (efreet_desktop_cache)
    {
        char rp[PATH_MAX];

        if (!realpath(file, rp)) return NULL;
        desktop = eina_hash_find(efreet_desktop_cache, rp);
        if (desktop)
        {
            if (efreet_desktop_cache_check(desktop))
            {
                desktop->ref++;
                return desktop;
            }

            desktop->cached = 0;
            eina_hash_del_by_key(efreet_desktop_cache, rp);
        }
    }

    desktop = efreet_desktop_new(file);
    if (!desktop) return NULL;

    if (!desktop->eet)
    {
        char buf[PATH_MAX];
        char *p;

        /*
         * Read file from disk, save path in cache so it will be included in next
         * cache update
         */
        strncpy(buf, desktop->orig_path, PATH_MAX);
        buf[PATH_MAX - 1] = '\0';
        p = dirname(buf);
        if (!eina_list_search_unsorted(efreet_desktop_dirs, EINA_COMPARE_CB(strcmp), p))
            efreet_desktop_dirs = eina_list_append(efreet_desktop_dirs, eina_stringshare_add(p));
        efreet_desktop_update_cache();
    }

    if (efreet_desktop_cache) eina_hash_add(efreet_desktop_cache, desktop->orig_path, desktop);
    desktop->cached = 1;
    return desktop;
}
Esempio n. 5
0
EAPI int
efreet_desktop_category_del(Efreet_Desktop *desktop, const char *category)
{
    char *found = NULL;

    if (!desktop || !desktop->categories) return 0;

    if ((found = eina_list_search_unsorted(desktop->categories,
                                           EINA_COMPARE_CB(strcmp), category)))
    {
        eina_stringshare_del(found);
        desktop->categories = eina_list_remove(desktop->categories, found);

        return 1;
    }

    return 0;
}
Esempio n. 6
0
/**
 * Find all desktop categories
 * This list must be freed using EINA_LIST_FREE
 *
 * @return an Eina_List of category names (const char *)
 */
EAPI Eina_List *
efreet_util_desktop_categories_list(void)
{
    char **keys;
    int num, i;
    Eina_List *ret = NULL;

    if (!efreet_cache_check(&cache, efreet_desktop_util_cache_file(), EFREET_DESKTOP_UTILS_CACHE_MAJOR)) return NULL;
    keys = eet_list(cache, "*::ca", &num);
    if (!keys) return NULL;
    for (i = 0; i < num; i++)
    {
        const char *data;
        int size;

        data = eet_read_direct(cache, keys[i], &size);
        if (!data) continue;
        if (eina_list_search_unsorted(ret, EINA_COMPARE_CB(strcmp), data)) continue;
        ret = eina_list_append(ret, data);
    }
    free(keys);
    return ret;
}
Esempio n. 7
0
File: main.c Progetto: Limsik/e17
int
main(int argc, char ** argv)
{
    int i, passed = 0, num_tests = 0;
    Eina_List *run = NULL;
    double total;
    char *env;

    eina_init();
    ecore_init();

    total = ecore_time_get();
    if (argc > 1)
    {
        for (i = 1; i < argc; i++)
        {
            if ((!strcmp(argv[i], "-h")) ||
                (!strcmp(argv[i], "--help")))
            {
                for (i = 0; tests[i].name; i++)
                {
                    printf("%s\n", tests[i].name);
                }
                return 1;
            }
            run = eina_list_append(run, argv[i]);
        }
    }

    environment_store();
    for (i = 0; tests[i].name; i++)
    {
        int ret;
        double start;

        /* we've been given specific tests and it isn't in the list */
        if (run && !eina_list_search_unsorted(run, EINA_COMPARE_CB(strcasecmp),
                                                        tests[i].name))
            continue;

        if (!efreet_init())
        {
            printf("Error initializing Efreet\n");
            continue;
        }

        num_tests ++;

        printf("%s:\t\t", tests[i].name);
        fflush(stdout);
        start = ecore_time_get();
        ret = tests[i].cb();
        printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
                                            ecore_time_get() - start);
        passed += ret;

        efreet_shutdown();
        environment_restore();
    }

    printf("\n-----------------\n");
    clearenv();
    EINA_LIST_FREE(environment, env)
        free(env);
    printf("Passed %d of %d tests.\n", passed, num_tests);

    while (run)
        run = eina_list_remove_list(run, run);

    printf("Total run: %.3f seconds\n", ecore_time_get() - total);

    ecore_shutdown();
    eina_shutdown();
    return 0;
}
Esempio n. 8
0
int
ef_cb_efreet_config_dirs(void)
{
   Eina_List *tmp, *l;
   int ret = 1;
   unsigned int i;
   unsigned int ok;
   char dirs[128], *val;
   char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL};
   char *def_vals[] = {"/etc/xdg", NULL};

   dirs[0] = '\0';

   for (i = 0; vals[i]; i++)
     {
        if (i > 0) strcat(dirs, ":");
        strcat(dirs, vals[i]);
     }

   efreet_shutdown();
   setenv("XDG_CONFIG_DIRS", dirs, 1);
   efreet_init();

   ok = 0;
   tmp = efreet_config_dirs_get();
   for (i = 0; vals[i]; i++)
     {
        char *found;

        found = eina_list_search_unsorted(tmp, EINA_COMPARE_CB(strcmp), vals[i]);
        if (!ecore_file_exists(vals[i]) && found)
          {
             printf("efreet_data_dirs_get() includes non-existing dir (%s) when "
                    "%s set\n", vals[i], dirs);
             ret = 0;
             continue;
          }
        if (ecore_file_exists(vals[i]) && !found)
          {
             printf("efreet_data_dirs_get() is missing dir (%s) when "
                    "%s set\n", vals[i], dirs);
             ret = 0;
             continue;
          }
        if (ecore_file_exists(vals[i]) && found)
          ok++;
     }
   if (eina_list_count(tmp) != ok)
     {
        printf("efreet_data_dirs_get() returned more values then it "
               "should have given %s as input\n", dirs);
        ret = 0;
     }

   efreet_shutdown();
   unsetenv("XDG_CONFIG_DIRS");
   efreet_init();

   i = 0;
   tmp = efreet_config_dirs_get();
   EINA_LIST_FOREACH(tmp, l, val)
     {
        if (!def_vals[i])
          {
             printf("efreet_config_dirs_get() returned more values then it "
                    "should have given %s as input\n", dirs);
             ret = 0;
             break;
          }

        if (strcmp(val, def_vals[i]))
          {
             printf("efreet_config_dirs_get() returned incorrect value (%s) when "
                    "XDG_CONFIG_DIRS= is set\n", val);
             ret = 0;
          }

        i++;
     }
   return ret;
}
Esempio n. 9
0
   const Ecore_File_Download_Job *job = data1;
   const Ecore_Con_Url           *url = data2;

   if (job->url_con == url) return 0;
   return -1;
}

#ifdef BUILD_ECORE_CON
# ifdef HAVE_CURL
static Eina_Bool
_ecore_file_download_url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
{
   Ecore_Con_Event_Url_Complete *ev = event;
   Ecore_File_Download_Job      *job;

   job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con);
   if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON;

   if (job->completion_cb)
     job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, !ev->status);

   _job_list = eina_list_remove(_job_list, job);
   fclose(job->file);
   free(job->dst);
   ecore_con_url_free(job->url_con);
   free(job);

   return ECORE_CALLBACK_DONE;
}
# endif
#endif