move around - flatter.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 17 Aug 2008 07:44:18 +0000 (07:44 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 17 Aug 2008 07:44:18 +0000 (07:44 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/efreet@35497 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

104 files changed:
.cvsignore [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
Doxyfile [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
NOTES [new file with mode: 0644]
README [new file with mode: 0644]
TODO [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.in [new file with mode: 0644]
debian/.cvsignore [new file with mode: 0644]
debian/changelog.in [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/libefreet-dev.install [new file with mode: 0644]
debian/libefreet-doc.dirs [new file with mode: 0644]
debian/libefreet-doc.doc-base [new file with mode: 0644]
debian/libefreet0.install [new file with mode: 0644]
debian/patches/01_menu_extra_path.patch [new file with mode: 0644]
debian/rules [new file with mode: 0755]
doc/.cvsignore [new file with mode: 0644]
doc/e.css [new file with mode: 0644]
doc/foot.html [new file with mode: 0644]
doc/head.html [new file with mode: 0644]
doc/images/_.gif [new file with mode: 0644]
doc/images/b.png [new file with mode: 0644]
doc/images/n.gif [new file with mode: 0644]
doc/images/n.png [new file with mode: 0644]
doc/images/t.gif [new file with mode: 0644]
doc/images/t.png [new file with mode: 0644]
doc/images/tl.gif [new file with mode: 0644]
doc/images/tl.png [new file with mode: 0644]
efreet-mime.pc.in [new file with mode: 0644]
efreet-trash.pc.in [new file with mode: 0644]
efreet.pc.in [new file with mode: 0644]
efreet.spec.in [new file with mode: 0644]
gendoc [new file with mode: 0644]
m4/ac_attribute.m4 [new file with mode: 0644]
m4/ac_define_dir.m4 [new file with mode: 0644]
src/.cvsignore [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/bin/.cvsignore [new file with mode: 0644]
src/bin/Makefile.am [new file with mode: 0644]
src/bin/compare/.cvsignore [new file with mode: 0644]
src/bin/compare/Makefile.am [new file with mode: 0644]
src/bin/compare/comp.h [new file with mode: 0644]
src/bin/compare/efreet_alloc.c [new file with mode: 0644]
src/bin/compare/efreet_menu_alloc.c [new file with mode: 0644]
src/bin/data/.cvsignore [new file with mode: 0644]
src/bin/data/Makefile.am [new file with mode: 0644]
src/bin/data/entry [new file with mode: 0644]
src/bin/data/entry.png [new file with mode: 0644]
src/bin/data/long.ini [new file with mode: 0644]
src/bin/data/preferences.menu [new file with mode: 0644]
src/bin/data/sub/.cvsignore [new file with mode: 0644]
src/bin/data/sub/Makefile.am [new file with mode: 0644]
src/bin/data/sub/test.desktop [new file with mode: 0644]
src/bin/data/test.desktop [new file with mode: 0644]
src/bin/data/test.ini [new file with mode: 0644]
src/bin/data/test.menu [new file with mode: 0644]
src/bin/data/test_garbage [new file with mode: 0644]
src/bin/data/test_menu_bad_comment.menu [new file with mode: 0644]
src/bin/data/test_menu_slash_bad.menu [new file with mode: 0644]
src/bin/data/test_type.desktop [new file with mode: 0644]
src/bin/ef_cache.c [new file with mode: 0644]
src/bin/ef_data_dirs.c [new file with mode: 0644]
src/bin/ef_desktop.c [new file with mode: 0644]
src/bin/ef_icon_theme.c [new file with mode: 0644]
src/bin/ef_ini.c [new file with mode: 0644]
src/bin/ef_locale.c [new file with mode: 0644]
src/bin/ef_menu.c [new file with mode: 0644]
src/bin/ef_mime.c [new file with mode: 0644]
src/bin/ef_test.h [new file with mode: 0644]
src/bin/ef_utils.c [new file with mode: 0644]
src/bin/efreet_spec_test.c [new file with mode: 0644]
src/bin/main.c [new file with mode: 0644]
src/lib/.cvsignore [new file with mode: 0644]
src/lib/Efreet.h [new file with mode: 0644]
src/lib/Efreet_Mime.h [new file with mode: 0644]
src/lib/Efreet_Trash.h [new file with mode: 0644]
src/lib/Makefile.am [new file with mode: 0644]
src/lib/efreet.c [new file with mode: 0644]
src/lib/efreet_base.c [new file with mode: 0644]
src/lib/efreet_base.h [new file with mode: 0644]
src/lib/efreet_desktop.c [new file with mode: 0644]
src/lib/efreet_desktop.h [new file with mode: 0644]
src/lib/efreet_icon.c [new file with mode: 0644]
src/lib/efreet_icon.h [new file with mode: 0644]
src/lib/efreet_ini.c [new file with mode: 0644]
src/lib/efreet_ini.h [new file with mode: 0644]
src/lib/efreet_menu.c [new file with mode: 0644]
src/lib/efreet_menu.h [new file with mode: 0644]
src/lib/efreet_mime.c [new file with mode: 0644]
src/lib/efreet_private.h [new file with mode: 0644]
src/lib/efreet_trash.c [new file with mode: 0644]
src/lib/efreet_uri.c [new file with mode: 0644]
src/lib/efreet_uri.h [new file with mode: 0644]
src/lib/efreet_utils.c [new file with mode: 0644]
src/lib/efreet_utils.h [new file with mode: 0644]
src/lib/efreet_xml.c [new file with mode: 0644]
src/lib/efreet_xml.h [new file with mode: 0644]

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..1fc2479
--- /dev/null
@@ -0,0 +1,21 @@
+Makefile
+Makefile.in
+README
+aclocal.m4
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+stamp-h1
+*.pc
+efreet.spec
+efreet_doxy_warnings.txt
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..47a0100
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,5 @@
+dan 'dj2' sinclair
+Brian 'rephorm' Mattern
+Sebastian 'englebass' Dransfeld
+Nathan 'RbdPngn' Ingersoll
+Nicholas 'Mekius' Hughart
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..376a24a
--- /dev/null
+++ b/COPYING
@@ -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.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Doxyfile b/Doxyfile
new file mode 100644 (file)
index 0000000..d86bc2d
--- /dev/null
+++ b/Doxyfile
@@ -0,0 +1,1252 @@
+# Doxyfile 1.4.7
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           =  Efreet
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 0.0.3
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, 
+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, 
+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, 
+# Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# This tag can be used to specify the encoding used in the generated output. 
+# The encoding is not always determined by the language that is chosen, 
+# but also whether or not the output is meant for Windows or non-Windows users. 
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES 
+# forces the Windows encoding (this is the default for the Windows binary), 
+# whereas setting the tag to NO uses a Unix-style encoding (the default for 
+# all platforms other than Windows).
+
+USE_WINDOWS_ENCODING   = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = YES
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = src/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like the Qt-style comments (thus requiring an 
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = YES
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 4
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 
+# include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = YES
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = YES
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from the 
+# version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = efreet_doxy_warnings.txt
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = src/lib
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = doc/images/
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.  Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = efreet_ Efreet_
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = doc/head.html
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = doc/foot.html
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = doc/e.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = YES
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             =__UNUSED__=
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a caller dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable caller graphs for selected 
+# functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_WIDTH    = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT   = 1024
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that a graph may be further truncated if the graph's 
+# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH 
+# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), 
+# the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, which results in a white background. 
+# Warning: Depending on the platform used, enabling this option may lead to 
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to 
+# read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..5458714
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,234 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..58d3c5e
--- /dev/null
@@ -0,0 +1,11 @@
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = src
+
+MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
+                       config.h.in config.sub configure install-sh \
+                       ltconfig ltmain.sh missing mkinstalldirs \
+                       stamp-h.in depcomp efreet_doxy_warnings.txt
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = efreet.pc efreet-mime.pc efreet-trash.pc
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/NOTES b/NOTES
new file mode 100644 (file)
index 0000000..485be66
--- /dev/null
+++ b/NOTES
@@ -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
+
+  
+
+
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..b60f4d1
--- /dev/null
+++ b/README
@@ -0,0 +1,16 @@
+Efreet
+------
+
+Requirements:
+-------------
+
+Must:
+  libc ecore ecore-file
+
+An implementation of several specifications from freedesktop.org intended for use in Enlightenment DR17 (e17) and other applications using the Enlightenment Foundation Libraries (EFL). Currently, the following specifications are included:
+  o Base Directory
+  o Desktop Entry
+  o Icon Theme
+  o Menu
+
+Efreet depends only on Ecore.
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..a40fb31
--- /dev/null
+++ b/TODO
@@ -0,0 +1,24 @@
+TODO
+----
+- efreet_desktop_command_* should free the exec strings for you (set free cb on execs list in _build()). need to make sure users of this function are updated when this change is made (e.g. e17's exec cb)
+- Efreet_Menu should setup an Ecore_File_Monitor on the .menu files and the
+  app_dir and reload the menu when needed
+
+- 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
+
+- Add support for searching for a list of fallback icons in the current theme
+  BEFORE looking in the inherited themes (e.g. for mime-types that go from
+  specific to general).
+
+- If a theme has several icon types (png, xpm..) prefer the first in the
+  extension list.
+
+- Add some ref/free tracking to check if users aren't abusing the system.
+
+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.
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..995ff2f
--- /dev/null
@@ -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
diff --git a/configure.in b/configure.in
new file mode 100644 (file)
index 0000000..75ee660
--- /dev/null
@@ -0,0 +1,81 @@
+rm -f config.cache
+
+AC_INIT(efreet, 0.5.0.044, enlightenment-devel@lists.sourceforge.net)
+AC_PREREQ(2.52)
+AC_CONFIG_SRCDIR(configure.in)
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+
+AM_INIT_AUTOMAKE(1.6 dist-bzip2)
+AM_CONFIG_HEADER(config.h)
+
+AC_ISC_POSIX
+AC_PROG_CC
+AM_PROG_CC_STDC
+AC_HEADER_STDC
+AC_C_CONST
+AC_C___ATTRIBUTE__
+
+AC_LIBTOOL_WIN32_DLL
+define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
+define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
+AC_PROG_LIBTOOL
+
+VMAJ=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $1);}'`
+VMIN=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $2);}'`
+VMIC=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $3);}'`
+SNAP=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $4);}'`
+version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN"
+AC_SUBST(version_info)
+
+AC_FUNC_ALLOCA
+
+PCFLAGS=$CFLAGS
+
+PKG_CHECK_MODULES(ECORE, [ecore >= 0.9.9 ecore-file >= 0.9.9])
+
+CFLAGS=$ECORE_CFLAGS" "$CFLAGS
+
+requirements="ecore ecore-file"
+
+AC_ARG_ENABLE(strict-spec,
+       [AC_HELP_STRING([--enable-strict-spec],[Enable strict spec compliance])],
+       [enable_strict_spec=$enableval], [enable_strict_spec="auto"])
+if test "x$enable_strict_spec" = "xyes" ; then
+    AC_DEFINE(STRICT_SPEC, 1, [Strict Spec Compliance])
+fi
+
+AC_ARG_ENABLE(sloppy-spec,
+       [AC_HELP_STRING([--disable-sloppy-spec],[Enable sloppy spec compliance])],
+       [enable_sloppy_spec=$enableval], [enable_sloppy_spec="yes"])
+if test "x$enable_sloppy_spec" = "xyes" ; then
+    AC_DEFINE(SLOPPY_SPEC, 1, [Sloppy Spec Compliance])
+fi
+
+CFLAGS=$PCFLAGS
+
+AC_ARG_ENABLE(hidden-visibility,
+       [AC_HELP_STRING([--enable-hidden-visibility],[Enable hidden visibility])],
+       [enable_hidden_visibility=$enableval], [enable_hidden_visibility="auto"])
+if test "x$enable_hidden_visibility" = "xyes" ; then
+    CPPFLAGS="$CPPFLAGS -fvisibility=hidden"
+else
+    AC_DEFINE(DEFAULT_VISIBLITY, 1, [Default visibility])
+fi
+AM_CONDITIONAL(DEFAULT_VISIBILITY, test "x$enable_hidden_visibility" != "xyes")
+
+AC_SUBST(requirements)
+AC_OUTPUT([
+efreet.spec
+efreet.pc
+efreet-mime.pc
+efreet-trash.pc
+Makefile
+src/Makefile
+src/lib/Makefile
+src/bin/Makefile
+src/bin/data/Makefile
+src/bin/data/sub/Makefile
+src/bin/compare/Makefile
+], []
+)
diff --git a/debian/.cvsignore b/debian/.cvsignore
new file mode 100644 (file)
index 0000000..6d10dce
--- /dev/null
@@ -0,0 +1 @@
+changelog
diff --git a/debian/changelog.in b/debian/changelog.in
new file mode 100644 (file)
index 0000000..0671906
--- /dev/null
@@ -0,0 +1,6 @@
+efreet (@VERSION@-1) unstable; urgency=low
+
+  * CVS snapshot.
+
+ -- Falko Schmidt <falko@alphagemini.org>  Mon, 28 Apr 2008 15:54:56 +0000
+
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..851a2f9
--- /dev/null
@@ -0,0 +1,59 @@
+Source: efreet
+Section: libs
+Priority: optional
+Maintainer: Falko Schmidt <falko@alphagemini.org>
+Build-Depends: debhelper (>= 6), cdbs, libecore-dev, doxygen
+Standards-Version: 3.7.3
+Homepage: http://www.enlightenment.org
+
+Package: libefreet0
+Architecture: any
+Depends: ${shlibs:Depends}
+Provides: libefreet
+Recommends: menu-xdg
+Description: Library that implements freedesktop.org specs for use with E17/EFL
+ An implementation of several specifications from freedesktop.org intended for
+ use in Enlightenment DR17 (e17) and other applications using the Enlightenment
+ Foundation Libraries (EFL). Currently, the following specifications are
+ included:
+  - Base Directory
+  - Desktop Entry
+  - Icon Theme
+  - Menu
+ .
+ This package provides the libefreet0 and libefreet0-mime libraries, which
+ contains efreet-based functions for dealing with mime.
+
+Package: libefreet-dev
+Section: libdevel
+Architecture: any
+Depends: libefreet0 (= ${binary:Version}), libecore-dev
+Provides: libefreet0-dev
+Description: Development files for libefreet and libefreet-mime
+ An implementation of several specifications from freedesktop.org intended for
+ use in Enlightenment DR17 (e17) and other applications using the Enlightenment
+ Foundation Libraries (EFL). Currently, the following specifications are
+ included:
+  - Base Directory
+  - Desktop Entry
+  - Icon Theme
+  - Menu
+ .
+ This packages contains headers and static libraries for Efreet.
+
+Package: libefreet-doc
+Section: doc
+Architecture: any
+Provides: libefreet0-doc
+Description: libefreet and libfreet-mime API documentation
+ An implementation of several specifications from freedesktop.org intended for
+ use in Enlightenment DR17 (e17) and other applications using the Enlightenment
+ Foundation Libraries (EFL). Currently, the following specifications are
+ included:
+  - Base Directory
+  - Desktop Entry
+  - Icon Theme
+  - Menu
+ .
+ This package contains HTML documentation for development with libefreet and
+ libefreet-mime.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..5221bba
--- /dev/null
@@ -0,0 +1,43 @@
+This package was debianized by Falko Schmidt <falko@alphagemini.org> on
+Sun, 20 Apr 2008 23:41:27 +0000.
+
+The source code is from the e17/libs/efreet module of the enlightenment CVS
+tree. For more information, see:
+
+http://www.enlightenment.org
+
+Upstream Authors:
+       
+       Dan Sinclair <dj2@everburning.com>
+
+Copyright: 
+
+       Copyright (C) 2006 Dan Sinclair and various contributors (see AUTHORS)
+
+License:
+
+  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.
+
+On Debian systems, the complete text of the BSD License can be found
+in `/usr/share/common-licenses/BSD'.
+
+The Debian packaging is:
+  (C) 2006 2007,Debian Pkg-e Team <pkg-e-devel@lists.alioth.debian.org>
+  and is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
diff --git a/debian/libefreet-dev.install b/debian/libefreet-dev.install
new file mode 100644 (file)
index 0000000..7714b86
--- /dev/null
@@ -0,0 +1,4 @@
+debian/tmp/usr/lib/*.so
+debian/tmp/usr/lib/*.a
+debian/tmp/usr/include/*
+debian/tmp/usr/lib/pkgconfig/*
diff --git a/debian/libefreet-doc.dirs b/debian/libefreet-doc.dirs
new file mode 100644 (file)
index 0000000..81f6a9d
--- /dev/null
@@ -0,0 +1 @@
+usr/share/doc/libefreet-doc
diff --git a/debian/libefreet-doc.doc-base b/debian/libefreet-doc.doc-base
new file mode 100644 (file)
index 0000000..bf69164
--- /dev/null
@@ -0,0 +1,10 @@
+Document: efreet
+Title: Efreet Guide
+Author: Dan Sinclair
+Abstract: This document describes Efreet API
+ and provides sample C code.
+Section: Programming/C
+
+Format: HTML
+Index: /usr/share/doc/libefreet-doc/html/index.html
+Files: /usr/share/doc/libefreet-doc/html/*.html
diff --git a/debian/libefreet0.install b/debian/libefreet0.install
new file mode 100644 (file)
index 0000000..79bbe2f
--- /dev/null
@@ -0,0 +1 @@
+debian/tmp/usr/lib/*.so.*
diff --git a/debian/patches/01_menu_extra_path.patch b/debian/patches/01_menu_extra_path.patch
new file mode 100644 (file)
index 0000000..01b6005
--- /dev/null
@@ -0,0 +1,14 @@
+#Allows E17 to find a menu provided by the e17 package if no menus are found
+#after searching the FDO paths
+--- efreet-0.0.3/src/lib/efreet_menu.c 2007-05-13 18:58:05.000000000 +0200
++++ efreet-0.0.3.patch/src/lib/efreet_menu.c   2007-05-13 18:57:35.000000000 +0200
+@@ -583,6 +583,9 @@
+             return efreet_menu_parse(menu);
+     }
++    snprintf(menu, sizeof(menu), "/etc/xdg/menus/enlightenment-applications.menu");
++    if (ecore_file_exists(menu)) return efreet_menu_parse(menu);
++
+     return NULL;
+ }
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..e860a8a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/make -f
+  
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+
+DEB_CONFIGURE_EXTRA_FLAGS := --disable-rpath
+
+build/libefreet-doc::
+       cd $(DEB_SRCDIR) && ./gendoc
+
+install/libefreet-doc::
+       cp -R $(DEB_SRCDIR)/doc/html debian/libefreet-doc/usr/share/doc/libefreet-doc/
+
+clean::
+       rm -rf $(DEB_SRCDIR)/doc/html $(DEB_SRCDIR)/doc/latex
+       ./autogen.sh --prefix=/usr
diff --git a/doc/.cvsignore b/doc/.cvsignore
new file mode 100644 (file)
index 0000000..2ec816f
--- /dev/null
@@ -0,0 +1,2 @@
+html
+latex
diff --git a/doc/e.css b/doc/e.css
new file mode 100644 (file)
index 0000000..a9f6f64
--- /dev/null
+++ b/doc/e.css
@@ -0,0 +1,161 @@
+body {
+    background: url("images/b.png");
+    background-repeat: repeat-x;
+    background-position: top left;
+    background-color: #f4f4f4;
+    text-align: center;
+    font-family: sans-serif;
+    padding: 0;
+    margin: 0;
+}
+
+div.main {
+    margin: 1em auto;
+    vertical-align: top;
+    font-family: "Bitstream Vera", "Vera", "Trebuchet MS", Trebuchet, Tahoma, sans-serif;
+    color: #444444;
+    font-size: 0.8em;
+    text-align: justify;
+    width: 80%;
+}
+
+td.t { background-image:url("images/t.gif"); }
+td.t[class] { background-image:url("images/t.png"); }
+td.tl { background-image:url("images/tl.gif"); }
+td.tl[class] { background-image:url("images/tl.png"); }
+
+td.nav, td.lnav,  td.rnav {
+   align: middle;
+   text-align: center;
+   vertical-align: middle;
+   width: 100px;
+   height: 25px;
+   font-family: "Bitstream Vera", "Vera", "Trebuchet MS", Trebuchet, Tahoma, sans-serif;
+   color: #000000;
+   font-size: 9px;
+   font-weight: bold;
+   white-space: no-wrap;
+}  
+
+td.lnav[class] { background-image:url("images/n.png"); }
+td.lnav[class] { background-image:url("images/n.png"); }
+td.rnav { background-image:url("images/n.gif"); }
+td.rnav[class] { background-image:url("images/n.png"); }
+
+hr {
+    width: 200px;
+    height: 1px;
+    background: #dddddd;
+    border: 0;
+}
+
+p { color: #444444 ;}
+p.tiny, small {
+    color: #888888;
+    font-size: 0.5em;
+}
+
+h1 { 
+    text-align: center;
+    font-size: 1.3em; 
+}
+
+h2 { font-size: 1.1em; }
+h3 { font-size: 0.9em; }
+
+span.keyword { color: #008000; }
+span.keywordtype { color: #604020; }
+span.keywordflow { color: #e08000; }
+span.comment { color: #800000; }
+span.preprocessor { color: #806020; }
+span.stringliteral { color: #002080; }
+span.charliteral { color: #008080; }
+
+a:link {
+    color: #445566;
+    text-decoration: underline;
+}  
+   
+a:visited {
+    color: #667788;
+    text-decoration: underline;
+}  
+
+a:active {                
+    color: #88cccc;
+    text-decoration: none;
+}
+
+a:hover {
+    color: #112266;
+    text-decoration: underline;
+}  
+
+a.nav {
+    text-decoration: none;
+    display: block;
+}
+a.nav:link, a.nav:visited { color: #888888; }
+a.nav:active { color: #000000; }
+a.nav:hover { color: #444444; }
+a.code:link, a.code:visited { text-decoration: none; }
+
+div.fragment {
+    font-size: 1em;
+    border: 1px dotted #cccccc;
+    background-color: #ffffff;
+    text-align: left;
+    vertical-align: middle;
+    padding: 2px;
+    margin-left: 25px;
+    margin-right: 25px;
+    overflow: auto;
+}
+
+td.indexkey {
+    font-weight: bold;
+    padding-left: 10px;
+    padding-right: 0;
+    padding-top: 2px;
+    padding-bottom: 0px;
+    margin: 0;
+    margin-top: 2px;
+    margin-bottom: 2px;
+    border: 1px dotted #cccccc;
+    border-right: 0px dotted #cccccc;
+}
+
+td.indexvalue {
+    font-style: italic;
+    padding-right: 10px;
+    padding-left: 0;
+    padding-top: 2px;
+    padding-bottom: 2px;
+    margin: 0;
+    margin-top: 2px;
+    margin-bottom: 2px;
+    border: 1px dotted #cccccc;
+    border-left: 0px dotted #cccccc;
+}
+
+.mdescRight { font-style: italic; }
+.memitem {
+    padding-left: 2px;
+    padding-right: 2px;
+    border: 1px dotted #cccccc;
+    background-color: #ffffff;
+}
+.memname {
+    white-space: nowrap;
+    font-weight: bold;
+}
+.paramname { font-weight: normal; }
+
+div.ah {
+    border: thin solid #888888;
+    font-weight: bold;
+    margin-bottom: 3px;
+    margin-top: 3px;
+}
+
diff --git a/doc/foot.html b/doc/foot.html
new file mode 100644 (file)
index 0000000..0d3303d
--- /dev/null
@@ -0,0 +1,6 @@
+  </div>
+  <hr />
+  <p class="tiny">Copyright &copy; Enlightenment.org</p>
+  <p class="tiny">$projectname Documentation Generated: $datetime</p>
+ </body>
+</html>
diff --git a/doc/head.html b/doc/head.html
new file mode 100644 (file)
index 0000000..b58c16b
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+ <head>
+  <title>$title</title>
+  <link href="e.css" rel="stylesheet" type="text/css" />
+ </head>
+
+<body>
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+  <tr>
+   <td class="t" width="50%" valign="top" align="left">
+    <table width="100px" height="100px" border="0" cellpadding="0" cellspacing="0">
+     <tr><td class="lnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=index">Home</a></td></tr>
+     <tr><td class="lnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=news">News</a></td></tr>
+     <tr><td class="lnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=about">About</a></td></tr>
+     <tr><td class="rnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=download">Download</a></td></tr>
+    </table>
+   </td>
+   <td class="tl" width="612" height="250" valign="bottom" align="center">
+    <img src="images/_.gif" width="612" height="1"/>
+    <table border="0" cellpadding="0" cellspacing="4px">
+     <tr>
+      <td class='nav'><a class='nav' href="index.html">Main&nbsp;Page</a></td>
+      <td class='nav'><a class='nav' href="files.html">Files</a></td>
+      <td class='nav'><a class='nav' href="modules.html">Modules</a></td>
+      <td class="nav"><a class="nav" href="annotated.html">Data&nbsp;Structures</a></td>
+      <td class="nav"><a class="nav" href="classes.html">Index</a></td>
+     </tr>
+    </table>
+    <hr />
+   </td>
+   <td class="t" width="50%" valign="top" align="right">
+    <table width="100px" height="100px" border="0" cellpadding="0" cellspacing="0">
+     <tr><td class="rnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=support">Support</a></td></tr>
+     <tr><td class="lnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=contribute">Contribute</a></td></tr>
+     <tr><td class="lnav"><a class="nav" href="http://web.enlightenment.org/p.php?p=contact">Contact</a></td></tr>
+     <tr><td class="lnav"><a class="nav" href="http://trac.enlightenment.org/e">Tracker</a></td></tr>
+    </table>
+   </td>
+  </tr>
+ </table>
+
+ <div class="main">
diff --git a/doc/images/_.gif b/doc/images/_.gif
new file mode 100644 (file)
index 0000000..60fa7a1
Binary files /dev/null and b/doc/images/_.gif differ
diff --git a/doc/images/b.png b/doc/images/b.png
new file mode 100644 (file)
index 0000000..04e5ac8
Binary files /dev/null and b/doc/images/b.png differ
diff --git a/doc/images/n.gif b/doc/images/n.gif
new file mode 100644 (file)
index 0000000..28608c4
Binary files /dev/null and b/doc/images/n.gif differ
diff --git a/doc/images/n.png b/doc/images/n.png
new file mode 100644 (file)
index 0000000..2bb256f
Binary files /dev/null and b/doc/images/n.png differ
diff --git a/doc/images/t.gif b/doc/images/t.gif
new file mode 100644 (file)
index 0000000..cff3068
Binary files /dev/null and b/doc/images/t.gif differ
diff --git a/doc/images/t.png b/doc/images/t.png
new file mode 100644 (file)
index 0000000..06b6079
Binary files /dev/null and b/doc/images/t.png differ
diff --git a/doc/images/tl.gif b/doc/images/tl.gif
new file mode 100644 (file)
index 0000000..4455dbc
Binary files /dev/null and b/doc/images/tl.gif differ
diff --git a/doc/images/tl.png b/doc/images/tl.png
new file mode 100644 (file)
index 0000000..95ae5b6
Binary files /dev/null and b/doc/images/tl.png differ
diff --git a/efreet-mime.pc.in b/efreet-mime.pc.in
new file mode 100644 (file)
index 0000000..f03b952
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: efreet-mime
+Description: Freedesktop Shared Mime Info standard implementation for the EFL
+Requires: @requirements@
+Version: @VERSION@
+Libs: -L${libdir} -lefreet_mime
+Cflags: -I${includedir}/efreet
diff --git a/efreet-trash.pc.in b/efreet-trash.pc.in
new file mode 100644 (file)
index 0000000..343e90e
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: efreet-trash
+Description: Freedesktop Shared Trash implementation for the EFL
+Requires: @requirements@
+Version: @VERSION@
+Libs: -L${libdir} -lefreet_trash
+Cflags: -I${includedir}/efreet
diff --git a/efreet.pc.in b/efreet.pc.in
new file mode 100644 (file)
index 0000000..60a8ce9
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: efreet
+Description: Freedesktop standards implementation for the EFL
+Requires: @requirements@
+Version: @VERSION@
+Libs: -L${libdir} -lefreet
+Cflags: -I${includedir}/efreet
diff --git a/efreet.spec.in b/efreet.spec.in
new file mode 100644 (file)
index 0000000..3e8041d
--- /dev/null
@@ -0,0 +1,65 @@
+%define _missing_doc_files_terminate_build 0
+
+Summary: FreeDesktop.Org Compatibility Library
+Name: @PACKAGE@
+Version: @VERSION@
+Release: 0.%(date '+%Y%m%d')
+License: BSD
+Group: System Environment/Libraries
+URL: http://www.enlightenment.org/
+Source: %{name}-%{version}.tar.gz
+Packager: %{?_packager:%{_packager}}%{!?_packager:Michael Jennings <mej@eterm.org>}
+Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)}
+Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
+Obsoletes: ecore-desktop <= 0.9.9.040
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%description
+Efreet implements the FreeDesktop.Org application and MIME-handling
+standards.
+
+%package devel
+Summary: Efreet headers, static libraries, documentation and test programs
+Group: System Environment/Libraries
+Requires: %{name} = %{version}
+
+%description devel
+Headers, static libraries, test programs and documentation for Efreet
+
+%prep
+%setup -q
+
+%build
+%{configure} --prefix=%{_prefix}
+%{__make} %{?_smp_mflags} %{?mflags}
+
+%install
+%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install
+
+# Get rid of unneeded testing cruft.
+%{__rm} -rf $RPM_BUILD_ROOT%{_datadir}/%{name}
+
+%clean
+test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%defattr(-, root, root)
+%doc AUTHORS COPYING* README
+%{_bindir}/%{name}*
+%{_libdir}/*.so.*
+
+%files devel
+%defattr(-, root, root)
+%{_includedir}/%{name}
+%{_libdir}/*.so
+%{_libdir}/*.la
+%{_libdir}/*.a
+%{_libdir}/pkgconfig/*
+
+%changelog
diff --git a/gendoc b/gendoc
new file mode 100644 (file)
index 0000000..82948bd
--- /dev/null
+++ b/gendoc
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+doxygen
+
+if [ ! -e doc/html/images ]; then
+    mkdir -p doc/html/images
+fi
+
+cp doc/images/*.png doc/images/*.gif doc/html/images
+
diff --git a/m4/ac_attribute.m4 b/m4/ac_attribute.m4
new file mode 100644 (file)
index 0000000..9e4b6b3
--- /dev/null
@@ -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__)
+])
+
diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4
new file mode 100644 (file)
index 0000000..f3d8734
--- /dev/null
@@ -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
+])
diff --git a/src/.cvsignore b/src/.cvsignore
new file mode 100644 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..ad292fa
--- /dev/null
@@ -0,0 +1,4 @@
+
+SUBDIRS = lib bin
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/bin/.cvsignore b/src/bin/.cvsignore
new file mode 100644 (file)
index 0000000..d8dfbd7
--- /dev/null
@@ -0,0 +1,7 @@
+.deps
+.libs
+Makefile
+Makefile.in
+efreet_spec_test
+efreet_test
+efreet_cache_test
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
new file mode 100644 (file)
index 0000000..43add38
--- /dev/null
@@ -0,0 +1,45 @@
+
+SUBDIRS = data compare
+
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I. \
+-I$(top_srcdir)/src/lib \
+@ECORE_CFLAGS@ \
+-DPACKAGE_BIN_DIR=\"$(bindir)\" \
+-DPACKAGE_LIB_DIR=\"$(libdir)\" \
+-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\"
+
+bin_PROGRAMS = efreet_test efreet_spec_test efreet_cache_test
+
+efreet_test_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la \
+                           $(top_builddir)/src/lib/libefreet_mime.la
+efreet_test_LDADD = $(top_builddir)/src/lib/libefreet.la \
+                    $(top_builddir)/src/lib/libefreet_mime.la \
+                    @ECORE_LIBS@
+efreet_test_SOURCES = \
+ef_test.h \
+ef_data_dirs.c \
+ef_icon_theme.c \
+ef_ini.c \
+ef_utils.c \
+ef_desktop.c \
+ef_menu.c \
+ef_mime.c \
+main.c
+
+if DEFAULT_VISIBILITY
+efreet_test_SOURCES += \
+ef_locale.c
+endif
+
+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
+
+efreet_cache_test_DEPENDENCIES = $(top_builddir)/src/lib/libefreet.la
+efreet_cache_test_LDADD = $(top_builddir)/src/lib/libefreet.la @ECORE_LIBS@
+efreet_cache_test_SOURCES = \
+ef_cache.c
diff --git a/src/bin/compare/.cvsignore b/src/bin/compare/.cvsignore
new file mode 100644 (file)
index 0000000..695ac40
--- /dev/null
@@ -0,0 +1,8 @@
+.deps
+.libs
+Makefile
+Makefile.in
+compare_results
+ecore_alloc
+efreet_alloc
+efreet_menu_alloc
diff --git a/src/bin/compare/Makefile.am b/src/bin/compare/Makefile.am
new file mode 100644 (file)
index 0000000..b04da8b
--- /dev/null
@@ -0,0 +1,17 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I. \
+-I$(top_srcdir)/src/lib \
+@ECORE_CFLAGS@
+
+bin_PROGRAMS = efreet_alloc efreet_menu_alloc
+
+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@
+
diff --git a/src/bin/compare/comp.h b/src/bin/compare/comp.h
new file mode 100644 (file)
index 0000000..c02eebe
--- /dev/null
@@ -0,0 +1,527 @@
+#ifndef COMP_H
+#define COMP_H
+
+#define LOOPS 1000
+#define THEME "Tango"
+#define SIZE 16
+
+#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
diff --git a/src/bin/compare/efreet_alloc.c b/src/bin/compare/efreet_alloc.c
new file mode 100644 (file)
index 0000000..818d0b0
--- /dev/null
@@ -0,0 +1,28 @@
+#include <Efreet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "comp.h"
+
+int
+main(int argc, char **argv)
+{
+    int i = 0, k;
+    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"));
+            if (path) free(path);
+        }
+    }
+
+    efreet_shutdown();
+
+    return 0;
+}
+
diff --git a/src/bin/compare/efreet_menu_alloc.c b/src/bin/compare/efreet_menu_alloc.c
new file mode 100644 (file)
index 0000000..5a43a0c
--- /dev/null
@@ -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;
+}
+
diff --git a/src/bin/data/.cvsignore b/src/bin/data/.cvsignore
new file mode 100644 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/src/bin/data/Makefile.am b/src/bin/data/Makefile.am
new file mode 100644 (file)
index 0000000..50eef85
--- /dev/null
@@ -0,0 +1,18 @@
+SUBDIRS = sub
+
+MAINTAINERCLEANFILES = Makefile.in
+
+testdir = $(pkgdatadir)/test
+test_DATA = \
+test.ini \
+long.ini \
+test.desktop \
+test_type.desktop \
+test.menu \
+test_menu_slash_bad.menu \
+entry.png \
+entry \
+preferences.menu \
+test_garbage
+
+EXTRA_DIST = $(test_DATA)
diff --git a/src/bin/data/entry b/src/bin/data/entry
new file mode 100644 (file)
index 0000000..503d8e5
Binary files /dev/null and b/src/bin/data/entry differ
diff --git a/src/bin/data/entry.png b/src/bin/data/entry.png
new file mode 100644 (file)
index 0000000..503d8e5
Binary files /dev/null and b/src/bin/data/entry.png differ
diff --git a/src/bin/data/long.ini b/src/bin/data/long.ini
new file mode 100644 (file)
index 0000000..32154dd
--- /dev/null
@@ -0,0 +1,3 @@
+[section]
+key=averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,the last value
+key2=averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,averylongvalue,the last value
diff --git a/src/bin/data/preferences.menu b/src/bin/data/preferences.menu
new file mode 100644 (file)
index 0000000..904dbd2
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE Menu PUBLIC 
+        "-//freedesktop//DTD Menu 1.0//EN"
+        "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
+
+<Menu>
+  <Name>Preferences</Name>
+  <Directory>Preferences.directory</Directory>
+
+  <AppDir>blah</AppDir>
+  <AppDir>/var/tmp</AppDir>
+
+  <Move> 
+    <Old>Blah</Old 
+    <New>Borp</New> 
+  </Move>  
+
+  <Menu> 
+    <Name>House</Name> 
+    <Directory>House.directory</Directory> 
+    <Include> 
+      <Category>House</Category> 
+      <Category>Garden</Category>
+    </Include> 
+  </Menu> 
+  <Menu> 
+    <Name>Mouse</Name> 
+    <Directory>House.directory</Directory> 
+    <Include> 
+      <Category>House</Category> 
+      <Category>Garden</Category>
+    </Include> 
+  </Menu> 
+  <Menu> 
+    <Name>House</Name> 
+    <Directory>House.directory</Directory> 
+    <Include> 
+      <Category>Cat</Category>
+    </Include> 
+  </Menu> 
+</Menu>
+
diff --git a/src/bin/data/sub/.cvsignore b/src/bin/data/sub/.cvsignore
new file mode 100644 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/src/bin/data/sub/Makefile.am b/src/bin/data/sub/Makefile.am
new file mode 100644 (file)
index 0000000..7aaf7fc
--- /dev/null
@@ -0,0 +1,8 @@
+
+MAINTAINERCLEANFILES = Makefile.in
+
+testdir = $(pkgdatadir)/test/sub
+test_DATA = \
+test.desktop
+
+EXTRA_DIST = $(test_DATA)
diff --git a/src/bin/data/sub/test.desktop b/src/bin/data/sub/test.desktop
new file mode 100644 (file)
index 0000000..7abf2ae
--- /dev/null
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=Sub
+Exec=subtest
+Categories=Test
diff --git a/src/bin/data/test.desktop b/src/bin/data/test.desktop
new file mode 100644 (file)
index 0000000..412601f
--- /dev/null
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=Efreet Test Application
+GenericName=Test Application
+Exec=efreet_test %F %i
+Categories=Test;Enlightenment;
+Icon=TestIcon
+X-Test=Own key
diff --git a/src/bin/data/test.ini b/src/bin/data/test.ini
new file mode 100644 (file)
index 0000000..7f73d81
--- /dev/null
@@ -0,0 +1,21 @@
+# Comments should be ignored (and empty lines)
+
+[contact]
+Name=Foo Bar
+Name[en_US]=English Foo Bar
+Email=  foo@bar.com
+Email[de_DE] = foo@bar.de
+Age =  30
+TrueBoolean=true
+FalseBoolean=false
+InvalidBoolean=invalid
+Escaped=line1\nline2\r\nline3\ttabbed \\ with a backslash\sand\sspaces
+
+[AIM]
+Username=foobar
+
+# the next line has a single space. it should be skipped as well
+[Jabber]
+Username=foobar@bar.de
+
diff --git a/src/bin/data/test.menu b/src/bin/data/test.menu
new file mode 100644 (file)
index 0000000..7ae21ff
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE Menu PUBLIC 
+        "-//freedesktop//DTD Menu 1.0//EN"
+        "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
+
+<Menu>
+  <Name>Applications</Name>
+  <Directory>Applications.directory</Directory>
+
+  <DefaultAppDirs/>
+  <DefaultDirectoryDirs/>
+
+  <MergeDir>applications-merged</MergeDir>
+
+  <LegacyDir>/usr/share/applnk</LegacyDir>
+
+  <DefaultLayout>
+    <Merge type="menus"/>
+    <Merge type="files"/>
+    <Separator/>
+    <Menuname>More</Menuname>
+  </DefaultLayout>
+
+  <Move> 
+    <Old>Foo</Old> 
+    <New>Bar</New> 
+    <Old>Foo2</Old> 
+    <New>Bar2</New> 
+  </Move>  
+
+  <Menu> 
+    <Name>Preferences</Name> 
+    <Directory>Preferences.directory</Directory> 
+    <MergeFile>preferences.menu</MergeFile> 
+  </Menu> 
+
+  <Menu> 
+    <Name>Office</Name> 
+    <Directory>Office.directory</Directory> 
+    <Include> 
+      <Category>Office</Category> 
+    </Include> 
+    <Exclude> 
+      <Filename>foo.desktop</Filename> 
+      <And>
+        <Not>
+          <Filename>bar.desktop</Filename>
+        </Not>
+      </And>
+    </Exclude> 
+  </Menu> 
+</Menu>
+
diff --git a/src/bin/data/test_garbage b/src/bin/data/test_garbage
new file mode 100644 (file)
index 0000000..7d178fd
--- /dev/null
@@ -0,0 +1,2341 @@
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcd
\ No newline at end of file
diff --git a/src/bin/data/test_menu_bad_comment.menu b/src/bin/data/test_menu_bad_comment.menu
new file mode 100644 (file)
index 0000000..5815b89
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE Menu PUBLIC 
+        "-//freedesktop//DTD Menu 1.0//EN"
+        "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
+
+<Menu>
+  <Name>Applications</Name>
+  <Directory>Applications.directory</Directory>
+
+  <!-- a comment
+   <!-- with a comment -->
+  <Or> This should be commented </Or>
+  -->
+</Menu>
+
diff --git a/src/bin/data/test_menu_slash_bad.menu b/src/bin/data/test_menu_slash_bad.menu
new file mode 100644 (file)
index 0000000..8f7b6f0
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE Menu PUBLIC 
+        "-//freedesktop//DTD Menu 1.0//EN"
+        "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
+
+<Menu>
+  <Name>Applications/Bar</Name>
+
+  <Menu> 
+    <Name>Preferences/Baz</Name> 
+  </Menu> 
+</Menu>
diff --git a/src/bin/data/test_type.desktop b/src/bin/data/test_type.desktop
new file mode 100644 (file)
index 0000000..1b67ff5
--- /dev/null
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=My_Type
+Name=Efreet Test Application
+GenericName=Test Application
+Exec=efreet_test %F %i
+Categories=Test;Enlightenment;
+Icon=TestIcon
+X-Test=Own key
diff --git a/src/bin/ef_cache.c b/src/bin/ef_cache.c
new file mode 100644 (file)
index 0000000..45ffd80
--- /dev/null
@@ -0,0 +1,46 @@
+#include "Efreet.h"
+#include <stdio.h>
+#include "ef_test.h"
+
+static int
+timer(void *data __UNUSED__)
+{
+    Ecore_List *list;
+    Efreet_Desktop *desktop;
+    double start;
+
+    start = ecore_time_get();
+    desktop = efreet_util_desktop_name_find("Mozilla Firefox");
+    printf("Mozilla Firefox: %p %.3f\n", desktop, (ecore_time_get() - start));
+    start = ecore_time_get();
+    desktop = efreet_util_desktop_generic_name_find("Mail/News");
+    printf("Mail/News: %p %.3f\n", desktop, (ecore_time_get() - start));
+    start = ecore_time_get();
+    desktop = efreet_util_desktop_wm_class_find("Mozilla-firefox-bin", NULL);
+    printf("Mozilla-firefox-bin: %p %.3f\n", desktop, (ecore_time_get() - start));
+
+    list = efreet_util_desktop_mime_list("application/ogg");
+    if (list)
+    {
+        ecore_list_first_goto(list);
+        while ((desktop = ecore_list_next(list)))
+        {
+            printf("application/ogg: %s\n", desktop->name);
+        }
+        ecore_list_destroy(list);
+    }
+
+    return 0;
+}
+
+int
+main(int argc __UNUSED__, char **argv __UNUSED__)
+{
+    if (!efreet_init()) return 1;
+    if (!efreet_util_init()) return 1;
+    ecore_timer_add(2.0, timer, NULL);
+    ecore_main_loop_begin();
+    efreet_util_shutdown();
+    efreet_shutdown();
+    return 0;
+}
diff --git a/src/bin/ef_data_dirs.c b/src/bin/ef_data_dirs.c
new file mode 100644 (file)
index 0000000..291273d
--- /dev/null
@@ -0,0 +1,302 @@
+#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;
+
+    efreet_shutdown();
+    setenv("XDG_DATA_HOME", "/var/tmp", 1);
+    efreet_init();
+
+    tmp = efreet_data_home_get();
+    if (strcmp(tmp, "/var/tmp"))
+    {
+        printf("efreet_data_home_get() returned incorrect "
+                "value (%s) on XDG_DATA_HOME=/var/tmp\n", tmp);
+        ret = 0;
+    }
+
+    /* reset efreet here so we can set a new home dir */
+    efreet_shutdown();
+    unsetenv("XDG_DATA_HOME");
+    setenv("HOME", "/home/tmp", 1);
+    efreet_init();
+
+    tmp = efreet_data_home_get();
+    if (strcmp(tmp, "/home/tmp/.local/share"))
+    {
+        printf("efreet_data_home_get() returned incorrect "
+                "value (%s) on blank XDG_DATA_HOME\n", tmp);
+        ret = 0;
+    }
+
+    /* reset efreet here so we can set a new home dir */
+    efreet_shutdown();
+    unsetenv("XDG_DATA_HOME");
+    unsetenv("HOME");
+    efreet_init();
+
+    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;
+
+    efreet_shutdown();
+    setenv("XDG_CONFIG_HOME", "/var/tmp", 1);
+    efreet_init();
+
+    tmp = efreet_config_home_get();
+    if (strcmp(tmp, "/var/tmp"))
+    {
+        printf("efreet_config_home_get() returned incorrect "
+                "value (%s) on XDG_CONFIG_HOME=/var/tmp\n", tmp);
+        ret = 0;
+    }
+
+    /* reset efreet here so we can set a new home dir */
+    efreet_shutdown();
+    unsetenv("XDG_CONFIG_HOME");
+    setenv("HOME", "/home/tmp", 1);
+    efreet_init();
+
+    tmp = efreet_config_home_get();
+    if (strcmp(tmp, "/home/tmp/.config"))
+    {
+        printf("efreet_config_home_get() returned incorrect "
+                "value (%s) on blank XDG_CONFIG_HOME\n", tmp);
+        ret = 0;
+    }
+
+    /* reset efreet here so we can set a new home dir */
+    efreet_shutdown();
+    unsetenv("XDG_CONFIG_HOME");
+    unsetenv("HOME");
+    efreet_init();
+
+    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;
+
+    efreet_shutdown();
+    setenv("XDG_CACHE_HOME", "/var/tmp", 1);
+    efreet_init();
+
+    tmp = efreet_cache_home_get();
+    if (strcmp(tmp, "/var/tmp"))
+    {
+        printf("efreet_cache_home_get() returned incorrect "
+                "value (%s) on XDG_CACHE_HOME=/var/tmp\n", tmp);
+        ret = 0;
+    }
+
+    /* reset efreet here so we can set a new home dir */
+    efreet_shutdown();
+    unsetenv("XDG_CACHE_HOME");
+    setenv("HOME", "/home/tmp", 1);
+    efreet_init();
+
+    tmp = efreet_cache_home_get();
+    if (strcmp(tmp, "/home/tmp/.cache"))
+    {
+        printf("efreet_cache_home_get() returned incorrect "
+                "value (%s) on blank XDG_CACHE_HOME\n", tmp);
+        ret = 0;
+    }
+
+    /* reset efreet here so we can set a new home dir */
+    efreet_shutdown();
+    unsetenv("XDG_CACHE_HOME");
+    unsetenv("HOME");
+    efreet_init();
+
+    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';
+    for (i = 0; vals[i] != NULL; i++)
+    {
+        if (i > 0) strcat(dirs, ":");
+        strcat(dirs, vals[i]);
+    }
+
+    efreet_shutdown();
+    setenv("XDG_DATA_DIRS", dirs, 1);
+    efreet_init();
+
+    i = 0;
+    tmp = efreet_data_dirs_get();
+    ecore_list_first_goto(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();
+    unsetenv("XDG_DATA_DIRS");
+    efreet_init();
+
+    i = 0;
+    tmp = efreet_data_dirs_get();
+    if (ecore_list_count(tmp) != 2)
+    {
+        printf("efreet_data_dirs_get() nodes is differnet from expected default\n");
+        ret = 0;
+    }
+
+    ecore_list_first_goto(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';
+
+    for (i = 0; vals[i] != NULL; i++)
+    {
+        if (i > 0) strcat(dirs, ":");
+        strcat(dirs, vals[i]);
+    }
+
+    efreet_shutdown();
+    setenv("XDG_CONFIG_DIRS", dirs, 1);
+    efreet_init();
+
+    i = 0;
+    tmp = efreet_config_dirs_get();
+    ecore_list_first_goto(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();
+    unsetenv("XDG_CONFIG_DIRS");
+    efreet_init();
+
+    i = 0;
+    tmp = efreet_config_dirs_get();
+    ecore_list_first_goto(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;
+}
diff --git a/src/bin/ef_desktop.c b/src/bin/ef_desktop.c
new file mode 100644 (file)
index 0000000..dd8c9b0
--- /dev/null
@@ -0,0 +1,396 @@
+#include "Efreet.h"
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include "ef_test.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"/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_first_goto(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;
+
+    efreet_desktop_free(desktop);
+
+    return ret;
+}
+
+#if 0
+int
+ef_cb_desktop_file_id(void)
+{
+    Efreet_Desktop *desktop;
+    int ret = 1;
+
+    desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
+    if (desktop)
+    {
+        const char *id;
+        int i = 0;
+
+        struct {
+            char *dir;
+            int legacy;
+            char *prefix;
+            char *expected;
+        } tests[] = {
+            {PACKAGE_DATA_DIR"/test/", 0, NULL, "test.desktop"},
+            {PACKAGE_DATA_DIR"/", 0, NULL, "test-test.desktop"},
+            {PACKAGE_DATA_DIR"/", 1, NULL, "test.desktop"},
+            {PACKAGE_DATA_DIR"/", 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"/test/test.desktop");
+    if (!desktop)
+    {
+        printf("Failed to get Desktop file\n");
+        return 0;
+    }
+
+    printf("save data: %d\n", efreet_desktop_save(desktop));
+    efreet_desktop_free(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_free_cb_set(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");
+    efreet_desktop_free(desktop);
+
+    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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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_first_goto(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 __UNUSED__,
+            char *exec, int remaining __UNUSED__)
+{
+  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);
+  return NULL;
+}
+
+static void *
+cb_type_parse(Efreet_Desktop *desktop __UNUSED__, Efreet_Ini *ini)
+{
+    const char *val;
+    val = efreet_ini_string_get(ini, "X-Test");
+    if (!val) return NULL;
+    return (void *)strdup(val);
+}
+
+int
+ef_cb_desktop_type_parse(void)
+{
+    Efreet_Desktop *desktop;
+    int my_type;
+    char *val;
+    int ret = 1;
+
+    /* add my custom desktop type to efreet */
+    my_type = efreet_desktop_type_add("My_Type", cb_type_parse, NULL,
+                                        (Efreet_Desktop_Type_Free_Cb)free);
+
+    desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test_type.desktop");
+    if (!desktop)
+    {
+        printf("No desktop found.\n");
+        return 0;
+    }
+
+    if (desktop->type != my_type)
+    {
+        printf("Invalid type returned in desktop");
+        ret = 0;
+    }
+
+    val = (char *)efreet_desktop_type_data_get(desktop);
+    if (!val || strcmp(val, "Own key"))
+    {
+        printf("Invalid value of custom key (%s).\n", val);
+        ret = 0;
+    }
+
+    efreet_desktop_free(desktop);
+    return ret;
+}
diff --git a/src/bin/ef_icon_theme.c b/src/bin/ef_icon_theme.c
new file mode 100644 (file)
index 0000000..dbfd6b6
--- /dev/null
@@ -0,0 +1,631 @@
+#include "Efreet.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <Ecore_File.h>
+
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
+#define SIZE 128
+#define THEME "Human"
+#define FREE(x) do { free(x); x = NULL; } while (0);
+
+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;
+
+    unsetenv("XDG_DATA_HOME");
+    efreet_shutdown();
+    putenv("HOME=/var/tmp");
+    efreet_init();
+
+    tmp = efreet_icon_user_dir_get();
+    if (strcmp(tmp, "/var/tmp/.local/share/icons"))
+    {
+        printf("efreet_icon_user_dir_get() returned incorrect "
+                "value (%s) on HOME=/var/tmp\n", tmp);
+        ret = 0;
+    }
+
+    efreet_shutdown();
+    unsetenv("HOME");
+    efreet_init();
+
+    tmp = efreet_icon_user_dir_get();
+    if (strcmp(tmp, "/tmp/.local/share/icons"))
+    {
+        printf("efreet_icon_user_dir_get() returned incorrect "
+                "value (%s) on HOME=\n", tmp);
+        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_free_key_cb_set(dirs, free);
+
+    icon_dirs = efreet_data_dirs_get();
+    ecore_list_first_goto(icon_dirs);
+
+    ef_icon_theme_themes_find(efreet_icon_user_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_first_goto(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_count(themes) > 0)
+    {
+        char *dir;
+
+        printf("efreet_icon_theme_list_get() missed: ");
+        ecore_list_first_goto(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_first_remove(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;
+            if (!efreet_ini_localestring_get(ini, "Name")) 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",
+#if 0
+    "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",
+#endif
+    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_first_goto(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_free_key_cb_set(icon_hash, free);
+    ecore_hash_free_value_cb_set(icon_hash, free);
+
+    ef_icons_find(theme, themes, icon_hash);
+    ecore_list_destroy(themes);
+
+    double start = ecore_time_get();
+    for (i = 0; icons[i] != NULL; i++)
+    {
+        char *path, *s;
+
+        path = efreet_icon_path_find(THEME, icons[i], SIZE);
+
+        if (!path)
+        {
+#if 0
+            if (ecore_hash_get(icon_hash, icons[i]))
+            {
+                printf("NOT FOUND %s\n", icons[i]);
+                ret = 0;
+            }
+#endif
+            continue;
+        }
+
+        s = strrchr(path, '.');
+        if (s) *s = '\0';
+        s = strrchr(path, '/');
+        if (s) s++;
+
+        if (s && strcmp(s, icons[i]))
+        {
+            printf("Name mismatch name (%s) vs ef (%s)\n", icons[i], s);
+            ret = 0;
+        }
+        free(path);
+    }
+    printf("Time: %f\n", (ecore_time_get() - start));
+    ecore_hash_destroy(icon_hash);
+
+    start = ecore_time_get();
+    for (i = 0; icons[i] != NULL; i++)
+    {
+        char *path, *s;
+
+        path = efreet_icon_path_find(THEME, icons[i], SIZE);
+
+        if (!path) continue;
+
+        s = strrchr(path, '.');
+        if (s) *s = '\0';
+        s = strrchr(path, '/');
+        if (s) s++;
+
+        if (s && strcmp(s, icons[i]))
+        {
+            printf("Name mismatch name (%s) vs ef (%s)\n", icons[i], s);
+            ret = 0;
+        }
+        free(path);
+    }
+    printf("Time: %f\n", (ecore_time_get() - start));
+
+    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_first_goto(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_first_goto(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_first_goto(theme->paths.path);
+        while ((theme_path = ecore_list_next(theme->paths.path)))
+        {
+            Efreet_Icon_Theme_Directory *dir;
+
+            ecore_list_first_goto(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_first_goto(theme->inherits);
+        while ((parent = ecore_list_next(theme->inherits)))
+        {
+            ecore_list_first_goto(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_first_goto(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_first_remove(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);
+}
diff --git a/src/bin/ef_ini.c b/src/bin/ef_ini.c
new file mode 100644 (file)
index 0000000..d31fb45
--- /dev/null
@@ -0,0 +1,174 @@
+#include "Efreet.h"
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.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"/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"/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;
+}
+
+int
+ef_cb_ini_garbage(void)
+{
+  Efreet_Ini *ini;
+  int ret = 1;
+   
+  ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/test_garbage");
+  if (!ini)
+  {
+    printf("Ini failed to parse.\n");
+    return 0;
+  }
+  if (ini->data) ret = 0;
+  efreet_ini_free(ini);
+  return ret;
+}
diff --git a/src/bin/ef_locale.c b/src/bin/ef_locale.c
new file mode 100644 (file)
index 0000000..d71799e
--- /dev/null
@@ -0,0 +1,85 @@
+#include "Efreet.h"
+#include "efreet_private.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.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;
+}
diff --git a/src/bin/ef_menu.c b/src/bin/ef_menu.c
new file mode 100644 (file)
index 0000000..9894b4f
--- /dev/null
@@ -0,0 +1,154 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "config.h"
+#include <stdio.h>
+#include <unistd.h>
+
+#if 0
+static void
+ef_menu_desktop_exec(Efreet_Menu *menu)
+{
+    if (menu->entries)
+    {
+        Efreet_Desktop *desktop;
+
+        ecore_list_first_goto(menu->entries);
+        while ((desktop = ecore_list_next(menu->entries)))
+            efreet_desktop_exec(desktop, NULL);
+    }
+    if (menu->sub_menus)
+    {
+        Efreet_Menu *sub_menu;
+
+        ecore_list_first_goto(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"/test/test.menu");
+    if (!menu)
+    {
+        printf("efreet_menu_get() returned NULL\n");
+        return 0;
+    }
+    printf("\n");
+    efreet_menu_dump(menu, "");
+    efreet_menu_free(menu);
+
+    return 1;
+}
+
+int
+ef_cb_menu_with_slashes(void)
+{
+    Efreet_Menu *menu;
+
+    menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test_menu_slash_bad.menu");
+    if (menu)
+    {
+        printf("efreet_menu_get() didn't return NULL\n");
+        return 0;
+    }
+
+    return 1;
+}
+
+int
+ef_cb_menu_save(void)
+{
+    Efreet_Menu *menu;
+    int ret;
+
+//    menu = efreet_menu_get();
+    menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu");
+    if (!menu)
+    {
+        printf("efreet_menu_get() returned NULL\n");
+        return 0;
+    }
+    unlink("/tmp/test.menu");
+    ret = efreet_menu_save(menu, "/tmp/test.menu");
+    efreet_menu_free(menu);
+    return ret;
+}
+
+int
+ef_cb_menu_edit(void)
+{
+    Efreet_Menu *menu, *entry;
+    Efreet_Desktop *desktop;
+
+//    menu = efreet_menu_get();
+    menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu");
+    if (!menu)
+    {
+        printf("efreet_menu_get() returned NULL\n");
+        return 0;
+    }
+#if 0
+    printf("\n");
+    efreet_menu_dump(menu, "");
+    printf("\n");
+#endif
+
+    desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
+    if (!desktop)
+    {
+        efreet_menu_free(menu);
+        printf("No desktop found.\n");
+        return 0;
+    }
+
+    efreet_menu_desktop_insert(menu, desktop, 0);
+#if 0
+    printf("\n");
+    efreet_menu_dump(menu, "");
+    printf("\n");
+#endif
+    ecore_list_first_goto(menu->entries);
+    entry = ecore_list_current(menu->entries);
+    if (desktop != entry->desktop)
+    {
+        efreet_menu_free(menu);
+        return 0;
+    }
+
+    efreet_menu_desktop_insert(menu, desktop, 2);
+#if 0
+    printf("\n");
+    efreet_menu_dump(menu, "");
+    printf("\n");
+#endif
+    ecore_list_index_goto(menu->entries, 2);
+    entry = ecore_list_current(menu->entries);
+    if (desktop != entry->desktop)
+    {
+        efreet_menu_free(menu);
+        return 0;
+    }
+
+    efreet_menu_desktop_insert(menu, desktop, -1);
+#if 0
+    printf("\n");
+    efreet_menu_dump(menu, "");
+    printf("\n");
+#endif
+    ecore_list_last_goto(menu->entries);
+    entry = ecore_list_current(menu->entries);
+    if (desktop != entry->desktop)
+    {
+        efreet_menu_free(menu);
+        return 0;
+    }
+
+    efreet_menu_free(menu);
+    return 1;
+}
diff --git a/src/bin/ef_mime.c b/src/bin/ef_mime.c
new file mode 100644 (file)
index 0000000..7cf1e02
--- /dev/null
@@ -0,0 +1,52 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "Efreet_Mime.h"
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+int
+ef_mime_cb_get(void)
+{
+    const char *mime = NULL;
+    int misses = 0, i = 0;
+    struct
+    {
+        char *file;
+        char *mime;
+    } files[] = {
+        {PACKAGE_DATA_DIR"/test/test_type.desktop", "application/x-desktop"},
+        {PACKAGE_DATA_DIR"/test/entry.png", "image/png"},
+        {PACKAGE_DATA_DIR"/test/entry", "image/png"},
+        {PACKAGE_DATA_DIR"/test/sub", "inode/directory"},
+        {NULL, NULL}
+    };
+
+
+    if (!efreet_mime_init())
+    {
+        printf("Could not init efreet\n");
+        return 1;
+    }
+
+    for (i = 0; files[i].file != NULL; ++i)
+    {
+        mime = efreet_mime_type_get(files[i].file);
+        if (!mime)
+        {
+            printf("Got %s as null instead of %s\n", files[i].file, files[i].mime);
+            misses ++;
+        }
+        else if (strcmp(mime, files[i].mime))
+        {
+            printf("Got %s as %s instead of %s\n", files[i].file, mime, files[i].mime);
+            misses ++;
+        }
+    }
+
+    efreet_mime_shutdown();
+
+    return !misses;
+}
diff --git a/src/bin/ef_test.h b/src/bin/ef_test.h
new file mode 100644 (file)
index 0000000..0592711
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef EF_TEST
+#define EF_TEST
+
+#include "config.h"
+
+#if HAVE___ATTRIBUTE__
+#define __UNUSED__ __attribute__((unused))
+#else
+#define __UNUSED__
+#endif
+
+#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0);
+#define NEW(x, c) calloc(c, sizeof(x))
+
+#endif
diff --git a/src/bin/ef_utils.c b/src/bin/ef_utils.c
new file mode 100644 (file)
index 0000000..8377837
--- /dev/null
@@ -0,0 +1,26 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "efreet_private.h"
+#include <stdio.h>
+
+int
+ef_cb_utils(void)
+{
+    Efreet_Desktop *desktop;
+    const char *tmp2;
+
+    if (!efreet_util_init()) return 0;
+    printf("\n");
+
+    tmp2 = efreet_util_path_to_file_id("/usr/share/applications/this/tmp/test.desktop");
+    if (tmp2) printf("%s\n", tmp2);
+
+    desktop = efreet_util_desktop_file_id_find("kde-kresources.desktop");
+    printf("kde-kresources.desktop: %p\n", desktop);
+    desktop = efreet_util_desktop_file_id_find("mplayer.desktop");
+    printf("mplayer.desktop: %p\n", desktop);
+    desktop = efreet_util_desktop_file_id_find("nautilus-computer.desktop");
+    printf("nautilus-computer.desktop: %p\n", desktop);
+    efreet_util_shutdown();
+    return 1;
+}
diff --git a/src/bin/efreet_spec_test.c b/src/bin/efreet_spec_test.c
new file mode 100644 (file)
index 0000000..a5ef2a6
--- /dev/null
@@ -0,0 +1,58 @@
+#include <Efreet.h>
+#include <stdio.h>
+#include "ef_test.h"
+
+#define PATH_MAX 4096
+
+static void dump(Efreet_Menu *menu, const char *path);
+
+int
+main(int argc __UNUSED__, char **argv __UNUSED__)
+{
+    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_first_goto(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);
+        }
+    }
+}
diff --git a/src/bin/main.c b/src/bin/main.c
new file mode 100644 (file)
index 0000000..105a057
--- /dev/null
@@ -0,0 +1,176 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "Efreet_Mime.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_ini_long_line(void);
+int ef_cb_ini_garbage(void);
+#if DEFAULT_VISIBILITY
+int ef_cb_locale(void);
+#endif
+int ef_cb_desktop_parse(void);
+int ef_cb_desktop_save(void);
+int ef_cb_desktop_command_get(void);
+int ef_cb_desktop_type_parse(void);
+#if 0
+int ef_cb_desktop_file_id(void);
+#endif
+int ef_cb_menu_get(void);
+int ef_cb_menu_with_slashes(void);
+int ef_cb_menu_save(void);
+#if 0
+int ef_cb_menu_edit(void);
+#endif
+int ef_cb_utils(void);
+int ef_mime_cb_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},
+    {"INI Garbage Parsing", ef_cb_ini_garbage},
+#if DEFAULT_VISIBILITY
+    {"Locale Parsing", ef_cb_locale},
+#endif
+    {"Desktop Parsing", ef_cb_desktop_parse},
+    {"Desktop Type Parsing", ef_cb_desktop_type_parse},
+    {"Desktop Save", ef_cb_desktop_save},
+    {"Desktop Command", ef_cb_desktop_command_get},
+#if 0
+    {"Desktop File ID", ef_cb_desktop_file_id},
+#endif
+    {"Menu Parsing", ef_cb_menu_get},
+    {"Menu Incorrect Names", ef_cb_menu_with_slashes},
+    {"Menu Save", ef_cb_menu_save},
+#if 0
+    {"Menu Edit", ef_cb_menu_edit},
+#endif
+    {"Utils", ef_cb_utils},
+    {"Mime", ef_mime_cb_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_free_cb_set(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_first_goto(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++)
+        {
+            if ((!strcmp(argv[i], "-h")) ||
+                (!strcmp(argv[i], "--help")))
+            {
+                for (i = 0; tests[i].name != NULL; i++)
+                {
+                    printf("%s\n", tests[i].name);
+                }
+                return 1;
+            }
+            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;
+}
diff --git a/src/lib/.cvsignore b/src/lib/.cvsignore
new file mode 100644 (file)
index 0000000..09980ae
--- /dev/null
@@ -0,0 +1,6 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.lo
+*.la
diff --git a/src/lib/Efreet.h b/src/lib/Efreet.h
new file mode 100644 (file)
index 0000000..db13044
--- /dev/null
@@ -0,0 +1,70 @@
+/* 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
+ * @li FDO URI Specification
+ * @li Shared Mime Info Specification
+ * @li Trash Specification
+ */
+
+#ifdef EAPI
+#undef EAPI
+#endif
+#ifdef _MSC_VER
+# ifdef BUILDING_DLL
+#  define EAPI __declspec(dllexport)
+# else
+#  define EAPI __declspec(dllimport)
+# endif
+#else
+# ifdef __GNUC__
+#  if __GNUC__ >= 4
+#   define EAPI __attribute__ ((visibility("default")))
+#  else
+#   define EAPI
+#  endif
+# else
+#  define EAPI
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "efreet_base.h"
+#include "efreet_ini.h"
+#include "efreet_icon.h"
+#include "efreet_desktop.h"
+#include "efreet_menu.h"
+#include "efreet_utils.h"
+#include "efreet_uri.h"
+
+EAPI int efreet_init(void);
+EAPI int efreet_shutdown(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/Efreet_Mime.h b/src/lib/Efreet_Mime.h
new file mode 100644 (file)
index 0000000..229a604
--- /dev/null
@@ -0,0 +1,63 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#ifndef EFREET_MIME_H
+#define EFREET_MIME_H
+
+/**
+ * @file Efreet_Mime.h
+ * @brief The file that must be included by any project wishing to use
+ * @addtogroup Efreet_Mime Efreet_Mime: The XDG Shared Mime Info standard
+ * Efreet Mime is a library designed to help apps work with the
+ * Freedesktop.org Shared Mime Info standard.
+ * Efreet_Mime.h provides all of the necessary headers and
+ * includes to work with Efreet_Mime.
+ * @{
+ */
+
+
+#ifdef EAPI
+#undef EAPI
+#endif
+#ifdef _MSC_VER
+# ifdef BUILDING_DLL
+#  define EAPI __declspec(dllexport)
+# else
+#  define EAPI __declspec(dllimport)
+# endif
+#else
+# ifdef __GNUC__
+#  if __GNUC__ >= 4
+#   define EAPI __attribute__ ((visibility("default")))
+#  else
+#   define EAPI
+#  endif
+# else
+#  define EAPI
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+EAPI int         efreet_mime_init(void);
+EAPI void        efreet_mime_shutdown(void);
+
+EAPI const char *efreet_mime_type_get(const char *file);
+EAPI const char *efreet_mime_magic_type_get(const char *file);
+EAPI const char *efreet_mime_globs_type_get(const char *file);
+EAPI const char *efreet_mime_special_type_get(const char *file);
+EAPI const char *efreet_mime_fallback_type_get(const char *file);
+
+EAPI char *efreet_mime_type_icon_get(const char *mime, const char *theme,
+                                                          unsigned int size);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/Efreet_Trash.h b/src/lib/Efreet_Trash.h
new file mode 100644 (file)
index 0000000..febf70d
--- /dev/null
@@ -0,0 +1,56 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#ifndef EFREET_TRASH_H
+#define EFREET_TRASH_H
+
+#ifdef EAPI
+#undef EAPI
+#endif
+#ifdef _MSC_VER
+# ifdef BUILDING_DLL
+#  define EAPI __declspec(dllexport)
+# else
+#  define EAPI __declspec(dllimport)
+# endif
+#else
+# ifdef __GNUC__
+#  if __GNUC__ >= 4
+#   define EAPI __attribute__ ((visibility("default")))
+#  else
+#   define EAPI
+#  endif
+# else
+#  define EAPI
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file Efreet_Trash.h
+ * @brief Contains the methods used to support the FDO trash specification.
+ * @addtogroup Efreet_Trash Efreet_Trash: The XDG Trash Specification
+ * Efreet_Trash.h provides all of the necessary headers and includes to
+ * work with Efreet_Trash.
+ * @{
+ */
+
+EAPI int         efreet_trash_init(void);
+EAPI void        efreet_trash_shutdown(void);
+
+EAPI const char *efreet_trash_dir_get(void);
+EAPI int         efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete);
+EAPI Ecore_List *efreet_trash_ls(void);
+EAPI int         efreet_trash_is_empty(void);
+EAPI int         efreet_trash_empty_trash(void);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
new file mode 100644 (file)
index 0000000..c304b48
--- /dev/null
@@ -0,0 +1,67 @@
+
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I$(top_builddir) \
+-I$(top_srcdir) \
+@ECORE_CFLAGS@
+
+lib_LTLIBRARIES = libefreet.la libefreet_mime.la libefreet_trash.la
+
+EFREETHEADERS = \
+Efreet.h \
+efreet_base.h \
+efreet_desktop.h \
+efreet_icon.h \
+efreet_ini.h \
+efreet_menu.h \
+efreet_utils.h \
+efreet_uri.h
+
+EFREETSOURCES = \
+efreet.c \
+efreet_base.c \
+efreet_icon.c \
+efreet_xml.c \
+efreet_ini.c \
+efreet_desktop.c \
+efreet_menu.c \
+efreet_utils.c \
+efreet_uri.c \
+efreet_private.h \
+efreet_xml.h \
+$(EFREETHEADERS)
+
+libefreet_la_SOURCES = \
+       $(EFREETSOURCES)
+
+EFREETMIMEHEADERS = \
+Efreet_Mime.h
+
+EFREETMIMESOURCES = \
+efreet_mime.c \
+$(EFREETMIMEHEADERS)
+
+libefreet_mime_la_SOURCES = \
+$(EFREETMIMESOURCES)
+
+
+EFREETTRASHHEADERS = \
+Efreet_Trash.h
+
+EFREETTRASHSOURCES = \
+efreet_trash.c \
+$(EFREETTRASHHEADERS)
+
+libefreet_trash_la_SOURCES = \
+$(EFREETTRASHSOURCES)
+
+
+installed_headersdir = $(prefix)/include/efreet
+installed_headers_DATA = $(EFREETHEADERS) $(EFREETMIMEHEADERS) $(EFREETTRASHHEADERS)
+
+libefreet_la_LIBADD = @ECORE_LIBS@
+libefreet_la_LDFLAGS = -version-info @version_info@
+
+libefreet_mime_la_LIBADD = @ECORE_LIBS@ libefreet.la
+libefreet_trash_la_LIBADD = @ECORE_LIBS@ libefreet.la
diff --git a/src/lib/efreet.c b/src/lib/efreet.c
new file mode 100644 (file)
index 0000000..4edeca4
--- /dev/null
@@ -0,0 +1,189 @@
+/* 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
+ */
+EAPI 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
+ */
+EAPI 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;
+}
diff --git a/src/lib/efreet_base.c b/src/lib/efreet_base.c
new file mode 100644 (file)
index 0000000..1485081
--- /dev/null
@@ -0,0 +1,211 @@
+/* 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 efreet 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
+ */
+EAPI 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.
+ */
+EAPI 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
+ */
+EAPI 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.
+ */
+EAPI 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
+ */
+EAPI 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_free_cb_set(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;
+}
diff --git a/src/lib/efreet_base.h b/src/lib/efreet_base.h
new file mode 100644 (file)
index 0000000..021c89b
--- /dev/null
@@ -0,0 +1,30 @@
+/* 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>
+
+EAPI const char *efreet_data_home_get(void);
+EAPI Ecore_List *efreet_data_dirs_get(void);
+
+EAPI const char *efreet_config_home_get(void);
+EAPI Ecore_List *efreet_config_dirs_get(void);
+
+EAPI const char *efreet_cache_home_get(void);
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_desktop.c b/src/lib/efreet_desktop.c
new file mode 100644 (file)
index 0000000..19b493f
--- /dev/null
@@ -0,0 +1,1825 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "efreet_private.h"
+
+#define DESKTOP_VERSION 1.0
+
+/**
+ * The current desktop environment (e.g. "Enlightenment" or "Gnome")
+ */
+static const char *desktop_environment = NULL;
+
+/**
+ * A cache of all loaded desktops, hashed by file name.
+ * Values are Efreet_Desktop structures
+ */
+static Ecore_Hash *efreet_desktop_cache = NULL;
+
+/**
+ * A list of the desktop types available
+ */
+static Ecore_List *efreet_desktop_types = NULL;
+
+/**
+ * A unique id for each tmp file created while building a command
+ */
+static int efreet_desktop_command_file_id = 0;
+
+static int init = 0;
+static int cache_flush = 0;
+
+EAPI int EFREET_DESKTOP_TYPE_APPLICATION = 0;
+EAPI int EFREET_DESKTOP_TYPE_LINK = 0;
+EAPI int EFREET_DESKTOP_TYPE_DIRECTORY = 0;
+
+/**
+ * @internal
+ * Information about custom types
+ */
+typedef struct Efreet_Desktop_Type_Info Efreet_Desktop_Type_Info;
+struct Efreet_Desktop_Type_Info
+{
+    int id;
+    char *type;
+    Efreet_Desktop_Type_Parse_Cb parse_func;
+    Efreet_Desktop_Type_Save_Cb save_func;
+    Efreet_Desktop_Type_Free_Cb free_func;
+};
+
+static int efreet_desktop_read(Efreet_Desktop *desktop);
+static void efreet_desktop_clear(Efreet_Desktop *desktop);
+static Efreet_Desktop_Type_Info *efreet_desktop_type_parse(const char *type_str);
+static void *efreet_desktop_application_fields_parse(Efreet_Desktop *desktop,
+                                                    Efreet_Ini *ini);
+static void efreet_desktop_application_fields_save(Efreet_Desktop *desktop,
+                                                    Efreet_Ini *ini);
+static void *efreet_desktop_link_fields_parse(Efreet_Desktop *desktop,
+                                                Efreet_Ini *ini);
+static void efreet_desktop_link_fields_save(Efreet_Desktop *desktop,
+                                                Efreet_Ini *ini);
+static int efreet_desktop_generic_fields_parse(Efreet_Desktop *desktop,
+                                                Efreet_Ini *ini);
+static void efreet_desktop_generic_fields_save(Efreet_Desktop *desktop,
+                                                Efreet_Ini *ini);
+static void efreet_desktop_x_fields_parse(Ecore_Hash_Node *node,
+                                            Efreet_Desktop *desktop);
+static void efreet_desktop_x_fields_save(Ecore_Hash_Node *node,
+                                            Efreet_Ini *ini);
+static int efreet_desktop_environment_check(Efreet_Ini *ini);
+static char *efreet_string_append(char *dest, int *size,
+                                    int *len, const char *src);
+static char *efreet_string_append_char(char *dest, int *size,
+                                        int *len, char c);
+static Ecore_List *efreet_desktop_command_build(Efreet_Desktop_Command *command);
+static void efreet_desktop_command_free(Efreet_Desktop_Command *command);
+static char *efreet_desktop_command_append_quoted(char *dest, int *size,
+                                                    int *len, char *src);
+static char *efreet_desktop_command_append_icon(char *dest, int *size, int *len,
+                                                Efreet_Desktop *desktop);
+static char *efreet_desktop_command_append_single(char *dest, int *size, int *len,
+                                                Efreet_Desktop_Command_File *file,
+                                                char type);
+static char *efreet_desktop_command_append_multiple(char *dest, int *size, int *len,
+                                                    Efreet_Desktop_Command *command,
+                                                    char type);
+
+static char *efreet_desktop_command_path_absolute(const char *path);
+static Efreet_Desktop_Command_File *efreet_desktop_command_file_process(
+                                                    Efreet_Desktop_Command *command,
+                                                    const char *file);
+static const char *efreet_desktop_command_file_uri_process(const char *uri);
+static void efreet_desktop_command_file_free(Efreet_Desktop_Command_File *file);
+
+static void efreet_desktop_cb_download_complete(void *data, const char *file,
+                                                                int status);
+static int efreet_desktop_cb_download_progress(void *data, const char *file,
+                                           long int dltotal, long int dlnow,
+                                           long int ultotal, long int ulnow);
+
+
+static void *efreet_desktop_exec_cb(void *data, Efreet_Desktop *desktop,
+                                            char *exec, int remaining);
+
+static void efreet_desktop_type_info_free(Efreet_Desktop_Type_Info *info);
+static int efreet_desktop_command_flags_get(Efreet_Desktop *desktop);
+static void *efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Ecore_List *execs);
+
+/**
+ * @internal
+ * @return Returns > 0 on success or 0 on failure
+ * @brief Initialize the Desktop parser subsystem
+ */
+int
+efreet_desktop_init(void)
+{
+    if (init++) return init;
+    if (!ecore_string_init()) return --init;
+    if (!ecore_file_init()) return --init;
+
+    efreet_desktop_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(efreet_desktop_cache, ECORE_FREE_CB(free));
+
+    efreet_desktop_types = ecore_list_new();
+    ecore_list_free_cb_set(efreet_desktop_types,
+                            ECORE_FREE_CB(efreet_desktop_type_info_free));
+
+    EFREET_DESKTOP_TYPE_APPLICATION = efreet_desktop_type_add("Application",
+                                        efreet_desktop_application_fields_parse,
+                                        efreet_desktop_application_fields_save,
+                                        NULL);
+    EFREET_DESKTOP_TYPE_LINK = efreet_desktop_type_add("Link",
+                                    efreet_desktop_link_fields_parse,
+                                    efreet_desktop_link_fields_save, NULL);
+    EFREET_DESKTOP_TYPE_DIRECTORY = efreet_desktop_type_add("Directory", NULL,
+                                                                NULL, NULL);
+
+    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_desktop_shutdown(void)
+{
+    if (--init) return init;
+    ecore_file_shutdown();
+    ecore_string_shutdown();
+
+    IF_RELEASE(desktop_environment);
+    IF_FREE_HASH(efreet_desktop_cache);
+    IF_FREE_LIST(efreet_desktop_types);
+
+    return init;
+}
+
+/**
+ * @internal
+ * @param desktop: The desktop to check
+ * @return Returns 1 if the cache is still valid, 0 otherwise
+ * @brief This will check if the desktop cache is still valid.
+ */
+static int
+efreet_desktop_cache_check(Efreet_Desktop *desktop)
+{
+    if (!desktop) return 0;
+
+    /* have we modified this file since we last read it in? */
+    if ((desktop->cache_flush != cache_flush) ||
+        (ecore_file_mod_time(desktop->orig_path) != desktop->load_time))
+     return 0;
+
+    return 1;
+}
+
+/**
+ * @param file: The file to get the Efreet_Desktop from
+ * @return Returns a reference to a cached Efreet_Desktop on success, NULL
+ * on failure. This reference should not be freed.
+ * @brief Gets a reference to an Efreet_Desktop structure representing the
+ * contents of @a file or NULL if @a file is not a valid .desktop file.
+ */
+EAPI Efreet_Desktop *
+efreet_desktop_get(const char *file)
+{
+    Efreet_Desktop *desktop;
+
+    if (efreet_desktop_cache)
+    {
+        desktop = ecore_hash_get(efreet_desktop_cache, file);
+        if (desktop)
+        {
+            if (efreet_desktop_cache_check(desktop))
+            {
+                desktop->ref++;
+                return desktop;
+            }
+
+            efreet_desktop_clear(desktop);
+            if (efreet_desktop_read(desktop))
+            {
+                desktop->ref++;
+                desktop->cache_flush = cache_flush;
+                return desktop;
+            }
+
+            desktop->cached = 0;
+            ecore_hash_remove(efreet_desktop_cache, file);
+        }
+    }
+
+    desktop = efreet_desktop_new(file);
+    if (!desktop) return NULL;
+
+    ecore_hash_set(efreet_desktop_cache, strdup(file), desktop);
+    desktop->cached = 1;
+    return desktop;
+}
+
+/**
+ * @param desktop: The Efreet_Desktop to ref
+ * @return Returns the new reference count
+ */
+EAPI int
+efreet_desktop_ref(Efreet_Desktop *desktop)
+{
+    if (!desktop) return 0;
+    desktop->ref++;
+    return desktop->ref;
+}
+
+/**
+ * @param file: The file to create the Efreet_Desktop from
+ * @return Returns a new empty_Efreet_Desktop on success, NULL on failure
+ * @brief Creates a new empty Efreet_Desktop structure or NULL on failure
+ */
+EAPI Efreet_Desktop *
+efreet_desktop_empty_new(const char *file)
+{
+    Efreet_Desktop *desktop;
+
+    desktop = NEW(Efreet_Desktop, 1);
+    if (!desktop) return NULL;
+
+    desktop->orig_path = strdup(file);
+    desktop->load_time = ecore_file_mod_time(file);
+
+    desktop->ref = 1;
+
+    return desktop;
+}
+
+/**
+ * @internal
+ * @param file: The file to create the Efreet_Desktop from
+ * @return Returns a new Efreet_Desktop on success, NULL on failure
+ * @brief Creates a new Efreet_Desktop structure initialized from the
+ * contents of @a file or NULL on failure
+ */
+EAPI Efreet_Desktop *
+efreet_desktop_new(const char *file)
+{
+    Efreet_Desktop *desktop;
+
+    if (!ecore_file_exists(file)) return NULL;
+
+    desktop = NEW(Efreet_Desktop, 1);
+    if (!desktop) return NULL;
+
+    desktop->orig_path = strdup(file);
+
+    if (!efreet_desktop_read(desktop))
+    {
+        efreet_desktop_free(desktop);
+        return NULL;
+    }
+
+    desktop->ref = 1;
+    desktop->cache_flush = cache_flush;
+
+    return desktop;
+}
+
+/**
+ * @internal
+ * @param desktop: The desktop to fill
+ * @return Returns 1 on success, 0 on failure
+ * @brief initialize an Efreet_Desktop from the contents of @a file
+ */
+static int
+efreet_desktop_read(Efreet_Desktop *desktop)
+{
+    Efreet_Ini *ini;
+    int error = 0;
+    int ok;
+
+    ini = efreet_ini_new(desktop->orig_path);
+    if (!ini->data)
+    {
+        efreet_ini_free(ini);
+        return 0;
+    }
+
+    ok = efreet_ini_section_set(ini, "Desktop Entry");
+    if (!ok) ok = efreet_ini_section_set(ini, "KDE Desktop Entry");
+    if (!ok)
+    {
+        printf("efreet_desktop_new error: no Desktop Entry section\n");
+        error = 1;
+    }
+
+    if (!error)
+    {
+        Efreet_Desktop_Type_Info *info;
+
+        info = efreet_desktop_type_parse(efreet_ini_string_get(ini, "Type"));
+        if (info)
+        {
+            desktop->type = info->id;
+            desktop->version = efreet_ini_double_get(ini, "Version");
+
+            if (info->parse_func)
+                desktop->type_data = info->parse_func(desktop, ini);
+        }
+        else
+            error = 1;
+    }
+
+    if (!error && !efreet_desktop_environment_check(ini)) error = 1;
+    if (!error && !efreet_desktop_generic_fields_parse(desktop, ini)) error = 1;
+    if (!error)
+        ecore_hash_for_each_node(ini->section,
+                ECORE_FOR_EACH(efreet_desktop_x_fields_parse), desktop);
+
+    efreet_ini_free(ini);
+
+    desktop->load_time = ecore_file_mod_time(desktop->orig_path);
+
+    if (error) return 0;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param desktop: The Efreet_Desktop to work with
+ * @return Returns no value
+ * @brief Frees the Efreet_Desktop's data
+ */
+static void
+efreet_desktop_clear(Efreet_Desktop *desktop)
+{
+    IF_FREE(desktop->name);
+    IF_FREE(desktop->generic_name);
+    IF_FREE(desktop->comment);
+    IF_FREE(desktop->icon);
+    IF_FREE(desktop->url);
+
+    IF_FREE(desktop->try_exec);
+    IF_FREE(desktop->exec);
+    IF_FREE(desktop->path);
+    IF_FREE(desktop->startup_wm_class);
+
+    IF_FREE_LIST(desktop->only_show_in);
+    IF_FREE_LIST(desktop->not_show_in);
+    IF_FREE_LIST(desktop->categories);
+    IF_FREE_LIST(desktop->mime_types);
+
+    IF_FREE_HASH(desktop->x);
+
+    if (desktop->type_data)
+    {
+        Efreet_Desktop_Type_Info *info;
+        info = ecore_list_index_goto(efreet_desktop_types, desktop->type);
+        if (info->free_func)
+            info->free_func(desktop->type_data);
+    }
+}
+
+/**
+ * @param desktop: The desktop file to save
+ * @return Returns 1 on success or 0 on failure
+ * @brief Saves any changes made to @a desktop back to the file on the
+ * filesystem
+ */
+EAPI int
+efreet_desktop_save(Efreet_Desktop *desktop)
+{
+    Efreet_Desktop_Type_Info *info;
+    Efreet_Ini *ini;
+    int ok = 1;
+
+    ini = efreet_ini_new(desktop->orig_path);
+    efreet_ini_section_add(ini, "Desktop Entry");
+    efreet_ini_section_set(ini, "Desktop Entry");
+
+    info = ecore_list_index_goto(efreet_desktop_types, desktop->type);
+    if (info)
+    {
+        efreet_ini_string_set(ini, "Type", info->type);
+        if (info->save_func) info->save_func(desktop, ini);
+    }
+    else
+        ok = 0;
+
+    if (ok)
+    {
+        char *val;
+
+        if (desktop->only_show_in)
+        {
+            val = efreet_desktop_string_list_join(desktop->only_show_in);
+            efreet_ini_string_set(ini, "OnlyShowIn", val);
+            FREE(val);
+        }
+        if (desktop->not_show_in)
+        {
+            val = efreet_desktop_string_list_join(desktop->not_show_in);
+            efreet_ini_string_set(ini, "NotShowIn", val);
+            FREE(val);
+        }
+        efreet_desktop_generic_fields_save(desktop, ini);
+        /* When we save the file, it should be updated to the
+         * latest version that we support! */
+        efreet_ini_double_set(ini, "Version", DESKTOP_VERSION);
+
+        if (!efreet_ini_save(ini, desktop->orig_path)) ok = 0;
+        else
+        {
+            if (desktop != ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
+            {
+                desktop->cached = 1;
+                ecore_hash_set(efreet_desktop_cache,
+                                strdup(desktop->orig_path), desktop);
+            }
+        }
+    }
+    efreet_ini_free(ini);
+    return ok;
+}
+
+/**
+ * @param desktop: The desktop file to save
+ * @param file: The filename to save as
+ * @return Returns 1 on success or 0 on failure
+ * @brief Saves @a desktop to @a file
+ */
+EAPI int
+efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file)
+{
+    if (desktop == ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
+    {
+        desktop->cached = 0;
+        ecore_hash_remove(efreet_desktop_cache, desktop->orig_path);
+    }
+    FREE(desktop->orig_path);
+    desktop->orig_path = strdup(file);
+    return efreet_desktop_save(desktop);
+}
+
+/**
+ * @internal
+ * @param desktop: The Efreet_Desktop to work with
+ * @return Returns no value
+ * @brief Frees the Efreet_Desktop structure and all of it's data
+ */
+EAPI void
+efreet_desktop_free(Efreet_Desktop *desktop)
+{
+    if (!desktop) return;
+
+    desktop->ref--;
+    if (desktop->ref > 0) return;
+
+    if (desktop->cached && efreet_desktop_cache)
+        ecore_hash_remove(efreet_desktop_cache, desktop->orig_path);
+
+    IF_FREE(desktop->orig_path);
+
+    IF_FREE(desktop->name);
+    IF_FREE(desktop->generic_name);
+    IF_FREE(desktop->comment);
+    IF_FREE(desktop->icon);
+    IF_FREE(desktop->url);
+
+    IF_FREE(desktop->try_exec);
+    IF_FREE(desktop->exec);
+    IF_FREE(desktop->path);
+    IF_FREE(desktop->startup_wm_class);
+
+    IF_FREE_LIST(desktop->only_show_in);
+    IF_FREE_LIST(desktop->not_show_in);
+    IF_FREE_LIST(desktop->categories);
+    IF_FREE_LIST(desktop->mime_types);
+
+    IF_FREE_HASH(desktop->x);
+
+    if (desktop->type_data)
+    {
+        Efreet_Desktop_Type_Info *info;
+        info = ecore_list_index_goto(efreet_desktop_types, desktop->type);
+        if (info->free_func)
+            info->free_func(desktop->type_data);
+    }
+
+    FREE(desktop);
+}
+
+/**
+ * @param desktop: The desktop file to work with
+ * @param files: The files to be substituted into the exec line
+ * @param data: The data pointer to pass
+ * @return Returns the Ecore_Exce for @a desktop
+ * @brief Parses the @a desktop exec line and returns an Ecore_Exe.
+ */
+EAPI void
+efreet_desktop_exec(Efreet_Desktop *desktop, Ecore_List *files, void *data)
+{
+    efreet_desktop_command_get(desktop, files, efreet_desktop_exec_cb, data);
+}
+
+static void *
+efreet_desktop_exec_cb(void *data, Efreet_Desktop *desktop __UNUSED__,
+                                char *exec, int remaining __UNUSED__)
+{
+    ecore_exe_run(exec, data);
+    free(exec);
+    return NULL;
+}
+
+/**
+ * @param environment: the environment name
+ * @brief sets the global desktop environment name
+ */
+EAPI void
+efreet_desktop_environment_set(const char *environment)
+{
+    if (desktop_environment) ecore_string_release(desktop_environment);
+    if (environment) desktop_environment = ecore_string_instance(environment);
+    else desktop_environment = NULL;
+}
+
+/**
+ * @return environment: the environment name
+ * @brief sets the global desktop environment name
+ */
+EAPI const char *
+efreet_desktop_environment_get(void)
+{
+    return desktop_environment;
+}
+
+/**
+ * @param desktop: The desktop to work with
+ * @return Returns the number of categories assigned to this desktop
+ * @brief Retrieves the number of categories the given @a desktop belongs
+ * too
+ */
+EAPI unsigned int
+efreet_desktop_category_count_get(Efreet_Desktop *desktop)
+{
+    if (!desktop || !desktop->categories) return 0;
+    return ecore_list_count(desktop->categories);
+}
+
+/**
+ * @param desktop: the desktop
+ * @param category: the category name
+ * @brief add a category to a desktop
+ */
+EAPI void
+efreet_desktop_category_add(Efreet_Desktop *desktop, const char *category)
+{
+    if (!desktop) return;
+
+    if (!desktop->categories)
+    {
+        desktop->categories = ecore_list_new();
+        ecore_list_free_cb_set(desktop->categories,
+                                ECORE_FREE_CB(ecore_string_release));
+    }
+    else
+        if (ecore_list_find(desktop->categories,
+                                ECORE_COMPARE_CB(strcmp), category)) return;
+
+    ecore_list_append(desktop->categories,
+                        (void *)ecore_string_instance(category));
+}
+
+/**
+ * @param desktop: the desktop
+ * @param category: the category name
+ * @brief removes a category from a desktop
+ * @return 1 if the desktop had his category listed, 0 otherwise
+ */
+EAPI int
+efreet_desktop_category_del(Efreet_Desktop *desktop, const char *category)
+{
+    int found = 0;
+    if (!desktop || !desktop->categories) return 0;
+
+    if (ecore_list_find(desktop->categories,
+                            ECORE_COMPARE_CB(strcmp), category))
+    {
+        found = 1;
+        ecore_list_remove(desktop->categories);
+    }
+
+    return found;
+}
+
+/**
+ * @param type: The type to add to the list of matching types
+ * @param parse_func: a function to parse out custom fields
+ * @param save_func: a function to save data returned from @a parse_func
+ * @param free_func: a function to free data returned from @a parse_func
+ * @return Returns the id of the new type
+ * @brief Adds the given type to the list of types in the system
+ */
+EAPI int
+efreet_desktop_type_add(const char *type, Efreet_Desktop_Type_Parse_Cb parse_func,
+                        Efreet_Desktop_Type_Save_Cb save_func,
+                        Efreet_Desktop_Type_Free_Cb free_func)
+{
+    int id;
+    Efreet_Desktop_Type_Info *info;
+
+    info = NEW(Efreet_Desktop_Type_Info, 1);
+    if (!info) return 0;
+
+    id = ecore_list_count(efreet_desktop_types);
+
+    info->id = id;
+    info->type = strdup(type);
+    info->parse_func = parse_func;
+    info->save_func = save_func;
+    info->free_func = free_func;
+
+    ecore_list_append(efreet_desktop_types, info);
+
+    return id;
+}
+
+/**
+ * @brief Add an alias for an existing desktop type.
+ * @param from_type the type to alias (e.g. EFREE_DESKTOP_TYPE_APPLICATION)
+ * @param alias the alias
+ * @return the new type id, or -1 if @p from_type was not valid
+ *
+ * This allows applications to add non-standard types that behave exactly as standard types.
+ */
+EAPI int
+efreet_desktop_type_alias(int from_type, const char *alias)
+{
+    Efreet_Desktop_Type_Info *info;
+    info = ecore_list_index_goto(efreet_desktop_types, from_type);
+    if (!info) return -1;
+
+    return efreet_desktop_type_add(alias, info->parse_func, info->save_func, info->free_func);
+}
+
+/**
+ * @internal
+ * @brief Free an Efreet Desktop_Type_Info struct
+ */
+static void
+efreet_desktop_type_info_free(Efreet_Desktop_Type_Info *info)
+{
+    if (!info) return;
+    IF_FREE(info->type);
+    free(info);
+}
+
+/**
+ * @brief get type specific data for custom desktop types
+ * @param desktop the desktop
+ * @return type specific data, or NULL if there is none
+ */
+EAPI void *
+efreet_desktop_type_data_get(Efreet_Desktop *desktop)
+{
+    return desktop->type_data;
+}
+
+/**
+ * @internal
+ * @param type_str: the type as a string
+ * @return the parsed type
+ * @brief parse the type string into an Efreet_Desktop_Type
+ */
+static Efreet_Desktop_Type_Info *
+efreet_desktop_type_parse(const char *type_str)
+{
+    Efreet_Desktop_Type_Info *info;
+
+    if (!type_str) return NULL;
+
+    ecore_list_first_goto(efreet_desktop_types);
+    while ((info = ecore_list_next(efreet_desktop_types)))
+    {
+        if (!strcmp(info->type, type_str))
+            return info;
+    }
+
+    return NULL;
+}
+
+/**
+ * @param string: the raw string list
+ * @return an Ecore_List of ecore string's
+ * @brief Parse ';' separate list of strings according to the desktop spec
+ */
+EAPI Ecore_List *
+efreet_desktop_string_list_parse(const char *string)
+{
+    Ecore_List *list;
+    char *tmp;
+    char *s, *p;
+
+    if (!string) return NULL;
+
+    list = ecore_list_new();
+    if (!list) return NULL;
+
+    ecore_list_free_cb_set(list, ECORE_FREE_CB(ecore_string_release));
+
+    tmp = strdup(string);
+    s = tmp;
+
+    while ((p = strchr(s, ';')))
+    {
+        if (p > tmp && *(p-1) == '\\') continue;
+        *p = '\0';
+        ecore_list_append(list, (void *)ecore_string_instance(s));
+        s = p + 1;
+    }
+    /* If this is true, the .desktop file does not follow the standard */
+    if (*s)
+    {
+#ifdef STRICT_SPEC
+        printf("[Efreet]: Found a string list without ';' "
+                "at the end: %s\n", string);
+#endif
+        ecore_list_append(list, (void *)ecore_string_instance(s));
+    }
+
+    free(tmp);
+
+    return list;
+}
+
+/**
+ * @param list: Ecore_List with strings
+ * @return a raw string list
+ * @brief Create a ';' separate list of strings according to the desktop spec
+ */
+EAPI char *
+efreet_desktop_string_list_join(Ecore_List *list)
+{
+    const char *tmp;
+    char *string;
+    size_t size, pos, len;
+
+    if (ecore_list_empty_is(list)) return strdup("");
+
+    size = 1024;
+    string = malloc(size);
+    pos = 0;
+
+    ecore_list_first_goto(list);
+    while ((tmp = ecore_list_next(list)))
+    {
+        len = strlen(tmp);
+        /* +1 for ';' */
+        if ((len + pos + 1) >= size)
+        {
+            size = len + pos + 1024;
+            string = realloc(string, size);
+        }
+        strcpy(string + pos, tmp);
+        pos += len;
+        strcpy(string + pos, ";");
+        pos += 1;
+    }
+    return string;
+}
+
+/**
+ * @brief Tell Efreet to flush any cached desktop entries so it reloads on get.
+ *
+ * This flags the cache to be invalid, so next time a desktop file is fetched
+ * it will force it to be re-read off disk next time efreet_desktop_get() is
+ * called.
+ */
+EAPI void
+efreet_desktop_cache_flush(void)
+{
+    cache_flush++;
+}
+
+/**
+ * @internal
+ * @param desktop: the Efreet_Desktop to store parsed fields in
+ * @param ini: the Efreet_Ini to parse fields from
+ * @return No value
+ * @brief Parse application specific desktop fields
+ */
+static void *
+efreet_desktop_application_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
+{
+    const char *val;
+
+    val = efreet_ini_string_get(ini, "TryExec");
+    if (val) desktop->try_exec = strdup(val);
+
+    val = efreet_ini_string_get(ini, "Exec");
+    if (val) desktop->exec = strdup(val);
+
+    val = efreet_ini_string_get(ini, "Path");
+    if (val) desktop->path = strdup(val);
+
+    val = efreet_ini_string_get(ini, "StartupWMClass");
+    if (val) desktop->startup_wm_class = strdup(val);
+
+    desktop->categories = efreet_desktop_string_list_parse(
+                                efreet_ini_string_get(ini, "Categories"));
+    desktop->mime_types = efreet_desktop_string_list_parse(
+                                efreet_ini_string_get(ini, "MimeType"));
+
+    desktop->terminal = efreet_ini_boolean_get(ini, "Terminal");
+    desktop->startup_notify = efreet_ini_boolean_get(ini, "StartupNotify");
+
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param desktop: the Efreet_Desktop to save fields from
+ * @param ini: the Efreet_Ini to save fields to
+ * @return Returns no value
+ * @brief Save application specific desktop fields
+ */
+static void
+efreet_desktop_application_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
+{
+    char *val;
+
+    if (desktop->try_exec)
+        efreet_ini_string_set(ini, "TryExec", desktop->try_exec);
+
+    if (desktop->exec)
+        efreet_ini_string_set(ini, "Exec", desktop->exec);
+
+    if (desktop->path)
+        efreet_ini_string_set(ini, "Path", desktop->path);
+
+    if (desktop->startup_wm_class)
+        efreet_ini_string_set(ini, "StartupWMClass", desktop->startup_wm_class);
+
+    if (desktop->categories)
+    {
+        val = efreet_desktop_string_list_join(desktop->categories);
+        efreet_ini_string_set(ini, "Categories", val);
+        FREE(val);
+    }
+
+    if (desktop->mime_types)
+    {
+        val = efreet_desktop_string_list_join(desktop->mime_types);
+        efreet_ini_string_set(ini, "MimeType", val);
+        FREE(val);
+    }
+
+    efreet_ini_boolean_set(ini, "Terminal", desktop->terminal);
+    efreet_ini_boolean_set(ini, "StartupNotify", desktop->startup_notify);
+}
+
+/**
+ * @internal
+ * @param desktop: the Efreet_Desktop to store parsed fields in
+ * @param ini: the Efreet_Ini to parse fields from
+ * @return Returns no value
+ * @brief Parse link specific desktop fields
+ */
+static void *
+efreet_desktop_link_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
+{
+    const char *val;
+
+    val = efreet_ini_string_get(ini, "URL");
+    if (val) desktop->url = strdup(val);
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param desktop: the Efreet_Desktop to save fields from
+ * @param ini: the Efreet_Ini to save fields in
+ * @return Returns no value
+ * @brief Save link specific desktop fields
+ */
+static void
+efreet_desktop_link_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
+{
+    if (desktop->url) efreet_ini_string_set(ini, "URL", desktop->url);
+}
+
+/**
+ * @internal
+ * @param desktop: the Efreet_Desktop to store parsed fields in
+ * @param ini: the Efreet_Ini to parse fields from
+ * @return 1 if parsed succesfully, 0 otherwise
+ * @brief Parse desktop fields that all types can include
+ */
+static int
+efreet_desktop_generic_fields_parse(Efreet_Desktop *desktop, Efreet_Ini *ini)
+{
+    const char *val;
+
+    val = efreet_ini_localestring_get(ini, "Name");
+    if (val) desktop->name = strdup(val);
+    else
+    {
+        printf("efreet_desktop_generic_fields_parse error: no Name\n");
+        return 0;
+    }
+
+    val = efreet_ini_localestring_get(ini, "GenericName");
+    if (val) desktop->generic_name = strdup(val);
+
+    val = efreet_ini_localestring_get(ini, "Comment");
+    if (val) desktop->comment = strdup(val);
+
+    val = efreet_ini_localestring_get(ini, "Icon");
+    if (val) desktop->icon = strdup(val);
+
+    desktop->no_display = efreet_ini_boolean_get(ini, "NoDisplay");
+    desktop->hidden = efreet_ini_boolean_get(ini, "Hidden");
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param desktop: the Efreet_Desktop to save fields from
+ * @param ini: the Efreet_Ini to save fields to
+ * @return Returns nothing
+ * @brief Save desktop fields that all types can include
+ */
+static void
+efreet_desktop_generic_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
+{
+    const char *val;
+
+    if (desktop->name)
+    {
+        efreet_ini_localestring_set(ini, "Name", desktop->name);
+        val = efreet_ini_string_get(ini, "Name");
+        if (!val)
+            efreet_ini_string_set(ini, "Name", desktop->name);
+    }
+    if (desktop->generic_name)
+    {
+        efreet_ini_localestring_set(ini, "GenericName", desktop->generic_name);
+        val = efreet_ini_string_get(ini, "GenericName");
+        if (!val)
+            efreet_ini_string_set(ini, "GenericName", desktop->generic_name);
+    }
+    if (desktop->comment)
+    {
+        efreet_ini_localestring_set(ini, "Comment", desktop->comment);
+        val = efreet_ini_string_get(ini, "Comment");
+        if (!val)
+            efreet_ini_string_set(ini, "Comment", desktop->comment);
+    }
+    if (desktop->icon)
+    {
+        efreet_ini_localestring_set(ini, "Icon", desktop->icon);
+        val = efreet_ini_string_get(ini, "Icon");
+        if (!val)
+            efreet_ini_string_set(ini, "Icon", desktop->icon);
+    }
+
+    efreet_ini_boolean_set(ini, "NoDisplay", desktop->no_display);
+    efreet_ini_boolean_set(ini, "Hidden", desktop->hidden);
+
+    if (desktop->x) ecore_hash_for_each_node(desktop->x,
+                                             ECORE_FOR_EACH(efreet_desktop_x_fields_save),
+                                             ini);
+}
+
+/**
+ * @internal
+ * @param node: The node to work with
+ * @param desktop: The desktop file to work with
+ * @return Returns no value
+ * @brief Parses out an X- key from @a node and stores in @a desktop
+ */
+static void
+efreet_desktop_x_fields_parse(Ecore_Hash_Node *node, Efreet_Desktop *desktop)
+{
+    if (strncmp(node->key, "X-", 2)) return;
+
+    if (!desktop->x)
+    {
+        desktop->x = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+        ecore_hash_free_key_cb_set(desktop->x,
+                            ECORE_FREE_CB(ecore_string_release));
+        ecore_hash_free_value_cb_set(desktop->x,
+                            ECORE_FREE_CB(ecore_string_release));
+    }
+    ecore_hash_set(desktop->x, (void *)ecore_string_instance(node->key),
+            (void *)ecore_string_instance(node->value));
+}
+
+/**
+ * @internal
+ * @param node: The node to work with
+ * @param ini: The ini file to work with
+ * @return Returns no value
+ * @brief Stores an X- key from @a node and stores in @a ini
+ */
+static void
+efreet_desktop_x_fields_save(Ecore_Hash_Node *node, Efreet_Ini *ini)
+{
+    efreet_ini_string_set(ini, node->key, node->value);
+}
+
+
+/**
+ * @internal
+ * @param ini: The Efreet_Ini to parse values from
+ * @return 1 if desktop should be included in current environement, 0 otherwise
+ * @brief Determines if a desktop should be included in the current environment,
+ * based on the values of the OnlyShowIn and NotShowIn fields
+ */
+static int
+efreet_desktop_environment_check(Efreet_Ini *ini)
+{
+    Ecore_List *list;
+    const char *val;
+
+    list = efreet_desktop_string_list_parse(efreet_ini_string_get(ini, "OnlyShowIn"));
+    if (list)
+    {
+        int found = 0;
+
+        if (desktop_environment)
+        {
+            ecore_list_first_goto(list);
+            while ((val = ecore_list_next(list)))
+            {
+                if (!strcmp(val, desktop_environment))
+                {
+                    found = 1;
+                    break;
+                }
+            }
+        }
+
+        ecore_list_destroy(list);
+        return found;
+    }
+
+    if (desktop_environment)
+    {
+        int found = 0;
+
+        list = efreet_desktop_string_list_parse(efreet_ini_string_get(ini, "NotShowIn"));
+        if (list)
+        {
+            ecore_list_first_goto(list);
+            while ((val = ecore_list_next(list)))
+            {
+                if (!strcmp(val, desktop_environment))
+                {
+                    found = 1;
+                    break;
+                }
+            }
+            ecore_list_destroy(list);
+        }
+
+        return !found;
+    }
+
+    return 1;
+}
+
+
+/**
+ * @param desktop: the desktop entry
+ * @param files: an ecore list of file names to execute, as either absolute paths,
+ * relative paths, or uris
+ * @param func: a callback to call for each prepared command line
+ * @param data: user data passed to the callback
+ * @return Returns the return value of @p func on success or NULL on failure
+ * @brief Get a command to use to execute a desktop entry.
+ */
+EAPI void *
+efreet_desktop_command_get(Efreet_Desktop *desktop, Ecore_List *files,
+                            Efreet_Desktop_Command_Cb func, void *data)
+{
+    return efreet_desktop_command_progress_get(desktop, files, func, NULL, data);
+}
+
+/**
+ * @param desktop: the desktop entry
+ * @param files an ecore list of local files, as absolute paths, local paths, or file:// uris (or NULL to get exec string with no files appended)
+ * @return Returns an ecore list of exec strings
+ * @brief Get the command to use to execute a desktop entry
+ *
+ * The returned list and each of its elements must be freed.
+ */
+EAPI Ecore_List *
+efreet_desktop_command_local_get(Efreet_Desktop *desktop, Ecore_List *files)
+{
+    Efreet_Desktop_Command *command;
+    char *file;
+    Ecore_List *execs;
+
+    if (!desktop || !desktop->exec) return NULL;
+
+    command = NEW(Efreet_Desktop_Command, 1);
+    if (!command) return 0;
+
+    command->files = ecore_list_new();
+    command->desktop = desktop;
+
+    ecore_list_free_cb_set(command->files,
+                            ECORE_FREE_CB(efreet_desktop_command_file_free));
+
+    command->flags = efreet_desktop_command_flags_get(desktop);
+    /* get the required info for each file passed in */
+    if (files)
+    {
+        ecore_list_first_goto(files);
+        while ((file = ecore_list_next(files)))
+        {
+            Efreet_Desktop_Command_File *dcf;
+
+            dcf = efreet_desktop_command_file_process(command, file);
+            if (!dcf) continue;
+            if (dcf->pending)
+            {
+                efreet_desktop_command_file_free(dcf);
+                continue;
+            }
+            ecore_list_append(command->files, dcf);
+        }
+    }
+
+    execs = efreet_desktop_command_build(command);
+    efreet_desktop_command_free(command);
+
+    return execs;
+}
+
+
+/**
+ * @param desktop: the desktop entry
+ * @param files: an ecore list of file names to execute, as either absolute paths,
+ * relative paths, or uris
+ * @param cb_command: a callback to call for each prepared command line
+ * @param cb_progress: a callback to get progress for the downloads
+ * @param data: user data passed to the callback
+ * @return Returns 1 on success or 0 on failure
+ * @brief Get a command to use to execute a desktop entry, and receive progress
+ * updates for downloading of remote URI's passed in.
+ */
+EAPI void *
+efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Ecore_List *files,
+                                    Efreet_Desktop_Command_Cb cb_command,
+                                    Efreet_Desktop_Progress_Cb cb_progress,
+                                    void *data)
+{
+    Efreet_Desktop_Command *command;
+    char *file;
+    void *ret = NULL;
+
+    if (!desktop || !cb_command || !desktop->exec) return NULL;
+
+    command = NEW(Efreet_Desktop_Command, 1);
+    if (!command) return NULL;
+
+    command->cb_command = cb_command;
+    command->cb_progress = cb_progress;
+    command->data = data;
+    command->files = ecore_list_new();
+    command->desktop = desktop;
+
+    ecore_list_free_cb_set(command->files,
+                            ECORE_FREE_CB(efreet_desktop_command_file_free));
+
+    command->flags = efreet_desktop_command_flags_get(desktop);
+    /* get the required info for each file passed in */
+    if (files)
+    {
+        ecore_list_first_goto(files);
+        while ((file = ecore_list_next(files)))
+        {
+            Efreet_Desktop_Command_File *dcf;
+
+            dcf = efreet_desktop_command_file_process(command, file);
+            if (!dcf) continue;
+            ecore_list_append(command->files, dcf);
+            command->num_pending += dcf->pending;
+        }
+    }
+
+    if (command->num_pending == 0)
+    {
+        Ecore_List *execs;
+        execs = efreet_desktop_command_build(command);
+        ret = efreet_desktop_command_execs_process(command, execs);
+        ecore_list_destroy(execs);
+        efreet_desktop_command_free(command);
+    }
+
+    return ret;
+}
+
+/**
+ * @internal
+ *
+ * @brief Determine which file related field codes are present in the Exec string of a .desktop
+ * @params desktop and Efreet Desktop
+ * @return a bitmask of file field codes present in exec string
+ */
+static int
+efreet_desktop_command_flags_get(Efreet_Desktop *desktop)
+{
+    int flags = 0;
+    const char *p;
+    /* first, determine which fields are present in the Exec string */
+    p = strchr(desktop->exec, '%');
+    while (p)
+    {
+        p++;
+        switch(*p)
+        {
+            case 'f':
+            case 'F':
+                flags |= EFREET_DESKTOP_EXEC_FLAG_FULLPATH;
+                break;
+            case 'u':
+            case 'U':
+                flags |= EFREET_DESKTOP_EXEC_FLAG_URI;
+                break;
+            case 'd':
+            case 'D':
+                flags |= EFREET_DESKTOP_EXEC_FLAG_DIR;
+                break;
+            case 'n':
+            case 'N':
+                flags |= EFREET_DESKTOP_EXEC_FLAG_FILE;
+                break;
+            case '%':
+                p++;
+                break;
+            default:
+                break;
+        }
+
+        p = strchr(p, '%');
+    }
+#ifdef SLOPPY_SPEC   
+   /* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
+    * do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
+    * unlikely to be fixed in distributions etc. in the long run as gnome/kde
+    * seem to have workarounds too so no one notices.
+    */
+   if (!flags) flags |= EFREET_DESKTOP_EXEC_FLAG_FULLPATH;
+#endif
+   
+    return flags;
+}
+
+
+/**
+ * @internal
+ *
+ * @brief Call the command callback for each exec in the list
+ * @param command
+ * @param execs
+ */
+static void *
+efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Ecore_List *execs)
+{
+    char *exec;
+    int num;
+    void *ret = NULL;
+   
+    num = ecore_list_count(execs);
+    ecore_list_first_goto(execs);
+    while ((exec = ecore_list_next(execs)))
+    {
+        ret = command->cb_command(command->data, command->desktop, exec, --num);
+    }
+    return ret;
+}
+
+
+/**
+ * @brief Builds the actual exec string from the raw string and a list of
+ * processed filename information. The callback passed in to
+ * efreet_desktop_command_get is called for each exec string created.
+ *
+ * @param command: the command to build
+ * @return a list of executable strings
+ */
+static Ecore_List *
+efreet_desktop_command_build(Efreet_Desktop_Command *command)
+{
+    Efreet_Desktop_Command_File *file = NULL;
+    int first = 1;
+    Ecore_List *execs;
+    char *exec;
+
+    execs = ecore_list_new();
+
+    ecore_list_first_goto(command->files);
+
+    /* if the Exec field appends multiple, that will run the list to the end,
+     * causing this loop to only run once. otherwise, this loop will generate a
+     * command for each file in the list. if the list is empty, this
+     * will run once, removing any file field codes */
+    while ((file = ecore_list_next(command->files)) || first)
+    {
+        const char *p;
+        int len = 0;
+        int size = PATH_MAX;
+        int file_added = 0;
+
+        first = 0;
+
+        exec = malloc(size);
+        p = command->desktop->exec;
+        len = 0;
+
+        while (*p)
+        {
+            if (len >= size - 1)
+            {
+                size = len + 1024;
+                exec = realloc(exec, size);
+            }
+
+            /* XXX handle fields inside quotes? */
+            if (*p == '%')
+            {
+                p++;
+                switch (*p)
+                {
+                    case 'f':
+                    case 'u':
+                    case 'd':
+                    case 'n':
+                        if (file)
+                        {
+                            exec = efreet_desktop_command_append_single(exec, &size,
+                                                                    &len, file, *p);
+                            file_added = 1;
+                        }
+                        break;
+                    case 'F':
+                    case 'U':
+                    case 'D':
+                    case 'N':
+                        if (file)
+                        {
+                            exec = efreet_desktop_command_append_multiple(exec, &size,
+                                                                    &len, command, *p);
+                            file_added = 1;
+                        }
+                        break;
+                    case 'i':
+                        exec = efreet_desktop_command_append_icon(exec, &size, &len,
+                                                                    command->desktop);
+                        break;
+                    case 'c':
+                        exec = efreet_desktop_command_append_quoted(exec, &size, &len,
+                                                                command->desktop->name);
+                        break;
+                    case 'k':
+                        exec = efreet_desktop_command_append_quoted(exec, &size, &len,
+                                                            command->desktop->orig_path);
+                        break;
+                    case 'v':
+                    case 'm':
+                        printf("[Efreet]: Deprecated conversion char: '%c' in file '%s'\n",
+                                                            *p, command->desktop->orig_path);
+                        break;
+                    case '%':
+                        exec[len++] = *p;
+                        break;
+                    default:
+#ifdef STRICT_SPEC
+                        printf("[Efreet]: Unknown conversion character: '%c'\n", *p);
+#endif
+                        break;
+                }
+            }
+            else exec[len++] = *p;
+            p++;
+        }
+
+#ifdef SLOPPY_SPEC       
+       /* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
+       * do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
+       * unlikely to be fixed in distributions etc. in the long run as gnome/kde
+       * seem to have workarounds too so no one notices.
+       */
+       if ((file) && (!file_added))
+        {
+           printf("[Efreet]: %s\n"
+                  "  command: %s\n"
+                  "  has no file path/uri spec info for executing this app WITH a\n"
+                  "  file/uri as a parameter. This is unlikely to be the intent.\n"
+                  "  please check the .desktop file and fix it by adding a %%U or %%F\n"
+                  "  or something appropriate.",
+                  command->desktop->orig_path, command->desktop->exec);
+            if (len >= size - 1)
+             {
+                size = len + 1024;
+                exec = realloc(exec, size);
+             }
+           exec[len++] = ' ';
+           exec = efreet_desktop_command_append_multiple(exec, &size,
+                                                         &len, command, 'F');
+           file_added = 1;
+        }
+#endif
+        exec[len++] = '\0';
+
+        ecore_list_append(execs, exec);
+
+        /* If no file was added, then the Exec field doesn't contain any file
+         * fields (fFuUdDnN). We only want to run the app once in this case. */
+        if (!file_added) break;
+    }
+
+    return execs;
+}
+
+static void
+efreet_desktop_command_free(Efreet_Desktop_Command *command)
+{
+    if (!command) return;
+
+    IF_FREE_LIST(command->files);
+    FREE(command);
+}
+
+static char *
+efreet_desktop_command_append_quoted(char *dest, int *size, int *len, char *src)
+{
+    if (!src) return dest;
+    dest = efreet_string_append(dest, size, len, "'");
+
+    /* single quotes in src need to be escaped */
+    if (strchr(src, '\''))
+    {
+        char *p;
+        p = src;
+        while (*p)
+        {
+            if (*p == '\'')
+                dest = efreet_string_append(dest, size, len, "\'\\\'");
+
+            dest = efreet_string_append_char(dest, size, len, *p);
+            p++;
+        }
+    }
+    else
+        dest = efreet_string_append(dest, size, len, src);
+
+    dest = efreet_string_append(dest, size, len, "'");
+
+    return dest;
+}
+
+static char *
+efreet_desktop_command_append_multiple(char *dest, int *size, int *len,
+                                        Efreet_Desktop_Command *command,
+                                        char type)
+{
+    Efreet_Desktop_Command_File *file;
+    int first = 1;
+
+    if (!command->files) return dest;
+
+    ecore_list_first_goto(command->files);
+    while ((file = ecore_list_next(command->files)))
+    {
+        if (first)
+            first = 0;
+        else
+            dest = efreet_string_append_char(dest, size, len, ' ');
+
+        dest = efreet_desktop_command_append_single(dest, size, len,
+                                                    file, tolower(type));
+    }
+
+    return dest;
+}
+
+static char *
+efreet_desktop_command_append_single(char *dest, int *size, int *len,
+                                        Efreet_Desktop_Command_File *file,
+                                        char type)
+{
+    char *str;
+    switch(type)
+    {
+        case 'f':
+            str = file->fullpath;
+            break;
+        case 'u':
+            str = file->uri;
+            break;
+        case 'd':
+            str = file->dir;
+            break;
+        case 'n':
+            str = file->file;
+            break;
+        default:
+            printf("Invalid type passed to efreet_desktop_command_append_single:"
+                                                                " '%c'\n", type);
+            return dest;
+    }
+
+    if (!str) return dest;
+
+    dest = efreet_desktop_command_append_quoted(dest, size, len, str);
+
+    return dest;
+}
+
+static char *
+efreet_desktop_command_append_icon(char *dest, int *size, int *len,
+                                            Efreet_Desktop *desktop)
+{
+    if (!desktop->icon || !desktop->icon[0]) return dest;
+
+    dest = efreet_string_append(dest, size, len, "--icon ");
+    dest = efreet_desktop_command_append_quoted(dest, size, len, desktop->icon);
+
+    return dest;
+}
+
+
+/**
+ * Append a string to a buffer, reallocating as necessary.
+ */
+static char *
+efreet_string_append(char *dest, int *size, int *len, const char *src)
+{
+    int l;
+    int off = 0;
+
+    l = ecore_strlcpy(dest + *len, src, *size - *len);
+
+    while (l > *size - *len)
+    {
+        /* we successfully appended this much */
+        off += *size - *len - 1;
+        *len = *size - 1;
+        *size += 1024;
+        dest = realloc(dest, *size);
+        *(dest + *len) = '\0';
+
+        l = ecore_strlcpy(dest + *len, src + off, *size - *len);
+    }
+    *len += l;
+
+    return dest;
+}
+
+static char *
+efreet_string_append_char(char *dest, int *size, int *len, char c)
+{
+    if (*len >= *size - 1)
+    {
+        *size += 1024;
+        dest = realloc(dest, *size);
+    }
+
+    dest[(*len)++] = c;
+    dest[*len] = '\0';
+
+    return dest;
+}
+
+/**
+ * @param command: the Efreet_Desktop_Comand that this file is for
+ * @param file: the filname as either an absolute path, relative path, or URI
+ */
+static Efreet_Desktop_Command_File *
+efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char *file)
+{
+    Efreet_Desktop_Command_File *f;
+    const char *uri, *base;
+    int nonlocal = 0;
+/*
+    printf("FLAGS: %d, %d, %d, %d\n",
+        command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH ? 1 : 0,
+        command->flags & EFREET_DESKTOP_EXEC_FLAG_URI ? 1 : 0,
+        command->flags & EFREET_DESKTOP_EXEC_FLAG_DIR ? 1 : 0,
+        command->flags & EFREET_DESKTOP_EXEC_FLAG_FILE ? 1 : 0);
+*/
+    f = NEW(Efreet_Desktop_Command_File, 1);
+    if (!f) return NULL;
+
+    f->command = command;
+
+    /* handle uris */
+    if(!strncmp(file, "http://", 7) || !strncmp(file, "ftp://", 6))
+    {
+        uri = file;
+        base = ecore_file_file_get(file);
+
+        nonlocal = 1;
+    }
+    else if (!strncmp(file, "file:", 5))
+    {
+        file = efreet_desktop_command_file_uri_process(file);
+        if (!file)
+        {
+            efreet_desktop_command_file_free(f);
+            return NULL;
+        }
+    }
+
+    if (nonlocal)
+    {
+        /* process non-local uri */
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH)
+        {
+            char buf[PATH_MAX];
+
+            snprintf(buf, PATH_MAX, "/tmp/%d-%d-%s", getpid(),
+                            efreet_desktop_command_file_id++, base);
+            f->fullpath = strdup(buf);
+            f->pending = 1;
+
+            ecore_file_download(uri, f->fullpath, efreet_desktop_cb_download_complete,
+                                            efreet_desktop_cb_download_progress, f);
+        }
+
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_URI)
+            f->uri = strdup(uri);
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_DIR)
+            f->dir = strdup("/tmp");
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FILE)
+            f->file = strdup(base);
+    }
+    else
+    {
+        char *abs = efreet_desktop_command_path_absolute(file);
+        /* process local uri/path */
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH)
+            f->fullpath = strdup(abs);
+
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_URI)
+        {
+            char buf[PATH_MAX];
+            snprintf(buf, sizeof(buf), "file://%s", abs);
+            f->uri = strdup(buf);
+        }
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_DIR)
+            f->dir = ecore_file_dir_get(abs);
+        if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FILE)
+            f->file = strdup(ecore_file_file_get(file));
+
+        free(abs);
+    }
+#if 0
+    printf("  fullpath: %s\n", f->fullpath);
+    printf("  uri: %s\n", f->uri);
+    printf("  dir: %s\n", f->dir);
+    printf("  file: %s\n", f->file);
+#endif
+    return f;
+}
+
+/**
+ * @brief Find the local path portion of a file uri.
+ * @param uri: a uri beginning with "file:"
+ * @return the location of the path portion of the uri,
+ * or NULL if the file is not on this machine
+ */
+static const char *
+efreet_desktop_command_file_uri_process(const char *uri)
+{
+    const char *path = NULL;
+    int len = strlen(uri);
+
+    /* uri:foo/bar => relative path foo/bar*/
+    if (len >= 4 && uri[5] != '/')
+        path = uri + strlen("file:");
+
+    /* uri:/foo/bar => absolute path /foo/bar */
+    else if (len >= 5 && uri[6] != '/')
+        path = uri + strlen("file:");
+
+    /* uri://foo/bar => absolute path /bar on machine foo */
+    else if (len >= 6 && uri[7] != '/')
+    {
+        char *tmp, *p;
+        char hostname[PATH_MAX];
+        tmp = strdup(uri + 7);
+        p = strchr(tmp, '/');
+        if (p)
+        {
+            *p = '\0';
+            if (!strcmp(tmp, "localhost"))
+                path = uri + strlen("file://localhost");
+            else
+            {
+                int ret;
+
+                ret = gethostname(hostname, PATH_MAX);
+                if ((ret == 0) && !strcmp(tmp, hostname))
+                    path = uri + strlen("file://") + strlen(hostname);
+            }
+        }
+        free(tmp);
+    }
+
+    /* uri:///foo/bar => absolute path /foo/bar on local machine */
+    else if (len >= 7)
+        path = uri + strlen("file://");
+
+    return path;
+}
+
+static void
+efreet_desktop_command_file_free(Efreet_Desktop_Command_File *file)
+{
+    if (!file) return;
+
+    IF_FREE(file->fullpath);
+    IF_FREE(file->uri);
+    IF_FREE(file->dir);
+    IF_FREE(file->file);
+
+    FREE(file);
+}
+
+
+static void
+efreet_desktop_cb_download_complete(void *data, const char *file __UNUSED__,
+                                                        int status __UNUSED__)
+{
+    Efreet_Desktop_Command_File *f;
+    f = data;
+
+    /* XXX check status... error handling, etc */
+    f->pending = 0;
+    f->command->num_pending--;
+
+    if (f->command->num_pending <= 0)
+    {
+        Ecore_List *execs;
+        execs = efreet_desktop_command_build(f->command);
+        /* TODO: Need to handle the return value from efreet_desktop_command_execs_process */
+        efreet_desktop_command_execs_process(f->command, execs);
+        ecore_list_destroy(execs);
+        efreet_desktop_command_free(f->command);
+    }
+}
+
+static int
+efreet_desktop_cb_download_progress(void *data,
+                                    const char *file __UNUSED__,
+                                    long int dltotal, long int dlnow,
+                                    long int ultotal __UNUSED__,
+                                    long int ulnow __UNUSED__)
+{
+    Efreet_Desktop_Command_File *dcf;
+
+    dcf = data;
+    if (dcf->command->cb_progress)
+        return dcf->command->cb_progress(dcf->command->data,
+                                        dcf->command->desktop,
+                                        dcf->uri, dltotal, dlnow);
+
+    return 0;
+}
+
+/**
+ * @brief Build an absolute path from an absolute or relative one.
+ * @param path: an absolute or relative path
+ * @return an allocated absolute path (must be freed)
+ */
+static char *
+efreet_desktop_command_path_absolute(const char *path)
+{
+    char *buf;
+    int size = PATH_MAX;
+    int len = 0;
+
+    /* relative url */
+    if (path[0] != '/')
+    {
+        if (!(buf = malloc(size))) return NULL;
+        if (!getcwd(buf, size))
+        {
+            FREE(buf);
+            return NULL;
+        }
+        len = strlen(buf);
+
+        if (buf[len-1] != '/') buf = efreet_string_append(buf, &size, &len, "/");
+        buf = efreet_string_append(buf, &size, &len, path);
+
+        return buf;
+    }
+
+    /* just dup an already absolute buffer */
+    return strdup(path);
+}
diff --git a/src/lib/efreet_desktop.h b/src/lib/efreet_desktop.h
new file mode 100644 (file)
index 0000000..5244bc2
--- /dev/null
@@ -0,0 +1,150 @@
+/* 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
+ *
+ * @{
+ */
+
+EAPI extern int EFREET_DESKTOP_TYPE_APPLICATION;
+EAPI extern int EFREET_DESKTOP_TYPE_LINK;
+EAPI extern int 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);
+
+/**
+ * A callback used to parse data for custom types
+ */
+typedef void *(*Efreet_Desktop_Type_Parse_Cb) (Efreet_Desktop *desktop, Efreet_Ini *ini);
+
+/**
+ * A callback used to save data for custom types
+ */
+typedef void (*Efreet_Desktop_Type_Save_Cb) (Efreet_Desktop *desktop, Efreet_Ini *ini);
+
+/**
+ * A callback used to free data for custom types
+ */
+typedef void *(*Efreet_Desktop_Type_Free_Cb) (void *data);
+
+/**
+ * Efreet_Desktop
+ * @brief a parsed representation of a .desktop file
+ */
+struct Efreet_Desktop
+{
+    int type;               /**< type of desktop file */
+
+    int ref;                /**< reference count - internal */
+    int cache_flush;        /**< cache flush value - internal */
+
+    double version;         /**< version of spec file conforms to */
+
+    char *orig_path;        /**< original path to .desktop file */
+    long long load_time;    /**< modified time of .desktop on 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 */
+    unsigned char cached:1;            /**< The desktop file is cached by Efreet */
+
+    Ecore_Hash *x; /**< Keep track of all user extensions, keys that begin with X- */
+    void *type_data; /**< Type specific data for custom types */
+};
+
+EAPI Efreet_Desktop   *efreet_desktop_get(const char *file);
+EAPI int               efreet_desktop_ref(Efreet_Desktop *desktop);
+EAPI Efreet_Desktop   *efreet_desktop_empty_new(const char *file);
+EAPI Efreet_Desktop   *efreet_desktop_new(const char *file);
+EAPI void              efreet_desktop_free(Efreet_Desktop *desktop);
+
+EAPI int               efreet_desktop_save(Efreet_Desktop *desktop);
+EAPI int               efreet_desktop_save_as(Efreet_Desktop *desktop,
+                                                const char *file);
+
+EAPI void              efreet_desktop_exec(Efreet_Desktop *desktop,
+                                      Ecore_List *files, void *data);
+
+EAPI void              efreet_desktop_environment_set(const char *environment);
+EAPI const char       *efreet_desktop_environment_get(void);
+EAPI void             *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);
+EAPI void              *efreet_desktop_command_get(Efreet_Desktop *desktop,
+                                         Ecore_List *files,
+                                         Efreet_Desktop_Command_Cb func,
+                                         void *data);
+EAPI Ecore_List *      efreet_desktop_command_local_get(Efreet_Desktop *desktop,
+                                         Ecore_List *files);
+
+EAPI unsigned int      efreet_desktop_category_count_get(Efreet_Desktop *desktop);
+EAPI void              efreet_desktop_category_add(Efreet_Desktop *desktop,
+                                              const char *category);
+EAPI int               efreet_desktop_category_del(Efreet_Desktop *desktop,
+                                              const char *category);
+
+EAPI int               efreet_desktop_type_add(const char *type,
+                                    Efreet_Desktop_Type_Parse_Cb parse_func,
+                                    Efreet_Desktop_Type_Save_Cb save_func,
+                                    Efreet_Desktop_Type_Free_Cb free_func);
+EAPI int               efreet_desktop_type_alias (int from_type,
+                                             const char *alias);
+EAPI void             *efreet_desktop_type_data_get(Efreet_Desktop *desktop);
+
+EAPI Ecore_List       *efreet_desktop_string_list_parse(const char *string);
+EAPI char             *efreet_desktop_string_list_join(Ecore_List *list);
+
+EAPI void              efreet_desktop_cache_flush(void);
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_icon.c b/src/lib/efreet_icon.c
new file mode 100644 (file)
index 0000000..cf104cd
--- /dev/null
@@ -0,0 +1,1641 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "efreet_private.h"
+
+static char *efreet_icon_deprecated_user_dir = NULL;
+static char *efreet_icon_user_dir = NULL;
+static Ecore_Hash *efreet_icon_themes = NULL;
+static Ecore_List *efreet_icon_extensions = NULL;
+static Ecore_List *efreet_extra_icon_dirs = NULL;
+static Ecore_Hash *efreet_icon_cache = NULL;
+
+static int efreet_icon_init_count = 0;
+
+typedef struct Efreet_Icon_Cache Efreet_Icon_Cache;
+struct Efreet_Icon_Cache
+{
+    char *key;
+    char *path;
+    time_t lasttime;
+};
+
+static char *efreet_icon_remove_extension(const char *icon);
+static Efreet_Icon_Theme *efreet_icon_find_theme_check(const char *theme_name);
+
+
+static char *efreet_icon_find_fallback(Efreet_Icon_Theme *theme,
+                                       const char *icon,
+                                       unsigned int size);
+static char *efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme,
+                                            Ecore_List *icons,
+                                            unsigned int size);
+static char *efreet_icon_find_helper(Efreet_Icon_Theme *theme,
+                                     const char *icon, unsigned int size);
+static char *efreet_icon_list_find_helper(Efreet_Icon_Theme *theme,
+                                          Ecore_List *icons, unsigned int size);
+static char *efreet_icon_lookup_icon(Efreet_Icon_Theme *theme,
+                                     const char *icon_name, unsigned int size);
+static char *efreet_icon_fallback_icon(const char *icon_name);
+static char *efreet_icon_fallback_dir_scan(const char *dir,
+                                           const char *icon_name);
+
+static char *efreet_icon_lookup_directory(Efreet_Icon_Theme *theme,
+                                          Efreet_Icon_Theme_Directory *dir,
+                                          const char *icon_name);
+static int efreet_icon_directory_size_distance(Efreet_Icon_Theme_Directory *dir,
+                                                    unsigned int size);
+static int efreet_icon_directory_size_match(Efreet_Icon_Theme_Directory *dir,
+                                                  unsigned int size);
+
+static Efreet_Icon *efreet_icon_new(const char *path);
+static void efreet_icon_point_free(Efreet_Icon_Point *point);
+static void efreet_icon_populate(Efreet_Icon *icon, const char *file);
+
+static char *efreet_icon_lookup_directory_helper(Efreet_Icon_Theme_Directory *dir,
+                                    const char *path, const char *icon_name);
+
+static Efreet_Icon_Theme *efreet_icon_theme_new(void);
+static void efreet_icon_theme_free(Efreet_Icon_Theme *theme);
+static void efreet_icon_theme_dir_scan_all(const char *theme_name);
+static void efreet_icon_theme_dir_scan(const char *dir,
+                                        const char *theme_name);
+static void efreet_icon_theme_dir_validity_check(void);
+static void efreet_icon_theme_path_add(Efreet_Icon_Theme *theme,
+                                                const char *path);
+static void efreet_icon_theme_index_read(Efreet_Icon_Theme *theme,
+                                                const char *path);
+
+static Efreet_Icon_Theme_Directory *efreet_icon_theme_directory_new(Efreet_Ini *ini,
+                                                                const char *name);
+static void efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir);
+
+static void efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme);
+static int efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme,
+                                                        const char *dir);
+
+static int efreet_icon_cache_find(Efreet_Icon_Cache *value, const char *key);
+static void efreet_icon_cache_flush(Ecore_List *list);
+static void efreet_icon_cache_free(Efreet_Icon_Cache *value);
+static char *efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int size);
+static void efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int size, const char *value);
+
+/**
+ * @internal
+ * @return Returns 1 on success or 0 on failure
+ * @brief Initializes the icon system
+ */
+int
+efreet_icon_init(void)
+{
+    if (efreet_icon_init_count++ > 0)
+        return efreet_icon_init_count;
+
+    if (!efreet_icon_themes)
+    {
+        const char *default_exts[] = {".png", ".xpm", NULL};
+        int i;
+
+        if (!ecore_init())
+        {
+            efreet_icon_init_count--;
+            return 0;
+        }
+
+        /* setup the default extension list */
+        efreet_icon_extensions = ecore_list_new();
+        ecore_list_free_cb_set(efreet_icon_extensions, free);
+
+        for (i = 0; default_exts[i] != NULL; i++)
+            ecore_list_append(efreet_icon_extensions, strdup(default_exts[i]));
+
+        efreet_icon_themes = ecore_hash_new(NULL, NULL);
+        ecore_hash_free_value_cb_set(efreet_icon_themes,
+                            ECORE_FREE_CB(efreet_icon_theme_free));
+        efreet_extra_icon_dirs = ecore_list_new();
+
+        efreet_icon_cache = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
+        ecore_hash_free_value_cb_set(efreet_icon_cache, ECORE_FREE_CB(ecore_list_destroy));
+    }
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @return Returns no value
+ * @brief Shuts down the icon system
+ */
+void
+efreet_icon_shutdown(void)
+{
+    if (--efreet_icon_init_count)
+        return;
+
+    IF_FREE(efreet_icon_user_dir);
+    IF_FREE(efreet_icon_deprecated_user_dir);
+
+    IF_FREE_LIST(efreet_icon_extensions);
+    IF_FREE_HASH(efreet_icon_themes);
+    IF_FREE_LIST(efreet_extra_icon_dirs);
+
+    IF_FREE_HASH(efreet_icon_cache);
+
+    ecore_shutdown();
+    efreet_icon_init_count = 0;
+}
+
+/**
+ * @return Returns the user icon directory
+ * @brief Returns the user icon directory
+ */
+const char *
+efreet_icon_deprecated_user_dir_get(void)
+{
+    const char *user;
+    int len;
+
+    if (efreet_icon_deprecated_user_dir) return efreet_icon_deprecated_user_dir;
+
+    user = efreet_home_dir_get();
+    len = strlen(user) + strlen("/.icons") + 1;
+    efreet_icon_deprecated_user_dir = malloc(sizeof(char) * len);
+    snprintf(efreet_icon_deprecated_user_dir, len, "%s/.icons", user);
+
+    return efreet_icon_deprecated_user_dir;
+}
+
+EAPI const char *
+efreet_icon_user_dir_get(void)
+{
+    const char *user;
+    int len;
+
+    if (efreet_icon_user_dir) return efreet_icon_user_dir;
+
+    user = efreet_data_home_get();
+    len = strlen(user) + strlen("/icons") + 1;
+    efreet_icon_user_dir = malloc(sizeof(char) * len);
+    snprintf(efreet_icon_user_dir, len, "%s/icons", user);
+
+    return efreet_icon_user_dir;
+}
+
+/**
+ * @param ext: The extension to add to the list of checked extensions
+ * @return Returns no value.
+ * @brief Adds the given extension to the list of possible icon extensions
+ */
+EAPI void
+efreet_icon_extension_add(const char *ext)
+{
+    ecore_list_prepend(efreet_icon_extensions, strdup(ext));
+}
+
+/**
+ * @return Returns a list of strings that are paths to other icon directories
+ * @brief Gets the list of all extra directories to look for icons. These
+ * directories are used to look for icons after looking in the user icon dir
+ * and before looking in standard system directories. The order of search is
+ * from first to last directory in this list. the strings in the list should
+ * be created with ecore_string_instance().
+ */
+EAPI Ecore_List *
+efreet_icon_extra_list_get(void)
+{
+    return efreet_extra_icon_dirs;
+}
+
+/**
+ * @return Returns a list of Efreet_Icon structs for all the non-hidden icon
+ * themes
+ * @brief Retrieves all of the non-hidden icon themes available on the system.
+ * The returned list must be freed. Do not free the list data.
+ */
+EAPI Ecore_List *
+efreet_icon_theme_list_get(void)
+{
+    Ecore_List *list, *theme_list;
+    char *dir;
+
+    /* update the list to include all icon themes */
+    efreet_icon_theme_dir_scan_all(NULL);
+    efreet_icon_theme_dir_validity_check();
+
+    /* create the list for the user */
+    list = ecore_list_new();
+    theme_list = ecore_hash_keys(efreet_icon_themes);
+    ecore_list_first_goto(theme_list);
+    while ((dir = ecore_list_next(theme_list)))
+    {
+        Efreet_Icon_Theme *theme;
+
+        theme = ecore_hash_get(efreet_icon_themes, dir);
+        if (theme->hidden || theme->fake) continue;
+#ifndef STRICT_SPEC
+        if (!theme->name.name) continue;
+#endif
+
+        ecore_list_append(list, theme);
+    }
+    ecore_list_destroy(theme_list);
+
+    return list;
+}
+
+/**
+ * @param theme_name: The theme to look for
+ * @return Returns the icon theme related to the given theme name or NULL if
+ * none exists.
+ * @brief Tries to get the icon theme structure for the given theme name
+ */
+EAPI Efreet_Icon_Theme *
+efreet_icon_theme_find(const char *theme_name)
+{
+    const char *key;
+    Efreet_Icon_Theme *theme;
+
+    key = ecore_string_instance(theme_name);
+    theme = ecore_hash_get(efreet_icon_themes, key);
+    if (!theme)
+    {
+        efreet_icon_theme_dir_scan_all(theme_name);
+        theme = ecore_hash_get(efreet_icon_themes, key);
+    }
+    ecore_string_release(key);
+
+    return theme;
+}
+
+/**
+ * @internal
+ * @param icon: The icon name to strip extension
+ * @return Extension removed if in list of extensions, else untouched.
+ * @brief Removes extension from icon name if in list of extensions.
+ */
+static char *
+efreet_icon_remove_extension(const char *icon)
+{
+    char *tmp = NULL, *ext = NULL;
+
+    tmp = strdup(icon);
+    ext = strrchr(tmp, '.');
+    if (ext)
+    {
+        const char *ext2;
+        ecore_list_first_goto(efreet_icon_extensions);
+        while ((ext2 = ecore_list_next(efreet_icon_extensions)))
+        {
+            if (!strcmp(ext, ext2))
+            {
+#ifdef STRICT_SPEC
+                printf("[Efreet]: Requesting an icon with an extension: %s\n",
+                                                                        icon);
+#endif
+                *ext = '\0';
+                break;
+            }
+        }
+    }
+
+    return tmp;
+}
+
+/**
+ * @internal
+ * @param theme_name: The icon theme to look for
+ * @return Returns the Efreet_Icon_Theme structure representing this theme
+ * or a new blank theme if not found
+ * @brief Retrieves a theme, or creates a blank one if not found.
+ */
+static Efreet_Icon_Theme *
+efreet_icon_find_theme_check(const char *theme_name)
+{
+    Efreet_Icon_Theme *theme = NULL;
+    theme = efreet_icon_theme_find(theme_name);
+    if (!theme)
+    {
+        theme = efreet_icon_theme_new();
+        theme->fake = 1;
+        theme->name.internal = ecore_string_instance(theme_name);
+        ecore_hash_set(efreet_icon_themes, (void *)theme->name.internal, theme);
+    }
+
+    return theme;
+}
+
+/**
+ * @param theme_name: The icon theme to look for
+ * @param icon: The icon to look for
+ * @param size; The icon size to look for
+ * @return Returns the path to the given icon or NULL if none found
+ * @brief Retrives the path to the given icon.
+ */
+EAPI char *
+efreet_icon_path_find(const char *theme_name, const char *icon, unsigned int size)
+{
+    char *value = NULL;
+    Efreet_Icon_Theme *theme;
+
+    theme = efreet_icon_find_theme_check(theme_name);
+
+#ifdef SLOPPY_SPEC
+    {
+        char *tmp;
+
+        tmp = efreet_icon_remove_extension(icon);
+        value = efreet_icon_find_helper(theme, tmp, size);
+        FREE(tmp);
+    }
+#else
+    value = efreet_icon_find_helper(theme, icon, size);
+#endif
+
+    /* we didn't find the icon in the theme or in the inherited directories
+     * then just look for a non theme icon
+     */
+    if (!value || (value == (void *)-1)) value = efreet_icon_fallback_icon(icon);
+
+    if (value == (void *)-1) value = NULL;
+    return value;
+}
+
+/**
+ * @param theme_name: The icon theme to look for
+ * @param icons: List of icons to look for
+ * @param size; The icon size to look for
+ * @return Returns the path representing first found icon or
+ * NULL if none of the icons are found
+ * @brief Retrieves all of the information about the first found icon in
+ * the list.
+ * @note This function will search the given theme for all icons before falling
+ * back. This is useful when searching for mimetype icons.
+ */
+EAPI char *
+efreet_icon_list_find(const char *theme_name, Ecore_List *icons,
+                                                            unsigned int size)
+{
+    const char *icon = NULL;
+    char *value = NULL;
+    Efreet_Icon_Theme *theme;
+
+    theme = efreet_icon_find_theme_check(theme_name);
+
+    ecore_list_first_goto(icons);
+#ifdef SLOPPY_SPEC
+    {
+        Ecore_List *tmps = NULL;
+
+        tmps = ecore_list_new();
+        ecore_list_free_cb_set(tmps, free);
+        ecore_list_first_goto(icons);
+        while ((icon = ecore_list_next(icons)))
+            ecore_list_append(tmps, efreet_icon_remove_extension(icon));
+
+        value = efreet_icon_list_find_helper(theme, tmps, size);
+        ecore_list_destroy(tmps);
+    }
+#else
+    value = efreet_icon_list_find_helper(theme, icons, size);
+#endif
+
+    /* we didn't find the icons in the theme or in the inherited directories
+     * then just look for a non theme icon
+     */
+    if (!value || (value == (void *)-1))
+    {
+        ecore_list_first_goto(icons);
+        while ((icon = ecore_list_next(icons)))
+        {
+            value = efreet_icon_fallback_icon(icon);
+            if (value && (value != (void *)-1))
+                break;
+        }
+    }
+
+    if (value == (void *)-1) value = NULL;
+    return value;
+}
+
+/**
+ * @param theme: The icon theme to look for
+ * @param icon: The icon to look for
+ * @param size: The icon size to look for
+ * @return Returns the Efreet_Icon structure representing this icon or NULL
+ * if the icon is not found
+ * @brief Retrieves all of the information about the given icon.
+ */
+EAPI Efreet_Icon *
+efreet_icon_find(const char *theme_name, const char *icon, unsigned int size)
+{
+    char *path;
+
+    path = efreet_icon_path_find(theme_name, icon, size);
+    if (path)
+    {
+        Efreet_Icon *icon;
+
+        icon = efreet_icon_new(path);
+        free(path);
+        return icon;
+    }
+
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param theme: The theme to search in
+ * @param icon: The icon to search for
+ * @param size: The size to search for
+ * @return Returns the icon matching the given information or NULL if no
+ * icon found
+ * @brief Scans inheriting themes for the given icon
+ */
+static char *
+efreet_icon_find_fallback(Efreet_Icon_Theme *theme,
+                          const char *icon, unsigned int size)
+{
+    char *parent = NULL;
+    char *value = NULL;
+
+    if (theme->inherits)
+    {
+        ecore_list_first_goto(theme->inherits);
+        while ((parent = ecore_list_next(theme->inherits)))
+        {
+            Efreet_Icon_Theme *parent_theme;
+
+            parent_theme = efreet_icon_theme_find(parent);
+            if ((!parent_theme) || (parent_theme == theme)) continue;
+
+            value = efreet_icon_find_helper(parent_theme, icon, size);
+            if (value && (value != (void *)-1)) break;
+        }
+    }
+    /* if this isn't the hicolor theme, and we have no other fallbacks
+     * check hicolor */
+    else if (strcmp(theme->name.internal, "hicolor"))
+    {
+        Efreet_Icon_Theme *parent_theme;
+
+        parent_theme = efreet_icon_theme_find("hicolor");
+        if (parent_theme)
+            value = efreet_icon_find_helper(parent_theme, icon, size);
+    }
+
+    return value;
+}
+
+/**
+ * @internal
+ * @param theme: The theme to search in
+ * @param icon: The icon to search for
+ * @param size: The size to search for
+ * @return Returns the icon matching the given information or NULL if no
+ * icon found
+ * @brief Scans the theme and any inheriting themes for the given icon
+ */
+static char *
+efreet_icon_find_helper(Efreet_Icon_Theme *theme,
+                        const char *icon, unsigned int size)
+{
+    char *value;
+    static int recurse = 0;
+
+    efreet_icon_theme_cache_check(theme);
+
+    /* go no further if this theme is fake */
+    if (theme->fake || !theme->valid) return NULL;
+
+    /* limit recursion in finding themes and inherited themes to 256 levels */
+    if (recurse > 256) return NULL;
+    recurse++;
+
+    value = efreet_icon_lookup_icon(theme, icon, size);
+
+    /* we didin't find the image check the inherited themes */
+    if (!value || (value == (void *)-1))
+        value = efreet_icon_find_fallback(theme, icon, size);
+
+    recurse--;
+    return value;
+}
+
+/**
+ * @internal
+ * @param theme: The theme to search in
+ * @param icons: The icons to search for
+ * @param size: The size to search for
+ * @return Returns the icon matching the given information or NULL if no
+ * icon found
+ * @brief Scans inheriting themes for the given icons
+ */
+static char *
+efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme,
+                               Ecore_List *icons, unsigned int size)
+{
+    char *parent = NULL;
+    char *value = NULL;
+
+    if (theme->inherits)
+    {
+        ecore_list_first_goto(theme->inherits);
+        while ((parent = ecore_list_next(theme->inherits)))
+        {
+            Efreet_Icon_Theme *parent_theme;
+
+            parent_theme = efreet_icon_theme_find(parent);
+            if ((!parent_theme) || (parent_theme == theme)) continue;
+
+            value = efreet_icon_list_find_helper(parent_theme,
+                                                        icons, size);
+            if (value && (value != (void *)-1)) break;
+        }
+    }
+
+    /* if this isn't the hicolor theme, and we have no other fallbacks
+     * check hicolor
+     */
+    else if (strcmp(theme->name.internal, "hicolor"))
+    {
+        Efreet_Icon_Theme *parent_theme;
+
+        parent_theme = efreet_icon_theme_find("hicolor");
+        if (parent_theme)
+            value = efreet_icon_list_find_helper(parent_theme,
+                                                        icons, size);
+    }
+
+    return value;
+}
+
+/**
+ * @internal
+ * @param theme: The theme to search in
+ * @param icons: The icons to search for
+ * @param size: The size to search for
+ * @return Returns the icon matching the given information or NULL if no
+ * icon found
+ * @brief Scans the theme and any inheriting themes for the given icons
+ */
+static char *
+efreet_icon_list_find_helper(Efreet_Icon_Theme *theme,
+                             Ecore_List *icons, unsigned int size)
+{
+    char *value = NULL;
+    const char *icon = NULL;
+    static int recurse = 0;
+
+    efreet_icon_theme_cache_check(theme);
+
+    /* go no further if this theme is fake */
+    if (theme->fake || !theme->valid) return NULL;
+
+    /* limit recursion in finding themes and inherited themes to 256 levels */
+    if (recurse > 256) return NULL;
+    recurse++;
+
+    ecore_list_first_goto(icons);
+    while ((icon = ecore_list_next(icons)))
+    {
+        value = efreet_icon_lookup_icon(theme, icon, size);
+        if (value && (value != (void *)-1))
+            break;
+    }
+
+    /* we didn't find the image check the inherited themes */
+    if (!value || (value == (void *)-1))
+        value = efreet_icon_list_find_fallback(theme, icons, size);
+
+    recurse--;
+    return value;
+}
+
+/**
+ * @internal
+ * @param theme: The icon theme to look in
+ * @param icon_name: The icon name to look for
+ * @param size: The icon size to look for
+ * @return Returns the path for the theme/icon/size combo or NULL if
+ * none found
+ * @brief Looks for the @a icon in the @a theme for the @a size given.
+ */
+static char *
+efreet_icon_lookup_icon(Efreet_Icon_Theme *theme, const char *icon_name,
+                                                    unsigned int size)
+{
+    char *icon = NULL, *tmp = NULL;
+    Efreet_Icon_Theme_Directory *dir;
+    int minimal_size = INT_MAX;
+
+    if (!theme || (theme->paths.count == 0) || !icon_name || !size)
+        return NULL;
+
+    icon = efreet_icon_cache_check(theme, icon_name, size);
+    if (icon) return icon;
+
+    /* search for allowed size == requested size */
+    ecore_list_first_goto(theme->directories);
+    while ((dir = ecore_list_next(theme->directories)))
+    {
+        if (!efreet_icon_directory_size_match(dir, size)) continue;
+        icon = efreet_icon_lookup_directory(theme, dir,
+                                            icon_name);
+        if (icon)
+        {
+            efreet_icon_cache_add(theme, icon_name, size, icon);
+            return icon;
+        }
+    }
+
+    /* search for any icon that matches */
+    ecore_list_first_goto(theme->directories);
+    while ((dir = ecore_list_next(theme->directories)))
+    {
+        int distance;
+
+        distance = efreet_icon_directory_size_distance(dir, size);
+        if (distance >= minimal_size) continue;
+
+        tmp = efreet_icon_lookup_directory(theme, dir,
+                                           icon_name);
+        if (tmp)
+        {
+            FREE(icon);
+            icon = tmp;
+            minimal_size = distance;
+        }
+    }
+
+    efreet_icon_cache_add(theme, icon_name, size, icon);
+    return icon;
+}
+
+
+/**
+ * @internal
+ * @param theme: The theme to use
+ * @param dir: The theme directory to look in
+ * @param icon_name: The icon name to look for
+ * @return Returns the icon cloest matching the given information or NULL if
+ * none found
+ * @brief Tries to find the file closest matching the given icon
+ */
+static char *
+efreet_icon_lookup_directory(Efreet_Icon_Theme *theme,
+                             Efreet_Icon_Theme_Directory *dir,
+                             const char *icon_name)
+{
+    if (theme->paths.count == 1)
+        return efreet_icon_lookup_directory_helper(dir, theme->paths.path, icon_name);
+
+    else
+    {
+        char *icon;
+        const char *path;
+
+        ecore_list_first_goto(theme->paths.path);
+        while ((path = ecore_list_next(theme->paths.path)))
+        {
+            icon = efreet_icon_lookup_directory_helper(dir, path, icon_name);
+            if (icon) return icon;
+        }
+    }
+
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param dir: The theme directory to work with
+ * @param size: The size to check
+ * @return Returns true if the size matches for the given directory, 0
+ * otherwise
+ * @brief Checks if the size matches for the given directory or not
+ */
+static int
+efreet_icon_directory_size_match(Efreet_Icon_Theme_Directory *dir,
+                                unsigned int size)
+{
+    if (dir->type == EFREET_ICON_SIZE_TYPE_FIXED)
+        return (dir->size.normal == size);
+
+    if (dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE)
+        return ((dir->size.min < size) && (size < dir->size.max));
+
+    if (dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD)
+        return (((dir->size.normal - dir->size.threshold) < size)
+                && (size < (dir->size.normal + dir->size.threshold)));
+
+    return 0;
+}
+
+/**
+ * @internal
+ * @param dir: The directory to work with
+ * @param size: The size to check for
+ * @return Returns the distance this size is away from the desired size
+ * @brief Returns the distance the given size is away from the desired size
+ */
+static int
+efreet_icon_directory_size_distance(Efreet_Icon_Theme_Directory *dir,
+                                    unsigned int size)
+{
+    if (dir->type == EFREET_ICON_SIZE_TYPE_FIXED)
+        return (abs(dir->size.normal - size));
+
+    if (dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE)
+    {
+        if (size < dir->size.min)
+            return dir->size.min - size;
+        if (dir->size.max < size)
+            return size - dir->size.max;
+
+        return 0;
+    }
+
+    if (dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD)
+    {
+        if (size < (dir->size.normal - dir->size.threshold))
+            return (dir->size.min - size);
+        if ((dir->size.normal + dir->size.threshold) < size)
+            return (size - dir->size.max);
+
+        return 0;
+    }
+
+    return 0;
+}
+
+/**
+ * @internal
+ * @param icon_name: The icon name to look for
+ * @return Returns the Efreet_Icon for the given name or NULL if none found
+ * @brief Looks for the un-themed icon in the base directories
+ */
+static char *
+efreet_icon_fallback_icon(const char *icon_name)
+{
+    char *icon;
+
+    if (!icon_name) return NULL;
+    icon = efreet_icon_cache_check(NULL, icon_name, 0);
+    if (icon) return icon;
+
+    icon = efreet_icon_fallback_dir_scan(efreet_icon_deprecated_user_dir_get(), icon_name);
+    if (!icon)
+        icon = efreet_icon_fallback_dir_scan(efreet_icon_user_dir_get(), icon_name);
+    if (!icon)
+    {
+        Ecore_List *xdg_dirs;
+        const char *dir;
+        char path[PATH_MAX];
+
+        ecore_list_first_goto(efreet_extra_icon_dirs);
+        while ((dir = ecore_list_next(efreet_extra_icon_dirs)))
+        {
+            icon = efreet_icon_fallback_dir_scan(dir, icon_name);
+            if (icon)
+            {
+                efreet_icon_cache_add(NULL, icon_name, 0, icon);
+                return icon;
+            }
+        }
+
+        xdg_dirs = efreet_data_dirs_get();
+        ecore_list_first_goto(xdg_dirs);
+        while ((dir = ecore_list_next(xdg_dirs)))
+        {
+            snprintf(path, PATH_MAX, "%s/icons", dir);
+            icon = efreet_icon_fallback_dir_scan(path, icon_name);
+            if (icon)
+            {
+                efreet_icon_cache_add(NULL, icon_name, 0, icon);
+                return icon;
+            }
+        }
+
+        icon = efreet_icon_fallback_dir_scan("/usr/share/pixmaps", icon_name);
+    }
+
+    efreet_icon_cache_add(NULL, icon_name, 0, icon);
+    return icon;
+}
+
+/**
+ * @internal
+ * @param dir: The directory to scan
+ * @param icon_name: The icon to look for
+ * @return Returns the icon for the given name or NULL on failure
+ * @brief Scans the given @a dir for the given @a icon_name returning the
+ * Efreet_icon if found, NULL otherwise.
+ */
+static char *
+efreet_icon_fallback_dir_scan(const char *dir, const char *icon_name)
+{
+    char *icon = NULL;
+    char path[PATH_MAX], *ext;
+    const char *icon_path[] = { dir, "/", icon_name, NULL };
+    size_t size;
+
+    if (!dir || !icon_name) return NULL;
+
+    size = efreet_array_cat(path, sizeof(path), icon_path);
+    ecore_list_first_goto(efreet_icon_extensions);
+    while ((ext = ecore_list_next(efreet_icon_extensions)))
+    {
+        ecore_strlcpy(path + size, ext, sizeof(path) - size);
+
+        if (ecore_file_exists(path))
+        {
+            icon = strdup(path);
+            if (icon) break;
+        }
+        *(path + size) = '\0';
+    }
+    /* This is to catch non-conforming .desktop files */
+#ifdef SLOPPY_SPEC
+    if (!icon)
+    {
+        if (ecore_file_exists(path))
+        {
+            icon = strdup(path);
+#ifdef STRICT_SPEC
+            if (icon)
+                printf("[Efreet]: Found an icon that already has an extension: %s\n", path);
+#endif
+        }
+    }
+#endif
+
+    return icon;
+}
+
+/**
+ * @internal
+ * @param theme: The theme to work with
+ * @param dir: The theme directory to work with
+ * @param path: The partial path to use
+ * @return Returns no value
+ * @brief Caches the icons in the given theme directory path at the given
+ * size
+ */
+static char *
+efreet_icon_lookup_directory_helper(Efreet_Icon_Theme_Directory *dir,
+                                    const char *path, const char *icon_name)
+{
+    char *icon = NULL;
+    char file_path[PATH_MAX];
+    const char *ext, *path_strs[] = { path, "/", dir->name, "/", icon_name, NULL };
+    size_t len;
+
+    len = efreet_array_cat(file_path, sizeof(file_path), path_strs);
+
+    ecore_list_first_goto(efreet_icon_extensions);
+    while ((ext = ecore_list_next(efreet_icon_extensions)))
+    {
+        ecore_strlcpy(file_path + len, ext, sizeof(file_path) - len);
+
+        if (ecore_file_exists(file_path))
+        {
+            icon = strdup(file_path);
+            break;
+        }
+    }
+    return icon;
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Icon struct on success or NULL on failure
+ * @brief Creates a new Efreet_Icon struct
+ */
+static Efreet_Icon *
+efreet_icon_new(const char *path)
+{
+    Efreet_Icon *icon;
+    char *p;
+
+    icon = NEW(Efreet_Icon, 1);
+    icon->path = strdup(path);
+
+    /* load the .icon file if it's available */
+    p = strrchr(icon->path, '.');
+    if (p)
+    {
+        char ico_path[PATH_MAX];
+
+        *p = '\0';
+
+        snprintf(ico_path, sizeof(ico_path), "%s.icon", icon->path);
+        *p = '.';
+
+        if (ecore_file_exists(ico_path))
+            efreet_icon_populate(icon, ico_path);
+    }
+
+    if (!icon->name)
+    {
+        const char *file;
+
+        file = ecore_file_file_get(icon->path);
+        p = strrchr(icon->path, '.');
+        if (p) *p = '\0';
+        icon->name = strdup(file);
+        if (p) *p = '.';
+    }
+
+    return icon;
+}
+
+/**
+ * @param icon: The Efreet_Icon to cleanup
+ * @return Returns no value.
+ * @brief Free's the given icon and all its internal data.
+ */
+EAPI void
+efreet_icon_free(Efreet_Icon *icon)
+{
+    if (!icon) return;
+
+    icon->ref_count --;
+    if (icon->ref_count > 0) return;
+
+    IF_FREE(icon->path);
+    IF_FREE(icon->name);
+    IF_FREE_LIST(icon->attach_points);
+
+    FREE(icon);
+}
+
+/**
+ * @internal
+ * @param point: The Efreet_Icon_Point to free
+ * @return Returns no value
+ * @brief Frees the given structure
+ */
+static void
+efreet_icon_point_free(Efreet_Icon_Point *point)
+{
+    if (!point) return;
+
+    FREE(point);
+}
+
+/**
+ * @internal
+ * @param icon: The icon to populate
+ * @param file: The file to populate from
+ * @return Returns no value
+ * @brief Tries to populate the icon information from the given file
+ */
+static void
+efreet_icon_populate(Efreet_Icon *icon, const char *file)
+{
+    Efreet_Ini *ini;
+    const char *tmp;
+
+    ini = efreet_ini_new(file);
+    if (!ini->data)
+    {
+        efreet_ini_free(ini);
+        return;
+    }
+
+    efreet_ini_section_set(ini, "Icon Data");
+    tmp = efreet_ini_localestring_get(ini, "DisplayName");
+    if (tmp) icon->name = strdup(tmp);
+
+    tmp = efreet_ini_string_get(ini, "EmbeddedTextRectangle");
+    if (tmp)
+    {
+        int points[4];
+        char *t, *s, *p;
+        int i;
+
+        t = strdup(tmp);
+        s = t;
+        for (i = 0; i < 4; i++)
+        {
+            if (s)
+            {
+                p = strchr(s, ',');
+
+                if (p) *p = '\0';
+                points[i] = atoi(s);
+
+                if (p) s = ++p;
+                else s = NULL;
+            }
+            else
+            {
+                points[i] = 0;
+            }
+        }
+
+        icon->has_embedded_text_rectangle = 1;
+        icon->embedded_text_rectangle.x0 = points[0];
+        icon->embedded_text_rectangle.y0 = points[1];
+        icon->embedded_text_rectangle.x1 = points[2];
+        icon->embedded_text_rectangle.y1 = points[3];
+
+        FREE(t);
+    }
+
+    tmp = efreet_ini_string_get(ini, "AttachPoints");
+    if (tmp)
+    {
+        char *t, *s, *p;
+
+        icon->attach_points = ecore_list_new();
+        ecore_list_free_cb_set(icon->attach_points,
+                            ECORE_FREE_CB(efreet_icon_point_free));
+
+        t = strdup(tmp);
+        s = t;
+        p = t;
+        while (s)
+        {
+            Efreet_Icon_Point *point;
+
+            p = strchr(s, ',');
+            /* If this happens there is something wrong with the .icon file */
+            if (!p) break;
+
+            point = NEW(Efreet_Icon_Point, 1);
+
+            *p = '\0';
+            point->x = atoi(s);
+
+            s = ++p;
+            p = strchr(s, '|');
+            if (p) *p = '\0';
+
+            point->y = atoi(s);
+            ecore_list_append(icon->attach_points, point);
+
+            if (p) s = ++p;
+            else s = NULL;
+        }
+        FREE(t);
+    }
+
+    efreet_ini_free(ini);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Icon_Theme on success or NULL on failure
+ * @brief Creates a new Efreet_Icon_Theme structure
+ */
+static Efreet_Icon_Theme *
+efreet_icon_theme_new(void)
+{
+    Efreet_Icon_Theme *theme;
+
+    theme = NEW(Efreet_Icon_Theme, 1);
+
+    return theme;
+}
+
+/**
+ * @internal
+ * @param theme: The theme to free
+ * @return Returns no value
+ * @brief Frees up the @a theme structure.
+ */
+static void
+efreet_icon_theme_free(Efreet_Icon_Theme *theme)
+{
+    if (!theme) return;
+
+    IF_RELEASE(theme->name.internal);
+    IF_RELEASE(theme->name.name);
+
+    IF_FREE(theme->comment);
+    IF_FREE(theme->example_icon);
+
+    if (theme->paths.count == 1)
+        IF_FREE(theme->paths.path);
+    else
+        IF_FREE_LIST(theme->paths.path);
+
+    IF_FREE_LIST(theme->inherits);
+    IF_FREE_LIST(theme->directories);
+
+    FREE(theme);
+}
+
+/**
+ * @internal
+ * @param theme: The theme to work with
+ * @param path: The path to add
+ * @return Returns no value
+ * @brief This will correctly add the given path to the list of theme paths.
+ * @Note Assumes you've already verified that @a path is a valid directory.
+ */
+static void
+efreet_icon_theme_path_add(Efreet_Icon_Theme *theme, const char *path)
+{
+    if (!theme || !path) return;
+
+    if (theme->paths.count == 0)
+        theme->paths.path = strdup(path);
+
+    else if (theme->paths.count > 1)
+        ecore_list_append(theme->paths.path, strdup(path));
+
+    else
+    {
+        char *old;
+
+        old = theme->paths.path;
+        theme->paths.path = ecore_list_new();
+        ecore_list_free_cb_set(theme->paths.path, free);
+
+        ecore_list_append(theme->paths.path, old);
+        ecore_list_append(theme->paths.path, strdup(path));
+    }
+    theme->paths.count++;
+}
+
+/**
+ * @internal
+ * @return Returns no value
+ * @brief This validates that our cache is still valid.
+ *
+ * This is checked by the following algorithm:
+ *   - if we've check less then 5 seconds ago we're good
+ *   - if the mtime on the dir is less then our last check time we're good
+ *   - otherwise, invalidate the caches
+ */
+static void
+efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme)
+{
+    double new_check;
+
+    new_check = ecore_time_get();
+
+    /* we're within 5 seconds of the last time we checked the cache */
+    if ((new_check - 5) <= theme->last_cache_check) return;
+
+    if (theme->fake)
+        efreet_icon_theme_dir_scan_all(theme->name.internal);
+
+    else if (theme->paths.count == 1)
+        efreet_icon_theme_cache_check_dir(theme, theme->paths.path);
+
+    else if (theme->paths.count > 1)
+    {
+        char *path;
+
+        ecore_list_first_goto(theme->paths.path);
+        while ((path = ecore_list_next(theme->paths.path)))
+        {
+            if (!efreet_icon_theme_cache_check_dir(theme, path))
+                break;
+        }
+    }
+    theme->last_cache_check = new_check;
+}
+
+/**
+ * @internal
+ * @param theme: The icon theme to check
+ * @param dir: The directory to check
+ * @return Returns 1 if the cache is still valid, 0 otherwise
+ * @brief This will check if the theme cache is still valid. If it isn't the
+ * cache will be invalided and 0 returned.
+ */
+static int
+efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme, const char *dir)
+{
+    struct stat buf;
+
+    /* have we modified this directory since our last cache check? */
+    if (stat(dir, &buf) || (buf.st_mtime > theme->last_cache_check))
+    {
+        ecore_hash_remove(efreet_icon_cache, theme);
+        return 0;
+    }
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param theme_name: The theme to scan for
+ * @return Returns no value
+ * @brief Scans the theme directories. If @a theme_name is NULL it will load
+ * up all theme data. If @a theme_name is not NULL it will look for that
+ * specific theme data
+ */
+static void
+efreet_icon_theme_dir_scan_all(const char *theme_name)
+{
+    Ecore_List *xdg_dirs;
+    char path[PATH_MAX], *dir;
+
+    efreet_icon_theme_dir_scan(efreet_icon_deprecated_user_dir_get(), theme_name);
+    efreet_icon_theme_dir_scan(efreet_icon_user_dir_get(), theme_name);
+
+    xdg_dirs = efreet_data_dirs_get();
+    ecore_list_first_goto(xdg_dirs);
+    while ((dir = ecore_list_next(xdg_dirs)))
+    {
+        snprintf(path, sizeof(path), "%s/icons", dir);
+        efreet_icon_theme_dir_scan(path, theme_name);
+    }
+
+    efreet_icon_theme_dir_scan("/usr/share/pixmaps", theme_name);
+}
+
+/**
+ * @internal
+ * @param search_dir: The directory to scan
+ * @param theme_name: Scan for this specific theme, set to NULL to find all
+ * themes.
+ * @return Returns no value
+ * @brief Scans the given directory and adds non-hidden icon themes to the
+ * given list. If the theme isnt' in our cache then load the index.theme and
+ * add to the cache.
+ */
+static void
+efreet_icon_theme_dir_scan(const char *search_dir, const char *theme_name)
+{
+    DIR *dirs;
+    struct dirent *dir;
+
+    if (!search_dir) return;
+
+    dirs = opendir(search_dir);
+    if (!dirs) return;
+
+    while ((dir = readdir(dirs)))
+    {
+        Efreet_Icon_Theme *theme;
+        char path[PATH_MAX];
+        const char *key;
+
+        if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) continue;
+
+        /* only care if this is a directory or the theme name matches the
+         * given name */
+        snprintf(path, sizeof(path), "%s/%s", search_dir, dir->d_name);
+        if (((theme_name != NULL) && (strcmp(theme_name, dir->d_name)))
+                || !ecore_file_is_dir(path))
+            continue;
+
+        key = ecore_string_instance(dir->d_name);
+        theme = ecore_hash_get(efreet_icon_themes, key);
+
+        if (!theme)
+        {
+            theme = efreet_icon_theme_new();
+            theme->name.internal = key;
+            ecore_hash_set(efreet_icon_themes,
+                        (void *)theme->name.internal, theme);
+        }
+        else
+        {
+            if (theme->fake)
+                theme->fake = 0;
+            ecore_string_release(key);
+        }
+
+        efreet_icon_theme_path_add(theme, path);
+
+        /* we're already valid so no reason to check for an index.theme file */
+        if (theme->valid) continue;
+
+        /* if the index.theme file exists we parse it into the theme */
+        strncat(path, "/index.theme", sizeof(path));
+        if (ecore_file_exists(path))
+            efreet_icon_theme_index_read(theme, path);
+    }
+    closedir(dirs);
+
+    /* if we were given a theme name we want to make sure that that given
+     * theme is valid before finishing, unless it's a fake theme */
+    if (theme_name)
+    {
+        Efreet_Icon_Theme *theme;
+
+        theme = ecore_hash_get(efreet_icon_themes, theme_name);
+        if (theme && !theme->valid && !theme->fake)
+        {
+            ecore_hash_remove(efreet_icon_themes, theme_name);
+            efreet_icon_theme_free(theme);
+        }
+    }
+}
+
+/**
+ * @internal
+ * @param theme: The theme to set the values into
+ * @param path: The path to the index.theme file for this theme
+ * @return Returns no value
+ * @brief This will load up the theme with the data in the index.theme file
+ */
+static void
+efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path)
+{
+    Efreet_Ini *ini;
+    const char *tmp;
+
+    if (!theme || !path) return;
+
+    ini = efreet_ini_new(path);
+    if (!ini->data)
+    {
+        efreet_ini_free(ini);
+        return;
+    }
+
+    efreet_ini_section_set(ini, "Icon Theme");
+    tmp = efreet_ini_localestring_get(ini, "Name");
+    if (tmp) theme->name.name = ecore_string_instance(tmp);
+
+    tmp = efreet_ini_localestring_get(ini, "Comment");
+    if (tmp) theme->comment = strdup(tmp);
+
+    tmp = efreet_ini_string_get(ini, "Example");
+    if (tmp) theme->example_icon = strdup(tmp);
+
+    theme->hidden = efreet_ini_boolean_get(ini, "Hidden");
+
+    theme->valid = 1;
+
+    /* Check the inheritance. If there is none we inherit from the hicolor theme */
+    tmp = efreet_ini_string_get(ini, "Inherits");
+    if (tmp)
+    {
+        char *t, *s, *p;
+
+        theme->inherits = ecore_list_new();
+        ecore_list_free_cb_set(theme->inherits, free);
+
+        t = strdup(tmp);
+        s = t;
+        p = strchr(s, ',');
+
+        while (p)
+        {
+            *p = '\0';
+
+            ecore_list_append(theme->inherits, strdup(s));
+            s = ++p;
+            p = strchr(s, ',');
+        }
+        ecore_list_append(theme->inherits, strdup(s));
+
+        FREE(t);
+    }
+
+    /* make sure this one is done last as setting the directory will change
+     * the ini section ... */
+    tmp = efreet_ini_string_get(ini, "Directories");
+    if (tmp)
+    {
+        char *t, *s, *p;
+
+        theme->directories = ecore_list_new();
+        ecore_list_free_cb_set(theme->directories,
+                            ECORE_FREE_CB(efreet_icon_theme_directory_free));
+
+        t = strdup(tmp);
+        s = t;
+        p = s;
+
+        while (p)
+        {
+            p = strchr(s, ',');
+
+            if (p) *p = '\0';
+
+            ecore_list_append(theme->directories,
+                            efreet_icon_theme_directory_new(ini, s));
+
+            if (p) s = ++p;
+        }
+
+        FREE(t);
+    }
+
+    efreet_ini_free(ini);
+}
+
+/**
+ * @internal
+ * @return Returns no value
+ * @brief Because the theme icon directories can be spread over multiple
+ * base directories we may need to create the icon theme strucutre before
+ * finding the index.theme file. It may also be that we never find an
+ * index.theme file as this isn't a valid theme. This function makes sure
+ * that everything we've got in our hash has a valid key to it.
+ */
+static void
+efreet_icon_theme_dir_validity_check(void)
+{
+    Ecore_List *keys;
+    const char *name;
+
+    keys = ecore_hash_keys(efreet_icon_themes);
+    ecore_list_first_goto(keys);
+    while ((name = ecore_list_next(keys)))
+    {
+        Efreet_Icon_Theme *theme;
+
+        theme = ecore_hash_get(efreet_icon_themes, name);
+        if (!theme->valid && !theme->fake)
+        {
+            ecore_hash_remove(efreet_icon_themes, name);
+            efreet_icon_theme_free(theme);
+        }
+    }
+    ecore_list_destroy(keys);
+}
+
+/**
+ * @internal
+ * @param ini: The ini file with information on this directory
+ * @param name: The name of the directory
+ * @return Returns a new Efreet_Icon_Theme_Directory based on the
+ * information in @a ini.
+ * @brief Creates and initialises an icon theme directory from the given ini
+ * information
+ */
+static Efreet_Icon_Theme_Directory *
+efreet_icon_theme_directory_new(Efreet_Ini *ini, const char *name)
+{
+    Efreet_Icon_Theme_Directory *dir;
+    int val;
+    const char *tmp;
+
+    if (!ini) return NULL;
+
+    dir = NEW(Efreet_Icon_Theme_Directory, 1);
+    dir->name = strdup(name);
+
+    efreet_ini_section_set(ini, name);
+
+    tmp = efreet_ini_string_get(ini, "Context");
+    if (tmp)
+    {
+        if (!strcasecmp(tmp, "Actions"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_ACTIONS;
+
+        else if (!strcasecmp(tmp, "Devices"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_DEVICES;
+
+        else if (!strcasecmp(tmp, "FileSystems"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_FILESYSTEMS;
+
+        else if (!strcasecmp(tmp, "MimeTypes"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_MIMETYPES;
+    }
+
+    tmp = efreet_ini_string_get(ini, "Type");
+    if (tmp)
+    {
+        if (!strcasecmp(tmp, "Fixed"))
+            dir->type = EFREET_ICON_SIZE_TYPE_FIXED;
+
+        else if (!strcasecmp(tmp, "Scalable"))
+            dir->type = EFREET_ICON_SIZE_TYPE_SCALABLE;
+
+        else if (!strcasecmp(tmp, "Threshold"))
+            dir->type = EFREET_ICON_SIZE_TYPE_THRESHOLD;
+    }
+
+    dir->size.normal = efreet_ini_int_get(ini, "Size");
+
+    val = efreet_ini_int_get(ini, "MinSize");
+    if (val < 0) dir->size.min = dir->size.normal;
+    else dir->size.min = val;
+
+    val = efreet_ini_int_get(ini, "MaxSize");
+    if (val < 0) dir->size.max = dir->size.normal;
+    else dir->size.max = val;
+
+    val = efreet_ini_int_get(ini, "Threshold");
+    if (val < 0) dir->size.threshold = 2;
+    else dir->size.threshold = val;
+
+    return dir;
+}
+
+/**
+ * @internal
+ * @param dir: The Efreet_Icon_Theme_Directory to free
+ * @return Returns no value
+ * @brief Frees the given directory @a dir
+ */
+static void
+efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir)
+{
+    if (!dir) return;
+
+    IF_FREE(dir->name);
+    FREE(dir);
+}
+
+static int
+efreet_icon_cache_find(Efreet_Icon_Cache *value, const char *key)
+{
+    if (!value || !key) return -1;
+    return strcmp(value->key, key);
+}
+
+static void
+efreet_icon_cache_flush(Ecore_List *list)
+{
+    /* TODO:
+     * * Dynamic cache size
+     * * Maybe add references to cache, so that we sort on how often a value is used
+     */
+    while (ecore_list_count(list) > 100)
+    {
+        Efreet_Icon_Cache *cache;
+
+        cache = ecore_list_last_remove(list);
+        efreet_icon_cache_free(cache);
+    }
+}
+
+static void
+efreet_icon_cache_free(Efreet_Icon_Cache *value)
+{
+    if (!value) return;
+
+    IF_FREE(value->key);
+    IF_FREE(value->path);
+    free(value);
+}
+
+static char *
+efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int size)
+{
+    Ecore_List *list;
+    Efreet_Icon_Cache *cache;
+    char key[4096];
+    struct stat st;
+
+    list = ecore_hash_get(efreet_icon_cache, theme);
+    if (!list)
+    {
+        list = ecore_list_new();
+        ecore_list_free_cb_set(list, ECORE_FREE_CB(efreet_icon_cache_free));
+        ecore_hash_set(efreet_icon_cache, theme, list);
+        return NULL;
+    }
+
+    snprintf(key, sizeof(key), "%s %d", icon, size);
+    cache = ecore_list_find(list, ECORE_COMPARE_CB(efreet_icon_cache_find), key);
+    if (cache)
+    {
+        ecore_list_remove(list);
+        if (!cache->path)
+        {
+            ecore_list_prepend(list, cache);
+            return (void *)-1;
+        }
+        else if (!stat(cache->path, &st) && st.st_mtime == cache->lasttime)
+        {
+            ecore_list_prepend(list, cache);
+            return strdup(cache->path);
+        }
+        efreet_icon_cache_free(cache);
+    }
+    return NULL;
+}
+
+static void
+efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int size, const char *value)
+{
+    Ecore_List *list;
+    Efreet_Icon_Cache *cache;
+    char key[4096];
+    struct stat st;
+
+    list = ecore_hash_get(efreet_icon_cache, theme);
+    if (!list)
+    {
+        list = ecore_list_new();
+        ecore_list_free_cb_set(list, ECORE_FREE_CB(efreet_icon_cache_free));
+        ecore_hash_set(efreet_icon_cache, theme, list);
+    }
+
+    snprintf(key, sizeof(key), "%s %d", icon, size);
+    cache = NEW(Efreet_Icon_Cache, 1);
+    cache->key = strdup(key);
+    if ((value) && !stat(value, &st))
+    {
+        cache->path = strdup(value);
+        cache->lasttime = st.st_mtime;
+    }
+    else
+        cache->lasttime = ecore_time_get();
+    ecore_list_prepend(list, cache);
+    efreet_icon_cache_flush(list);
+}
diff --git a/src/lib/efreet_icon.h b/src/lib/efreet_icon.h
new file mode 100644 (file)
index 0000000..118307e
--- /dev/null
@@ -0,0 +1,182 @@
+/* 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 */
+
+    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 */
+};
+
+EAPI const char        *efreet_icon_user_dir_get(void);
+EAPI void               efreet_icon_extension_add(const char *ext);
+
+EAPI Ecore_List        *efreet_icon_extra_list_get(void);
+EAPI Ecore_List        *efreet_icon_theme_list_get(void);
+EAPI Efreet_Icon_Theme *efreet_icon_theme_find(const char *theme_name);
+EAPI Efreet_Icon       *efreet_icon_find(const char *theme_name,
+                                            const char *icon,
+                                            unsigned int size);
+EAPI char              *efreet_icon_list_find(const char *theme_name,
+                                                Ecore_List *icons,
+                                                unsigned int size);
+EAPI char              *efreet_icon_path_find(const char *theme_name,
+                                                const char *icon,
+                                                unsigned int size);
+EAPI void               efreet_icon_free(Efreet_Icon *icon);
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_ini.c b/src/lib/efreet_ini.c
new file mode 100644 (file)
index 0000000..bf21e1c
--- /dev/null
@@ -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;
+}
+
+/**
+ * @param file: The file to parse
+ * @return Returns a new Efreet_Ini structure initialized with the contents
+ * of @a file, or NULL on memory allocation failure
+ * @brief Creates and initializes a new Ini structure with the contents of
+ * @a file, or NULL on failure
+ */
+EAPI Efreet_Ini *
+efreet_ini_new(const char *file)
+{
+    Efreet_Ini *ini;
+
+    ini = NEW(Efreet_Ini, 1);
+    if (!ini) return NULL;
+
+    /* This can validly be NULL at the moment as _parse() will return NULL
+     * if the input file doesn't exist. Should we change _parse() to create
+     * the hash and only return NULL on failed parse? */
+    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 if the
+ *         file fails to parse or if the file doesn't exist
+ * @brief Parses the ini file @a file into an Ecore_Hash
+ */
+static Ecore_Hash *
+efreet_ini_parse(const char *file)
+{
+    const char *buffer, *line_start;
+    FILE *f;
+    Ecore_Hash *data, *section = NULL;
+    struct stat file_stat;
+    int line_length, left;
+
+    f = fopen(file, "rb");
+    if (!f) return NULL;
+
+    if (fstat(fileno(f), &file_stat) || (file_stat.st_size < 1))
+    {
+        fclose(f);
+        return NULL;
+    }
+    if (!S_ISREG(file_stat.st_mode)) /* if not a regular file - close */
+    {
+        fclose(f);
+        return NULL;
+    }
+
+    left = file_stat.st_size;
+    buffer = mmap(NULL, left, PROT_READ, MAP_SHARED, fileno(f), 0);
+    if (buffer == MAP_FAILED)
+    {
+        fclose(f);
+        return NULL;
+    }
+
+    data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(data, ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_value_cb_set(data, ECORE_FREE_CB(ecore_hash_destroy));
+
+    line_start = buffer;
+    while (left > 0)
+    {
+        int sep;
+
+        /* find the end of line */
+        for (line_length = 0; 
+                (line_length < left) && 
+                (line_start[line_length] != '\n'); line_length++)
+            ;
+
+        /* check for all white space */
+        while (isspace(line_start[0]) && (line_length > 0))
+        {
+            line_start++;
+            line_length--;
+        }
+
+        /* skip empty lines and comments */
+        if ((line_length == 0) || (line_start[0] == '\r') || 
+                (line_start[0] == '\n') || (line_start[0] == '#') ||
+                (line_start[0] == '\0')) 
+            goto next_line;
+
+        /* new section */
+        if (line_start[0] == '[')
+        {
+            int header_length;
+
+            /* find the ']' */
+            for (header_length = 1; 
+                    (header_length < line_length) && 
+                    (line_start[header_length] != ']'); ++header_length)
+                ;
+
+            if (line_start[header_length] == ']')
+            {
+                Ecore_Hash *old;
+                const char *header;
+
+                header = alloca(header_length * sizeof(unsigned char));
+                if (!header) goto next_line;
+
+                memcpy((char*)header, line_start + 1, header_length - 1);
+                ((char*)header)[header_length - 1] = '\0';
+
+                section = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+                ecore_hash_free_key_cb_set(section,
+                            ECORE_FREE_CB(ecore_string_release));
+                ecore_hash_free_value_cb_set(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;
+        }
+
+        if (section == NULL)
+        {
+//            printf("Invalid file (%s) (missing section)\n", file);
+            goto next_line;
+        }
+
+        /* find for '=' */
+        for (sep = 0; (sep < line_length) && (line_start[sep] != '='); ++sep)
+            ;
+
+        if (sep < line_length)
+        {
+            const char *key, *value;
+            char *old;
+            int key_end, value_start, value_end;
+
+            /* trim whitespace from end of key */
+            for (key_end = sep - 1; 
+                    (key_end > 0) && isspace(line_start[key_end]); --key_end)
+                ;
+
+            if (!isspace(line_start[key_end])) key_end++;
+
+            /* trim whitespace from start of value */
+            for (value_start = sep + 1; 
+                    (value_start < line_length) && 
+                    isspace(line_start[value_start]); ++value_start)
+                ;
+
+            /* trim \n off of end of value */
+            for (value_end = line_length; 
+                    (value_end > value_start) &&
+                    ((line_start[value_end] == '\n') ||
+                        (line_start[value_end] == '\r')); --value_end)
+                ;
+
+            if (line_start[value_end] != '\n'
+                    && line_start[value_end] != '\r'
+                    && value_end < line_length)
+                value_end++;
+
+            /* make sure we have a key. blank values are allowed */
+            if (key_end == 0)
+            {
+                /* invalid file... */
+//                printf("Invalid file (%s) (invalid key=value pair)\n", file);
+
+                goto next_line;
+            }
+
+            key = alloca((key_end + 1) * sizeof(unsigned char));
+            value = alloca((value_end - value_start + 1) * sizeof(unsigned char));
+            if (!key || !value) goto next_line;
+
+            memcpy((char*)key, line_start, key_end);
+            ((char*)key)[key_end] = '\0';
+
+            memcpy((char*)value, line_start + value_start, 
+                    value_end - value_start);
+            ((char*)value)[value_end - value_start] = '\0';
+
+            old = ecore_hash_remove(section, key);
+            IF_FREE(old);
+
+            ecore_hash_set(section, (void *)ecore_string_instance(key),
+                           efreet_ini_unescape(value));
+        }
+//        else
+//        {
+//            /* invalid file... */
+//            printf("Invalid file (%s) (missing = from key=value pair)\n", file);
+//        }
+
+next_line:
+        left -= line_length + 1;
+        line_start += line_length + 1;
+    }
+    munmap((char*) buffer, file_stat.st_size);
+    fclose(f);
+
+    return data;
+}
+
+/**
+ * @param ini: The Efreet_Ini to work with
+ * @return Returns no value
+ * @brief Frees the given Efree_Ini structure.
+ */
+EAPI void
+efreet_ini_free(Efreet_Ini *ini)
+{
+    if (!ini) return;
+
+    IF_FREE_HASH(ini->data);
+    FREE(ini);
+}
+
+/**
+ * @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.
+ */
+EAPI int
+efreet_ini_save(Efreet_Ini *ini, const char *file)
+{
+    FILE *f;
+    if (!ini || !ini->data) return 0;
+
+    f = fopen(file, "wb");
+    if (!f) return 0;
+    ecore_hash_for_each_node(ini->data, ECORE_FOR_EACH(efreet_ini_section_save), f);
+    fclose(f);
+
+    return 1;
+}
+
+/**
+ * @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
+ */
+EAPI int
+efreet_ini_section_set(Efreet_Ini *ini, const char *section)
+{
+    if (!ini || !ini->data || !section) return 0;
+
+    ini->section = ecore_hash_get(ini->data, section);
+    return (ini->section ? 1 : 0);
+}
+
+/**
+ * @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
+ */
+EAPI 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_free_key_cb_set(ini->data, ECORE_FREE_CB(ecore_string_release));
+        ecore_hash_free_value_cb_set(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_free_key_cb_set(hash, ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_value_cb_set(hash, ECORE_FREE_CB(free));
+    ecore_hash_set(ini->data, (void *)ecore_string_instance(section), hash);
+}
+
+/**
+ * @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.
+ */
+EAPI 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);
+}
+
+/**
+ * @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
+ */
+EAPI 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));
+}
+
+/**
+ * @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.
+ */
+EAPI 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;
+}
+
+/**
+ * @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
+ */
+EAPI 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);
+}
+
+/**
+ * @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.
+ */
+EAPI 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;
+}
+
+/**
+ * @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
+ */
+EAPI 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);
+}
+
+/**
+ * @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
+ */
+EAPI 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;
+}
+
+/**
+ * @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
+ */
+EAPI 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");
+}
+
+/**
+ * @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
+ */
+EAPI 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 && (*val != '\0')) found = 1;
+    }
+
+    if (!found && lang && country)
+    {
+        snprintf(buf, maxlen, "%s[%s_%s]", key, lang, country);
+        val = efreet_ini_string_get(ini, buf);
+        if (val && (*val != '\0')) found = 1;
+    }
+
+    if (!found && lang && modifier)
+    {
+        snprintf(buf, maxlen, "%s[%s@%s]", key, lang, modifier);
+        val = efreet_ini_string_get(ini, buf);
+        if (val && (*val != '\0')) found = 1;
+    }
+
+    if (!found && lang)
+    {
+        snprintf(buf, maxlen, "%s[%s]", key, lang);
+        val = efreet_ini_string_get(ini, buf);
+        if (val && (*val != '\0')) found = 1;
+    }
+
+    if (!found)
+        val = efreet_ini_string_get(ini, key);
+
+    FREE(buf);
+
+    return val;
+}
+
+/**
+ * @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
+ */
+EAPI 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[1] != '\0'))
+        {
+            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);
+}
diff --git a/src/lib/efreet_ini.h b/src/lib/efreet_ini.h
new file mode 100644 (file)
index 0000000..b6614c1
--- /dev/null
@@ -0,0 +1,59 @@
+/* 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 */
+};
+
+EAPI Efreet_Ini  *efreet_ini_new(const char *file);
+EAPI void         efreet_ini_free(Efreet_Ini *ini);
+EAPI int          efreet_ini_save(Efreet_Ini *ini, const char *path);
+
+EAPI int          efreet_ini_section_set(Efreet_Ini *ini, const char *section);
+EAPI void         efreet_ini_section_add(Efreet_Ini *ini, const char *section);
+
+EAPI const char  *efreet_ini_string_get(Efreet_Ini *ini, const char *key);
+EAPI void         efreet_ini_string_set(Efreet_Ini *ini, const char *key,
+                                                    const char *value);
+
+EAPI const char  *efreet_ini_localestring_get(Efreet_Ini *ini, const char *key);
+EAPI void         efreet_ini_localestring_set(Efreet_Ini *ini, const char *key,
+                                                    const char *value);
+
+EAPI unsigned int efreet_ini_boolean_get(Efreet_Ini *ini, const char *key);
+EAPI void         efreet_ini_boolean_set(Efreet_Ini *ini, const char *key,
+                                                    unsigned int value);
+
+EAPI int          efreet_ini_int_get(Efreet_Ini *ini, const char *key);
+EAPI void         efreet_ini_int_set(Efreet_Ini *ini, const char *key, int value);
+
+EAPI double       efreet_ini_double_get(Efreet_Ini *ini, const char *key);
+EAPI void         efreet_ini_double_set(Efreet_Ini *ini, const char *key,
+                                                    double value);
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_menu.c b/src/lib/efreet_menu.c
new file mode 100644 (file)
index 0000000..52ec22e
--- /dev/null
@@ -0,0 +1,3931 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "efreet_private.h"
+
+/**
+ * Efreet_Menu_Move
+ */
+typedef struct Efreet_Menu_Move Efreet_Menu_Move;
+
+/**
+ * Efreet_Menu_Move
+ * Info on a menu movement
+ */
+struct Efreet_Menu_Move
+{
+    char *old_name;     /**< The menu path to move from */
+    char *new_name;     /**< The menu path to move too */
+};
+
+/**
+ * Efreet_Menu_Internal
+ */
+typedef struct Efreet_Menu_Internal Efreet_Menu_Internal;
+
+/**
+ * Efreet_Menu_Internal
+ * Contains the information about a menu
+ */
+struct Efreet_Menu_Internal
+{
+    struct
+    {
+        char *path;         /**< The base file path */
+        char *name;         /**< The filename for this menu */
+    } file;                 /**< The menu file information */
+
+    struct
+    {
+        const char *internal;     /**< The menu name */
+        const char *name;         /**< Name to use in the menus */
+    } name;                       /**< The names for this menu */
+
+    Efreet_Desktop *directory; /**< The directory */
+    Ecore_DList *directories;  /**< All the directories set in the menu file */
+
+    Efreet_Menu_Move *current_move; /**< The current move */
+
+    Ecore_List *app_dirs;           /**< .desktop application directories */
+
+    Ecore_List *app_pool;           /**< application pool */
+    Ecore_List *applications;       /**< applications in this menu */
+
+    Ecore_DList *directory_dirs;    /**< .directory file directories */
+    Ecore_Hash *directory_cache;    /**< .directory dirs */
+
+    Ecore_List *moves;              /**< List of moves to be handled by the menu */
+    Ecore_List *filters;            /**< Include and Exclude filters */
+
+    Efreet_Menu_Internal *parent;   /**< Our parent menu */
+    Ecore_List *sub_menus;          /**< Our sub menus */
+
+    Ecore_List *layout;             /**< This menus layout */
+    Ecore_List *default_layout;     /**< Default layout */
+    char show_empty;    /**< Whether to show empty menus */
+    char in_line;       /**< Whether this meny can be inlined */
+    char inline_limit;  /**< Number of elements which triggers inline */
+    char inline_header; /**< Whether we should use the header name when this menu is inlined */
+    char inline_alias;  /**< Whether we should use the menu name when inlining */
+
+    unsigned char seen_allocated:1;     /**< have we set the only_unallocated */
+    unsigned char only_unallocated:1;   /**< Show only unallocated .desktops */
+
+    unsigned char seen_deleted:1;       /**< Have we seen the deleted item yet */
+    unsigned char deleted:1;            /**< The menu is deleted */
+};
+
+/**
+ * Efreet_Menu_App_Dir
+ */
+typedef struct Efreet_Menu_App_Dir Efreet_Menu_App_Dir;
+
+/**
+ * Holds information on an app dir
+ */
+struct Efreet_Menu_App_Dir
+{
+    char *path;                 /**< directory path */
+    char *prefix;               /**< If it's legacy it can have a prefix */
+    unsigned int legacy:1;      /**< is this a legacy dir */
+};
+
+/**
+ * The type of operations we can perform with a filter
+ */
+enum Efreet_Menu_Filter_Op_Type
+{
+    EFREET_MENU_FILTER_OP_OR,
+    EFREET_MENU_FILTER_OP_AND,
+    EFREET_MENU_FILTER_OP_NOT
+};
+
+/**
+ * Efreet_Menu_Filter_Op_Type
+ */
+typedef enum Efreet_Menu_Filter_Op_Type Efreet_Menu_Filter_Op_Type;
+
+/**
+ * The type of filter
+ */
+enum Efreet_Menu_Filter_Type
+{
+    EFREET_MENU_FILTER_INCLUDE,
+    EFREET_MENU_FILTER_EXCLUDE
+};
+
+/**
+ * Efreet_Menu_Filter_Type
+ */
+typedef enum Efreet_Menu_Filter_Type Efreet_Menu_Filter_Type;
+
+/**
+ * Efreet_Menu_Filter_Op
+ */
+typedef struct Efreet_Menu_Filter_Op Efreet_Menu_Filter_Op;
+
+/**
+ * Efreet_Menu_Filter_Op
+ * Contains information on a filter operation
+ */
+struct Efreet_Menu_Filter_Op
+{
+    Efreet_Menu_Filter_Op_Type type; /**< The type of operation */
+    Ecore_List *categories;          /**< The categories this op applies too */
+    Ecore_List *filenames;           /**< The filenames this op applies too */
+
+    Ecore_List *filters;             /**< Child filters */
+
+    unsigned char all:1;             /**< Applies to all .desktop files */
+};
+
+/**
+ * Efreet_Menu_Filter
+ */
+typedef struct Efreet_Menu_Filter Efreet_Menu_Filter;
+
+/**
+ * Efreet_Menu_Filter
+ * Stores information on a filter
+ */
+struct Efreet_Menu_Filter
+{
+    Efreet_Menu_Filter_Type type;   /**< The type of filter */
+    Efreet_Menu_Filter_Op *op;      /**< The filter operations */
+};
+
+/**
+ * The type of layout
+ */
+enum Efreet_Menu_Layout_Type
+{
+    EFREET_MENU_LAYOUT_MENUNAME,
+    EFREET_MENU_LAYOUT_FILENAME,
+    EFREET_MENU_LAYOUT_SEPARATOR,
+    EFREET_MENU_LAYOUT_MERGE
+};
+
+/**
+ * Efreet_Menu_Layout_Type
+ */
+typedef enum Efreet_Menu_Layout_Type Efreet_Menu_Layout_Type;
+
+/**
+ * Efreet_Menu_Layout
+ */
+typedef struct Efreet_Menu_Layout Efreet_Menu_Layout;
+
+/**
+ * Efreet_Menu_Layout
+ * Stores information on a layout
+ */
+struct Efreet_Menu_Layout
+{
+    Efreet_Menu_Layout_Type  type;   /**< The type of layout */
+    char *name;                      /**< The name of the element */
+
+    /* The items below are for Menuname Layout elements */
+    char show_empty;    /**< Whether to show empty menus */
+    char in_line;       /**< Whether this meny can be inlined */
+    char inline_limit;  /**< Number of elements which triggers inline */
+    char inline_header; /**< Whether we should use the header name when this menu is inlined */
+    char inline_alias;  /**< Whether we should use the menu name when inlining */
+};
+
+/**
+ * Efreet_Menu_Desktop
+ */
+typedef struct Efreet_Menu_Desktop Efreet_Menu_Desktop;
+
+/**
+ * Efreet_Menu_Desktop
+ * Stores information on a desktop for the menu
+ */
+struct Efreet_Menu_Desktop
+{
+    Efreet_Desktop *desktop;   /**< The desktop we refer too */
+    const char *id;            /**< The desktop file id */
+    unsigned char allocated:1; /**< If this desktop has been allocated */
+};
+
+static char *efreet_menu_prefix = NULL; /**< The $XDG_MENU_PREFIX env var */
+Ecore_List *efreet_menu_kde_legacy_dirs = NULL; /**< The directories to use for KDELegacy entries */
+static const char *efreet_tag_menu = NULL;
+
+static Ecore_Hash *efreet_merged_menus = NULL;
+static Ecore_Hash *efreet_merged_dirs = NULL;
+
+static Ecore_Hash *efreet_menu_handle_cbs = NULL;
+static Ecore_Hash *efreet_menu_filter_cbs = NULL;
+static Ecore_Hash *efreet_menu_move_cbs = NULL;
+static Ecore_Hash *efreet_menu_layout_cbs = NULL;
+
+static const char *efreet_menu_prefix_get(void);
+
+static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal,
+                                                    const char *name,
+                                                    Efreet_Menu_Internal **parent);
+static int efreet_menu_cb_compare_names(Efreet_Menu_Internal *internal, const char *name);
+static int efreet_menu_cb_md_compare_ids(Efreet_Menu_Desktop *md, const char *name);
+
+static int efreet_menu_cb_entry_compare_menu(Efreet_Menu *entry, Efreet_Menu_Internal *internal);
+static int efreet_menu_cb_entry_compare_desktop(Efreet_Menu *entry, Efreet_Desktop *desktop);
+
+static int efreet_menu_cb_move_compare(Efreet_Menu_Move *move, const char *old);
+
+static int efreet_menu_process(Efreet_Menu_Internal *internal, unsigned int only_unallocated);
+static int efreet_menu_process_dirs(Efreet_Menu_Internal *internal);
+static int efreet_menu_app_dirs_process(Efreet_Menu_Internal *internal);
+static int efreet_menu_app_dir_scan(Efreet_Menu_Internal *internal,
+                                        const char *path,
+                                        const char *id,
+                                        int legacy);
+static int efreet_menu_directory_dirs_process(Efreet_Menu_Internal *internal);
+static int efreet_menu_directory_dir_scan(const char *path,
+                                            const char *relative_path,
+                                            Ecore_Hash *cache);
+static Efreet_Desktop *efreet_menu_directory_get(Efreet_Menu_Internal *internal,
+                                                    const char *path);
+static void efreet_menu_process_filters(Efreet_Menu_Internal *internal,
+                                            unsigned int only_unallocated);
+static void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications,
+                                        Ecore_Hash *matches,
+                                        Efreet_Menu_Filter *filter,
+                                        unsigned int only_unallocated);
+static int efreet_menu_filter_matches(Efreet_Menu_Filter_Op *op,
+                                        Efreet_Menu_Desktop *md);
+static int efreet_menu_filter_or_matches(Efreet_Menu_Filter_Op *op,
+                                            Efreet_Menu_Desktop *md);
+static int efreet_menu_filter_and_matches(Efreet_Menu_Filter_Op *op,
+                                            Efreet_Menu_Desktop *md);
+static int efreet_menu_filter_not_matches(Efreet_Menu_Filter_Op *op,
+                                            Efreet_Menu_Desktop *md);
+
+static Efreet_Menu *efreet_menu_layout_menu(Efreet_Menu_Internal *internal);
+static Efreet_Menu *efreet_menu_layout_desktop(Efreet_Menu_Desktop *md);
+static void efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *internal,
+                                            Efreet_Menu_Layout *layout);
+static int efreet_menu_layout_is_empty(Efreet_Menu *entry);
+
+static Efreet_Menu_Internal *efreet_menu_internal_new(void);
+static void efreet_menu_internal_free(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_sub_menu_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_app_dirs_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_directory_dirs_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_directories_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_move_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_filter_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_layout_list(Efreet_Menu_Internal *internal);
+static void efreet_menu_create_default_layout_list(Efreet_Menu_Internal *internal);
+static char *efreet_menu_path_get(Efreet_Menu_Internal *internal, const char *suffix);
+
+static Efreet_Menu_App_Dir *efreet_menu_app_dir_new(void);
+static void efreet_menu_app_dir_free(Efreet_Menu_App_Dir *dir);
+
+static Efreet_Menu_Move *efreet_menu_move_new(void);
+static void efreet_menu_move_free(Efreet_Menu_Move *move);
+
+static Efreet_Menu_Filter *efreet_menu_filter_new(void);
+static void efreet_menu_filter_free(Efreet_Menu_Filter *filter);
+
+static Efreet_Menu_Layout *efreet_menu_layout_new(void);
+static void efreet_menu_layout_free(Efreet_Menu_Layout *layout);
+
+static Efreet_Menu_Filter_Op *efreet_menu_filter_op_new(void);
+static void efreet_menu_filter_op_free(Efreet_Menu_Filter_Op *op);
+
+static Efreet_Menu_Desktop *efreet_menu_desktop_new(void);
+static void efreet_menu_desktop_free(Efreet_Menu_Desktop *md);
+
+static Efreet_Menu *efreet_menu_entry_new(void);
+
+static int efreet_menu_handle_menu(Efreet_Menu_Internal *internal, Efreet_Xml *xml);
+static int efreet_menu_handle_name(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+
+static int efreet_menu_handle_sub_menu(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_app_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_default_app_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_directory_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_directory(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_only_unallocated(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_not_only_unallocated(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_deleted(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_not_deleted(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_include(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_exclude(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_filename(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_category(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_all(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_and(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_or(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_not(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_default_merge_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_legacy_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static Efreet_Menu_Internal *efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root,
+                                                Efreet_Menu_Internal *parent,
+                                                const char *legacy_dir,
+                                                const char *prefix);
+static int efreet_menu_handle_kde_legacy_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_move(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_old(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_new(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+static int efreet_menu_handle_default_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+
+static int efreet_menu_handle_filter(Efreet_Menu_Internal *parent, Efreet_Xml *xml,
+                                                    Efreet_Menu_Filter_Type type);
+static int efreet_menu_handle_filter_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+static int efreet_menu_handle_filter_child_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml,
+                                                      Efreet_Menu_Filter_Op_Type type);
+
+static int efreet_menu_handle_layout_menuname(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+static int efreet_menu_handle_layout_filename(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+static int efreet_menu_handle_layout_separator(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+static int efreet_menu_handle_layout_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+
+static int efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *path);
+static int efreet_menu_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *path);
+
+static int efreet_menu_cb_app_dirs_compare(Efreet_Menu_App_Dir *a, const char *b);
+
+static void efreet_menu_resolve_moves(Efreet_Menu_Internal *internal);
+static void efreet_menu_concatenate(Efreet_Menu_Internal *dest, Efreet_Menu_Internal *src);
+
+static int efreet_menu_cb_menu_compare(Efreet_Menu_Internal *a, Efreet_Menu_Internal *b);
+static int efreet_menu_cb_md_compare(Efreet_Menu_Desktop *a, Efreet_Menu_Desktop *b);
+
+static int efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent);
+static int efreet_menu_save_indent(FILE *f, int indent);
+
+static void efreet_menu_path_set(Efreet_Menu_Internal *internal, const char *path);
+
+/**
+ * @return Returns 1 on success, 0 on failure
+ * @brief Initializes the Efreet Menu system.
+ */
+int
+efreet_menu_init(void)
+{
+    int i;
+
+    struct
+    {
+        char *key;
+        int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+    } menu_cbs[] = {
+        {"Menu", efreet_menu_handle_sub_menu},
+        {"AppDir", efreet_menu_handle_app_dir},
+        {"DefaultAppDirs", efreet_menu_handle_default_app_dirs},
+        {"DirectoryDir", efreet_menu_handle_directory_dir},
+        {"DefaultDirectoryDirs", efreet_menu_handle_default_directory_dirs},
+        {"Name", efreet_menu_handle_name},
+        {"Directory", efreet_menu_handle_directory},
+        {"OnlyUnallocated", efreet_menu_handle_only_unallocated},
+        {"NotOnlyUnallocated", efreet_menu_handle_not_only_unallocated},
+        {"Deleted", efreet_menu_handle_deleted},
+        {"NotDeleted", efreet_menu_handle_not_deleted},
+        {"Include", efreet_menu_handle_include},
+        {"Exclude", efreet_menu_handle_exclude},
+        {"MergeFile", efreet_menu_handle_merge_file},
+        {"MergeDir", efreet_menu_handle_merge_dir},
+        {"DefaultMergeDirs", efreet_menu_handle_default_merge_dirs},
+        {"LegacyDir", efreet_menu_handle_legacy_dir},
+        {"KDELegacyDirs", efreet_menu_handle_kde_legacy_dirs},
+        {"Move", efreet_menu_handle_move},
+        {"Layout", efreet_menu_handle_layout},
+        {"DefaultLayout", efreet_menu_handle_default_layout},
+        {NULL, NULL}
+    };
+
+    struct
+    {
+        char *key;
+        int (*cb)(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+    } filter_cbs[] = {
+        {"Filename", efreet_menu_handle_filename},
+        {"Category", efreet_menu_handle_category},
+        {"All", efreet_menu_handle_all},
+        {"And", efreet_menu_handle_and},
+        {"Or", efreet_menu_handle_or},
+        {"Not", efreet_menu_handle_not},
+        {NULL, NULL}
+    };
+
+    struct
+    {
+        char *key;
+        int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+    } move_cbs[] = {
+        {"Old", efreet_menu_handle_old},
+        {"New", efreet_menu_handle_new},
+        {NULL, NULL}
+    };
+
+    struct
+    {
+        char *key;
+        int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+    } layout_cbs[] = {
+        {"Menuname", efreet_menu_handle_layout_menuname},
+        {"Filename", efreet_menu_handle_layout_filename},
+        {"Separator", efreet_menu_handle_layout_separator},
+        {"Merge", efreet_menu_handle_layout_merge},
+        {NULL, NULL}
+    };
+
+    if (!ecore_string_init()) return 0;
+    if (!efreet_xml_init()) return 0;
+
+    efreet_menu_handle_cbs = ecore_hash_new(NULL, NULL);
+    efreet_menu_filter_cbs = ecore_hash_new(NULL, NULL);
+    efreet_menu_move_cbs = ecore_hash_new(NULL, NULL);
+    efreet_menu_layout_cbs = ecore_hash_new(NULL, NULL);
+    if (!efreet_menu_handle_cbs || !efreet_menu_filter_cbs
+            || !efreet_menu_move_cbs || !efreet_menu_layout_cbs)
+        return 0;
+
+    ecore_hash_free_key_cb_set(efreet_menu_handle_cbs,
+                        ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_key_cb_set(efreet_menu_filter_cbs,
+                        ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_key_cb_set(efreet_menu_move_cbs,
+                        ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_key_cb_set(efreet_menu_layout_cbs,
+                        ECORE_FREE_CB(ecore_string_release));
+
+    /* set Menu into it's own so we can check the XML is valid before trying
+     * to handle it */
+    efreet_tag_menu = ecore_string_instance(menu_cbs[0].key);
+
+    for (i = 0; menu_cbs[i].key != NULL; i++)
+        ecore_hash_set(efreet_menu_handle_cbs,
+                        (void *)ecore_string_instance(menu_cbs[i].key),
+                        menu_cbs[i].cb);
+
+    for (i = 0; filter_cbs[i].key != NULL; i++)
+        ecore_hash_set(efreet_menu_filter_cbs,
+                        (void *)ecore_string_instance(filter_cbs[i].key),
+                        filter_cbs[i].cb);
+
+    for (i = 0; move_cbs[i].key != NULL; i++)
+        ecore_hash_set(efreet_menu_move_cbs,
+                        (void *)ecore_string_instance(move_cbs[i].key),
+                        move_cbs[i].cb);
+
+    for (i = 0; layout_cbs[i].key != NULL; i++)
+        ecore_hash_set(efreet_menu_layout_cbs,
+                        (void *)ecore_string_instance(layout_cbs[i].key),
+                        layout_cbs[i].cb);
+
+    return 1;
+}
+
+/**
+ * @return Returns no value
+ * @brief Initialize legacy kde support. This function blocks while
+ * the kde-config script is run.
+ */
+EAPI int
+efreet_menu_kde_legacy_init(void)
+{
+    FILE *f;
+    char buf[PATH_MAX];
+    char *p, *s;
+
+    IF_FREE_LIST(efreet_menu_kde_legacy_dirs);
+
+    f = popen("kde-config --path apps", "r");
+    if (!f) return 0;
+
+    efreet_menu_kde_legacy_dirs = ecore_list_new();
+    ecore_list_free_cb_set(efreet_menu_kde_legacy_dirs,
+                            ECORE_FREE_CB(ecore_string_release));
+
+    /* XXX if the return from kde-config is a line longer than PATH_MAX,
+     * this won't be correct (increase buffer and get the rest...) */
+    if (!fgets(buf, PATH_MAX, f))
+    {
+        printf("Error initializing KDE legacy information\n");
+        return 0;
+    }
+    s = buf;
+
+    p = strchr(s, ':');
+    while (p)
+    {
+        *p = '\0';
+        ecore_list_append(efreet_menu_kde_legacy_dirs,
+                            (void *)ecore_string_instance(s));
+        s = p + 1;
+        p = strchr(s, ':');
+    }
+
+    if (*s)
+        ecore_list_append(efreet_menu_kde_legacy_dirs,
+                            (void *)ecore_string_instance(s));
+
+    pclose(f);
+    return 1;
+}
+
+/**
+ * @return Returns no value
+ * @brief Shuts down the Efreet menu system
+ */
+void
+efreet_menu_shutdown(void)
+{
+    IF_FREE(efreet_menu_prefix);
+
+    IF_FREE_HASH(efreet_menu_handle_cbs);
+    IF_FREE_HASH(efreet_menu_filter_cbs);
+    IF_FREE_HASH(efreet_menu_move_cbs);
+    IF_FREE_HASH(efreet_menu_layout_cbs);
+
+    IF_FREE_LIST(efreet_menu_kde_legacy_dirs);
+
+    IF_FREE_HASH(efreet_merged_menus);
+    IF_FREE_HASH(efreet_merged_dirs);
+
+    IF_RELEASE(efreet_tag_menu);
+
+    efreet_xml_shutdown();
+    ecore_string_shutdown();
+}
+
+EAPI Efreet_Menu *
+efreet_menu_new(void)
+{
+    Efreet_Menu *menu;
+    menu = efreet_menu_entry_new();
+    menu->type = EFREET_MENU_ENTRY_MENU;
+    return menu;
+}
+
+/**
+ * @return Returns the Efreet_Menu_Internal representation of the default menu or
+ * NULL if none found
+ * @brief Creates the default menu representation
+ */
+EAPI Efreet_Menu *
+efreet_menu_get(void)
+{
+    char menu[PATH_MAX];
+    const char *dir;
+    Ecore_List *config_dirs;
+
+    /* check the users config directory first */
+    snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
+                        efreet_config_home_get(), efreet_menu_prefix_get());
+    if (ecore_file_exists(menu))
+        return efreet_menu_parse(menu);
+
+    /* fallback to the XDG_CONFIG_DIRS */
+    config_dirs = efreet_config_dirs_get();
+    ecore_list_first_goto(config_dirs);
+    while ((dir = ecore_list_next(config_dirs)))
+    {
+        snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
+                                    dir, efreet_menu_prefix_get());
+        if (ecore_file_exists(menu))
+            return efreet_menu_parse(menu);
+    }
+
+    return NULL;
+}
+
+/**
+ * @param path: The path of the menu to load
+ * @return Returns the Efreet_Menu_Internal representation on success or NULL on
+ * failure
+ * @brief Parses the given .menu file and creates the menu representation
+ */
+EAPI Efreet_Menu *
+efreet_menu_parse(const char *path)
+{
+    Efreet_Xml *xml;
+    Efreet_Menu_Internal *internal = NULL;
+    Efreet_Menu *entry = NULL;
+    Ecore_List *search_dirs;
+
+    xml = efreet_xml_new(path);
+    if (!xml) return NULL;
+
+    /* make sure we've got a <Menu> to start with */
+    if (xml->tag != efreet_tag_menu)
+    {
+        printf("Menu file didn't start with <Menu> tag.\n");
+        efreet_xml_del(xml);
+        return NULL;
+    }
+
+    IF_FREE_HASH(efreet_merged_menus);
+    efreet_merged_menus = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(efreet_merged_menus, ECORE_FREE_CB(free));
+
+    IF_FREE_HASH(efreet_merged_dirs);
+    efreet_merged_dirs = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(efreet_merged_dirs, ECORE_FREE_CB(free));
+
+    /* split appart the filename and the path */
+    internal = efreet_menu_internal_new();
+
+    /* Set default values */
+    internal->show_empty = 0;
+    internal->in_line = 0;
+    internal->inline_limit = 4;
+    internal->inline_header = 1;
+    internal->inline_alias = 0;
+
+    search_dirs = efreet_config_dirs_get();
+
+    efreet_menu_path_set(internal, path);
+    if (!efreet_menu_handle_menu(internal, xml))
+    {
+        efreet_xml_del(xml);
+        efreet_menu_internal_free(internal);
+        return NULL;
+    }
+    efreet_xml_del(xml);
+
+    efreet_menu_resolve_moves(internal);
+
+    if (!efreet_menu_process_dirs(internal))
+    {
+        efreet_menu_internal_free(internal);
+        return NULL;
+    }
+
+    /* handle all .desktops */
+    if (!efreet_menu_process(internal, 0))
+    {
+        efreet_menu_internal_free(internal);
+        return NULL;
+    }
+
+    /* handle menus with only unallocated .desktops */
+    if (!efreet_menu_process(internal, 1))
+    {
+        efreet_menu_internal_free(internal);
+        return NULL;
+    }
+
+    /* layout menu */
+    entry = efreet_menu_layout_menu(internal);
+    efreet_menu_internal_free(internal);
+    return entry;
+}
+
+/**
+ * @param menu: The menu to work with
+ * @param path: The path where the menu should be saved
+ * @return Returns 1 on success, 0 on failure
+ * @brief Saves the menu to file
+ */
+EAPI int
+efreet_menu_save(Efreet_Menu *menu, const char *path)
+{
+    FILE *f;
+    int ret;
+
+    f = fopen(path, "w");
+    if (!f) return 0;
+    fprintf(f, "<?xml version=\"1.0\"?>\n");
+    fprintf(f, "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" "
+                "\"http://standards.freedesktop.org/menu-spec/menu-1.0.dtd\">\n");
+    ret = efreet_menu_save_menu(menu, f, 0);
+    fclose(f);
+    return ret;
+}
+
+static int
+efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent)
+{
+    efreet_menu_save_indent(f, indent);
+    fprintf(f, "<Menu>\n");
+    efreet_menu_save_indent(f, indent + 1);
+    fprintf(f, "<Name>%s</Name>\n", menu->name);
+
+    if (indent == 0)
+    {
+        /* Only save these for the root element */
+        efreet_menu_save_indent(f, indent + 1);
+        fprintf(f, "<DefaultAppDirs/>\n");
+        efreet_menu_save_indent(f, indent + 1);
+        fprintf(f, "<DefaultDirectoryDirs/>\n");
+    }
+
+    if (menu->desktop)
+    {
+        efreet_menu_save_indent(f, indent + 1);
+        fprintf(f, "<Directory>%s</Directory>\n", menu->desktop->orig_path);
+    }
+
+    if (menu->entries)
+    {
+        Efreet_Menu *entry;
+        int has_desktop = 0, has_menu = 0;
+
+        efreet_menu_save_indent(f, indent + 1);
+        fprintf(f, "<Layout>\n");
+        ecore_list_first_goto(menu->entries);
+        while ((entry = ecore_list_next(menu->entries)))
+        {
+            if (entry->type == EFREET_MENU_ENTRY_MENU)
+            {
+                efreet_menu_save_indent(f, indent + 2);
+                fprintf(f, "<Menuname>%s</Menuname>\n", entry->id);
+                has_menu = 1;
+            }
+            else if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
+            {
+                efreet_menu_save_indent(f, indent + 2);
+                fprintf(f, "<Filename>%s</Filename>\n", entry->id);
+                has_desktop = 1;
+            }
+            else if (entry->type == EFREET_MENU_ENTRY_SEPARATOR)
+            {
+                efreet_menu_save_indent(f, indent + 2);
+                fprintf(f, "<Separator/>\n");
+            }
+        }
+        efreet_menu_save_indent(f, indent + 1);
+        fprintf(f, "</Layout>\n");
+
+        if (has_desktop)
+        {
+            efreet_menu_save_indent(f, indent + 1);
+            fprintf(f, "<Include>\n");
+            ecore_list_first_goto(menu->entries);
+            while ((entry = ecore_list_next(menu->entries)))
+            {
+                if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
+                {
+                    efreet_menu_save_indent(f, indent + 2);
+                    fprintf(f, "<Filename>%s</Filename>\n", entry->id);
+                }
+            }
+            efreet_menu_save_indent(f, indent + 1);
+            fprintf(f, "</Include>\n");
+        }
+
+        if (has_menu)
+        {
+            ecore_list_first_goto(menu->entries);
+            while ((entry = ecore_list_next(menu->entries)))
+            {
+                if (entry->type == EFREET_MENU_ENTRY_MENU)
+                    efreet_menu_save_menu(entry, f, indent + 1);
+            }
+        }
+    }
+    efreet_menu_save_indent(f, indent);
+    fprintf(f, "</Menu>\n");
+    return 1;
+}
+
+static int
+efreet_menu_save_indent(FILE *f, int indent)
+{
+    int i;
+
+    for (i = 0; i < indent; i++)
+        fprintf(f, "  ");
+    return 1;
+}
+
+/**
+ * @param menu: The menu to work with
+ * @param desktop: The desktop to insert
+ * @param pos: The position to place the new desktop
+ * @return Returns 1 on success, 0 on failure
+ * @brief Insert a desktop element in a menu structure. Only accepts desktop files
+ * in default directories.
+ */
+EAPI int
+efreet_menu_desktop_insert(Efreet_Menu *menu, Efreet_Desktop *desktop, int pos)
+{
+    Efreet_Menu *entry;
+    const char *id;
+
+    if (!desktop || !menu) return 0;
+    id = efreet_util_path_to_file_id(desktop->orig_path);
+    if (!id) return 0;
+
+    entry = efreet_menu_entry_new();
+    entry->type = EFREET_MENU_ENTRY_DESKTOP;
+    entry->id = ecore_string_instance(id);
+    entry->name = ecore_string_instance(desktop->name);
+    if (desktop->icon) entry->icon = ecore_string_instance(desktop->icon);
+    efreet_desktop_ref(desktop);
+    entry->desktop = desktop;
+
+    if (!menu->entries)
+    {
+        menu->entries = ecore_list_new();
+        ecore_list_free_cb_set(menu->entries, ECORE_FREE_CB(efreet_menu_free));
+    }
+
+    if (pos < 0 || pos >= ecore_list_count(menu->entries))
+        ecore_list_append(menu->entries, entry);
+    else
+    {
+        ecore_list_index_goto(menu->entries, pos);
+        ecore_list_insert(menu->entries, entry);
+    }
+    return 1;
+}
+
+/**
+ * @param menu: The menu to work with
+ * @param desktop: The desktop to remove
+ * @return Returns 1 on success, 0 on failure
+ * @brief Remove a desktop element in a menu structure. Only accepts desktop files
+ * in default directories.
+ */
+EAPI int
+efreet_menu_desktop_remove(Efreet_Menu *menu, Efreet_Desktop *desktop)
+{
+    Efreet_Menu *entry;
+
+    if (!desktop || !menu) return 0;
+
+    entry = ecore_list_find(menu->entries,
+                            ECORE_COMPARE_CB(efreet_menu_cb_entry_compare_desktop),
+                            desktop);
+    if (entry)
+    {
+        ecore_list_remove(menu->entries);
+        efreet_menu_free(entry);
+        return 1;
+    }
+    return 0;
+}
+
+/**
+ * @param menu: The menu to work with
+ * @param menu: The menu to work with
+ * @param indent: The indent level to print the menu at
+ * @return Returns no value
+ * @brief Dumps the contents of the menu to the command line
+ */
+EAPI void
+efreet_menu_dump(Efreet_Menu *menu, const char *indent)
+{
+    printf("%s%s: ", indent, menu->name);
+    printf("%s\n", (menu->icon ? menu->icon : "No icon"));
+
+    /* XXX dump the rest of the menu info */
+
+    if (menu->entries)
+    {
+        Efreet_Menu *entry;
+        char *new_indent;
+        int len;
+
+        len = strlen(indent) + 3;
+        new_indent = malloc(sizeof(char *) * len);
+        snprintf(new_indent, len, "%s  ", indent);
+
+        ecore_list_first_goto(menu->entries);
+        while ((entry = ecore_list_next(menu->entries)))
+        {
+            if (entry->type == EFREET_MENU_ENTRY_SEPARATOR)
+                printf("%s|---\n", new_indent);
+            else if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
+                printf("%s|-%s\n", new_indent, entry->name);
+            else if (entry->type == EFREET_MENU_ENTRY_MENU)
+                efreet_menu_dump(entry, new_indent);
+            else if (entry->type == EFREET_MENU_ENTRY_HEADER)
+                printf("%s|---%s\n", new_indent, entry->name);
+        }
+
+        FREE(new_indent);
+    }
+}
+
+/**
+ * @param user_dir: The user directory to work with
+ * @param system_dirs: The system directories to work with
+ * @param suffix: The path suffix to add
+ * @return Returns the list of directories
+ * @brief Creates the list of directories based on the user
+ * dir, system dirs and given suffix.
+ */
+Ecore_List *
+efreet_default_dirs_get(const char *user_dir, Ecore_List *system_dirs,
+                                                    const char *suffix)
+{
+    const char *xdg_dir;
+    char dir[PATH_MAX];
+    Ecore_List *list;
+
+    list = ecore_list_new();
+    ecore_list_free_cb_set(list, ECORE_FREE_CB(free));
+
+    snprintf(dir, sizeof(dir), "%s/%s", user_dir, suffix);
+    ecore_list_append(list, strdup(dir));
+
+    ecore_list_first_goto(system_dirs);
+    while ((xdg_dir = ecore_list_next(system_dirs)))
+    {
+        snprintf(dir, sizeof(dir), "%s/%s", xdg_dir, suffix);
+        ecore_list_append(list, strdup(dir));
+    }
+
+    return list;
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_Internal struct
+ * @brief Allocates and initializes a new Efreet_Menu_Internal structure
+ */
+static Efreet_Menu_Internal *
+efreet_menu_internal_new(void)
+{
+    Efreet_Menu_Internal *internal;
+
+    internal = NEW(Efreet_Menu_Internal, 1);
+    internal->show_empty = -1;
+    internal->in_line = -1;
+    internal->inline_limit = -1;
+    internal->inline_header = -1;
+    internal->inline_alias = -1;
+
+    return internal;
+}
+
+/**
+ * @param menu: The menu to free
+ * @return Returns no value
+ * @brief Frees up the given menu structure
+ */
+void
+efreet_menu_internal_free(Efreet_Menu_Internal *internal)
+{
+    if (!internal) return;
+
+    IF_FREE(internal->file.path);
+    IF_FREE(internal->file.name);
+
+    IF_RELEASE(internal->name.internal);
+    internal->name.name = NULL;
+
+    IF_FREE_LIST(internal->applications);
+
+    IF_FREE_DLIST(internal->directories);
+    IF_FREE_LIST(internal->app_dirs);
+    IF_FREE_LIST(internal->app_pool);
+    IF_FREE_DLIST(internal->directory_dirs);
+    IF_FREE_HASH(internal->directory_cache);
+
+    IF_FREE_LIST(internal->moves);
+    IF_FREE_LIST(internal->filters);
+
+    IF_FREE_LIST(internal->sub_menus);
+
+    IF_FREE_LIST(internal->layout);
+    IF_FREE_LIST(internal->default_layout);
+
+    FREE(internal);
+}
+
+/**
+ * @internal
+ * @return Returns the XDG_MENU_PREFIX env variable or "" if none set
+ * @brief Retrieves the XDG_MENU_PREFIX or "" if not set.
+ */
+static const char *
+efreet_menu_prefix_get(void)
+{
+    char *prefix;
+
+    if (efreet_menu_prefix) return efreet_menu_prefix;
+
+    prefix = getenv("XDG_MENU_PREFIX");
+    if (prefix) efreet_menu_prefix = strdup(prefix);
+    else efreet_menu_prefix = strdup("");
+
+    return efreet_menu_prefix;
+}
+
+/**
+ * @internal
+ * @param menu: The menu to populate
+ * @param xml: The xml dom tree to populate from
+ * @return Returns 1 if this XML tree is valid, 0 otherwise
+ * @brief Populates the given menu from the given xml structure
+ *
+ * We walk the Menu children backwards. The reason for this is so that we
+ * can deal with all the things that make us select the 'last' element
+ * (MergeFile, Directory, etc). We'll see the last one first and can deal
+ * with it right away.
+ */
+static int
+efreet_menu_handle_menu(Efreet_Menu_Internal *internal, Efreet_Xml *xml)
+{
+    Efreet_Xml *child;
+    int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+
+    ecore_list_last_goto(xml->children);
+    while ((child = ecore_dlist_previous(xml->children)))
+    {
+        cb = ecore_hash_get(efreet_menu_handle_cbs, child->tag);
+        if (cb)
+        {
+            if (!cb(internal, child))
+                return 0;
+        }
+        else
+        {
+            printf("Unknown XML tag: %s\n", child->tag);
+            return 0;
+        }
+    }
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent Menu
+ * @param xml: The xml that defines the menu
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the sub-menu nodes of the XML file
+ */
+static int
+efreet_menu_handle_sub_menu(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    Efreet_Menu_Internal *internal, *match;
+
+    efreet_menu_create_sub_menu_list(parent);
+
+    internal = efreet_menu_internal_new();
+    internal->file.path = strdup(parent->file.path);
+    if (!efreet_menu_handle_menu(internal, xml))
+    {
+        efreet_menu_internal_free(internal);
+        return 0;
+    }
+
+    /* if this menu already exists we just take this one and stick it on the
+     * start of the existing one */
+    if ((match = ecore_list_find(parent->sub_menus,
+                ECORE_COMPARE_CB(efreet_menu_cb_menu_compare), internal)))
+    {
+
+        efreet_menu_concatenate(match, internal);
+        efreet_menu_internal_free(internal);
+    }
+    else
+        ecore_list_prepend(parent->sub_menus, internal);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the AppDir tag
+ */
+static int
+efreet_menu_handle_app_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    char *path;
+    Efreet_Menu_App_Dir *app_dir;
+
+    if (!parent || !xml) return 0;
+
+    efreet_menu_create_app_dirs_list(parent);
+    path = efreet_menu_path_get(parent, xml->text);
+    if (!path) return 0;
+
+    /* we've already got this guy in our list we can skip it */
+    if (ecore_list_find(parent->app_dirs,
+            ECORE_COMPARE_CB(efreet_menu_cb_app_dirs_compare), path))
+    {
+        FREE(path);
+        return 1;
+    }
+
+    app_dir = efreet_menu_app_dir_new();
+    app_dir->path = path;
+
+    ecore_list_prepend(parent->app_dirs, app_dir);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: UNUSED
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the DefaultAppDirs
+ */
+static int
+efreet_menu_handle_default_app_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__)
+{
+    Ecore_List *dirs, *prepend;
+    char *dir;
+
+    if (!parent) return 0;
+
+    efreet_menu_create_app_dirs_list(parent);
+    dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
+                                                                    "applications");
+    prepend = ecore_list_new();
+    ecore_list_first_goto(dirs);
+    while ((dir = ecore_list_next(dirs)))
+    {
+        Efreet_Menu_App_Dir *app_dir;
+
+        if (ecore_list_find(parent->app_dirs,
+                    ECORE_COMPARE_CB(efreet_menu_cb_app_dirs_compare), dir))
+            continue;
+
+        app_dir = efreet_menu_app_dir_new();
+        app_dir->path = strdup(dir);
+
+        ecore_list_append(prepend, app_dir);
+    }
+    ecore_list_destroy(dirs);
+    ecore_list_prepend_list(parent->app_dirs, prepend);
+    ecore_list_destroy(prepend);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the DirectoryDir tag
+ */
+static int
+efreet_menu_handle_directory_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    char *path;
+
+    if (!parent || !xml) return 0;
+
+    efreet_menu_create_directory_dirs_list(parent);
+    path = efreet_menu_path_get(parent, xml->text);
+    if (!path) return 0;
+
+    /* we've already got this guy in our list we can skip it */
+    if (ecore_list_find(parent->directory_dirs, ECORE_COMPARE_CB(strcmp), path))
+    {
+        FREE(path);
+        return 1;
+    }
+
+    ecore_dlist_prepend(parent->directory_dirs, path);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: UNUSED
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the DefaultDirectoryDirs tag
+ */
+static int
+efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__)
+{
+    Ecore_List *dirs;
+    char *dir;
+
+    if (!parent) return 0;
+
+    efreet_menu_create_directory_dirs_list(parent);
+    dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
+                                                            "desktop-directories");
+    ecore_list_first_goto(dirs);
+    while ((dir = ecore_list_next(dirs)))
+    {
+        if (ecore_list_find(parent->directory_dirs, ECORE_COMPARE_CB(strcmp), dir))
+            continue;
+
+        ecore_dlist_prepend(parent->directory_dirs, strdup(dir));
+    }
+
+    ecore_list_destroy(dirs);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent Menu
+ * @param xml: The xml to work with
+ * @return Returns 1 on success or 0 on failure
+ * @brief Sets the menu name from the given XML fragment.
+ */
+static int
+efreet_menu_handle_name(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    /* not allowed to have two Name settings in a menu */
+    if (parent->name.internal)
+    {
+        printf("efreet_menu_handle_name() setting second name into menu\n");
+        return 0;
+    }
+
+    /* ignore the name if it contains a / */
+    if (strchr(xml->text, '/')) return 1;
+
+    parent->name.internal = ecore_string_instance(xml->text);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Directory tag
+ *
+ * This just adds the given directory path to a list which we'll walk once
+ * we've traversed the entire menu into memory.
+ */
+static int
+efreet_menu_handle_directory(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    if (!parent || !xml) return 0;
+
+    efreet_menu_create_directories_list(parent);
+    ecore_dlist_prepend(parent->directories, strdup(xml->text));
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the OnlyUnallocated tag
+ */
+static int
+efreet_menu_handle_only_unallocated(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    if (!parent || !xml) return 0;
+
+    /* a later instance has been seen so we can ignore this one */
+    if (parent->seen_allocated) return 1;
+
+    parent->seen_allocated = 1;
+    parent->only_unallocated = 1;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the NotOnlyUnallocated tag
+ */
+static int
+efreet_menu_handle_not_only_unallocated(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    if (!parent || !xml) return 0;
+
+    /* a later instance has been seen so we can ignore this one */
+    if (parent->seen_allocated) return 1;
+
+    parent->seen_allocated = 1;
+    parent->only_unallocated = 0;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Deleted tag
+ */
+static int
+efreet_menu_handle_deleted(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    if (!parent || !xml) return 0;
+
+    /* a later instance has been seen so we can ignore this one */
+    if (parent->seen_deleted) return 1;
+
+    parent->seen_deleted = 1;
+    parent->deleted = 1;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the NotDeleted tag
+ */
+static int
+efreet_menu_handle_not_deleted(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    if (!parent || !xml) return 0;
+
+    /* a later instance has been seen so we can ignore this one */
+    if (parent->seen_deleted) return 1;
+
+    parent->seen_deleted = 1;
+    parent->deleted = 0;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The XML tree to work with
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles parsing the Include tag and all subtags
+ */
+static int
+efreet_menu_handle_include(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    return efreet_menu_handle_filter(parent, xml,
+                                EFREET_MENU_FILTER_INCLUDE);
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Exclude tag and all subtags
+ */
+static int
+efreet_menu_handle_exclude(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    return efreet_menu_handle_filter(parent, xml,
+                                EFREET_MENU_FILTER_EXCLUDE);
+}
+
+/**
+ * @internal
+ * @param op: The filter operation
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Filename tag
+ */
+static int
+efreet_menu_handle_filename(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    if (!op || !xml) return 0;
+
+    if (!op->filenames)
+    {
+        op->filenames = ecore_list_new();
+        ecore_list_free_cb_set(op->filenames, free);
+    }
+
+    ecore_list_append(op->filenames, strdup(xml->text));
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param op: The filter operation
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Category tag
+ */
+static int
+efreet_menu_handle_category(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    if (!op || !xml) return 0;
+
+    if (!op->categories)
+    {
+        op->categories = ecore_list_new();
+        ecore_list_free_cb_set(op->categories, free);
+    }
+
+    ecore_list_append(op->categories, strdup(xml->text));
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param op: The filter operation
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the All tag and all subtags
+ */
+static int
+efreet_menu_handle_all(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    if (!op || !xml) return 0;
+
+    op->all = 1;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param op: The filter operation
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the And tag and all subtags
+ */
+static int
+efreet_menu_handle_and(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    if (!op || !xml) return 0;
+
+    return efreet_menu_handle_filter_child_op(op, xml,
+                            EFREET_MENU_FILTER_OP_AND);
+}
+
+/**
+ * @internal
+ * @param op: The filter operation
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Or tag and all subtags
+ */
+static int
+efreet_menu_handle_or(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    if (!op || !xml) return 0;
+
+    return efreet_menu_handle_filter_child_op(op, xml,
+                            EFREET_MENU_FILTER_OP_OR);
+}
+
+/**
+ * @internal
+ * @param op: The filter operation
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Not tag and all subtags
+ */
+static int
+efreet_menu_handle_not(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    if (!op || !xml) return 0;
+
+    return efreet_menu_handle_filter_child_op(op, xml,
+                            EFREET_MENU_FILTER_OP_NOT);
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the MergeFile tag
+ */
+static int
+efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    char *path = NULL;
+    const char *attr = NULL;
+    int is_path = 1;
+    int ret = 1;
+
+    if (!parent || !xml) return 0;
+
+    /* check to see if this is a path or parent type */
+    attr = efreet_xml_attribute_get(xml, "type");
+    if (attr && !strcmp(attr, "parent"))
+        is_path = 0;
+
+    /* we're given a path */
+    if (is_path)
+        path = efreet_menu_path_get(parent, xml->text);
+
+    /* need to find the next menu with the same name as ours in the config
+     * dir after ours (if we're in a config dir) */
+    else
+    {
+        Ecore_List *search_dirs;
+        const char *dir, *p;
+        int len = 0;
+
+        if (!parent->file.path)
+        {
+            printf("efreet_menu_handle_merge_file() missing menu path ...\n");
+            return 0;
+        }
+
+        search_dirs = efreet_config_dirs_get();
+
+        /* we need to find the next menu with the same name in the directory
+         * after the on the the menu was found in. to do that we first check
+         * if it's in the config_home_directory() if so we need to search
+         * all of the dirs. If it isn't in the config home directory then we
+         * scan the search dirs and look for it. The search_dirs list will
+         * be left at the next pointer so we can start looking for the menu
+         * from that point */
+
+        ecore_list_first_goto(search_dirs);
+        dir = efreet_config_home_get();
+        len = strlen(dir);
+        if (strncmp(dir, parent->file.path, len))
+        {
+            while ((dir = ecore_list_next(search_dirs)))
+            {
+                if (!strncmp(dir, parent->file.path, len))
+                    break;
+            }
+        }
+
+        if (!dir)
+        {
+            printf("efreet_menu_handle_merge_file() failed to find "
+                    "menu parent directory\n");
+            return 0;
+        }
+
+        /* the parent file path may have more path then just the base
+         * directory so we need to append that as well */
+        p = parent->file.path + len;
+
+        /* whatever dirs are left in the search dir we need to look for the
+         * menu with the same relative filename */
+        while ((dir = ecore_list_next(search_dirs)))
+        {
+            char file[PATH_MAX];
+
+            snprintf(file, sizeof(file), "%s/%s/%s", dir, (p ? p : ""),
+                                                        parent->file.name);
+            if (ecore_file_exists(file))
+            {
+                path = strdup(file);
+                break;
+            }
+        }
+    }
+
+    /* nothing to do if no file found */
+    if (!path) return 1;
+
+    if (!efreet_menu_merge(parent, xml, path))
+        ret = 0;
+
+    FREE(path);
+
+    return ret;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu to merge into
+ * @param xml: The XML to be merged
+ * @param path: The path to the .menu file to merge
+ */
+static int
+efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *path)
+{
+    Efreet_Xml *merge_xml;
+    Efreet_Menu_Internal *internal;
+    char *realpath;
+
+    if (!parent || !xml || !path) return 0;
+
+    /* do nothing if the file doesn't exist */
+    if (!ecore_file_exists(path)) return 1;
+
+    realpath = ecore_file_realpath(path);
+    if (realpath[0] == '\0')
+    {
+        printf("efreet_menu_merge() unable to get real path for %s\n", path);
+        return 0;
+    }
+
+    /* don't merge the same path twice */
+    if (ecore_hash_get(efreet_merged_menus, realpath))
+        return 1;
+
+    ecore_hash_set(efreet_merged_menus, strdup(realpath), (void *)1);
+
+    merge_xml = efreet_xml_new(realpath);
+    FREE(realpath);
+
+    if (!merge_xml)
+    {
+        printf("efreet_menu_merge() failed to read in the "
+                "merge file (%s)\n", realpath);
+        return 0;
+    }
+
+    internal = efreet_menu_internal_new();
+    efreet_menu_path_set(internal, path);
+    efreet_menu_handle_menu(internal, merge_xml);
+    efreet_menu_concatenate(parent, internal);
+    efreet_menu_internal_free(internal);
+
+    efreet_xml_del(merge_xml);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the MergeDir tag
+ */
+static int
+efreet_menu_handle_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    char *path;
+    int ret;
+
+    if (!parent || !xml || !xml->text) return 0;
+
+    path = efreet_menu_path_get(parent, xml->text);
+    if (!path) return 1;
+    if (!ecore_file_exists(path))
+    {
+        FREE(path);
+        return 1;
+    }
+
+    ret = efreet_menu_merge_dir(parent, xml, path);
+    FREE(path);
+
+    return ret;
+}
+
+/**
+ * @internal
+ * @param parent: the parent menu of the merge
+ * @param xml: The xml tree
+ * @param path: The path to the merge directory
+ * @return Returns 1 on success or 0 on failure
+ * @brief Find all of the .menu files in the given directory and merge them
+ * into the @a parent menu.
+ */
+static int
+efreet_menu_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *path)
+{
+    char dir_path[PATH_MAX];
+    DIR *files;
+    struct dirent *file;
+
+    if (!parent || !xml || !path) return 0;
+
+    /* check to see if we've merged this directory already */
+    if (ecore_hash_get(efreet_merged_dirs, path)) return 1;
+    ecore_hash_set(efreet_merged_dirs, strdup(path), (void *)1);
+
+    files = opendir(path);
+    if (!files) return 1;
+
+    while ((file = readdir(files)))
+    {
+        char *p;
+
+        if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
+        p = strrchr(file->d_name, '.');
+        if (!p) continue;
+        if (strcmp(p, ".menu")) continue;
+
+        snprintf(dir_path, PATH_MAX, "%s/%s", path, file->d_name);
+        if (!efreet_menu_merge(parent, xml, dir_path))
+            return 0;
+    }
+    closedir(files);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the DefaultMergeDirs tag
+ */
+static int
+efreet_menu_handle_default_merge_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    Ecore_List *dirs;
+    char path[PATH_MAX], *p;
+    const char *prefix;
+
+    if (!parent || !xml) return 0;
+
+    prefix = efreet_menu_prefix_get();
+    if (!strcmp(prefix, "gnome-") &&
+            (!strcmp(parent->file.name, "gnome-applications.menu")))
+        p = strdup("applications");
+
+    else if ((!strcmp(prefix, "kde-") &&
+            (!strcmp(parent->file.name, "kde-applications.menu"))))
+        p = strdup("applications");
+
+    else
+    {
+        char *s;
+
+        p = strdup(parent->file.name);
+        s = strrchr(p, '.');
+        if (s) *s = '\0';
+    }
+    snprintf(path, sizeof(path), "menus/%s-merged", p);
+    FREE(p);
+
+    dirs = efreet_default_dirs_get(efreet_config_home_get(),
+                                    efreet_config_dirs_get(), path);
+    ecore_list_first_goto(dirs);
+    while ((p = ecore_list_first_remove(dirs)))
+    {
+        efreet_menu_merge_dir(parent, xml, p);
+        FREE(p);
+    }
+    ecore_list_destroy(dirs);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the LegacyDir tag
+ */
+static int
+efreet_menu_handle_legacy_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    Efreet_Menu_Internal *legacy;
+
+    if (!parent || !xml) return 0;
+
+    legacy = efreet_menu_handle_legacy_dir_helper(NULL, parent, xml->text,
+                                efreet_xml_attribute_get(xml, "prefix"));
+    efreet_menu_concatenate(parent, legacy);
+    efreet_menu_internal_free(legacy);
+
+    return 1;
+
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param legacy_dir: The legacy directory path
+ * @param prefix: The legacy directory prefix if one set
+ * @return Returns the Efreet_Menu_Internal representing the legacy hierarchy
+ * @brief Handles the process of merging @a legacy_dir into @a parent menu
+ */
+static Efreet_Menu_Internal *
+efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root,
+                                        Efreet_Menu_Internal *parent,
+                                        const char *legacy_dir,
+                                        const char *prefix)
+{
+    char *path, file_path[PATH_MAX];
+    Efreet_Menu_Internal *legacy_internal;
+    Efreet_Menu_Filter *filter;
+    Efreet_Menu_App_Dir *app_dir;
+    int path_len, count = 0;
+    DIR *files;
+    struct dirent *file;
+
+    if (!parent || !legacy_dir) return 0;
+
+    path = efreet_menu_path_get(parent, legacy_dir);
+
+    /* nothing to do if the legacy path doesn't exist */
+    if (!ecore_file_exists(path))
+    {
+        FREE(path);
+        return NULL;
+    }
+
+    legacy_internal = efreet_menu_internal_new();
+    legacy_internal->name.internal = ecore_string_instance(ecore_file_file_get(path));
+
+    /* add the legacy dir as an app dir */
+    app_dir = efreet_menu_app_dir_new();
+    app_dir->path = strdup(path);
+    app_dir->legacy = 1;
+    if (prefix && !strchr(prefix, '/')) app_dir->prefix = strdup(prefix);
+
+    efreet_menu_create_app_dirs_list(legacy_internal);
+    ecore_list_append(legacy_internal->app_dirs, app_dir);
+#ifndef STRICT_SPEC
+    if (root)
+    {
+        /* XXX This seems wrong, but it makes efreet pass the fdo tests */
+        app_dir = efreet_menu_app_dir_new();
+        app_dir->path = strdup(path);
+        app_dir->legacy = 1;
+        if (prefix && !strchr(prefix, '/')) app_dir->prefix = strdup(prefix);
+        ecore_list_append(root->app_dirs, app_dir);
+    }
+#endif
+
+    /* add the legacy dir as a directory dir */
+    efreet_menu_create_directory_dirs_list(legacy_internal);
+    ecore_dlist_append(legacy_internal->directory_dirs, strdup(path));
+
+    /* setup a filter for all the conforming .desktop files in the legacy
+     * dir */
+    filter = efreet_menu_filter_new();
+    filter->type = EFREET_MENU_FILTER_INCLUDE;
+
+    filter->op->type = EFREET_MENU_FILTER_OP_OR;
+    filter->op->filenames = ecore_list_new();
+    ecore_list_free_cb_set(filter->op->filenames, free);
+
+    efreet_menu_create_filter_list(legacy_internal);
+    ecore_list_append(legacy_internal->filters, filter);
+
+    path_len = strlen(path);
+    files = opendir(path);
+    while ((file = readdir(files)))
+    {
+        Efreet_Desktop *desktop = NULL;
+        char buf[PATH_MAX];
+        char *exten;
+
+        if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
+        file_path[0] = '\0';
+        ecore_strlcpy(file_path, path, PATH_MAX);
+        ecore_strlcpy(file_path + path_len, "/", PATH_MAX - path_len);
+        ecore_strlcpy(file_path + path_len + 1, file->d_name, PATH_MAX - path_len - 1);
+
+        /* recurse into sub directories */
+        if (ecore_file_is_dir(file_path))
+        {
+            Efreet_Menu_Internal *ret;
+
+            ret = efreet_menu_handle_legacy_dir_helper(root ? root : legacy_internal,
+                                                        legacy_internal, file_path, prefix);
+            if (!ret)
+            {
+                efreet_menu_internal_free(legacy_internal);
+                FREE(path);
+                closedir(files);
+                return NULL;
+            }
+
+            efreet_menu_create_sub_menu_list(legacy_internal);
+            ecore_list_prepend(legacy_internal->sub_menus, ret);
+
+            continue;
+        }
+
+        if (!strcmp(file->d_name, ".directory"))
+        {
+            legacy_internal->directory = efreet_desktop_get(file_path);
+            if (legacy_internal->directory
+                    && legacy_internal->directory->type != EFREET_DESKTOP_TYPE_DIRECTORY)
+            {
+                efreet_desktop_free(legacy_internal->directory);
+                legacy_internal->directory = NULL;
+            }
+            continue;
+        }
+
+        exten = strrchr(file->d_name, '.');
+
+        if (exten && !strcmp(exten, ".desktop"))
+            desktop = efreet_desktop_get(file_path);
+
+        if (!desktop) continue;
+
+        /* if the .desktop has categories it isn't legacy */
+        if (efreet_desktop_category_count_get(desktop) != 0)
+            continue;
+
+        /* XXX: This will disappear when the .desktop is free'd */
+        efreet_desktop_category_add(desktop, "Legacy");
+
+        if (prefix)
+        {
+            snprintf(buf, PATH_MAX, "%s%s", prefix, file->d_name);
+            ecore_list_append(filter->op->filenames, strdup(buf));
+        }
+        else
+            ecore_list_append(filter->op->filenames, strdup(file->d_name));
+
+        count++;
+        efreet_desktop_free(desktop);
+    }
+    closedir(files);
+
+    FREE(path);
+    return legacy_internal;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: UNUSED
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the KDELegacyDirs tag
+ */
+static int
+efreet_menu_handle_kde_legacy_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__)
+{
+    const char *dir;
+
+    if (!parent) return 0;
+
+    if (!efreet_menu_kde_legacy_dirs) return 1;
+
+    /* XXX if one _helper() call succeeds, we return success. should this be flipped?
+     * (return fail if on of them failed) */
+    ecore_list_first_goto(efreet_menu_kde_legacy_dirs);
+    while ((dir = ecore_list_next(efreet_menu_kde_legacy_dirs)))
+    {
+        Efreet_Menu_Internal *kde;
+
+        kde = efreet_menu_handle_legacy_dir_helper(NULL, parent, dir, "kde");
+        if (kde)
+        {
+            efreet_menu_concatenate(parent, kde);
+            efreet_menu_internal_free(kde);
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Move tag and all subtags
+ */
+static int
+efreet_menu_handle_move(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    Efreet_Xml *child;
+
+    if (!parent || !xml) return 0;
+
+    efreet_menu_create_move_list(parent);
+
+    ecore_list_first_goto(xml->children);
+    while ((child = ecore_list_next(xml->children)))
+    {
+        int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
+
+        cb = ecore_hash_get(efreet_menu_move_cbs, child->tag);
+        if (cb)
+        {
+            if (!cb(parent, child))
+                return 0;
+        }
+        else
+        {
+            printf("efreet_menu_handle_move() unknown tag found "
+                    "in Move (%s)\n", child->tag);
+            return 0;
+        }
+    }
+
+    parent->current_move = NULL;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Old tag
+ */
+static int
+efreet_menu_handle_old(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    Efreet_Menu_Move *move;
+
+    if (!parent || !xml || !xml->text) return 0;
+
+    if (parent->current_move)
+    {
+        printf("efreet_menu_handle_old() saw second <Old> "
+                "before seeing <New>\n");
+        return 0;
+    }
+
+    /* If we already moved this menu, remove the old move */
+    /* XXX This seems wrong, but it makes efreet pass the fdo tests */
+#ifndef STRICT_SPEC
+    move = ecore_list_find(parent->moves,
+            ECORE_COMPARE_CB(efreet_menu_cb_move_compare), xml->text);
+    if (move) ecore_list_remove_destroy(parent->moves);
+#endif
+
+    move = efreet_menu_move_new();
+    move->old_name = strdup(xml->text);
+
+    parent->current_move = move;
+    ecore_list_append(parent->moves, move);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the New tag
+ */
+static int
+efreet_menu_handle_new(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    if (!parent || !xml || !xml->text) return 0;
+
+    if (!parent->current_move)
+    {
+        printf("efreet_menu_handle_new() saw New before seeing Old\n");
+        return 0;
+    }
+
+    parent->current_move->new_name = strdup(xml->text);
+    parent->current_move = NULL;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the Layout tag and all subtags
+ */
+static int
+efreet_menu_handle_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    Efreet_Xml *child;
+
+    if (!parent || !xml) return 0;
+
+    /* We use the last existing layout */
+    if (parent->layout) return 1;
+
+    efreet_menu_create_layout_list(parent);
+
+    ecore_list_first_goto(xml->children);
+    while ((child = ecore_list_next(xml->children)))
+    {
+        int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+
+        cb = ecore_hash_get(efreet_menu_layout_cbs, child->tag);
+        if (cb)
+        {
+            if (!cb(parent, child, 0))
+                return 0;
+        }
+        else
+        {
+            printf("efreet_menu_handle_move() unknown tag found "
+                    "in Layout (%s)\n", child->tag);
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The xml tree
+ * @return Returns 1 on success or 0 on failure
+ * @brief Handles the DefaultLayout tag
+ */
+static int
+efreet_menu_handle_default_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
+{
+    const char *val;
+    Efreet_Xml *child;
+
+    if (!parent || !xml) return 0;
+
+    /* We use the last existing layout */
+    if (parent->default_layout) return 1;
+
+    val = efreet_xml_attribute_get(xml, "show_empty");
+    if (val) parent->show_empty = !strcmp(val, "true");
+
+    val = efreet_xml_attribute_get(xml, "inline");
+    if (val) parent->in_line = !strcmp(val, "true");
+
+    val = efreet_xml_attribute_get(xml, "inline_limit");
+    if (val) parent->inline_limit = atoi(val);
+
+    val = efreet_xml_attribute_get(xml, "inline_header");
+    if (val) parent->inline_header = !strcmp(val, "true");
+
+    val = efreet_xml_attribute_get(xml, "inline_alias");
+    if (val) parent->inline_alias = !strcmp(val, "true");
+
+    efreet_menu_create_default_layout_list(parent);
+
+    ecore_list_first_goto(xml->children);
+    while ((child = ecore_list_next(xml->children)))
+    {
+        int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
+
+        cb = ecore_hash_get(efreet_menu_layout_cbs, child->tag);
+        if (cb)
+        {
+            if (!cb(parent, child, 1))
+                return 0;
+        }
+        else
+        {
+            printf("efreet_menu_handle_move() unknown tag found in "
+                    "DefaultLayout (%s)\n", child->tag);
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+static int
+efreet_menu_handle_layout_menuname(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def)
+{
+    Efreet_Menu_Layout *layout;
+    const char *val;
+
+    if (!parent || !xml) return 0;
+
+    if (!xml->text)
+    {
+        printf("efreet_menu_handle_layout_menuname() The Menuname tag in "
+                "layout needs a filename.\n");
+        return 0;
+    }
+
+    layout = efreet_menu_layout_new();
+    layout->type = EFREET_MENU_LAYOUT_MENUNAME;
+    layout->name = strdup(xml->text);
+
+    val = efreet_xml_attribute_get(xml, "show_empty");
+    if (val) layout->show_empty = !strcmp(val, "true");
+
+    val = efreet_xml_attribute_get(xml, "inline");
+    if (val) layout->in_line = !strcmp(val, "true");
+
+    val = efreet_xml_attribute_get(xml, "inline_limit");
+    if (val) layout->inline_limit = atoi(val);
+
+    val = efreet_xml_attribute_get(xml, "inline_header");
+    if (val) layout->inline_header = !strcmp(val, "true");
+
+    val = efreet_xml_attribute_get(xml, "inline_alias");
+    if (val) layout->inline_alias = !strcmp(val, "true");
+
+    if (def) ecore_list_append(parent->default_layout, layout);
+    else ecore_list_append(parent->layout, layout);
+
+    return 1;
+}
+
+static int
+efreet_menu_handle_layout_filename(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def)
+{
+    Efreet_Menu_Layout *layout;
+
+    if (!parent || !xml) return 0;
+
+    if (!xml->text)
+    {
+        printf("efreet_menu_handle_layout_filename() The Filename tag in "
+                "layout needs a filename.\n");
+        return 0;
+    }
+
+    layout = efreet_menu_layout_new();
+    layout->type = EFREET_MENU_LAYOUT_FILENAME;
+    layout->name = strdup(xml->text);
+
+    if (def) ecore_list_append(parent->default_layout, layout);
+    else ecore_list_append(parent->layout, layout);
+
+    return 1;
+}
+
+static int
+efreet_menu_handle_layout_separator(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def)
+{
+    Efreet_Menu_Layout *layout;
+
+    if (!parent || !xml) return 0;
+
+    layout = efreet_menu_layout_new();
+    layout->type = EFREET_MENU_LAYOUT_SEPARATOR;
+    if (def)
+        ecore_list_append(parent->default_layout, layout);
+    else
+        ecore_list_append(parent->layout, layout);
+    return 1;
+}
+
+static int
+efreet_menu_handle_layout_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def)
+{
+    Efreet_Menu_Layout *layout;
+    const char *attr;
+
+    if (!parent || !xml) return 0;
+
+    attr = efreet_xml_attribute_get(xml, "type");
+    if (!attr)
+    {
+        printf("efreet_menu_handle_layout_merge() The Merge tag in layout "
+                "needs a type attribute.\n");
+        return 0;
+    }
+
+    if (strcmp(attr, "files") && strcmp(attr, "menus") && strcmp(attr, "all"))
+    {
+        printf("efreet_menu_handle_layout_merge() The type attribute for "
+                "the Merge tag contains an unknown value (%s).\n", attr);
+        return 0;
+    }
+
+    layout = efreet_menu_layout_new();
+    layout->type = EFREET_MENU_LAYOUT_MERGE;
+    layout->name = strdup(attr);
+
+    if (def) ecore_list_append(parent->default_layout, layout);
+    else ecore_list_append(parent->layout, layout);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param parent: The parent menu
+ * @param xml: The XML tree to parse
+ * @param type: The type of filter
+ * @return Returns 1 on success or 0 on failure
+ * @brief Parses the given XML tree and adds the filter to the parent menu
+ */
+static int
+efreet_menu_handle_filter(Efreet_Menu_Internal *parent, Efreet_Xml *xml,
+                                        Efreet_Menu_Filter_Type type)
+{
+    Efreet_Menu_Filter *filter;
+
+    efreet_menu_create_filter_list(parent);
+
+    /* filters have a default or relationship */
+    filter = efreet_menu_filter_new();
+    filter->type = type;
+    filter->op->type = EFREET_MENU_FILTER_OP_OR;
+
+    if (!efreet_menu_handle_filter_op(filter->op, xml))
+    {
+        efreet_menu_filter_free(filter);
+        return 0;
+    }
+
+    ecore_list_prepend(parent->filters, filter);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param op: The operation to work with
+ * @param xml: The XML tree representing this operation
+ * @return Returns 1 on success or 0 on failure
+ * @brief Parses the given XML tree and populates the operation
+ */
+static int
+efreet_menu_handle_filter_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
+{
+    Efreet_Xml *child;
+
+    ecore_list_first_goto(xml->children);
+    while ((child = ecore_list_next(xml->children)))
+    {
+        int (*cb)(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
+
+        cb = ecore_hash_get(efreet_menu_filter_cbs, child->tag);
+        if (cb)
+        {
+            if (!cb(op, child))
+                return 0;
+        }
+        else
+        {
+            printf("efreet_menu_handle_filter_op() unknown tag in filter (%s)\n", child->tag);
+            return 0;
+        }
+    }
+    return 1;
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_Filter on success or NULL on failure
+ * @brief Creates and initializes an Efreet_Menu_Filter object
+ */
+static Efreet_Menu_Filter *
+efreet_menu_filter_new(void)
+{
+    Efreet_Menu_Filter *filter;
+
+    filter = NEW(Efreet_Menu_Filter, 1);
+    filter->op = efreet_menu_filter_op_new();
+    if (!filter->op)
+    {
+        FREE(filter);
+        return NULL;
+    }
+
+    return filter;
+}
+
+/**
+ * @internal
+ * @param filter: The filter to work with
+ * @return Returns no data
+ * @brief Frees the given filter and all data
+ */
+static void
+efreet_menu_filter_free(Efreet_Menu_Filter *filter)
+{
+    if (!filter) return;
+
+    if (filter->op) efreet_menu_filter_op_free(filter->op);
+    filter->op = NULL;
+
+    FREE(filter);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_Layout on success or NULL on failure
+ * @brief Creates and initializes an Efreet_Menu_Layout object
+ */
+static Efreet_Menu_Layout *
+efreet_menu_layout_new(void)
+{
+    Efreet_Menu_Layout *layout;
+
+    layout = NEW(Efreet_Menu_Layout, 1);
+    layout->show_empty = -1;
+    layout->in_line = -1;
+    layout->inline_limit = -1;
+    layout->inline_header = -1;
+    layout->inline_alias = -1;
+
+    return layout;
+}
+
+/**
+ * @internal
+ * @param layout: The layout to work with
+ * @return Returns no data
+ * @brief Frees the given layout and all data
+ */
+static void
+efreet_menu_layout_free(Efreet_Menu_Layout *layout)
+{
+    if (!layout) return;
+
+    IF_FREE(layout->name);
+
+    FREE(layout);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_Filter_Op on success or NULL on failure
+ * @brief Creates and initializes an Efreet_Menu_Filter_Op structure
+ */
+static Efreet_Menu_Filter_Op *
+efreet_menu_filter_op_new(void)
+{
+    Efreet_Menu_Filter_Op *op;
+
+    op = NEW(Efreet_Menu_Filter_Op, 1);
+
+    return op;
+}
+
+/**
+ * @internal
+ * @param op: The operation to work with
+ * @return Returns no value.
+ * @brief Frees the given operation and all sub data
+ */
+static void
+efreet_menu_filter_op_free(Efreet_Menu_Filter_Op *op)
+{
+    if (!op) return;
+
+    IF_FREE_LIST(op->categories);
+    IF_FREE_LIST(op->filenames);
+    IF_FREE_LIST(op->filters);
+
+    FREE(op);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_Desktop on success or NULL on failure
+ * @brief Creates and returns an Efreet_Menu_Desktop
+ */
+static Efreet_Menu_Desktop *
+efreet_menu_desktop_new(void)
+{
+    Efreet_Menu_Desktop *md;
+
+    md = NEW(Efreet_Menu_Desktop, 1);
+
+    return md;
+}
+
+/**
+ * @internal
+ * @param md: The Efreet_Menu_Desktop to free
+ * @return Returns no value
+ * @brief Frees the given structure
+ */
+static void
+efreet_menu_desktop_free(Efreet_Menu_Desktop *md)
+{
+    IF_RELEASE(md->id);
+    if (md->desktop) efreet_desktop_free(md->desktop);
+    FREE(md);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu on success or NULL on failure
+ * @brief Creates and returns an Efreet_Menu
+ */
+static Efreet_Menu *
+efreet_menu_entry_new(void)
+{
+    Efreet_Menu *entry;
+
+    entry = NEW(Efreet_Menu, 1);
+
+    return entry;
+}
+
+/**
+ * @internal
+ * @param entry: The Efreet_Menu to free
+ * @return Returns no value
+ * @brief Frees the given structure
+ */
+EAPI void
+efreet_menu_free(Efreet_Menu *entry)
+{
+    IF_RELEASE(entry->name);
+    IF_RELEASE(entry->icon);
+    IF_FREE_LIST(entry->entries);
+    IF_RELEASE(entry->id);
+    if (entry->desktop) efreet_desktop_free(entry->desktop);
+    FREE(entry);
+}
+
+/**
+ * @internal
+ * @param op: The op to add a child too
+ * @param xml: The XML tree of the child
+ * @param type: The type of child to add
+ * @return Returns 1 on success or 0 on failure
+ * @brief Parses the given XML tree and populates a new child operation.
+ */
+static int
+efreet_menu_handle_filter_child_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml,
+                                                Efreet_Menu_Filter_Op_Type type)
+{
+    Efreet_Menu_Filter_Op *child_op;
+
+    child_op = efreet_menu_filter_op_new();
+    child_op->type = type;
+
+    if (!efreet_menu_handle_filter_op(child_op, xml))
+    {
+        efreet_menu_filter_op_free(child_op);
+        return 0;
+    }
+
+    if (!op->filters)
+    {
+        op->filters = ecore_list_new();
+        ecore_list_free_cb_set(op->filters,
+                    ECORE_FREE_CB(efreet_menu_filter_op_free));
+    }
+
+    ecore_list_append(op->filters, child_op);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param menu: The menu to work with
+ * @param only_unallocated: Do we only look for unallocated items?
+ * @return Returns 1 if we've successfully processed the menu, 0 otherwise
+ * @brief Handles the processing of the menu data to retrieve the .desktop
+ * files for the menu
+ */
+static int
+efreet_menu_process(Efreet_Menu_Internal *internal, unsigned int only_unallocated)
+{
+    /* a menu _MUST_ have a name */
+    if (!internal->name.internal || (internal->name.internal[0] == '\0'))
+        return 0;
+
+    /* handle filtering out .desktop files as needed. This deals with all
+     * .desktop files */
+    efreet_menu_process_filters(internal, only_unallocated);
+
+    if (internal->sub_menus)
+    {
+        Efreet_Menu_Internal *sub_internal;
+
+        ecore_list_first_goto(internal->sub_menus);
+        while ((sub_internal = ecore_list_next(internal->sub_menus)))
+        {
+            sub_internal->parent = internal;
+            efreet_menu_process(sub_internal, only_unallocated);
+        }
+    }
+
+    return 1;
+}
+
+/* This will walk through all of the app dirs and load all the .desktop
+ * files into the cache for the menu. The .desktop files will have their
+ * allocated flag set to 0 */
+static int
+efreet_menu_process_dirs(Efreet_Menu_Internal *internal)
+{
+    /* Scan application directories for .desktop files */
+    if (!efreet_menu_app_dirs_process(internal))
+        return 0;
+
+    /* Scan directory directories for .directory file */
+    if (!efreet_menu_directory_dirs_process(internal))
+        return 0;
+
+    if (internal->sub_menus)
+    {
+        Efreet_Menu_Internal *sub_internal;
+
+        ecore_list_first_goto(internal->sub_menus);
+        while ((sub_internal = ecore_list_next(internal->sub_menus)))
+        {
+            sub_internal->parent = internal;
+            efreet_menu_process_dirs(sub_internal);
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param menu: the menu to process
+ * @param only_unallocated: Only handle menus taht deal with unallocated items
+ * @return Returns no value
+ * @brief Handles the processing of the filters attached to the given menu.
+ *
+ * For each include filter we'll add the items to our applications array. Each
+ * exclude filter will remove items from the applications array
+ */
+static void
+efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_unallocated)
+{
+    Efreet_Menu_Filter *filter;
+    int included = 0;
+
+    /* nothing to do if we're checking the other option */
+    if (only_unallocated != internal->only_unallocated) return;
+
+    if (!internal->applications) internal->applications = ecore_list_new();
+    else ecore_list_clear(internal->applications);
+
+    if (!internal->filters) return;
+
+    ecore_list_first_goto(internal->filters);
+    while ((filter = ecore_list_next(internal->filters)))
+    {
+        Efreet_Menu_Desktop *md;
+
+        /* skip excludes until we get an include */
+        if (!included && (filter->type == EFREET_MENU_FILTER_EXCLUDE))
+            continue;
+        included = 1;
+
+        if (filter->type == EFREET_MENU_FILTER_INCLUDE)
+        {
+            Ecore_Hash *matches;
+
+            matches = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+            efreet_menu_process_app_pool(internal->app_pool, internal->applications,
+                                        matches, filter, internal->only_unallocated);
+            if (internal->parent)
+            {
+                Efreet_Menu_Internal *parent;
+
+                parent = internal->parent;
+                do {
+                    efreet_menu_process_app_pool(parent->app_pool,
+                                                internal->applications, matches, filter,
+                                                internal->only_unallocated);
+                } while ((parent = parent->parent));
+            }
+            ecore_hash_destroy(matches);
+        }
+        else
+        {
+            /* check each item in our menu so far and see if it's excluded */
+            ecore_list_first_goto(internal->applications);
+            while ((md = ecore_list_current(internal->applications)))
+            {
+                if (efreet_menu_filter_matches(filter->op, md))
+                    ecore_list_remove(internal->applications);
+                else
+                    ecore_list_next(internal->applications);
+            }
+        }
+    }
+
+    /* sort the menu applications. we do this in process filters so it will only
+     * be done once per menu.*/
+    if (internal->applications)
+    {
+        int count;
+
+        count = ecore_list_count(internal->applications);
+        if (count)
+        {
+            Ecore_Sheap *sheap;
+            Efreet_Menu_Desktop *md;
+
+            sheap = ecore_sheap_new(
+                        ECORE_COMPARE_CB(efreet_menu_cb_md_compare), count);
+            while ((md = ecore_list_first_remove(internal->applications)))
+                ecore_sheap_insert(sheap, md);
+
+            while ((md = ecore_sheap_extract(sheap)))
+            {
+                if (md->desktop->no_display) continue;
+                ecore_list_append(internal->applications, md);
+            }
+
+            ecore_sheap_destroy(sheap);
+        }
+
+        /* Don't keep the list if it is empty */
+        if (ecore_list_empty_is(internal->applications))
+            IF_FREE_LIST(internal->applications);
+    }
+}
+
+/**
+ * @internal
+ * @param pool: The app pool to iterate
+ * @param applications: The list of applications to append too
+ * @param matches: The hash of previously matched ids
+ * @param filter: The menu filter to run on the pool items
+ * @param only_unallocated: Do we check only unallocated pool items?
+ * @return Returns no value.
+ * @brief This will iterate the items in @a pool and append them to @a
+ * applications if they match the @a filter given and aren't previoulsy entered
+ * in @a matches. If @a only_unallocated is set we'll only only at the
+ * .desktop files that haven't been previoulsy matched
+ */
+static
+void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications,
+                                        Ecore_Hash *matches,
+                                        Efreet_Menu_Filter *filter,
+                                        unsigned int only_unallocated)
+{
+    Efreet_Menu_Desktop *md;
+
+    if (!pool) return;
+
+    ecore_list_first_goto(pool);
+    while ((md = ecore_list_next(pool)))
+    {
+        if (ecore_hash_get(matches, md->id)) continue;
+        if (only_unallocated && md->allocated) continue;
+        if (efreet_menu_filter_matches(filter->op, md))
+        {
+            ecore_list_append(applications, md);
+            ecore_hash_set(matches, (void *)md->id, md);
+            md->allocated = 1;
+        }
+    }
+}
+
+/**
+ * @internal
+ * @param op: The filter operation to execute
+ * @param md: The desktop to run the filter on
+ * @return Returns 1 if this desktop matches the given filter, 0 otherwise
+ * @brief This will execute the given @a filter on the given desktop
+ */
+static int
+efreet_menu_filter_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md)
+{
+    if (op->type == EFREET_MENU_FILTER_OP_OR)
+        return efreet_menu_filter_or_matches(op, md);
+
+    if (op->type == EFREET_MENU_FILTER_OP_AND)
+        return efreet_menu_filter_and_matches(op, md);
+
+    if (op->type == EFREET_MENU_FILTER_OP_NOT)
+        return efreet_menu_filter_not_matches(op, md);
+
+    return 0;
+}
+
+/**
+ * @internal
+ * @param op: The filter operation to execute
+ * @param md: The desktop to execute on
+ * @return Returns 1 if the desktop matches, 0 otherwise
+ * @brief Executes the OR operation, @a op, on the desktop, @a md.
+ */
+static int
+efreet_menu_filter_or_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md)
+{
+    Efreet_Menu_Filter_Op *child;
+    char *t;
+
+    if (op->all) return 1;
+
+    if (op->categories && md->desktop->categories)
+    {
+        ecore_list_first_goto(op->categories);
+        while ((t = ecore_list_next(op->categories)))
+        {
+            if (ecore_list_find(md->desktop->categories, ECORE_COMPARE_CB(strcmp), t))
+                return 1;
+        }
+    }
+
+    if (op->filenames)
+    {
+        ecore_list_first_goto(op->filenames);
+        while ((t = ecore_list_next(op->filenames)))
+            if (!strcmp(t, md->id)) return 1;
+    }
+
+    if (op->filters)
+    {
+        ecore_list_first_goto(op->filters);
+        while ((child = ecore_list_next(op->filters)))
+        {
+            if (efreet_menu_filter_matches(child, md))
+                return 1;
+        }
+    }
+
+    return 0;
+}
+
+/**
+ * @internal
+ * @param op: The filter operation to execute
+ * @param md: The desktop to execute on
+ * @return Returns 1 if the desktop matches, 0 otherwise
+ * @brief Executes the AND operation, @a op, on the desktop, @a md.
+ */
+static int
+efreet_menu_filter_and_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md)
+{
+    Efreet_Menu_Filter_Op *child;
+    char *t;
+
+    if (op->categories)
+    {
+        if ((ecore_list_count(op->categories) > 0) && !md->desktop->categories)
+            return 0;
+
+        ecore_list_first_goto(op->categories);
+        while ((t = ecore_list_next(op->categories)))
+        {
+            if (!ecore_list_find(md->desktop->categories, ECORE_COMPARE_CB(strcmp), t))
+                return 0;
+        }
+    }
+
+    if (op->filenames)
+    {
+        ecore_list_first_goto(op->filenames);
+        while ((t = ecore_list_next(op->filenames)))
+        {
+            if (strcmp(t, md->id)) return 0;
+        }
+    }
+
+    if (op->filters)
+    {
+        ecore_list_first_goto(op->filters);
+        while ((child = ecore_list_next(op->filters)))
+        {
+            if (!efreet_menu_filter_matches(child, md))
+                return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param op: The filter operation to execute
+ * @param md: The desktop to execute on
+ * @return Returns 1 if the desktop matches, 0 otherwise
+ * @brief Executes the NOT operation, @a op, on the desktop, @a md.
+ */
+static int
+efreet_menu_filter_not_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md)
+{
+    Efreet_Menu_Filter_Op *child;
+    char *t;
+
+    /* !all means no desktops match */
+    if (op->all) return 0;
+
+    if (op->categories)
+    {
+        if ((ecore_list_count(op->categories) > 0) && !md->desktop->categories)
+            return 1;
+
+        ecore_list_first_goto(op->categories);
+        while ((t = ecore_list_next(op->categories)))
+        {
+            if (ecore_list_find(md->desktop->categories, ECORE_COMPARE_CB(strcmp), t))
+                return 0;
+        }
+    }
+
+    if (op->filenames)
+    {
+        ecore_list_first_goto(op->filenames);
+        while ((t = ecore_list_next(op->filenames)))
+        {
+            if (!strcmp(t, md->id)) return 0;
+        }
+    }
+
+    if (op->filters)
+    {
+        ecore_list_first_goto(op->filters);
+        while ((child = ecore_list_next(op->filters)))
+        {
+            if (efreet_menu_filter_matches(child, md))
+                return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param dest: The destination menu
+ * @param src: The source menu
+ * @return Returns no value
+ * @brief Takes the child elements of the menu @a src and puts then on the
+ * _start_ of the menu @a dest.
+ */
+static void
+efreet_menu_concatenate(Efreet_Menu_Internal *dest, Efreet_Menu_Internal *src)
+{
+    Efreet_Menu_Internal *submenu;
+
+    if (!dest || !src) return;
+
+    if (!dest->directory && src->directory)
+    {
+        dest->directory = src->directory;
+        src->directory = NULL;
+    }
+
+    if (!dest->seen_allocated && src->seen_allocated)
+    {
+        dest->only_unallocated = src->only_unallocated;
+        dest->seen_allocated = 1;
+    }
+
+    if (!dest->seen_deleted && src->seen_deleted)
+    {
+        dest->deleted = src->deleted;
+        dest->seen_deleted = 1;
+    }
+
+    if (src->directories)
+    {
+        efreet_menu_create_directories_list(dest);
+        ecore_dlist_prepend_list(dest->directories, src->directories);
+    }
+
+    if (src->app_dirs)
+    {
+        efreet_menu_create_app_dirs_list(dest);
+        ecore_list_prepend_list(dest->app_dirs, src->app_dirs);
+    }
+
+    if (src->directory_dirs)
+    {
+        efreet_menu_create_directory_dirs_list(dest);
+        ecore_dlist_prepend_list(dest->directory_dirs, src->directory_dirs);
+    }
+
+    if (src->moves)
+    {
+        efreet_menu_create_move_list(dest);
+        ecore_list_prepend_list(dest->moves, src->moves);
+    }
+
+    if (src->filters)
+    {
+        efreet_menu_create_filter_list(dest);
+        ecore_list_prepend_list(dest->filters, src->filters);
+    }
+
+    if (src->sub_menus)
+    {
+        efreet_menu_create_sub_menu_list(dest);
+
+        while ((submenu = ecore_list_last_remove(src->sub_menus)))
+        {
+            Efreet_Menu_Internal *match;
+
+            /* if this menu is in the list already we just add to that */
+            if ((match = ecore_list_find(dest->sub_menus,
+                        ECORE_COMPARE_CB(efreet_menu_cb_menu_compare), submenu)))
+            {
+                efreet_menu_concatenate(match, submenu);
+                efreet_menu_internal_free(submenu);
+            }
+            else
+                ecore_list_prepend(dest->sub_menus, submenu);
+        }
+    }
+}
+
+/**
+ * @internal
+ * @param menu: The menu to work with
+ * @return Returns no value
+ * @brief Handles any \<Move\> commands in the menus
+ */
+static void
+efreet_menu_resolve_moves(Efreet_Menu_Internal *internal)
+{
+    Efreet_Menu_Internal *child;
+    Efreet_Menu_Move *move;
+
+    /* child moves are handled before parent moves */
+    if (internal->sub_menus)
+    {
+        ecore_list_first_goto(internal->sub_menus);
+        while ((child = ecore_list_next(internal->sub_menus)))
+            efreet_menu_resolve_moves(child);
+    }
+
+    /* nothing to do if this menu has no moves */
+    if (!internal->moves) return;
+
+    ecore_list_first_goto(internal->moves);
+    while ((move = ecore_list_next(internal->moves)))
+    {
+        Efreet_Menu_Internal *origin, *dest, *parent;
+
+        /* if the origin path doesn't exist we do nothing */
+        origin = efreet_menu_by_name_find(internal, move->old_name, &parent);
+        if (!origin) continue;
+
+        /* remove the origin menu from the parent */
+        ecore_list_remove(parent->sub_menus);
+
+        /* if the destination path doesn't exist we just rename the origin
+         * menu and append to the parents list of children */
+        dest = efreet_menu_by_name_find(internal, move->new_name, &parent);
+        if (!dest)
+        {
+            char *path, *tmp, *t;
+
+            /* if the dest path has /'s in it then we need to add menus to
+             * fill out the paths */
+            t = strdup(move->new_name);
+            tmp = t;
+            path = strchr(tmp, '/');
+            while (path)
+            {
+                Efreet_Menu_Internal *ancestor;
+
+                *path = '\0';
+
+                ancestor = efreet_menu_internal_new();
+                ancestor->name.internal = ecore_string_instance(tmp);
+
+                efreet_menu_create_sub_menu_list(parent);
+                ecore_list_append(parent->sub_menus, ancestor);
+
+                parent = ancestor;
+                tmp = ++path;
+                path = strchr(tmp, '/');
+            }
+
+            IF_RELEASE(origin->name.internal);
+            origin->name.internal = ecore_string_instance(tmp);
+
+            efreet_menu_create_sub_menu_list(parent);
+            ecore_list_append(parent->sub_menus, origin);
+
+            FREE(t);
+        }
+        else
+        {
+            efreet_menu_concatenate(dest, origin);
+            efreet_menu_internal_free(origin);
+        }
+    }
+    IF_FREE_LIST(internal->moves);
+}
+
+/**
+ * @internal
+ * @param menu: The menu to start searching from
+ * @param name: The menu name to find
+ * @param parent: The parent of the found menu
+ * @return Returns the menu with the given @a name or NULL if none found
+ * @brief Searches the menu tree starting at @a menu looking for a menu with
+ * @a name.
+ */
+static Efreet_Menu_Internal *
+efreet_menu_by_name_find(Efreet_Menu_Internal *internal, const char *name, Efreet_Menu_Internal **parent)
+{
+    char *part, *tmp, *ptr;
+
+    if (parent) *parent = internal;
+
+    /* find the correct parent menu */
+    tmp = strdup(name);
+    ptr = tmp;
+    part = strchr(ptr, '/');
+    while (part)
+    {
+        *part = '\0';
+
+        if (!ecore_list_find(internal->sub_menus,
+                    ECORE_COMPARE_CB(efreet_menu_cb_compare_names), ptr))
+        {
+            FREE(tmp);
+            return NULL;
+        }
+
+        internal = ecore_list_current(internal->sub_menus);
+        ptr = ++part;
+        part = strchr(ptr, '/');
+    }
+
+    if (parent) *parent = internal;
+
+    /* find the menu in the parent list */
+    if (!ecore_list_find(internal->sub_menus,
+                ECORE_COMPARE_CB(efreet_menu_cb_compare_names), ptr))
+    {
+        FREE(tmp);
+        return NULL;
+    }
+
+    FREE(tmp);
+    return ecore_list_current(internal->sub_menus);
+}
+
+static void
+efreet_menu_path_set(Efreet_Menu_Internal *internal, const char *path)
+{
+    char *tmp, *p;
+
+    tmp = strdup(path);
+    p = strrchr(tmp, '/');
+    if (p)
+    {
+        *p = '\0';
+        p++;
+
+        internal->file.path = strdup(tmp);
+        internal->file.name = strdup(p);
+    }
+    FREE(tmp);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_Move struct on success or NULL on failure
+ * @brief Creates an returns a new Efreet_Menu_Move struct or NULL on failure
+ */
+static Efreet_Menu_Move *
+efreet_menu_move_new(void)
+{
+    Efreet_Menu_Move *move;
+
+    move = NEW(Efreet_Menu_Move, 1);
+
+    return move;
+}
+
+/**
+ * @internal
+ * @param move: The Efreet_Menu_Move to free
+ * @return Returns no value.
+ * @brief Frees the given move structure
+ */
+static void
+efreet_menu_move_free(Efreet_Menu_Move *move)
+{
+    if (!move) return;
+
+    IF_FREE(move->old_name);
+    IF_FREE(move->new_name);
+
+    FREE(move);
+}
+
+/**
+ * @internal
+ * @return Returns a new Efreet_Menu_App_Dir on success or NULL on failure
+ * @brief Creates and initializes a new Efreet_Menu_App_Dir structure
+ */
+static Efreet_Menu_App_Dir *
+efreet_menu_app_dir_new(void)
+{
+    Efreet_Menu_App_Dir *dir;
+
+    dir = NEW(Efreet_Menu_App_Dir, 1);
+
+    return dir;
+}
+
+/**
+ * @internal
+ * @param dir: The app dir to free
+ * @return Returns no value
+ * @brief Frees @a dir
+ */
+static void
+efreet_menu_app_dir_free(Efreet_Menu_App_Dir *dir)
+{
+    if (!dir) return;
+
+    IF_FREE(dir->path);
+    IF_FREE(dir->prefix);
+
+    FREE(dir);
+}
+
+/**
+ * @internal
+ * @param a: The app dir to compare too
+ * @param b: The path to compare too
+ * @return Returns 1 if the strings are equals, 0 otherwise
+ * @brief Compares the too strings
+ */
+static int
+efreet_menu_cb_app_dirs_compare(Efreet_Menu_App_Dir *a, const char *b)
+{
+    return ecore_str_compare(a->path, b);
+}
+
+static void
+efreet_menu_create_sub_menu_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->sub_menus) return;
+
+    internal->sub_menus = ecore_list_new();
+    ecore_list_free_cb_set(internal->sub_menus,
+                        ECORE_FREE_CB(efreet_menu_internal_free));
+}
+
+static void
+efreet_menu_create_app_dirs_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->app_dirs) return;
+
+    internal->app_dirs = ecore_list_new();
+    ecore_list_free_cb_set(internal->app_dirs,
+                        ECORE_FREE_CB(efreet_menu_app_dir_free));
+}
+
+static void
+efreet_menu_create_directory_dirs_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->directory_dirs) return;
+
+    internal->directory_dirs = ecore_dlist_new();
+    ecore_list_free_cb_set(internal->directory_dirs, ECORE_FREE_CB(free));
+}
+
+static void
+efreet_menu_create_move_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->moves) return;
+
+    internal->moves = ecore_list_new();
+    ecore_list_free_cb_set(internal->moves, ECORE_FREE_CB(efreet_menu_move_free));
+}
+
+static void
+efreet_menu_create_filter_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->filters) return;
+
+    internal->filters = ecore_list_new();
+    ecore_list_free_cb_set(internal->filters,
+                        ECORE_FREE_CB(efreet_menu_filter_free));
+}
+
+static void
+efreet_menu_create_layout_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->layout) return;
+
+    internal->layout = ecore_list_new();
+    ecore_list_free_cb_set(internal->layout,
+                        ECORE_FREE_CB(efreet_menu_layout_free));
+}
+
+static void
+efreet_menu_create_default_layout_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->default_layout) return;
+
+    internal->default_layout = ecore_list_new();
+    ecore_list_free_cb_set(internal->default_layout,
+                        ECORE_FREE_CB(efreet_menu_layout_free));
+}
+
+static void
+efreet_menu_create_directories_list(Efreet_Menu_Internal *internal)
+{
+    if (!internal || internal->directories) return;
+
+    internal->directories = ecore_dlist_new();
+    ecore_list_free_cb_set(internal->directories, free);
+}
+
+static char *
+efreet_menu_path_get(Efreet_Menu_Internal *internal, const char *suffix)
+{
+    char path[PATH_MAX];
+    size_t len;
+
+    /* see if we've got an absolute or relative path */
+    if (suffix[0] == '/')
+        snprintf(path, sizeof(path), "%s", suffix);
+
+    else
+    {
+        if (!internal->file.path)
+        {
+            printf("efreet_menu_handle_app_dir() missing menu path ...\n");
+            return NULL;
+        }
+        snprintf(path, sizeof(path), "%s/%s", internal->file.path, suffix);
+    }
+
+    len = strlen(path);
+    while (path[len] == '/') path[len--] = '\0';
+
+    return strdup(path);
+}
+
+static int
+efreet_menu_cb_menu_compare(Efreet_Menu_Internal *a, Efreet_Menu_Internal *b)
+{
+    return ecore_str_compare(a->name.internal, b->name.internal);
+}
+
+static int
+efreet_menu_app_dirs_process(Efreet_Menu_Internal *internal)
+{
+    Efreet_Menu_App_Dir *app_dir;
+
+    if (internal->app_pool)
+    {
+        ecore_list_destroy(internal->app_pool);
+        internal->app_pool = NULL;
+    }
+
+    if (internal->app_dirs)
+    {
+        internal->app_pool = ecore_list_new();
+        ecore_list_free_cb_set(internal->app_pool, ECORE_FREE_CB(efreet_menu_desktop_free));
+
+        ecore_list_first_goto(internal->app_dirs);
+        while ((app_dir = ecore_list_next(internal->app_dirs)))
+            efreet_menu_app_dir_scan(internal, app_dir->path, app_dir->prefix, app_dir->legacy);
+    }
+    return 1;
+}
+
+static int
+efreet_menu_app_dir_scan(Efreet_Menu_Internal *internal, const char *path, const char *id, int legacy)
+{
+    Efreet_Desktop *desktop;
+    Efreet_Menu_Desktop *menu_desktop;
+    DIR *files;
+    char buf[PATH_MAX], buf2[PATH_MAX];
+    struct dirent *file;
+    char *ext;
+
+    files = opendir(path);
+    if (!files) return 1;
+
+    while ((file = readdir(files)))
+    {
+        if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
+        snprintf(buf, PATH_MAX, "%s/%s", path, file->d_name);
+        if (id)
+            snprintf(buf2, PATH_MAX, "%s-%s", id, file->d_name);
+        else
+            strcpy(buf2, file->d_name);
+
+        if (ecore_file_is_dir(buf))
+        {
+            if (!legacy)
+                efreet_menu_app_dir_scan(internal, buf, buf2, legacy);
+        }
+        else
+        {
+            ext = strrchr(buf, '.');
+
+            if (!ext || strcmp(ext, ".desktop")) continue;
+            desktop = efreet_desktop_get(buf);
+
+            if (!desktop || desktop->type != EFREET_DESKTOP_TYPE_APPLICATION)
+            {
+                if (desktop) efreet_desktop_free(desktop);
+                continue;
+            }
+            /* Don't add two files with the same id in the app pool */
+            if (ecore_list_find(internal->app_pool,
+                    ECORE_COMPARE_CB(efreet_menu_cb_md_compare_ids), buf2)) continue;
+
+            menu_desktop = efreet_menu_desktop_new();
+            menu_desktop->desktop = desktop;
+            menu_desktop->id = ecore_string_instance(buf2);
+            ecore_list_prepend(internal->app_pool, menu_desktop);
+        }
+    }
+    closedir(files);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param menu: The menu to work with
+ * @return Returns 1 on success or 0 on failure
+ * @brief Process the directory dirs in @a menu
+ */
+static int
+efreet_menu_directory_dirs_process(Efreet_Menu_Internal *internal)
+{
+    const char *path;
+
+    if (internal->directory_dirs)
+    {
+        internal->directory_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+        ecore_hash_free_key_cb_set(internal->directory_cache, ECORE_FREE_CB(free));
+        ecore_hash_free_value_cb_set(internal->directory_cache, ECORE_FREE_CB(efreet_desktop_free));
+
+        ecore_dlist_last_goto(internal->directory_dirs);
+        while ((path = ecore_dlist_previous(internal->directory_dirs)))
+            efreet_menu_directory_dir_scan(path, NULL, internal->directory_cache);
+    }
+
+    if (internal->directories)
+    {
+        ecore_dlist_last_goto(internal->directories);
+        while ((path = ecore_dlist_previous(internal->directories)))
+        {
+            internal->directory = efreet_menu_directory_get(internal, path);
+            if (internal->directory) break;
+        }
+    }
+    if (!internal->directory)
+        internal->name.name = internal->name.internal;
+    else
+        internal->name.name = internal->directory->name;
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param path: The path to scan
+ * @param relative_path: The relative portion of the path
+ * @param cache: The cache to populate
+ * @return Returns 1 on success or 0 on failure
+ * @brief Scans the given directory dir for .directory files and adds the
+ * applications to the cache
+ */
+static int
+efreet_menu_directory_dir_scan(const char *path, const char *relative_path,
+                                                            Ecore_Hash *cache)
+{
+    Efreet_Desktop *desktop;
+    DIR *files;
+    char buf[PATH_MAX], buf2[PATH_MAX];
+    struct dirent *file;
+    char *ext;
+
+    files = opendir(path);
+    if (!files) return 1;
+
+    while ((file = readdir(files)))
+    {
+        if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
+        snprintf(buf, PATH_MAX, "%s/%s", path, file->d_name);
+        if (relative_path)
+            snprintf(buf2, PATH_MAX, "%s/%s", relative_path, file->d_name);
+        else
+            strcpy(buf2, file->d_name);
+
+        if (ecore_file_is_dir(buf))
+            efreet_menu_directory_dir_scan(buf, buf2, cache);
+
+        else
+        {
+            ext = strrchr(buf, '.');
+            if (!ext || strcmp(ext, ".directory")) continue;
+
+            desktop = efreet_desktop_get(buf);
+            if (!desktop || desktop->type != EFREET_DESKTOP_TYPE_DIRECTORY)
+            {
+                efreet_desktop_free(desktop);
+                continue;
+            }
+
+            ecore_hash_set(cache, (void *)strdup(buf2), desktop);
+        }
+    }
+    closedir(files);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param menu: The menu to work with
+ * @param path: The path to work with
+ * @return Returns the desktop file for this path or NULL if none exists
+ * @brief Finds the desktop file for the given path.
+ */
+static Efreet_Desktop *
+efreet_menu_directory_get(Efreet_Menu_Internal *internal, const char *path)
+{
+    Efreet_Desktop *dir;
+
+    if (internal->directory_cache)
+    {
+        dir = ecore_hash_get(internal->directory_cache, path);
+        if (dir) return dir;
+    }
+
+    if (internal->parent)
+        return efreet_menu_directory_get(internal->parent, path);
+
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param a: The first desktop
+ * @param b: The second desktop
+ * @return Returns the comparison of the desktop files
+ * @brief Compares the desktop files.
+ */
+static int
+efreet_menu_cb_md_compare(Efreet_Menu_Desktop *a, Efreet_Menu_Desktop *b)
+{
+#ifdef STRICT_SPEC
+    return strcmp(ecore_file_file_get(a->desktop->orig_path), ecore_file_file_get(b->desktop->orig_path));
+#else
+    return strcasecmp(a->desktop->name, b->desktop->name);
+#endif
+}
+
+static int
+efreet_menu_cb_compare_names(Efreet_Menu_Internal *internal, const char *name)
+{
+    return strcmp(internal->name.internal, name);
+}
+
+static int
+efreet_menu_cb_md_compare_ids(Efreet_Menu_Desktop *md, const char *name)
+{
+    return strcmp(md->id, name);
+}
+
+static Efreet_Menu *
+efreet_menu_layout_menu(Efreet_Menu_Internal *internal)
+{
+    Efreet_Menu *entry;
+    Ecore_List *layout = NULL;
+
+    if (internal->parent)
+    {
+        /* Copy default layout rules */
+        if (internal->show_empty == -1)    internal->show_empty = internal->parent->show_empty;
+        if (internal->in_line == -1)       internal->in_line = internal->parent->in_line;
+        if (internal->inline_limit == -1)  internal->inline_limit = internal->parent->inline_limit;
+        if (internal->inline_header == -1) internal->inline_header = internal->parent->inline_header;
+        if (internal->inline_alias == -1)  internal->inline_alias = internal->parent->inline_alias;
+    }
+
+    if (internal->layout)
+        layout = internal->layout;
+
+    else if (internal->parent)
+    {
+        Efreet_Menu_Internal *parent;
+        parent = internal->parent;
+        do
+        {
+            layout = parent->default_layout;
+            parent = parent->parent;
+        } while (!layout && parent);
+    }
+
+    /* init entry */
+    entry = efreet_menu_entry_new();
+    entry->type = EFREET_MENU_ENTRY_MENU;
+    entry->id = ecore_string_instance(internal->name.internal);
+    entry->name = ecore_string_instance(internal->name.name);
+    if (internal->directory)
+    {
+        entry->icon = ecore_string_instance(internal->directory->icon);
+        efreet_desktop_ref(internal->directory);
+        entry->desktop = internal->directory;
+    }
+    entry->entries = ecore_list_new();
+    ecore_list_free_cb_set(entry->entries, ECORE_FREE_CB(efreet_menu_free));
+
+#if 1 //STRICT_SPEC
+    if (internal->sub_menus)
+    {
+        ecore_list_sort(internal->sub_menus,
+                        ECORE_COMPARE_CB(efreet_menu_cb_menu_compare), ECORE_SORT_MIN);
+    }
+#endif
+
+    if (layout)
+    {
+        Efreet_Menu_Layout *lay;
+
+        ecore_list_first_goto(layout);
+        while ((lay = ecore_list_next(layout)))
+            efreet_menu_layout_entries_get(entry, internal, lay);
+    }
+    else
+    {
+        /* Default layout, first menus, then desktop */
+        if (internal->sub_menus)
+        {
+            Efreet_Menu_Internal *sub;
+
+            ecore_list_first_goto(internal->sub_menus);
+            while ((sub = ecore_list_next(internal->sub_menus)))
+            {
+                Efreet_Menu *sub_entry;
+                if ((sub->directory && sub->directory->no_display) || sub->deleted) continue;
+                sub_entry = efreet_menu_layout_menu(sub);
+                /* Don't show empty menus */
+                if (!sub_entry->entries)
+                {
+                    efreet_menu_free(sub_entry);
+                    continue;
+                }
+                ecore_list_append(entry->entries, sub_entry);
+            }
+        }
+
+        if (internal->applications)
+        {
+            Efreet_Menu_Desktop *md;
+
+            ecore_list_first_goto(internal->applications);
+            while ((md = ecore_list_next(internal->applications)))
+            {
+                Efreet_Menu *sub_entry;
+                sub_entry = efreet_menu_layout_desktop(md);
+                ecore_list_append(entry->entries, sub_entry);
+            }
+        }
+    }
+
+    /* Don't keep this list around if it is empty */
+    if (ecore_list_empty_is(entry->entries)) IF_FREE_LIST(entry->entries);
+
+    return entry;
+}
+
+static Efreet_Menu *
+efreet_menu_layout_desktop(Efreet_Menu_Desktop *md)
+{
+    Efreet_Menu *entry;
+
+    /* init entry */
+    entry = efreet_menu_entry_new();
+    entry->type = EFREET_MENU_ENTRY_DESKTOP;
+    entry->id = ecore_string_instance(md->id);
+    entry->name = ecore_string_instance(md->desktop->name);
+    if (md->desktop->icon) entry->icon = ecore_string_instance(md->desktop->icon);
+    efreet_desktop_ref(md->desktop);
+    entry->desktop = md->desktop;
+
+    return entry;
+}
+
+static void
+efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *internal,
+        Efreet_Menu_Layout *layout)
+{
+    Efreet_Menu *sub_entry;
+
+    if (internal->sub_menus && layout->type == EFREET_MENU_LAYOUT_MENUNAME)
+    {
+        Efreet_Menu_Internal *sub;
+
+        /* Efreet_Menu_Layout might be from DefaultLayout, so we need a local copy */
+        int show_empty, in_line, inline_limit, inline_header, inline_alias;
+
+        if (layout->show_empty == -1) show_empty = internal->show_empty;
+        else show_empty = layout->show_empty;
+
+        if (layout->in_line == -1) in_line = internal->in_line;
+        else in_line = layout->in_line;
+
+        if (layout->inline_limit == -1) inline_limit = internal->inline_limit;
+        else inline_limit = layout->inline_limit;
+
+        if (layout->inline_header == -1) inline_header = internal->inline_header;
+        else inline_header = layout->inline_header;
+
+        if (layout->inline_alias == -1) inline_alias = internal->inline_alias;
+        else inline_alias = layout->inline_alias;
+
+        sub = ecore_list_find(internal->sub_menus,
+                ECORE_COMPARE_CB(efreet_menu_cb_compare_names), layout->name);
+        if (sub)
+        {
+            if (!(sub->directory && sub->directory->no_display) && !sub->deleted)
+            {
+                sub_entry = efreet_menu_layout_menu(sub);
+                if (!show_empty && efreet_menu_layout_is_empty(sub_entry))
+                    efreet_menu_free(sub_entry);
+                else if (in_line &&
+                        ((inline_limit == 0) ||
+                         (!sub_entry->entries || (ecore_list_count(sub_entry->entries) <= inline_limit))))
+                {
+                    /* Inline */
+                    if (!sub_entry->entries)
+                    {
+                        /* Can't inline an empty submenu */
+                        ecore_list_append(entry->entries, sub_entry);
+                    }
+                    else if (inline_alias && (ecore_list_count(sub_entry->entries) == 1))
+                    {
+                        Efreet_Menu *tmp;
+
+                        tmp = ecore_list_first_remove(sub_entry->entries);
+                        IF_RELEASE(tmp->name);
+                        tmp->name = sub_entry->name;
+                        sub_entry->name = NULL;
+                        IF_RELEASE(tmp->icon);
+                        tmp->icon = sub_entry->icon;
+                        sub_entry->icon = NULL;
+                        ecore_list_append(entry->entries, tmp);
+                        efreet_menu_free(sub_entry);
+                    }
+                    else
+                    {
+                        Efreet_Menu *tmp;
+
+                        if (inline_header)
+                        {
+                            tmp = efreet_menu_entry_new();
+                            tmp->type = EFREET_MENU_ENTRY_HEADER;
+                            tmp->name = sub_entry->name;
+                            sub_entry->name = NULL;
+                            tmp->icon = sub_entry->icon;
+                            sub_entry->icon = NULL;
+                            ecore_list_append(entry->entries, tmp);
+                        }
+                        ecore_list_first_goto(sub_entry->entries);
+                        while ((tmp = ecore_list_first_remove(sub_entry->entries)))
+                            ecore_list_append(entry->entries, tmp);
+                        efreet_menu_free(sub_entry);
+                    }
+                }
+                else
+                    ecore_list_append(entry->entries, sub_entry);
+            }
+            ecore_list_remove(internal->sub_menus);
+            efreet_menu_internal_free(sub);
+        }
+        if (ecore_list_empty_is(internal->sub_menus)) IF_FREE_LIST(internal->sub_menus);
+    }
+    else if (internal->applications && layout->type == EFREET_MENU_LAYOUT_FILENAME)
+    {
+        Efreet_Menu_Desktop *md;
+        md = ecore_list_find(internal->applications,
+                ECORE_COMPARE_CB(efreet_menu_cb_md_compare_ids), layout->name);
+        if (md)
+        {
+            sub_entry = efreet_menu_layout_desktop(md);
+            ecore_list_append(entry->entries, sub_entry);
+            ecore_list_remove(internal->applications);
+        }
+        if (ecore_list_empty_is(internal->applications)) IF_FREE_LIST(internal->applications);
+    }
+    else if (layout->type == EFREET_MENU_LAYOUT_MERGE)
+    {
+        if (internal->applications && !strcmp(layout->name, "files"))
+        {
+            Efreet_Menu_Desktop *md;
+
+            ecore_list_first_goto(internal->applications);
+            while ((md = ecore_list_first_remove(internal->applications)))
+            {
+                sub_entry = ecore_list_find(entry->entries,
+                        ECORE_COMPARE_CB(efreet_menu_cb_entry_compare_desktop), md->desktop);
+                if (!sub_entry)
+                {
+                    sub_entry = efreet_menu_layout_desktop(md);
+                    ecore_list_append(entry->entries, sub_entry);
+                }
+            }
+            IF_FREE_LIST(internal->applications);
+        }
+        else if (internal->sub_menus && !strcmp(layout->name, "menus"))
+        {
+            Efreet_Menu_Internal *sub;
+
+            ecore_list_first_goto(internal->sub_menus);
+            while ((sub = ecore_list_first_remove(internal->sub_menus)))
+            {
+                if ((sub->directory && sub->directory->no_display) || sub->deleted)
+                {
+                    efreet_menu_internal_free(sub);
+                    continue;
+                }
+                sub_entry = ecore_list_find(entry->entries,
+                        ECORE_COMPARE_CB(efreet_menu_cb_entry_compare_menu), sub);
+                if (!sub_entry)
+                {
+                    sub_entry = efreet_menu_layout_menu(sub);
+                    if (!internal->show_empty && efreet_menu_layout_is_empty(sub_entry))
+                        efreet_menu_free(sub_entry);
+                    else if (internal->in_line &&
+                            ((internal->inline_limit == 0) ||
+                             (!sub_entry->entries || (ecore_list_count(sub_entry->entries) <= internal->inline_limit))))
+                    {
+                        /* Inline */
+                        if (!sub_entry->entries)
+                        {
+                            /* Can't inline an empty submenu */
+                            ecore_list_append(entry->entries, sub_entry);
+                        }
+                        else if (internal->inline_alias && (ecore_list_count(sub_entry->entries) == 1))
+                        {
+                            Efreet_Menu *tmp;
+
+                            tmp = ecore_list_first_remove(sub_entry->entries);
+                            ecore_string_release(tmp->name);
+                            tmp->name = sub_entry->name;
+                            sub_entry->name = NULL;
+                            IF_RELEASE(tmp->icon);
+                            if (sub_entry->icon)
+                            {
+                                tmp->icon = sub_entry->icon;
+                                sub_entry->icon = NULL;
+                            }
+                            ecore_list_append(entry->entries, tmp);
+                            efreet_menu_free(sub_entry);
+                        }
+                        else
+                        {
+                            Efreet_Menu *tmp;
+
+                            if (internal->inline_header)
+                            {
+                                tmp = efreet_menu_entry_new();
+                                tmp->type = EFREET_MENU_ENTRY_HEADER;
+                                tmp->name = sub_entry->name;
+                                sub_entry->name = NULL;
+                                if (sub_entry->icon) tmp->icon = sub_entry->icon;
+                                sub_entry->icon = NULL;
+                                ecore_list_append(entry->entries, tmp);
+                            }
+                            ecore_list_first_goto(sub_entry->entries);
+                            while ((tmp = ecore_list_first_remove(sub_entry->entries)))
+                                ecore_list_append(entry->entries, tmp);
+                            efreet_menu_free(sub_entry);
+                        }
+                    }
+                    else
+                        ecore_list_append(entry->entries, sub_entry);
+                }
+                efreet_menu_internal_free(sub);
+            }
+            IF_FREE_LIST(internal->sub_menus);
+        }
+        else if (internal->sub_menus && !strcmp(layout->name, "all"))
+        {
+            char *orig;
+
+            orig = layout->name;
+            layout->name = "menus";
+            efreet_menu_layout_entries_get(entry, internal, layout);
+            layout->name = "files";
+            efreet_menu_layout_entries_get(entry, internal, layout);
+            layout->name = orig;
+        }
+    }
+    else if (layout->type == EFREET_MENU_LAYOUT_SEPARATOR)
+    {
+        sub_entry = efreet_menu_entry_new();
+        sub_entry->type = EFREET_MENU_ENTRY_SEPARATOR;
+        ecore_list_append(entry->entries, sub_entry);
+    }
+}
+
+static int
+efreet_menu_cb_entry_compare_menu(Efreet_Menu *entry, Efreet_Menu_Internal *internal)
+{
+    if (entry->type != EFREET_MENU_ENTRY_MENU) return 1;
+    return ecore_str_compare(entry->name, internal->name.name);
+}
+
+static int
+efreet_menu_cb_entry_compare_desktop(Efreet_Menu *entry, Efreet_Desktop *desktop)
+{
+    if (entry->type != EFREET_MENU_ENTRY_DESKTOP) return -1;
+    return ecore_str_compare(entry->name, desktop->name);
+}
+
+static int
+efreet_menu_cb_move_compare(Efreet_Menu_Move *move, const char *old)
+{
+    return ecore_str_compare(move->old_name, old);
+}
+
+static int
+efreet_menu_layout_is_empty(Efreet_Menu *entry)
+{
+    Efreet_Menu *sub_entry;
+
+    if (!entry->entries) return 1;
+
+    ecore_list_first_goto(entry->entries);
+    while ((sub_entry = ecore_list_next(entry->entries)))
+    {
+        if (sub_entry->type == EFREET_MENU_ENTRY_MENU) return 0;
+        if (sub_entry->type == EFREET_MENU_ENTRY_DESKTOP) return 0;
+    }
+    return 1;
+}
diff --git a/src/lib/efreet_menu.h b/src/lib/efreet_menu.h
new file mode 100644 (file)
index 0000000..c22debd
--- /dev/null
@@ -0,0 +1,72 @@
+/* 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;
+    const 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 */
+};
+
+EAPI int              efreet_menu_kde_legacy_init(void);
+
+EAPI Efreet_Menu     *efreet_menu_new(void);
+EAPI Efreet_Menu     *efreet_menu_get(void);
+EAPI Efreet_Menu     *efreet_menu_parse(const char *path);
+EAPI int              efreet_menu_save(Efreet_Menu *menu, const char *path);
+EAPI void             efreet_menu_free(Efreet_Menu *menu);
+
+EAPI int              efreet_menu_desktop_insert(Efreet_Menu *menu,
+                                                    Efreet_Desktop *desktop,
+                                                    int pos);
+EAPI int              efreet_menu_desktop_remove(Efreet_Menu *menu,
+                                                    Efreet_Desktop *desktop);
+
+EAPI void             efreet_menu_dump(Efreet_Menu *menu, const char *indent);
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_mime.c b/src/lib/efreet_mime.c
new file mode 100644 (file)
index 0000000..af7304c
--- /dev/null
@@ -0,0 +1,1229 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include <Efreet.h>
+#include <Ecore_Data.h>
+#include <Efreet_Mime.h>
+#include "efreet_private.h"
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+static Ecore_List *globs = NULL;     /* contains Efreet_Mime_Glob structs */
+static Ecore_List *magics = NULL;    /* contains Efreet_Mime_Magic structs */
+static Ecore_Hash *wild = NULL;      /* contains *.ext and mime.types globs*/
+static Ecore_Hash *monitors = NULL;  /* contains file monitors */
+
+/**
+ * @internal
+ * @brief Holds whether we are big/little endian
+ * @note This is set during efreet_mime_init based on
+ * a runtime check.
+ */
+static enum
+{
+    EFREET_ENDIAN_BIG = 0,
+    EFREET_ENDIAN_LITTLE = 1
+} efreet_mime_endianess = EFREET_ENDIAN_BIG;
+
+/*
+ * Buffer sized used for magic checks.  The default is good enough for the
+ * current set of magic rules.  This setting is only here for the future.
+ */
+#define EFREET_MIME_MAGIC_BUFFER_SIZE 512
+
+/**
+ * Efreet_Mime_Glob
+ * @brief A parsed representation of a globs file
+ */
+typedef struct Efreet_Mime_Glob Efreet_Mime_Glob;
+struct Efreet_Mime_Glob
+{
+    const char *glob;
+    const char *mime;
+};
+
+/**
+ * Efreet_Mime_Magic
+ * @brief A parsed representation of a magic file section
+ */
+typedef struct Efreet_Mime_Magic Efreet_Mime_Magic;
+struct Efreet_Mime_Magic
+{
+    unsigned int priority;
+    const char *mime;
+    Ecore_List *entries;
+};
+
+/**
+ * Efreet_Mime_Magic_Entry
+ * @brief A parsed representation of a magic file entry
+ */
+typedef struct Efreet_Mime_Magic_Entry Efreet_Mime_Magic_Entry;
+struct Efreet_Mime_Magic_Entry
+{
+    unsigned int indent;
+    unsigned int offset;
+    unsigned int word_size;
+    unsigned int range_len;
+    unsigned short value_len;
+    char *mask;
+    char *value;
+};
+
+static int efreet_mime_glob_remove(const char *glob);
+static void efreet_mime_mime_types_load(const char *file);
+static void efreet_mime_shared_mimeinfo_globs_load(const char *file);
+static void efreet_mime_shared_mimeinfo_magic_load(const char *file);
+static void efreet_mime_shared_mimeinfo_magic_parse(char *data, int size);
+static const char *efreet_mime_magic_check_priority(const char *file,
+                                                      unsigned int start,
+                                                      unsigned int end);
+static int efreet_mime_init_files(void);
+static const char *efreet_mime_special_check(const char *file);
+static const char *efreet_mime_fallback_check(const char *file);
+static void efreet_mime_glob_free(void *data);
+static void efreet_mime_magic_free(void *data);
+static void efreet_mime_magic_entry_free(void *data);
+static int efreet_mime_glob_match(const char *str, const char *glob);
+static int efreet_mime_glob_case_match(char *str, const char *glob);
+static int efreet_mime_endian_check(void);
+
+static void efreet_mime_monitor_add(const char *file);
+static void efreet_mime_cb_update_file(void *data,
+                                        Ecore_File_Monitor *monitor,
+                                        Ecore_File_Event event,
+                                        const char *path);
+
+/**
+ * @return Returns 1 on success or 0 on failure
+ * @brief Initializes the efreet mime settings
+ */
+EAPI int
+efreet_mime_init(void)
+{
+    if (!ecore_init())
+        return 0;
+
+    if (!ecore_file_init())
+        return 0;
+
+    if (!efreet_init())
+        return 0;
+
+    efreet_mime_endianess = efreet_mime_endian_check();
+
+    monitors = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(monitors, ECORE_FREE_CB(free));
+    ecore_hash_free_value_cb_set(monitors,
+                    ECORE_FREE_CB(ecore_file_monitor_del));
+
+    if (!efreet_mime_init_files())
+        return 0;
+
+    return 1;
+}
+
+/**
+ * @return Returns no value
+ * @brief Cleans up the efreet mime settings system
+ */
+EAPI void
+efreet_mime_shutdown(void)
+{
+    IF_FREE_LIST(globs);
+    IF_FREE_LIST(magics);
+    IF_FREE_HASH(monitors);
+    IF_FREE_HASH(wild);
+
+    efreet_shutdown();
+    ecore_file_shutdown();
+    ecore_shutdown();
+}
+
+/**
+ * @param file: The file to find the mime type
+ * @return Returns mime type as a string
+ * @brief Retreive the mime type of a file
+ */
+EAPI const char *
+efreet_mime_type_get(const char *file)
+{
+    const char *type = NULL;
+
+    if ((type = efreet_mime_special_check(file)))
+        return type;
+
+    /* Check magics with priority > 80 */
+    if ((type = efreet_mime_magic_check_priority(file, 0, 80)))
+        return type;
+
+    /* Check globs */
+    if ((type = efreet_mime_globs_type_get(file)))
+        return type;
+
+    /* Check rest of magics */
+    if ((type = efreet_mime_magic_check_priority(file, 80, 0)))
+        return type;
+
+    return efreet_mime_fallback_check(file);
+}
+
+/**
+ * @param mime: The name of the mime type
+ * @param theme: The name of the theme to search icons in
+ * @param size: The wanted size of the icon
+ * @return Returns mime type icon path as a string
+ * @brief Retreive the mime type icon for a file
+ */
+EAPI char *
+efreet_mime_type_icon_get(const char *mime, const char *theme, unsigned int size)
+{
+    char *icon = NULL;
+    Ecore_List *icons  = NULL;
+    const char *env = NULL;
+    char *p = NULL, *pp = NULL, *ppp = NULL;
+    char buf[PATH_MAX];
+
+    if (!mime || !theme || !size)
+        return NULL;
+
+    icons = ecore_list_new();
+    ecore_list_free_cb_set(icons, free);
+
+    /* Standard icon name */
+    p = strdup(mime);
+    pp = p;
+    while (*pp)
+    {
+        if (*pp == '/') *pp = '-';
+        pp++;
+    }
+    ecore_list_append(icons, p);
+
+    /* Environment Based icon names */
+    if ((env = efreet_desktop_environment_get()))
+    {
+        snprintf(buf, sizeof(buf), "%s-mime-%s", env, p);
+        ecore_list_append(icons, strdup(buf));
+
+        snprintf(buf, sizeof(buf), "%s-%s", env, p);
+        ecore_list_append(icons, strdup(buf));
+    }
+
+    /* Mime prefixed icon names */
+    snprintf(buf, sizeof(buf), "mime-%s", p);
+    ecore_list_append(icons, strdup(buf));
+
+    /* Generic icons */
+    pp = strdup(p);
+    while ((ppp = strrchr(pp, '-')))
+    {
+        *ppp = '\0';
+
+        snprintf(buf, sizeof(buf), "%s-generic", pp);
+        ecore_list_append(icons, strdup(buf));
+
+        snprintf(buf, sizeof(buf), "%s", pp);
+        ecore_list_append(icons, strdup(buf));
+    }
+    FREE(pp);
+
+    /* Search for icons using list */
+    icon = efreet_icon_list_find(theme, icons, size);
+    ecore_list_destroy(icons);
+
+    return icon;
+}
+
+/**
+ * @param file: The file to check the mime type
+ * @return Returns mime type as a string
+ * @brief Retreive the mime type of a file using magic
+ */
+EAPI const char *
+efreet_mime_magic_type_get(const char *file)
+{
+    return efreet_mime_magic_check_priority(file, 0, 0);
+}
+
+/**
+ * @param file: The file to check the mime type
+ * @return Returns mime type as a string
+ * @brief Retreive the mime type of a file using globs
+ */
+EAPI const char *
+efreet_mime_globs_type_get(const char *file)
+{
+    Efreet_Mime_Glob *g;
+    char *sl, *p;
+    const char *s;
+    char *ext, *mime;
+
+    /* Check in the extension hash for the type */
+    ext = strchr(file, '.');
+    if (ext)
+    {
+        sl = alloca(strlen(ext) + 1);
+        for (s = ext, p = sl; *s; s++, p++) *p = tolower(*s);
+        *p = 0;
+        p = sl;
+        while (p)
+        {
+            p++;
+            if (p && (mime = ecore_hash_get(wild, p))) return mime;
+            p = strchr(p, '.');
+        }
+    }
+
+    /* Fallback to the other globs if not found */
+    ecore_list_first_goto(globs);
+    while ((g = ecore_list_next(globs)))
+    {
+        if (efreet_mime_glob_match(file, g->glob))
+            return g->mime;
+    }
+
+    ext = alloca(strlen(file) + 1);
+    for (s = file, p = ext; *s; s++, p++) *p = tolower(*s);
+    *p = 0;
+    ecore_list_first_goto(globs);
+    while ((g = ecore_list_next(globs)))
+    {
+        if (efreet_mime_glob_case_match(ext, g->glob))
+            return g->mime;
+    }
+    return NULL;
+}
+
+/**
+ * @param file: The file to check the mime type
+ * @return Returns mime type as a string
+ * @brief Retreive the special mime type of a file
+ */
+EAPI const char *
+efreet_mime_special_type_get(const char *file)
+{
+    return efreet_mime_special_check(file);
+}
+
+/**
+ * @param file: The file to check the mime type
+ * @return Returns mime type as a string
+ * @brief Retreive the fallback mime type of a file
+ */
+EAPI const char *
+efreet_mime_fallback_type_get(const char *file)
+{
+    return efreet_mime_fallback_check(file);
+}
+
+/**
+ * @internal
+ * @return Returns the endianess
+ * @brief Retreive the endianess of the machine
+ */
+static int
+efreet_mime_endian_check(void)
+{
+    int test = 1;
+    return (*((char*)(&test)));
+}
+
+/**
+ * @internal
+ * @param file: File to monitor
+ * @return Returns no value.
+ * @brief Creates a new file monitor if we aren't already monitoring the
+ * given file
+ */
+static void
+efreet_mime_monitor_add(const char *file)
+{
+    Ecore_File_Monitor *fm = NULL;
+
+    /* if this is already in our hash then we're already monitoring so no
+     * reason to re-monitor */
+    if (ecore_hash_get(monitors, file))
+        return;
+
+    if ((fm = ecore_file_monitor_add(file, efreet_mime_cb_update_file, NULL)))
+        ecore_hash_set(monitors, strdup(file), fm);
+}
+
+/**
+ * @internal
+ * @param datadirs: List of XDG data dirs
+ * @param datahome: Path to XDG data home directory
+ * @return Returns no value
+ * @brief Read all glob files in XDG data/home dirs.
+ * Also reads the /etc/mime.types file.
+ */
+static void
+efreet_mime_load_globs(Ecore_List *datadirs, const char *datahome)
+{
+    char buf[4096];
+    const char *datadir = NULL;
+
+    IF_FREE_HASH(wild);
+    wild = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(wild, ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_value_cb_set(wild,
+                    ECORE_FREE_CB(ecore_string_release));
+    IF_FREE_LIST(globs);
+    globs = ecore_list_new();
+    ecore_list_free_cb_set(globs, efreet_mime_glob_free);
+
+
+    /*
+     * This is here for legacy reasons.  It is mentioned briefly
+     * in the spec and seems to still be quite valid.  It is
+     * loaded first so the globs files will override anything
+     * in here.
+    */
+    efreet_mime_mime_types_load("/etc/mime.types");
+
+    datadir = datahome;
+    ecore_list_first_goto(datadirs);
+    while (datadir)
+    {
+        snprintf(buf, sizeof(buf), "%s/mime/globs", datadir);
+        efreet_mime_shared_mimeinfo_globs_load(buf);
+
+        datadir = ecore_list_next(datadirs);
+    }
+}
+
+/**
+ * @internal
+ * @param datadirs: List of XDG data dirs
+ * @param datahome: Path to XDG data home directory
+ * @return Returns no value
+ * @brief Read all magic files in XDG data/home dirs.
+ */
+static void
+efreet_mime_load_magics(Ecore_List *datadirs, const char *datahome)
+{
+    char buf[4096];
+    const char *datadir = NULL;
+
+    IF_FREE_LIST(magics);
+    magics = ecore_list_new();
+    ecore_list_free_cb_set(magics, efreet_mime_magic_free);
+
+    datadir = datahome;
+    ecore_list_first_goto(datadirs);
+    while (datadir)
+    {
+        snprintf(buf, sizeof(buf), "%s/mime/magic", datadir);
+        efreet_mime_shared_mimeinfo_magic_load(buf);
+
+        datadir = ecore_list_next(datadirs);
+    }
+}
+
+/**
+ * @internal
+ * @param data: Data pointer passed to monitor_add
+ * @param monitor: Ecore_File_Monitor associated with this event
+ * @param event: The type of event
+ * @param path: Path to the file that was updated
+ * @return Returns no value
+ * @brief Callback for all file monitors.  Just reloads the appropriate
+ * list depending on which file changed.  If it was a magic file
+ * only the magic list is updated.  If it was a glob file or /etc/mime.types,
+ * the globs are updated.
+ */
+static void
+efreet_mime_cb_update_file(void *data __UNUSED__,
+                    Ecore_File_Monitor *monitor __UNUSED__,
+                    Ecore_File_Event event __UNUSED__,
+                    const char *path)
+{
+    Ecore_List *datadirs = NULL;
+    const char *datahome = NULL;
+
+    if (!(datahome = efreet_data_home_get()))
+        return;
+
+    if (!(datadirs = efreet_data_dirs_get()))
+        return;
+
+    if (strstr(path, "magic"))
+        efreet_mime_load_magics(datadirs, datahome);
+    else
+        efreet_mime_load_globs(datadirs, datahome);
+}
+
+/**
+ * @internal
+ * @param datadirs: List of XDG data dirs
+ * @param datahome: Path to XDG data home directory
+ * @return Returns 1 on success, 0 on failure
+ * @brief Initializes globs, magics, and monitors lists.
+ */
+static int
+efreet_mime_init_files(void)
+{
+    Ecore_List *datadirs = NULL;
+    char buf[PATH_MAX];
+    const char *datahome, *datadir = NULL;
+
+    if (!(datahome = efreet_data_home_get()))
+        return 0;
+
+    if (!(datadirs = efreet_data_dirs_get()))
+        return 0;
+
+    /*
+     * Add our file monitors
+     * We watch the directories so we can watch for new files
+     */
+    datadir = datahome;
+    ecore_list_first_goto(datadirs);
+    while (datadir)
+    {
+        snprintf(buf, PATH_MAX, "%s/mime", datadir);
+        efreet_mime_monitor_add(buf);
+
+        datadir = ecore_list_next(datadirs);
+    }
+    efreet_mime_monitor_add("/etc/mime.types");
+
+    /* Load our mime information */
+    efreet_mime_load_globs(datadirs, datahome);
+    efreet_mime_load_magics(datadirs, datahome);
+
+    return 1;
+}
+
+/**
+ * @internal
+ * @param file: File to examine
+ * @return Returns mime type if special file, else NULL
+ * @brief Returns a mime type based on the stat of a file.
+ * This is used first to catch directories and other special
+ * files.  A NULL return doesn't necessarily mean failure, but
+ * can also mean the file is regular.
+ * @note Mapping of file types to mime types:
+ * Stat Macro   File Type           Mime Type
+ * S_IFREG      regular             NULL
+ * S_IFIFO      named pipe (fifo)   inode/fifo
+ * S_IFCHR      character special   inode/chardevice
+ * S_IFDIR      directory           inode/directory
+ * S_IFBLK      block special       inode/blockdevice
+ * S_IFLNK      symbolic link       inode/symlink
+ * S_IFSOCK     socket              inode/socket
+ *
+ * This function can also return inode/mount-point.
+ * This is calculated by comparing the st_dev of the directory
+ * against that of it's parent directory.  If they differ it
+ * is considered a mount point.
+ */
+static const char *
+efreet_mime_special_check(const char *file)
+{
+    struct stat s;
+    int path_len = 0;
+
+    if (!lstat(file, &s))
+    {
+        if (S_ISREG(s.st_mode))
+            return NULL;
+
+        if (S_ISLNK(s.st_mode))
+            return "inode/symlink";
+
+        if (S_ISFIFO(s.st_mode))
+            return "inode/fifo";
+
+        if (S_ISCHR(s.st_mode))
+            return "inode/chardevice";
+
+        if (S_ISBLK(s.st_mode))
+            return "inode/blockdevice";
+
+        if (S_ISSOCK(s.st_mode))
+            return "inode/socket";
+
+        if (S_ISDIR(s.st_mode))
+        {
+            struct stat s2;
+            char parent[PATH_MAX];
+            char path[PATH_MAX];
+
+            strncpy(path, file, PATH_MAX);
+
+            path_len = strlen(file);
+            strncpy(parent, path, PATH_MAX);
+
+            /* Kill any trailing slash */
+            parent[--path_len] = '\0';
+
+            /* Truncate to last slash */
+            while (parent[--path_len] != '/') parent[path_len] = '\0';
+
+            if (!lstat(parent, &s2))
+            {
+                if (s.st_dev != s2.st_dev)
+                    return "inode/mount-point";
+            }
+
+            return "inode/directory";
+        }
+
+        return NULL;
+    }
+
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param file: File to examine
+ * @return Returns mime type or NULL if the file doesn't exist
+ * @brief Returns text/plain if the file appears to contain text and
+ * returns application/octet-stream if it appears to be binary.
+ */
+static const char *
+efreet_mime_fallback_check(const char *file)
+{
+    FILE *f = NULL;
+    char buf[32];
+    int i;
+
+    if (!(f = fopen(file, "r"))) return NULL;
+
+    i = fread(buf, 1, sizeof(buf), f);
+    fclose(f);
+
+    if (i == 0) return "application/octet-stream";
+
+    /*
+     * Check for ASCII control characters in the first 32 bytes.
+     * Line Feeds, carriage returns, and tabs are ignored as they are
+     * quite common in text files in the first 32 chars.
+     */
+    for (i -= 1; i >= 0; --i)
+    {
+        if ((buf[i] < 0x20) &&
+            (buf[i] != '\n') &&     /* Line Feed */
+            (buf[i] != '\r') &&     /* Carriage Return */
+            (buf[i] != '\t'))       /* Tab */
+            return "application/octet-stream";
+    }
+
+    return "text/plain";
+}
+
+/**
+ * @internal
+ * @param glob: Glob to search for
+ * @return Returns 1 on success, 0 on failure
+ * @brief Removes a glob from the list
+ */
+static int
+efreet_mime_glob_remove(const char *glob)
+{
+    Efreet_Mime_Glob *mime = NULL;
+
+    mime = ecore_list_first_goto(globs);
+    while ((mime = ecore_list_current(globs)))
+    {
+        if (!strcmp(glob, mime->glob))
+        {
+            ecore_list_remove(globs);
+            IF_RELEASE(mime->glob);
+            IF_RELEASE(mime->mime);
+            FREE(mime);
+            return 1;
+        }
+        ecore_list_next(globs);
+    }
+
+    return 0;
+}
+
+/**
+ * @internal
+ * @param file: mime.types file to load
+ * @return Returns no value
+ * @brief Loads values from a mime.types style file
+ * into the globs list.
+ * @note Format:
+ * application/msaccess     mdb
+ * application/msword       doc dot
+ */
+static void
+efreet_mime_mime_types_load(const char *file)
+{
+    FILE *f = NULL;
+    char buf[4096], mimetype[4096];
+    char ext[4096], *p = NULL, *pp = NULL;
+
+    f = fopen(file, "rb");
+    if (!f) return;
+    while (fgets(buf, sizeof(buf), f))
+    {
+        p = buf;
+        while (isspace(*p) && (*p != 0) && (*p != '\n')) p++;
+
+        if (*p == '#') continue;
+        if ((*p == '\n') || (*p == 0)) continue;
+
+        pp = p;
+        while (!isspace(*p) && (*p != 0) && (*p != '\n')) p++;
+
+        if ((*p == '\n') || (*p == 0)) continue;
+        strncpy(mimetype, pp, (p - pp));
+        mimetype[p - pp] = 0;
+
+        do
+        {
+            while (isspace(*p) && (*p != 0) && (*p != '\n')) p++;
+
+            if ((*p == '\n') || (*p == 0)) break;
+
+            pp = p;
+            while (!isspace(*p) && (*p != 0) && (*p != '\n')) p++;
+
+            strncpy(ext, pp, (p - pp));
+            ext[p - pp] = 0;
+
+            ecore_hash_set(wild, (void*)ecore_string_instance(ext),
+                                            (void*)ecore_string_instance(mimetype));
+        }
+        while ((*p != '\n') && (*p != 0));
+    }
+    fclose(f);
+}
+
+/**
+ * @internal
+ * @param file: globs file to load
+ * @return Returns no value
+ * @brief Loads values from a mime.types style file
+ * into the globs list.
+ * @note Format:
+ * text/vnd.wap.wml:*.wml
+ * application/x-7z-compressed:*.7z
+ * application/vnd.corel-draw:*.cdr
+ * text/spreadsheet:*.sylk
+ */
+static void
+efreet_mime_shared_mimeinfo_globs_load(const char *file)
+{
+    FILE *f = NULL;
+    char buf[4096], mimetype[4096], ext[4096], *p, *pp;
+    Efreet_Mime_Glob *mime = NULL;
+
+    f = fopen(file, "rb");
+    if (!f) return;
+
+    while (fgets(buf, sizeof(buf), f))
+    {
+        p = buf;
+        while (isspace(*p) && (*p != 0) && (*p != '\n')) p++;
+
+        if (*p == '#') continue;
+        if ((*p == '\n') || (*p == 0)) continue;
+
+        pp = p;
+        while ((*p != ':') && (*p != 0) && (*p != '\n')) p++;
+
+        if ((*p == '\n') || (*p == 0)) continue;
+        strncpy(mimetype, pp, (p - pp));
+        mimetype[p - pp] = 0;
+        p++;
+        pp = ext;
+
+        while ((*p != 0) && (*p != '\n'))
+        {
+            *pp = *p;
+            pp++;
+            p++;
+        }
+
+        *pp = 0;
+
+        if (ext[0] == '*' && ext[1] == '.')
+        {
+            ecore_hash_set(wild, (void*)ecore_string_instance(&(ext[2])),
+                                      (void*)ecore_string_instance(mimetype));
+        }
+        else
+        {
+            mime = NEW(Efreet_Mime_Glob, 1);
+            if (mime)
+            {
+                mime->mime = ecore_string_instance(mimetype);
+                mime->glob = ecore_string_instance(ext);
+                if ((!mime->mime) || (!mime->glob))
+                {
+                    IF_RELEASE(mime->mime);
+                    IF_RELEASE(mime->glob);
+                    FREE(mime);
+                }
+                else
+                {
+                    efreet_mime_glob_remove(ext);
+                    ecore_list_append(globs, mime);
+                }
+            }
+        }
+    }
+
+    fclose(f);
+}
+
+/**
+ * @internal
+ * @param in: Number to count the digits
+ * @return Returns number of digits
+ * @brief Calculates and returns the number of digits
+ * in a number.
+ */
+static int
+efreet_mime_count_digits(int in)
+{
+    int i = 1, j = in;
+
+    if (j < 10) return 1;
+    while ((j /= 10) > 0) ++i;
+
+    return i;
+}
+
+/**
+ * @internal
+ * @param file: File to parse
+ * @return Returns no value
+ * @brief Loads a magic file and adds information to magics list
+ */
+static void
+efreet_mime_shared_mimeinfo_magic_load(const char *file)
+{
+    int fd = -1, size;
+    char *data = (void *)-1;
+
+    if (!file) return;
+
+    size = ecore_file_size(file);
+    if (size <= 0) return;
+
+    fd = open(file, O_RDONLY);
+    if (fd == -1) return;
+
+    data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
+    if (data == MAP_FAILED)
+    {
+        close(fd);
+        return;
+    }
+
+    efreet_mime_shared_mimeinfo_magic_parse(data, size);
+
+    munmap(data, size);
+    close(fd);
+}
+
+/**
+ * @param data: The data from the file
+ * @return Returns no value
+ * @brief Parses a magic file
+ * @note Format:
+ *
+ * ----------------------------------------------------------------------
+ * |                     HEX                         |    ASCII         |
+ * ----------------------------------------------------------------------
+ * |4D 49 4D 45 2D 4D 61 67 69 63 00 0A 5B 39 30 3A  | MIME-Magic..[90: |
+ * |61 70 70 6C 69 63 61 74 69 6F 6E 2F 64 6F 63 62  | application/docb |
+ * |6F 6F 6B 2B 78 6D 6C 5D 0A 3E 30 3D 00 05 3C 3F  | ook+xml].>0=..<? |
+ * |78 6D 6C 0A 31 3E 30 3D 00 19 2D 2F 2F 4F 41 53  | xml.1>0=..-//OAS |
+ * |49 53 2F 2F 44 54 44 20 44 6F 63 42 6F 6F 6B 20  | IS//DTD DocBook  |
+ * |58 4D 4C 2B 31 30 31 0A 31 3E 30 3D 00 17 2D 2F  | XML+101.1>0=..-/ |
+ * ----------------------------------------------------------------------
+ *
+ * indent
+ *   The nesting depth of the rule, corresponding to the number of '>'
+ *   characters in the traditional file format.
+ * ">" start-offset
+ *     The offset into the file to look for a match.
+ * "=" value
+ *     Two bytes giving the (big-endian) length of the value, followed by the
+ *     value itself.
+ * "&" mask
+ *     The mask, which (if present) is exactly the same length as the value.
+ * "~" word-size
+ *     On little-endian machines, the size of each group to byte-swap.
+ * "+" range-length
+ *     The length of the region in the file to check.
+ *
+ * The indent, range-length, word-size and mask components are optional.
+ * If missing, indent defaults to 0, range-length to 1, the word-size to 1,
+ * and the mask to all 'one' bits.  In our case, mask is null as it is
+ * quicker, uses less memory and will acheive the same exact effect.
+ */
+static void
+efreet_mime_shared_mimeinfo_magic_parse(char *data, int size)
+{
+    Efreet_Mime_Magic *mime = NULL;
+    Efreet_Mime_Magic_Entry *entry = NULL;
+    char *ptr;
+
+    ptr = data;
+
+    /* make sure we're a magic file */
+    if (!ptr || (size < 12) || strncmp(ptr, "MIME-Magic\0\n", 12))
+        return;
+
+    ptr += 12;
+
+    for (; (ptr - data) < size; )
+    {
+        if (*ptr == '[')
+        {
+            char *val, buf[512];
+
+            mime = NEW(Efreet_Mime_Magic, 1);
+            mime->entries = ecore_list_new();
+            ecore_list_free_cb_set(mime->entries,
+                                  efreet_mime_magic_entry_free);
+            ecore_list_append(magics, mime);
+
+            val = ++ptr;
+            while ((*val != ':')) val++;
+            memcpy(&buf, ptr, val - ptr);
+            buf[val - ptr] = '\0';
+
+            mime->priority = atoi(buf);
+            ptr = ++val;
+
+            while ((*val != ']')) val++;
+            memcpy(&buf, ptr, val - ptr);
+            buf[val - ptr] = '\0';
+
+            mime->mime = ecore_string_instance(buf);
+            ptr = ++val;
+
+            while (*ptr != '\n') ptr++;
+        }
+        else
+        {
+            short tshort;
+
+            if (!mime) continue;
+            if (!entry)
+            {
+                if (!(entry = NEW(Efreet_Mime_Magic_Entry, 1)))
+                {
+                    IF_FREE_LIST(magics);
+                    return;
+                }
+
+                entry->indent = 0;
+                entry->offset = 0;
+                entry->value_len = 0;
+                entry->word_size = 1;
+                entry->range_len = 1;
+                entry->mask = NULL;
+                entry->value = NULL;
+                ptr++;
+
+                ecore_list_append(mime->entries, entry);
+           }
+
+            switch(*ptr)
+            {
+                case '>':
+                    ptr ++;
+                    entry->offset = atoi(ptr);
+                    ptr += efreet_mime_count_digits(entry->offset);
+                    break;
+
+                case '=':
+                    ptr++;
+       
+                    memcpy(&tshort, ptr, sizeof(short));
+                    entry->value_len = ntohs(tshort);
+                    ptr += 2;
+
+                    entry->value = NEW(1, entry->value_len);
+                    memcpy(entry->value, ptr, entry->value_len);
+                    ptr += entry->value_len;
+                    break;
+
+                case '&':
+                    ptr++;
+                    entry->mask = NEW(1, entry->value_len);
+                    memcpy(entry->mask, ptr, entry->value_len);
+                    ptr += entry->value_len;
+                    break;
+
+                case '~':
+                    ptr++;
+                    entry->word_size = atoi(ptr);
+                    if (((entry->word_size != 0)
+                            && (entry->word_size != 1)
+                            && (entry->word_size != 2)
+                            && (entry->word_size != 4))
+                            || (entry->value_len % entry->word_size))
+                    {
+                        /* Invalid, Destroy */
+                        FREE(entry->value);
+                        FREE(entry->mask);
+                        FREE(entry);
+
+                        while (*ptr != '\n') ptr++;
+                        break;
+                    }
+
+                    if (efreet_mime_endianess == EFREET_ENDIAN_LITTLE)
+                    {
+                        int j;
+
+                        for (j = 0; j < entry->value_len; j += entry->word_size)
+                        {
+                            if (entry->word_size == 2)
+                            {
+                                ((short*)entry->value)[j] =
+                                              ntohs(((short*)entry->value)[j]);
+
+                                if (entry->mask)
+                                    ((short*)entry->mask)[j] =
+                                              ntohs(((short*)entry->mask)[j]);
+                            }
+                            else if (entry->word_size == 4)
+                            {
+                                ((int*)entry->value)[j] =
+                                              ntohl(((int*)entry->value)[j]);
+
+                                if (entry->mask)
+                                    ((int*)entry->mask)[j] =
+                                              ntohl(((int*)entry->mask)[j]);
+                            }
+                        }
+                    }
+
+                    ptr += efreet_mime_count_digits(entry->word_size);
+                    break;
+
+                case '+':
+                    ptr++;
+                    entry->range_len = atoi(ptr);
+                    ptr += efreet_mime_count_digits(entry->range_len);
+                    break;
+
+                case '\n':
+                    ptr++;
+                    entry = NULL;
+                    break;
+
+                default:
+                    if (isdigit(*ptr))
+                    {
+                        entry->indent = atoi(ptr);
+                        ptr += efreet_mime_count_digits(entry->indent);
+                    }
+                    break;
+            }
+        }
+    }
+
+    if (entry)
+    {
+        IF_FREE(entry->value);
+        IF_FREE(entry->mask);
+        FREE(entry);
+    }
+}
+
+/**
+ * @internal
+ * @param file: File to check
+ * @param start: Start priority, if 0 start at beginning
+ * @param end: End priority, should be less then start
+ * unless start
+ * @return Returns mime type for file if found, NULL if not
+ * @brief Applies magic rules to a file given a start and end priority
+ */
+static const char *
+efreet_mime_magic_check_priority(const char *file,
+                                  unsigned int start,
+                                  unsigned int end)
+{
+    Efreet_Mime_Magic *m = NULL;
+    Efreet_Mime_Magic_Entry *e = NULL;
+    FILE *f = NULL;
+    unsigned int i = 0, offset = 0,level = 0, match = 0, bytes_read = 0;
+    const char *last_mime = NULL;
+    char c, v, buf[EFREET_MIME_MAGIC_BUFFER_SIZE];
+
+    f = fopen(file, "rb");
+    if (!f) return NULL;
+
+    if (!(m = ecore_list_first_goto(magics)))
+    {
+        fclose(f);
+        return NULL;
+    }
+
+    if ((bytes_read = fread(buf, 1, sizeof(buf), f)) == 0)
+    {
+        fclose(f);
+        return NULL;
+    }
+
+    while ((m = ecore_list_next(magics)))
+    {
+        if ((start != 0) && (m->priority > start))
+            continue;
+
+        if (m->priority < end)
+            break;
+
+        ecore_list_first_goto(m->entries);
+        while ((e = ecore_list_next(m->entries)))
+        {
+            if ((level < e->indent) && !match)
+                continue;
+
+            if ((level >= e->indent) && !match)
+                level = e->indent;
+
+            else if ((level > e->indent) && match)
+            {
+                fclose(f);
+                if (last_mime) return last_mime;
+            }
+
+            for (offset = e->offset; offset < e->offset + e->range_len; offset++)
+            {
+                if (((offset + e->value_len) > bytes_read) &&
+                        (fseek(f, offset, SEEK_SET) == -1))
+                    break;
+
+                match = 1;
+                for (i = 0; i < e->value_len; ++i)
+                {
+                    if (offset + e->value_len > bytes_read)
+                        c = fgetc(f);
+                    else
+                        c = buf[offset + i];
+
+                    v = e->value[i];
+                    if (e->mask) v &= e->mask[i];
+
+                    if (!(c == v))
+                    {
+                        match = 0;
+                        break;
+                    }
+                }
+
+                if (match)
+                {
+                    level += 1;
+                    last_mime = m->mime;
+                    break;
+                }
+            }
+        }
+    }
+    fclose(f);
+
+    return NULL;
+}
+
+/**
+ * @internal
+ * @param data: Data pointer that is being destroyed
+ * @return Returns no value
+ * @brief Callback for globs destroy
+ */
+static void
+efreet_mime_glob_free(void *data)
+{
+    Efreet_Mime_Glob *m = data;
+
+    IF_RELEASE(m->mime);
+    IF_RELEASE(m->glob);
+    IF_FREE(m);
+}
+
+/**
+ * @internal
+ * @param data: Data pointer that is being destroyed
+ * @return Returns no value
+ * @brief Callback for magics destroy
+ */
+static void
+efreet_mime_magic_free(void *data)
+{
+    Efreet_Mime_Magic *m = data;
+
+    IF_RELEASE(m->mime);
+    IF_FREE_LIST(m->entries);
+    IF_FREE(m);
+}
+
+/**
+ * @internal
+ * @param data: Data pointer that is being destroyed
+ * @return Returns no value
+ * @brief Callback for magic entry destroy
+ */
+static void
+efreet_mime_magic_entry_free(void *data)
+{
+    Efreet_Mime_Magic_Entry *e = data;
+
+    IF_FREE(e->mask);
+    IF_FREE(e->value);
+    IF_FREE(e);
+}
+
+
+/**
+ * @internal
+ * @param str: String (filename) to match
+ * @param glob: Glob to match str to
+ * @return Returns 1 on success, 0 on failure
+ * @brief Compares str to glob, case sensitive
+ */
+static int
+efreet_mime_glob_match(const char *str, const char *glob)
+{
+    if (!str || !glob) return 0;
+    if (glob[0] == 0)
+    {
+        if (str[0] == 0) return 1;
+        return 0;
+    }
+    if (!fnmatch(glob, str, 0)) return 1;
+    return 0;
+}
+
+/**
+ * @internal
+ * @param str: String (filename) to match
+ * @param glob: Glob to match str to
+ * @return Returns 1 on success, 0 on failure
+ * @brief Compares str to glob, case insensitive (expects str already in lower case)
+ */
+static int
+efreet_mime_glob_case_match(char *str, const char *glob)
+{
+    const char *p;
+    char *tglob, *tp;
+
+    if (!str || !glob) return 0;
+    if (glob[0] == 0)
+    {
+        if (str[0] == 0) return 1;
+        return 0;
+    }
+    tglob = alloca(strlen(glob) + 1);
+    for (tp = tglob, p = glob; *p; p++, tp++) *tp = tolower(*p);
+    *tp = 0;
+    if (!fnmatch(str, tglob, 0)) return 1;
+    return 0;
+}
diff --git a/src/lib/efreet_private.h b/src/lib/efreet_private.h
new file mode 100644 (file)
index 0000000..dc30631
--- /dev/null
@@ -0,0 +1,214 @@
+/* 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 "config.h"
+#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 <sys/stat.h>
+#include <dirent.h>
+#include <fnmatch.h>
+#include <limits.h>
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#include <Ecore.h>
+#include <Ecore_File.h>
+#include <Ecore_Str.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) do { free(x); x = NULL; } while (0)
+
+/**
+ * @def IF_FREE(x)
+ * If x is set, free x and set to NULL
+ */
+#define IF_FREE(x) do { if (x) FREE(x); } while (0)
+
+/**
+ * @def IF_RELEASE(x)
+ * If x is set, ecore_string_release x and set to NULL
+ */
+#define IF_RELEASE(x) do { \
+    if (x) { \
+        const char *__tmp; __tmp = (x); (x) = NULL; ecore_string_release(__tmp); \
+    } \
+    (x) = NULL; \
+} while (0)
+
+/**
+ * @def IF_FREE_LIST(x)
+ * If x is a valid pointer destroy x and set to NULL
+ */
+#define IF_FREE_LIST(x) do { \
+    if (x) { \
+        Ecore_List *__tmp; __tmp = (x); (x) = NULL; ecore_list_destroy(__tmp); \
+    } \
+    (x) = NULL; \
+} while (0)
+
+/**
+ * @def IF_FREE_DLIST(x)
+ * If x is a valid pointer destroy x and set to NULL
+ */
+#define IF_FREE_DLIST(x) do { \
+    if (x) { \
+        Ecore_DList *__tmp; __tmp = (x); (x) = NULL; ecore_dlist_destroy(__tmp); \
+    } \
+    (x) = NULL; \
+} while (0)
+
+/**
+ * @def IF_FREE_HASH(x)
+ * If x is a valid pointer destroy x and set to NULL
+ */
+#define IF_FREE_HASH(x) do { \
+    if (x) { \
+        Ecore_Hash *__tmp; __tmp = (x); (x) = NULL; ecore_hash_destroy(__tmp); \
+    } \
+    (x) = NULL; \
+} while (0)
+
+/**
+ * @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);
+Ecore_List *efreet_default_dirs_get(const char *user_dir,
+                                    Ecore_List *system_dirs,
+                                    const char *suffix);
+
+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[]);
+
+const char *efreet_desktop_environment_get(void);
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_trash.c b/src/lib/efreet_trash.c
new file mode 100644 (file)
index 0000000..c43cb02
--- /dev/null
@@ -0,0 +1,199 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include <errno.h>
+#include <time.h>
+#include "Efreet.h"
+#include "Efreet_Trash.h"
+#include "efreet_private.h"
+
+static const char *efreet_trash_dir = NULL;
+
+/**
+ * @return Returns 1 on success or 0 on failure
+ * @brief Initializes the efreet trash system
+ */
+EAPI int
+efreet_trash_init(void)
+{
+    return 1;
+}
+
+/**
+ * @return Returns no value
+ * @brief Cleans up the efreet trash system
+ */
+EAPI void
+efreet_trash_shutdown(void)
+{
+    IF_RELEASE(efreet_trash_dir);
+}
+
+/**
+ * @return Returns the XDG Trash local directory or NULL on errors
+ * @brief Retrieves the XDG Trash local directory
+ */
+EAPI const char*
+efreet_trash_dir_get(void)
+{
+    char buf[PATH_MAX];
+
+    if (efreet_trash_dir && ecore_file_exists(efreet_trash_dir))
+        return efreet_trash_dir;
+
+    snprintf(buf, sizeof(buf), "%s/Trash", efreet_data_home_get());
+    if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
+        return NULL;
+
+    IF_RELEASE(efreet_trash_dir);
+    efreet_trash_dir = ecore_string_instance(buf);
+
+    snprintf(buf, sizeof(buf), "%s/files", efreet_trash_dir);
+    if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
+        return NULL;
+
+    snprintf(buf, sizeof(buf), "%s/info", efreet_trash_dir);
+    if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
+        return NULL;
+
+    return efreet_trash_dir;
+}
+
+/**
+ * @param uri: The local uri to move in the trash
+ * @param force_delete: If you set this to 1 than files on different filesystems
+ * will be deleted permanently
+ * @return Return 1 on success, 0 on failure or -1 in case the uri is not on the
+ * same filesystem and force_delete is not set.
+ * @brief This function try to move the given uri to the trash. Files on 
+ * different filesystem can't be moved to trash. If force_delete
+ * is 0 than non-local files will be ignored and -1 is returned, if you set
+ * force_delete to 1 non-local files will be deleted without asking.
+ */
+EAPI int
+efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
+{
+    char dest[PATH_MAX];
+    char times[64];
+    const char *fname;
+    const char *escaped;
+    int i = 1;
+    time_t now;
+    FILE *f;
+
+    if (!uri || !uri->path || !ecore_file_can_write(uri->path)) return 0;
+
+    fname = ecore_file_file_get(uri->path);
+    snprintf(dest, PATH_MAX, "%s/files/%s", efreet_trash_dir_get(), fname);
+
+    /* search for a free filename */
+    while (ecore_file_exists(dest))
+        snprintf(dest, PATH_MAX, "%s/files/%s$%d",
+                 efreet_trash_dir_get(), fname, i++);
+    fname = ecore_file_file_get(dest);
+
+    /* move file to trash dir */
+    if (rename(uri->path, dest))
+    {
+        if (errno == EXDEV)
+        {
+            if (!force_delete) return -1;
+            if (!ecore_file_recursive_rm(uri->path))
+            {
+                printf("EFREET TRASH ERROR: Can't delete file.\n");
+                return 0; 
+            }
+        }
+        else
+        {
+            printf("EFREET TRASH ERROR: Can't move file to trash.\n");
+            return 0;
+        }
+    }
+
+    /* create info file */
+    snprintf(dest, PATH_MAX, "%s/info/%s.trashinfo",
+             efreet_trash_dir_get(), fname);
+
+    if (f = fopen(dest, "w"))
+    {
+        fputs("[Trash Info]\n", f); //TODO is '\n' right?? (or \r\c??)
+
+        fputs("Path=", f);
+        escaped = efreet_uri_encode(uri);
+        fputs(escaped + 7, f); // +7 == don't write 'file://'
+        IF_RELEASE(escaped);
+
+        time(&now);
+        strftime(times, sizeof(times), "%Y-%m-%dT%H:%M:%S", localtime(&now));
+        fputs("\nDeletionDate=", f);
+        fputs(times, f);
+        fputs("\n", f);
+        fclose(f);
+    }
+    else
+    {
+        printf("EFREET TRASH ERROR: Can't create trash info file.\n");
+        return 0;
+    }
+
+    return 1;
+}
+
+/**
+ * @return Return 1 if the trash is empty or 0 if some file are in.
+ * @brief Check if the trash is currently empty
+ */
+EAPI int
+efreet_trash_is_empty(void)
+{
+    char buf[PATH_MAX];
+    snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get());
+   
+    /* TODO Check also trash in other filesystems */
+    return ecore_file_dir_is_empty(buf);
+}
+
+/**
+ * @return Return 1 on success or 0 on failure
+ * @brief Delete all the files inside the trash.
+ */
+EAPI int
+efreet_trash_empty_trash(void)
+{
+    char buf[PATH_MAX];
+
+    snprintf(buf, PATH_MAX, "%s/info", efreet_trash_dir_get());
+    if (!ecore_file_recursive_rm(buf)) return 0;
+    ecore_file_mkdir(buf);
+
+    snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get());
+    if (!ecore_file_recursive_rm(buf)) return 0;
+    ecore_file_mkdir(buf);
+
+    /* TODO Empty also trash in other filesystems */
+    return 1;
+}
+
+/**
+ * @return Return a list of strings with filename (remember to free the list
+ * when you don't need anymore)
+ * @brief List all the files and directory currently inside the trash.
+ */
+EAPI Ecore_List*
+efreet_trash_ls(void)
+{
+    char *infofile;
+    char buf[PATH_MAX];
+    Ecore_List *files;
+
+    // NOTE THIS FUNCTION NOW IS NOT COMPLETE AS I DON'T NEED IT
+    // TODO read the name from the infofile instead of the filename
+
+    snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get());
+    files = ecore_file_ls(buf);
+
+    while (infofile = ecore_list_next(files))
+        printf("FILE: %s\n", infofile);
+
+    return files;
+}
+
diff --git a/src/lib/efreet_uri.c b/src/lib/efreet_uri.c
new file mode 100644 (file)
index 0000000..e50d7ce
--- /dev/null
@@ -0,0 +1,117 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "efreet_private.h"
+
+
+/**
+ * @param full_uri: a valid uri string to parse
+ * @return Return The corresponding Efreet_Uri structure. Or NULL on errors.
+ * @brief Read a single uri and return an Efreet_Uri struct. If there's no
+ * hostname in the uri then the hostname parameter will be NULL. All the uri
+ * escaped chars will be converted to normal.
+ */
+EAPI Efreet_Uri *
+efreet_uri_decode(const char *full_uri)
+{
+    Efreet_Uri *uri;
+    const char *p;
+    char protocol[64], hostname[_POSIX_HOST_NAME_MAX], path[PATH_MAX];
+    int i = 0;
+
+    /* An uri should be in the form <protocol>://<hostname>/<path> */
+    if (!strstr(full_uri, "://")) return NULL;
+
+    memset(protocol, 0, 64);
+    memset(hostname, 0, _POSIX_HOST_NAME_MAX);
+    memset(path, 0, PATH_MAX);
+
+    /* parse protocol */
+    p = full_uri;
+    for (i = 0; *p != ':' && *p != '\0' && i < 64; p++, i++)
+         protocol[i] = *p;
+    protocol[i] = '\0';
+
+    /* parse hostname */
+    p += 3;
+    if (*p != '/')
+    {
+        for (i = 0; *p != '/' && *p != '\0' && i < _POSIX_HOST_NAME_MAX; p++, i++)
+            hostname[i] = *p;
+        hostname[i] = '\0';
+    }
+    else
+        hostname[0] = '\0';
+
+    /* parse path */
+    /* See http://www.faqs.org/rfcs/rfc1738.html for the escaped chars */
+    for (i = 0; *p != '\0' && i < PATH_MAX; i++, p++)
+    {
+        if (*p == '%')
+        {
+            path[i] = *(++p);
+            path[i + 1] = *(++p);
+            path[i] = (char)strtol(&(path[i]), NULL, 16);
+            path[i + 1] = '\0';
+        }
+        else
+            path[i] = *p;
+    }
+
+    uri = NEW(Efreet_Uri, 1);
+    if (!uri) return NULL;
+
+    uri->protocol = ecore_string_instance(protocol);
+    uri->hostname = ecore_string_instance(hostname);
+    uri->path = ecore_string_instance(path);
+
+    return uri;
+}
+
+/**
+ * @param uri: Create an URI string from an Efreet_Uri struct
+ * @return The string rapresentation of uri (ex: 'file:///home/my%20name')
+ * @brief Get the string rapresentation of the given uri struct escaping
+ * illegal caracters. Remember to free the string with ecore_string_release()
+ * when you don't need it anymore.
+ * @note The resulting string will contain the protocol and the path but not
+ * the hostname, as many apps doesn't handle it.
+ */
+EAPI const char *
+efreet_uri_encode(Efreet_Uri *uri)
+{
+    char dest[PATH_MAX * 3 + 4];
+    const char *p;
+    int i;
+
+    if (!uri || !uri->path || !uri->protocol) return NULL;
+    memset(dest, 0, PATH_MAX * 3 + 4);
+    snprintf(dest, strlen(uri->protocol) + 4, "%s://", uri->protocol);
+
+    /* Most app doesn't handle the hostname in the uri so it's put to NULL */
+    for (i = strlen(uri->protocol) + 3, p = uri->path; *p != '\0'; p++, i++)
+    {
+        if (isalnum(*p) || strchr("/$-_.+!*'()", *p))
+            dest[i] = *p;
+        else
+        {
+            snprintf(&(dest[i]), 4, "%%%02X", *p);
+            i += 2;
+        }
+    }
+
+    return ecore_string_instance(dest);
+}
+
+/**
+ * @param uri: The uri to free
+ * @brief Free the given uri structure.
+ */
+EAPI void
+efreet_uri_free(Efreet_Uri *uri)
+{
+    if (!uri) return;
+    IF_RELEASE(uri->protocol);
+    IF_RELEASE(uri->path);
+    IF_RELEASE(uri->hostname);
+    FREE(uri);
+}
diff --git a/src/lib/efreet_uri.h b/src/lib/efreet_uri.h
new file mode 100644 (file)
index 0000000..6b8548b
--- /dev/null
@@ -0,0 +1,43 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#ifndef EFREET_URI_H
+#define EFREET_URI_H
+
+/**
+ * @file efreet_uri.h
+ * @brief Contains the methods used to support the FDO URI specification.
+ * @addtogroup Efreet_Uri Efreet_Uri: The FDO URI Specification functions
+ * @{
+ */
+
+#include <Ecore.h>
+#include <Ecore_Data.h>
+
+
+/**
+ * Efreet_Uri
+ */
+typedef struct Efreet_Uri Efreet_Uri;
+
+/**
+ * Efreet_Uri
+ * @brief Contains a simple rappresentation of an uri. The string don't have 
+ * special chars escaped.
+ */
+struct Efreet_Uri
+{
+    const char *protocol;   /**< The protocol used (usually 'file')*/
+    const char *hostname;   /**< The name of the host if any, or NULL */
+    const char *path;       /**< The full file path whitout protocol nor host*/
+};
+
+
+EAPI const char *efreet_uri_encode(Efreet_Uri *uri);
+EAPI Efreet_Uri *efreet_uri_decode(const char *val);
+EAPI void        efreet_uri_free(Efreet_Uri *uri);
+
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/efreet_utils.c b/src/lib/efreet_utils.c
new file mode 100644 (file)
index 0000000..629d17f
--- /dev/null
@@ -0,0 +1,1101 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#include "Efreet.h"
+#include "efreet_private.h"
+
+typedef struct Efreet_Cache_Fill        Efreet_Cache_Fill;
+typedef struct Efreet_Cache_Fill_Dir    Efreet_Cache_Fill_Dir;
+typedef struct Efreet_Cache_Search      Efreet_Cache_Search;
+typedef struct Efreet_Cache_Search_List Efreet_Cache_Search_List;
+typedef struct Efreet_Monitor           Efreet_Monitor;
+typedef struct Efreet_Util_Desktop      Efreet_Util_Desktop;
+
+struct Efreet_Cache_Fill
+{
+    Ecore_List            *dirs;
+    Efreet_Cache_Fill_Dir *current;
+    DIR  *files;
+};
+
+struct Efreet_Cache_Fill_Dir
+{
+    char *path;
+    char *file_id;
+    int   priority;
+};
+
+struct Efreet_Cache_Search
+{
+    const char *what1;
+    const char *what2;
+};
+
+struct Efreet_Cache_Search_List
+{
+    Ecore_List *list;
+    const char *what;
+};
+
+struct Efreet_Monitor
+{
+    char *file_id;
+    Ecore_File_Monitor *monitor;
+    int priority;
+};
+
+struct Efreet_Util_Desktop
+{
+    Efreet_Desktop *desktop;
+    int priority;
+};
+
+static char *efreet_util_path_in_default(const char *section, const char *path);
+
+static int  efreet_util_cache_fill(void *data);
+static void efreet_util_cache_add(const char *path, const char *file_id, int priority, int event);
+static void efreet_util_cache_remove(const char *path, const char *file_id, int priority);
+static void efreet_util_cache_reload(const char *path, const char *file_id, int priority);
+static void efreet_util_cache_dir_free(void *data);
+
+static void efreet_util_cache_search_mime(void *value, void *data);
+static int  efreet_util_cache_search_wm_class(const void *value, const void *data);
+static int  efreet_util_cache_search_exec(const void *value, const void *data);
+static int  efreet_util_cache_search_name(const void *value, const void *data);
+static int  efreet_util_cache_search_generic_name(const void *value, const void *data);
+
+static void efreet_util_cache_search_name_glob(void *value, void *data);
+static void efreet_util_cache_search_exec_glob(void *value, void *data);
+static void efreet_util_cache_search_generic_name_glob(void *value, void *data);
+static void efreet_util_cache_search_comment_glob(void *value, void *data);
+
+static int  efreet_util_glob_match(const char *str, const char *glob);
+
+static void efreet_util_monitor(const char *path, const char *file_id, int priority);
+static void efreet_util_monitor_cb(void *data, Ecore_File_Monitor *monitor,
+                                    Ecore_File_Event event, const char *path);
+static void efreet_util_monitor_free(void *data);
+static void efreet_util_menus_find_helper(Ecore_List *menus, const char *config_dir);
+
+static void efreet_util_desktops_by_category_add(Efreet_Desktop *desktop);
+static void efreet_util_desktops_by_category_remove(Efreet_Desktop *desktop);
+
+static void efreet_util_desktop_free(Efreet_Util_Desktop *ud);
+static void efreet_event_desktop_change_free(void *data, void *ev);
+
+static Ecore_Hash *desktop_by_file_id = NULL;
+static Ecore_Hash *file_id_by_desktop_path = NULL;
+static Ecore_Hash *desktops_by_category = NULL;
+
+static Ecore_Idler       *idler = NULL;
+static Efreet_Cache_Fill *fill = NULL;
+
+static Ecore_List *monitors = NULL;
+
+static int init = 0;
+
+EAPI int EFREET_EVENT_DESKTOP_LIST_CHANGE = 0;
+EAPI int EFREET_EVENT_DESKTOP_CHANGE = 0;
+
+EAPI int
+efreet_util_init(void)
+{
+    Ecore_List *dirs;
+
+    if (init++) return init;
+
+    if (!EFREET_EVENT_DESKTOP_LIST_CHANGE)
+        EFREET_EVENT_DESKTOP_LIST_CHANGE = ecore_event_type_new();
+    if (!EFREET_EVENT_DESKTOP_CHANGE)
+        EFREET_EVENT_DESKTOP_CHANGE = ecore_event_type_new();
+    desktop_by_file_id = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(desktop_by_file_id, ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_value_cb_set(desktop_by_file_id, ECORE_FREE_CB(efreet_util_desktop_free));
+
+    file_id_by_desktop_path = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(file_id_by_desktop_path, ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_value_cb_set(file_id_by_desktop_path, ECORE_FREE_CB(ecore_string_release));
+
+    desktops_by_category = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+    ecore_hash_free_key_cb_set(desktops_by_category, ECORE_FREE_CB(ecore_string_release));
+    ecore_hash_free_value_cb_set(desktops_by_category, ECORE_FREE_CB(ecore_list_destroy));
+
+    monitors = ecore_list_new();
+    ecore_list_free_cb_set(monitors, efreet_util_monitor_free);
+
+    fill = NEW(Efreet_Cache_Fill, 1);
+    fill->dirs = ecore_list_new();
+    ecore_list_free_cb_set(fill->dirs, efreet_util_cache_dir_free);
+    dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
+                                                                    "applications");
+    if (dirs)
+    {
+        Efreet_Cache_Fill_Dir *dir;
+        char *path;
+        int priority = 0;
+
+        while ((path = ecore_list_first_remove(dirs)))
+        {
+            dir = NEW(Efreet_Cache_Fill_Dir, 1);
+            dir->path = path;
+            dir->priority = priority++;
+            ecore_list_append(fill->dirs, dir);
+        }
+        ecore_list_destroy(dirs);
+    }
+    idler = ecore_idler_add(efreet_util_cache_fill, NULL);
+    return init;
+}
+
+EAPI int
+efreet_util_shutdown(void)
+{
+    if (--init) return init;
+
+    if (idler)
+    {
+        ecore_idler_del(idler);
+        IF_FREE_LIST(fill->dirs);
+        if (fill->current) efreet_util_cache_dir_free(fill->current);
+        if (fill->files) closedir(fill->files);
+        free(fill);
+    }
+    idler = NULL;
+
+    IF_FREE_HASH(desktop_by_file_id);
+    IF_FREE_HASH(file_id_by_desktop_path);
+
+    IF_FREE_LIST(monitors);
+
+    IF_FREE_HASH(desktops_by_category);
+
+    return init;
+}
+
+static char *
+efreet_util_path_in_default(const char *section, const char *path)
+{
+    Ecore_List *dirs;
+    char *ret = NULL;
+    char *dir;
+
+    dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
+                                                                    section);
+
+    ecore_list_first_goto(dirs);
+    while ((dir = ecore_list_next(dirs)))
+    {
+        size_t len;
+
+        len = strlen(dir);
+        if (!strncmp(path, dir, strlen(dir)))
+        {
+            ret = strdup(dir);
+            break;
+        }
+    }
+
+    ecore_list_destroy(dirs);
+    return ret;
+}
+
+EAPI const char *
+efreet_util_path_to_file_id(const char *path)
+{
+    size_t len;
+    char *tmp, *p;
+    char *base;
+    const char *file_id = NULL;
+
+    if (!path) return NULL;
+    file_id = ecore_hash_get(file_id_by_desktop_path, path);
+    if (file_id) return file_id;
+
+    base = efreet_util_path_in_default("applications", path);
+    if (!base) return NULL;
+
+    len = strlen(base);
+    if (strlen(path) <= len)
+    {
+        free(base);
+        return NULL;
+    }
+    if (strncmp(path, base, len))
+    {
+        free(base);
+        return NULL;
+    }
+
+    tmp = strdup(path + len + 1);
+    p = tmp;
+    while (*p)
+    {
+        if (*p == '/') *p = '-';
+        p++;
+    }
+    free(base);
+    file_id = ecore_string_instance(tmp);
+    free(tmp);
+    ecore_hash_set(file_id_by_desktop_path, (void *)ecore_string_instance(path),
+                                                        (void *)file_id);
+    return file_id;
+}
+
+EAPI Ecore_List *
+efreet_util_desktop_mime_list(const char *mime)
+{
+    Efreet_Cache_Search_List search;
+
+    search.list = ecore_list_new();
+    search.what = ecore_string_instance(mime);
+
+    ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_mime, &search);
+    ecore_string_release(search.what);
+
+    if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
+    return search.list;
+}
+
+EAPI Efreet_Desktop *
+efreet_util_desktop_wm_class_find(const char *wmname, const char *wmclass)
+{
+    Efreet_Cache_Search search;
+    Efreet_Util_Desktop *ud;
+
+    if ((!wmname) && (!wmclass)) return NULL;
+    search.what1 = wmname;
+    search.what2 = wmclass;
+    ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_wm_class, &search);
+    if (ud) return ud->desktop;
+    return NULL;
+}
+
+EAPI Efreet_Desktop *
+efreet_util_desktop_file_id_find(const char *file_id)
+{
+    Efreet_Desktop *desktop = NULL;
+    Efreet_Util_Desktop *ud = NULL;
+    Ecore_List *dirs;
+    const char *dir;
+    int priority = 0;
+
+    if (!file_id) return NULL;
+    ud = ecore_hash_get(desktop_by_file_id, file_id);
+    if (ud) return ud->desktop;
+
+    dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
+                                                                    "applications");
+    if (!dirs) return NULL;
+
+    ecore_list_first_goto(dirs);
+    while ((dir = ecore_list_next(dirs)))
+    {
+        char *tmp, *p;
+        char buf[PATH_MAX];
+
+        tmp = strdup(file_id);
+        p = tmp;
+
+        while (p)
+        {
+            snprintf(buf, sizeof(buf), "%s/%s", dir, tmp);
+            desktop = efreet_desktop_get(buf);
+            if (desktop) break;
+            p = strchr(p, '-');
+            if (p) *p = '/';
+        }
+        free(tmp);
+        if (desktop) break;
+        priority++;
+    }
+    ecore_list_destroy(dirs);
+    if (desktop)
+    {
+        Efreet_Event_Desktop_Change *ev;
+
+        ud = NEW(Efreet_Util_Desktop, 1);
+        ud->priority = priority;
+        ud->desktop = desktop;
+
+        ecore_hash_set(desktop_by_file_id, (void *)ecore_string_instance(file_id), ud);
+        efreet_util_desktops_by_category_add(desktop);
+
+        ev = NEW(Efreet_Event_Desktop_Change, 1);
+        ev->current = desktop;
+        efreet_desktop_ref(ev->current);
+        ev->change = EFREET_DESKTOP_CHANGE_ADD;
+        ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
+    }
+    return desktop;
+}
+
+EAPI Efreet_Desktop *
+efreet_util_desktop_exec_find(const char *exec)
+{
+    Efreet_Cache_Search search;
+    Efreet_Util_Desktop *ud;
+
+    if (!exec) return NULL;
+    search.what1 = exec;
+    search.what2 = NULL;
+    ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_exec, &search);
+    if (ud) return ud->desktop;
+    return NULL;
+}
+
+EAPI Efreet_Desktop *
+efreet_util_desktop_name_find(const char *name)
+{
+    Efreet_Cache_Search search;
+    Efreet_Util_Desktop *ud;
+
+    if (!name) return NULL;
+    search.what1 = name;
+    search.what2 = NULL;
+    ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_name, &search);
+    if (ud) return ud->desktop;
+    return NULL;
+}
+
+EAPI Efreet_Desktop *
+efreet_util_desktop_generic_name_find(const char *generic_name)
+{
+    Efreet_Cache_Search search;
+    Efreet_Util_Desktop *ud;
+
+    if (!generic_name) return NULL;
+    search.what1 = generic_name;
+    search.what2 = NULL;
+    ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_generic_name, &search);
+    if (ud) return ud->desktop;
+    return NULL;
+}
+
+EAPI Ecore_List *
+efreet_util_desktop_name_glob_list(const char *glob)
+{
+    Efreet_Cache_Search_List search;
+
+    search.list = ecore_list_new();
+    search.what = glob;
+
+    ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_name_glob, &search);
+
+    if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
+    return search.list;
+}
+
+EAPI Ecore_List *
+efreet_util_desktop_exec_glob_list(const char *glob)
+{
+    Efreet_Cache_Search_List search;
+
+    search.list = ecore_list_new();
+    search.what = glob;
+
+    ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_exec_glob, &search);
+
+    if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
+    return search.list;
+}
+
+EAPI Ecore_List *
+efreet_util_desktop_generic_name_glob_list(const char *glob)
+{
+    Efreet_Cache_Search_List search;
+
+    search.list = ecore_list_new();
+    search.what = glob;
+
+    ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_generic_name_glob, &search);
+
+    if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
+    return search.list;
+}
+
+EAPI Ecore_List *
+efreet_util_desktop_comment_glob_list(const char *glob)
+{
+    Efreet_Cache_Search_List search;
+
+    search.list = ecore_list_new();
+    search.what = glob;
+
+    ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_comment_glob, &search);
+
+    if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
+    return search.list;
+}
+
+/**
+ * Find all desktop categories
+ * This list must be freed using ecore_list_destroy()
+ *
+ * @return an Ecore_List of category names (const char *)
+ */
+EAPI Ecore_List *
+efreet_util_desktop_categories_list(void)
+{
+    return ecore_hash_keys(desktops_by_category);
+}
+
+/**
+ * Find all desktops in a given category
+ *
+ * Note: this returns a pointer to an internal list. Do not add to, remove from, or delete this list.
+ *
+ * @param category the category name
+ * @return a list of desktops
+ */
+EAPI Ecore_List *
+efreet_util_desktop_category_list(const char *category)
+{
+    return ecore_hash_get(desktops_by_category, category);
+}
+
+#if 0
+static void
+dump(void *value, void *data __UNUSED__)
+{
+    Ecore_Hash_Node *node;
+    node = value;
+    printf("%s -> %p\n", (char *)node->key, node->value);
+}
+#endif
+
+static int
+efreet_util_cache_fill(void *data __UNUSED__)
+{
+    struct dirent *file = NULL;
+    double start;
+    char buf[PATH_MAX];
+
+    if (!fill->dirs)
+    {
+        free(fill);
+        idler = NULL;
+        fill = NULL;
+        ecore_event_add(EFREET_EVENT_DESKTOP_LIST_CHANGE, NULL, NULL, NULL);
+
+        return 0;
+    }
+    if (!fill->current)
+    {
+        fill->current = ecore_list_first_remove(fill->dirs);
+        if (!fill->current)
+        {
+            IF_FREE_LIST(fill->dirs);
+            free(fill);
+            idler = NULL;
+            fill = NULL;
+#if 0
+            ecore_hash_for_each_node(desktop_by_file_id, dump, NULL);
+            ecore_hash_for_each_node(file_id_by_desktop_path, dump, NULL);
+            printf("%d\n", ecore_hash_count(desktop_by_file_id));
+#endif
+            ecore_event_add(EFREET_EVENT_DESKTOP_LIST_CHANGE, NULL, NULL, NULL);
+
+            return 0;
+        }
+    }
+
+    start = ecore_time_get();
+    if (!fill->files) fill->files = opendir(fill->current->path);
+    if (!fill->files)
+    {
+        /* Couldn't open this dir, continue to next */
+        efreet_util_cache_dir_free(fill->current);
+        fill->current = NULL;
+    }
+    else
+    {
+        do
+        {
+            char file_id[PATH_MAX];
+
+            file = readdir(fill->files);
+            if (!file) break;
+            if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
+
+            snprintf(buf, PATH_MAX, "%s/%s", fill->current->path, file->d_name);
+            if (fill->current->file_id)
+                snprintf(file_id, PATH_MAX, "%s-%s", fill->current->file_id, file->d_name);
+            else
+                strcpy(file_id, file->d_name);
+
+            if (ecore_file_is_dir(buf))
+            {
+                Efreet_Cache_Fill_Dir *dir;
+
+                dir = NEW(Efreet_Cache_Fill_Dir, 1);
+                dir->path = strdup(buf);
+                dir->file_id = strdup(file_id);
+                dir->priority = fill->current->priority;
+                ecore_list_append(fill->dirs, dir);
+            }
+            else
+                efreet_util_cache_add(buf, file_id, fill->current->priority, 0);
+        } while ((ecore_time_get() - start) < 0.01);
+
+        if (!file)
+        {
+            /* This dir has been search through */
+            efreet_util_monitor(fill->current->path, fill->current->file_id,
+                                fill->current->priority);
+            efreet_util_cache_dir_free(fill->current);
+            fill->current = NULL;
+            closedir(fill->files);
+            fill->files = NULL;
+        }
+    }
+
+    return 1;
+}
+
+static void
+efreet_util_cache_add(const char *path, const char *file_id, int priority, int event)
+{
+    Efreet_Desktop *desktop;
+    Efreet_Util_Desktop *ud;
+    char *ext;
+
+    ext = strrchr(path, '.');
+    if (!ext || strcmp(ext, ".desktop")) return;
+    desktop = efreet_desktop_get(path);
+
+    if (!desktop || desktop->type != EFREET_DESKTOP_TYPE_APPLICATION)
+    {
+        if (desktop) efreet_desktop_free(desktop);
+        return;
+    }
+
+    if (!ecore_hash_get(file_id_by_desktop_path, desktop->orig_path))
+        ecore_hash_set(file_id_by_desktop_path,
+                        (void *)ecore_string_instance(desktop->orig_path),
+                        (void *)ecore_string_instance(file_id));
+
+    ud = ecore_hash_get(desktop_by_file_id, file_id);
+    if (!ud)
+    {
+        ud = NEW(Efreet_Util_Desktop, 1);
+        ud->priority = priority;
+        ud->desktop = desktop;
+
+        ecore_hash_set(desktop_by_file_id, (void *)ecore_string_instance(file_id), ud);
+        efreet_util_desktops_by_category_add(desktop);
+
+        if (event)
+        {
+            Efreet_Event_Desktop_Change *ev;
+
+            ev = NEW(Efreet_Event_Desktop_Change, 1);
+            ev->current = desktop;
+            efreet_desktop_ref(ev->current);
+            ev->change = EFREET_DESKTOP_CHANGE_ADD;
+            ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
+        }
+    }
+    else if (priority < ud->priority)
+    {
+        efreet_util_desktops_by_category_remove(ud->desktop);
+        efreet_util_desktops_by_category_add(desktop);
+
+        if (event)
+        {
+            Efreet_Event_Desktop_Change *ev;
+
+            ev = NEW(Efreet_Event_Desktop_Change, 1);
+            ev->current = desktop;
+            efreet_desktop_ref(ev->current);
+            ev->previous = ud->desktop;
+            efreet_desktop_ref(ev->previous);
+            ev->change = EFREET_DESKTOP_CHANGE_UPDATE;
+            efreet_desktop_free(ud->desktop);
+            ud->desktop = desktop;
+            ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
+        }
+        else
+        {
+            efreet_desktop_free(ud->desktop);
+            ud->desktop = desktop;
+        }
+    }
+    else
+        efreet_desktop_free(desktop);
+}
+
+static void
+efreet_util_cache_remove(const char *path, const char *file_id, int priority)
+{
+    Efreet_Util_Desktop *ud;
+    char *ext;
+
+    ext = strrchr(path, '.');
+    if (!ext || strcmp(ext, ".desktop")) return;
+    ud = ecore_hash_get(desktop_by_file_id, file_id);
+    if (ud && (ud->priority >= priority))
+    {
+        Efreet_Event_Desktop_Change *ev;
+
+        ecore_hash_remove(desktop_by_file_id, file_id);
+        efreet_util_desktops_by_category_remove(ud->desktop);
+
+        ev = NEW(Efreet_Event_Desktop_Change, 1);
+        ev->current = ud->desktop;
+        efreet_desktop_ref(ev->current);
+        ev->change = EFREET_DESKTOP_CHANGE_REMOVE;
+        ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
+
+        efreet_util_desktop_free(ud);
+
+        /* This call will search application dirs and add the file to cache if it
+         * exists. */
+        efreet_util_desktop_file_id_find(file_id);
+    }
+    ecore_hash_remove(file_id_by_desktop_path, path);
+}
+
+static void
+efreet_util_cache_reload(const char *path, const char *file_id, int priority)
+{
+    Efreet_Desktop *desktop;
+    Efreet_Util_Desktop *ud;
+    char *ext;
+
+    ext = strrchr(path, '.');
+    if (!ext || strcmp(ext, ".desktop")) return;
+    desktop = efreet_desktop_get(path);
+
+    if (!desktop || desktop->type != EFREET_DESKTOP_TYPE_APPLICATION)
+    {
+        if (desktop) efreet_desktop_free(desktop);
+        return;
+    }
+
+    ud = ecore_hash_get(desktop_by_file_id, file_id);
+    if (ud)
+    {
+        Efreet_Event_Desktop_Change *ev;
+
+        if (ud->priority < priority)
+        {
+            efreet_desktop_free(desktop);
+            return;
+        }
+
+        efreet_util_desktops_by_category_remove(ud->desktop);
+        efreet_util_desktops_by_category_add(desktop);
+
+        ev = NEW(Efreet_Event_Desktop_Change, 1);
+        ev->current = desktop;
+        efreet_desktop_ref(ev->current);
+        ev->previous = ud->desktop;
+        efreet_desktop_ref(ev->previous);
+        ev->change = EFREET_DESKTOP_CHANGE_UPDATE;
+        ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
+
+        efreet_desktop_free(ud->desktop);
+        ud->desktop = desktop;
+    }
+    else
+    {
+        Efreet_Event_Desktop_Change *ev;
+
+        ud = NEW(Efreet_Util_Desktop, 1);
+        ud->priority = priority;
+        ud->desktop = desktop;
+
+        ecore_hash_set(desktop_by_file_id, (void *)ecore_string_instance(file_id), ud);
+        efreet_util_desktops_by_category_remove(ud->desktop);
+        efreet_util_desktops_by_category_add(desktop);
+
+        ev = NEW(Efreet_Event_Desktop_Change, 1);
+        ev->current = desktop;
+        efreet_desktop_ref(ev->current);
+        ev->change = EFREET_DESKTOP_CHANGE_ADD;
+        ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
+    }
+}
+
+static void
+efreet_util_cache_dir_free(void *data)
+{
+    Efreet_Cache_Fill_Dir *dir;
+
+    dir = data;
+    IF_FREE(dir->path);
+    IF_FREE(dir->file_id);
+    free(dir);
+}
+
+static void
+efreet_util_cache_search_mime(void *value, void *data)
+{
+    Ecore_Hash_Node          *node;
+    Efreet_Cache_Search_List *search;
+    Efreet_Util_Desktop      *ud;
+    const char               *mime;
+
+    node = value;
+    search = data;
+    ud = node->value;
+
+    if (!ud->desktop->mime_types) return;
+    ecore_list_first_goto(ud->desktop->mime_types);
+    while ((mime = ecore_list_next(ud->desktop->mime_types)))
+    {
+        if (search->what == mime)
+        {
+            ecore_list_append(search->list, ud->desktop);
+            break;
+        }
+    }
+}
+
+static int
+efreet_util_cache_search_wm_class(const void *value, const void *data)
+{
+    const Efreet_Cache_Search *search;
+    const Efreet_Util_Desktop *ud;
+
+    ud = value;
+    search = data;
+
+    if (!ud->desktop->startup_wm_class) return 1;
+    if ((search->what2) && (!strcmp(ud->desktop->startup_wm_class, search->what2)))
+        return 0;
+    else if ((search->what1) && (!strcmp(ud->desktop->startup_wm_class, search->what1)))
+        return 0;
+    return 1;
+}
+
+static int
+efreet_util_cache_search_exec(const void *value, const void *data)
+{
+    const Efreet_Cache_Search *search;
+    const Efreet_Util_Desktop *ud;
+    char                      *exec;
+    const char                *file;
+
+    ud = value;
+    search = data;
+
+    if (!ud->desktop->exec) return 1;
+    exec = ecore_file_app_exe_get(ud->desktop->exec);
+    if (!exec) return 1;
+    if (!strcmp(exec, search->what1))
+    {
+       free(exec);
+       return 0;
+    }
+
+    file = ecore_file_file_get(exec);
+    if (file && !strcmp(file, search->what1))
+    {
+       free(exec);
+       return 0;
+    }
+    free(exec);
+    return 1;
+}
+
+static int
+efreet_util_cache_search_name(const void *value, const void *data)
+{
+    const Efreet_Cache_Search *search;
+    const Efreet_Util_Desktop *ud;
+
+    ud = value;
+    search = data;
+
+    if (!ud->desktop->name) return 1;
+    return strcmp(ud->desktop->name, search->what1);
+}
+
+static int
+efreet_util_cache_search_generic_name(const void *value, const void *data)
+{
+    const Efreet_Cache_Search *search;
+    const Efreet_Util_Desktop *ud;
+
+    ud = value;
+    search = data;
+
+    if (!ud->desktop->generic_name) return 1;
+    return strcmp(ud->desktop->generic_name, search->what1);
+}
+
+static void
+efreet_util_cache_search_name_glob(void *value, void *data)
+{
+    Ecore_Hash_Node          *node;
+    Efreet_Cache_Search_List *search;
+    Efreet_Util_Desktop      *ud;
+
+    node = value;
+    search = data;
+    ud = node->value;
+
+    if (efreet_util_glob_match(ud->desktop->name, search->what))
+        ecore_list_append(search->list, ud->desktop);
+}
+
+static void
+efreet_util_cache_search_exec_glob(void *value, void *data)
+{
+    Ecore_Hash_Node          *node;
+    Efreet_Cache_Search_List *search;
+    Efreet_Util_Desktop      *ud;
+    char                     *exec;
+
+    node = value;
+    search = data;
+    ud = node->value;
+
+    if (!ud->desktop->exec) return;
+    exec = ecore_file_app_exe_get(ud->desktop->exec);
+    if (exec)
+    {
+        if (efreet_util_glob_match(exec, search->what))
+            ecore_list_append(search->list, ud->desktop);
+        free(exec);
+    }
+}
+
+static void
+efreet_util_cache_search_generic_name_glob(void *value, void *data)
+{
+    Ecore_Hash_Node          *node;
+    Efreet_Cache_Search_List *search;
+    Efreet_Util_Desktop      *ud;
+
+    node = value;
+    search = data;
+    ud = node->value;
+
+    if (efreet_util_glob_match(ud->desktop->generic_name, search->what))
+        ecore_list_append(search->list, ud->desktop);
+}
+
+static void
+efreet_util_cache_search_comment_glob(void *value, void *data)
+{
+    Ecore_Hash_Node          *node;
+    Efreet_Cache_Search_List *search;
+    Efreet_Util_Desktop      *ud;
+
+    node = value;
+    search = data;
+    ud = node->value;
+
+    if (efreet_util_glob_match(ud->desktop->comment, search->what))
+        ecore_list_append(search->list, ud->desktop);
+}
+
+static int
+efreet_util_glob_match(const char *str, const char *glob)
+{
+    if (!str || !glob)
+        return 0;
+    if (glob[0] == '\0')
+    {
+        if (str[0] == '\0') return 1;
+        return 0;
+    }
+    if (!strcmp(glob, "*")) return 1;
+    if (!fnmatch(glob, str, 0)) return 1;
+    return 0;
+}
+
+static void
+efreet_util_monitor(const char *path, const char *file_id, int priority)
+{
+    Efreet_Monitor *em;
+
+    em = NEW(Efreet_Monitor, 1);
+    em->monitor = ecore_file_monitor_add(path, efreet_util_monitor_cb, em);
+    if (file_id) em->file_id = strdup(file_id);
+    em->priority = priority;
+    ecore_list_append(monitors, em);
+}
+
+static void
+efreet_util_monitor_cb(void *data, Ecore_File_Monitor *monitor __UNUSED__,
+                        Ecore_File_Event event, const char *path)
+{
+    Efreet_Monitor *em;
+    char file_id[PATH_MAX];
+
+    em = data;
+    if (em->file_id)
+        snprintf(file_id, sizeof(file_id), "%s-%s", em->file_id, ecore_file_file_get(path));
+    else
+        strcpy(file_id, ecore_file_file_get(path));
+    switch (event)
+    {
+        case ECORE_FILE_EVENT_NONE:
+            /* Ignore */
+            break;
+        case ECORE_FILE_EVENT_CREATED_FILE:
+            efreet_util_cache_add(path, file_id, em->priority, 1);
+            break;
+        case ECORE_FILE_EVENT_CREATED_DIRECTORY:
+            {
+                Efreet_Cache_Fill_Dir *dir;
+
+                if (!fill)
+                {
+                    fill = NEW(Efreet_Cache_Fill, 1);
+                    fill->dirs = ecore_list_new();
+                    ecore_list_free_cb_set(fill->dirs, efreet_util_cache_dir_free);
+                }
+
+                dir = NEW(Efreet_Cache_Fill_Dir, 1);
+                dir->path = strdup(path);
+                dir->file_id = strdup(file_id);
+                dir->priority = em->priority;
+                ecore_list_append(fill->dirs, dir);
+
+                if (!idler)
+                    idler = ecore_idler_add(efreet_util_cache_fill, NULL);
+            }
+            break;
+        case ECORE_FILE_EVENT_DELETED_FILE:
+            efreet_util_cache_remove(path, file_id, em->priority);
+            break;
+        case ECORE_FILE_EVENT_DELETED_DIRECTORY:
+            /* Ignore, we should already have a monitor on any subdir */
+            break;
+        case ECORE_FILE_EVENT_DELETED_SELF:
+            if (ecore_list_goto(monitors, em))
+                ecore_list_remove(monitors);
+            efreet_util_monitor_free(em);
+            break;
+        case ECORE_FILE_EVENT_MODIFIED:
+            efreet_util_cache_reload(path, file_id, em->priority);
+            break;
+    }
+}
+
+static void
+efreet_util_monitor_free(void *data)
+{
+    Efreet_Monitor *em;
+
+    em = data;
+    if (em->monitor) ecore_file_monitor_del(em->monitor);
+    IF_FREE(em->file_id);
+    free(em);
+}
+
+/**
+ * Returns a list of .menu files found in the various config dirs.
+ * @return An ecore list of menu file paths (const char *). This must be freed with ecore_list_destroy().
+ */
+EAPI Ecore_List *
+efreet_util_menus_find(void)
+{
+    Ecore_List *menus, *dirs;
+    const char *dir;
+
+    menus = ecore_list_new();
+    ecore_list_free_cb_set(menus, ECORE_FREE_CB(free));
+
+    efreet_util_menus_find_helper(menus, efreet_config_home_get());
+
+    dirs = efreet_config_dirs_get();
+    ecore_list_first_goto(dirs);
+    while ((dir = ecore_list_next(dirs)))
+        efreet_util_menus_find_helper(menus, dir);
+
+    return menus;
+}
+
+static void
+efreet_util_menus_find_helper(Ecore_List *menus, const char *config_dir)
+{
+    DIR *files = NULL;
+    struct dirent *file = NULL;
+    char dbuf[PATH_MAX], fbuf[PATH_MAX];
+
+    snprintf(dbuf, sizeof(dbuf), "%s/menus", config_dir);
+    files = opendir(dbuf);
+    if (!files) return;
+    while ((file = readdir(files))) {
+        const char *exten;
+        exten = strrchr(file->d_name, '.');
+        if (!exten) continue;
+        if (strcmp(".menu", exten)) continue;
+
+        snprintf(fbuf, PATH_MAX, "%s/%s", dbuf, file->d_name);
+        if (ecore_file_is_dir(fbuf)) continue;
+
+        ecore_list_append(menus, strdup(fbuf));
+    }
+    closedir(files);
+}
+
+static void
+efreet_util_desktops_by_category_add(Efreet_Desktop *desktop)
+{
+    const char *category;
+
+    if (!desktop->categories) return;
+
+    ecore_list_first_goto(desktop->categories);
+    while ((category = ecore_list_next(desktop->categories)))
+    {
+        Ecore_List *list;
+        list = ecore_hash_get(desktops_by_category, category);
+        if (!list)
+        {
+            list = ecore_list_new();
+            ecore_hash_set(desktops_by_category,
+                    (void *)ecore_string_instance(category), list);
+        }
+        if (!ecore_list_goto(list, desktop))
+            ecore_list_append(list, desktop);
+    }
+}
+
+static void
+efreet_util_desktops_by_category_remove(Efreet_Desktop *desktop)
+{
+    const char *category;
+
+    if (!desktop->categories) return;
+
+    ecore_list_first_goto(desktop->categories);
+    while ((category = ecore_list_next(desktop->categories)))
+    {
+        Ecore_List *list;
+        list = ecore_hash_get(desktops_by_category, category);
+        if (!list) continue;
+        if (ecore_list_goto(list, desktop))
+            ecore_list_remove(list);
+        if (ecore_list_empty_is(list))
+        {
+            ecore_hash_remove(desktops_by_category, category);
+            ecore_list_destroy(list);
+        }
+    }
+}
+
+static void
+efreet_util_desktop_free(Efreet_Util_Desktop *ud)
+{
+    if (!ud) return;
+
+    efreet_desktop_free(ud->desktop);
+    free(ud);
+}
+
+static void
+efreet_event_desktop_change_free(void *data __UNUSED__, void *ev)
+{
+    Efreet_Event_Desktop_Change *event;
+
+    event = ev;
+    if (event->current) efreet_desktop_free(event->current);
+    if (event->previous) efreet_desktop_free(event->previous);
+
+    free(event);
+}
diff --git a/src/lib/efreet_utils.h b/src/lib/efreet_utils.h
new file mode 100644 (file)
index 0000000..9bafd8f
--- /dev/null
@@ -0,0 +1,49 @@
+/* vim: set sw=4 ts=4 sts=4 et: */
+#ifndef EFREET_UTILS_H
+#define EFREET_UTILS_H
+
+typedef enum Efreet_Desktop_Change Efreet_Desktop_Change;
+
+enum Efreet_Desktop_Change
+{
+    EFREET_DESKTOP_CHANGE_ADD,
+    EFREET_DESKTOP_CHANGE_REMOVE,
+    EFREET_DESKTOP_CHANGE_UPDATE
+};
+
+typedef struct Efreet_Event_Desktop_Change Efreet_Event_Desktop_Change;
+
+struct Efreet_Event_Desktop_Change
+{
+    Efreet_Desktop *current;
+    Efreet_Desktop *previous;
+    Efreet_Desktop_Change change;
+};
+
+EAPI int efreet_util_init(void);
+EAPI int efreet_util_shutdown(void);
+
+EAPI const char *efreet_util_path_to_file_id(const char *path);
+
+EAPI Ecore_List *efreet_util_desktop_mime_list(const char *mime);
+
+EAPI Efreet_Desktop *efreet_util_desktop_wm_class_find(const char *wmname, const char *wmclass);
+EAPI Efreet_Desktop *efreet_util_desktop_file_id_find(const char *file_id);
+EAPI Efreet_Desktop *efreet_util_desktop_exec_find(const char *exec);
+EAPI Efreet_Desktop *efreet_util_desktop_name_find(const char *name);
+EAPI Efreet_Desktop *efreet_util_desktop_generic_name_find(const char *generic_name);
+
+EAPI Ecore_List *efreet_util_desktop_name_glob_list(const char *glob);
+EAPI Ecore_List *efreet_util_desktop_exec_glob_list(const char *glob);
+EAPI Ecore_List *efreet_util_desktop_generic_name_glob_list(const char *glob);
+EAPI Ecore_List *efreet_util_desktop_comment_glob_list(const char *glob);
+
+EAPI Ecore_List *efreet_util_desktop_categories_list(void);
+EAPI Ecore_List *efreet_util_desktop_category_list(const char *category);
+
+EAPI Ecore_List *efreet_util_menus_find(void);
+
+EAPI extern int EFREET_EVENT_DESKTOP_LIST_CHANGE;
+EAPI extern int EFREET_EVENT_DESKTOP_CHANGE;
+
+#endif
diff --git a/src/lib/efreet_xml.c b/src/lib/efreet_xml.c
new file mode 100644 (file)
index 0000000..62477de
--- /dev/null
@@ -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_first_goto(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_free_cb_set(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)--;
+    }
+}
diff --git a/src/lib/efreet_xml.h b/src/lib/efreet_xml.h
new file mode 100644 (file)
index 0000000..acd7bb2
--- /dev/null
@@ -0,0 +1,60 @@
+/* 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