コード例 #1
0
ファイル: ef_utils.c プロジェクト: jigpu/efl
int
ef_cb_utils(void)
{
   Efreet_Desktop *desktop;
   const char *tmp2;

   printf("\n");

   tmp2 = efreet_util_path_to_file_id("/usr/share/applications/this/tmp/test.desktop");
   if (tmp2) printf("%s\n", tmp2);

   desktop = efreet_util_desktop_file_id_find("kde-kresources.desktop");
   printf("kde-kresources.desktop: %p\n", desktop);
   efreet_desktop_free(desktop);

   desktop = efreet_util_desktop_file_id_find("mplayer.desktop");
   printf("mplayer.desktop: %p\n", desktop);
   efreet_desktop_free(desktop);

   desktop = efreet_util_desktop_file_id_find("nautilus-computer.desktop");
   printf("nautilus-computer.desktop: %p\n", desktop);
   efreet_desktop_free(desktop);

   return 1;
}
コード例 #2
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;
}
コード例 #3
0
EAPI Efreet_Desktop *
efreet_desktop_new(const char *file)
{
    Efreet_Desktop *desktop = NULL;
    char *tmp;

    EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);

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

    desktop = efreet_cache_desktop_find(tmp);
    free(tmp);
    if (desktop)
    {
        desktop->ref++;
        if (!efreet_desktop_environment_check(desktop))
        {
            efreet_desktop_free(desktop);
            return NULL;
        }
        return desktop;
    }
    return efreet_desktop_uncached_new(file);
}
コード例 #4
0
 EINA_LIST_FREE(desks, desk)
   {
      if (!desk->exec)
        {
           efreet_desktop_free(desk);
           continue;
        }
      desktops = eina_list_append(desktops, desk);
   }
コード例 #5
0
   EINA_LIST_FREE(desks, desk)
     {
        char dbuf[4096];

        if (!desk->exec)
          {
             efreet_desktop_free(desk);
             continue;
          }
        if (sscanf(desk->exec, "%4000s", dbuf) == 1)
          {
             for (i = 0; i < (sizeof(apps) / sizeof(App)); i++)
               {
                  if (apps[i].found == 0)
                    {
                       char abuf[4096];
                            
                       if (sscanf(apps[i].exec, "%4000s", abuf) == 1)
                         {
                            char *p1, *p2;
                                 
                            if (!ecore_file_app_installed(abuf))
                              {
                                 /* can't find exe - mark as not available */
                                 apps[i].found = -1;
                              }
                            else
                              {
                                 p1 = strrchr(dbuf, '/');
                                 if (p1) p1++;
                                 else p1 = dbuf;
                                 p2 = strrchr(abuf, '/');
                                 if (p2) p2++;
                                 else p2 = abuf;
                                 if (!strcmp(p1, p2))
                                   /* mark as found in .desktops */
                                   apps[i].found = 2;
                              }
                         }
                    }
               }
          }
        efreet_desktop_free(desk);
     }
コード例 #6
0
EAPI Efreet_Desktop *
efreet_desktop_new(const char *file)
{
    Efreet_Desktop *desktop = NULL;

    if (!file) return NULL;
    desktop = efreet_cache_desktop_find(file);
    if (desktop)
    {
        desktop->ref++;
        if (!efreet_desktop_environment_check(desktop))
        {
            efreet_desktop_free(desktop);
            return NULL;
        }
        return desktop;
        efreet_desktop_free(desktop);
    }
    return efreet_desktop_uncached_new(file);
}
コード例 #7
0
ファイル: efreet_desktop.c プロジェクト: Limsik/e17
EAPI Efreet_Desktop *
efreet_desktop_new(const char *file)
{
    Efreet_Desktop *desktop = NULL;

    EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);

    desktop = efreet_cache_desktop_find(file);
    if (desktop)
    {
        desktop->ref++;
        if (!efreet_desktop_environment_check(desktop))
        {
            efreet_desktop_free(desktop);
            return NULL;
        }
        return desktop;
        efreet_desktop_free(desktop);
    }
    return efreet_desktop_uncached_new(file);
}
コード例 #8
0
/**
 * @param file: The file to create the Efreet_Desktop from
 * @return Returns a new Efreet_Desktop on success, NULL on failure
 * @brief Creates a new Efreet_Desktop structure initialized from the
 * contents of @a file or NULL on failure
 *
 * By using efreet_desktop_uncached_new the Efreet_Desktop structure will be
 * read from disk, and not from any cache.
 */
