Initial import of efreet, an implementation of the freedesktop icon and menu

specs.


SVN revision: 28214
This commit is contained in:
ningerso 2007-02-03 13:05:30 +00:00 committed by ningerso
parent 5bcce9f86b
commit 9e363d07e9
44 changed files with 14826 additions and 0 deletions

4
legacy/efreet/AUTHORS Normal file
View File

@ -0,0 +1,4 @@
dan 'dj2' sinclair
Brian 'rephorm' Mattern
Sebastian 'englebass' Dransfeld
Nathan 'RbdPngn' Ingersoll

20
legacy/efreet/COPYING Normal file
View File

@ -0,0 +1,20 @@
Copyright (C) 2006 dan sinclair and various contributors (see AUTHORS)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies of the Software, its documentation and marketing & publicity
materials, and acknowledgment shall be given in the documentation, materials
and software packages that this Software was used.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1252
legacy/efreet/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

48
legacy/efreet/NOTES Normal file
View File

@ -0,0 +1,48 @@
rephorm one thing. if you plan to add .desktop editing, according to the
spec you need to keep EVERYTHING around (even sections / keys you don't know
/ care about)
dj2 k
rephorm but for most usage (read only) thats a waste of memory
dj2 hm, i guess the best way to do that is keep everything in a hash
dj2 and write accessor functions
dj2 or pull the common stuff out to functions and leve the rest in the hash
rephorm and maybe have a flag for 'readonly' to kill the hash
dj2 yea, will have to put some tought into the api for that
rephorm ooh. comments need to be preserved also in edits
rephorm efreet_xml has one bug that i see
rephorm if you have something like <tag>before<child />after</tag>, you
can't get to the 'after' text
dj2 hm, will have to look at that
rephorm (it stores 'before' as the text on 'tag')
rephorm it should probably create child nodes with the text
rephorm so tag would have 3 children, text: before, tag: child and text: after
efreet_desktop_string_list_parse() needs to optionally use comma (',') as
the separator if the desktop version is < 1.0 (but, what if it isn't set??)
desktop_command_get:
check for needed types (nNfFuU)
get lists of needed types (dirs, fullpaths, urls, etc)
if type in uU:
create Pending struct
start downloads, pass Pending in as data
else:
if tyep in UF...
exec
download cb:
if type in fF

20
legacy/efreet/TODO Normal file
View File

@ -0,0 +1,20 @@
TODO
----
- Efreet_Menu should setup an Ecore_File_Monitor on the .menu files and the
app_dir and reload the menu when needed
- .desktop saving
- We need a better system to distinguish between when a user wants to create a
new .desktop file and when he wants to parse an existing file.
- The move handling is wrong when moving to a destination with /'s in the
name. We should be creating intermediate menus for each of the /'d items
instead of just making the name as we do now
Notes from the Menu Spec test
-----------------------------
- We're appending the / to the menu names in the test case. We should
possibly be doing that in the efreet code itself.

16
legacy/efreet/autogen.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh
touch README
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi

View File

@ -0,0 +1,80 @@
AC_INIT(configure.in)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(efreet, 0.0.3)
AM_CONFIG_HEADER(config.h)
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_C_CONST
AM_ENABLE_SHARED
AM_PROG_LIBTOOL
AC_C___ATTRIBUTE__
dnl Set PACKAGE_DATA_DIR in config.h.
AC_DEFINE_DIR([PACKAGE_DATA_DIR], [datadir], [Shared Data Directory.])
PCFLAGS=$CFLAGS
AC_PATH_GENERIC(ecore, 0.9.9,
[ ],
[
AC_MSG_ERROR([
ERROR:
The ecore-config development script was not found in your execute
path. This may mean one of several things
1. You may not have installed the ecore-devel (or ecore-dev) packages.
2. You may have ecore installed somewhere not covered by your path.
If this is the case make sure you have the packages installed, AND
that the ecore-config script is in your execute path (see your
shell's manual page on setting the \$PATH environment variable), OR
alternatively, specify the script to use with --with-ecore-config.
])
]
)
CFLAGS=$ECORE_CFLAGS" "$CFLAGS
requirements="ecore"
AC_ARG_ENABLE(ecore-desktop,
[AC_HELP_STRING([--enable-ecore-desktop],[Enable Ecore_Desktop tests])],
[enable_ecore_desktop=$enableval], [enable_ecore_desktop="auto"])
have_ecore_desktop=no
if test "x$enable_ecore_desktop" != "xno" ; then
AC_CHECK_HEADER(Ecore_Desktop.h,
[have_ecore_desktop=yes],
[], [])
if test "x$have_ecore_desktop" = "xyes" ; then
AC_DEFINE(ENABLE_ECORE_DESKTOP, 1, [Enable Ecore_Desktop])
elif test "x$enable_ecore_desktop" = "xyes" ; then
AC_MSG_ERROR(No Ecore_Desktop found disabling comparison tests.)
fi
fi
AM_CONDITIONAL(HAVE_ECORE_DESKTOP, test "x$have_ecore_desktop" = xyes)
AC_ARG_ENABLE(strict-spec,
[AC_HELP_STRING([--enable-strict-spec],[Enable strict spec compliance])],
[enable_strict_spec=$enableval], [enable_strict_spec="auto"])
STRICT_SPEC=0
if test "x$enable_strict_spec" = "xyes" ; then
STRICT_SPEC=1
fi
AC_DEFINE_UNQUOTED(STRICT_SPEC, $STRICT_SPEC, [Strict Spec Compliance])
CFLAGS=$PCFLAGS
AC_SUBST(requirements)
AC_OUTPUT([
efreet-config
Makefile
src/Makefile
src/lib/Makefile
src/bin/Makefile
src/bin/data/Makefile
src/bin/data/sub/Makefile
src/bin/compare/Makefile
], []
)

View File

@ -0,0 +1,59 @@
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
exec_prefix_set=no
usage="\
Usage: efreet-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
if test $# -eq 0; then
echo "${usage}" 1>&2
exit 1
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo $prefix
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo $exec_prefix
;;
--version)
echo @VERSION@
;;
--cflags)
if test @prefix@/include != /usr/include ; then
includes="-I@prefix@/include"
fi
echo $includes @ECORE_CFLAGS@ -I$prefix/include/efreet
;;
--libs)
libdirs=-L@libdir@
echo $libdirs -lefreet @ECORE_LIBS@
;;
*)
echo "${usage}" 1>&2
exit 1
;;
esac
shift
done
exit 0

View File

@ -0,0 +1,15 @@
AC_DEFUN([AC_C___ATTRIBUTE__],
[
AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [
AC_TRY_COMPILE([#include <stdlib.h>
int func(int x); int foo(int x __attribute__ ((unused))) { exit(1); }],
[],
ac_cv___attribute__=yes, ac_cv___attribute__=no)])
if test "$ac_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [Define to 1 if your compiler has __attribute__])
fi
AC_MSG_RESULT($ac_cv___attribute__)
])

View File

@ -0,0 +1,47 @@
##### http://autoconf-archive.cryp.to/ac_define_dir.html
#
# SYNOPSIS
#
# AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
#
# DESCRIPTION
#
# This macro sets VARNAME to the expansion of the DIR variable,
# taking care of fixing up ${prefix} and such.
#
# VARNAME is then offered as both an output variable and a C
# preprocessor symbol.
#
# Example:
#
# AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
#
# LAST MODIFICATION
#
# 2006-10-13
#
# COPYLEFT
#
# Copyright (c) 2006 Stepan Kasal <kasal@ucw.cz>
# Copyright (c) 2006 Andreas Schwab <schwab@suse.de>
# Copyright (c) 2006 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2006 Alexandre Oliva
#
# Copying and distribution of this file, with or without
# modification, are permitted in any medium without royalty provided
# the copyright notice and this notice are preserved.
AC_DEFUN([AC_DEFINE_DIR], [
prefix_NONE=
exec_prefix_NONE=
test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
dnl refers to ${prefix}. Thus we have to use `eval' twice.
eval ac_define_dir="\"[$]$2\""
eval ac_define_dir="\"$ac_define_dir\""
AC_SUBST($1, "$ac_define_dir")
AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
test "$prefix_NONE" && prefix=NONE
test "$exec_prefix_NONE" && exec_prefix=NONE
])

View File

@ -0,0 +1,138 @@
dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl
dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS
dnl
dnl The script must support `--cflags' and `--libs' args.
dnl If MINIMUM-VERSION is specified, the script must also support the
dnl `--version' arg.
dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given,
dnl it must also support `--prefix' and `--exec-prefix'.
dnl (In other words, it must be like gtk-config.)
dnl
dnl For example:
dnl
dnl AC_PATH_GENERIC(Foo, 1.0.0)
dnl
dnl would run `foo-config --version' and check that it is at least 1.0.0
dnl
dnl If so, the following would then be defined:
dnl
dnl FOO_CFLAGS to `foo-config --cflags`
dnl FOO_LIBS to `foo-config --libs`
dnl
dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK)
dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount)
dnl
dnl @author Angus Lees <gusl@cse.unsw.edu.au>
AC_DEFUN([AC_PATH_GENERIC],
[dnl
dnl we're going to need uppercase, lowercase and user-friendly versions of the
dnl string `LIBRARY'
pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
dnl
dnl Get the cflags and libraries from the LIBRARY-config script
dnl
AC_ARG_WITH(DOWN-prefix,
[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)],
DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
AC_ARG_WITH(DOWN-exec-prefix,
[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)],
DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
if test x$DOWN[]_config_exec_prefix != x ; then
DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
if test x${UP[]_CONFIG+set} != xset ; then
UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
fi
fi
if test x$DOWN[]_config_prefix != x ; then
DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
if test x${UP[]_CONFIG+set} != xset ; then
UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
fi
fi
AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no)
ifelse([$2], ,
AC_MSG_CHECKING(for $1),
AC_MSG_CHECKING(for $1 - version >= $2)
)
no_[]DOWN=""
if test "$UP[]_CONFIG" = "no" ; then
no_[]DOWN=yes
else
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
ifelse([$2], , ,[
DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'`
DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])"
DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])"
DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])"
# Compare wanted version to what config script returned.
# If I knew what library was being run, i'd probably also compile
# a test program at this point (which also extracted and tested
# the version in some library-specific way)
if test "$DOWN[]_config_major_version" -lt \
"$DOWN[]_wanted_major_version" \
-o \( "$DOWN[]_config_major_version" -eq \
"$DOWN[]_wanted_major_version" \
-a "$DOWN[]_config_minor_version" -lt \
"$DOWN[]_wanted_minor_version" \) \
-o \( "$DOWN[]_config_major_version" -eq \
"$DOWN[]_wanted_major_version" \
-a "$DOWN[]_config_minor_version" -eq \
"$DOWN[]_wanted_minor_version" \
-a "$DOWN[]_config_micro_version" -lt \
"$DOWN[]_wanted_micro_version" \) ; then
# older version found
no_[]DOWN=yes
echo -n "*** An old version of $1 "
echo -n "($DOWN[]_config_major_version"
echo -n ".$DOWN[]_config_minor_version"
echo ".$DOWN[]_config_micro_version) was found."
echo -n "*** You need a version of $1 newer than "
echo -n "$DOWN[]_wanted_major_version"
echo -n ".$DOWN[]_wanted_minor_version"
echo ".$DOWN[]_wanted_micro_version."
echo "***"
echo "*** If you have already installed a sufficiently new version, this error"
echo "*** probably means that the wrong copy of the DOWN-config shell script is"
echo "*** being found. The easiest way to fix this is to remove the old version"
echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the"
echo "*** correct copy of DOWN-config. (In this case, you will have to"
echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
echo "*** so that the correct libraries are found at run-time)"
fi
])
fi
if test "x$no_[]DOWN" = x ; then
AC_MSG_RESULT(yes)
ifelse([$3], , :, [$3])
else
AC_MSG_RESULT(no)
if test "$UP[]_CONFIG" = "no" ; then
echo "*** The DOWN-config script installed by $1 could not be found"
echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the UP[]_CONFIG environment variable to the"
echo "*** full path to DOWN-config."
fi
UP[]_CFLAGS=""
UP[]_LIBS=""
ifelse([$4], , :, [$4])
fi
AC_SUBST(UP[]_CFLAGS)
AC_SUBST(UP[]_LIBS)
popdef([UP])
popdef([DOWN])
])

View File

@ -0,0 +1,4 @@
SUBDIRS = lib bin
MAINTAINERCLEANFILES = Makefile.in

View File

@ -0,0 +1,25 @@
SUBDIRS = data compare
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = \
-I. -I$(top_srcdir)/src/lib @ECORE_CFLAGS@
bin_PROGRAMS = efreet_test efreet_spec_test
efreet_test_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la
efreet_test_LDADD = $(top_builddir)/src/lib/libefreet.la @ECORE_LIBS@
efreet_test_SOURCES = \
ef_data_dirs.c \
ef_icon_theme.c \
ef_ini.c \
ef_locale.c \
ef_desktop.c \
ef_menu.c \
main.c
efreet_spec_test_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la
efreet_spec_test_LDADD = $(top_builddir)/src/lib/libefreet.la
efreet_spec_test_SOURCES = \
efreet_spec_test.c

View File

@ -0,0 +1,29 @@
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = \
-I. -I$(top_srcdir)/src/lib @ECORE_CFLAGS@
if HAVE_ECORE_DESKTOP
bin_PROGRAMS = efreet_alloc ecore_alloc compare_results efreet_menu_alloc
else
bin_PROGRAMS = efreet_alloc efreet_menu_alloc
endif
efreet_menu_alloc_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la
efreet_menu_alloc_SOURCES = efreet_menu_alloc.c comp.h
efreet_menu_alloc_LDADD = $(top_builddir)/src/lib/libefreet.la @ECORE_LIBS@
efreet_alloc_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la
efreet_alloc_SOURCES = efreet_alloc.c comp.h
efreet_alloc_LDADD = $(top_builddir)/src/lib/libefreet.la @ECORE_LIBS@
if HAVE_ECORE_DESKTOP
ecore_alloc_DEPENDENCIES =
ecore_alloc_SOURCES = ecore_alloc.c comp.h
ecore_alloc_LDADD = @ECORE_LIBS@
compare_results_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la
compare_results_SOURCES = compare_results.c comp.h
compare_results_LDADD = $(top_builddir)/src/lib/libefreet.la @ECORE_LIBS@
endif

View File

