2007-02-03 05:05:30 -08:00
|
|
|
/* vim: set sw=4 ts=4 sts=4 et: */
|
2009-04-20 16:20:40 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2010-01-04 18:15:41 -08:00
|
|
|
#include <limits.h>
|
2009-04-20 16:20:40 -07:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
# include <winsock2.h>
|
|
|
|
#endif
|
|
|
|
|
2009-04-27 22:39:22 -07:00
|
|
|
#include <Ecore.h>
|
2009-04-20 16:20:40 -07:00
|
|
|
#include <Ecore_File.h>
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
#include "Efreet.h"
|
|
|
|
#include "efreet_private.h"
|
|
|
|
|
2010-01-24 13:21:27 -08:00
|
|
|
#define DESKTOP_VERSION "1.0"
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The current desktop environment (e.g. "Enlightenment" or "Gnome")
|
|
|
|
*/
|
|
|
|
static const char *desktop_environment = NULL;
|
|
|
|
|
|
|
|
/**
|
2007-09-06 09:15:10 -07:00
|
|
|
* A cache of all loaded desktops, hashed by file name.
|
2007-02-03 05:05:30 -08:00
|
|
|
* Values are Efreet_Desktop structures
|
|
|
|
*/
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Hash *efreet_desktop_cache = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-02-04 18:06:05 -08:00
|
|
|
/**
|
|
|
|
* A list of the desktop types available
|
|
|
|
*/
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List *efreet_desktop_types = NULL;
|
2007-02-04 18:06:05 -08:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* A unique id for each tmp file created while building a command
|
|
|
|
*/
|
|
|
|
static int efreet_desktop_command_file_id = 0;
|
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
static char *cache_file = NULL;
|
|
|
|
static Eet_File *cache = NULL;
|
2010-03-01 13:43:59 -08:00
|
|
|
static Eet_Data_Descriptor *desktop_edd = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2009-09-21 09:36:29 -07:00
|
|
|
#ifdef EFREET_MODULE_LOG_DOM
|
|
|
|
#undef EFREET_MODULE_LOG_DOM
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define EFREET_MODULE_LOG_DOM _efreet_desktop_log_dom
|
|
|
|
static int _efreet_desktop_log_dom = -1;
|
|
|
|
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int EFREET_DESKTOP_TYPE_APPLICATION = 0;
|
|
|
|
EAPI int EFREET_DESKTOP_TYPE_LINK = 0;
|
|
|
|
EAPI int EFREET_DESKTOP_TYPE_DIRECTORY = 0;
|
2007-02-05 13:16:55 -08:00
|
|
|
|
2007-02-05 12:23:31 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Information about custom types
|
|
|
|
*/
|
|
|
|
typedef struct Efreet_Desktop_Type_Info Efreet_Desktop_Type_Info;
|
|
|
|
struct Efreet_Desktop_Type_Info
|
|
|
|
{
|
2007-02-05 13:16:55 -08:00
|
|
|
int id;
|
2007-02-05 12:23:31 -08:00
|
|
|
char *type;
|
|
|
|
Efreet_Desktop_Type_Parse_Cb parse_func;
|
2007-02-05 13:16:55 -08:00
|
|
|
Efreet_Desktop_Type_Save_Cb save_func;
|
2007-02-05 12:23:31 -08:00
|
|
|
Efreet_Desktop_Type_Free_Cb free_func;
|
|
|
|
};
|
|
|
|
|
2007-03-27 12:41:23 -07:00
|
|
|
static int efreet_desktop_read(Efreet_Desktop *desktop);
|
2010-03-01 10:16:32 -08:00
|
|
|
#if 0
|
2007-03-27 12:41:23 -07:00
|
|
|
static void efreet_desktop_clear(Efreet_Desktop *desktop);
|
2010-03-01 10:16:32 -08:00
|
|
|
#endif
|
2007-02-05 13:16:55 -08:00
|
|
|
static Efreet_Desktop_Type_Info *efreet_desktop_type_parse(const char *type_str);
|
2007-09-06 09:15:10 -07:00
|
|
|
static void *efreet_desktop_application_fields_parse(Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini);
|
2007-09-06 09:15:10 -07:00
|
|
|
static void efreet_desktop_application_fields_save(Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini);
|
2007-02-05 13:16:55 -08:00
|
|
|
static void *efreet_desktop_link_fields_parse(Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini);
|
2007-09-06 09:15:10 -07:00
|
|
|
static void efreet_desktop_link_fields_save(Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini);
|
2007-09-06 09:15:10 -07:00
|
|
|
static int efreet_desktop_generic_fields_parse(Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini);
|
2007-09-06 09:15:10 -07:00
|
|
|
static void efreet_desktop_generic_fields_save(Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool efreet_desktop_x_fields_parse(const Eina_Hash *hash,
|
2010-02-04 01:12:35 -08:00
|
|
|
const void *key,
|
|
|
|
void *data,
|
|
|
|
void *fdata);
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool efreet_desktop_x_fields_save(const Eina_Hash *hash,
|
2010-02-04 01:12:35 -08:00
|
|
|
const void *key,
|
|
|
|
void *value,
|
|
|
|
void *fdata);
|
2007-02-03 05:05:30 -08:00
|
|
|
static int efreet_desktop_environment_check(Efreet_Ini *ini);
|
2007-09-06 09:15:10 -07:00
|
|
|
static char *efreet_string_append(char *dest, int *size,
|
2007-02-03 05:05:30 -08:00
|
|
|
int *len, const char *src);
|
2007-09-06 09:15:10 -07:00
|
|
|
static char *efreet_string_append_char(char *dest, int *size,
|
2007-02-03 05:05:30 -08:00
|
|
|
int *len, char c);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List *efreet_desktop_command_build(Efreet_Desktop_Command *command);
|
2007-02-03 05:05:30 -08:00
|
|
|
static void efreet_desktop_command_free(Efreet_Desktop_Command *command);
|
2007-09-06 09:15:10 -07:00
|
|
|
static char *efreet_desktop_command_append_quoted(char *dest, int *size,
|
2007-02-03 05:05:30 -08:00
|
|
|
int *len, char *src);
|
|
|
|
static char *efreet_desktop_command_append_icon(char *dest, int *size, int *len,
|
|
|
|
Efreet_Desktop *desktop);
|
2007-09-06 09:15:10 -07:00
|
|
|
static char *efreet_desktop_command_append_single(char *dest, int *size, int *len,
|
|
|
|
Efreet_Desktop_Command_File *file,
|
2007-02-03 05:05:30 -08:00
|
|
|
char type);
|
2007-09-06 09:15:10 -07:00
|
|
|
static char *efreet_desktop_command_append_multiple(char *dest, int *size, int *len,
|
|
|
|
Efreet_Desktop_Command *command,
|
2007-02-03 05:05:30 -08:00
|
|
|
char type);
|
|
|
|
|
|
|
|
static char *efreet_desktop_command_path_absolute(const char *path);
|
|
|
|
static Efreet_Desktop_Command_File *efreet_desktop_command_file_process(
|
2007-09-06 09:15:10 -07:00
|
|
|
Efreet_Desktop_Command *command,
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *file);
|
|
|
|
static const char *efreet_desktop_command_file_uri_process(const char *uri);
|
|
|
|
static void efreet_desktop_command_file_free(Efreet_Desktop_Command_File *file);
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
static void efreet_desktop_cb_download_complete(void *data, const char *file,
|
2007-02-03 05:05:30 -08:00
|
|
|
int status);
|
|
|
|
static int efreet_desktop_cb_download_progress(void *data, const char *file,
|
|
|
|
long int dltotal, long int dlnow,
|
|
|
|
long int ultotal, long int ulnow);
|
|
|
|
|
|
|
|
|
2008-02-24 11:12:49 -08:00
|
|
|
static void *efreet_desktop_exec_cb(void *data, Efreet_Desktop *desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
char *exec, int remaining);
|
|
|
|
|
2007-02-05 12:23:31 -08:00
|
|
|
static void efreet_desktop_type_info_free(Efreet_Desktop_Type_Info *info);
|
2007-06-17 21:26:50 -07:00
|
|
|
static int efreet_desktop_command_flags_get(Efreet_Desktop *desktop);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static void *efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Eina_List *execs);
|
2007-02-05 12:23:31 -08:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns > 0 on success or 0 on failure
|
|
|
|
* @brief Initialize the Desktop parser subsystem
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
efreet_desktop_init(void)
|
|
|
|
{
|
2009-10-09 23:19:13 -07:00
|
|
|
_efreet_desktop_log_dom = eina_log_domain_register("Efreet_desktop", EFREET_DEFAULT_LOG_COLOR);
|
|
|
|
if (_efreet_desktop_log_dom < 0)
|
|
|
|
{
|
2010-02-04 01:12:35 -08:00
|
|
|
ERROR("Efreet: Could not create a log domain for Efreet_desktop");
|
|
|
|
return 0;
|
2009-10-09 23:19:13 -07:00
|
|
|
}
|
|
|
|
if (!ecore_file_init())
|
2010-03-01 10:16:32 -08:00
|
|
|
goto ecore_error;
|
2010-03-01 13:43:59 -08:00
|
|
|
desktop_edd = efreet_desktop_edd_init();
|
|
|
|
if (!desktop_edd)
|
2010-03-01 10:16:32 -08:00
|
|
|
goto edd_error;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
efreet_desktop_cache = eina_hash_string_superfast_new(NULL);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_types = NULL;
|
2007-02-05 13:16:55 -08:00
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
EFREET_DESKTOP_TYPE_APPLICATION = efreet_desktop_type_add("Application",
|
|
|
|
efreet_desktop_application_fields_parse,
|
|
|
|
efreet_desktop_application_fields_save,
|
2007-02-05 13:16:55 -08:00
|
|
|
NULL);
|
2007-09-06 09:15:10 -07:00
|
|
|
EFREET_DESKTOP_TYPE_LINK = efreet_desktop_type_add("Link",
|
|
|
|
efreet_desktop_link_fields_parse,
|
2007-02-05 13:16:55 -08:00
|
|
|
efreet_desktop_link_fields_save, NULL);
|
2007-09-06 09:15:10 -07:00
|
|
|
EFREET_DESKTOP_TYPE_DIRECTORY = efreet_desktop_type_add("Directory", NULL,
|
2007-02-05 13:16:55 -08:00
|
|
|
NULL, NULL);
|
2007-02-04 18:06:05 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
/* TODO:
|
|
|
|
* Should add a lock here, so that several programs starting at the same
|
|
|
|
* time wont run several copies of efreet_desktop_cache_create
|
|
|
|
*
|
|
|
|
* Or do the right thing and run the exe with ecore_exe
|
|
|
|
*/
|
|
|
|
if (!ecore_file_exists(efreet_desktop_cache_file()))
|
|
|
|
system(PACKAGE_BIN_DIR "/efreet_desktop_cache_create");
|
|
|
|
/* TODO: Need file monitor on cache in case it is updated */
|
|
|
|
cache = eet_open(efreet_desktop_cache_file(), EET_FILE_MODE_READ);
|
2009-10-09 23:19:13 -07:00
|
|
|
return 1;
|
2010-03-01 10:16:32 -08:00
|
|
|
|
|
|
|
edd_error:
|
|
|
|
ecore_file_shutdown();
|
|
|
|
ecore_error:
|
|
|
|
eina_log_domain_unregister(_efreet_desktop_log_dom);
|
|
|
|
return 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @returns the number of initializations left for this system
|
|
|
|
* @brief Attempts to shut down the subsystem if nothing else is using it
|
|
|
|
*/
|
2009-10-09 23:19:13 -07:00
|
|
|
void
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_shutdown(void)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Efreet_Desktop_Type_Info *info;
|
|
|
|
|
2007-02-04 18:06:05 -08:00
|
|
|
IF_RELEASE(desktop_environment);
|
2007-02-03 05:05:30 -08:00
|
|
|
IF_FREE_HASH(efreet_desktop_cache);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
while (efreet_desktop_types)
|
|
|
|
{
|
|
|
|
info = eina_list_data_get(efreet_desktop_types);
|
|
|
|
efreet_desktop_type_info_free(info);
|
|
|
|
efreet_desktop_types = eina_list_remove_list(efreet_desktop_types,
|
|
|
|
efreet_desktop_types);
|
|
|
|
}
|
2010-03-01 10:16:32 -08:00
|
|
|
if (cache) eet_close(cache);
|
2010-03-01 13:43:59 -08:00
|
|
|
efreet_desktop_edd_shutdown(desktop_edd);
|
2009-10-09 23:19:13 -07:00
|
|
|
ecore_file_shutdown();
|
|
|
|
eina_log_domain_unregister(_efreet_desktop_log_dom);
|
2010-03-01 10:16:32 -08:00
|
|
|
IF_FREE(cache_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI const char *
|
|
|
|
efreet_desktop_cache_file(void)
|
|
|
|
{
|
|
|
|
char tmp[PATH_MAX] = { '\0' };
|
|
|
|
const char *home, *lang, *country, *modifier;
|
|
|
|
|
|
|
|
if (cache_file) return cache_file;
|
|
|
|
|
|
|
|
home = efreet_home_dir_get();
|
|
|
|
lang = efreet_lang_get();
|
|
|
|
country = efreet_lang_country_get();
|
|
|
|
modifier = efreet_lang_modifier_get();
|
|
|
|
|
|
|
|
if (lang && country && modifier)
|
|
|
|
snprintf(tmp, sizeof(tmp), "%s/.efreet/desktop_%s_%s@%s.cache", home, lang, country, modifier);
|
|
|
|
else if (lang && country)
|
|
|
|
snprintf(tmp, sizeof(tmp), "%s/.efreet/desktop_%s_%s.cache", home, lang, country);
|
|
|
|
else if (lang)
|
|
|
|
snprintf(tmp, sizeof(tmp), "%s/.efreet/desktop_%s.cache", home, lang);
|
|
|
|
else
|
|
|
|
snprintf(tmp, sizeof(tmp), "%s/.efreet/desktop.cache", home);
|
|
|
|
|
|
|
|
cache_file = strdup(tmp);
|
|
|
|
return cache_file;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: The desktop to check
|
|
|
|
* @return Returns 1 if the cache is still valid, 0 otherwise
|
2007-09-06 09:15:10 -07:00
|
|
|
* @brief This will check if the desktop cache is still valid.
|
2007-02-03 05:05:30 -08:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
efreet_desktop_cache_check(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
if (!desktop) return 0;
|
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
/* TODO:
|
|
|
|
* We always accept files in cache, but we should update cache
|
|
|
|
* when a file has changed on disk
|
|
|
|
*/
|
|
|
|
if (desktop->eet) return 1;
|
2007-02-03 05:05:30 -08:00
|
|
|
/* have we modified this file since we last read it in? */
|
2010-03-01 10:16:32 -08:00
|
|
|
if (ecore_file_mod_time(desktop->orig_path) != desktop->load_time)
|
2010-02-04 01:12:35 -08:00
|
|
|
return 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param file: The file to get the Efreet_Desktop from
|
2007-09-06 09:15:10 -07:00
|
|
|
* @return Returns a reference to a cached Efreet_Desktop on success, NULL
|
2007-02-03 05:05:30 -08:00
|
|
|
* 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.
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI Efreet_Desktop *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_get(const char *file)
|
|
|
|
{
|
|
|
|
Efreet_Desktop *desktop;
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
if (efreet_desktop_cache)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
desktop = eina_hash_find(efreet_desktop_cache, file);
|
2007-02-03 05:05:30 -08:00
|
|
|
if (desktop)
|
|
|
|
{
|
|
|
|
if (efreet_desktop_cache_check(desktop))
|
2007-06-14 11:37:31 -07:00
|
|
|
{
|
|
|
|
desktop->ref++;
|
2007-02-03 05:05:30 -08:00
|
|
|
return desktop;
|
2007-06-14 11:37:31 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
#if 0
|
2007-03-27 12:41:23 -07:00
|
|
|
efreet_desktop_clear(desktop);
|
|
|
|
if (efreet_desktop_read(desktop))
|
2007-06-14 11:37:31 -07:00
|
|
|
{
|
|
|
|
desktop->ref++;
|
2007-03-27 12:41:23 -07:00
|
|
|
return desktop;
|
2007-06-14 11:37:31 -07:00
|
|
|
}
|
2010-03-01 10:16:32 -08:00
|
|
|
#endif
|
2007-03-27 12:41:23 -07:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
/* TODO: Submit event to signal that this file has changed */
|
2007-06-14 11:37:31 -07:00
|
|
|
desktop->cached = 0;
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_del(efreet_desktop_cache, file, NULL);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
desktop = efreet_desktop_new(file);
|
|
|
|
if (!desktop) return NULL;
|
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
if (efreet_desktop_cache) eina_hash_add(efreet_desktop_cache, file, desktop);
|
2007-06-14 08:53:02 -07:00
|
|
|
desktop->cached = 1;
|
2007-02-03 05:05:30 -08:00
|
|
|
return desktop;
|
|
|
|
}
|
|
|
|
|
2007-06-22 02:39:58 -07:00
|
|
|
/**
|
|
|
|
* @param desktop: The Efreet_Desktop to ref
|
|
|
|
* @return Returns the new reference count
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int
|
2007-06-22 02:39:58 -07:00
|
|
|
efreet_desktop_ref(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
if (!desktop) return 0;
|
|
|
|
desktop->ref++;
|
|
|
|
return desktop->ref;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @param file: The file to create the Efreet_Desktop from
|
|
|
|
* @return Returns a new empty_Efreet_Desktop on success, NULL on failure
|
|
|
|
* @brief Creates a new empty Efreet_Desktop structure or NULL on failure
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI Efreet_Desktop *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_empty_new(const char *file)
|
|
|
|
{
|
|
|
|
Efreet_Desktop *desktop;
|
|
|
|
|
|
|
|
desktop = NEW(Efreet_Desktop, 1);
|
|
|
|
if (!desktop) return NULL;
|
|
|
|
|
|
|
|
desktop->orig_path = strdup(file);
|
2007-06-16 17:33:39 -07:00
|
|
|
desktop->load_time = ecore_file_mod_time(file);
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2007-06-14 08:53:02 -07:00
|
|
|
desktop->ref = 1;
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
return desktop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @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
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI Efreet_Desktop *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_new(const char *file)
|
|
|
|
{
|
2010-03-01 10:16:32 -08:00
|
|
|
/* TODO: Need file monitor on file and events to notify change */
|
|
|
|
Efreet_Desktop *desktop = NULL;
|
2010-03-02 12:07:41 -08:00
|
|
|
char *rp = NULL;
|
2010-03-01 10:16:32 -08:00
|
|
|
|
2010-03-02 12:07:41 -08:00
|
|
|
rp = ecore_file_realpath(file);
|
2010-03-01 10:16:32 -08:00
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
/* TODO: Check if the cached version is out of date */
|
2010-03-02 12:07:41 -08:00
|
|
|
desktop = eet_data_read(cache, desktop_edd, rp);
|
2010-03-01 10:16:32 -08:00
|
|
|
if (desktop)
|
|
|
|
{
|
|
|
|
desktop->ref = 1;
|
|
|
|
desktop->eet = 1;
|
2010-03-02 12:07:41 -08:00
|
|
|
free(rp);
|
2010-03-01 10:16:32 -08:00
|
|
|
return desktop;
|
|
|
|
}
|
|
|
|
}
|
2010-03-01 11:05:59 -08:00
|
|
|
/* TODO:
|
|
|
|
* Add .desktop file path to a cache file, so that
|
|
|
|
* efreet_desktop_cache_create can add it to the cache
|
|
|
|
*/
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-02 12:07:41 -08:00
|
|
|
if (!ecore_file_exists(rp)) goto error;
|
2007-07-26 04:37:23 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
desktop = NEW(Efreet_Desktop, 1);
|
2010-03-02 12:07:41 -08:00
|
|
|
if (!desktop) goto error;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-02 12:07:41 -08:00
|
|
|
desktop->orig_path = rp;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-02 12:07:41 -08:00
|
|
|
if (!efreet_desktop_read(desktop)) goto error;
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2007-06-14 08:53:02 -07:00
|
|
|
desktop->ref = 1;
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2007-03-27 12:41:23 -07:00
|
|
|
return desktop;
|
2010-03-02 12:07:41 -08:00
|
|
|
error:
|
|
|
|
if (desktop) efreet_desktop_free(desktop);
|
|
|
|
if (rp) free(rp);
|
|
|
|
return NULL;
|
2007-03-27 12:41:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: The desktop to fill
|
|
|
|
* @return Returns 1 on success, 0 on failure
|
|
|
|
* @brief initialize an Efreet_Desktop from the contents of @a file
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
efreet_desktop_read(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
Efreet_Ini *ini;
|
|
|
|
int error = 0;
|
|
|
|
int ok;
|
|
|
|
|
|
|
|
ini = efreet_ini_new(desktop->orig_path);
|
2007-09-06 09:15:10 -07:00
|
|
|
if (!ini->data)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
efreet_ini_free(ini);
|
2007-03-27 12:41:23 -07:00
|
|
|
return 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
ok = efreet_ini_section_set(ini, "Desktop Entry");
|
|
|
|
if (!ok) ok = efreet_ini_section_set(ini, "KDE Desktop Entry");
|
2007-09-06 09:15:10 -07:00
|
|
|
if (!ok)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2009-09-21 09:36:29 -07:00
|
|
|
ERR("efreet_desktop_new error: no Desktop Entry section");
|
2007-02-03 05:05:30 -08:00
|
|
|
error = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
{
|
2007-02-05 13:16:55 -08:00
|
|
|
Efreet_Desktop_Type_Info *info;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-02-05 13:16:55 -08:00
|
|
|
info = efreet_desktop_type_parse(efreet_ini_string_get(ini, "Type"));
|
|
|
|
if (info)
|
2007-02-04 18:06:05 -08:00
|
|
|
{
|
2010-01-24 13:21:27 -08:00
|
|
|
const char *val;
|
|
|
|
|
2007-02-05 13:16:55 -08:00
|
|
|
desktop->type = info->id;
|
2010-01-24 13:21:27 -08:00
|
|
|
val = efreet_ini_string_get(ini, "Version");
|
|
|
|
if (val) desktop->version = strdup(val);
|
2007-02-05 13:16:55 -08:00
|
|
|
|
2007-02-05 12:23:31 -08:00
|
|
|
if (info->parse_func)
|
2007-09-06 09:15:10 -07:00
|
|
|
desktop->type_data = info->parse_func(desktop, ini);
|
2007-02-04 18:06:05 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
error = 1;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!error && !efreet_desktop_environment_check(ini)) error = 1;
|
|
|
|
if (!error && !efreet_desktop_generic_fields_parse(desktop, ini)) error = 1;
|
|
|
|
if (!error)
|
2010-02-04 01:12:35 -08:00
|
|
|
eina_hash_foreach(ini->section, efreet_desktop_x_fields_parse, desktop);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
efreet_ini_free(ini);
|
|
|
|
|
2007-06-16 17:33:39 -07:00
|
|
|
desktop->load_time = ecore_file_mod_time(desktop->orig_path);
|
2007-03-27 12:50:57 -07:00
|
|
|
|
2007-03-27 12:41:23 -07:00
|
|
|
if (error) return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: The Efreet_Desktop to work with
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Frees the Efreet_Desktop's data
|
|
|
|
*/
|
2010-03-01 10:16:32 -08:00
|
|
|
#if 0
|
2007-03-27 12:41:23 -07:00
|
|
|
static void
|
|
|
|
efreet_desktop_clear(Efreet_Desktop *desktop)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
char *data;
|
|
|
|
|
2007-03-27 12:41:23 -07:00
|
|
|
IF_FREE(desktop->name);
|
|
|
|
IF_FREE(desktop->generic_name);
|
|
|
|
IF_FREE(desktop->comment);
|
|
|
|
IF_FREE(desktop->icon);
|
|
|
|
IF_FREE(desktop->url);
|
|
|
|
|
|
|
|
IF_FREE(desktop->try_exec);
|
|
|
|
IF_FREE(desktop->exec);
|
|
|
|
IF_FREE(desktop->path);
|
|
|
|
IF_FREE(desktop->startup_wm_class);
|
|
|
|
|
2009-03-23 05:19:31 -07:00
|
|
|
IF_FREE_LIST(desktop->only_show_in, free);
|
|
|
|
IF_FREE_LIST(desktop->not_show_in, free);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
while (desktop->categories)
|
|
|
|
{
|
|
|
|
data = eina_list_data_get(desktop->categories);
|
|
|
|
eina_stringshare_del(data);
|
|
|
|
desktop->categories = eina_list_remove_list(desktop->categories, desktop->categories);
|
|
|
|
}
|
|
|
|
while (desktop->mime_types)
|
|
|
|
{
|
|
|
|
data = eina_list_data_get(desktop->mime_types);
|
|
|
|
eina_stringshare_del(data);
|
|
|
|
desktop->mime_types = eina_list_remove_list(desktop->mime_types, desktop->mime_types);
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-03-27 12:41:23 -07:00
|
|
|
IF_FREE_HASH(desktop->x);
|
|
|
|
|
|
|
|
if (desktop->type_data)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Type_Info *info;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
info = eina_list_nth(efreet_desktop_types, desktop->type);
|
2007-03-27 12:41:23 -07:00
|
|
|
if (info->free_func)
|
2007-09-06 09:15:10 -07:00
|
|
|
info->free_func(desktop->type_data);
|
2007-03-27 12:41:23 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
2010-03-01 10:16:32 -08:00
|
|
|
#endif
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: The desktop file to save
|
|
|
|
* @return Returns 1 on success or 0 on failure
|
|
|
|
* @brief Saves any changes made to @a desktop back to the file on the
|
|
|
|
* filesystem
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_save(Efreet_Desktop *desktop)
|
|
|
|
{
|
2007-02-05 13:16:55 -08:00
|
|
|
Efreet_Desktop_Type_Info *info;
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini;
|
|
|
|
int ok = 1;
|
|
|
|
|
2009-05-15 04:47:39 -07:00
|
|
|
ini = efreet_ini_new(NULL);
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_ini_section_add(ini, "Desktop Entry");
|
|
|
|
efreet_ini_section_set(ini, "Desktop Entry");
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
info = eina_list_nth(efreet_desktop_types, desktop->type);
|
2007-09-06 09:15:10 -07:00
|
|
|
if (info)
|
2007-02-04 18:06:05 -08:00
|
|
|
{
|
2007-02-05 13:16:55 -08:00
|
|
|
efreet_ini_string_set(ini, "Type", info->type);
|
|
|
|
if (info->save_func) info->save_func(desktop, ini);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
2007-02-04 18:06:05 -08:00
|
|
|
else
|
|
|
|
ok = 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
if (desktop->only_show_in)
|
|
|
|
{
|
|
|
|
val = efreet_desktop_string_list_join(desktop->only_show_in);
|
|
|
|
efreet_ini_string_set(ini, "OnlyShowIn", val);
|
|
|
|
FREE(val);
|
|
|
|
}
|
|
|
|
if (desktop->not_show_in)
|
|
|
|
{
|
|
|
|
val = efreet_desktop_string_list_join(desktop->not_show_in);
|
|
|
|
efreet_ini_string_set(ini, "NotShowIn", val);
|
|
|
|
FREE(val);
|
|
|
|
}
|
|
|
|
efreet_desktop_generic_fields_save(desktop, ini);
|
|
|
|
/* When we save the file, it should be updated to the
|
|
|
|
* latest version that we support! */
|
2010-01-24 13:21:27 -08:00
|
|
|
efreet_ini_string_set(ini, "Version", DESKTOP_VERSION);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (!efreet_ini_save(ini, desktop->orig_path)) ok = 0;
|
2010-03-01 10:16:32 -08:00
|
|
|
#if 0
|
2007-02-03 05:05:30 -08:00
|
|
|
else
|
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
if (desktop != eina_hash_find(efreet_desktop_cache, desktop->orig_path))
|
2007-06-14 11:37:31 -07:00
|
|
|
{
|
|
|
|
desktop->cached = 1;
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_del(efreet_desktop_cache, desktop->orig_path, NULL);
|
|
|
|
eina_hash_add(efreet_desktop_cache, desktop->orig_path,
|
|
|
|
desktop);
|
2007-06-14 11:37:31 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
2010-03-01 10:16:32 -08:00
|
|
|
#endif
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
efreet_ini_free(ini);
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: The desktop file to save
|
|
|
|
* @param file: The filename to save as
|
|
|
|
* @return Returns 1 on success or 0 on failure
|
|
|
|
* @brief Saves @a desktop to @a file
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file)
|
|
|
|
{
|
2010-03-01 10:16:32 -08:00
|
|
|
if (desktop->cached && efreet_desktop_cache &&
|
|
|
|
desktop == eina_hash_find(efreet_desktop_cache, desktop->orig_path))
|
2007-06-14 11:37:31 -07:00
|
|
|
{
|
|
|
|
desktop->cached = 0;
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_del(efreet_desktop_cache, desktop->orig_path, NULL);
|
2007-06-14 11:37:31 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
FREE(desktop->orig_path);
|
|
|
|
desktop->orig_path = strdup(file);
|
|
|
|
return efreet_desktop_save(desktop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: The Efreet_Desktop to work with
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Frees the Efreet_Desktop structure and all of it's data
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_free(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
if (!desktop) return;
|
|
|
|
|
2007-06-14 08:53:02 -07:00
|
|
|
desktop->ref--;
|
|
|
|
if (desktop->ref > 0) return;
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2007-06-22 02:39:58 -07:00
|
|
|
if (desktop->cached && efreet_desktop_cache)
|
2010-02-04 01:12:35 -08:00
|
|
|
eina_hash_del(efreet_desktop_cache, desktop->orig_path, NULL);
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
if (desktop->eet)
|
|
|
|
{
|
|
|
|
eina_list_free(desktop->only_show_in);
|
|
|
|
eina_list_free(desktop->not_show_in);
|
|
|
|
eina_list_free(desktop->categories);
|
|
|
|
eina_list_free(desktop->mime_types);
|
|
|
|
IF_FREE_HASH(desktop->x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *str;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
IF_FREE(desktop->orig_path);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
IF_FREE(desktop->version);
|
|
|
|
IF_FREE(desktop->name);
|
|
|
|
IF_FREE(desktop->generic_name);
|
|
|
|
IF_FREE(desktop->comment);
|
|
|
|
IF_FREE(desktop->icon);
|
|
|
|
IF_FREE(desktop->url);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
IF_FREE(desktop->try_exec);
|
|
|
|
IF_FREE(desktop->exec);
|
|
|
|
IF_FREE(desktop->path);
|
|
|
|
IF_FREE(desktop->startup_wm_class);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
IF_FREE_LIST(desktop->only_show_in, free);
|
|
|
|
IF_FREE_LIST(desktop->not_show_in, free);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
EINA_LIST_FREE(desktop->categories, str)
|
|
|
|
eina_stringshare_del(str);
|
|
|
|
EINA_LIST_FREE(desktop->mime_types, str)
|
|
|
|
eina_stringshare_del(str);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 10:16:32 -08:00
|
|
|
IF_FREE_HASH(desktop->x);
|
|
|
|
|
|
|
|
if (desktop->type_data)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Type_Info *info;
|
|
|
|
info = eina_list_nth(efreet_desktop_types, desktop->type);
|
|
|
|
if (info->free_func)
|
|
|
|
info->free_func(desktop->type_data);
|
|
|
|
}
|
2007-02-05 12:23:31 -08:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
FREE(desktop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: The desktop file to work with
|
|
|
|
* @param files: The files to be substituted into the exec line
|
2008-08-02 14:48:44 -07:00
|
|
|
* @param data: The data pointer to pass
|
2007-02-03 05:05:30 -08:00
|
|
|
* @return Returns the Ecore_Exce for @a desktop
|
|
|
|
* @brief Parses the @a desktop exec line and returns an Ecore_Exe.
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_exec(Efreet_Desktop *desktop, Eina_List *files, void *data)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
efreet_desktop_command_get(desktop, files, efreet_desktop_exec_cb, data);
|
|
|
|
}
|
|
|
|
|
2008-02-24 11:12:49 -08:00
|
|
|
static void *
|
2007-09-06 09:15:10 -07:00
|
|
|
efreet_desktop_exec_cb(void *data, Efreet_Desktop *desktop __UNUSED__,
|
2007-02-03 05:05:30 -08:00
|
|
|
char *exec, int remaining __UNUSED__)
|
|
|
|
{
|
2009-04-20 16:20:40 -07:00
|
|
|
#ifndef _WIN32
|
2007-02-03 05:05:30 -08:00
|
|
|
ecore_exe_run(exec, data);
|
|
|
|
free(exec);
|
2009-04-20 16:20:40 -07:00
|
|
|
#endif
|
2008-02-24 11:12:49 -08:00
|
|
|
return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param environment: the environment name
|
|
|
|
* @brief sets the global desktop environment name
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_environment_set(const char *environment)
|
|
|
|
{
|
2008-10-15 07:48:03 -07:00
|
|
|
if (desktop_environment) eina_stringshare_del(desktop_environment);
|
|
|
|
if (environment) desktop_environment = eina_stringshare_add(environment);
|
2007-02-03 05:05:30 -08:00
|
|
|
else desktop_environment = NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-17 08:07:59 -07:00
|
|
|
/**
|
|
|
|
* @return environment: the environment name
|
|
|
|
* @brief sets the global desktop environment name
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *
|
2007-07-17 08:07:59 -07:00
|
|
|
efreet_desktop_environment_get(void)
|
|
|
|
{
|
|
|
|
return desktop_environment;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @param desktop: The desktop to work with
|
|
|
|
* @return Returns the number of categories assigned to this desktop
|
|
|
|
* @brief Retrieves the number of categories the given @a desktop belongs
|
|
|
|
* too
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI unsigned int
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_category_count_get(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
if (!desktop || !desktop->categories) return 0;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
return eina_list_count(desktop->categories);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: the desktop
|
|
|
|
* @param category: the category name
|
|
|
|
* @brief add a category to a desktop
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_category_add(Efreet_Desktop *desktop, const char *category)
|
|
|
|
{
|
|
|
|
if (!desktop) return;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if (eina_list_search_unsorted(desktop->categories,
|
2009-03-26 10:56:51 -07:00
|
|
|
EINA_COMPARE_CB(strcmp), category)) return;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
desktop->categories = eina_list_append(desktop->categories,
|
2008-10-15 07:48:03 -07:00
|
|
|
(void *)eina_stringshare_add(category));
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: the desktop
|
|
|
|
* @param category: the category name
|
|
|
|
* @brief removes a category from a desktop
|
|
|
|
* @return 1 if the desktop had his category listed, 0 otherwise
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_category_del(Efreet_Desktop *desktop, const char *category)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
char *found = NULL;
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!desktop || !desktop->categories) return 0;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if ((found = eina_list_search_unsorted(desktop->categories,
|
2009-03-26 10:56:51 -07:00
|
|
|
EINA_COMPARE_CB(strcmp), category)))
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
eina_stringshare_del(found);
|
|
|
|
desktop->categories = eina_list_remove(desktop->categories, found);
|
|
|
|
|
|
|
|
return 1;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
return 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
2007-02-04 18:06:05 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param type: The type to add to the list of matching types
|
2007-02-05 12:23:31 -08:00
|
|
|
* @param parse_func: a function to parse out custom fields
|
2007-02-05 13:16:55 -08:00
|
|
|
* @param save_func: a function to save data returned from @a parse_func
|
2007-02-05 12:23:31 -08:00
|
|
|
* @param free_func: a function to free data returned from @a parse_func
|
2007-09-06 09:15:10 -07:00
|
|
|
* @return Returns the id of the new type
|
2007-02-04 18:06:05 -08:00
|
|
|
* @brief Adds the given type to the list of types in the system
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int
|
2007-02-05 12:23:31 -08:00
|
|
|
efreet_desktop_type_add(const char *type, Efreet_Desktop_Type_Parse_Cb parse_func,
|
2007-02-05 13:16:55 -08:00
|
|
|
Efreet_Desktop_Type_Save_Cb save_func,
|
2007-02-05 12:23:31 -08:00
|
|
|
Efreet_Desktop_Type_Free_Cb free_func)
|
2007-02-04 18:06:05 -08:00
|
|
|
{
|
|
|
|
int id;
|
2007-02-05 12:23:31 -08:00
|
|
|
Efreet_Desktop_Type_Info *info;
|
|
|
|
|
|
|
|
info = NEW(Efreet_Desktop_Type_Info, 1);
|
|
|
|
if (!info) return 0;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
id = eina_list_count(efreet_desktop_types);
|
2007-02-05 13:16:55 -08:00
|
|
|
|
|
|
|
info->id = id;
|
2007-02-05 12:23:31 -08:00
|
|
|
info->type = strdup(type);
|
|
|
|
info->parse_func = parse_func;
|
2007-02-05 13:16:55 -08:00
|
|
|
info->save_func = save_func;
|
2007-02-05 12:23:31 -08:00
|
|
|
info->free_func = free_func;
|
2007-02-04 18:06:05 -08:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_types = eina_list_append(efreet_desktop_types, info);
|
2007-02-04 18:06:05 -08:00
|
|
|
|
2007-02-05 13:16:55 -08:00
|
|
|
return id;
|
2007-02-04 18:06:05 -08:00
|
|
|
}
|
|
|
|
|
2007-06-20 11:04:26 -07:00
|
|
|
/**
|
|
|
|
* @brief Add an alias for an existing desktop type.
|
|
|
|
* @param from_type the type to alias (e.g. EFREE_DESKTOP_TYPE_APPLICATION)
|
|
|
|
* @param alias the alias
|
|
|
|
* @return the new type id, or -1 if @p from_type was not valid
|
|
|
|
*
|
2007-09-06 09:15:10 -07:00
|
|
|
* This allows applications to add non-standard types that behave exactly as standard types.
|
2007-06-20 11:04:26 -07:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int
|
|
|
|
efreet_desktop_type_alias(int from_type, const char *alias)
|
2007-06-20 11:04:26 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop_Type_Info *info;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
info = eina_list_nth(efreet_desktop_types, from_type);
|
2007-06-20 11:04:26 -07:00
|
|
|
if (!info) return -1;
|
|
|
|
|
|
|
|
return efreet_desktop_type_add(alias, info->parse_func, info->save_func, info->free_func);
|
|
|
|
}
|
|
|
|
|
2007-02-05 12:23:31 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @brief Free an Efreet Desktop_Type_Info struct
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_desktop_type_info_free(Efreet_Desktop_Type_Info *info)
|
|
|
|
{
|
|
|
|
if (!info) return;
|
|
|
|
IF_FREE(info->type);
|
|
|
|
free(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief get type specific data for custom desktop types
|
|
|
|
* @param desktop the desktop
|
|
|
|
* @return type specific data, or NULL if there is none
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void *
|
2007-02-05 12:23:31 -08:00
|
|
|
efreet_desktop_type_data_get(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
return desktop->type_data;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param type_str: the type as a string
|
|
|
|
* @return the parsed type
|
|
|
|
* @brief parse the type string into an Efreet_Desktop_Type
|
|
|
|
*/
|
2007-02-05 13:16:55 -08:00
|
|
|
static Efreet_Desktop_Type_Info *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_type_parse(const char *type_str)
|
|
|
|
{
|
2007-02-05 12:23:31 -08:00
|
|
|
Efreet_Desktop_Type_Info *info;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-02-05 13:16:55 -08:00
|
|
|
|
|
|
|
if (!type_str) return NULL;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(efreet_desktop_types, l, info)
|
2007-02-04 18:06:05 -08:00
|
|
|
{
|
2007-02-05 12:23:31 -08:00
|
|
|
if (!strcmp(info->type, type_str))
|
2007-02-05 13:16:55 -08:00
|
|
|
return info;
|
2007-02-04 18:06:05 -08:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-02-05 13:16:55 -08:00
|
|
|
return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string: the raw string list
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
* @return an Eina_List of ecore string's
|
2007-02-03 05:05:30 -08:00
|
|
|
* @brief Parse ';' separate list of strings according to the desktop spec
|
|
|
|
*/
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EAPI Eina_List *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_string_list_parse(const char *string)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *list = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
char *tmp;
|
|
|
|
char *s, *p;
|
|
|
|
|
|
|
|
if (!string) return NULL;
|
|
|
|
|
|
|
|
tmp = strdup(string);
|
|
|
|
s = tmp;
|
|
|
|
|
|
|
|
while ((p = strchr(s, ';')))
|
|
|
|
{
|
|
|
|
if (p > tmp && *(p-1) == '\\') continue;
|
|
|
|
*p = '\0';
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
list = eina_list_append(list, (void *)eina_stringshare_add(s));
|
2007-02-03 05:05:30 -08:00
|
|
|
s = p + 1;
|
|
|
|
}
|
|
|
|
/* If this is true, the .desktop file does not follow the standard */
|
|
|
|
if (*s)
|
|
|
|
{
|
2007-04-04 03:41:53 -07:00
|
|
|
#ifdef STRICT_SPEC
|
2009-09-21 09:36:29 -07:00
|
|
|
WRN("[Efreet]: Found a string list without ';' "
|
|
|
|
"at the end: %s", string);
|
2007-02-03 05:05:30 -08:00
|
|
|
#endif
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
list = eina_list_append(list, (void *)eina_stringshare_add(s));
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
free(tmp);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
* @param list: Eina_List with strings
|
2007-02-03 05:05:30 -08:00
|
|
|
* @return a raw string list
|
|
|
|
* @brief Create a ';' separate list of strings according to the desktop spec
|
|
|
|
*/
|
2007-11-04 04:29:36 -08:00
|
|
|
EAPI char *
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_string_list_join(Eina_List *list)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *tmp;
|
|
|
|
char *string;
|
|
|
|
size_t size, pos, len;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if (!list) return strdup("");
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
size = 1024;
|
|
|
|
string = malloc(size);
|
|
|
|
pos = 0;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(list, l, tmp)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
len = strlen(tmp);
|
|
|
|
/* +1 for ';' */
|
|
|
|
if ((len + pos + 1) >= size)
|
|
|
|
{
|
2007-05-04 08:02:55 -07:00
|
|
|
size = len + pos + 1024;
|
2007-02-03 05:05:30 -08:00
|
|
|
string = realloc(string, size);
|
|
|
|
}
|
|
|
|
strcpy(string + pos, tmp);
|
|
|
|
pos += len;
|
|
|
|
strcpy(string + pos, ";");
|
|
|
|
pos += 1;
|
|
|
|
}
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: the Efreet_Desktop to store parsed fields in
|
|
|
|
* @param ini: the Efreet_Ini to parse fields from
|
2007-02-05 13:16:55 -08:00
|
|
|
* @return No value
|
2007-02-03 05:05:30 -08:00
|
|
|
* @brief Parse application specific desktop fields
|
|
|
|
*/
|
2007-02-05 13:16:55 -08:00
|
|
|
static void *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_application_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|
|
|
{
|
|
|
|
const char *val;
|
|
|
|
|
|
|
|
val = efreet_ini_string_get(ini, "TryExec");
|
|
|
|
if (val) desktop->try_exec = strdup(val);
|
|
|
|
|
|
|
|
val = efreet_ini_string_get(ini, "Exec");
|
|
|
|
if (val) desktop->exec = strdup(val);
|
|
|
|
|
|
|
|
val = efreet_ini_string_get(ini, "Path");
|
|
|
|
if (val) desktop->path = strdup(val);
|
|
|
|
|
|
|
|
val = efreet_ini_string_get(ini, "StartupWMClass");
|
|
|
|
if (val) desktop->startup_wm_class = strdup(val);
|
|
|
|
|
|
|
|
desktop->categories = efreet_desktop_string_list_parse(
|
|
|
|
efreet_ini_string_get(ini, "Categories"));
|
|
|
|
desktop->mime_types = efreet_desktop_string_list_parse(
|
|
|
|
efreet_ini_string_get(ini, "MimeType"));
|
|
|
|
|
|
|
|
desktop->terminal = efreet_ini_boolean_get(ini, "Terminal");
|
|
|
|
desktop->startup_notify = efreet_ini_boolean_get(ini, "StartupNotify");
|
|
|
|
|
2007-02-05 13:16:55 -08:00
|
|
|
return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: the Efreet_Desktop to save fields from
|
|
|
|
* @param ini: the Efreet_Ini to save fields to
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Save application specific desktop fields
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_desktop_application_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|
|
|
{
|
|
|
|
char *val;
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
if (desktop->try_exec)
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_ini_string_set(ini, "TryExec", desktop->try_exec);
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
if (desktop->exec)
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_ini_string_set(ini, "Exec", desktop->exec);
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
if (desktop->path)
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_ini_string_set(ini, "Path", desktop->path);
|
|
|
|
|
|
|
|
if (desktop->startup_wm_class)
|
|
|
|
efreet_ini_string_set(ini, "StartupWMClass", desktop->startup_wm_class);
|
|
|
|
|
|
|
|
if (desktop->categories)
|
|
|
|
{
|
|
|
|
val = efreet_desktop_string_list_join(desktop->categories);
|
|
|
|
efreet_ini_string_set(ini, "Categories", val);
|
|
|
|
FREE(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desktop->mime_types)
|
|
|
|
{
|
|
|
|
val = efreet_desktop_string_list_join(desktop->mime_types);
|
|
|
|
efreet_ini_string_set(ini, "MimeType", val);
|
|
|
|
FREE(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
efreet_ini_boolean_set(ini, "Terminal", desktop->terminal);
|
|
|
|
efreet_ini_boolean_set(ini, "StartupNotify", desktop->startup_notify);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: the Efreet_Desktop to store parsed fields in
|
|
|
|
* @param ini: the Efreet_Ini to parse fields from
|
2007-02-05 13:16:55 -08:00
|
|
|
* @return Returns no value
|
2007-02-03 05:05:30 -08:00
|
|
|
* @brief Parse link specific desktop fields
|
|
|
|
*/
|
2007-02-05 13:16:55 -08:00
|
|
|
static void *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_link_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|
|
|
{
|
|
|
|
const char *val;
|
|
|
|
|
|
|
|
val = efreet_ini_string_get(ini, "URL");
|
|
|
|
if (val) desktop->url = strdup(val);
|
2007-02-05 13:16:55 -08:00
|
|
|
return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: the Efreet_Desktop to save fields from
|
|
|
|
* @param ini: the Efreet_Ini to save fields in
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Save link specific desktop fields
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_desktop_link_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|
|
|
{
|
|
|
|
if (desktop->url) efreet_ini_string_set(ini, "URL", desktop->url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: the Efreet_Desktop to store parsed fields in
|
|
|
|
* @param ini: the Efreet_Ini to parse fields from
|
|
|
|
* @return 1 if parsed succesfully, 0 otherwise
|
|
|
|
* @brief Parse desktop fields that all types can include
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
efreet_desktop_generic_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|
|
|
{
|
|
|
|
const char *val;
|
|
|
|
|
|
|
|
val = efreet_ini_localestring_get(ini, "Name");
|
|
|
|
if (val) desktop->name = strdup(val);
|
2007-09-06 09:15:10 -07:00
|
|
|
else
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2009-09-21 09:36:29 -07:00
|
|
|
ERR("efreet_desktop_generic_fields_parse error: no Name");
|
2007-02-03 05:05:30 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = efreet_ini_localestring_get(ini, "GenericName");
|
|
|
|
if (val) desktop->generic_name = strdup(val);
|
|
|
|
|
|
|
|
val = efreet_ini_localestring_get(ini, "Comment");
|
|
|
|
if (val) desktop->comment = strdup(val);
|
|
|
|
|
|
|
|
val = efreet_ini_localestring_get(ini, "Icon");
|
|
|
|
if (val) desktop->icon = strdup(val);
|
|
|
|
|
|
|
|
desktop->no_display = efreet_ini_boolean_get(ini, "NoDisplay");
|
|
|
|
desktop->hidden = efreet_ini_boolean_get(ini, "Hidden");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param desktop: the Efreet_Desktop to save fields from
|
|
|
|
* @param ini: the Efreet_Ini to save fields to
|
|
|
|
* @return Returns nothing
|
|
|
|
* @brief Save desktop fields that all types can include
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_desktop_generic_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|
|
|
{
|
|
|
|
const char *val;
|
|
|
|
|
|
|
|
if (desktop->name)
|
|
|
|
{
|
|
|
|
efreet_ini_localestring_set(ini, "Name", desktop->name);
|
|
|
|
val = efreet_ini_string_get(ini, "Name");
|
|
|
|
if (!val)
|
|
|
|
efreet_ini_string_set(ini, "Name", desktop->name);
|
|
|
|
}
|
|
|
|
if (desktop->generic_name)
|
|
|
|
{
|
|
|
|
efreet_ini_localestring_set(ini, "GenericName", desktop->generic_name);
|
|
|
|
val = efreet_ini_string_get(ini, "GenericName");
|
|
|
|
if (!val)
|
|
|
|
efreet_ini_string_set(ini, "GenericName", desktop->generic_name);
|
|
|
|
}
|
|
|
|
if (desktop->comment)
|
|
|
|
{
|
|
|
|
efreet_ini_localestring_set(ini, "Comment", desktop->comment);
|
|
|
|
val = efreet_ini_string_get(ini, "Comment");
|
|
|
|
if (!val)
|
|
|
|
efreet_ini_string_set(ini, "Comment", desktop->comment);
|
|
|
|
}
|
|
|
|
if (desktop->icon)
|
|
|
|
{
|
|
|
|
efreet_ini_localestring_set(ini, "Icon", desktop->icon);
|
|
|
|
val = efreet_ini_string_get(ini, "Icon");
|
|
|
|
if (!val)
|
|
|
|
efreet_ini_string_set(ini, "Icon", desktop->icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
efreet_ini_boolean_set(ini, "NoDisplay", desktop->no_display);
|
|
|
|
efreet_ini_boolean_set(ini, "Hidden", desktop->hidden);
|
2007-11-22 22:57:39 -08:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
if (desktop->x) eina_hash_foreach(desktop->x, efreet_desktop_x_fields_save,
|
2010-02-04 01:12:35 -08:00
|
|
|
ini);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param node: The node to work with
|
|
|
|
* @param desktop: The desktop file to work with
|
2009-02-26 14:35:38 -08:00
|
|
|
* @return Returns always true, to be used in eina_hash_foreach()
|
2007-11-22 22:57:39 -08:00
|
|
|
* @brief Parses out an X- key from @a node and stores in @a desktop
|
2007-02-03 05:05:30 -08:00
|
|
|
*/
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
2009-02-26 14:35:38 -08:00
|
|
|
efreet_desktop_x_fields_parse(const Eina_Hash *hash __UNUSED__, const void *key, void *value, void *fdata)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
Efreet_Desktop * desktop = fdata;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2009-02-26 14:35:38 -08:00
|
|
|
if (!desktop) return EINA_TRUE;
|
2008-12-17 07:33:43 -08:00
|
|
|
if (strncmp(key, "X-", 2)) return EINA_TRUE;
|
|
|
|
|
2009-02-26 14:35:38 -08:00
|
|
|
if (!desktop->x)
|
2010-02-04 01:12:35 -08:00
|
|
|
desktop->x = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_del(desktop->x, key, NULL);
|
|
|
|
eina_hash_add(desktop->x, key, (void *)eina_stringshare_add(value));
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
2007-11-22 22:57:39 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param node: The node to work with
|
|
|
|
* @param ini: The ini file to work with
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Stores an X- key from @a node and stores in @a ini
|
|
|
|
*/
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
2009-02-26 14:35:38 -08:00
|
|
|
efreet_desktop_x_fields_save(const Eina_Hash *hash __UNUSED__, const void *key, void *value, void *fdata)
|
2007-11-22 22:57:39 -08:00
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
Efreet_Ini *ini = fdata;
|
|
|
|
efreet_ini_string_set(ini, key, value);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2007-11-22 22:57:39 -08:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param ini: The Efreet_Ini to parse values from
|
|
|
|
* @return 1 if desktop should be included in current environement, 0 otherwise
|
2007-09-06 09:15:10 -07:00
|
|
|
* @brief Determines if a desktop should be included in the current environment,
|
2007-02-03 05:05:30 -08:00
|
|
|
* based on the values of the OnlyShowIn and NotShowIn fields
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
efreet_desktop_environment_check(Efreet_Ini *ini)
|
|
|
|
{
|
2009-02-25 08:46:51 -08:00
|
|
|
Eina_List *list;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
int found = 0;
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
if (!desktop_environment)
|
2010-02-04 01:12:35 -08:00
|
|
|
return 1;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
list = efreet_desktop_string_list_parse(efreet_ini_string_get(ini, "OnlyShowIn"));
|
|
|
|
if (list)
|
|
|
|
{
|
2010-02-04 01:12:35 -08:00
|
|
|
EINA_LIST_FREE(list, val)
|
|
|
|
{
|
|
|
|
if (!strcmp(val, desktop_environment))
|
|
|
|
found = 1;
|
|
|
|
eina_stringshare_del(val);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2010-02-04 01:12:35 -08:00
|
|
|
list = efreet_desktop_string_list_parse(efreet_ini_string_get(ini, "NotShowIn"));
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(list, val)
|
2010-02-04 01:12:35 -08:00
|
|
|
{
|
|
|
|
if (!strcmp(val, desktop_environment))
|
|
|
|
found = 1;
|
|
|
|
eina_stringshare_del(val);
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-02-04 01:12:35 -08:00
|
|
|
return !found;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: the desktop entry
|
2009-03-26 10:54:50 -07:00
|
|
|
* @param files: an eina list of file names to execute, as either absolute paths,
|
2007-02-03 05:05:30 -08:00
|
|
|
* relative paths, or uris
|
|
|
|
* @param func: a callback to call for each prepared command line
|
|
|
|
* @param data: user data passed to the callback
|
2008-02-20 07:39:03 -08:00
|
|
|
* @return Returns the return value of @p func on success or NULL on failure
|
2007-02-03 05:05:30 -08:00
|
|
|
* @brief Get a command to use to execute a desktop entry.
|
|
|
|
*/
|
2008-02-19 20:10:02 -08:00
|
|
|
EAPI void *
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_command_get(Efreet_Desktop *desktop, Eina_List *files,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Desktop_Command_Cb func, void *data)
|
|
|
|
{
|
|
|
|
return efreet_desktop_command_progress_get(desktop, files, func, NULL, data);
|
|
|
|
}
|
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
/**
|
|
|
|
* @param desktop: the desktop entry
|
2009-03-26 10:54:50 -07:00
|
|
|
* @param files an eina list of local files, as absolute paths, local paths, or file:// uris (or NULL to get exec string with no files appended)
|
|
|
|
* @return Returns an eina list of exec strings
|
2007-06-17 21:26:50 -07:00
|
|
|
* @brief Get the command to use to execute a desktop entry
|
|
|
|
*
|
|
|
|
* The returned list and each of its elements must be freed.
|
|
|
|
*/
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EAPI Eina_List *
|
|
|
|
efreet_desktop_command_local_get(Efreet_Desktop *desktop, Eina_List *files)
|
2007-06-17 21:26:50 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop_Command *command;
|
|
|
|
char *file;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *execs, *l;
|
2007-06-17 21:26:50 -07:00
|
|
|
|
|
|
|
if (!desktop || !desktop->exec) return NULL;
|
|
|
|
|
|
|
|
command = NEW(Efreet_Desktop_Command, 1);
|
|
|
|
if (!command) return 0;
|
|
|
|
|
|
|
|
command->desktop = desktop;
|
|
|
|
|
|
|
|
command->flags = efreet_desktop_command_flags_get(desktop);
|
|
|
|
/* get the required info for each file passed in */
|
|
|
|
if (files)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(files, l, file)
|
2007-06-17 21:26:50 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop_Command_File *dcf;
|
|
|
|
|
|
|
|
dcf = efreet_desktop_command_file_process(command, file);
|
|
|
|
if (!dcf) continue;
|
|
|
|
if (dcf->pending)
|
|
|
|
{
|
|
|
|
efreet_desktop_command_file_free(dcf);
|
|
|
|
continue;
|
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
command->files = eina_list_append(command->files, dcf);
|
2007-06-17 21:26:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
execs = efreet_desktop_command_build(command);
|
|
|
|
efreet_desktop_command_free(command);
|
|
|
|
|
|
|
|
return execs;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param desktop: the desktop entry
|
2009-03-26 10:54:50 -07:00
|
|
|
* @param files: an eina list of file names to execute, as either absolute paths,
|
2007-02-03 05:05:30 -08:00
|
|
|
* relative paths, or uris
|
|
|
|
* @param cb_command: a callback to call for each prepared command line
|
|
|
|
* @param cb_progress: a callback to get progress for the downloads
|
|
|
|
* @param data: user data passed to the callback
|
|
|
|
* @return Returns 1 on success or 0 on failure
|
2007-09-06 09:15:10 -07:00
|
|
|
* @brief Get a command to use to execute a desktop entry, and receive progress
|
2007-02-03 05:05:30 -08:00
|
|
|
* updates for downloading of remote URI's passed in.
|
|
|
|
*/
|
2008-02-19 20:10:02 -08:00
|
|
|
EAPI void *
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Eina_List *files,
|
2007-09-06 09:15:10 -07:00
|
|
|
Efreet_Desktop_Command_Cb cb_command,
|
|
|
|
Efreet_Desktop_Progress_Cb cb_progress,
|
2007-02-03 05:05:30 -08:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Command *command;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
char *file;
|
2008-02-19 20:10:02 -08:00
|
|
|
void *ret = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2008-02-19 20:10:02 -08:00
|
|
|
if (!desktop || !cb_command || !desktop->exec) return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
command = NEW(Efreet_Desktop_Command, 1);
|
2008-02-19 20:10:02 -08:00
|
|
|
if (!command) return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
command->cb_command = cb_command;
|
|
|
|
command->cb_progress = cb_progress;
|
|
|
|
command->data = data;
|
|
|
|
command->desktop = desktop;
|
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
command->flags = efreet_desktop_command_flags_get(desktop);
|
|
|
|
/* get the required info for each file passed in */
|
|
|
|
if (files)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(files, l, file)
|
2007-06-17 21:26:50 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop_Command_File *dcf;
|
|
|
|
|
|
|
|
dcf = efreet_desktop_command_file_process(command, file);
|
|
|
|
if (!dcf) continue;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
command->files = eina_list_append(command->files, dcf);
|
2007-06-17 21:26:50 -07:00
|
|
|
command->num_pending += dcf->pending;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command->num_pending == 0)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *execs;
|
2009-06-19 23:19:48 -07:00
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
execs = efreet_desktop_command_build(command);
|
2008-02-19 20:10:02 -08:00
|
|
|
ret = efreet_desktop_command_execs_process(command, execs);
|
2009-06-20 12:07:31 -07:00
|
|
|
eina_list_free(execs);
|
2007-06-17 21:26:50 -07:00
|
|
|
efreet_desktop_command_free(command);
|
|
|
|
}
|
|
|
|
|
2008-02-19 20:10:02 -08:00
|
|
|
return ret;
|
2007-06-17 21:26:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*
|
|
|
|
* @brief Determine which file related field codes are present in the Exec string of a .desktop
|
|
|
|
* @params desktop and Efreet Desktop
|
|
|
|
* @return a bitmask of file field codes present in exec string
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
efreet_desktop_command_flags_get(Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
int flags = 0;
|
|
|
|
const char *p;
|
2007-02-03 05:05:30 -08:00
|
|
|
/* first, determine which fields are present in the Exec string */
|
|
|
|
p = strchr(desktop->exec, '%');
|
|
|
|
while (p)
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
switch(*p)
|
|
|
|
{
|
|
|
|
case 'f':
|
|
|
|
case 'F':
|
2007-06-17 21:26:50 -07:00
|
|
|
flags |= EFREET_DESKTOP_EXEC_FLAG_FULLPATH;
|
2007-02-03 05:05:30 -08:00
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
case 'U':
|
2007-06-17 21:26:50 -07:00
|
|
|
flags |= EFREET_DESKTOP_EXEC_FLAG_URI;
|
2007-02-03 05:05:30 -08:00
|
|
|
break;
|
|
|
|
case '%':
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = strchr(p, '%');
|
|
|
|
}
|
2007-11-15 20:55:40 -08:00
|
|
|
#ifdef SLOPPY_SPEC
|
2010-02-04 01:12:35 -08:00
|
|
|
/* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
|
|
|
|
* do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
|
|
|
|
* unlikely to be fixed in distributions etc. in the long run as gnome/kde
|
|
|
|
* seem to have workarounds too so no one notices.
|
|
|
|
*/
|
|
|
|
if (!flags) flags |= EFREET_DESKTOP_EXEC_FLAG_FULLPATH;
|
2007-11-15 20:55:40 -08:00
|
|
|
#endif
|
2010-02-04 01:12:35 -08:00
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
return flags;
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*
|
|
|
|
* @brief Call the command callback for each exec in the list
|
2007-09-06 09:15:10 -07:00
|
|
|
* @param command
|
2007-06-17 21:26:50 -07:00
|
|
|
* @param execs
|
|
|
|
*/
|
2008-02-19 20:10:02 -08:00
|
|
|
static void *
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Eina_List *execs)
|
2007-06-17 21:26:50 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-06-17 21:26:50 -07:00
|
|
|
char *exec;
|
|
|
|
int num;
|
2008-02-19 20:10:02 -08:00
|
|
|
void *ret = NULL;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
num = eina_list_count(execs);
|
|
|
|
EINA_LIST_FOREACH(execs, l, exec)
|
2007-06-17 21:26:50 -07:00
|
|
|
{
|
2008-02-19 20:10:02 -08:00
|
|
|
ret = command->cb_command(command->data, command->desktop, exec, --num);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
2008-02-19 20:10:02 -08:00
|
|
|
return ret;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-09-06 09:15:10 -07:00
|
|
|
* @brief Builds the actual exec string from the raw string and a list of
|
|
|
|
* processed filename information. The callback passed in to
|
2007-02-03 05:05:30 -08:00
|
|
|
* efreet_desktop_command_get is called for each exec string created.
|
|
|
|
*
|
|
|
|
* @param command: the command to build
|
2007-06-17 21:26:50 -07:00
|
|
|
* @return a list of executable strings
|
2007-02-03 05:05:30 -08:00
|
|
|
*/
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_command_build(Efreet_Desktop_Command *command)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *execs = NULL;
|
2009-02-25 19:56:21 -08:00
|
|
|
const Eina_List *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
char *exec;
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
/* if the Exec field appends multiple, that will run the list to the end,
|
|
|
|
* causing this loop to only run once. otherwise, this loop will generate a
|
|
|
|
* command for each file in the list. if the list is empty, this
|
2007-02-03 05:05:30 -08:00
|
|
|
* will run once, removing any file field codes */
|
2009-02-25 19:56:21 -08:00
|
|
|
l = command->files;
|
|
|
|
do
|
2010-02-04 01:12:35 -08:00
|
|
|
{
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *p;
|
|
|
|
int len = 0;
|
|
|
|
int size = PATH_MAX;
|
|
|
|
int file_added = 0;
|
2010-02-04 01:12:35 -08:00
|
|
|
Efreet_Desktop_Command_File *file = eina_list_data_get(l);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
exec = malloc(size);
|
|
|
|
p = command->desktop->exec;
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
while (*p)
|
|
|
|
{
|
2007-09-06 09:15:10 -07:00
|
|
|
if (len >= size - 1)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2007-05-04 08:02:55 -07:00
|
|
|
size = len + 1024;
|
2007-02-03 05:05:30 -08:00
|
|
|
exec = realloc(exec, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX handle fields inside quotes? */
|
|
|
|
if (*p == '%')
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case 'f':
|
2007-09-06 09:15:10 -07:00
|
|
|
case 'u':
|
|
|
|
case 'd':
|
|
|
|
case 'n':
|
|
|
|
if (file)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2007-09-06 09:15:10 -07:00
|
|
|
exec = efreet_desktop_command_append_single(exec, &size,
|
2010-02-04 01:12:35 -08:00
|
|
|
&len, file, *p);
|
2007-02-03 05:05:30 -08:00
|
|
|
file_added = 1;
|
|
|
|
}
|
|
|
|
break;
|
2007-09-06 09:15:10 -07:00
|
|
|
case 'F':
|
|
|
|
case 'U':
|
|
|
|
case 'D':
|
|
|
|
case 'N':
|
|
|
|
if (file)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2007-09-06 09:15:10 -07:00
|
|
|
exec = efreet_desktop_command_append_multiple(exec, &size,
|
2010-02-04 01:12:35 -08:00
|
|
|
&len, command, *p);
|
2007-02-03 05:05:30 -08:00
|
|
|
file_added = 1;
|
|
|
|
}
|
|
|
|
break;
|
2007-09-06 09:15:10 -07:00
|
|
|
case 'i':
|
|
|
|
exec = efreet_desktop_command_append_icon(exec, &size, &len,
|
2010-02-04 01:12:35 -08:00
|
|
|
command->desktop);
|
2007-02-03 05:05:30 -08:00
|
|
|
break;
|
2007-09-06 09:15:10 -07:00
|
|
|
case 'c':
|
2007-02-03 05:05:30 -08:00
|
|
|
exec = efreet_desktop_command_append_quoted(exec, &size, &len,
|
2010-02-04 01:12:35 -08:00
|
|
|
command->desktop->name);
|
2007-02-03 05:05:30 -08:00
|
|
|
break;
|
2007-09-06 09:15:10 -07:00
|
|
|
case 'k':
|
|
|
|
exec = efreet_desktop_command_append_quoted(exec, &size, &len,
|
2010-02-04 01:12:35 -08:00
|
|
|
command->desktop->orig_path);
|
2007-02-03 05:05:30 -08:00
|
|
|
break;
|
2007-09-06 09:15:10 -07:00
|
|
|
case 'v':
|
|
|
|
case 'm':
|
2009-09-21 09:36:29 -07:00
|
|
|
WRN("[Efreet]: Deprecated conversion char: '%c' in file '%s'",
|
2010-02-04 01:12:35 -08:00
|
|
|
*p, command->desktop->orig_path);
|
2007-02-03 05:05:30 -08:00
|
|
|
break;
|
|
|
|
case '%':
|
|
|
|
exec[len++] = *p;
|
|
|
|
break;
|
|
|
|
default:
|
2007-04-04 03:41:53 -07:00
|
|
|
#ifdef STRICT_SPEC
|
2009-09-21 09:36:29 -07:00
|
|
|
WRN("[Efreet_desktop]: Unknown conversion character: '%c'", *p);
|
2007-02-03 05:05:30 -08:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else exec[len++] = *p;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2007-11-15 20:55:40 -08:00
|
|
|
#ifdef SLOPPY_SPEC
|
2010-02-04 01:12:35 -08:00
|
|
|
/* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
|
|
|
|
* do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
|
|
|
|
* unlikely to be fixed in distributions etc. in the long run as gnome/kde
|
|
|
|
* seem to have workarounds too so no one notices.
|
|
|
|
*/
|
|
|
|
if ((file) && (!file_added))
|
|
|
|
{
|
|
|
|
WRN("Efreet_desktop: %s\n"
|
|
|
|
" command: %s\n"
|
|
|
|
" has no file path/uri spec info for executing this app WITH a\n"
|
|
|
|
" file/uri as a parameter. This is unlikely to be the intent.\n"
|
|
|
|
" please check the .desktop file and fix it by adding a %%U or %%F\n"
|
|
|
|
" or something appropriate.",
|
|
|
|
command->desktop->orig_path, command->desktop->exec);
|
2007-11-15 18:35:01 -08:00
|
|
|
if (len >= size - 1)
|
2010-02-04 01:12:35 -08:00
|
|
|
{
|
|
|
|
size = len + 1024;
|
|
|
|
exec = realloc(exec, size);
|
|
|
|
}
|
|
|
|
exec[len++] = ' ';
|
|
|
|
exec = efreet_desktop_command_append_multiple(exec, &size,
|
|
|
|
&len, command, 'F');
|
|
|
|
file_added = 1;
|
|
|
|
}
|
2007-11-15 20:55:40 -08:00
|
|
|
#endif
|
2007-02-03 05:05:30 -08:00
|
|
|
exec[len++] = '\0';
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
execs = eina_list_append(execs, exec);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
/* If no file was added, then the Exec field doesn't contain any file
|
2007-02-03 05:05:30 -08:00
|
|
|
* fields (fFuUdDnN). We only want to run the app once in this case. */
|
|
|
|
if (!file_added) break;
|
2010-02-04 01:12:35 -08:00
|
|
|
}
|
2009-02-25 19:56:21 -08:00
|
|
|
while ((l = eina_list_next(l)) != NULL);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
return execs;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
efreet_desktop_command_free(Efreet_Desktop_Command *command)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Efreet_Desktop_Command_File *dcf;
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!command) return;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
while (command->files)
|
|
|
|
{
|
|
|
|
dcf = eina_list_data_get(command->files);
|
|
|
|
efreet_desktop_command_file_free(dcf);
|
|
|
|
command->files = eina_list_remove_list(command->files,
|
|
|
|
command->files);
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
FREE(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
efreet_desktop_command_append_quoted(char *dest, int *size, int *len, char *src)
|
|
|
|
{
|
|
|
|
if (!src) return dest;
|
|
|
|
dest = efreet_string_append(dest, size, len, "'");
|
|
|
|
|
|
|
|
/* single quotes in src need to be escaped */
|
|
|
|
if (strchr(src, '\''))
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
p = src;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (*p == '\'')
|
2008-07-06 07:06:31 -07:00
|
|
|
dest = efreet_string_append(dest, size, len, "\'\\\'");
|
2007-06-14 11:37:31 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
dest = efreet_string_append_char(dest, size, len, *p);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dest = efreet_string_append(dest, size, len, src);
|
|
|
|
|
|
|
|
dest = efreet_string_append(dest, size, len, "'");
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2007-09-06 09:15:10 -07:00
|
|
|
efreet_desktop_command_append_multiple(char *dest, int *size, int *len,
|
|
|
|
Efreet_Desktop_Command *command,
|
2007-02-03 05:05:30 -08:00
|
|
|
char type)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Command_File *file;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
int first = 1;
|
|
|
|
|
|
|
|
if (!command->files) return dest;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(command->files, l, file)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
if (first)
|
|
|
|
first = 0;
|
|
|
|
else
|
|
|
|
dest = efreet_string_append_char(dest, size, len, ' ');
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
dest = efreet_desktop_command_append_single(dest, size, len,
|
2007-02-03 05:05:30 -08:00
|
|
|
file, tolower(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2007-09-06 09:15:10 -07:00
|
|
|
efreet_desktop_command_append_single(char *dest, int *size, int *len,
|
|
|
|
Efreet_Desktop_Command_File *file,
|
2007-02-03 05:05:30 -08:00
|
|
|
char type)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case 'f':
|
|
|
|
str = file->fullpath;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
str = file->uri;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
str = file->dir;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
str = file->file;
|
|
|
|
break;
|
|
|
|
default:
|
2009-09-21 09:36:29 -07:00
|
|
|
ERR("Invalid type passed to efreet_desktop_command_append_single:"
|
|
|
|
" '%c'", type);
|
2007-02-03 05:05:30 -08:00
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!str) return dest;
|
|
|
|
|
|
|
|
dest = efreet_desktop_command_append_quoted(dest, size, len, str);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2007-09-06 09:15:10 -07:00
|
|
|
efreet_desktop_command_append_icon(char *dest, int *size, int *len,
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Desktop *desktop)
|
|
|
|
{
|
|
|
|
if (!desktop->icon || !desktop->icon[0]) return dest;
|
|
|
|
|
|
|
|
dest = efreet_string_append(dest, size, len, "--icon ");
|
|
|
|
dest = efreet_desktop_command_append_quoted(dest, size, len, desktop->icon);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append a string to a buffer, reallocating as necessary.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
efreet_string_append(char *dest, int *size, int *len, const char *src)
|
|
|
|
{
|
|
|
|
int l;
|
|
|
|
int off = 0;
|
|
|
|
|
2010-01-30 14:13:16 -08:00
|
|
|
l = eina_strlcpy(dest + *len, src, *size - *len);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
while (l > *size - *len)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
/* we successfully appended this much */
|
|
|
|
off += *size - *len - 1;
|
|
|
|
*len = *size - 1;
|
|
|
|
*size += 1024;
|
|
|
|
dest = realloc(dest, *size);
|
|
|
|
*(dest + *len) = '\0';
|
|
|
|
|
2010-01-30 14:13:16 -08:00
|
|
|
l = eina_strlcpy(dest + *len, src + off, *size - *len);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
*len += l;
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
efreet_string_append_char(char *dest, int *size, int *len, char c)
|
|
|
|
{
|
|
|
|
if (*len >= *size - 1)
|
|
|
|
{
|
|
|
|
*size += 1024;
|
|
|
|
dest = realloc(dest, *size);
|
|
|
|
}
|
|
|
|
|
|
|
|
dest[(*len)++] = c;
|
2007-02-09 04:20:49 -08:00
|
|
|
dest[*len] = '\0';
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param command: the Efreet_Desktop_Comand that this file is for
|
|
|
|
* @param file: the filname as either an absolute path, relative path, or URI
|
|
|
|
*/
|
|
|
|
static Efreet_Desktop_Command_File *
|
|
|
|
efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char *file)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Command_File *f;
|
|
|
|
const char *uri, *base;
|
|
|
|
int nonlocal = 0;
|
|
|
|
/*
|
2009-09-21 09:36:29 -07:00
|
|
|
DBG("FLAGS: %d, %d, %d, %d\n",
|
2007-02-03 05:05:30 -08:00
|
|
|
command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH ? 1 : 0,
|
2010-01-24 13:21:27 -08:00
|
|
|
command->flags & EFREET_DESKTOP_EXEC_FLAG_URI ? 1 : 0);
|
2007-02-03 05:05:30 -08:00
|
|
|
*/
|
|
|
|
f = NEW(Efreet_Desktop_Command_File, 1);
|
|
|
|
if (!f) return NULL;
|
|
|
|
|
|
|
|
f->command = command;
|
|
|
|
|
|
|
|
/* handle uris */
|
2010-02-04 01:12:35 -08:00
|
|
|
if (!strncmp(file, "http://", 7) || !strncmp(file, "ftp://", 6))
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
uri = file;
|
2007-07-25 10:01:04 -07:00
|
|
|
base = ecore_file_file_get(file);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
nonlocal = 1;
|
|
|
|
}
|
|
|
|
else if (!strncmp(file, "file:", 5))
|
|
|
|
{
|
|
|
|
file = efreet_desktop_command_file_uri_process(file);
|
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
efreet_desktop_command_file_free(f);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nonlocal)
|
|
|
|
{
|
|
|
|
/* process non-local uri */
|
|
|
|
if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2009-12-23 12:55:23 -08:00
|
|
|
snprintf(buf, sizeof(buf), "/tmp/%d-%d-%s", getpid(),
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_desktop_command_file_id++, base);
|
|
|
|
f->fullpath = strdup(buf);
|
|
|
|
f->pending = 1;
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
ecore_file_download(uri, f->fullpath, efreet_desktop_cb_download_complete,
|
2009-11-13 15:59:46 -08:00
|
|
|
efreet_desktop_cb_download_progress, f, NULL);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
if (command->flags & EFREET_DESKTOP_EXEC_FLAG_URI)
|
2007-02-03 05:05:30 -08:00
|
|
|
f->uri = strdup(uri);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-01 13:43:59 -08:00
|
|
|
char *absol = efreet_desktop_command_path_absolute(file);
|
2007-02-03 05:05:30 -08:00
|
|
|
/* process local uri/path */
|
|
|
|
if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH)
|
2010-03-01 13:43:59 -08:00
|
|
|
f->fullpath = strdup(absol);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (command->flags & EFREET_DESKTOP_EXEC_FLAG_URI)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
2010-03-01 13:43:59 -08:00
|
|
|
snprintf(buf, sizeof(buf), "file://%s", absol);
|
2007-02-03 05:05:30 -08:00
|
|
|
f->uri = strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(abs);
|
|
|
|
}
|
|
|
|
#if 0
|
2009-09-21 09:36:29 -07:00
|
|
|
INF(" fullpath: %s", f->fullpath);
|
|
|
|
INF(" uri: %s", f->uri);
|
|
|
|
INF(" dir: %s", f->dir);
|
|
|
|
INF(" file: %s", f->file);
|
2007-02-03 05:05:30 -08:00
|
|
|
#endif
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Find the local path portion of a file uri.
|
|
|
|
* @param uri: a uri beginning with "file:"
|
2007-09-06 09:15:10 -07:00
|
|
|
* @return the location of the path portion of the uri,
|
2007-02-03 05:05:30 -08:00
|
|
|
* or NULL if the file is not on this machine
|
|
|
|
*/
|
|
|
|
static const char *
|
|
|
|
efreet_desktop_command_file_uri_process(const char *uri)
|
|
|
|
{
|
|
|
|
const char *path = NULL;
|
|
|
|
int len = strlen(uri);
|
|
|
|
|
|
|
|
/* uri:foo/bar => relative path foo/bar*/
|
2007-09-06 09:15:10 -07:00
|
|
|
if (len >= 4 && uri[5] != '/')
|
2007-02-03 05:05:30 -08:00
|
|
|
path = uri + strlen("file:");
|
|
|
|
|
|
|
|
/* uri:/foo/bar => absolute path /foo/bar */
|
|
|
|
else if (len >= 5 && uri[6] != '/')
|
|
|
|
path = uri + strlen("file:");
|
|
|
|
|
|
|
|
/* uri://foo/bar => absolute path /bar on machine foo */
|
|
|
|
else if (len >= 6 && uri[7] != '/')
|
|
|
|
{
|
|
|
|
char *tmp, *p;
|
|
|
|
char hostname[PATH_MAX];
|
|
|
|
tmp = strdup(uri + 7);
|
|
|
|
p = strchr(tmp, '/');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
*p = '\0';
|
2007-09-06 09:15:10 -07:00
|
|
|
if (!strcmp(tmp, "localhost"))
|
2007-02-03 05:05:30 -08:00
|
|
|
path = uri + strlen("file://localhost");
|
2007-09-06 09:15:10 -07:00
|
|
|
else
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2007-09-06 09:15:10 -07:00
|
|
|
ret = gethostname(hostname, PATH_MAX);
|
|
|
|
if ((ret == 0) && !strcmp(tmp, hostname))
|
2007-02-03 05:05:30 -08:00
|
|
|
path = uri + strlen("file://") + strlen(hostname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* uri:///foo/bar => absolute path /foo/bar on local machine */
|
|
|
|
else if (len >= 7)
|
|
|
|
path = uri + strlen("file://");
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
efreet_desktop_command_file_free(Efreet_Desktop_Command_File *file)
|
|
|
|
{
|
|
|
|
if (!file) return;
|
|
|
|
|
|
|
|
IF_FREE(file->fullpath);
|
|
|
|
IF_FREE(file->uri);
|
|
|
|
IF_FREE(file->dir);
|
|
|
|
IF_FREE(file->file);
|
|
|
|
|
|
|
|
FREE(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2007-09-06 09:15:10 -07:00
|
|
|
efreet_desktop_cb_download_complete(void *data, const char *file __UNUSED__,
|
2007-02-03 05:05:30 -08:00
|
|
|
int status __UNUSED__)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Command_File *f;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
f = data;
|
|
|
|
|
|
|
|
/* XXX check status... error handling, etc */
|
|
|
|
f->pending = 0;
|
|
|
|
f->command->num_pending--;
|
|
|
|
|
|
|
|
if (f->command->num_pending <= 0)
|
2007-06-17 21:26:50 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *execs;
|
2009-06-19 23:50:01 -07:00
|
|
|
|
2007-06-17 21:26:50 -07:00
|
|
|
execs = efreet_desktop_command_build(f->command);
|
2008-02-24 11:20:08 -08:00
|
|
|
/* TODO: Need to handle the return value from efreet_desktop_command_execs_process */
|
2007-06-17 21:26:50 -07:00
|
|
|
efreet_desktop_command_execs_process(f->command, execs);
|
2009-06-20 12:07:31 -07:00
|
|
|
eina_list_free(execs);
|
2007-06-17 21:26:50 -07:00
|
|
|
efreet_desktop_command_free(f->command);
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
efreet_desktop_cb_download_progress(void *data,
|
|
|
|
const char *file __UNUSED__,
|
|
|
|
long int dltotal, long int dlnow,
|
|
|
|
long int ultotal __UNUSED__,
|
|
|
|
long int ulnow __UNUSED__)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Command_File *dcf;
|
|
|
|
|
|
|
|
dcf = data;
|
|
|
|
if (dcf->command->cb_progress)
|
2007-09-06 09:15:10 -07:00
|
|
|
return dcf->command->cb_progress(dcf->command->data,
|
|
|
|
dcf->command->desktop,
|
2007-02-03 05:05:30 -08:00
|
|
|
dcf->uri, dltotal, dlnow);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Build an absolute path from an absolute or relative one.
|
|
|
|
* @param path: an absolute or relative path
|
|
|
|
* @return an allocated absolute path (must be freed)
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
efreet_desktop_command_path_absolute(const char *path)
|
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
int size = PATH_MAX;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
/* relative url */
|
|
|
|
if (path[0] != '/')
|
|
|
|
{
|
2008-03-17 21:01:41 -07:00
|
|
|
if (!(buf = malloc(size))) return NULL;
|
|
|
|
if (!getcwd(buf, size))
|
|
|
|
{
|
|
|
|
FREE(buf);
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
len = strlen(buf);
|
|
|
|
|
|
|
|
if (buf[len-1] != '/') buf = efreet_string_append(buf, &size, &len, "/");
|
|
|
|
buf = efreet_string_append(buf, &size, &len, path);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2008-03-17 21:01:41 -07:00
|
|
|
/* just dup an already absolute buffer */
|
2007-02-03 05:05:30 -08:00
|
|
|
return strdup(path);
|
|
|
|
}
|
2009-05-15 04:47:39 -07:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
efreet_desktop_x_field_set(Efreet_Desktop *desktop, const char *key, const char *data)
|
|
|
|
{
|
2010-02-04 01:12:35 -08:00
|
|
|
if (!desktop || strncmp(key, "X-", 2))
|
|
|
|
return EINA_FALSE;
|
2009-05-15 04:47:39 -07:00
|
|
|
|
2010-02-04 01:12:35 -08:00
|
|
|
if (!desktop->x)
|
|
|
|
desktop->x = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
|
|
|
|
|
|
|
eina_hash_del(desktop->x, key, NULL);
|
|
|
|
eina_hash_add(desktop->x, key, eina_stringshare_add(data));
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2009-05-15 04:47:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
efreet_desktop_x_field_get(Efreet_Desktop *desktop, const char *key)
|
|
|
|
{
|
2010-02-04 01:12:35 -08:00
|
|
|
const char *ret;
|
|
|
|
|
|
|
|
if (!desktop || strncmp(key, "X-", 2))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!desktop->x)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = eina_hash_find(desktop->x, key);
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return eina_stringshare_add(ret);
|
2009-05-15 04:47:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
efreet_desktop_x_field_del(Efreet_Desktop *desktop, const char *key)
|
|
|
|
{
|
2010-02-04 01:12:35 -08:00
|
|
|
if (!desktop || strncmp(key, "X-", 2))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!desktop->x)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
return eina_hash_del(desktop->x, key, NULL);
|
2009-05-15 04:47:39 -07:00
|
|
|
}
|
2010-03-01 10:16:32 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI Eet_Data_Descriptor *
|
|
|
|
efreet_desktop_edd_init(void)
|
|
|
|
{
|
|
|
|
Eet_Data_Descriptor *edd;
|
|
|
|
|
|
|
|
Eet_Data_Descriptor_Class eddc;
|
|
|
|
if (!eet_eina_file_data_descriptor_class_set(&eddc, "cache", sizeof(Efreet_Desktop))) return NULL;
|
|
|
|
edd = eet_data_descriptor_file_new(&eddc);
|
|
|
|
if (!edd) return NULL;
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "type", type, EET_T_INT);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "version", version, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "orig_path", orig_path, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "load_time", load_time, EET_T_LONG_LONG);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "name", name, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "generic_name", generic_name, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "comment", comment, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "icon", icon, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "try_exec", try_exec, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "exec", exec, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "path", path, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "startup_wm_class", startup_wm_class, EET_T_STRING);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "url", url, EET_T_STRING);
|
|
|
|
eet_data_descriptor_element_add(edd, "only_show_in", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, only_show_in), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(edd, "not_show_in", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, not_show_in), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(edd, "categories", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, categories), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(edd, "mime_types", EET_T_STRING, EET_G_LIST, offsetof(Efreet_Desktop, mime_types), 0, NULL, NULL);
|
|
|
|
eet_data_descriptor_element_add(edd, "x", EET_T_STRING, EET_G_HASH, offsetof(Efreet_Desktop, x), 0, NULL, NULL);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "no_display", no_display, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "hidden", hidden, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "terminal", terminal, EET_T_UCHAR);
|
|
|
|
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Efreet_Desktop, "startup_notify", startup_notify, EET_T_UCHAR);
|
|
|
|
return edd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Needs EAPI because of helper binaries
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
efreet_desktop_edd_shutdown(Eet_Data_Descriptor *edd)
|
|
|
|
{
|
|
|
|
eet_data_descriptor_free(edd);
|
|
|
|
}
|
|
|
|
|