EAPI Efreet_Desktop *
efreet_desktop_uncached_new(const char *file)
{
    Efreet_Desktop *desktop = NULL;
    char rp[PATH_MAX];

    if (!file) return NULL;
    if (!realpath(file, rp)) return NULL;
    if (!ecore_file_exists(rp)) return NULL;

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

    return desktop;
}
コード例 #9
0
static int
cache_add(const char *path, const char *file_id, int priority EINA_UNUSED, int *changed)
{
    Efreet_Desktop *desk;
    char *ext;

    INF("FOUND: %s", path);
    if (file_id) INF(" (id): %s", file_id);
    ext = strrchr(path, '.');
    if (!ext || (strcmp(ext, ".desktop") && strcmp(ext, ".directory"))) return 1;
    desk = efreet_desktop_new(path);
    if (desk) INF("  OK");
    else      INF("  FAIL");
    if (!desk) return 1;
    if (!desk->eet)
    {
        /* This file isn't in cache */
        *changed = 1;
        INF("  NEW");
    }
    else if (ecore_file_mod_time(desk->orig_path) != desk->load_time)
    {
        efreet_desktop_free(desk);
        *changed = 1;
        desk = efreet_desktop_uncached_new(path);
        if (desk) INF("  CHANGED");
        else      INF("  NO UNCACHED");
    }
    if (!desk) return 1;
    if (file_id && old_file_ids && !eina_hash_find(old_file_ids->hash, file_id))
    {
        *changed = 1;
        INF("  NOT IN UTILS");
    }
    if (!eina_hash_find(paths, desk->orig_path))
    {
        if (!eet_data_write(ef, edd, desk->orig_path, desk, 0))
            return 0;
        eina_hash_add(paths, desk->orig_path, (void *)1);
    }
    /* TODO: We should check priority, and not just hope we search in right order */
    /* TODO: We need to find out if prioritized file id has changed because of
     * changed search order. */
    if (!desk->hidden && desk->type == EFREET_DESKTOP_TYPE_APPLICATION &&
        file_id && !eina_hash_find(file_ids, file_id))
    {
        Eina_List *l;
        char *data;
        Efreet_Cache_Array_String *array;

#define ADD_LIST(list, hash) \
        EINA_LIST_FOREACH((list), l, data) \
        { \
            array = eina_hash_find((hash), data); \
            if (!array) \
                array = NEW(Efreet_Cache_Array_String, 1); \
            array->array = realloc(array->array, sizeof (char *) * (array->array_count + 1)); \
            array->array[array->array_count++] = desk->orig_path; \
            eina_hash_set((hash), data, array); \
        }
#define ADD_ELEM(elem, hash) \
        if ((elem)) \
        { \
            data = (elem); \
            array = eina_hash_find((hash), data); \
            if (!array) \
                array = NEW(Efreet_Cache_Array_String, 1); \
            array->array = realloc(array->array, sizeof (char *) * (array->array_count + 1)); \
            array->array[array->array_count++] = desk->orig_path; \
            eina_hash_set((hash), data, array); \
        }
        ADD_LIST(desk->mime_types, mime_types);
        ADD_LIST(desk->categories, categories);
        ADD_ELEM(desk->startup_wm_class, startup_wm_class);
        ADD_ELEM(desk->name, name);
        ADD_ELEM(desk->generic_name, generic_name);
        ADD_ELEM(desk->comment, comment);
        ADD_ELEM(desk->exec, exec);
        eina_hash_add(file_ids, file_id, desk->orig_path);
        eina_hash_add(desktops, desk->orig_path, desk);
    }
    else
        efreet_desktop_free(desk);
    return 1;
}