@ -0,0 +1,528 @@
#ifndef COMP_H
#define COMP_H
#define LOOPS 1000
#define THEME "Tango"
#define SIZE "16x16"
#define ADDRESS_BOOK_NEW "address-book-new"
#define APPLICATION_EXIT "application-exit"
#define APPOINTMENT_NEW "appointment-new"
#define CONTACT_NEW "contact-new"
#define DIALOG_APPLY "dialog-apply"
#define DIALOG_CANCEL "dialog-cancel"
#define DIALOG_CLOSE "dialog-close"
#define DIALOG_OK "dialog-ok"
#define DOCUMENT_NEW "document-new"
#define DOCUMENT_OPEN "document-open"
#define DOCUMENT_OPEN_RECENT "document-open-recent"
#define DOCUMENT_PAGE_SETUP "document-page-setup"
#define DOCUMENT_PRINT "document-print"
#define DOCUMENT_PRINT_PREVIEW "document-print-preview"
#define DOCUMENT_PROPERTIES "document-properties"
#define DOCUMENT_REVERT "document-revert"
#define DOCUMENT_SAVE "document-save"
#define DOCUMENT_SAVE_AS "document-save-as"
#define EDIT_COPY "edit-copy"
#define EDIT_CUT "edit-cut"
#define EDIT_DELETE "edit-delete"
#define EDIT_FIND "edit-find"
#define EDIT_FIND_REPLACE "edit-find-replace"
#define EDIT_PASTE "edit-paste"
#define EDIT_REDO "edit-redo"
#define EDIT_SELECT_ALL "edit-select-all"
#define EDIT_UNDO "edit-undo"
#define FORMAT_INDENT_LESS "format-indent-less"
#define FORMAT_INDENT_MORE "format-indent-more"
#define FORMAT_JUSTIFY_CENTER "format-justify-center"
#define FORMAT_JUSTIFY_FILL "format-justify-fill"
#define FORMAT_JUSTIFY_LEFT "format-justify-left"
#define FORMAT_JUSTIFY_RIGHT "format-justify-right"
#define FORMAT_TEXT_DIRECTION_LTR "format-text-direction-ltr"
#define FORMAT_TEXT_DIRECTION_RTL "format-text-direction-rtl"
#define FORMAT_TEXT_BOLD "format-text-bold"
#define FORMAT_TEXT_ITALIC "format-text-italic"
#define FORMAT_TEXT_UNDERLINE "format-text-underline"
#define FORMAT_TEXT_STRIKETHROUGH "format-text-strikethrough"
#define GO_BOTTOM "go-bottom"
#define GO_DOWN "go-down"
#define GO_FIRST "go-first"
#define GO_HOME "go-home"
#define GO_JUMP "go-jump"
#define GO_LAST "go-last"
#define GO_NEXT "go-next"
#define GO_PREVIOUS "go-previous"
#define GO_TOP "go-top"
#define GO_UP "go-up"
#define HELP_ABOUT "help-about"
#define HELP_CONTENTS "help-contents"
#define HELP_FAQ "help-faq"
#define INSERT_IMAGE "insert-image"
#define INSERT_LINK "insert-link"
#define INSERT_OBJECT "insert-object"
#define INSERT_TEXT "insert-text"
#define LIST_ADD "list-add"
#define LIST_REMOVE "list-remove"
#define MAIL_FORWARD "mail-forward"
#define MAIL_MARK_IMPORTANT "mail-mark-important"
#define MAIL_MARK_JUNK "mail-mark-junk"
#define MAIL_MARK_NOTJUNK "mail-mark-notjunk"
#define MAIL_MARK_READ "mail-mark-read"
#define MAIL_MARK_UNREAD "mail-mark-unread"
#define MAIL_MESSAGE_NEW "mail-message-new"
#define MAIL_REPLY_ALL "mail-reply-all"
#define MAIL_REPLY_SENDER "mail-reply-sender"
#define MAIL_SEND_RECEIVE "mail-send-receive"
#define MEDIA_EJECT "media-eject"
#define MEDIA_PLAYBACK_PAUSE "media-playback-pause"
#define MEDIA_PLAYBACK_START "media-playback-start"
#define MEDIA_PLAYBACK_STOP "media-playback-stop"
#define MEDIA_RECORD "media-record"
#define MEDIA_SEEK_BACKWARD "media-seek-backward"
#define MEDIA_SEEK_FORWARD "media-seek-forward"
#define MEDIA_SKIP_BACKWARD "media-skip-backward"
#define MEDIA_SKIP_FORWARD "media-skip-forward"
#define SYSTEM_LOCK_SCREEN "system-lock-screen"
#define SYSTEM_LOG_OUT "system-log-out"
#define SYSTEM_RUN "system-run"
#define SYSTEM_SEARCH "system-search"
#define TOOLS_CHECK_SPELLING "tools-check-spelling"
#define VIEW_FULLSCREEN "view-fullscreen"
#define VIEW_REFRESH "view-refresh"
#define VIEW_SORT_ASCENDING "view-sort-ascending"
#define VIEW_SORT_DESCENDING "view-sort-descending"
#define WINDOW_CLOSE "window-close"
#define WINDOW_NEW "window-new"
#define ZOOM_BEST_FIT "zoom-best-fit"
#define ZOOM_IN "zoom-in"
#define ZOOM_ORIGINAL "zoom-original"
#define ZOOM_OUT "zoom-out"
#define PROCESS_WORKING "process-working"
#define ACCESSORIES_CALCULATOR "accessories-calculator"
#define ACCESSORIES_CHARACTER_MAP "accessories-character-map"
#define ACCESSORIES_DICTIONARY "accessories-dictionary"
#define ACCESSORIES_TEXT_EDITOR "accessories-text-editor"
#define HELP_BROWSER "help-browser"
#define MULTIMEDIA_VOLUME_CONTROL "multimedia-volume-control"
#define PREFERENCES_DESKTOP_ACCESSIBILITY "preferences-desktop-accessibility"
#define PREFERENCES_DESKTOP_FONT "preferences-desktop-font"
#define PREFERENCES_DESKTOP_KEYBOARD "preferences-desktop-keyboard"
#define PREFERENCES_DESKTOP_LOCALE "preferences-desktop-locale"
#define PREFERENCES_DESKTOP_MULTIMEDIA "preferences-desktop-multimedia"
#define PREFERENCES_DESKTOP_SCREENSAVER "preferences-desktop-screensaver"
#define PREFERENCES_DESKTOP_THEME "preferences-desktop-theme"
#define PREFERENCES_DESKTOP_WALLPAPER "preferences-desktop-wallpaper"
#define SYSTEM_FILE_MANAGER "system-file-manager"
#define SYSTEM_SOFTWARE_UPDATE "system-software-update"
#define UTILITIES_TERMINAL "utilities-terminal"
#define APPLICATIONS_ACCESSORIES "applications-accessories"
#define APPLICATIONS_DEVELOPMENT "applications-development"
#define APPLICATIONS_GAMES "applications-games"
#define APPLICATIONS_GRAPHICS "applications-graphics"
#define APPLICATIONS_INTERNET "applications-internet"
#define APPLICATIONS_MULTIMEDIA "applications-multimedia"
#define APPLICATIONS_OFFICE "applications-office"
#define APPLICATIONS_OTHER "applications-other"
#define APPLICATIONS_SYSTEM "applications-system"
#define APPLICATIONS_UTILITIES "applications-utilities"
#define PREFERENCES_DESKTOP "preferences-desktop"
#define PREFERENCES_DESKTOP_ACCESSIBILITY "preferences-desktop-accessibility"
#define PREFERENCES_DESKTOP_PERIPHERALS "preferences-desktop-peripherals"
#define PREFERENCES_DESKTOP_PERSONAL "preferences-desktop-personal"
#define PREFERENCES_OTHER "preferences-other"
#define PREFERENCES_SYSTEM "preferences-system"
#define PREFERENCES_SYSTEM_NETWORK "preferences-system-network"
#define SYSTEM_HELP "system-help"
#define AUDIO_CARD "audio-card"
#define AUDIO_INPUT_MICROPHONE "audio-input-microphone"
#define BATTERY "battery"
#define CAMERA_PHOTO "camera-photo"
#define CAMERA_VIDEO "camera-video"
#define COMPUTER "computer"
#define DRIVE_CDROM "drive-cdrom"
#define DRIVE_HARDDISK "drive-harddisk"
#define DRIVE_REMOVABLE_MEDIA "drive-removable-media"
#define INPUT_GAMING "input-gaming"
#define INPUT_KEYBOARD "input-keyboard"
#define INPUT_MOUSE "input-mouse"
#define MEDIA_CDROM "media-cdrom"
#define MEDIA_FLOPPY "media-floppy"
#define MULTIMEDIA_PLAYER "multimedia-player"
#define NETWORK_WIRED "network-wired"
#define NETWORK_WIRELESS "network-wireless"
#define PRINTER "printer"
#define EMBLEM_DEFAULT "emblem-default"
#define EMBLEM_DOCUMENTS "emblem-documents"
#define EMBLEM_DOWNLOADS "emblem-downloads"
#define EMBLEM_FAVORITE "emblem-favorite"
#define EMBLEM_IMPORTANT "emblem-important"
#define EMBLEM_MAIL "emblem-mail"
#define EMBLEM_PHOTOS "emblem-photos"
#define EMBLEM_READONLY "emblem-readonly"
#define EMBLEM_SHARED "emblem-shared"
#define EMBLEM_SYMBOLIC_LINK "emblem-symbolic-link"
#define EMBLEM_SYNCHRONIZED "emblem-synchronized"
#define EMBLEM_SYSTEM "emblem-system"
#define EMBLEM_UNREADABLE "emblem-unreadable"
#define FACE_ANGEL "face-angel"
#define FACE_CRYING "face-crying"
#define FACE_DEVIL_GRIN "face-devil-grin"
#define FACE_DEVIL_SAD "face-devil-sad"
#define FACE_GLASSES "face-glasses"
#define FACE_KISS "face-kiss"
#define FACE_MONKEY "face-monkey"
#define FACE_PLAIN "face-plain"
#define FACE_SAD "face-sad"
#define FACE_SMILE "face-smile"
#define FACE_SMILE_BIG "face-smile-big"
#define FACE_SMIRK "face-smirk"
#define FACE_SURPRISE "face-surprise"
#define FACE_WINK "face-wink"
#define APPLICATION_X_EXECUTABLE "application-x-executable"
#define AUDIO_X_GENERIC "audio-x-generic"
#define FONT_X_GENERIC "font-x-generic"
#define IMAGE_X_GENERIC "image-x-generic"
#define PACKAGE_X_GENERIC "package-x-generic"
#define TEXT_HTML "text-html"
#define TEXT_X_GENERIC "text-x-generic"
#define TEXT_X_GENERIC_TEMPLATE "text-x-generic-template"
#define TEXT_X_SCRIPT "text-x-script"
#define VIDEO_X_GENERIC "video-x-generic"
#define X_OFFICE_ADDRESS_BOOK "x-office-address-book"
#define X_OFFICE_CALENDAR "x-office-calendar"
#define X_OFFICE_DOCUMENT "x-office-document"
#define X_OFFICE_PRESENTATION "x-office-presentation"
#define X_OFFICE_SPREADSHEET "x-office-spreadsheet"
#define FOLDER "folder"
#define FOLDER_REMOTE "folder-remote"
#define NETWORK_SERVER "network-server"
#define NETWORK_WORKGROUP "network-workgroup"
#define START_HERE "start-here"
#define USER_DESKTOP "user-desktop"
#define USER_HOME "user-home"
#define USER_TRASH "user-trash"
#define APPOINTMENT_MISSED "appointment-missed"
#define APPOINTMENT_SOON "appointment-soon"
#define AUDIO_VOLUME_HIGH "audio-volume-high"
#define AUDIO_VOLUME_LOW "audio-volume-low"
#define AUDIO_VOLUME_MEDIUM "audio-volume-medium"
#define AUDIO_VOLUME_MUTED "audio-volume-muted"
#define BATTERY_CAUTION "battery-caution"
#define BATTERY_LOW "battery-low"
#define DIALOG_ERROR "dialog-error"
#define DIALOG_INFORMATION "dialog-information"
#define DIALOG_PASSWORD "dialog-password"
#define DIALOG_QUESTION "dialog-question"
#define DIALOG_WARNING "dialog-warning"
#define FOLDER_DRAG_ACCEPT "folder-drag-accept"
#define FOLDER_OPEN "folder-open"
#define FOLDER_VISITING "folder-visiting"
#define IMAGE_LOADING "image-loading"
#define IMAGE_MISSING "image-missing"
#define MAIL_ATTACHMENT "mail-attachment"
#define MAIL_UNREAD "mail-unread"
#define MAIL_READ "mail-read"
#define MAIL_REPLIED "mail-replied"
#define MAIL_SIGNED "mail-signed"
#define MAIL_SIGNED_VERIFIED "mail-signed-verified"
#define MEDIA_PLAYLIST_REPEAT "media-playlist-repeat"
#define MEDIA_PLAYLIST_SHUFFLE "media-playlist-shuffle"
#define NETWORK_ERROR "network-error"
#define NETWORK_IDLE "network-idle"
#define NETWORK_OFFLINE "network-offline"
#define NETWORK_RECEIVE "network-receive"
#define NETWORK_TRANSMIT "network-transmit"
#define NETWORK_TRANSMIT_RECEIVE "network-transmit-receive"
#define PRINTER_ERROR "printer-error"
#define PRINTER_PRINTING "printer-printing"
#define SOFTWARE_UPDATE_AVAILABLE "software-update-available"
#define SOFTWARE_UPDATE_URGENT "software-update-urgent"
#define SYNC_ERROR "sync-error"
#define SYNC_SYNCHRONIZING "sync-synchronizing"
#define TASK_DUE "task-due"
#define TASK_PASSED_DUE "task-passed-due"
#define USER_AWAY "user-away"
#define USER_IDLE "user-idle"
#define USER_OFFLINE "user-offline"
#define USER_ONLINE "user-online"
#define USER_TRASH_FULL "user-trash-full"
#define WEATHER_CLEAR "weather-clear"
#define WEATHER_CLEAR_NIGHT "weather-clear-night"
#define WEATHER_FEW_CLOUDS "weather-few-clouds"
#define WEATHER_FEW_CLOUDS_NIGHT "weather-few-clouds-night"
#define WEATHER_FOG "weather-fog"
#define WEATHER_OVERCAST "weather-overcast"
#define WEATHER_SEVERE_ALERT "weather-severe-alert"
#define WEATHER_SHOWERS "weather-showers"
#define WEATHER_SHOWERS_SCATTERED "weather-showers-scattered"
#define WEATHER_SNOW "weather-snow"
#define WEATHER_STORM "weather-storm"
const char *icons[] = {
ADDRESS_BOOK_NEW,
APPLICATION_EXIT,
APPOINTMENT_NEW,
CONTACT_NEW,
DIALOG_APPLY,
DIALOG_CANCEL,
DIALOG_CLOSE,
DIALOG_OK,
DOCUMENT_NEW,
DOCUMENT_OPEN,
DOCUMENT_OPEN_RECENT,
DOCUMENT_PAGE_SETUP,
DOCUMENT_PRINT,
DOCUMENT_PRINT_PREVIEW,
DOCUMENT_PROPERTIES,
DOCUMENT_REVERT,
DOCUMENT_SAVE,
DOCUMENT_SAVE_AS,
EDIT_COPY,
EDIT_CUT,
EDIT_DELETE,
EDIT_FIND,
EDIT_FIND_REPLACE,
EDIT_PASTE,
EDIT_REDO,
EDIT_SELECT_ALL,
EDIT_UNDO,
FORMAT_INDENT_LESS,
FORMAT_INDENT_MORE,
FORMAT_JUSTIFY_CENTER,
FORMAT_JUSTIFY_FILL,
FORMAT_JUSTIFY_LEFT,
FORMAT_JUSTIFY_RIGHT,
FORMAT_TEXT_DIRECTION_LTR,
FORMAT_TEXT_DIRECTION_RTL,
FORMAT_TEXT_BOLD,
FORMAT_TEXT_ITALIC,
FORMAT_TEXT_UNDERLINE,
FORMAT_TEXT_STRIKETHROUGH,
GO_BOTTOM,
GO_DOWN,
GO_FIRST,
GO_HOME,
GO_JUMP,
GO_LAST,
GO_NEXT,
GO_PREVIOUS,
GO_TOP,
GO_UP,
HELP_ABOUT,
HELP_CONTENTS,
HELP_FAQ,
INSERT_IMAGE,
INSERT_LINK,
INSERT_OBJECT,
INSERT_TEXT,
LIST_ADD,
LIST_REMOVE,
MAIL_FORWARD,
MAIL_MARK_IMPORTANT,
MAIL_MARK_JUNK,
MAIL_MARK_NOTJUNK,
MAIL_MARK_READ,
MAIL_MARK_UNREAD,
MAIL_MESSAGE_NEW,
MAIL_REPLY_ALL,
MAIL_REPLY_SENDER,
MAIL_SEND_RECEIVE,
MEDIA_EJECT,
MEDIA_PLAYBACK_PAUSE,
MEDIA_PLAYBACK_START,
MEDIA_PLAYBACK_STOP,
MEDIA_RECORD,
MEDIA_SEEK_BACKWARD,
MEDIA_SEEK_FORWARD,
MEDIA_SKIP_BACKWARD,
MEDIA_SKIP_FORWARD,
SYSTEM_LOCK_SCREEN,
SYSTEM_LOG_OUT,
SYSTEM_RUN,
SYSTEM_SEARCH,
TOOLS_CHECK_SPELLING,
VIEW_FULLSCREEN,
VIEW_REFRESH,
VIEW_SORT_ASCENDING,
VIEW_SORT_DESCENDING,
WINDOW_CLOSE,
WINDOW_NEW,
ZOOM_BEST_FIT,
ZOOM_IN,
ZOOM_ORIGINAL,
ZOOM_OUT,
PROCESS_WORKING,
ACCESSORIES_CALCULATOR,
ACCESSORIES_CHARACTER_MAP,
ACCESSORIES_DICTIONARY,
ACCESSORIES_TEXT_EDITOR,
HELP_BROWSER,
MULTIMEDIA_VOLUME_CONTROL,
PREFERENCES_DESKTOP_ACCESSIBILITY,
PREFERENCES_DESKTOP_FONT,
PREFERENCES_DESKTOP_KEYBOARD,
PREFERENCES_DESKTOP_LOCALE,
PREFERENCES_DESKTOP_MULTIMEDIA,
PREFERENCES_DESKTOP_SCREENSAVER,
PREFERENCES_DESKTOP_THEME,
PREFERENCES_DESKTOP_WALLPAPER,
SYSTEM_FILE_MANAGER,
SYSTEM_SOFTWARE_UPDATE,
UTILITIES_TERMINAL,
APPLICATIONS_ACCESSORIES,
APPLICATIONS_DEVELOPMENT,
APPLICATIONS_GAMES,
APPLICATIONS_GRAPHICS,
APPLICATIONS_INTERNET,
APPLICATIONS_MULTIMEDIA,
APPLICATIONS_OFFICE,
APPLICATIONS_OTHER,
APPLICATIONS_SYSTEM,
APPLICATIONS_UTILITIES,
PREFERENCES_DESKTOP,
PREFERENCES_DESKTOP_ACCESSIBILITY,
PREFERENCES_DESKTOP_PERIPHERALS,
PREFERENCES_DESKTOP_PERSONAL,
PREFERENCES_OTHER,
PREFERENCES_SYSTEM,
PREFERENCES_SYSTEM_NETWORK,
SYSTEM_HELP,
AUDIO_CARD,
AUDIO_INPUT_MICROPHONE,
BATTERY,
CAMERA_PHOTO,
CAMERA_VIDEO,
COMPUTER,
DRIVE_CDROM,
DRIVE_HARDDISK,
DRIVE_REMOVABLE_MEDIA,
INPUT_GAMING,
INPUT_KEYBOARD,
INPUT_MOUSE,
MEDIA_CDROM,
MEDIA_FLOPPY,
MULTIMEDIA_PLAYER,
NETWORK_WIRED,
NETWORK_WIRELESS,
PRINTER,
EMBLEM_DEFAULT,
EMBLEM_DOCUMENTS,
EMBLEM_DOWNLOADS,
EMBLEM_FAVORITE,
EMBLEM_IMPORTANT,
EMBLEM_MAIL,
EMBLEM_PHOTOS,
EMBLEM_READONLY,
EMBLEM_SHARED,
EMBLEM_SYMBOLIC_LINK,
EMBLEM_SYNCHRONIZED,
EMBLEM_SYSTEM,
EMBLEM_UNREADABLE,
FACE_ANGEL,
FACE_CRYING,
FACE_DEVIL_GRIN,
FACE_DEVIL_SAD,
FACE_GLASSES,
FACE_KISS,
FACE_MONKEY,
FACE_PLAIN,
FACE_SAD,
FACE_SMILE,
FACE_SMILE_BIG,
FACE_SMIRK,
FACE_SURPRISE,
FACE_WINK,
APPLICATION_X_EXECUTABLE,
AUDIO_X_GENERIC,
FONT_X_GENERIC,
IMAGE_X_GENERIC,
PACKAGE_X_GENERIC,
TEXT_HTML,
TEXT_X_GENERIC,
TEXT_X_GENERIC_TEMPLATE,
TEXT_X_SCRIPT,
VIDEO_X_GENERIC,
X_OFFICE_ADDRESS_BOOK,
X_OFFICE_CALENDAR,
X_OFFICE_DOCUMENT,
X_OFFICE_PRESENTATION,
X_OFFICE_SPREADSHEET,
FOLDER,
FOLDER_REMOTE,
NETWORK_SERVER,
NETWORK_WORKGROUP,
START_HERE,
USER_DESKTOP,
USER_HOME,
USER_TRASH,
APPOINTMENT_MISSED,
APPOINTMENT_SOON,
AUDIO_VOLUME_HIGH,
AUDIO_VOLUME_LOW,
AUDIO_VOLUME_MEDIUM,
AUDIO_VOLUME_MUTED,
BATTERY_CAUTION,
BATTERY_LOW,
DIALOG_ERROR,
DIALOG_INFORMATION,
DIALOG_PASSWORD,
DIALOG_QUESTION,
DIALOG_WARNING,
FOLDER_DRAG_ACCEPT,
FOLDER_OPEN,
FOLDER_VISITING,
IMAGE_LOADING,
IMAGE_MISSING,
MAIL_ATTACHMENT,
MAIL_UNREAD,
MAIL_READ,
MAIL_REPLIED,
MAIL_SIGNED,
MAIL_SIGNED_VERIFIED,
MEDIA_PLAYLIST_REPEAT,
MEDIA_PLAYLIST_SHUFFLE,
NETWORK_ERROR,
NETWORK_IDLE,
NETWORK_OFFLINE,
NETWORK_RECEIVE,
NETWORK_TRANSMIT,
NETWORK_TRANSMIT_RECEIVE,
PRINTER_ERROR,
PRINTER_PRINTING,
SOFTWARE_UPDATE_AVAILABLE,
SOFTWARE_UPDATE_URGENT,
SYNC_ERROR,
SYNC_SYNCHRONIZING,
TASK_DUE,
TASK_PASSED_DUE,
USER_AWAY,
USER_IDLE,
USER_OFFLINE,
USER_ONLINE,
USER_TRASH_FULL,
WEATHER_CLEAR,
WEATHER_CLEAR_NIGHT,
WEATHER_FEW_CLOUDS,
WEATHER_FEW_CLOUDS_NIGHT,
WEATHER_FOG,
WEATHER_OVERCAST,
WEATHER_SEVERE_ALERT,
WEATHER_SHOWERS,
WEATHER_SHOWERS_SCATTERED,
WEATHER_SNOW,
WEATHER_STORM,
NULL
};
#endif

View File

@ -0,0 +1,43 @@
#include <Ecore.h>
#include <Ecore_Desktop.h>
#include <Efreet.h>
#include <stdio.h>
#include <string.h>
#include "comp.h"
int
main(int argc, char ** argv)
{
int i;
const char *ef, *ed;
ecore_init();
ecore_desktop_init();
efreet_init();
efreet_icon_extension_add(".svg");
for (i = 0; icons[i] != NULL; i++)
{
ef = efreet_icon_path_find(THEME, icons[i], SIZE);
ed = ecore_desktop_icon_find(icons[i], SIZE, THEME);
if (!ef && !ed) continue;
if (!ef && ed)
printf("%s matched ecore (%s) but not efreet\n", icons[i], ed);
else if (ef && !ed)
printf("%s matched efreet (%s) but not ecore\n", icons[i], ef);
else if (strcmp(ef, ed))
printf("%s didn't match ef(%s) vs ed(%s)\n", icons[i], ef, ed);
}
efreet_shutdown();
ecore_desktop_shutdown();
ecore_shutdown();
return 0;
}

View File

@ -0,0 +1,29 @@
#include <Ecore.h>
#include <Ecore_Desktop.h>
#include <stdio.h>
#include "comp.h"
int
main(int argc, char ** argv)
{
int i = 0, k;
const char *path;
ecore_init();
ecore_desktop_init();
for (k = 0; k < LOOPS; k++)
{
for (i = 0; icons[i] != NULL; i++)
{
path = ecore_desktop_icon_find(icons[i], SIZE, THEME);
// printf("%s: %s\n", icons[i], (path ? path : "NOT FOUND"));
}
}
ecore_desktop_shutdown();
ecore_shutdown();
return 0;
}

View File

@ -0,0 +1,26 @@
#include <Efreet.h>
#include <stdio.h>
#include "comp.h"
int
main(int argc, char **argv)
{
int i = 0, k;
const char *path;
efreet_init();
for (k = 0; k < LOOPS; k++)
{
for (i = 0; icons[i] != NULL; i++)
{
path = efreet_icon_path_find(THEME, icons[i], SIZE);
// printf("%s: %s\n", icons[i], (path ? path : "NOT FOUND"));
}
}
efreet_shutdown();
return 0;
}

View File

@ -0,0 +1,23 @@
#include <Efreet.h>
#include <stdio.h>
#include "comp.h"
int
main(int argc, char **argv)
{
int k;
efreet_init();
for (k = 0; k < LOOPS; k++)
{
Efreet_Menu *menu;
menu = efreet_menu_get();
efreet_menu_free(menu);
}
efreet_shutdown();
return 0;
}

View File

@ -0,0 +1,297 @@
#include "Efreet.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
ef_cb_efreet_data_home(void)
{
const char *tmp;
int ret = 1;
putenv("XDG_DATA_HOME=/var/tmp");
tmp = efreet_data_home_get();
if (strcmp(tmp, "/var/tmp"))
{
printf("efreet_data_home_get() returned incorrect "
"value on XDG_DATA_HOME=/var/tmp\n");
ret = 0;
}
/* reset efreet here so we can set a new home dir */
efreet_shutdown();
efreet_init();
putenv("XDG_DATA_HOME=");
putenv("HOME=/home/tmp");
tmp = efreet_data_home_get();
if (strcmp(tmp, "/home/tmp/.local/share"))
{
printf("efreet_data_home_get() returned incorrect "
"value on blank XDG_DATA_HOME\n");
ret = 0;
}
/* reset efreet here so we can set a new home dir */
efreet_shutdown();
efreet_init();
putenv("XDG_DATA_HOME=");
putenv("HOME=");
tmp = efreet_data_home_get();
if (strcmp(tmp, "/tmp/.local/share"))
{
printf("efreet_data_home_get() returned incorrect "
"value (%s) on blank XDG_DATA_HOME and blank HOME\n", tmp);
ret = 0;
}
return ret;
}
int
ef_cb_efreet_config_home(void)
{
const char *tmp;
int ret = 1;
putenv("XDG_CONFIG_HOME=/var/tmp");
tmp = efreet_config_home_get();
if (strcmp(tmp, "/var/tmp"))
{
printf("efreet_config_home_get() returned incorrect "
"value on XDG_CONFIG_HOME=/var/tmp\n");
ret = 0;
}
/* reset efreet here so we can set a new home dir */
efreet_shutdown();
efreet_init();
putenv("XDG_CONFIG_HOME=");
putenv("HOME=/home/tmp");
tmp = efreet_config_home_get();
if (strcmp(tmp, "/home/tmp/.config"))
{
printf("efreet_config_home_get() returned incorrect "
"value on blank XDG_CONFIG_HOME\n");
ret = 0;
}
/* reset efreet here so we can set a new home dir */
efreet_shutdown();
efreet_init();
putenv("XDG_CONFIG_HOME=");
putenv("HOME=");
tmp = efreet_config_home_get();
if (strcmp(tmp, "/tmp/.config"))
{
printf("efreet_config_home_get() returned incorrect "
"value (%s) on blank XDG_CONFIG_HOME and blank HOME\n", tmp);
ret = 0;
}
return ret;
}
int
ef_cb_efreet_cache_home(void)
{
const char *tmp;
int ret = 1;
putenv("XDG_CACHE_HOME=/var/tmp");
tmp = efreet_cache_home_get();
if (strcmp(tmp, "/var/tmp"))
{
printf("efreet_cache_home_get() returned incorrect "
"value on XDG_CACHE_HOME=/var/tmp\n");
ret = 0;
}
/* reset efreet here so we can set a new home dir */
efreet_shutdown();
efreet_init();
putenv("XDG_CACHE_HOME=");
putenv("HOME=/home/tmp");
tmp = efreet_cache_home_get();
if (strcmp(tmp, "/home/tmp/.cache"))
{
printf("efreet_cache_home_get() returned incorrect "
"value on blank XDG_CACHE_HOME\n");
ret = 0;
}
/* reset efreet here so we can set a new home dir */
efreet_shutdown();
efreet_init();
putenv("XDG_CACHE_HOME=");
putenv("HOME=");
tmp = efreet_cache_home_get();
if (strcmp(tmp, "/tmp/.cache"))
{
printf("efreet_cache_home_get() returned incorrect "
"value (%s) on blank XDG_CACHE_HOME and blank HOME\n", tmp);
ret = 0;
}
return ret;
}
int
ef_cb_efreet_data_dirs(void)
{
Ecore_List *tmp;
int ret = 1, i;
char dirs[128], *val;
char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL};
char *def_vals[] = {"/usr/local/share", "/usr/share", NULL};
dirs[0] = '\0';
strcat(dirs, "XDG_DATA_DIRS=");
for (i = 0; vals[i] != NULL; i++)
{
if (i > 0) strcat(dirs, ":");
strcat(dirs, vals[i]);
}
putenv(dirs);
i = 0;
tmp = efreet_data_dirs_get();
ecore_list_goto_first(tmp);
while ((val = ecore_list_next(tmp)))
{
if (vals[i] == NULL)
{
printf("efreet_data_dirs_get() returned more values then it "
"should have given %s as input\n", dirs);
ret = 0;
break;
}
if (strcmp(val, vals[i]))
{
printf("efreet_data_dirs_get() returned incorrect value (%s) when "
"%s set\n", val, dirs);
ret = 0;
}
i++;
}
efreet_shutdown();
efreet_init();
putenv("XDG_DATA_DIRS=");
i = 0;
tmp = efreet_data_dirs_get();
ecore_list_goto_first(tmp);
while ((val = ecore_list_next(tmp)))
{
if (def_vals[i] == NULL)
{
printf("efreet_data_dirs_get() returned more values then it "
"should have given %s as input\n", dirs);
ret = 0;
break;
}
if (strcmp(val, def_vals[i]))
{
printf("efreet_data_dirs_get() returned incorrect value (%s) when "
"XDG_DATA_DIRS= is set\n", val);
ret = 0;
}
i++;
}
return ret;
}
int
ef_cb_efreet_config_dirs(void)
{
Ecore_List *tmp;
int ret = 1, i;
char dirs[128], *val;
char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL};
char *def_vals[] = {"/etc/xdg", NULL};
dirs[0] = '\0';
strcat(dirs, "XDG_CONFIG_DIRS=");
for (i = 0; vals[i] != NULL; i++)
{
if (i > 0) strcat(dirs, ":");
strcat(dirs, vals[i]);
}
putenv(dirs);
i = 0;
tmp = efreet_config_dirs_get();
ecore_list_goto_first(tmp);
while ((val = ecore_list_next(tmp)))
{
if (vals[i] == NULL)
{
printf("efreet_config_dirs_get() returned more values then it "
"should have given %s as input\n", dirs);
ret = 0;
break;
}
if (strcmp(val, vals[i]))
{
printf("efreet_config_dirs_get() returned incorrect value (%s) when "
"%s set\n", val, dirs);
ret = 0;
}
i++;
}
efreet_shutdown();
efreet_init();
putenv("XDG_CONFIG_DIRS=");
i = 0;
tmp = efreet_config_dirs_get();
ecore_list_goto_first(tmp);
while ((val = ecore_list_next(tmp)))
{
if (def_vals[i] == NULL)
{
printf("efreet_config_dirs_get() returned more values then it "
"should have given %s as input\n", dirs);
ret = 0;
break;
}
if (strcmp(val, def_vals[i]))
{
printf("efreet_config_dirs_get() returned incorrect value (%s) when "
"XDG_CONFIG_DIRS= is set\n", val);
ret = 0;
}
i++;
}
return ret;
}

View File

@ -0,0 +1,346 @@
#include "Efreet.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include "../lib/efreet_private.h"
static void _cb_command(void *data, Efreet_Desktop *desktop, char *exec, int remaining);
int
ef_cb_desktop_parse(void)
{
Efreet_Desktop *desktop;
int ret = 1;
desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/efreet/test/test.desktop");
if (!desktop)
{
printf("No desktop found.\n");
return 0;
}
if (!desktop->name || strcmp(desktop->name, "Efreet Test Application"))
{
printf("Invalid Name\n");
ret = 0;
}
if (!desktop->generic_name ||
strcmp(desktop->generic_name, "Test Application"))
{
printf("Incorrent GenericName\n");
ret = 0;
}
if (!desktop->exec || strcmp(desktop->exec, "efreet_test %F %i"))
{
printf("Incorrect Exec (%s)\n", (desktop->exec ? desktop->exec : "(null)"));
ret = 0;
}
if (desktop->categories)
{
const char *categories[] = {"Test", "Enlightenment"};
const char *cat;
int num_categories = 2, i = 0;
ecore_list_goto_first(desktop->categories);
while ((cat = ecore_list_next(desktop->categories)))
{
if (i >= num_categories)
{
printf("Too many categories found.\n");
ret = 0;
break;
}
if (!cat || !categories[i] || strcmp(cat, categories[i]))
{
printf("Expected category %s, found %s\n", categories[i], cat);
ret = 0;
}
i++;
}
}
else ret = 0;
return ret;
}
#if 0
int
ef_cb_desktop_file_id(void)
{
Efreet_Desktop *desktop;
int ret = 1;
desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/efreet/test/test.desktop");
if (desktop)
{
const char *id;
int i = 0;
struct {
char *dir;
int legacy;
char *prefix;
char *expected;
} tests[] = {
{PACKAGE_DATA_DIR"/efreet/test/", 0, NULL, "test.desktop"},
{PACKAGE_DATA_DIR"/efreet/", 0, NULL, "test-test.desktop"},
{PACKAGE_DATA_DIR"/efreet/", 1, NULL, "test.desktop"},
{PACKAGE_DATA_DIR"/efreet/", 1, "prefix", "prefix-test.desktop"},
{NULL, 0, NULL, NULL}
};
for (i = 0; tests[i].dir != NULL; i++)
{
id = efreet_desktop_id_get(desktop,
tests[i].dir,
tests[i].legacy,
tests[i].prefix);
if (!id || strcmp(id, tests[i].expected))
{
printf("Expecting id: %s, got: %s\n", tests[i].expected, id);
ret = 0;
}
if (id) ecore_string_release(id);
}
}
else
ret = 0;
return ret;
}
#endif
int
ef_cb_desktop_save(void)
{
Efreet_Desktop *desktop;
printf("\n");
desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/efreet/test/test.desktop");
printf("save data: %d\n", efreet_desktop_save(desktop));
desktop = efreet_desktop_empty_new("/tmp/test.desktop");
desktop->name = strdup("Efreet Test Application");
desktop->type = EFREET_DESKTOP_TYPE_APPLICATION;
desktop->generic_name = strdup("Test Application");
desktop->exec = strdup("efreet_test");
desktop->categories = ecore_list_new();
ecore_list_set_free_cb(desktop->categories, ECORE_FREE_CB(free));
ecore_list_append(desktop->categories, strdup("Test"));
ecore_list_append(desktop->categories, strdup("Enlightenment"));
printf("save test: %d\n", efreet_desktop_save(desktop));
unlink("/tmp/test.desktop");
#if 0
/* After saving a .desktop, it should be in the cache. This should then
* be destroyed with it. */
ecore_list_destroy(desktop->categories);
desktop->categories = NULL;
#endif
return 1;
}
typedef struct
{
Ecore_List *expected;
int error;
char type;
} Test_Info;
int
ef_cb_desktop_command_get(void)
{
Efreet_Desktop *desktop;
Ecore_List *files, *expected;
char olddir[PATH_MAX];
Test_Info *info;
int ret;
getcwd(olddir, PATH_MAX);
chdir("/");
printf("\n");
desktop = efreet_desktop_empty_new("test.desktop");
desktop->name = strdup("App Name");
desktop->icon = strdup("icon.png");
files = ecore_list_new();
ecore_list_append(files, "/tmp/absolute_path");
ecore_list_append(files, "relative_path");
ecore_list_append(files, "file:///tmp/absolute_uri");
ecore_list_append(files, "file:relative_uri");
info = NEW(Test_Info, 1);
expected = ecore_list_new();
info->expected = expected;
info->error = 0;
/* test single full path */
info->type = 'f';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %f");
ecore_list_append(expected, "app '/tmp/absolute_path'");
ecore_list_append(expected, "app '/relative_path'");
ecore_list_append(expected, "app '/tmp/absolute_uri'");
ecore_list_append(expected, "app '/relative_uri'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test single uri */
info->type = 'u';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %u");
ecore_list_append(expected, "app 'file:///tmp/absolute_path'");
ecore_list_append(expected, "app 'file:///relative_path'");
ecore_list_append(expected, "app 'file:///tmp/absolute_uri'");
ecore_list_append(expected, "app 'file:///relative_uri'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test single dir */
info->type = 'd';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %d");
ecore_list_append(expected, "app '/tmp'");
ecore_list_append(expected, "app '/'");
ecore_list_append(expected, "app '/tmp'");
ecore_list_append(expected, "app '/'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test single names */
info->type = 'n';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %n");
ecore_list_append(expected, "app 'absolute_path'");
ecore_list_append(expected, "app 'relative_path'");
ecore_list_append(expected, "app 'absolute_uri'");
ecore_list_append(expected, "app 'relative_uri'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test multiple fullpaths */
info->type = 'F';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %F");
ecore_list_append(expected, "app '/tmp/absolute_path' '/relative_path' '/tmp/absolute_uri' '/relative_uri'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test multiple URIs */
info->type = 'U';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %U");
ecore_list_append(expected, "app 'file:///tmp/absolute_path' 'file:///relative_path' 'file:///tmp/absolute_uri' 'file:///relative_uri'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test multiple dirs */
info->type = 'D';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %D");
ecore_list_append(expected, "app '/tmp' '/' '/tmp' '/'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test multiple names */
info->type = 'N';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %N");
ecore_list_append(expected, "app 'absolute_path' 'relative_path' 'absolute_uri' 'relative_uri'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, files, _cb_command, info);
ecore_list_clear(expected);
/* test icon appending */
info->type = 'i';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %i");
ecore_list_append(expected, "app --icon 'icon.png'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, NULL, _cb_command, info);
ecore_list_clear(expected);
/* test app name */
info->type = 'c';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %c");
ecore_list_append(expected, "app 'App Name'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, NULL, _cb_command, info);
ecore_list_clear(expected);
/* test desktop path */
info->type = 'k';
IF_FREE(desktop->exec);
desktop->exec = strdup("app %k");
ecore_list_append(expected, "app 'test.desktop'");
ecore_list_goto_first(expected);
efreet_desktop_command_get(desktop, NULL, _cb_command, info);
ecore_list_clear(expected);
/* clean up */
efreet_desktop_free(desktop);
ecore_list_destroy(files);
ecore_list_destroy(expected);
ret = info->error > 0 ? 0 : 1;
free(info);
chdir(olddir);
return ret;
}
static void
_cb_command(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
{
Test_Info *info = data;
char *expected;
expected = ecore_list_next(info->expected);
if (!expected)
{
printf(" ERROR: (%%%c) got \"%s\", expected nothing\n", info->type, exec);
info->error++;
}
else
{
if (strcmp(exec, expected))
{
printf(" ERROR: (%%%c) got \"%s\", expected \"%s\"\n", info->type, exec, expected);
info->error++;
}
}
free(exec);
}

View File

@ -0,0 +1,602 @@
#include "Efreet.h"
#include "efreet_private.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <Ecore_File.h>
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#define SIZE "16x16"
#define THEME "Tango"
static void ef_icon_theme_themes_find(const char *search_dir,
Ecore_Hash *themes);
static void ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes,
Ecore_Hash *icons);
static void ef_read_dir(const char *dir, Ecore_Hash *icons);
int
ef_cb_efreet_icon_theme(void)
{
int ret = 1;
const char *tmp;
putenv("HOME=/var/tmp");
tmp = efreet_icon_dir_get();
if (strcmp(tmp, "/var/tmp/.icons"))
{
printf("efreet_icon_dir_get() returned incorrect "
"value on HOME=/var/tmp\n");
ret = 0;
}
efreet_shutdown();
efreet_init();
putenv("HOME=");
tmp = efreet_icon_dir_get();
if (strcmp(tmp, "/tmp/.icons"))
{
printf("efreet_icon_dir_get() returned incorrect "
"value on HOME=\n");
ret = 0;
}
return ret;
}
int
ef_cb_efreet_icon_theme_list(void)
{
int ret = 1;
Ecore_List *themes;
Ecore_Hash *dirs;
Efreet_Icon_Theme *theme;
Ecore_List *icon_dirs;
const char *dir;
char buf[PATH_MAX];
dirs = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set_free_key(dirs, free);
icon_dirs = efreet_data_dirs_get();
ecore_list_goto_first(icon_dirs);
ef_icon_theme_themes_find(efreet_icon_dir_get(), dirs);
while ((dir = ecore_list_next(icon_dirs)))
{
snprintf(buf, sizeof(buf), "%s/icons", dir);
ef_icon_theme_themes_find(buf, dirs);
}
ef_icon_theme_themes_find("/usr/share/pixmaps", dirs);
themes = efreet_icon_theme_list_get();
ecore_list_goto_first(themes);
while ((theme = ecore_list_next(themes)))
{
if (ecore_hash_get(dirs, theme->name.internal))
ecore_hash_remove(dirs, theme->name.internal);
else
{
printf("efreet_icon_theme_list_get() returned %s which we didn't "
"see when scanning the directories.\n", theme->name.internal);
ret = 0;
}
}
ecore_list_destroy(themes);
themes = ecore_hash_keys(dirs);
if (ecore_list_nodes(themes) > 0)
{
char *dir;
printf("efreet_icon_theme_list_get() missed: ");
ecore_list_goto_first(themes);
while ((dir = ecore_list_next(themes)))
printf("%s ", dir);
printf("\n");
ret = 0;
}
ecore_list_destroy(themes);
ecore_hash_destroy(dirs);
return ret;
}
static void
ef_icon_theme_themes_find(const char *search_dir, Ecore_Hash *themes)
{
Ecore_List *dirs;
char *dir;
if (!search_dir || !themes) return;
dirs = ecore_file_ls(search_dir);
if (!dirs) return;
while ((dir = ecore_list_remove_first(dirs)))
{
char p[PATH_MAX];
/* if we've already added the theme we're done */
if (ecore_hash_get(themes, dir))
{
free(dir);
continue;
}
/* if the index.theme file exists we open it and look for the hidden
* flag. */
snprintf(p, sizeof(p), "%s/%s/index.theme", search_dir, dir);
if (ecore_file_exists(p))
{
Efreet_Ini *ini;
char *d;
int skip = 0;
ini = efreet_ini_new(p);
efreet_ini_section_set(ini, "Icon Theme");
if (efreet_ini_boolean_get(ini, "Hidden")) skip = 1;
efreet_ini_free(ini);
if (!skip)
{
d = strdup(dir);
ecore_hash_set(themes, d, d);
}
}
free(dir);
}
ecore_list_destroy(dirs);
}
const char *icons[] =
{
"address-book-new",
"application-exit",
"appointment-new",
"contact-new",
"dialog-apply",
"dialog-cancel",
"dialog-close",
"dialog-ok",
"document-new",
"document-open",
"document-open-recent",
"document-page-setup",
"document-print",
"document-print-preview",
"document-properties",
"document-revert",
"document-save",
"document-save-as",
"edit-copy",
"edit-cut",
"edit-delete",
"edit-find",
"edit-find-replace",
"edit-paste",
"edit-redo",
"edit-select-all",
"edit-undo",
"format-indent-less",
"format-indent-more",
"format-justify-center",
"format-justify-fill",
"format-justify-left",
"format-justify-right",
"format-text-direction-ltr",
"format-text-direction-rtl",
"format-text-bold",
"format-text-italic",
"format-text-underline",
"format-text-strikethrough",
"go-bottom",
"go-down",
"go-first",
"go-home",
"go-jump",
"go-last",
"go-next",
"go-previous",
"go-top",
"go-up",
"help-about",
"help-contents",
"help-faq",
"insert-image",
"insert-link",
"insert-object",
"insert-text",
"list-add",
"list-remove",
"mail-forward",
"mail-mark-important",
"mail-mark-junk",
"mail-mark-notjunk",
"mail-mark-read",
"mail-mark-unread",
"mail-message-new",
"mail-reply-all",
"mail-reply-sender",
"mail-send-receive",
"media-eject",
"media-playback-pause",
"media-playback-start",
"media-playback-stop",
"media-record",
"media-seek-backward",
"media-seek-forward",
"media-skip-backward",
"media-skip-forward",
"system-lock-screen",
"system-log-out",
"system-run",
"system-search",
"system-search",
"tools-check-spelling",
"view-fullscreen",
"view-refresh",
"view-sort-ascending",
"view-sort-descending",
"window-close",
"window-new",
"zoom-best-fit",
"zoom-in",
"zoom-original",
"zoom-out",
"process-working",
"accessories-calculator",
"accessories-character-map",
"accessories-dictionary",
"accessories-text-editor",
"help-browser",
"multimedia-volume-control",
"preferences-desktop-accessibility",
"preferences-desktop-font",
"preferences-desktop-keyboard",
"preferences-desktop-locale",
"preferences-desktop-multimedia",
"preferences-desktop-screensaver",
"preferences-desktop-theme",
"preferences-desktop-wallpaper",
"system-file-manager",
"system-software-update",
"utilities-terminal",
"applications-accessories",
"applications-development",
"applications-games",
"applications-graphics",
"applications-internet",
"applications-multimedia",
"applications-office",
"applications-other",
"applications-system",
"applications-utilities",
"preferences-desktop",
"preferences-desktop-accessibility",
"preferences-desktop-peripherals",
"preferences-desktop-personal",
"preferences-other",
"preferences-system",
"preferences-system-network",
"system-help",
"audio-card",
"audio-input-microphone",
"battery",
"camera-photo",
"camera-video",
"computer",
"drive-cdrom",
"drive-harddisk",
"drive-removable-media",
"input-gaming",
"input-keyboard",
"input-mouse",
"media-cdrom",
"media-floppy",
"multimedia-player",
"multimedia-player",
"network-wired",
"network-wireless",
"printer",
"emblem-default",
"emblem-documents",
"emblem-downloads",
"emblem-favorite",
"emblem-important",
"emblem-mail",
"emblem-photos",
"emblem-readonly",
"emblem-shared",
"emblem-symbolic-link",
"emblem-synchronized",
"emblem-system",
"emblem-unreadable",
"face-angel",
"face-crying",
"face-devil-grin",
"face-devil-sad",
"face-glasses",
"face-kiss",
"face-monkey",
"face-plain",
"face-sad",
"face-smile",
"face-smile-big",
"face-smirk",
"face-surprise",
"face-wink",
"application-x-executable",
"audio-x-generic",
"font-x-generic",
"image-x-generic",
"package-x-generic",
"text-html",
"text-x-generic",
"text-x-generic-template",
"text-x-script",
"video-x-generic",
"x-office-address-book",
"x-office-calendar",
"x-office-document",
"x-office-presentation",
"x-office-spreadsheet",
"folder",
"folder-remote",
"network-server",
"network-workgroup",
"start-here",
"user-desktop",
"user-home",
"user-trash",
"appointment-missed",
"appointment-soon",
"audio-volume-high",
"audio-volume-low",
"audio-volume-medium",
"audio-volume-muted",
"battery-caution",
"battery-low",
"dialog-error",
"dialog-information",
"dialog-password",
"dialog-question",
"dialog-warning",
"folder-drag-accept",
"folder-open",
"folder-visiting",
"image-loading",
"image-missing",
"mail-attachment",
"mail-unread",
"mail-read",
"mail-replied",
"mail-signed",
"mail-signed-verified",
"media-playlist-repeat",
"media-playlist-shuffle",
"network-error",
"network-idle",
"network-offline",
"network-receive",
"network-transmit",
"network-transmit-receive",
"printer-error",
"printer-printing",
"software-update-available",
"software-update-urgent",
"sync-error",
"sync-synchronizing",
"task-due",
"task-passed-due",
"user-away",
"user-idle",
"user-offline",
"user-online",
"user-trash-full",
"weather-clear",
"weather-clear-night",
"weather-few-clouds",
"weather-few-clouds-night",
"weather-fog",
"weather-overcast",
"weather-severe-alert",
"weather-showers",
"weather-showers-scattered",
"weather-snow",
"weather-storm",
NULL
};
int
ef_cb_efreet_icon_match(void)
{
int i, ret = 1;
Ecore_Hash *icon_hash;
Efreet_Icon_Theme *theme;
Ecore_List *themes;
themes = efreet_icon_theme_list_get();
ecore_list_goto_first(themes);
while ((theme = ecore_list_next(themes)))
{
if (!strcmp(theme->name.internal, THEME))
break;
}
if (!theme)
{
printf("Theme not installed, SKIPPED.\n");
ecore_list_destroy(themes);
return 1;
}
icon_hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set_free_key(icon_hash, free);
ecore_hash_set_free_value(icon_hash, free);
ef_icons_find(theme, themes, icon_hash);
ecore_list_destroy(themes);
for (i = 0; icons[i] != NULL; i++)
{
const char *path;
char *t, *s;
path = efreet_icon_path_find(THEME, icons[i], SIZE);
if (!path)
{
if (ecore_hash_get(icon_hash, icons[i]))
{
printf("NOT FOUND %s\n", icons[i]);
ret = 0;
}
continue;
}
t = strdup(path);
s = strrchr(t, '.');
if (s) *s = '\0';
s = strrchr(t, '/');
if (s) s++;
if (s && strcmp(s, icons[i]))
{
printf("Name mismatch name (%s) vs ef (%s)\n", icons[i], s);
ret = 0;
}
free(t);
}
ecore_hash_destroy(icon_hash);
return ret;
}
static void
ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Ecore_Hash *icons)
{
char path[PATH_MAX];
if (!theme || !icons) return;
if (theme->paths.count == 1)
{
Efreet_Icon_Theme_Directory *dir;
ecore_list_goto_first(theme->directories);
while ((dir = ecore_list_next(theme->directories)))
{
if (theme->paths.count > 1)
{
Ecore_List *list;
char *tmp;
list = theme->paths.path;
ecore_list_goto_first(list);
while ((tmp = ecore_list_next(list)))
{
snprintf(path, sizeof(path), "%s/%s/", tmp, dir->name);
ef_read_dir(path, icons);
}
}
else if (theme->paths.count == 1)
{
snprintf(path, sizeof(path), "%s/%s/", (char *)theme->paths.path, dir->name);
ef_read_dir(path, icons);
}
}
}
else if (theme->paths.count > 1)
{
const char *theme_path;
ecore_list_goto_first(theme->paths.path);
while ((theme_path = ecore_list_next(theme->paths.path)))
{
Efreet_Icon_Theme_Directory *dir;
ecore_list_goto_first(theme->directories);
while ((dir = ecore_list_next(theme->directories)))
{
snprintf(path, sizeof(path), "%s/%s/", theme_path, dir->name);
ef_read_dir(path, icons);
}
}
}
if (theme->inherits)
{
Efreet_Icon_Theme *parent_theme;
char *parent;
ecore_list_goto_first(theme->inherits);
while ((parent = ecore_list_next(theme->inherits)))
{
ecore_list_goto_first(themes);
while ((parent_theme = ecore_list_next(themes)))
{
if (!strcmp(parent_theme->name.internal, parent))
ef_icons_find(parent_theme, themes, icons);
}
}
}
else
{
Efreet_Icon_Theme *parent_theme;
ecore_list_goto_first(themes);
while ((parent_theme = ecore_list_next(themes)))
{
if (!strcmp(parent_theme->name.internal, "hicolor"))
ef_icons_find(parent_theme, themes, icons);
}
}
ef_read_dir("/usr/share/pixmaps", icons);
}
static void
ef_read_dir(const char *dir, Ecore_Hash *icons)
{
Ecore_List *files;
char *file;
if (!dir || !icons) return;
files = ecore_file_ls(dir);
if (!files) return;
while ((file = ecore_list_remove_first(files)))
{
char *p;
p = strrchr(file, '.');
if (!p)
{
FREE(file);
continue;
}
if (!strcmp(p, ".png") || !strcmp(p, ".xpm"))
{
*p = '\0';
p = strrchr(file, '/');
if (p) p++;
if (p) ecore_hash_set(icons, strdup(p), strdup(p));
}
FREE(file);
}
ecore_list_destroy(files);
}

View File

@ -0,0 +1,157 @@
#include "Efreet.h"
#include "efreet_private.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
int
ef_cb_ini_parse(void)
{
int ret = 1;
Efreet_Ini *ini;
putenv("LC_ALL=en_US");
ini = efreet_ini_new(PACKAGE_DATA_DIR"/efreet/test/test.ini");
if (!ini)
{
printf("efreet_ini_parse() Failed to initialize Efreet_Ini\n");
return 0;
}
if (efreet_ini_section_set(ini, "contact"))
{
const char *val;
int ival;
unsigned int bval;
val = efreet_ini_string_get(ini, "Name");
if (!val || strcmp(val, "Foo Bar"))
{
printf("efreet_ini_string_get() Name parsed incorrectly\n");
ret = 0;
}
val = efreet_ini_localestring_get(ini, "Name");
if (!val || strcmp(val, "English Foo Bar"))
{
printf("efreet_ini_localestring_get() Name parsed incorrectly\n");
ret = 0;
}
val = efreet_ini_string_get(ini, "Email");
if (!val || strcmp(val, "foo@bar.com"))
{
printf("efreet_ini_string_get() Email parsed incorrectly\n");
ret = 0;
}
val = efreet_ini_localestring_get(ini, "Email");
if (!val || strcmp(val, "foo@bar.com"))
{
printf("efreet_ini_localestring_get() Email parsed incorrectly\n");
ret = 0;
}
ival = efreet_ini_int_get(ini, "Age");
if (ival != 30)
{
printf("efreet_ini_int_get() Age parsed incorrectly\n");
ret = 0;
}
bval = efreet_ini_boolean_get(ini, "TrueBoolean");
if (!bval)
{
printf("efreet_ini_boolean_get() TrueBoolean parsed incorrectly\n");
ret = 0;
}
bval = efreet_ini_boolean_get(ini, "FalseBoolean");
if (bval)
{
printf("efreet_ini_boolean_get() FalseBoolean parsed incorrectly\n");
ret = 0;
}
bval = efreet_ini_boolean_get(ini, "InvalidBoolean");
if (bval)
{
printf("efreet_ini_boolean_get() InvalidBoolean parsed incorrectly\n");
ret = 0;
}
val = efreet_ini_string_get(ini, "Escaped");
if (!val || strcmp(val, "line1\nline2\r\nline3\ttabbed \\ with a backslash and spaces"))
{
printf("efreet_ini_unescape() improperly unescaped value\n");
ret = 0;
}
}
else
{
printf("efreet_ini_section_set() Failed to set 'contact' section\n");
ret = 0;
}
efreet_ini_free(ini);
return ret;
}
int
ef_cb_ini_long_line(void)
{
Efreet_Ini *ini;
int ret = 1;
struct
{
char *key;
int len;
} tests[] = {
{"key", 5099},
{"key2", 5099},
{NULL, 0}
};
ini = efreet_ini_new(PACKAGE_DATA_DIR"/efreet/test/long.ini");
if (!ini)
{
printf("Ini failed to parse.\n");
ret = 0;
}
if (ret) ret = efreet_ini_section_set(ini, "section");
if (ret)
{
const char *val;
int i, len;
for (i = 0; tests[i].key; i++)
{
val = efreet_ini_string_get(ini, tests[i].key);
if (val)
{
len = strlen(val);
if (len != tests[i].len)
{
printf("Invalid long line parsing. Value length: %d (expected %d)\n", len, tests[i].len);
ret = 0;
}
}
else
{
printf("Key missing: %s.", tests[i].key);
ret = 0;
}
}
}
else
{
printf("Section missing: 'section'.");
}
if (ini) efreet_ini_free(ini);
return ret;
}

View File

@ -0,0 +1,83 @@
#include <Efreet.h>
#include "efreet_private.h"
int
ef_cb_locale(void)
{
int ret = 1, i;
struct
{
char *lc_message;
char *lang;
char *country;
char *modifier;
} langs[] = {
/* these are ordered such that when we move from LANG to LC_MESSAGES
* the LANG env will still be effect. Same with moving from
* LC_MESSAGES to LANG */
{"LANG=", NULL, NULL, NULL},
{"LANG=en", "en", NULL, NULL},
{"LANG=en@Latn", "en", NULL, "Latn"},
{"LANG=en_US", "en", "US", NULL},
{"LANG=en_US@Latn", "en", "US", "Latn"},
{"LANG=en_US.blah@Latn", "en", "US", "Latn"},
{"LC_MESSAGES=", "en", "US", "Latn"}, /* This will fallback to LANG */
{"LC_MESSAGES=fr", "fr", NULL, NULL},
{"LC_MESSAGES=fr@Blah", "fr", NULL, "Blah"},
{"LC_MESSAGES=fr_FR", "fr", "FR", NULL},
{"LC_MESSAGES=fr_FR@Blah", "fr", "FR", "Blah"},
{"LC_MESSAGES=fr_FR.Foo@Blah", "fr", "FR", "Blah"},
{"LC_ALL=", "fr", "FR", "Blah"}, /* this will fallback to LC_MESSAGES */
{"LC_ALL=sr", "sr", NULL, NULL},
{"LC_ALL=sr@Ret", "sr", NULL, "Ret"},
{"LC_ALL=sr_YU", "sr", "YU", NULL},
{"LC_ALL=sr_YU@Ret", "sr", "YU", "Ret"},
{"LC_ALL=sr_YU.ssh@Ret", "sr", "YU", "Ret"},
{NULL, NULL, NULL, NULL}
};
/* reset everything to blank */
putenv("LC_ALL=");
putenv("LC_MESSAGES=");
putenv("LANG=");
for (i = 0; langs[i].lc_message != NULL; i++)
{
const char *tmp;
putenv(langs[i].lc_message);
tmp = efreet_lang_get();
if ((langs[i].lang && (!tmp || strcmp(tmp, langs[i].lang)))
|| (!langs[i].lang && tmp))
{
printf("efreet_lang_get() is wrong (%s) with %s\n",
tmp, langs[i].lang);
ret = 0;
}
tmp = efreet_lang_country_get();
if ((langs[i].country && (!tmp || strcmp(tmp, langs[i].country)))
|| (!langs[i].country && tmp))
{
printf("efreet_lang_country_get() is wrong (%s) with %s\n",
tmp, langs[i].lang);
ret = 0;
}
tmp = efreet_lang_modifier_get();
if ((langs[i].modifier && (!tmp || strcmp(tmp, langs[i].modifier)))
|| (!langs[i].modifier && tmp))
{
printf("efreet_lang_modifier_get() is wrong with %s with %s\n",
tmp, langs[i].lang);
ret = 0;
}
efreet_shutdown();
efreet_init();
}
return ret;
}

View File

@ -0,0 +1,75 @@
#include "Efreet.h"
#include "efreet_private.h"
static void
ef_menu_desktop_exec(Efreet_Menu *menu)
{
#if 0
if (menu->entries)
{
Efreet_Desktop *desktop;
ecore_list_goto_first(menu->entries);
while ((desktop = ecore_list_next(menu->entries)))
efreet_desktop_exec(desktop, NULL);
}
if (menu->sub_menus)
{
Efreet_Menu *sub_menu;
ecore_list_goto_first(menu->sub_menus);
while ((sub_menu = ecore_list_next(menu->sub_menus)))
ef_menu_desktop_exec(sub_menu);
}
#endif
}
int
ef_cb_menu_get(void)
{
Efreet_Menu *menu;
menu = efreet_menu_get();
// menu = efreet_menu_parse(PACKAGE_DATA_DIR"/efreet/test/test.menu");
if (!menu)
{
printf("efreet_menu_get() returned NULL\n");
return 0;
}
#if 0
if (strcmp(menu->name.internal, "Applications"))
{
printf("menu name didn't match\n");
return 0;
}
if (!menu->moves || ecore_list_nodes(menu->moves) != 2)
{
printf("Missing moves\n");
return 0;
}
if (menu->current_move)
{
printf("Current move still set\n");
return 0;
}
if (menu->filters)
{
printf("Have filters when we shouldn't\n");
return 0;
}
ef_menu_desktop_exec(menu);
#endif
printf("\n");
efreet_menu_dump(menu, "");
#if 0
unlink("/tmp/test.menu");
efreet_menu_save(menu, "/tmp/test.menu");
#endif
efreet_menu_free(menu);
return 1;
}

View File

@ -0,0 +1,58 @@
#include <Efreet.h>
#include <stdio.h>
#define PATH_MAX 4096
static void dump(Efreet_Menu *menu, const char *path);
int
main(int argc, char **argv)
{
Efreet_Menu *menu;
if (!efreet_init())
{
fprintf(stderr, "Failed to init Efreet\n");
return 1;
}
menu = efreet_menu_get();
if (!menu)
{
fprintf(stderr, "Failed to read menu\n");
return 1;
}
dump(menu, "");
efreet_menu_free(menu);
efreet_shutdown();
return 0;
}
static void
dump(Efreet_Menu *menu, const char *path)
{
Efreet_Menu *entry;
if (!menu || !menu->entries) return;
ecore_list_goto_first(menu->entries);
while ((entry = ecore_list_next(menu->entries)))
{
if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
{
if (!path || !*path) path = "/";
printf("%s\t%s\t%s\n", path, entry->id,
entry->desktop->orig_path);
}
else if (entry->type == EFREET_MENU_ENTRY_MENU)
{
char new_path[PATH_MAX];
snprintf(new_path, PATH_MAX, "%s%s/", path, entry->name);
dump(entry, new_path);
}
}
}

View File

@ -0,0 +1,142 @@
#include "Efreet.h"
#include <Ecore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int ef_cb_efreet_data_home(void);
int ef_cb_efreet_config_home(void);
int ef_cb_efreet_cache_home(void);
int ef_cb_efreet_data_dirs(void);
int ef_cb_efreet_config_dirs(void);
int ef_cb_efreet_icon_theme(void);
int ef_cb_efreet_icon_theme_list(void);
int ef_cb_efreet_icon_match(void);
int ef_cb_ini_parse(void);
int ef_cb_locale(void);
int ef_cb_desktop_parse(void);
#if 0
int ef_cb_desktop_file_id(void);
#endif
int ef_cb_menu_get(void);
int ef_cb_ini_long_line(void);
int ef_cb_desktop_save(void);
int ef_cb_desktop_command_get(void);
typedef struct Efreet_Test Efreet_Test;
struct Efreet_Test
{
char *name;
int (*cb)(void);
};
static Efreet_Test tests[] = {
{"Data Home", ef_cb_efreet_data_home},
{"Config Home", ef_cb_efreet_config_home},
{"Cache Home", ef_cb_efreet_cache_home},
{"Data Directories", ef_cb_efreet_data_dirs},
{"Config Directories", ef_cb_efreet_config_dirs},
{"Icon Theme Basic", ef_cb_efreet_icon_theme},
{"Icon Theme List", ef_cb_efreet_icon_theme_list},
{"Icon Matching", ef_cb_efreet_icon_match},
{"INI Parsing", ef_cb_ini_parse},
{"INI Long Line Parsing", ef_cb_ini_long_line},
{"Locale Parsing", ef_cb_locale},
{"Desktop Parsing", ef_cb_desktop_parse},
#if 0
{"Desktop File ID", ef_cb_desktop_file_id},
#endif
{"Menu Parsing", ef_cb_menu_get},
{"Desktop Save", ef_cb_desktop_save},
{"Desktop Command", ef_cb_desktop_command_get},
{NULL, NULL}
};
extern char **environ;
static Ecore_List *environment = NULL;
void
environment_store(void)
{
char **e;
if (environment)
ecore_list_clear(environment);
else
{
environment = ecore_list_new();
ecore_list_set_free_cb(environment, ECORE_FREE_CB(free));
}
for (e = environ; *e; e++)
ecore_list_append(environment, strdup(*e));
}
void
environment_restore(void)
{
char *e;
if (!environment) return;
*environ = NULL;
ecore_list_goto_first(environment);
while ((e = ecore_list_next(environment)))
putenv(e);
}
int
main(int argc, char ** argv)
{
int i, passed = 0, num_tests = 0;
Ecore_List *run = NULL;
double total;
total = ecore_time_get();
if (argc > 1)
{
run = ecore_list_new();
for (i = 1; i < argc; i++)
ecore_list_append(run, argv[i]);
}
environment_store();
for (i = 0; tests[i].name != NULL; i++)
{
int ret;
double start;
/* we've been given specific tests and it isn't in the list */
if (run && !ecore_list_find(run, ECORE_COMPARE_CB(strcasecmp),
tests[i].name))
continue;
if (!efreet_init())
{
printf("Error initializing Efreet\n");
continue;
}
num_tests ++;
printf("%s:\t\t", tests[i].name);
fflush(stdout);
start = ecore_time_get();
ret = tests[i].cb();
printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
ecore_time_get() - start);
passed += ret;
efreet_shutdown();
environment_restore();
}
printf("\n-----------------\n");
if (environment) ecore_list_destroy(environment);
printf("Passed %d of %d tests.\n", passed, num_tests);
if (run) ecore_list_destroy(run);
printf("Total run: %.3f seconds\n", ecore_time_get() - total);
return 0;
}

View File

@ -0,0 +1,44 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_H
#define EFREET_H
/**
* @file Efreet.h
* @brief The file that must be included by any project wishing to use
* Efreet. Efreet.h provides all of the necessary headers and includes to
* work with Efreet.
*/
/**
* @mainpage The Efreet Library
*
* @section intro Introduction
*
* Efreet is a library designed to help apps work several of the
* Freedesktop.org standards regarding Icons, Desktop files and Menus. To
* that end it implements the following specifications:
*
* @li XDG Base Directory Specification
* @li Icon Theme Specification
* @li Desktop Entry Specification
* @li Desktop Menu Specification
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "efreet_base.h"
#include "efreet_icon.h"
#include "efreet_desktop.h"
#include "efreet_menu.h"
int efreet_init(void);
int efreet_shutdown(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,37 @@
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = \
-I$(top_builddir) \
-I$(top_srcdir) \
-g -O0 -W -Wall \
@ECORE_CFLAGS@
lib_LTLIBRARIES = libefreet.la
EFREETHEADERS = \
Efreet.h \
efreet_base.h \
efreet_desktop.h \
efreet_icon.h \
efreet_menu.h
EFREETSOURCES = \
efreet.c \
efreet_base.c \
efreet_icon.c \
efreet_xml.c \
efreet_ini.c \
efreet_desktop.c \
efreet_menu.c \
$(EFREETHEADERS)
libefreet_la_SOURCES = \
$(EFREETSOURCES)
installed_headersdir = $(prefix)/include/efreet
installed_headers_DATA = $(EFREETHEADERS)
libefreet_la_LIBADD = @ECORE_LIBS@
libefreet_la_LDFLAGS = -version-info 1:0:0

View File

@ -0,0 +1,191 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#include "Efreet.h"
#include "efreet_private.h"
static int init = 0;
static int efreet_parsed_locale = 0;
static char *efreet_lang = NULL;
static char *efreet_lang_country = NULL;
static char *efreet_lang_modifier = NULL;
static void efreet_parse_locale(void);
static int efreet_parse_locale_setting(const char *env);
/**
* @return Returns > 0 if the initialization was successful, 0 otherwise
* @brief Initializes the Efreet system
*/
int
efreet_init(void)
{
if (init++) return init;
if (!efreet_base_init()) return --init;
if (!efreet_xml_init()) return --init;
if (!efreet_icon_init()) return --init;
if (!efreet_ini_init()) return --init;
if (!efreet_desktop_init()) return --init;
if (!efreet_menu_init()) return --init;
return init;
}
/**
* @return Returns the number of times the init function as been called
* minus the corresponding init call.
* @brief Shuts down Efreet if a balanced number of init/shutdown calls have
* been made
*/
int
efreet_shutdown(void)
{
if (--init) return init;
efreet_menu_shutdown();
efreet_desktop_shutdown();
efreet_ini_shutdown();
efreet_icon_shutdown();
efreet_xml_shutdown();
efreet_base_shutdown();
IF_FREE(efreet_lang);
IF_FREE(efreet_lang_country);
IF_FREE(efreet_lang_modifier);
efreet_parsed_locale = 0; /* reset this in case they init efreet again */
return init;
}
/**
* @internal
* @return Returns the current users language setting or NULL if none set
* @brief Retrieves the current language setting
*/
const char *
efreet_lang_get(void)
{
if (efreet_parsed_locale) return efreet_lang;
efreet_parse_locale();
return efreet_lang;
}
/**
* @internal
* @return Returns the current language country setting or NULL if none set
* @brief Retrieves the current country setting for the current language or
*/
const char *
efreet_lang_country_get(void)
{
if (efreet_parsed_locale) return efreet_lang_country;
efreet_parse_locale();
return efreet_lang_country;
}
/**
* @internal
* @return Returns the current language modifier setting or NULL if none
* set.
* @brief Retrieves the modifier setting for the language.
*/
const char *
efreet_lang_modifier_get(void)
{
if (efreet_parsed_locale) return efreet_lang_modifier;
efreet_parse_locale();
return efreet_lang_modifier;
}
/**
* @internal
* @return Returns no value
* @brief Parses out the language, country and modifer setting from the
* LC_MESSAGES environment variable
*/
static void
efreet_parse_locale(void)
{
efreet_parsed_locale = 1;
if (efreet_parse_locale_setting("LC_ALL"))
return;
if (efreet_parse_locale_setting("LC_MESSAGES"))
return;
efreet_parse_locale_setting("LANG");
}
/**
* @internal
* @param env: The environment variable to grab
* @return Returns 1 if we parsed something of @a env, 0 otherwise
* @brief Tries to parse the lang settings out of the given environment
* variable
*/
static int
efreet_parse_locale_setting(const char *env)
{
int found = 0;
char *setting;
char *p;
setting = getenv(env);
if (!setting) return 0;
setting = strdup(setting);
/* pull the modifier off the end */
p = strrchr(setting, '@');
if (p)
{
*p = '\0';
efreet_lang_modifier = strdup(p + 1);
found = 1;
}
/* if there is an encoding we ignore it */
p = strrchr(setting, '.');
if (p) *p = '\0';
/* get the country if available */
p = strrchr(setting, '_');
if (p)
{
*p = '\0';
efreet_lang_country = strdup(p + 1);
found = 1;
}
if (setting && (*setting != '\0'))
{
efreet_lang = strdup(setting);
found = 1;
}
FREE(setting);
return found;
}
/**
* @internal
* @param buffer: The destination buffer
* @param size: The destination buffer size
* @param strs: The strings to concatenate together
* @return Returns the size of the string in @a buffer
* @brief Concatenates the strings in @a strs into the given @a buffer not
* exceeding the given @a size.
*/
size_t
efreet_array_cat(char *buffer, size_t size, const char *strs[])
{
int i;
size_t n;
for (i = 0, n = 0; n < size && strs[i]; i++)
{
n += ecore_strlcpy(buffer + n, strs[i], size - n);
}
return n;
}

View File

@ -0,0 +1,212 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#include "Efreet.h"
#include "efreet_private.h"
static const char *efreet_home_dir = NULL;
static const char *xdg_data_home = NULL;
static const char *xdg_config_home = NULL;
static const char *xdg_cache_home = NULL;
static Ecore_List *xdg_data_dirs = NULL;
static Ecore_List *xdg_config_dirs = NULL;
static const char *efreet_dir_get(const char *key, const char *fallback);
static Ecore_List *efreet_dirs_get(const char *key,
const char *fallback);
/**
* @internal
* @return Returns 1 on success or 0 on failure
* @brief Initializes the efreet base settings
*/
int
efreet_base_init(void)
{
if (!ecore_string_init()) return 0;
return 1;
}
/**
* @internal
* @return Returns no value
* @brief Cleans up the efree base settings system
*/
void
efreet_base_shutdown(void)
{
IF_RELEASE(efreet_home_dir);
IF_RELEASE(xdg_data_home);
IF_RELEASE(xdg_config_home);
IF_RELEASE(xdg_cache_home);
IF_FREE_LIST(xdg_data_dirs);
IF_FREE_LIST(xdg_config_dirs);
ecore_string_shutdown();
}
/**
* @internal
* @return Returns the users home directory
* @brief Gets the users home directory and returns it.
*/
const char *
efreet_home_dir_get(void)
{
if (efreet_home_dir) return efreet_home_dir;
efreet_home_dir = getenv("HOME");
if (!efreet_home_dir || efreet_home_dir[0] == '\0')
efreet_home_dir = "/tmp";
efreet_home_dir = ecore_string_instance(efreet_home_dir);
return efreet_home_dir;
}
/**
* @return Returns the XDG Data Home directory
* @brief Retrieves the XDG Data Home directory
*/
const char *
efreet_data_home_get(void)
{
if (xdg_data_home) return xdg_data_home;
xdg_data_home = efreet_dir_get("XDG_DATA_HOME", "/.local/share");
return xdg_data_home;
}
/**
* @return Returns the Ecore_List of preference ordered extra data directories
* @brief Returns the Ecore_List of prefernece oredred extra data
* directories
*
* @note The returned list is static inside Efreet. If you add/remove from the
* list then the next call to efreet_data_dirs_get() will return your
* modified values. DO NOT free this list.
*/
Ecore_List *
efreet_data_dirs_get(void)
{
if (xdg_data_dirs) return xdg_data_dirs;
xdg_data_dirs = efreet_dirs_get("XDG_DATA_DIRS",
"/usr/local/share:/usr/share");
return xdg_data_dirs;
}
/**
* @return Returns the XDG Config Home directory
* @brief Retrieves the XDG Config Home directory
*/
const char *
efreet_config_home_get(void)
{
if (xdg_config_home) return xdg_config_home;
xdg_config_home = efreet_dir_get("XDG_CONFIG_HOME", "/.config");
return xdg_config_home;
}
/**
* @return Returns the Ecore_List of preference ordered extra config directories
* @brief Returns the Ecore_List of prefernece oredred extra config
* directories
*
* @note The returned list is static inside Efreet. If you add/remove from the
* list then the next call to efreet_config_dirs_get() will return your
* modified values. DO NOT free this list.
*/
Ecore_List *
efreet_config_dirs_get(void)
{
if (xdg_config_dirs) return xdg_config_dirs;
xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", "/etc/xdg");
return xdg_config_dirs;
}
/**
* @return Returns the XDG Cache Home directory
* @brief Retrieves the XDG Cache Home directory
*/
const char *
efreet_cache_home_get(void)
{
if (xdg_cache_home) return xdg_cache_home;
xdg_cache_home = efreet_dir_get("XDG_CACHE_HOME", "/.cache");
return xdg_cache_home;
}
/**
* @internal
* @param key: The environemnt key to lookup
* @param fallback: The fallback value to use
* @return Returns the directory related to the given key or the fallback
* @brief This trys to determine the correct directory name given the
* environment key @a key and fallbacks @a fallback.
*/
static const char *
efreet_dir_get(const char *key, const char *fallback)
{
char *dir;
const char *t;
dir = getenv(key);
if (!dir || dir[0] == '\0')
{
int len;
const char *user;
user = efreet_home_dir_get();
len = strlen(user) + strlen(fallback) + 1;
dir = malloc(sizeof(char) * len);
snprintf(dir, len, "%s%s", user, fallback);
t = ecore_string_instance(dir);
FREE(dir);
}
else t = ecore_string_instance(dir);
return t;
}
/**
* @internal
* @param key: The environment key to lookup
* @param fallback: The fallback value to use
* @return Returns a list of directories specified by the given key @a key
* or from the list of fallbacks in @a fallback.
* @brief Creates a list of directories as given in the environment key @a
* key or from the fallbacks in @a fallback
*/
static Ecore_List *
efreet_dirs_get(const char *key, const char *fallback)
{
Ecore_List *dirs;
const char *path;
char *tmp, *s, *p;
path = getenv(key);
if (!path || (path[0] == '\0')) path = fallback;
dirs = ecore_list_new();
ecore_list_set_free_cb(dirs, ECORE_FREE_CB(ecore_string_release));
if (!path) return dirs;
tmp = strdup(path);
s = tmp;
p = strchr(s, ':');
while (p)
{
*p = '\0';
if (!ecore_list_find(dirs, ECORE_COMPARE_CB(strcmp), s))
ecore_list_append(dirs, (void *)ecore_string_instance(s));
s = ++p;
p = strchr(s, ':');
}
if (!ecore_list_find(dirs, ECORE_COMPARE_CB(strcmp), s))
ecore_list_append(dirs, (void *)ecore_string_instance(s));
FREE(tmp);
return dirs;
}

View File

@ -0,0 +1,31 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_BASE_H
#define EFREET_BASE_H
/**
* @file efreet_base.h
* @brief Contains the methods used to support the FDO base directory
* specification.
* @addtogroup Efreet_Base Efreet_Base: The XDG Base Directory Specification
* functions
*
* @{
*/
#include <Ecore.h>
#include <Ecore_Data.h>
const char *efreet_data_home_get(void);
Ecore_List *efreet_data_dirs_get(void);
const char *efreet_config_home_get(void);
Ecore_List *efreet_config_dirs_get(void);
const char *efreet_cache_home_get(void);
/**
* @}
*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_DESKTOP_H
#define EFREET_DESKTOP_H
/**
* @file efreet_desktop.h
* @brief Contains the structures and methods used to support the
* FDO desktop entry specificiation.
* @addtogroup Efreet_Desktop Efreet_Desktop: The FDO Desktop Entry
* Specification functions and structures
*
* @{
*/
/**
* Possible types of .desktop files. Unknown files are ignored.
*/
enum Efreet_Desktop_Type
{
EFREET_DESKTOP_TYPE_UNKNOWN,
EFREET_DESKTOP_TYPE_APPLICATION,
EFREET_DESKTOP_TYPE_LINK,
EFREET_DESKTOP_TYPE_DIRECTORY
};
/**
* Efreet_Desktop_Type
*/
typedef enum Efreet_Desktop_Type Efreet_Desktop_Type;
/**
* Efreet_Desktop
*/
typedef struct Efreet_Desktop Efreet_Desktop;
/**
* A callback used with efreet_desktop_command_get()
*/
typedef void (*Efreet_Desktop_Command_Cb) (void *data, Efreet_Desktop *desktop, char *command, int remaining);
/**
* A callback used to get download progress of remote uris
*/
typedef int (*Efreet_Desktop_Progress_Cb) (void *data, Efreet_Desktop *desktop, char *uri, long int total, long int current);
/**
* Efreet_Desktop
* @brief a parsed representation of a .desktop file
*/
struct Efreet_Desktop
{
Efreet_Desktop_Type type; /**< type of desktop file */
double version; /**< version of spec file conforms to */
char *orig_path; /**< original path to .desktop file */
double load_time; /**< when the .desktop was loaded from disk */
char *name; /**< Specific name of the application */
char *generic_name; /**< Generic name of the application */
char *comment; /**< Tooltip for the entry */
char *icon; /**< Icon to display in file manager, menus, etc */
char *try_exec; /**< Binary to determine if app is installed */
char *exec; /**< Program to execute */
char *path; /**< Working directory to run app in */
char *startup_wm_class; /**< If specified will map at least one window with
the given string as it's WM class or WM name */
char *url; /**< URL to access if type is EFREET_TYPE_LINK */
Ecore_List *only_show_in; /**< list of environments that should
display the icon */
Ecore_List *not_show_in; /**< list of environments that shoudn't
display the icon */
Ecore_List *categories; /**< Categories in which item should be shown */
Ecore_List *mime_types; /**< The mime types supppored by this app */
unsigned char no_display:1; /**< Don't display this application in menus */
unsigned char hidden:1; /**< User delete the item */
unsigned char terminal:1; /**< Does the program run in a terminal */
unsigned char startup_notify:1; /**< The starup notify settings of the app */
Ecore_Hash *x; /**< Keep track of all user extensions, keys that begin with X- */
};
Efreet_Desktop *efreet_desktop_get(const char *file);
Efreet_Desktop *efreet_desktop_empty_new(const char *file);
void efreet_desktop_free(Efreet_Desktop *desktop);
int efreet_desktop_save(Efreet_Desktop *desktop);
int efreet_desktop_save_as(Efreet_Desktop *desktop,
const char *file);
void efreet_desktop_exec(Efreet_Desktop *desktop,
Ecore_List *files, void *data);
int efreet_desktop_no_display_get(Efreet_Desktop *desktop);
void efreet_desktop_environment_set(const char *environment);
int efreet_desktop_command_progress_get(Efreet_Desktop *desktop,
Ecore_List *files,
Efreet_Desktop_Command_Cb cb_command,
Efreet_Desktop_Progress_Cb cb_prog,
void *data);
int efreet_desktop_command_get(Efreet_Desktop *desktop,
Ecore_List *files,
Efreet_Desktop_Command_Cb func,
void *data);
unsigned int efreet_desktop_category_count_get(Efreet_Desktop *desktop);
void efreet_desktop_category_add(Efreet_Desktop *desktop,
const char *category);
int efreet_desktop_category_del(Efreet_Desktop *desktop,
const char *category);
/**
* @}
*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,178 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_ICON_H
#define EFREET_ICON_H
/**
* @file efreet_icon.h
* @brief Contains the structures and methods used to support the FDO icon
* theme specificiation.
* @addtogroup Efreet_Icon Efreet_Icon: The FDO Icon Theme
* Specification functions and structures
*
* @{
*/
/**
* The possible contexts for an icon directory
*/
enum Efreet_Icon_Theme_Context
{
EFREET_ICON_THEME_CONTEXT_NONE,
EFREET_ICON_THEME_CONTEXT_ACTIONS,
EFREET_ICON_THEME_CONTEXT_DEVICES,
EFREET_ICON_THEME_CONTEXT_FILESYSTEMS,
EFREET_ICON_THEME_CONTEXT_MIMETYPES
};
/**
* Efreet_icon_Theme_Context
*/
typedef enum Efreet_Icon_Theme_Context Efreet_Icon_Theme_Context;
/**
* The possible size types for an icon directory
*/
enum Efreet_Icon_Size_Type
{
EFREET_ICON_SIZE_TYPE_NONE,
EFREET_ICON_SIZE_TYPE_FIXED,
EFREET_ICON_SIZE_TYPE_SCALABLE,
EFREET_ICON_SIZE_TYPE_THRESHOLD
};
/**
* Efreet_Icon_Size_Type
*/
typedef enum Efreet_Icon_Size_Type Efreet_Icon_Size_Type;
/**
* Efreet_Icon_Theme
*/
typedef struct Efreet_Icon_Theme Efreet_Icon_Theme;
/**
* Efreet_Icon_Theme
* @brief contains all of the known information about a given theme
*/
struct Efreet_Icon_Theme
{
struct
{
const char *internal; /**< The internal theme name */
const char *name; /**< The user visible name */
} name; /**< The different names for the theme */
char *comment; /**< String describing the theme */
char *example_icon; /**< Icon to use as an example of the theme */
/* An icon theme can have multiple directories that store it's icons. We
* need to be able to find a search each one. If count is 1 then path
* will be a char * pointing to the directory. If count > 1 then path
* will be an Ecore_List of char *'s pointing to the directories */
struct
{
void *path; /**< The paths */
int count; /**< The number of path's */
} paths; /**< The paths to this theme */
Ecore_List *inherits; /**< Icon themes we inherit from */
Ecore_List *directories; /**< List of subdirectories for this theme */
double last_cache_check; /**< Last time the cache was checked */
Ecore_Hash *icon_cache; /**< Cache of the icon data */
unsigned char hidden:1; /**< Should this theme be hidden from users */
unsigned char valid:1; /**< Have we seen an index for this theme */
unsigned char fake:1; /**< This isnt' a real theme but the user has
tried to query from it. We create the
fake one to give us the theme cache. */
};
/**
* Efreet_Icon_Theme_Directory
*/
typedef struct Efreet_Icon_Theme_Directory Efreet_Icon_Theme_Directory;
/**
* Efreet_Icon_Theme_Directory
* @brief Contains all the information about a sub-directory of a theme
*/
struct Efreet_Icon_Theme_Directory
{
char *name; /**< The directory name */
Efreet_Icon_Theme_Context context; /**< The type of icons in the dir */
Efreet_Icon_Size_Type type; /**< The size type for the icons */
struct
{
unsigned int normal; /**< The size for this directory */
unsigned int min; /**< The minimum size for this directory */
unsigned int max; /**< The maximum size for this directory */
unsigned int threshold; /**< Size difference threshold */
} size; /**< The size settings for the icon theme */
};
/**
* Efreet_Icon
*/
typedef struct Efreet_Icon Efreet_Icon;
/**
* Efreet_Icon
* @brief Contains all the information about a given icon
*/
struct Efreet_Icon
{
char *path; /**< Full path to the icon */
char *name; /**< Translated UTF8 string that can
be used for the icon name */
struct
{
int x0, /**< x0 position */
y0, /**< y0 position */
x1, /**< x1 position */
y1; /**< y1 position */
} embedded_text_rectangle; /**< Rectangle where text can
be displayed on the icon */
Ecore_List *attach_points; /**< List of points to be used as anchor
points for emblems/overlays */
unsigned int ref_count; /**< References to this icon */
unsigned char has_embedded_text_rectangle:1; /**< Was the embedded
rectangle set */
};
/**
* Efreet_Point
*/
typedef struct Efreet_Icon_Point Efreet_Icon_Point;
/**
* Efreet_Point
* @brief Stores an x, y point.
*/
struct Efreet_Icon_Point
{
int x; /**< x coord */
int y; /**< y coord */
};
const char *efreet_icon_dir_get(void);
void efreet_icon_extension_add(const char *ext);
Ecore_List *efreet_icon_theme_list_get(void);
Efreet_Icon_Theme *efreet_icon_theme_find(const char *theme_name);
Efreet_Icon *efreet_icon_find(const char *theme_name, const char *icon,
const char *size);
const char *efreet_icon_path_find(const char *theme, const char *icon,
const char *size);
/**
* @}
*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,651 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#include "Efreet.h"
#include "efreet_private.h"
static Ecore_Hash *efreet_ini_parse(const char *file);
static char *efreet_ini_unescape(const char *str);
static void efreet_ini_section_save(Ecore_Hash_Node *node, FILE *f);
static void efreet_ini_value_save(Ecore_Hash_Node *node, FILE *f);
/**
* The number of times the Ini subsytem has been initialized
*/
static int init = 0;
/**
* @internal
* @return Returns > 0 on success or 0 on failure
* @brief Initialize the Ini parser subsystem
*/
int
efreet_ini_init(void)
{
if (init++) return init;
if (!ecore_string_init()) return --init;
return init;
}
/**
* @internal
* @returns the number of initializations left for this system
* @brief Attempts to shut down the subsystem if nothing else is using it
*/
int
efreet_ini_shutdown(void)
{
if (--init) return init;
ecore_string_shutdown();
return init;
}
/**
* @internal
* @param file: The file to parse
* @return Returns a new Efreet_Ini structure initialized with the contents
* of @a file, or NULL on failure
* @brief Creates and initializes a new Ini structure with the contents of
* @a file, or NULL on failure
*/
Efreet_Ini *
efreet_ini_new(const char *file)
{
Efreet_Ini *ini;
ini = NEW(Efreet_Ini, 1);
if (!ini) return NULL;
ini->data = efreet_ini_parse(file);
return ini;
}
/**
* @internal
* @param file The file to parse
* @return Returns an Ecore_Hash with the contents of @a file, or NULL on failure
* @brief Parses the ini file @a file into an Ecore_Hash
*/
static Ecore_Hash *
efreet_ini_parse(const char *file)
{
FILE *f;
/* a static buffer for quick reading of lines that fit */
char static_buf[4096];
int static_buf_len = 4096;
/* a big buffer to allocate for lines that are larger than the static one */
char *big_buf = NULL;
int big_buf_len = 0;
int big_buf_step = static_buf_len;
/* the current location to read into (with fgets) and the amount to read */
char *read_buf;
int read_len;
/* the current buffer to parse */
char *buf;
Ecore_Hash *data, *section = NULL;
/* start with the static buffer */
buf = read_buf = static_buf;
read_len = static_buf_len;
f = fopen(file, "r");
if (!f) return NULL;
data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set_free_key(data, ECORE_FREE_CB(ecore_string_release));
ecore_hash_set_free_value(data, ECORE_FREE_CB(ecore_hash_destroy));
/* if a line is longer than the buffer size, this \n will get overwritten. */
read_buf[read_len - 2] = '\n';
while(fgets(read_buf, read_len, f) != NULL)
{
char *key, *value, *p;
char *sep;
/* handle lines longer than the buffer size */
if (read_buf[read_len-2] != '\n')
{
int len;
len = strlen(buf);
if (!big_buf)
{
/* create new big buffer and copy in contents of static buf */
big_buf_len = 2 * big_buf_step;
big_buf = malloc(big_buf_len * sizeof(char));
strncpy(big_buf, buf, len + 1);
}
else if (buf == big_buf)
{
/* already using the big buffer. increase its size for the next read */
big_buf_len += big_buf_step;
big_buf = realloc(big_buf, big_buf_len);
}
else
{
/* the big buffer exists, but we aren't using it yet. copy contents of static buf in */
strncpy(big_buf, buf, len);
}
/* use big_buffer for next fgets and subsequent parsing */
buf = big_buf;
read_buf = big_buf + len;
read_len = big_buf_len - len;
read_buf[read_len-2] = '\n';
continue;
}
/* skip empty lines and comments */
if (buf[0] == '\0' || buf[0] == '\n' || buf[0] == '#') goto next_line;
/* new section */
if (buf[0] == '[')
{
char *header, *p;
header = buf + 1;
p = strchr(header, ']');
if (p)
{
Ecore_Hash *old;
*p = '\0';
section = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set_free_key(section, ECORE_FREE_CB(ecore_string_release));
ecore_hash_set_free_value(section, ECORE_FREE_CB(free));
old = ecore_hash_remove(data, header);
//if (old) printf("[efreet] Warning: duplicate section '%s' in file '%s'\n", header, file);
IF_FREE_HASH(old);
ecore_hash_set(data, (void *)ecore_string_instance(header),
section);
}
else
{
/* invalid file - skip line? or refuse to parse file? */
/* just printf for now till we figure out what to do */
printf("Invalid file (%s) (missing ] on group name)\n", file);
}
goto next_line;
}
/* parse key=value pair */
sep = strchr(buf, '=');
key = buf;
if (sep)
{
/* trim whitespace from end of key */
p = sep;
while (p > key && isspace(*(p - 1))) p--;
*p = '\0';
value = sep + 1;
/* trim whitespace from start of value */
while (*value && isspace(*value)) value++;
/* trim \n off of end of value */
p = value + strlen(value) - 1;
while (p > value && (*p == '\n' || *p == '\r')) p--;
*(p + 1) = '\0';
if (key && value && *key && *value)
{
char *old;
old = ecore_hash_remove(section, key);
//if (old) printf("[efreet] Warning: duplicate key '%s' in file '%s'\n", key, file);
IF_FREE(old);
ecore_hash_set(section, (void *)ecore_string_instance(key),
efreet_ini_unescape(value));
}
}
else
{
/* check if line is all whitespace, if so, skip it */
int nonwhite = 0;
p = buf;
while (*p)
{
if (!isspace(*p))
{
nonwhite = 1;
break;
}
p++;
}
if (!nonwhite) goto next_line;
/* invalid file... */
printf("Invalid file (%s) (missing = from key=value pair)\n", file);
}
next_line:
/* finished parsing a line. use static buffer for next line */
buf = read_buf = static_buf;
read_len = static_buf_len;
read_buf[read_len - 2] = '\n';
}
fclose(f);
if (big_buf) free(big_buf);
return data;
}
/**
* @internal
* @param ini: The Efreet_Ini to work with
* @return Returns no value
* @brief Frees the given Efree_Ini structure.
*/
void
efreet_ini_free(Efreet_Ini *ini)
{
if (!ini) return;
IF_FREE_HASH(ini->data);
FREE(ini);
}
/**
* @internal
* @param ini: The Efreet_Ini to work with
* @param file: The file to load
* @return Returns no value
* @brief Saves the given Efree_Ini structure.
*/
int
efreet_ini_save(Efreet_Ini *ini, const char *file)
{
FILE *f;
if (!ini) return 0;
f = fopen(file, "w");
if (!f) return 0;
ecore_hash_for_each_node(ini->data, ECORE_FOR_EACH(efreet_ini_section_save), f);
fclose(f);
return 1;
}
/**
* @internal
* @param ini: The Efreet_Ini to work with
* @param section: The section of the ini file we want to get values from
* @return Returns 1 if the section exists, otherwise 0
* @brief Sets the current working section of the ini file to @a section
*/
int
efreet_ini_section_set(Efreet_Ini *ini, const char *section)
{
if (!ini || !section) return 0;
ini->section = ecore_hash_get(ini->data, section);
return (ini->section ? 1 : 0);
}
/**
* @internal
* @param ini: The Efreet_Ini to work with
* @param section: The section of the ini file we want to add
* @return Returns no value
* @brief Adds a new working section of the ini file to @a section
*/
void
efreet_ini_section_add(Efreet_Ini *ini, const char *section)
{
Ecore_Hash *hash;
if (!ini || !section) return;
if (!ini->data)
{
ini->data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set_free_key(ini->data, ECORE_FREE_CB(ecore_string_release));
ecore_hash_set_free_value(ini->data, ECORE_FREE_CB(ecore_hash_destroy));
}
if (ecore_hash_get(ini->data, section)) return;
hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set_free_key(hash, ECORE_FREE_CB(ecore_string_release));
ecore_hash_set_free_value(hash, ECORE_FREE_CB(free));
ecore_hash_set(ini->data, (void *)ecore_string_instance(section), hash);
}
/**
* @internal
* @param ini: The Efree_Ini to work with
* @param key: The key to lookup
* @return Returns the string associated with the given key or NULL if not
* found.
* @brief Retrieves the value for the given key or NULL if none found.
*/
const char *
efreet_ini_string_get(Efreet_Ini *ini, const char *key)
{
if (!ini || !key || !ini->section) return NULL;
return ecore_hash_get(ini->section, key);
}
/**
* @internal
* @param ini: The Efree_Ini to work with
* @param key: The key to use
* @param value: The value to set
* @return Returns no value
* @brief Sets the value for the given key
*/
void
efreet_ini_string_set(Efreet_Ini *ini, const char *key, const char *value)
{
if (!ini || !key || !ini->section) return;
ecore_hash_set(ini->section, (void *)ecore_string_instance(key), strdup(value));
}
/**
* @internal
* @param ini: The Efree_Ini to work with
* @param key: The key to lookup
* @return Returns the integer associated with the given key or -1 if not
* found.
* @brief Retrieves the value for the given key or -1 if none found.
*/
int
efreet_ini_int_get(Efreet_Ini *ini, const char *key)
{
const char *str;
if (!ini || !key || !ini->section) return -1;
str = efreet_ini_string_get(ini, key);
if (str) return atoi(str);
return -1;
}
/**
* @internal
* @param ini: The Efree_Ini to work with
* @param key: The key to use
* @param value: The value to set
* @return Returns no value
* @brief Sets the value for the given key
*/
void
efreet_ini_int_set(Efreet_Ini *ini, const char *key, int value)
{
char str[12];
if (!ini || !key || !ini->section) return;
snprintf(str, 12, "%d", value);
efreet_ini_string_set(ini, key, str);
}
/**
* @internal
* @param ini: The Efree_Ini to work with
* @param key: The key to lookup
* @return Returns the double associated with the given key or -1 if not
* found.
* @brief Retrieves the value for the given key or -1 if none found.
*/
double
efreet_ini_double_get(Efreet_Ini *ini, const char *key)
{
const char *str;
if (!ini || !key || !ini->section) return -1;
str = efreet_ini_string_get(ini, key);
if (str) return atof(str);
return -1;
}
/**
* @internal
* @param ini: The Efree_Ini to work with
* @param key: The key to use
* @param value: The value to set
* @return Returns no value
* @brief Sets the value for the given key
*/
void
efreet_ini_double_set(Efreet_Ini *ini, const char *key, double value)
{
char str[512];
size_t len;
if (!ini || !key || !ini->section) return;
snprintf(str, 512, "%.6f", value);
len = strlen(str) - 1;
/* Strip trailing zero's */
while (str[len] == '0' && str[len - 1] != '.') str[len--] = 0;
efreet_ini_string_set(ini, key, str);
}
/**
* @internal
* @param ini: The ini struct to work with
* @param key: The key to search for
* @return Returns 1 if the boolean is true, 0 otherwise
* @brief Retrieves the boolean value at key @a key from the ini @a ini
*/
unsigned int
efreet_ini_boolean_get(Efreet_Ini *ini, const char *key)
{
const char *str;
if (!ini || !key || !ini->section) return 0;
str = efreet_ini_string_get(ini, key);
if (str && !strcmp("true", str)) return 1;
return 0;
}
/**
* @internal
* @param ini: The ini struct to work with
* @param key: The key to use
* @param value: The value to set
* @return Returns no value
* @brief Sets the value for the given key
*/
void
efreet_ini_boolean_set(Efreet_Ini *ini, const char *key, unsigned int value)
{
if (!ini || !key || !ini->section) return;
if (value) efreet_ini_string_set(ini, key, "true");
else efreet_ini_string_set(ini, key, "false");
}
/**
* @internal
* @param ini: The ini struct to work with
* @param key: The key to search for
* @return Returns the utf8 encoded string associated with @a key, or NULL
* if none found
* @brief Retrieves the utf8 encoded string associated with @a key in the current locale or NULL if none found
*/
const char *
efreet_ini_localestring_get(Efreet_Ini *ini, const char *key)
{
const char *lang, *country, *modifier;
const char *val = NULL;
char *buf;
int maxlen = 5; /* _, @, [, ] and \0 */
int found = 0;
if (!ini || !key || !ini->section) return NULL;
lang = efreet_lang_get();
country = efreet_lang_country_get();
modifier = efreet_lang_modifier_get();
maxlen += strlen(key);
if (lang) maxlen += strlen(lang);
if (country) maxlen += strlen(country);
if (modifier) maxlen += strlen(modifier);
buf = malloc(maxlen * sizeof(char));
if (lang && modifier && country)
{
snprintf(buf, maxlen, "%s[%s_%s@%s]", key, lang, country, modifier);
val = efreet_ini_string_get(ini, buf);
if (val) found = 1;
}
if (!found && lang && country)
{
snprintf(buf, maxlen, "%s[%s_%s]", key, lang, country);
val = efreet_ini_string_get(ini, buf);
if (val) found = 1;
}
if (!found && lang && modifier)
{
snprintf(buf, maxlen, "%s[%s@%s]", key, lang, modifier);
val = efreet_ini_string_get(ini, buf);
if (val) found = 1;
}
if (!found && lang)
{
snprintf(buf, maxlen, "%s[%s]", key, lang);
val = efreet_ini_string_get(ini, buf);
if (val) found = 1;
}
if (!found)
val = efreet_ini_string_get(ini, key);
FREE(buf);
return val;
}
/**
* @internal
* @param ini: The ini struct to work with
* @param key: The key to use
* @param value: The value to set
* @return Returns no value
* @brief Sets the value for the given key
*/
void
efreet_ini_localestring_set(Efreet_Ini *ini, const char *key, const char *value)
{
const char *lang, *country, *modifier;
char *buf;
int maxlen = 5; /* _, @, [, ] and \0 */
if (!ini || !key || !ini->section) return;
lang = efreet_lang_get();
country = efreet_lang_country_get();
modifier = efreet_lang_modifier_get();
maxlen += strlen(key);
if (lang) maxlen += strlen(lang);
if (country) maxlen += strlen(country);
if (modifier) maxlen += strlen(modifier);
buf = malloc(maxlen * sizeof(char));
if (lang && modifier && country)
snprintf(buf, maxlen, "%s[%s_%s@%s]", key, lang, country, modifier);
else if (lang && country)
snprintf(buf, maxlen, "%s[%s_%s]", key, lang, country);
else if (lang && modifier)
snprintf(buf, maxlen, "%s[%s@%s]", key, lang, modifier);
else if (lang)
snprintf(buf, maxlen, "%s[%s]", key, lang);
else
return;
efreet_ini_string_set(ini, buf, value);
FREE(buf);
}
/**
* @param str The string to unescape
* @return An allocated unescaped string
* @brief Unescapes backslash escapes in a string
*/
static char *
efreet_ini_unescape(const char *str)
{
char *buf, *dest;
const char *p;
if (!str) return NULL;
if (!strchr(str, '\\')) return strdup(str);
buf = malloc(strlen(str) + 1);
p = str;
dest = buf;
while(*p)
{
if (*p == '\\')
{
p++;
switch (*p)
{
case 's':
*(dest++) = ' ';
break;
case 'n':
*(dest++) = '\n';
break;
case 't':
*(dest++) = '\t';
break;
case 'r':
*(dest++) = '\r';
break;
case '\\':
*(dest++) = '\\';
break;
default:
(*dest++) = '\\';
(*dest++) = *p;
}
}
else
*(dest++) = *p;
p++;
}
*(dest) = '\0';
return buf;
}
static void
efreet_ini_section_save(Ecore_Hash_Node *node, FILE *f)
{
fprintf(f, "[%s]\n", (char *)node->key);
ecore_hash_for_each_node(node->value, ECORE_FOR_EACH(efreet_ini_value_save), f);
}
static void
efreet_ini_value_save(Ecore_Hash_Node *node, FILE *f)
{
fprintf(f, "%s=%s\n", (char *)node->key, (char *)node->value);
}

View File

@ -0,0 +1,60 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_INI_H
#define EFREET_INI_H
/**
* @internal
* @file efreet_ini.h
* @brief A simple and fast INI parser
* @addtogroup Efreet_Ini Efreet_Ini: An INI parser
*
* @{
*/
/**
* Efreet_Ini
*/
typedef struct Efreet_Ini Efreet_Ini;
/**
* Efreet_Ini
* @brief Contains all the information about an ini file.
*/
struct Efreet_Ini
{
Ecore_Hash *data; /**< Hash of string => (Hash of string => string) */
Ecore_Hash *section; /**< currently selected section */
};
Efreet_Ini *efreet_ini_new(const char *file);
void efreet_ini_free(Efreet_Ini *ini);
int efreet_ini_save(Efreet_Ini *ini, const char *path);
int efreet_ini_section_set(Efreet_Ini *ini, const char *section);
void efreet_ini_section_add(Efreet_Ini *ini, const char *section);
const char *efreet_ini_string_get(Efreet_Ini *ini, const char *key);
void efreet_ini_string_set(Efreet_Ini *ini, const char *key,
const char *value);
const char *efreet_ini_localestring_get(Efreet_Ini *ini, const char *key);
void efreet_ini_localestring_set(Efreet_Ini *ini, const char *key,
const char *value);
unsigned int efreet_ini_boolean_get(Efreet_Ini *ini, const char *key);
void efreet_ini_boolean_set(Efreet_Ini *ini, const char *key,
unsigned int value);
int efreet_ini_int_get(Efreet_Ini *ini, const char *key);
void efreet_ini_int_set(Efreet_Ini *ini, const char *key, int value);
double efreet_ini_double_get(Efreet_Ini *ini, const char *key);
void efreet_ini_double_set(Efreet_Ini *ini, const char *key,
double value);
/**
* @}
*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,69 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_MENU_H
#define EFREET_MENU_H
/**
* @file efreet_menu.h
* @brief Contains the structures and methods to support the Desktop
* Menu Specification.
* @addtogroup Efreet_Menu Efreet_Menu: The FDO Desktop Menu Specification
* functions and structures
*
* @{
*/
/**
* The type of entry
*/
enum Efreet_Menu_Entry_Type
{
EFREET_MENU_ENTRY_MENU,
EFREET_MENU_ENTRY_DESKTOP,
EFREET_MENU_ENTRY_SEPARATOR,
EFREET_MENU_ENTRY_HEADER
};
/**
* Efreet_Menu_Entry_Type
*/
typedef enum Efreet_Menu_Entry_Type Efreet_Menu_Entry_Type;
/**
* Efreet_Menu
*/
typedef struct Efreet_Menu Efreet_Menu;
/**
* Efreet_Menu
* Stores information on a entry in the menu
*/
struct Efreet_Menu
{
Efreet_Menu_Entry_Type type;
char *id; /**< File-id for desktop and relative name for menu */
const char *name; /**< Name this entry should show */
const char *icon; /**< Icon for this entry */
Efreet_Desktop *desktop; /**< The desktop we refer too */
Ecore_List *entries; /**< The menu items */
};
int efreet_menu_kde_legacy_init(void);
Efreet_Menu *efreet_menu_get(void);
Efreet_Menu *efreet_menu_parse(const char *path);
#if 0
int efreet_menu_save(Efreet_Menu *menu, const char *path);
#endif
void efreet_menu_free(Efreet_Menu *menu);
void efreet_menu_dump(Efreet_Menu *menu, const char *indent);
/**
* @}
*/
#endif

View File

@ -0,0 +1,183 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_PRIVATE_H
#define EFREET_PRIVATE_H
/**
* @file efreet_private.h
* @brief Contains methods and defines that are private to the Efreet
* implementaion
* @addtogroup Efreet_Private Efreet_Private: Private methods and defines
*
* @{
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <dirent.h>
#include <Ecore.h>
#include <Ecore_File.h>
#include "Ecore_Str.h"
#include "config.h"
#include "efreet_xml.h"
#include "efreet_ini.h"
/**
* @def NEW(x, c)
* Allocate and zero out c structures of type x
*/
#define NEW(x, c) calloc(c, sizeof(x))
/**
* @def FREE(x)
* Free x and set to NULL
*/
#define FREE(x) { free(x); x = NULL; }
/**
* @def IF_FREE(x)
* If x is set, free x and set to NULL
*/
#define IF_FREE(x) { if (x) FREE(x) }
/**
* @def IF_RELEASE(x)
* If x is set, ecore_string_release x and set to NULL
*/
#define IF_RELEASE(x) { if (x) ecore_string_release(x); x = NULL; }
/**
* @def IF_FREE_LIST(x)
* If x is a valid pointer destroy x and set to NULL
*/
#define IF_FREE_LIST(x) { if (x) ecore_list_destroy(x); x = NULL; }
/**
* @def IF_FREE_DLIST(x)
* If x is a valid pointer destroy x and set to NULL
*/
#define IF_FREE_DLIST(x) { if (x) ecore_dlist_destroy(x); x = NULL; }
/**
* @def IF_FREE_HASH(x)
* If x is a valid pointer destroy x and set to NULL
*/
#define IF_FREE_HASH(x) { if (x) ecore_hash_destroy(x); x = NULL; }
/**
* @def __UNUSED__
* A flag to mark a function parameter as unused
*/
#if HAVE___ATTRIBUTE__
#define __UNUSED__ __attribute__((unused))
#else
#define __UNUSED__
#endif
#ifndef PATH_MAX
/**
* @def PATH_MAX
* Convenience define to set the maximim path length
*/
#define PATH_MAX 4096
#endif
/**
* @internal
* The different types of commands in an Exec entry
*/
enum Efreet_Desktop_Command_Flag
{
EFREET_DESKTOP_EXEC_FLAG_FULLPATH = 0x0001,
EFREET_DESKTOP_EXEC_FLAG_URI = 0x0002,
EFREET_DESKTOP_EXEC_FLAG_DIR = 0x0004,
EFREET_DESKTOP_EXEC_FLAG_FILE = 0x0008
};
/**
* @internal
* Efreet_Desktop_Command_Flag
*/
typedef enum Efreet_Desktop_Command_Flag Efreet_Desktop_Command_Flag;
/**
* @internal
* Efreet_Desktop_Command
*/
typedef struct Efreet_Desktop_Command Efreet_Desktop_Command;
/**
* @internal
* Holds information on a desktop Exec command entry
*/
struct Efreet_Desktop_Command
{
Efreet_Desktop *desktop;
int num_pending;
Efreet_Desktop_Command_Flag flags;
Efreet_Desktop_Command_Cb cb_command;
Efreet_Desktop_Progress_Cb cb_progress;
void *data;
Ecore_List *files; /**< list of Efreet_Desktop_Command_File */
};
/**
* @internal
* Efreet_Desktop_Command_File
*/
typedef struct Efreet_Desktop_Command_File Efreet_Desktop_Command_File;
/**
* @internal
* Stores information on a file passed to the desktop Exec command
*/
struct Efreet_Desktop_Command_File
{
Efreet_Desktop_Command *command;
char *dir;
char *file;
char *fullpath;
char *uri;
int pending;
};
int efreet_base_init(void);
void efreet_base_shutdown(void);
int efreet_icon_init(void);
void efreet_icon_shutdown(void);
int efreet_menu_init(void);
void efreet_menu_shutdown(void);
int efreet_ini_init(void);
int efreet_ini_shutdown(void);
int efreet_desktop_init(void);
int efreet_desktop_shutdown(void);
const char *efreet_home_dir_get(void);
const char *efreet_lang_get(void);
const char *efreet_lang_country_get(void);
const char *efreet_lang_modifier_get(void);
size_t efreet_array_cat(char *buffer, size_t size, const char *strs[]);
/**
* @}
*/
#endif

View File

@ -0,0 +1,579 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#include "Efreet.h"
#include "efreet_private.h"
static void efreet_xml_dump(Efreet_Xml *xml, int level);
static Efreet_Xml *efreet_xml_parse(char **data, int *size);
static int efreet_xml_tag_parse(char **data, int *size, const char **tag);
static void efreet_xml_attributes_parse(char **data, int *size,
Efreet_Xml_Attribute ***attributes);
static void efreet_xml_text_parse(char **data, int *size, char **text);
static int efreet_xml_tag_empty(char **data, int *size);
static int efreet_xml_tag_close(char **data, int *size, const char *tag);
static void efreet_xml_cb_attribute_free(void *data);
static void efreet_xml_comment_skip(char **data, int *size);
static int error = 0;
static int init = 0;
/**
* @internal
* @return Returns > 0 on success or 0 on failure
* @brief Initialize the XML parser subsystem
*/
int
efreet_xml_init(void)
{
if (init++) return init;
if (!ecore_string_init()) return --init;
return init;
}
/**
* @internal
* @returns the number of initializations left for this system
* @brief Attempts to shut down the subsystem if nothing else is using it
*/
int
efreet_xml_shutdown(void)
{
if (--init) return init;
ecore_string_shutdown();
return init;
}
/**
* @internal
* @param file: The file to parse
* @return Returns an Efreet_Xml structure for the given file @a file or
* NULL on failure
* @brief Parses the given file into an Efreet_Xml structure.
*/
Efreet_Xml *
efreet_xml_new(const char *file)
{
Efreet_Xml *xml = NULL;
int size, fd = -1;
char *data = (void *)-1;
if (!file) return NULL;
size = ecore_file_size(file);
if (size <= 0) goto ERROR;
fd = open(file, O_RDONLY);
if (fd == -1) goto ERROR;
data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (data == (void *)-1) goto ERROR;
error = 0;
xml = efreet_xml_parse(&data, &size);
if (error) goto ERROR;
munmap(data, size);
close(fd);
return xml;
ERROR:
fprintf(stderr, "[efreet]: could not parse xml file\n");
if (data != (void *)-1) munmap(data, size);
if (fd != -1) close(fd);
if (xml) efreet_xml_del(xml);
return NULL;
}
/**
* @internal
* @param xml: The Efree_Xml to free
* @return Returns no value
* @brief Frees up the given Efreet_Xml structure
*/
void
efreet_xml_del(Efreet_Xml *xml)
{
if (xml->children) ecore_dlist_destroy(xml->children);
xml->children = NULL;
if (xml->tag) ecore_string_release(xml->tag);
if (xml->attributes)
{
Efreet_Xml_Attribute **curr;
curr = xml->attributes;
while (*curr)
{
ecore_string_release((*curr)->key);
ecore_string_release((*curr)->value);
FREE(*curr);
curr++;
}
FREE(xml->attributes);
}
IF_FREE(xml->text);
FREE(xml);
}
/**
* @param xml: The xml struct to work with
* @param key: The attribute key to look for
* @return Returns the value for the given key, or NULL if none found
* @brief Retrieves the value for the given attribute key
*/
const char *
efreet_xml_attribute_get(Efreet_Xml *xml, const char *key)
{
Efreet_Xml_Attribute **curr;
if (!xml || !key || !xml->attributes) return NULL;
for (curr = xml->attributes; *curr; curr++)
{
if (!strcmp((*curr)->key, key))
return (*curr)->value;
}
return NULL;
}
static void
efreet_xml_cb_attribute_free(void *data)
{
efreet_xml_del(data);
}
static void
efreet_xml_dump(Efreet_Xml *xml, int level)
{
int i;
for (i = 0; i < level; i++)
printf("\t");
printf("<%s", xml->tag);
if (xml->attributes)
{
Efreet_Xml_Attribute **curr;
for (curr = xml->attributes; *curr; curr++)
printf(" %s=\"%s\"", (*curr)->key, (*curr)->value);
}
if (xml->children)
{
Efreet_Xml *child;
printf(">\n");
ecore_dlist_goto_first(xml->children);
while ((child = ecore_dlist_next(xml->children)))
efreet_xml_dump(child, level + 1);
for (i = 0; i < level; i++)
printf("\t");
printf("</%s>\n", xml->tag);
}
else if (xml->text)
printf(">%s</%s>\n", xml->text, xml->tag);
else
printf("/>\n");
}
static Efreet_Xml *
efreet_xml_parse(char **data, int *size)
{
Efreet_Xml *xml, *sub_xml;
const char *tag = NULL;
/* parse this tag */
if (!efreet_xml_tag_parse(data, size, &(tag))) return NULL;
xml = NEW(Efreet_Xml, 1);
if (!xml)
{
ecore_string_release(tag);
return NULL;
}
xml->children = ecore_dlist_new();
ecore_dlist_set_free_cb(xml->children, efreet_xml_cb_attribute_free);
xml->tag = tag;
efreet_xml_attributes_parse(data, size, &(xml->attributes));
/* Check wether element is empty */
if (efreet_xml_tag_empty(data, size)) return xml;
efreet_xml_text_parse(data, size, &(xml->text));
/* Check wether element is closed */
if (efreet_xml_tag_close(data, size, xml->tag)) return xml;
while ((sub_xml = efreet_xml_parse(data, size)))
ecore_dlist_append(xml->children, sub_xml);
efreet_xml_tag_close(data, size, xml->tag);
return xml;
}
static int
efreet_xml_tag_parse(char **data, int *size, const char **tag)
{
const char *start = NULL, *end = NULL;
char buf[256];
int buf_size;
/* Search for tag */
while (*size > 1)
{
/* Check for tag start */
if (**data == '<')
{
/* Check for end tag */
if (*(*data + 1) == '/') return 0;
/* skip comments */
if (*size > 3 && *(*data + 1) == '!' && *(*data + 2) == '-' && *(*data + 3) == '-')
{
(*data) += 3;
(*size) -= 3;
efreet_xml_comment_skip(data, size);
continue;
}
/* Check for xml directives (and ignore them) */
else if ((*(*data + 1) != '!') && (*(*data + 1) != '?'))
{
(*size)--;
(*data)++;
start = *data;
break;
}
}
(*size)--;
(*data)++;
}
if (!start)
{
fprintf(stderr, "[efreet]: missing start tag\n");
error = 1;
return 0;
}
while (*size > 0)
{
if (!isalpha(**data))
{
end = *data;
break;
}
(*size)--;
(*data)++;
}
if (!end)
{
fprintf(stderr, "[efreet]: no end of tag\n");
error = 1;
return 0;
}
buf_size = end - start + 1;
if (buf_size <= 1)
{
fprintf(stderr, "[efreet]: no tag name\n");
error = 1;
return 0;
}
if (buf_size > 256) buf_size = 256;
memcpy(buf, start, buf_size - 1);
buf[buf_size - 1] = 0;
*tag = ecore_string_instance(buf);
return 1;
}
static void
efreet_xml_attributes_parse(char **data, int *size,
Efreet_Xml_Attribute ***attributes)
{
Efreet_Xml_Attribute attr[10];
int i, count = 0;
while (*size > 0)
{
if (**data == '>')
{
(*size)++;
(*data)--;
break;
}
else if ((count < 10) && (isalpha(**data)))
{
/* beginning of key */
const char *start = NULL, *end = NULL;
char buf[256];
int buf_size;
attr[count].key = NULL;
attr[count].value = NULL;
start = *data;
while ((*size > 0) && ((isalpha(**data)) || (**data == '_')))
{
(*size)--;
(*data)++;
}
end = *data;
buf_size = end - start + 1;
if (buf_size <= 1)
{
fprintf(stderr, "[efreet]: zero length key\n");
goto ERROR;
}
if (buf_size > 256) buf_size = 256;
memcpy(buf, start, buf_size - 1);
buf[buf_size - 1] = 0;
attr[count].key = ecore_string_instance(buf);
/* search for '=', key/value seperator */
start = NULL;
while (*size > 0)
{
if (**data == '=')
{
start = *data;
break;
}
(*size)--;
(*data)++;
}
if (!start)
{
fprintf(stderr, "[efreet]: missing value for attribute!\n");
goto ERROR;
}
/* search for '"', beginning of value */
start = NULL;
while (*size > 0)
{
if (**data == '"')
{
start = *data;
break;
}
(*size)--;
(*data)++;
}
if (!start)
{
fprintf(stderr, "[efreet]: erroneous value for attribute!\n");
goto ERROR;
}
/* skip '"' */
start++;
(*size)--;
(*data)++;
/* search for '"', end of value */
end = NULL;
while (*size > 0)
{
if (**data == '"')
{
end = *data;
break;
}
(*size)--;
(*data)++;
}
if (!end)
{
fprintf(stderr, "[efreet]: erroneous value for attribute!\n");
goto ERROR;
}
buf_size = end - start + 1;
if (buf_size <= 1)
{
fprintf(stderr, "[efreet]: zero length value\n");
goto ERROR;
}
if (buf_size > 256) buf_size = 256;
memcpy(buf, start, buf_size - 1);
buf[buf_size - 1] = 0;
attr[count].value = ecore_string_instance(buf);
count++;
}
(*size)--;
(*data)++;
}
*attributes = NEW(Efreet_Xml_Attribute *, count + 1);
for (i = 0; i < count; i++)
{
(*attributes)[i] = malloc(sizeof(Efreet_Xml_Attribute));
(*attributes)[i]->key = attr[i].key;
(*attributes)[i]->value = attr[i].value;
}
return;
ERROR:
while (count >= 0)
{
if (attr[count].key) ecore_string_release(attr[count].key);
if (attr[count].value) ecore_string_release(attr[count].value);
count--;
}
error = 1;
return;
}
static void
efreet_xml_text_parse(char **data, int *size, char **text)
{
const char *start = NULL, *end = NULL;
int buf_size;
/* skip leading whitespace */
while (*size > 0)
{
if (!isspace(**data))
{
start = *data;
break;
}
(*size)--;
(*data)++;
}
if (!start) return;
/* find next tag */
while (*size > 0)
{
if (**data == '<')
{
end = *data;
break;
}
(*size)--;
(*data)++;
}
if (!end) return;
/* skip trailing whitespace */
while (isspace(*(end - 1))) end--;
/* copy text */
buf_size = end - start + 1;
if (buf_size <= 1) return;
*text = malloc(buf_size);
memcpy(*text, start, buf_size - 1);
(*text)[buf_size - 1] = 0;
}
static int
efreet_xml_tag_empty(char **data, int *size)
{
while (*size > 1)
{
if (**data == '/')
{
(*size)--;
(*data)++;
if (**data == '>')
{
(*size)--;
(*data)++;
return 1;
}
}
else if (**data == '>')
{
(*size)--;
(*data)++;
return 0;
}
(*size)--;
(*data)++;
}
fprintf(stderr, "[efreet]: missing end of tag\n");
error = 1;
return 1;
}
static int
efreet_xml_tag_close(char **data, int *size, const char *tag)
{
while (*size > 1)
{
if (**data == '<')
{
if (*(*data + 1) == '/')
{
(*size) -= 2;
(*data) += 2;
if ((int)strlen(tag) > *size)
{
fprintf(stderr, "[efreet]: wrong end tag\n");
error = 1;
return 1;
}
else
{
char *tmp;
tmp = *data;
while ((*tag) && (*tmp == *tag))
{
tmp++;
tag++;
}
if (*tag)
{
fprintf(stderr, "[efreet]: wrong end tag\n");
error = 1;
return 1;
}
}
return 1;
}
else return 0;
}
(*size)--;
(*data)++;
}
return 0;
}
static void
efreet_xml_comment_skip(char **data, int *size)
{
while (*size > 2)
{
if (**data == '-' && *(*data + 1) == '-' && *(*data + 2) == '>')
{
(*data) += 3;
(*size) -= 3;
return;
}
(*data)++;
(*size)--;
}
}

View File

@ -0,0 +1,61 @@
/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_XML_H
#define EFREET_XML_H
/**
* @internal
* @file efreet_xml.h
* @brief A simple and fast XML parser
* @addtogroup Efreet_Xml Efreet_Xml: An XML parser
*
* @{
*/
/**
* Efreet_Xml_Attributes
*/
typedef struct Efreet_Xml_Attribute Efreet_Xml_Attribute;
/**
* Efreet_Xml_Attributes
* @brief Contains information about a given XML attribute
*/
struct Efreet_Xml_Attribute
{
const char *key; /**< The attribute key */
const char *value; /**< The attribute value */
};
/**
* Efreet_Xml
*/
typedef struct Efreet_Xml Efreet_Xml;
/**
* Efreet_Xml
* @brief Contains the XML tree for a given XML document
*/
struct Efreet_Xml
{
char *text; /**< The XML text for this node */
const char *tag; /**< The tag for this node */
Efreet_Xml_Attribute **attributes; /**< The attributes for this node */
Ecore_DList *children; /**< Child nodes */
};
int efreet_xml_init(void);
int efreet_xml_shutdown(void);
Efreet_Xml *efreet_xml_new(const char *file);
void efreet_xml_del(Efreet_Xml *xml);
const char *efreet_xml_attribute_get(Efreet_Xml *xml, const char *key);
/**
* @}
*/
#endif