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/e_dbus@35497 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

92 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]
README [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/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/libedbus-dev.install [new file with mode: 0644]
debian/libedbus0.install [new file with mode: 0644]
debian/rules [new file with mode: 0755]
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/e.css [new file with mode: 0644]
doc/images/foot.html [new file with mode: 0644]
doc/images/head.html [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]
e_dbus.spec.in [new file with mode: 0644]
edbus.pc.in [new file with mode: 0644]
ehal.pc.in [new file with mode: 0644]
enm.pc.in [new file with mode: 0644]
enotify.pc.in [new file with mode: 0644]
gendoc [new file with mode: 0755]
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/hal.c [new file with mode: 0644]
src/bin/nm.c [new file with mode: 0644]
src/bin/notification_daemon.c [new file with mode: 0644]
src/bin/notify-send.c [new file with mode: 0644]
src/bin/notify.c [new file with mode: 0644]
src/bin/test.c [new file with mode: 0644]
src/bin/test_client.c [new file with mode: 0644]
src/lib/.cvsignore [new file with mode: 0644]
src/lib/Makefile.am [new file with mode: 0644]
src/lib/dbus/.cvsignore [new file with mode: 0644]
src/lib/dbus/E_DBus.h [new file with mode: 0644]
src/lib/dbus/Makefile.am [new file with mode: 0644]
src/lib/dbus/e_dbus.c [new file with mode: 0644]
src/lib/dbus/e_dbus_interfaces.c [new file with mode: 0644]
src/lib/dbus/e_dbus_message.c [new file with mode: 0644]
src/lib/dbus/e_dbus_methods.c [new file with mode: 0644]
src/lib/dbus/e_dbus_object.c [new file with mode: 0644]
src/lib/dbus/e_dbus_private.h [new file with mode: 0644]
src/lib/dbus/e_dbus_signal.c [new file with mode: 0644]
src/lib/dbus/e_dbus_util.c [new file with mode: 0644]
src/lib/hal/.cvsignore [new file with mode: 0644]
src/lib/hal/E_Hal.h [new file with mode: 0644]
src/lib/hal/Makefile.am [new file with mode: 0644]
src/lib/hal/e_hal_device.c [new file with mode: 0644]
src/lib/hal/e_hal_device.h [new file with mode: 0644]
src/lib/hal/e_hal_manager.c [new file with mode: 0644]
src/lib/hal/e_hal_manager.h [new file with mode: 0644]
src/lib/hal/e_hal_util.c [new file with mode: 0644]
src/lib/hal/e_hal_util.h [new file with mode: 0644]
src/lib/nm/.cvsignore [new file with mode: 0644]
src/lib/nm/E_Nm.h [new file with mode: 0644]
src/lib/nm/Makefile.am [new file with mode: 0644]
src/lib/nm/README [new file with mode: 0644]
src/lib/nm/e_nm.c [new file with mode: 0644]
src/lib/nm/e_nm_device.c [new file with mode: 0644]
src/lib/nm/e_nm_manager.c [new file with mode: 0644]
src/lib/nm/e_nm_network.c [new file with mode: 0644]
src/lib/nm/e_nm_private.h [new file with mode: 0644]
src/lib/nm/e_nm_util.c [new file with mode: 0644]
src/lib/notification/.cvsignore [new file with mode: 0644]
src/lib/notification/E_Notification_Daemon.h [new file with mode: 0644]
src/lib/notification/E_Notify.h [new file with mode: 0644]
src/lib/notification/Makefile.am [new file with mode: 0644]
src/lib/notification/client.c [new file with mode: 0644]
src/lib/notification/daemon.c [new file with mode: 0644]
src/lib/notification/e_notify_private.h [new file with mode: 0644]
src/lib/notification/marshal.c [new file with mode: 0644]
src/lib/notification/notification-spec-0.9.txt [new file with mode: 0644]
src/lib/notification/notification.c [new file with mode: 0644]

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..7a9dcad
--- /dev/null
@@ -0,0 +1,20 @@
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+compile
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+stamp-h1
+*.pc
+e_dbus.spec
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..5fd000b
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Brian Mattern <rephorm@rephorm.com>
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..52d1cbd
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,20 @@
+Copyright (C) 2006 Brian Mattern 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..3d3346e
--- /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           =  e_dbus
+
+# 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.1.0
+
+# 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           = e_dbus_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          = e_ E_
+
+#---------------------------------------------------------------------------
+# 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..23e5f25
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,236 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
+Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+These are generic installation instructions.
+
+   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 only 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.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  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=c89 CFLAGS=-O2 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 must use a version of `make' that
+supports the `VPATH' variable, such as 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 `..'.
+
+   If you have to use a `make' that does not support the `VPATH'
+variable, you have 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).  Here is a another example:
+
+     /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
+configuration-related scripts to be executed by `/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..b33aad2
--- /dev/null
@@ -0,0 +1,18 @@
+SUBDIRS = src
+
+MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
+                       config.log config.sub configure depcomp \
+                      install-sh ltmain.sh missing compile
+
+pkgconfigdir = $(libdir)/pkgconfig
+
+if BUILD_EHAL
+EHAL_PC = ehal.pc
+endif
+if BUILD_ENM
+ENM_PC = enm.pc
+endif
+if BUILD_ENOTIFY
+ENOTIFY_PC = enotify.pc
+endif
+pkgconfig_DATA = edbus.pc $(EHAL_PC) $(ENM_PC) $(ENOTIFY_PC)
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..d7cc41c
--- /dev/null
+++ b/README
@@ -0,0 +1,19 @@
+e_dbus v0.01
+
+Requirements:
+-------------
+
+Must:
+  libc libdbus ecore
+
+This is the start of some basic convenience wrappers around dbus to ease integrating dbus with EFL based applications.
+
+When using e_dbus, direct use of the low level dbus api is still heavily required for processing messages.
+
+A few things to note:
+
+e_dbus_bus_get() currently creates a new private connection to whichever bus is passed in, and hooks this into the ecore main loop. At some point, we should implement internal refcounting and sharing of these private connections (one for each bus type) so that e.g. multiple modules in an app can reuse the same connection. libdbus implements its own shared connections (available via dbus_bus_get()), but the final reference is always retained by libdbus iteself, causing any cleanup handlers on the connection to only be called at app exit. Thus, if a module hooks a connection in to the mainloop, there is no way to clean up fully before unloading the module, causing issues. 
+
+This code is still in its infancy, and although works, may have some rough edges. The design is not set in stone, so feel free to propose (and implement) changes / improvements.
+
+Patches can be sent to the enlightenment dev mailing list, or, if you have commit access, feel free to commit.
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..a22b36d
--- /dev/null
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+rm -rf autom4te.cache
+rm -f aclocal.m4 ltmain.sh
+
+echo "Running aclocal..."; aclocal $ACLOCAL_FLAGS || exit 1
+echo "Running autoheader..."; autoheader || exit 1
+echo "Running libtoolize..."; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
+echo "Running automake..."; automake --gnu --add-missing --copy || exit 1
+echo "Running autoconf..."; autoconf || exit 1
+
+if [ -z "$NOCONFIGURE" ] ; then
+  ./configure "$@"
+fi
diff --git a/configure.in b/configure.in
new file mode 100644 (file)
index 0000000..6023589
--- /dev/null
@@ -0,0 +1,115 @@
+# get rid of that stupid cache mechanism
+rm -f config.cache
+
+AC_INIT(e_dbus, 0.5.0.043, 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_PROG_CC
+AC_HEADER_STDC
+AM_PROG_CC_C_O
+
+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)
+
+dnl Check enabled modules to build
+AC_ARG_ENABLE(ehal,
+                                 AC_HELP_STRING([--disable-ehal],
+                                                                         [Disable ehal build]),
+                                 [enable_ehal=$enableval],
+                                 [enable_ehal="yes"])
+AC_ARG_ENABLE(enm,
+                                 AC_HELP_STRING([--disable-enm], 
+                                                                         [Disable enm build]),
+                                 [enable_enm=$enableval],
+                                 [enable_enm="yes"])
+AC_ARG_ENABLE(enotify,
+                                 AC_HELP_STRING([--disable-enotify], 
+                                                                         [Disable enotify build]),
+                                 [enable_enotify=$enableval],
+                                 [enable_enotify="yes"])
+
+
+PKG_CHECK_MODULES([EDBUS], [
+  dbus-1 >= 0.62
+  ecore >= 0.9.9
+])
+
+
+dnl evas
+if test "x${enable_enotify}" = "xyes"
+then
+       PKG_CHECK_MODULES(EVAS, [evas >= 0.9.9], [], [enable_enotify="no"])
+fi
+
+AC_ARG_ENABLE(build-test-gui,
+  AS_HELP_STRING([--enable-build-test-gui], [Build with gui for testing]),
+  [ PKG_CHECK_MODULES([HAL_TEST_GUI], [
+    ewl
+    efreet
+    ],
+    # temporarily disable until update to newer tree2 api
+    [AC_DEFINE([EWL_GUI], 0, [An ewl gui for e_dbus_hal])],
+    [AC_DEFINE([EWL_GUI], 0, [An ewl gui for e_dbus_hal])]
+    )
+ ]
+)
+
+AM_CONDITIONAL([BUILD_EHAL],    [test "x${enable_ehal}"    = "xyes"])
+AM_CONDITIONAL([BUILD_ENM],     [test "x${enable_enm}"     = "xyes"])
+AM_CONDITIONAL([BUILD_ENOTIFY], [test "x${enable_enotify}" = "xyes"])
+
+AC_OUTPUT([
+e_dbus.spec
+Makefile
+src/Makefile
+src/lib/Makefile
+src/lib/dbus/Makefile
+src/lib/hal/Makefile
+src/lib/nm/Makefile
+src/lib/notification/Makefile
+src/bin/Makefile
+edbus.pc
+ehal.pc
+enotify.pc
+enm.pc
+])
+
+
+#####################################################################
+## Info
+
+echo
+echo
+echo
+echo "------------------------------------------------------------------------"
+echo "$PACKAGE $VERSION"
+echo "------------------------------------------------------------------------"
+echo
+echo "Modules:"
+echo
+echo "  EHal.................: $enable_ehal"
+echo "  ENM..................: $enable_enm"
+echo "  ENotify..............: $enable_enotify"
+echo
+echo "Configuration Options Summary:"
+echo
+echo "  Compilation..........: make"
+echo
+echo "  Installation.........: make install"
+echo
+echo "    prefix.............: $prefix"
+echo
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..97eb7b7
--- /dev/null
@@ -0,0 +1,6 @@
+edbus (@VERSION@-1) unstable; urgency=low
+
+  * CVS snapshot.
+
+ -- Falko Schmidt <falko@alphagemini.org>  Mon, 28 Apr 2008 15:53:27 +0000
+
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..1e8b314
--- /dev/null
@@ -0,0 +1 @@
+6
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..86f81f0
--- /dev/null
@@ -0,0 +1,28 @@
+Source: edbus
+Section: libs
+Priority: optional
+Maintainer: Falko Schmidt <falko@alphagemini.org>
+Build-Depends: debhelper (>= 6), cdbs, libecore-dev, libdbus-1-dev, libevas-dev
+Standards-Version: 3.7.3
+Homepage: http://www.enlightenment.org
+
+Package: libedbus-dev
+Section: libdevel
+Architecture: any
+Depends: libedbus0 (= ${binary:Version}), libdbus-1-dev
+Replaces: libe-dbus0-dev
+Description: D-Bus and HAL wrapper libraries for use with the EFL - Development files
+ Wrappers around D-Bus to ease integrating D-Bus with EFL based applications.
+ .
+ This packages contains headers and static libraries for libedbus, libehal and
+ libenotify
+
+Package: libedbus0
+Architecture: any
+Depends: ${shlibs:Depends}
+Replaces: libe-dbus0
+Description: D-Bus and HAL wrapper libraries for use with the EFL
+ This package contains:
+ - libedbus0 and libehal0 : D-Bus and HAL-related wrappers to ease integrating
+   D-Bus and HAL with EFL-based applications
+ - libenotify0 : provides an EFL-based notification support
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..4ee41bb
--- /dev/null
@@ -0,0 +1,49 @@
+This package was debianized by Falko Schmidt <falko@alphagemini.org> on
+Mon, 28 Apr 2008 16:04:35 +0000.
+
+The source is downloaded from the e17/libs/eet module of the enlightenment CVS
+tree. For more information, see:
+
+  http://www.enlightenment.org/cvs.html
+
+Upstream Author: Brian Mattern <rephorm@rephorm.com>
+
+Copyright: 
+
+  Copyright (C) 2007 Brian Mattern and various contributor
+
+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 and its Copyright notices. In addition publicly
+  documented acknowledgment must be given that this software has been used if no
+  source code of this software is made available publicly. This includes
+  acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+  documents or any documentation provided with any product containing this
+  software. This License does not apply to any software that links to the
+  libraries provided by this software (statically or dynamically), but only to
+  the software provided.
+
+  Please see the COPYING.PLAIN for a plain-english explanation of this notice
+  and it's intent.
+
+  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/libedbus-dev.install b/debian/libedbus-dev.install
new file mode 100644 (file)
index 0000000..9af979d
--- /dev/null
@@ -0,0 +1,4 @@
+debian/tmp/usr/lib/*.a
+debian/tmp/usr/lib/*.so
+debian/tmp/usr/include/*
+debian/tmp/usr/lib/pkgconfig/*.pc
diff --git a/debian/libedbus0.install b/debian/libedbus0.install
new file mode 100644 (file)
index 0000000..79bbe2f
--- /dev/null
@@ -0,0 +1 @@
+debian/tmp/usr/lib/*.so.*
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..378c8aa
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+
+DEB_MAKE_CLEAN_TARGET := clean
+
+clean::
+       ./autogen.sh --prefix=/usr $(DEB_CONFIGURE_EXTRA_FLAGS)
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..1e8e960
--- /dev/null
@@ -0,0 +1,43 @@
+<!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="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/e.css b/doc/images/e.css
new file mode 100644 (file)
index 0000000..a9f6f64
--- /dev/null
@@ -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/images/foot.html b/doc/images/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/images/head.html b/doc/images/head.html
new file mode 100644 (file)
index 0000000..1e8e960
--- /dev/null
@@ -0,0 +1,43 @@
+<!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="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/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/e_dbus.spec.in b/e_dbus.spec.in
new file mode 100644 (file)
index 0000000..e827a7a
--- /dev/null
@@ -0,0 +1,64 @@
+%define _missing_doc_files_terminate_build 0
+
+Summary: EFL Wrapper for DBus
+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-dbus <= 0.9.9.040
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%description
+e_dbus provides a convenience wrapper for EFL applications using DBus.
+
+%package devel
+Summary: e_dbus headers, static libraries, documentation and test programs
+Group: System Environment/Libraries
+Requires: %{name} = %{version}
+
+%description devel
+Headers, static libraries, test programs and documentation for e_dbus
+
+%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}/*
+%{_libdir}/*.so.*
+
+%files devel
+%defattr(-, root, root)
+%{_includedir}/*.h
+%{_libdir}/*.so
+%{_libdir}/*.la
+%{_libdir}/*.a
+%{_libdir}/pkgconfig/*
+
+%changelog
diff --git a/edbus.pc.in b/edbus.pc.in
new file mode 100644 (file)
index 0000000..705d4a2
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: edbus
+Description: DBus convenience library
+Requires: ecore dbus-1
+Version: @VERSION@
+Libs: -L${libdir} -ledbus
+Cflags: -I${includedir}
diff --git a/ehal.pc.in b/ehal.pc.in
new file mode 100644 (file)
index 0000000..0382713
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ehal
+Description: Hal convenience library
+Requires: ecore edbus
+Version: @VERSION@
+Libs: -L${libdir} -lehal
+Cflags: -I${includedir}
diff --git a/enm.pc.in b/enm.pc.in
new file mode 100644 (file)
index 0000000..2247ced
--- /dev/null
+++ b/enm.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: enotify
+Description: Network Manager convenience library
+Requires: ecore edbus
+Version: @VERSION@
+Libs: -L${libdir} -lenm
+Cflags: -I${includedir}
diff --git a/enotify.pc.in b/enotify.pc.in
new file mode 100644 (file)
index 0000000..e97fbde
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: enotify
+Description: Notification convenience library
+Requires: ecore edbus
+Version: @VERSION@
+Libs: -L${libdir} -lenotify
+Cflags: -I${includedir}
diff --git a/gendoc b/gendoc
new file mode 100755 (executable)
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/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..97baf85
--- /dev/null
@@ -0,0 +1,2 @@
+MAINTAINERCLEANFILES = Makefile.in
+SUBDIRS = lib bin
diff --git a/src/bin/.cvsignore b/src/bin/.cvsignore
new file mode 100644 (file)
index 0000000..9ee1dc8
--- /dev/null
@@ -0,0 +1,11 @@
+.deps
+Makefile
+Makefile.in
+.libs
+e_dbus_hal
+e_dbus_test
+e_dbus_test_client
+e_dbus_nm
+e_dbus_notify
+e_dbus_notification_daemon
+e-notify-send
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
new file mode 100644 (file)
index 0000000..251b2d2
--- /dev/null
@@ -0,0 +1,95 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+EDBUS_CPPFLAGS = \
+-I$(top_srcdir)/src/lib/dbus \
+-I$(top_srcdir)/src/lib/hal \
+-I$(top_srcdir)/src/lib/nm \
+-I$(top_srcdir)/src/lib/notification \
+@EDBUS_CFLAGS@ 
+
+LIBS = \
+@EDBUS_LIBS@
+
+EDBUS_PROG = e_dbus_test e_dbus_test_client
+if BUILD_EHAL
+EHAL_PROG = e_dbus_hal
+endif
+if BUILD_ENM
+ENM_PROG = e_dbus_nm
+endif
+if BUILD_ENOTIFY
+ENOTIFY_PROG = e_dbus_notify e_dbus_notification_daemon e-notify-send
+endif
+
+bin_PROGRAMS = $(EDBUS_PROG) $(EHAL_PROG) $(ENM_PROG) $(ENOTIFY_PROG)
+
+e_dbus_test_SOURCES = \
+test.c
+
+e_dbus_test_CPPFLAGS = $(EDBUS_CPPFLAGS)
+e_dbus_test_LDADD = $(top_builddir)/src/lib/dbus/libedbus.la $(LIBS)
+e_dbus_test_DEPENDENCIES = $(top_builddir)/src/lib/dbus/libedbus.la
+
+e_dbus_test_client_SOURCES = \
+test_client.c
+
+e_dbus_test_client_CPPFLAGS = $(EDBUS_CPPFLAGS)
+e_dbus_test_client_LDADD = $(top_builddir)/src/lib/dbus/libedbus.la $(LIBS)
+e_dbus_test_client_DEPENDENCIES = $(top_builddir)/src/lib/dbus/libedbus.la
+
+
+if BUILD_EHAL
+HALSOURCES = \
+hal.c
+
+e_dbus_hal_CPPFLAGS = \
+$(EDBUS_CPPFLAGS) \
+@HAL_TEST_GUI_CFLAGS@
+
+e_dbus_hal_LIBS = \
+$(LIBS) \
+@HAL_TEST_GUI_LIBS@
+
+e_dbus_hal_SOURCES = \
+       $(HALSOURCES)
+
+e_dbus_hal_LDADD = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/hal/libehal.la $(e_dbus_hal_LIBS) 
+e_dbus_hal_DEPENDENCIES = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/hal/libehal.la
+endif
+
+
+if BUILD_ENM
+NMSOURCES = \
+nm.c
+
+e_dbus_nm_SOURCES = \
+       $(NMSOURCES)
+
+e_dbus_nm_CPPFLAGS = $(EDBUS_CPPFLAGS)
+e_dbus_nm_LDADD = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/nm/libenm.la $(LIBS) 
+e_dbus_nm_DEPENDENCIES = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/nm/libenm.la
+endif
+
+
+if BUILD_ENOTIFY
+e_dbus_notify_SOURCES = \
+       notify.c
+
+e_dbus_notify_CPPFLAGS = $(EDBUS_CPPFLAGS)
+e_dbus_notify_LDADD = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/notification/libenotify.la $(LIBS) 
+e_dbus_notify_DEPENDENCIES = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/notification/libenotify.la
+
+e_dbus_notification_daemon_SOURCES = \
+       notification_daemon.c
+
+e_dbus_notification_daemon_CPPFLAGS = $(EDBUS_CPPFLAGS)
+e_dbus_notification_daemon_LDADD = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/notification/libenotify.la $(LIBS) 
+e_dbus_notification_daemon_DEPENDENCIES = $(top_builddir)/src/lib/dbus/libedbus.la $(top_builddir)/src/lib/notification/libenotify.la
+
+e_notify_send_SOURCES = \
+ notify-send.c
+
+e_notify_send_CPPFLAGS = $(EDBUS_CPPFLAGS)
+e_notify_send_LDADD = $(top_builddir)/src/lib/notification/libenotify.la $(LIBS) 
+e_notify_send_DEPENDENCIES = $(top_builddir)/src/lib/notification/libenotify.la
+endif 
diff --git a/src/bin/hal.c b/src/bin/hal.c
new file mode 100644 (file)
index 0000000..215951c
--- /dev/null
@@ -0,0 +1,830 @@
+#include "E_Hal.h"
+#include <config.h>
+
+#if EWL_GUI
+#include <Ewl.h>
+#include <Efreet.h>
+#endif
+
+#include <string.h>
+
+/* test app */
+
+static E_DBus_Connection *conn;
+#if EWL_GUI
+static int mount_id = 0;
+#endif
+
+#define DEVICE_TYPE_STORAGE 1
+#define DEVICE_TYPE_VOLUME  2
+typedef struct Device Device;
+struct Device {
+  int type;
+  char *udi;
+};
+
+typedef struct Storage Storage;
+struct Storage {
+  int type;
+  char *udi;
+  char *bus;
+  char *drive_type;
+
+  char *model;
+  char *vendor;
+  char *serial;
+
+  char removable;
+  char media_available;
+  unsigned long media_size;
+
+  char requires_eject;
+  char hotpluggable;
+  char media_check_enabled;
+
+  struct {
+    char *drive;
+    char *volume;
+  } icon;
+
+  Ecore_List *volumes;
+};
+
+
+typedef struct Volume Volume;
+struct Volume {
+  int type;
+  char *udi;
+  char *uuid;
+  char *label;
+  char *fstype;
+
+  char partition;
+  char *partition_label;
+  char mounted;
+  char *mount_point;
+
+  Storage *storage;
+};
+
+static Ecore_List *storage_devices;
+static Ecore_List *volumes;
+
+void
+devices_dirty(void)
+{
+#if EWL_GUI
+  Ewl_Widget *mvc;
+
+  mvc = ewl_widget_name_find("device_mvc");
+  ewl_mvc_dirty_set(EWL_MVC(mvc), 1);
+#endif
+}
+
+
+Storage *
+storage_new(void)
+{
+  Storage *s;
+  s = calloc(1, sizeof(Storage));
+  s->type = DEVICE_TYPE_STORAGE;
+  s->volumes = ecore_list_new();
+  return s;
+}
+
+void
+storage_free(Storage *storage)
+{
+  Volume *v;
+  printf("storage_free: %s\n", storage->udi);
+
+  /* disconnect storage from volume */
+  ecore_list_first_goto(storage->volumes);
+  while ((v = ecore_list_next(storage->volumes)))
+    v->storage = NULL;
+  ecore_list_destroy(storage->volumes);
+    
+  if (storage->udi) free(storage->udi);
+  if (storage->bus) free(storage->bus);
+  if (storage->drive_type) free(storage->drive_type);
+
+  if (storage->model) free(storage->model);
+  if (storage->vendor) free(storage->vendor);
+  if (storage->serial) free(storage->serial);
+  if (storage->icon.drive) free(storage->icon.drive);
+  if (storage->icon.volume) free(storage->icon.volume);
+
+  free(storage);
+}
+
+static int
+storage_find_helper(Storage *s, const char *udi)
+{
+  if (!s->udi) return -1;
+  return strcmp(s->udi, udi);
+}
+
+Storage *
+storage_find(const char *udi)
+{
+  Storage *s = NULL;
+  if (!udi) return NULL;
+  s = ecore_list_find(storage_devices, ECORE_COMPARE_CB(storage_find_helper), udi);
+  return s;
+}
+
+void
+storage_remove(const char *udi)
+{
+  if (storage_find(udi))
+  {
+    ecore_list_remove_destroy(storage_devices);
+    devices_dirty();
+  }
+}
+
+static void
+cb_storage_properties(void *data, void *reply_data, DBusError *error)
+{
+  Storage *s = data;
+  E_Hal_Properties *ret = reply_data;
+  int err = 0;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    goto error;
+  }
+
+  s->bus = e_hal_property_string_get(ret, "storage.bus", &err);
+  if (err) goto error;
+  s->drive_type = e_hal_property_string_get(ret, "storage.drive_type", &err);
+  if (err) goto error;
+  s->model = e_hal_property_string_get(ret, "storage.model", &err);
+  if (err) goto error;
+  s->vendor = e_hal_property_string_get(ret, "storage.vendor", &err);
+  if (err) goto error;
+  s->serial = e_hal_property_string_get(ret, "storage.serial", &err);
+
+  s->removable = e_hal_property_bool_get(ret, "storage.removable", &err);
+  if (err) goto error;
+
+  if (s->removable)
+  {
+    s->media_available = e_hal_property_bool_get(ret, "storage.removable.media_available", &err);
+    s->media_size = e_hal_property_uint64_get(ret, "storage.removable.media_size", &err);
+  }
+
+  s->requires_eject = e_hal_property_bool_get(ret, "storage.requires_eject", &err);
+  s->hotpluggable = e_hal_property_bool_get(ret, "storage.hotpluggable", &err);
+  s->media_check_enabled = e_hal_property_bool_get(ret, "storage.media_check_enabled", &err);
+
+  s->icon.drive = e_hal_property_string_get(ret, "storage.icon.drive", &err);
+  s->icon.volume = e_hal_property_string_get(ret, "storage.icon.volume", &err);
+
+  devices_dirty();
+  /* now fetch the children (volumes?) */
+
+  //printf("Got storage:\n  udi: %s\n  bus: %s\n  drive_type: %s\n  model: %s\n  vendor: %s\n  serial: %s\n  icon.drive: %s\n  icon.volume: %s\n\n", s->udi, s->bus, s->drive_type, s->model, s->vendor, s->serial, s->icon.drive, s->icon.volume);
+  return;
+
+error:
+  storage_remove(s->udi);
+}
+
+Storage *
+storage_append(const char *udi)
+{
+  Storage *s;
+  if (!udi) return NULL;
+  s = storage_new();
+  s->udi = strdup(udi);
+  ecore_list_append(storage_devices, s);
+  e_hal_device_get_all_properties(conn, s->udi, cb_storage_properties, s);
+  devices_dirty();
+  return s;
+}
+
+Volume *
+volume_new(void)
+{
+  Volume *v;
+  v = calloc(1, sizeof(Volume));
+  v->type = DEVICE_TYPE_VOLUME;
+  return v;
+}
+
+void
+volume_free(Volume *volume)
+{
+  if (!volume) return;
+
+  /* disconnect volume from storage */
+  if (volume->storage)
+  {
+    if (ecore_list_goto(volume->storage->volumes, volume))
+      ecore_list_remove(volume->storage->volumes);
+  }
+
+  if (volume->udi) free(volume->udi);
+  if (volume->uuid) free(volume->uuid);
+  if (volume->label) free(volume->label);
+  if (volume->fstype) free(volume->fstype);
+  if (volume->partition_label) free(volume->partition_label);
+  if (volume->mount_point) free(volume->mount_point);
+
+  free(volume);
+}
+
+static int
+volume_find_helper(Volume *v, const char *udi)
+{
+  if (!v->udi) return -1;
+  return strcmp(v->udi, udi);
+}
+
+Volume *
+volume_find(const char *udi)
+{
+  if (!udi) return NULL;
+  return ecore_list_find(volumes, ECORE_COMPARE_CB(volume_find_helper), udi);
+}
+
+void
+volume_remove(const char *udi)
+{
+  if (volume_find(udi))
+  {
+    ecore_list_remove_destroy(volumes);
+    devices_dirty();
+  }
+}
+
+static void
+cb_volume_properties(void *data, void *reply_data, DBusError *error)
+{
+  Volume *v = data;
+  Storage *s = NULL;
+  E_Hal_Device_Get_All_Properties_Return *ret = reply_data;
+  int err = 0;
+  char *str = NULL;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    goto error;
+  }
+
+  /* skip volumes with volume.ignore set */
+  if (e_hal_property_bool_get(ret, "volume.ignore", &err) || err)
+    goto error;
+
+  /* skip volumes that aren't filesystems */
+  str = e_hal_property_string_get(ret, "volume.fsusage", &err);
+  if (err || !str) goto error;
+  if (strcmp(str, "filesystem")) goto error;
+  free(str);
+  str = NULL;
+
+  v->uuid = e_hal_property_string_get(ret, "volume.uuid", &err);
+  if (err) goto error;
+
+  v->label = e_hal_property_string_get(ret, "volume.label", &err);
+  if (err) goto error;
+
+  v->fstype = e_hal_property_string_get(ret, "volume.fstype", &err);
+  if (err) goto error;
+
+  v->mounted = e_hal_property_bool_get(ret, "volume.is_mounted", &err);
+  if (err) goto error;
+
+  v->partition = e_hal_property_bool_get(ret, "volume.is_partition", &err);
+  if (err) goto error;
+
+  v->mount_point = e_hal_property_string_get(ret, "volume.mount_point", &err);
+  if (err) goto error;
+
+  if (v->partition)
+  {
+    v->partition_label = e_hal_property_string_get(ret, "volume.partition.label", &err);
+    if (err) goto error;
+  }
+
+  str = e_hal_property_string_get(ret, "info.parent", &err);
+  if (!err && str)
+  {
+    s = storage_find(str);
+    if (s)
+    {
+      v->storage = s;
+      ecore_list_append(s->volumes, v);
+    }
+    free(str);
+    str = NULL;
+  }
+  
+  //printf("Got volume\n  udi: %s\n  uuid: %s\n  fstype: %s\n  label: %s\n  partition: %d\n  partition_label: %s\n  mounted: %d\n  mount_point: %s\n\n", v->udi, v->uuid, v->fstype,  v->label, v->partition, v->partition ? v->partition_label : "(not a partition)", v->mounted, v->mount_point);
+  //if (s) printf("  for storage: %s\n", s->udi);
+  //else printf("  storage unknown\n");
+
+  devices_dirty();
+  return;
+
+error:
+  if (str) free(str);
+  volume_remove(v->udi);
+  return;
+  
+}
+
+void
+volume_setup(Volume *v)
+{
+  e_hal_device_get_all_properties(conn, v->udi, cb_volume_properties, v);
+}
+
+Volume *
+volume_append(const char *udi)
+{
+  Volume *v;
+  if (!udi) return NULL;
+  printf("ADDING %s\n", udi);
+  v = volume_new();
+  v->udi = strdup(udi);
+  ecore_list_append(volumes, v);
+  volume_setup(v);
+
+  //this will get called when volume_setup() returns, which is more important
+  //devices_dirty();
+
+  return v;
+}
+
+static void
+cb_test_get_all_devices(void *user_data, void *reply_data, DBusError *error)
+{
+  E_Hal_Manager_Get_All_Devices_Return *ret = reply_data;
+  char *device;
+  
+  if (!ret || !ret->strings) return;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    return;
+  }
+
+  ecore_list_first_goto(ret->strings);
+  while ((device = ecore_list_next(ret->strings)))
+  {
+    printf("device: %s\n", device);
+  }
+}
+
+static void
+cb_test_find_device_by_capability_storage(void *user_data, void *reply_data, DBusError *error)
+{
+  E_Hal_Manager_Find_Device_By_Capability_Return *ret = reply_data;
+  char *device;
+  
+  if (!ret || !ret->strings) return;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    return;
+  }
+
+  ecore_list_first_goto(ret->strings);
+  while ((device = ecore_list_next(ret->strings)))
+    storage_append(device);
+}
+
+static void
+cb_test_find_device_by_capability_volume(void *user_data, void *reply_data, DBusError *error)
+{
+  E_Hal_Manager_Find_Device_By_Capability_Return *ret = reply_data;
+  char *device;
+  
+  if (!ret || !ret->strings) return;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    return;
+  }
+
+  ecore_list_first_goto(ret->strings);
+  while ((device = ecore_list_next(ret->strings)))
+    volume_append(device);
+}
+
+static void
+cb_is_storage(void *user_data, void *reply_data, DBusError *error)
+{
+  char *udi = user_data;
+  E_Hal_Device_Query_Capability_Return *ret = reply_data;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    goto error;
+  }
+
+  if (ret && ret->boolean)
+    storage_append(udi);
+
+error:
+  free(udi);
+}
+
+static void
+cb_is_volume(void *user_data, void *reply_data, DBusError *error)
+{
+  char *udi = user_data;
+  E_Hal_Device_Query_Capability_Return *ret = reply_data;
+
+  if (dbus_error_is_set(error)) 
+  {
+    // XXX handle...
+    dbus_error_free(error);
+    goto error;
+  }
+
+  if (ret && ret->boolean)
+    volume_append(udi);
+
+error:
+  free(udi);
+}
+
+static void
+cb_signal_device_added(void *data, DBusMessage *msg)
+{
+  DBusError err;
+  char *udi;
+  int ret;
+
+  dbus_error_init(&err);
+  dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID);
+  udi = strdup(udi);
+  printf("Device added: %s\n", udi); 
+  ret = e_hal_device_query_capability(conn, udi, "storage", cb_is_storage, strdup(udi));
+  e_hal_device_query_capability(conn, udi, "volume", cb_is_volume, strdup(udi));
+}
+
+void
+cb_signal_device_removed(void *data, DBusMessage *msg)
+{
+  DBusError err;
+  char *udi;
+
+  dbus_error_init(&err);
+
+  dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID);
+  printf("Removed: %s\n", udi);
+  storage_remove(udi);
+  volume_remove(udi);
+}
+
+void
+cb_signal_new_capability(void *data, DBusMessage *msg)
+{
+  DBusError err;
+  char *udi, *capability;
+
+  dbus_error_init(&err);
+
+  dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_STRING, &capability, DBUS_TYPE_INVALID);
+  if (!strcmp(capability, "storage"))
+    storage_append(udi);
+
+}
+
+/*** gui ***/
+
+#if EWL_GUI
+static void
+cb_window_destroy(Ewl_Widget *w, void *ev, void *data)
+{
+  ewl_main_quit();
+}
+
+static void
+cb_window_close(Ewl_Widget *w, void *ev, void *data)
+{
+  ewl_widget_destroy(w);
+}
+
+static void
+cb_volume_unmounted(void *user_data, void *method_return, DBusError *error)
+{
+  Volume *vol = user_data;
+  vol->mounted = 0;
+  printf("Volume unmounted reply: %s\n", vol->udi);
+}
+
+static void
+cb_volume_mounted(void *user_data, void *method_return, DBusError *error)
+{
+  Volume *vol = user_data;
+  vol->mounted = 1;
+  printf("Volume mounted reply: %s\n", vol->udi);
+}
+
+static void
+cb_device_view_clicked(Ewl_Widget *w, void *ev, void *data)
+{
+  Device *dev = data;
+  char buf[4096];
+
+  printf("Device clicked: %s\n", dev->udi);
+  if (dev->type == DEVICE_TYPE_VOLUME)
+  {
+    Volume *vol = (Volume *)dev;
+    if (vol->mounted)
+    {
+      e_hal_device_volume_unmount(conn, vol->udi, NULL, cb_volume_unmounted, vol);
+    }
+    else
+    {
+      char *mount_point;
+#if 0
+      if (vol->mount_point && vol->mount_point[0])
+        mount_point = vol->mount_point;
+#endif
+      if (vol->label && vol->label[0])
+        mount_point = vol->label;
+      else if (vol->uuid && vol->uuid[0])
+        mount_point = vol->uuid;
+      else
+      {
+        // XXX need to check this...
+        snprintf(buf, sizeof(buf), "%d\n", mount_id++);
+        mount_point = buf;
+      }
+
+      printf("Attempting to mount %s to %s\n", vol->udi, mount_point);
+      e_hal_device_volume_mount(conn, vol->udi, mount_point, vol->fstype, NULL, cb_volume_mounted, vol);
+    }
+  }
+}
+
+
+static Ewl_Widget *
+cb_device_view_constructor(void)
+{
+  Ewl_Widget *icon;
+
+  icon = ewl_icon_simple_new();
+  ewl_box_orientation_set(EWL_BOX(icon), EWL_ORIENTATION_HORIZONTAL);
+  return icon;
+}
+
+static void
+device_view_device_set(Ewl_Icon *icon, Device *dev)
+{
+  char buf[500];
+  const char *path;
+  const char *icon_name = NULL;
+
+  if (dev->type == DEVICE_TYPE_STORAGE)
+  {
+    Storage *s = (Storage *)dev;
+
+    if (s->icon.drive && s->icon.drive[0])
+      icon_name = s->icon.drive;
+
+    snprintf(buf, sizeof(buf), "%s", (s->model && s->model[0]) ? s->model : "Unknown drive");
+  }
+  else if (dev->type == DEVICE_TYPE_VOLUME)
+  {
+    Volume *v = (Volume *)dev;
+    if (v->storage && v->storage->icon.volume && v->storage->icon.volume[0])
+      icon_name = v->storage->icon.volume;
+    snprintf(buf, sizeof(buf), "%s (%s)", (v->label && v->label[0]) ? v->label : "Unlabeled Volume", v->fstype ? v->fstype : "Unknown");
+  }
+  else
+  {
+    fprintf(stderr, "Invalid device type.");
+    buf[0] = 0;
+  }
+
+  ewl_icon_label_set(icon, buf);
+  if (icon_name)
+  {
+    //printf("find icon path: %s\n", icon_name);
+    path = efreet_icon_path_find("Tango", icon_name, 32);
+    //printf("found: %s\n", path);
+    if (path)
+    {
+      ewl_icon_image_set(icon, path, NULL);
+      free(path);
+    }
+  }
+  ewl_callback_append(EWL_WIDGET(icon), EWL_CALLBACK_CLICKED, cb_device_view_clicked, dev);
+
+}
+
+static void
+cb_device_view_assign(Ewl_Widget *w, void *data)
+{
+  Device *dev = data;
+  device_view_device_set(EWL_ICON(w), dev);
+}
+
+static Ewl_Widget *
+cb_device_view_header_fetch(void *data, int column)
+{
+  Ewl_Widget *label;
+
+  label = ewl_label_new();
+  ewl_label_text_set(EWL_LABEL(label), "Device");
+  ewl_widget_show(label);
+  return label;
+}
+
+static int
+cb_device_tree_expandable_get(void *data, unsigned int row)
+{
+  Ecore_List *devices;
+  Device *dev;
+
+  devices = data;
+  if (!devices) return FALSE;
+
+  dev = ecore_list_index_goto(devices, row);
+  if (!dev) return FALSE;
+
+  if (dev->type == DEVICE_TYPE_STORAGE)
+  {
+    Storage *s = (Storage *)dev;
+    if (ecore_list_count(s->volumes) > 0)
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
+static void *
+cb_device_tree_expansion_data_fetch(void *data, unsigned int parent)
+{
+  Ecore_List *devices;
+  Device *dev;
+  Storage *s;
+  dev = data;
+
+  devices = data;
+  if (!devices) return NULL;
+
+  dev = ecore_list_index_goto(devices, parent);
+  
+  if (!dev) return NULL;
+  if (dev->type != DEVICE_TYPE_STORAGE) return NULL;
+  s = (Storage *)dev;
+  return s->volumes;
+}
+
+#if 0
+Ewl_Widget *
+mountbox_list_new(void)
+{
+  Ewl_Widget *list;
+  Ewl_Model *model;
+  Ewl_View *view;
+
+  model = ewl_model_ecore_list_get();
+
+  view = ewl_view_new();
+  ewl_view_constructor_set(view, cb_device_view_constructor);
+  ewl_view_assign_set(view, EWL_VIEW_ASSIGN(cb_device_view_assign));
+
+  list = ewl_list_new();
+  ewl_mvc_model_set(EWL_MVC(list), model);
+  ewl_mvc_view_set(EWL_MVC(list), view);
+  ewl_mvc_data_set(EWL_MVC(list), volumes);
+
+  ewl_widget_name_set(list, "volume_mvc");
+
+  return list;
+}
+#endif
+
+Ewl_Widget *
+mountbox_tree_new(void)
+{
+  Ewl_Widget *tree;
+  Ewl_Model *model;
+  Ewl_View *view;
+
+  model = ewl_model_ecore_list_get();
+  ewl_model_expandable_set(model, cb_device_tree_expandable_get);
+  ewl_model_expansion_data_fetch_set(model, cb_device_tree_expansion_data_fetch);
+
+  view = ewl_view_new();
+  ewl_view_constructor_set(view, cb_device_view_constructor);
+  ewl_view_assign_set(view, EWL_VIEW_ASSIGN(cb_device_view_assign));
+  ewl_view_header_fetch_set(view, cb_device_view_header_fetch);
+
+  tree = ewl_tree2_new();
+  ewl_mvc_model_set(EWL_MVC(tree), model);
+  ewl_mvc_data_set(EWL_MVC(tree), storage_devices);
+  ewl_tree2_column_append(EWL_TREE2(tree), view, FALSE);
+
+  ewl_widget_name_set(tree, "device_mvc");
+
+  return tree;
+}
+
+Ewl_Widget *
+mountbox_mainwin_new(void)
+{
+  Ewl_Widget *win, *box, *list;
+  win = ewl_window_new();
+  ewl_window_title_set(EWL_WINDOW(win), "EWL Mountbox");
+  ewl_window_class_set(EWL_WINDOW(win), "ewl_mountbox");
+  ewl_window_name_set(EWL_WINDOW(win), "ewl_mountbox");
+
+  ewl_object_fill_policy_set(EWL_OBJECT(win), EWL_FLAG_FILL_ALL);
+  ewl_object_size_request(EWL_OBJECT(win), 400, 400);
+
+  ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, cb_window_close, NULL);
+  ewl_callback_append(win, EWL_CALLBACK_DESTROY, cb_window_destroy, NULL);
+
+  box = ewl_vbox_new();
+  ewl_container_child_append(EWL_CONTAINER(win), box);
+  ewl_widget_show(box);
+
+  list = mountbox_tree_new();
+  ewl_container_child_append(EWL_CONTAINER(box), list);
+  ewl_widget_show(list);
+
+  return win;
+}
+#endif
+int 
+main(int argc, char **argv)
+{
+#if EWL_GUI
+  Ewl_Widget *win;
+#endif
+
+  ecore_init();
+  ecore_string_init();
+  e_dbus_init();
+
+#if EWL_GUI
+  efreet_init();
+  if (!ewl_init(&argc, argv))
+  {
+    fprintf(stderr, "Unable to init EWL.\n");
+    return 1;
+  }
+#endif
+
+  conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+  if (!conn)
+  {
+    printf("Error connecting to system bus. Is it running?\n");
+    return 1;
+  }
+
+  storage_devices = ecore_list_new();
+  ecore_list_free_cb_set(storage_devices, ECORE_FREE_CB(storage_free));
+  volumes = ecore_list_new();
+  ecore_list_free_cb_set(volumes, ECORE_FREE_CB(volume_free));
+
+#if EWL_GUI
+  win = mountbox_mainwin_new();
+  ewl_widget_show(win);
+#endif
+
+  e_hal_manager_get_all_devices(conn, cb_test_get_all_devices, NULL);
+  e_hal_manager_find_device_by_capability(conn, "storage", cb_test_find_device_by_capability_storage, NULL);
+  e_hal_manager_find_device_by_capability(conn, "volume", cb_test_find_device_by_capability_volume, NULL);
+  
+  e_dbus_signal_handler_add(conn, "org.freedesktop.Hal", "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal.Manager", "DeviceAdded", cb_signal_device_added, NULL);
+  e_dbus_signal_handler_add(conn, "org.freedesktop.Hal", "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal.Manager", "DeviceRemoved", cb_signal_device_removed, NULL);
+  e_dbus_signal_handler_add(conn, "org.freedesktop.Hal", "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal.Manager", "NewCapability", cb_signal_new_capability, NULL);
+
+#if EWL_GUI
+  ewl_main();
+  efreet_shutdown();
+  ewl_shutdown();
+#else
+  ecore_main_loop_begin();
+#endif
+  ecore_list_destroy(storage_devices);
+  ecore_list_destroy(volumes);
+  e_dbus_connection_close(conn);
+  e_dbus_shutdown();
+  ecore_string_shutdown();
+  ecore_shutdown();
+  return 1;
+}
diff --git a/src/bin/nm.c b/src/bin/nm.c
new file mode 100644 (file)
index 0000000..5ff90ec
--- /dev/null
@@ -0,0 +1,249 @@
+#include <E_Nm.h>
+#include <Ecore_Data.h>
+#include <dbus/dbus.h>
+
+#define E_NM_DEVICE_TYPE_WIRED 1
+#define E_NM_DEVICE_TYPE_WIRELESS 2
+
+typedef struct NM_Manager NM_Manager;
+struct NM_Manager
+{
+  E_NM_Context *ctx;
+  Ecore_List *devices;
+};
+
+void
+cb_manager_get_udi(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    char *udi;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+       dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &udi);
+
+    printf("Got udi: %s\n", udi);
+}
+
+void
+cb_manager_get_interface(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    char *interface;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &interface);
+
+    printf("Got interface: %s\n", interface);
+}
+
+void
+cb_manager_get_driver(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    char *driver;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &driver);
+
+    printf("Got driver: %s\n", driver);
+}
+
+void
+cb_manager_get_capabilities(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    dbus_uint32_t caps;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &caps);
+
+    printf("Got capabilities: %i\n", caps);
+}
+
+void
+cb_manager_get_ip4address(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    dbus_int32_t ip;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &ip);
+
+    printf("Got IPv4 address: %i.%i.%i.%i\n",
+          (ip       & 0xff),
+          ((ip >> 8 ) & 0xff),
+          ((ip >> 16) & 0xff),
+          ((ip >> 24) & 0xff)
+          );
+}
+
+void
+cb_manager_get_state(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    dbus_uint32_t state;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &state);
+
+    printf("Got state: %i\n", state);
+}
+
+void
+cb_manager_get_ip4config(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    char *ip4config;
+
+    if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &ip4config);
+
+    printf("Got IPv4 config path: %s\n", ip4config);
+}
+
+void
+cb_manager_get_carrier(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    dbus_uint32_t carrier;
+
+   if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &carrier);
+
+    printf("Got carrier: %i\n", carrier);
+}
+
+void
+cb_manager_get_type(void *data, void *reply, DBusError *err)
+{
+    DBusMessageIter iter, sub;
+    dbus_uint32_t type;
+
+    if (dbus_error_is_set(err))
+      {
+        printf("Error: %s - %s\n" ,err->name, err->message);
+        return;
+      }
+
+    dbus_message_iter_init(reply, &iter);
+    dbus_message_iter_recurse(&iter, &sub);
+    dbus_message_iter_get_basic(&sub, &type);
+
+    printf("Got type: %i (1 = ethernet, 2 = wireless)\n", type);
+}
+
+void
+cb_manager_get_devices(void *data, void *reply, DBusError *err)
+{
+   NM_Manager *app = data;
+   const char *dev;
+
+   if (dbus_error_is_set(err))
+     {
+       printf("Error: %s - %s\n" ,err->name, err->message);
+       return;
+     }
+   
+   app->devices = reply;
+   ecore_list_first_goto(app->devices);
+   printf("Got devices:\n");
+   while ((dev = ecore_list_next(app->devices)))
+     {
+       printf("%s\n", dev);
+        e_nm_device_get_udi(app->ctx, dev, cb_manager_get_udi, app);
+       e_nm_device_get_interface(app->ctx, dev, cb_manager_get_interface, app);
+       e_nm_device_get_driver(app->ctx, dev, cb_manager_get_driver, app);
+       e_nm_device_get_capabilities(app->ctx, dev, cb_manager_get_capabilities, app);
+       e_nm_device_get_ip4address(app->ctx, dev, cb_manager_get_ip4address, app);
+       e_nm_device_get_state(app->ctx, dev, cb_manager_get_state, app);
+       /* FIXME: Getting the ip4config needs fixing */
+       //e_nm_device_get_ip4config(app->ctx, dev, cb_manager_get_ip4config, app);
+       e_nm_device_get_carrier(app->ctx, dev, cb_manager_get_carrier, app);
+       e_nm_device_get_type(app->ctx, dev, cb_manager_get_type, app);
+     }
+}
+
+int 
+main(int argc, char **argv)
+{
+   NM_Manager *app;
+   ecore_init();
+   ecore_string_init();
+   e_dbus_init();
+   
+   app = calloc(1, sizeof(NM_Manager));
+   
+   app->ctx = e_nm_new();
+   if (!app->ctx)
+     {
+       printf("Error connecting to system bus. Is it running?\n");
+       return 1;
+     }
+   
+   e_nm_get_devices(app->ctx, cb_manager_get_devices, app);
+   
+   ecore_main_loop_begin();
+   
+   e_nm_free(app->ctx);
+   free(app);
+   e_dbus_shutdown();
+   ecore_string_shutdown();
+   ecore_shutdown();
+   return 0;
+}
diff --git a/src/bin/notification_daemon.c b/src/bin/notification_daemon.c
new file mode 100644 (file)
index 0000000..aeb8c17
--- /dev/null
@@ -0,0 +1,175 @@
+#include <E_Notification_Daemon.h>
+
+typedef struct Daemon_Data Daemon_Data;
+typedef struct Timer_Data Timer_Data;
+
+struct Timer_Data
+{
+  Daemon_Data *d;
+  E_Notification *n;
+};
+
+struct Daemon_Data
+{
+  E_Notification_Daemon *daemon;
+  Ecore_List *open_notes;
+
+  Ecore_List *history;
+  int history_start;
+  int max_history_length;
+  int default_timeout;
+
+  int next_id;
+};
+
+void
+daemon_note_close(Daemon_Data *dd, E_Notification *n, int reason)
+{
+  printf("Close notification #%d\n", e_notification_id_get(n));
+
+  if (ecore_list_goto(dd->open_notes, n))
+  {
+    ecore_list_remove(dd->open_notes);
+    e_notification_closed_set(n, 1);
+    e_notification_daemon_signal_notification_closed(dd->daemon, e_notification_id_get(n), reason);
+    e_notification_unref(n);
+  }
+}
+
+int
+cb_note_close_timer(void *data)
+{
+  Timer_Data *td = data;
+
+  if (!e_notification_closed_get(td->n))
+    daemon_note_close(td->d, td->n, E_NOTIFICATION_CLOSED_EXPIRED);
+
+  e_notification_unref(td->n);
+  free(td);
+
+  return 0;
+}
+
+void
+daemon_note_show(Daemon_Data *d, E_Notification *n)
+{
+  e_notification_ref(n);
+  ecore_list_append(d->open_notes, n); 
+  e_notification_ref(n);
+  ecore_list_append(d->history, n); 
+
+  // adjust history
+  if (ecore_list_count(d->history) > d->max_history_length)
+  {
+    E_Notification *old;
+    old = ecore_list_first_remove(d->history);
+    d->history_start = e_notification_id_get(old) + 1;
+    e_notification_unref(old);
+  }
+
+  {
+    int timeout;
+
+    timeout = e_notification_timeout_get(n);
+    Timer_Data *td = calloc(1, sizeof(Timer_Data));
+    td->d = d;
+    e_notification_ref(n);
+    td->n = n;
+    ecore_timer_add(timeout == -1 ? d->default_timeout : (float)timeout / 1000, cb_note_close_timer, td);
+  }
+
+  printf("Received notification from %s:\n%s\n%s\n\n", 
+    e_notification_app_name_get(n),
+    e_notification_summary_get(n), e_notification_body_get(n)
+  );
+}
+
+E_Notification *
+daemon_note_open_find(Daemon_Data *d, int id)
+{
+  E_Notification *n;
+  ecore_list_first_goto(d->open_notes);
+  while ((n = ecore_list_next(d->open_notes)))
+    if (e_notification_id_get(n) == id) return n;
+
+  return NULL;
+}
+
+E_Notification *
+daemon_note_history_find(Daemon_Data *d, int id)
+{
+  if (id < d->history_start) return NULL;
+
+  // TODO
+
+  return NULL;
+}
+
+
+
+int
+cb_notify(E_Notification_Daemon *daemon, E_Notification *n)
+{
+  Daemon_Data *dd;
+  unsigned int replaces_id;
+  unsigned int new_id;
+
+  dd = e_notification_daemon_data_get(daemon);
+  replaces_id = e_notification_replaces_id_get(n);
+  if (replaces_id) 
+  {
+    // close old one flagged as replaced
+  }
+
+  new_id = dd->next_id++;
+  e_notification_id_set(n, new_id);
+
+  daemon_note_show(dd, n);
+
+  return new_id;
+}
+
+void
+cb_close_notification(E_Notification_Daemon *daemon, unsigned int notification_id)
+{
+  Daemon_Data *dd;
+  E_Notification *n;
+  dd = e_notification_daemon_data_get(daemon);
+  n = daemon_note_open_find(dd, notification_id);
+  if (n)
+    daemon_note_close(dd, n, E_NOTIFICATION_CLOSED_REQUESTED);
+  // else send error?
+}
+
+
+int
+main(int argc, char **argv)
+{
+  E_Notification_Daemon *d;
+  Daemon_Data *dd;
+
+  ecore_init();
+
+  dd = calloc(1, sizeof(Daemon_Data));
+  dd->open_notes = ecore_list_new();
+  dd->history = ecore_list_new();
+  ecore_list_free_cb_set(dd->open_notes, ECORE_FREE_CB(e_notification_unref));
+  ecore_list_free_cb_set(dd->history, ECORE_FREE_CB(e_notification_unref));
+  dd->next_id = dd->history_start = 1;
+  dd->max_history_length = 5;
+  dd->default_timeout = 5;
+
+  /* set up the daemon */
+  d = e_notification_daemon_add("e_notification_module", "Enlightenment");
+  e_notification_daemon_data_set(d, dd);
+  dd->daemon = d;
+  e_notification_daemon_callback_notify_set(d, cb_notify);
+  e_notification_daemon_callback_close_notification_set(d, cb_close_notification);
+
+  ecore_main_loop_begin();
+  ecore_list_destroy(dd->open_notes);
+  ecore_list_destroy(dd->history);
+  free(dd);
+  e_notification_daemon_free(d);
+  ecore_shutdown();
+}
diff --git a/src/bin/notify-send.c b/src/bin/notify-send.c
new file mode 100644 (file)
index 0000000..76f0f8f
--- /dev/null
@@ -0,0 +1,127 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <getopt.h>
+#include <E_Notify.h>
+
+#include "config.h"
+
+void
+version(void)
+{
+  printf("e-notify-send "VERSION"\n");
+}
+
+void
+usage(void)
+{
+  printf("Usage:\n"
+         "  e-notify-send [OPTION...] <SUMMARY> [BODY] - create a notification\n"
+         "\n"
+         "Help Options:\n"
+         "  -?, --help                        Show help options\n"
+         "\n"
+         "Application Options:\n"
+         "  -n, --name=NAME                   Specifies the application name to use (default is e-notify-send).\n"
+         "  -u, --urgency=LEVEL               Specifies the urgency level (low, normal, critical).\n"
+         "  -t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.\n"
+         "  -i, --icon=ICON                   Specifies an icon filename or stock icon to display.\n"
+         "  -c, --category=TYPE               Specifies the notification category.\n"
+         "  -v, --version                     Version of the package.\n"
+         "\n");
+}
+
+int
+main(int argc, char **argv)
+{
+  int ch;
+  char *endptr;
+  int timeout;
+  E_Notification *n;
+
+  e_notification_init();
+  n = e_notification_new();
+  e_notification_app_name_set(n, "e-notify-send");
+  e_notification_timeout_set(n, -1);
+
+  /* options descriptor */
+  static struct option longopts[] = {
+      { "help",        no_argument,            NULL,           '?' },
+      { "name",        required_argument,      NULL,           'n' },
+      { "urgency",     required_argument,      NULL,           'u' },
+      { "expire-time", required_argument,      NULL,           't' },
+      { "icon",        required_argument,      NULL,           'i' },
+      { "categorie",   required_argument,      NULL,           'c' },
+      { "version",     no_argument,            NULL,           'v' },
+      { NULL,          0,                      NULL,             0 }
+  };
+
+  while ((ch = getopt_long(argc, argv, "?vn:u:t:i:c:", longopts, NULL)) != -1)
+    switch (ch) {
+    case '?':
+      usage();
+      return EXIT_SUCCESS;
+      break;
+    case 'v':
+      version();
+      return EXIT_SUCCESS;
+      break;
+    case 'n':
+      e_notification_app_name_set(n, optarg);
+      break;
+    case 'u':
+      if (!strcasecmp(optarg, "low"))
+        e_notification_hint_urgency_set(n, E_NOTIFICATION_URGENCY_LOW);
+      else if (!strcasecmp(optarg, "normal"))
+        e_notification_hint_urgency_set(n, E_NOTIFICATION_URGENCY_NORMAL);
+      else if (!strcasecmp(optarg, "critical"))
+        e_notification_hint_urgency_set(n, E_NOTIFICATION_URGENCY_CRITICAL);
+      else
+        printf("Urgency level must be: low, normal or critical\n");
+      break;
+    case 't':
+      errno = 0;
+      timeout = strtol(optarg, &endptr, 10);
+      if ((errno != 0 && timeout == 0) || endptr == optarg) 
+        {
+          fprintf(stderr, "Cannot parse integer value '%s' for -t\n", optarg);
+          return EXIT_FAILURE;
+        }
+      else if (timeout > INT_MAX || timeout < INT_MIN)
+        {
+          fprintf(stderr, "Integer value '%s' for -t out of range\n", optarg);
+          return EXIT_FAILURE;
+        }
+      else 
+        e_notification_timeout_set(n, timeout);
+      break;
+    case 'i':
+      e_notification_app_icon_set(n, optarg);
+      break;
+    case 'c':
+      e_notification_hint_category_set(n, optarg);
+      break;
+    default:
+      usage();
+      return EXIT_FAILURE;
+    }
+  argc -= optind;
+  argv += optind;
+
+  if (argc < 1)
+    {
+      usage();
+      return EXIT_FAILURE;
+    }
+
+  e_notification_summary_set(n, argv[0]);
+  if (argc > 1) e_notification_body_set(n, argv[1]);
+
+  e_notification_send(n, NULL, NULL);
+  e_notification_unref(n);
+  e_notification_shutdown();
+
+  return EXIT_SUCCESS;
+}
diff --git a/src/bin/notify.c b/src/bin/notify.c
new file mode 100644 (file)
index 0000000..49851a1
--- /dev/null
@@ -0,0 +1,82 @@
+#include <E_DBus.h>
+#include <E_Notify.h>
+
+void
+cb_sent(void *data, void *ret, DBusError *err)
+{
+  E_Notification_Return_Notify *notify;
+  notify = ret;
+  if (notify) 
+  {
+    printf("id: %d\n", notify->notification_id);
+  }
+  else if (dbus_error_is_set(err))
+  {
+    printf("Error: %s\n", err->message);
+  }
+
+  free(notify);
+}
+
+int
+cb_timer(void *data)
+{
+  E_Notification *n;
+  char buf[1024];
+  static int num = 0;
+  static const char *icons[] = {
+    "xterm",
+    "firefox",
+    "gvim"
+  };
+
+  snprintf(buf, sizeof(buf), "<i>%s</i> says <b>Hello</b> #%d", icons[num%3], num / 3); 
+  n = e_notification_full_new(icons[num%3], 0, icons[num%3], "Summary", buf, -1);
+  e_notification_send(n, cb_sent, NULL);
+  e_notification_unref(n);
+  num++;
+
+  return 1;
+}
+
+void
+cb_action_invoked(void *data, int type, void *event)
+{
+  E_Notification_Event_Action_Invoked *ev;
+
+  ev = event;
+  printf("Action (%d): %s\n", ev->notification_id, ev->action_id);
+  free(ev);
+}
+
+void
+cb_note_closed(void *data, int type, void *event)
+{
+  E_Notification_Event_Notification_Closed *ev;
+  static const char *reasons[] = {
+    "Expired",
+    "Dismissed",
+    "Requested",
+    "Undefined"
+  };
+
+  ev = event;
+  printf("Note %d closed: %s\n", ev->notification_id, reasons[ev->reason]);
+  free(ev);
+}
+
+int
+main(int argc, char **argv)
+{
+  int ret = 0;
+  ecore_init();
+  if (e_notification_init())
+  {
+    ecore_timer_add(1, cb_timer, NULL);
+    ecore_main_loop_begin();
+    e_notification_shutdown();
+  }
+
+  ecore_shutdown();
+  return ret;
+}
diff --git a/src/bin/test.c b/src/bin/test.c
new file mode 100644 (file)
index 0000000..31d6149
--- /dev/null
@@ -0,0 +1,103 @@
+#include <Ecore.h>
+#include "E_DBus.h"
+#include <stdio.h>
+#include <string.h>
+#include <dbus/dbus.h>
+
+void
+copy_message(DBusMessageIter *from, DBusMessageIter *to)
+{
+  int type;
+  printf("  copy message\n");
+  while((type = dbus_message_iter_get_arg_type(from)) != DBUS_TYPE_INVALID)
+  {
+    printf("  copy type: %c\n", type);
+    if (dbus_type_is_basic(type))
+    {
+      /* XXX is int64 big enough to hold all basic types? */
+      dbus_int64_t val;
+      dbus_message_iter_get_basic(from, &val);
+      dbus_message_iter_append_basic(to, type, &val);
+    }
+    else if (dbus_type_is_container(type))
+    {
+      int subtype;
+
+      subtype = dbus_message_iter_get_element_type(from);
+      if (type == DBUS_TYPE_ARRAY && dbus_type_is_fixed(subtype))
+      {
+        int n;
+        void *val;
+        dbus_message_iter_get_fixed_array(from, &val, &n);
+        dbus_message_iter_append_fixed_array(to, subtype, val, n);
+      }
+      else
+      {
+        DBusMessageIter fsub, tsub;
+        char *sig;
+        dbus_message_iter_recurse(from, &fsub);
+        dbus_message_iter_get_signature(&fsub);
+        dbus_message_iter_open_container(to, type, sig, &tsub);
+        copy_message(&fsub, &tsub);
+        dbus_message_iter_close_container(to, &tsub);
+      }
+    }
+    dbus_message_iter_next(from);
+  }
+}
+
+DBusMessage *
+cb_repeat(E_DBus_Object *obj, DBusMessage *msg)
+{
+  DBusMessage *reply;
+  DBusMessageIter from, to;
+
+  printf("\n\nREPEAT\n--------\n");
+  reply = dbus_message_new_method_return(msg);
+  dbus_message_iter_init(msg, &from);
+  dbus_message_iter_init_append(reply, &to);
+
+  copy_message(&from, &to);
+  return reply;
+}
+
+void
+cb_request_name(void *data, DBusMessage *msg, DBusError *err)
+{
+  // XXX check that this actually succeeded and handle errors...
+  printf("request name\n");
+}
+
+int
+_setup(E_DBus_Connection *conn)
+{
+  E_DBus_Object *repeater;
+  E_DBus_Interface *iface;
+  e_dbus_request_name(conn, "org.e.Repeater", 0, cb_request_name, NULL);
+  repeater = e_dbus_object_add(conn, "/org/e/Repeater", NULL);
+  iface = e_dbus_interface_new("org.e.Repeater");
+  e_dbus_interface_method_add(iface, "Repeat", NULL, NULL, cb_repeat);
+  e_dbus_object_interface_attach(repeater, iface);
+  return 1;
+}
+
+int
+main (int argc, char ** argv)
+{
+  E_DBus_Connection *conn;
+  ecore_init();
+  e_dbus_init();
+
+  conn = e_dbus_bus_get(DBUS_BUS_SESSION);
+  if (conn)
+  {
+    if (_setup(conn)) ecore_main_loop_begin();
+    e_dbus_connection_close(conn);
+  }
+
+  e_dbus_shutdown();
+  ecore_shutdown();
+
+  return 0;
+}
diff --git a/src/bin/test_client.c b/src/bin/test_client.c
new file mode 100644 (file)
index 0000000..3a6b8c8
--- /dev/null
@@ -0,0 +1,68 @@
+#include <E_DBus.h>
+
+#define NUM_LOOPS 10000
+
+static dbus_uint32_t msg_num = 0;
+
+void
+cb_reply(void *data, DBusMessage *reply, DBusError *error)
+{
+  dbus_uint32_t val;
+  if (dbus_error_is_set(error))
+  {
+    printf("Error: %s - %s\n", error->name, error->message);
+    return;
+  }
+
+  dbus_message_get_args(reply, error, DBUS_TYPE_UINT32, &val, DBUS_TYPE_INVALID);
+  printf("Received: %d\n", val);
+  if (val == NUM_LOOPS - 1) ecore_main_loop_quit();
+}
+
+int
+send_message(void *data)
+{
+
+  DBusMessage *msg;
+  E_DBus_Connection *conn;
+  
+  conn = data;
+
+  msg = dbus_message_new_method_call(
+    "org.e.Repeater",
+    "/org/e/Repeater",
+    "org.e.Repeater",
+    "Repeat"
+  );
+
+  dbus_message_append_args(msg, DBUS_TYPE_UINT32, &msg_num, DBUS_TYPE_INVALID);
+  msg_num++;
+  e_dbus_message_send(conn, msg, cb_reply, -1, NULL);
+  dbus_message_unref(msg);
+  printf("Sent: %d\n", msg_num);
+  return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+  E_DBus_Connection *conn;
+  int ret = 0;
+  ecore_init();
+  e_dbus_init();
+
+  conn = e_dbus_bus_get(DBUS_BUS_SESSION);
+  if (conn)
+    ecore_timer_add(0.0, send_message, conn);
+  else
+  {
+    printf("Error: could not connect to session bus.\n");
+    ret = 1;
+  }
+
+  ecore_main_loop_begin();
+
+  e_dbus_shutdown();
+  ecore_shutdown();
+  return ret;
+}
diff --git a/src/lib/.cvsignore b/src/lib/.cvsignore
new file mode 100644 (file)
index 0000000..e995588
--- /dev/null
@@ -0,0 +1,3 @@
+.deps
+Makefile
+Makefile.in
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
new file mode 100644 (file)
index 0000000..87c2fe1
--- /dev/null
@@ -0,0 +1,3 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+SUBDIRS=dbus hal nm notification
diff --git a/src/lib/dbus/.cvsignore b/src/lib/dbus/.cvsignore
new file mode 100644 (file)
index 0000000..e49f9e1
--- /dev/null
@@ -0,0 +1,12 @@
+.deps
+Makefile
+Makefile.in
+.libs
+e_dbus.lo
+e_dbus_interfaces.lo
+e_dbus_message.lo
+e_dbus_methods.lo
+e_dbus_object.lo
+e_dbus_signal.lo
+e_dbus_util.lo
+libedbus.la
diff --git a/src/lib/dbus/E_DBus.h b/src/lib/dbus/E_DBus.h
new file mode 100644 (file)
index 0000000..e08246f
--- /dev/null
@@ -0,0 +1,162 @@
+#ifndef E_DBUS_H
+#define E_DBUS_H
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+#include <dbus/dbus.h>
+#include <Ecore.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
+
+   EAPI extern int E_DBUS_EVENT_SIGNAL;
+
+   typedef struct E_DBus_Connection E_DBus_Connection;
+   typedef struct E_DBus_Object E_DBus_Object;
+   typedef struct E_DBus_Interface E_DBus_Interface;
+   typedef struct E_DBus_Signal_Handler E_DBus_Signal_Handler;
+
+   typedef DBusMessage *(* E_DBus_Method_Cb)(E_DBus_Object *obj, DBusMessage *message);
+   typedef void (*E_DBus_Method_Return_Cb) (void *data, DBusMessage *msg, DBusError *error);
+   typedef void (*E_DBus_Signal_Cb) (void *data, DBusMessage *msg);
+
+   typedef void (*E_DBus_Object_Property_Get_Cb) (E_DBus_Object *obj, const char *property, int *type, void **value);
+   typedef int  (*E_DBus_Object_Property_Set_Cb) (E_DBus_Object *obj, const char *property, int type, void *value);
+
+/**
+ * A callback function for a DBus call
+ * @param user_data the data passed in to the method call
+ * @param event_data a struct containing the return data.
+ */
+   typedef void (*E_DBus_Callback_Func) (void *user_data, void *method_return, DBusError *error);
+   typedef void *(*E_DBus_Unmarshal_Func) (DBusMessage *msg, DBusError *err);
+   typedef void (*E_DBus_Free_Func) (void *data);
+
+   typedef struct E_DBus_Callback E_DBus_Callback;
+
+
+   EAPI int e_dbus_init(void);
+   EAPI int e_dbus_shutdown(void);
+
+/* setting up the connection */
+
+   EAPI E_DBus_Connection *e_dbus_bus_get(DBusBusType type);
+
+   EAPI void e_dbus_connection_ref(E_DBus_Connection *conn);
+
+   EAPI E_DBus_Connection *e_dbus_connection_setup(DBusConnection *conn);
+   EAPI void e_dbus_connection_close(E_DBus_Connection *conn);
+
+/* receiving method calls */
+   EAPI E_DBus_Interface *e_dbus_interface_new(const char *interface);
+   EAPI void e_dbus_interface_ref(E_DBus_Interface *iface);
+   EAPI void e_dbus_interface_unref(E_DBus_Interface *iface);
+   EAPI void e_dbus_object_interface_attach(E_DBus_Object *obj, E_DBus_Interface *iface);
+   EAPI void e_dbus_object_interface_detach(E_DBus_Object *obj, E_DBus_Interface *iface);
+   EAPI int e_dbus_interface_method_add(E_DBus_Interface *iface, const char *member, const char *signature, const char *reply_signature, E_DBus_Method_Cb func);
+
+   EAPI E_DBus_Object *e_dbus_object_add(E_DBus_Connection *conn, const char *object_path, void *data);
+   EAPI void e_dbus_object_free(E_DBus_Object *obj);
+   EAPI void *e_dbus_object_data_get(E_DBus_Object *obj);
+
+   EAPI void e_dbus_object_property_get_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Get_Cb func);
+   EAPI void e_dbus_object_property_set_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Set_Cb func);
+
+
+/* sending method calls */
+
+
+   EAPI DBusPendingCall *e_dbus_message_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Method_Return_Cb cb_return, int timeout, void *data);
+
+   EAPI DBusPendingCall *e_dbus_method_call_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Unmarshal_Func unmarshal_func, E_DBus_Callback_Func cb_func, E_DBus_Free_Func free_func, int timeout, void *data);
+
+
+/* signal receiving */
+
+   EAPI E_DBus_Signal_Handler *e_dbus_signal_handler_add(E_DBus_Connection *conn, const char *sender, const char *path, const char *interface, const char *member, E_DBus_Signal_Cb cb_signal, void *data);
+   EAPI void e_dbus_signal_handler_del(E_DBus_Connection *conn, E_DBus_Signal_Handler *sh);
+
+/* standard dbus method calls */
+
+   EAPI void e_dbus_request_name(E_DBus_Connection *conn, const char *name, 
+                                 unsigned int flags,
+                                 E_DBus_Method_Return_Cb cb_return,
+                                 void *data);
+   EAPI void e_dbus_release_name(E_DBus_Connection *conn, const char *name,
+                                 E_DBus_Method_Return_Cb cb_return,
+                                 void *data);
+
+   EAPI void e_dbus_get_name_owner(E_DBus_Connection *conn, const char *name,
+                                   E_DBus_Method_Return_Cb cb_return,
+                                   void *data);
+   EAPI void e_dbus_list_names(E_DBus_Connection *conn,
+                               E_DBus_Method_Return_Cb cb_return,
+                               void *data);
+   EAPI void e_dbus_list_activatable_names(E_DBus_Connection *conn,
+                                           E_DBus_Method_Return_Cb cb_return,
+                                           void *data);
+   EAPI void e_dbus_name_has_owner(E_DBus_Connection *conn, const char *name,
+                                   E_DBus_Method_Return_Cb cb_return,
+                                   void *data);
+   EAPI void e_dbus_start_service_by_name(E_DBus_Connection *conn, const char *name,
+                                          E_DBus_Method_Return_Cb cb_return,
+                                          void *data);
+
+/* standard methods calls on objects */
+   EAPI void e_dbus_peer_ping(E_DBus_Connection *conn, const char *destination,
+                              const char *path, E_DBus_Method_Return_Cb cb_return,
+                              void *data);
+   EAPI void e_dbus_peer_get_machine_id(E_DBus_Connection *conn,
+                                        const char *destination, const char *path,
+                                        E_DBus_Method_Return_Cb cb_return,
+                                        void *data);
+   EAPI void e_dbus_properties_get(E_DBus_Connection *conn, const char *destination,
+                                   const char *path, const char *interface,
+                                   const char *property,
+                                   E_DBus_Method_Return_Cb cb_return,
+                                   void *data);
+   EAPI void e_dbus_properties_set(E_DBus_Connection *conn, const char *destination,
+                                   const char *path, const char *interface,
+                                   const char *property, int value_type,
+                                   void *value, E_DBus_Method_Return_Cb cb_return,
+                                   void *data);
+
+
+   EAPI E_DBus_Callback *e_dbus_callback_new(E_DBus_Callback_Func cb_func, E_DBus_Unmarshal_Func unmarshal_func, E_DBus_Free_Func free_func, void *user_data);
+
+   EAPI void e_dbus_callback_free(E_DBus_Callback *callback);
+   EAPI void e_dbus_callback_call(E_DBus_Callback *cb, void *data, DBusError *error);
+   EAPI void *e_dbus_callback_unmarshal(E_DBus_Callback *cb, DBusMessage *msg, DBusError *err);
+   EAPI void e_dbus_callback_return_free(E_DBus_Callback *callback, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/dbus/Makefile.am b/src/lib/dbus/Makefile.am
new file mode 100644 (file)
index 0000000..ae69d41
--- /dev/null
@@ -0,0 +1,23 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+@EDBUS_CFLAGS@
+
+lib_LTLIBRARIES = libedbus.la
+include_HEADERS = E_DBus.h
+
+libedbus_la_SOURCES = \
+       e_dbus_private.h \
+       e_dbus.c \
+       e_dbus_message.c \
+       e_dbus_methods.c \
+       e_dbus_interfaces.c \
+       e_dbus_object.c \
+       e_dbus_util.c \
+       e_dbus_signal.c
+
+
+libedbus_la_LIBADD = \
+@EDBUS_LIBS@
+libedbus_la_LDFLAGS      = -version-info @version_info@
+
diff --git a/src/lib/dbus/e_dbus.c b/src/lib/dbus/e_dbus.c
new file mode 100644 (file)
index 0000000..eefbf31
--- /dev/null
@@ -0,0 +1,586 @@
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+
+#include <stdbool.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <Ecore.h>
+#include <Ecore_Data.h>
+
+#define NUM_BUS_TYPES 3
+
+/*
+ * TODO: 
+ *  listen for disconnected signal and clean up?
+ *  listen for NameOwnerChanged signals for names we have SignalHandler's for
+ *    remap SH to listen for signals from new owner
+ */
+
+static int connection_slot = -1;
+
+static int init = 0;
+EAPI int E_DBUS_EVENT_SIGNAL = 0;
+
+static E_DBus_Connection *shared_connections[2] = {NULL, NULL};
+
+typedef struct E_DBus_Handler_Data E_DBus_Handler_Data;
+typedef struct E_DBus_Timeout_Data E_DBus_Timeout_Data;
+
+
+struct E_DBus_Handler_Data
+{
+  int fd;
+  Ecore_Fd_Handler *fd_handler;
+  E_DBus_Connection *cd;
+  DBusWatch *watch;
+  int enabled;
+};
+
+struct E_DBus_Timeout_Data
+{
+  Ecore_Timer *handler;
+  DBusTimeout *timeout;
+  E_DBus_Connection *cd;
+  int interval;
+};
+
+static int e_dbus_idler(void *data);
+
+static int
+e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler)
+{
+  E_DBus_Handler_Data *hd;
+  DBusConnection *conn;
+  unsigned int condition = 0;
+
+  DEBUG(5, "fd handler (%ld)!\n", (long int)fd_handler);
+
+  hd = data;
+
+  if (!hd->enabled) {
+    DEBUG(5, "handler disabled\n");
+    if (hd->fd_handler) ecore_main_fd_handler_del(hd->fd_handler);
+    hd->fd_handler = NULL;
+    return 0;
+  }
+
+  conn = hd->cd->conn;
+
+  if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) condition |= DBUS_WATCH_READABLE;
+  if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) condition |= DBUS_WATCH_WRITABLE;
+  if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) condition |= DBUS_WATCH_ERROR;
+
+  if (condition & DBUS_WATCH_ERROR) DEBUG(5, "DBUS watch error\n");
+  dbus_watch_handle(hd->watch, condition);
+  hd = NULL;
+
+  return 1;
+}
+
+
+static void
+e_dbus_fd_handler_add(E_DBus_Handler_Data *hd)
+{
+  unsigned int dflags;
+  Ecore_Fd_Handler_Flags eflags;
+
+  if (hd->fd_handler) return;
+  DEBUG(5, "fd handler add (%d)\n", hd->fd);
+
+  dflags = dbus_watch_get_flags(hd->watch);
+  eflags = ECORE_FD_ERROR;
+  if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ;
+  if (dflags & DBUS_WATCH_WRITABLE) eflags |= ECORE_FD_WRITE;
+
+
+  hd->fd_handler = ecore_main_fd_handler_add(hd->fd,
+                                             eflags,
+                                             e_dbus_fd_handler,
+                                             hd,
+                                             NULL,
+                                             NULL);
+
+  ecore_list_append(hd->cd->fd_handlers, hd->fd_handler);
+}
+
+
+static void
+e_dbus_handler_data_free(void *data)
+{
+  E_DBus_Handler_Data *hd = data;
+  
+  DEBUG(5, "e_dbus_handler_data_free\n");
+  if (hd->fd_handler)
+  {
+    if (ecore_list_goto(hd->cd->fd_handlers, hd->fd_handler))
+      ecore_list_remove(hd->cd->fd_handlers);
+    ecore_main_fd_handler_del(hd->fd_handler);
+  }
+  free(hd);
+}
+
+static void
+e_dbus_connection_data_watch_add(E_DBus_Connection *cd, DBusWatch *watch)
+{
+  E_DBus_Handler_Data *hd;
+
+  hd = calloc(1, sizeof(E_DBus_Handler_Data));
+  dbus_watch_set_data(watch, hd, e_dbus_handler_data_free);
+  hd->cd = cd;
+  hd->watch = watch;
+
+  hd->enabled = dbus_watch_get_enabled(watch);
+  hd->fd = dbus_watch_get_fd(hd->watch);
+  DEBUG(5, "watch add (enabled: %d)\n", hd->enabled);
+  if (hd->enabled) e_dbus_fd_handler_add(hd);
+}
+
+static E_DBus_Connection *
+e_dbus_connection_new(DBusConnection *conn)
+{
+  E_DBus_Connection *cd;
+  const char *conn_name;
+
+  cd = calloc(1, sizeof(E_DBus_Connection));
+  if (!cd) return NULL;
+
+  cd->conn = conn;
+  conn_name = dbus_bus_get_unique_name(conn);
+  if (conn_name)
+  {
+    DEBUG(1, "Connected! Name: %s\n", conn_name);
+    cd->conn_name = strdup(conn_name);
+  }
+  else
+    DEBUG(1, "Not connected\n");
+
+  cd->shared_type = -1;
+  cd->fd_handlers = ecore_list_new();
+  cd->timeouts = ecore_list_new();
+
+  return cd;
+}
+
+static void
+e_dbus_connection_free(void *data)
+{
+  E_DBus_Connection *cd = data;
+  Ecore_Fd_Handler *fd_handler;
+  Ecore_Timer *timer;
+  DEBUG(5, "e_dbus_connection free!\n");
+
+  ecore_list_first_goto(cd->fd_handlers);
+  while ((fd_handler = ecore_list_next(cd->fd_handlers)))
+    ecore_main_fd_handler_del(fd_handler);
+  ecore_list_destroy(cd->fd_handlers);
+
+  ecore_list_first_goto(cd->timeouts);
+  while ((timer = ecore_list_next(cd->timeouts)))
+    ecore_timer_del(timer);
+  ecore_list_destroy(cd->timeouts);
+
+  if (cd->shared_type != -1)
+    shared_connections[cd->shared_type] = NULL;
+
+  if (cd->conn_name) free(cd->conn_name);
+
+  free(cd);
+}
+
+
+static void
+cb_main_wakeup(void *data)
+{
+  E_DBus_Connection *cd;
+  DEBUG(5, "wakeup main!\n");
+
+  cd = data;
+
+  if (!cd->idler) cd->idler = ecore_idler_add(e_dbus_idler, cd);
+  else DEBUG(1, "already idling\n");
+}
+
+static void
+cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *data)
+{
+  E_DBus_Connection *cd;
+
+  DEBUG(5, "dispatch status: %d!\n", new_status);
+  cd = data;
+
+  if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler) cd->idler = ecore_idler_add(e_dbus_idler, cd);
+
+  else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler) 
+  {
+    ecore_idler_del(cd->idler);
+    cd->idler = NULL;
+  }
+}
+
+static int
+e_dbus_timeout_handler(void *data)
+{
+  E_DBus_Timeout_Data *td;
+
+  td = data;
+
+  if (dbus_timeout_get_enabled(td->timeout)) 
+  {
+    DEBUG(5, "timeout_handler (not enabled, ending)\n");
+    td->handler = NULL;
+    return 0;
+  }
+
+  DEBUG(5, "timeout handler!\n");
+  dbus_timeout_handle(td->timeout);
+  return 1;
+}
+
+static void
+e_dbus_timeout_data_free(void *timeout_data)
+{
+  E_DBus_Timeout_Data *td = timeout_data;
+  DEBUG(5, "e_dbus_timeout_data_free\n");
+  if (td->handler) ecore_timer_del(td->handler);
+  free(td);
+}
+
+static dbus_bool_t 
+cb_timeout_add(DBusTimeout *timeout, void *data)
+{
+  E_DBus_Connection *cd;
+  E_DBus_Timeout_Data *td;
+  
+  cd = data;
+  DEBUG(5, "timeout add!\n");
+  td = calloc(1, sizeof(E_DBus_Timeout_Data));
+  td->cd = cd;
+  dbus_timeout_set_data(timeout, (void *)td, e_dbus_timeout_data_free);
+
+  td->interval = dbus_timeout_get_interval(timeout);
+  td->timeout = timeout;
+
+  if (dbus_timeout_get_enabled(timeout)) td->handler = ecore_timer_add(td->interval, e_dbus_timeout_handler, td);
+  ecore_list_append(td->cd->timeouts, td->handler);
+
+  return true;
+}
+
+static void
+cb_timeout_del(DBusTimeout *timeout, void *data)
+{
+  E_DBus_Timeout_Data *td;
+  DEBUG(5, "timeout del!\n");
+
+  td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout);
+
+  if (td->handler) 
+  {
+    if (ecore_list_goto(td->cd->timeouts, td->handler))
+      ecore_list_remove(td->cd->timeouts);
+    ecore_timer_del(td->handler);
+    td->handler = NULL;
+  }
+
+  /* Note: timeout data gets freed when the timeout itself is freed by dbus */
+}
+
+static void
+cb_timeout_toggle(DBusTimeout *timeout, void *data)
+{
+  E_DBus_Timeout_Data *td;
+  DEBUG(5, "timeout toggle!\n");
+
+  td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout);
+
+  if (dbus_timeout_get_enabled(td->timeout))
+  {
+    td->interval = dbus_timeout_get_interval(timeout);
+    td->handler = ecore_timer_add(td->interval, e_dbus_timeout_handler, td);
+  }
+  else
+  {
+    ecore_timer_del(td->handler);
+    td->handler = NULL;
+  }
+
+
+}
+
+static dbus_bool_t 
+cb_watch_add(DBusWatch *watch, void *data)
+{
+  E_DBus_Connection *cd;
+  cd = data;
+
+  DEBUG(5, "cb_watch_add\n");
+  e_dbus_connection_data_watch_add(cd, watch);
+
+  return true;
+}
+
+static void
+cb_watch_del(DBusWatch *watch, void *data)
+{
+  E_DBus_Connection *cd;
+  E_DBus_Handler_Data *hd;
+  cd = data;
+
+  DEBUG(5, "cb_watch_del\n");
+  hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch);
+
+  if (hd->fd_handler) 
+  {
+    if (ecore_list_goto(hd->cd->fd_handlers, hd->fd_handler))
+      ecore_list_remove(hd->cd->fd_handlers);
+    ecore_main_fd_handler_del(hd->fd_handler);
+    hd->fd_handler = NULL;
+  }
+}
+
+static void
+cb_watch_toggle(DBusWatch *watch, void *data)
+{
+  E_DBus_Handler_Data *hd;
+
+  DEBUG(5, "cb_watch_toggle\n");
+  hd = dbus_watch_get_data(watch);
+
+  if (!hd) return;
+
+  hd->enabled = dbus_watch_get_enabled(watch);
+
+  if (hd->enabled) e_dbus_fd_handler_add(hd);
+}
+
+static void
+e_dbus_message_free(void *data, void *message)
+{
+  dbus_message_unref(message);
+}
+
+static DBusHandlerResult
+e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data)
+{
+  DEBUG(3, "-----------------\nMessage!\n\n");
+
+  DEBUG(3, "type: %s\n", dbus_message_type_to_string(dbus_message_get_type(message)));
+  DEBUG(3, "path: %s\n", dbus_message_get_path(message));
+  DEBUG(3, "interface: %s\n", dbus_message_get_interface(message));
+  DEBUG(3, "member: %s\n", dbus_message_get_member(message));
+  DEBUG(3, "sender: %s\n", dbus_message_get_sender(message));
+
+  switch (dbus_message_get_type(message))
+  {
+    case DBUS_MESSAGE_TYPE_METHOD_CALL:
+      DEBUG(3, "signature: %s\n", dbus_message_get_signature(message));
+      break;
+    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
+      DEBUG(3, "reply serial %d\n", dbus_message_get_reply_serial(message));
+      break;
+    case DBUS_MESSAGE_TYPE_ERROR:
+      DEBUG(3, "error: %s\n", dbus_message_get_error_name(message));
+      break;
+    case DBUS_MESSAGE_TYPE_SIGNAL:
+      ecore_event_add(E_DBUS_EVENT_SIGNAL, dbus_message_ref(message),
+                      e_dbus_message_free, NULL);
+      /* don't need to handle signals, they're for everyone who wants them */
+      return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+      break;
+    default:
+      break;
+  }
+  DEBUG(3, "-----------------\n\n");
+
+  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+int e_dbus_idler_active = 0;
+
+static int
+e_dbus_idler(void *data)
+{
+  E_DBus_Connection *cd;
+  cd = data;
+
+  if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn))
+  {
+    DEBUG(5, "done dispatching!\n");
+    cd->idler = NULL;
+    return 0;
+  }
+  e_dbus_idler_active++;
+  dbus_connection_ref(cd->conn);
+  DEBUG(5, "dispatch!\n");
+  dbus_connection_dispatch(cd->conn);
+  dbus_connection_unref(cd->conn);
+  e_dbus_signal_handlers_clean(cd);
+  e_dbus_idler_active--;
+  return 1;
+}
+
+/**
+ * Retrieve a connection to the bus and integrate it with the ecore main loop.
+ * @param type the type of bus to connect to, e.g. DBUS_BUS_SYSTEM or DBUS_BUS_SESSION
+ */
+EAPI E_DBus_Connection *
+e_dbus_bus_get(DBusBusType type)
+{
+  DBusError err;
+  E_DBus_Connection *econn;
+  DBusConnection *conn;
+
+  /* each app only needs a single connection to either bus */
+  if (type == DBUS_BUS_SYSTEM || type == DBUS_BUS_SESSION)
+  {
+    if (shared_connections[type]) 
+    {
+      e_dbus_connection_ref(shared_connections[type]);
+      return shared_connections[type];
+    }
+  }
+
+  dbus_error_init(&err);
+
+  conn = dbus_bus_get_private(type, &err);
+  if (dbus_error_is_set(&err))
+  {
+    fprintf(stderr, "Error connecting to bus: %s\n", err.message);
+    dbus_error_free(&err);
+    return NULL;
+  }
+
+  econn = e_dbus_connection_setup(conn);
+  if (!econn)
+  {
+    fprintf(stderr, "Error setting up dbus connection.\n");
+    dbus_connection_close(conn);
+    dbus_connection_unref(conn);
+    return NULL;
+  }
+
+  if (type == DBUS_BUS_SYSTEM || type == DBUS_BUS_SESSION)
+  {
+    econn->shared_type = type;
+    shared_connections[type] = econn;
+  }
+  dbus_error_free(&err);
+  e_dbus_connection_ref(econn);
+  return econn;
+}
+
+/**
+ * Integrate a DBus connection with the ecore main loop
+ *
+ * @param conn - a dbus connection
+ */
+EAPI E_DBus_Connection *
+e_dbus_connection_setup(DBusConnection *conn)
+{
+  E_DBus_Connection *cd;
+
+  cd = e_dbus_connection_new(conn);
+  if (!cd) return NULL;
+
+  /* connection_setup */
+  dbus_connection_set_exit_on_disconnect(cd->conn, FALSE);
+  dbus_connection_allocate_data_slot(&connection_slot);
+
+  dbus_connection_set_data(cd->conn, connection_slot, (void *)cd, e_dbus_connection_free);
+  dbus_connection_set_watch_functions(cd->conn,
+                                      cb_watch_add,
+                                      cb_watch_del,
+                                      cb_watch_toggle,
+                                      cd,
+                                      NULL);
+
+  dbus_connection_set_timeout_functions(cd->conn,
+                                      cb_timeout_add,
+                                      cb_timeout_del,
+                                      cb_timeout_toggle,
+                                      cd,
+                                      NULL);
+
+  dbus_connection_set_wakeup_main_function(cd->conn, cb_main_wakeup, cd, NULL);
+  dbus_connection_set_dispatch_status_function(cd->conn, cb_dispatch_status, cd, NULL);
+  dbus_connection_add_filter(cd->conn, e_dbus_filter, NULL, NULL);
+
+  cb_dispatch_status(cd->conn, dbus_connection_get_dispatch_status(cd->conn), cd);
+
+  return cd;
+}
+
+
+/**
+ * Close out a connection retrieved with e_dbus_bus_get()
+ * @param conn the connection to close
+ */
+EAPI void
+e_dbus_connection_close(E_DBus_Connection *conn)
+{
+  DEBUG(5, "e_dbus_connection_close\n");
+
+  if (--(conn->refcount) != 0) return;
+
+  dbus_connection_free_data_slot(&connection_slot);
+  dbus_connection_remove_filter(conn->conn, e_dbus_filter, NULL);
+  dbus_connection_set_watch_functions (conn->conn,
+                                       NULL,
+                                       NULL,
+                                       NULL,
+                                       NULL, NULL);
+
+  dbus_connection_set_timeout_functions (conn->conn,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         NULL, NULL);
+
+  dbus_connection_set_dispatch_status_function (conn->conn, NULL, NULL, NULL);
+
+  dbus_connection_close(conn->conn);
+  dbus_connection_unref(conn->conn);
+
+  // Note: the E_DBus_Connection gets freed when the dbus_connection is cleaned up by the previous unref
+}
+
+EAPI void
+e_dbus_connection_ref(E_DBus_Connection *conn)
+{
+  conn->refcount++;
+}
+
+DBusConnection *
+e_dbus_connection_dbus_connection_get(E_DBus_Connection *conn)
+{
+  return conn->conn;
+}
+
+/**
+ * @brief Initialize e_dbus
+ */
+EAPI int
+e_dbus_init(void)
+{
+  if (++init != 1) return init;
+
+  E_DBUS_EVENT_SIGNAL = ecore_event_type_new();
+  e_dbus_signal_init();
+  e_dbus_object_init();
+  return init;
+}
+
+/**
+ * Shutdown e_dbus.
+ */
+EAPI int
+e_dbus_shutdown(void)
+{
+  if (--init) return init;
+  e_dbus_object_shutdown();
+  e_dbus_signal_shutdown();
+  return init;
+}
diff --git a/src/lib/dbus/e_dbus_interfaces.c b/src/lib/dbus/e_dbus_interfaces.c
new file mode 100644 (file)
index 0000000..772543b
--- /dev/null
@@ -0,0 +1,107 @@
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+
+/**
+ * This file contains wrappers around the standard interfaces that
+ * objects on the bus should implement.
+ */
+
+/**
+ * Ping the dbus peer
+ *
+ * @param conn the dbus connection
+ * @param destination the bus name that the object is on
+ * @param path the object path
+ * @param cb_return a callback for a successful return
+ * @param data data to pass to the callbacks
+ */
+EAPI void
+e_dbus_peer_ping(E_DBus_Connection*conn, const char *destination, const char *path, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call(destination, path, "org.freedesktop.DBus.Peer", "Ping");
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+/**
+ * Get the UUID of the peer
+ *
+ * @param conn the dbus connection
+ * @param destination the bus name that the object is on
+ * @param path the object path
+ * @param cb_return a callback for a successful return
+ * @param data data to pass to the callbacks
+ */
+EAPI void
+e_dbus_peer_get_machine_id(E_DBus_Connection*conn, const char *destination, const char *path, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call(destination, path, "org.freedesktop.DBus.Peer", "GetMachineId");
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+/**
+ * Get the value of a property on an object
+ *
+ * @param conn the dbus connection
+ * @param destination the bus name that the object is on
+ * @param path the object path
+ * @param interface the interface name of the property
+ * @param property the name of the property
+ * @param cb_return a callback for a successful return
+ * @param data data to pass to the callbacks
+ */
+EAPI void
+e_dbus_properties_get(E_DBus_Connection*conn, const char *destination, const char *path, const char *interface, const char *property, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call(destination, path, "org.freedesktop.DBus.Properties", "Get");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+/**
+ * Set the value of a property on an object
+ *
+ * @param conn the dbus connection
+ * @param destination the bus name that the object is on
+ * @param path the object path
+ * @param interface the interface name of the property
+ * @param property the name of the property
+ * @param value_type the type of the property's value
+ * @param value a pointer to the value
+ * @param cb_return a callback for a successful return
+ * @param data data to pass to the callbacks
+ */
+EAPI void
+e_dbus_properties_set(E_DBus_Connection*conn, const char *destination, const char *path, const char *interface, const char *property, int value_type, void *value, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+  DBusMessageIter iter, sub;
+  DBusError err;
+
+  if (!dbus_type_is_basic(value_type)) 
+  {
+    if (cb_return)
+    {
+      dbus_error_init(&err);
+      dbus_set_error(&err, "org.enlightenment.DBus.InvalidType", "Only basic types may be set using e_dbus_properties_set()");
+      cb_return(data, NULL, &err);
+
+    }
+    return;
+  }
+
+  msg = dbus_message_new_method_call(destination, path, "org.freedesktop.DBus.Properties", "Set");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
+
+  dbus_message_iter_init_append(msg, &iter);
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, dbus_message_type_to_string(value_type), &sub);
+  dbus_message_iter_append_basic(&sub, value_type, &value);
+  dbus_message_iter_close_container(&iter, &sub);
+
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
diff --git a/src/lib/dbus/e_dbus_message.c b/src/lib/dbus/e_dbus_message.c
new file mode 100644 (file)
index 0000000..68bfc47
--- /dev/null
@@ -0,0 +1,116 @@
+#include <stdlib.h>
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+
+typedef struct E_DBus_Pending_Call_Data E_DBus_Pending_Call_Data;
+struct E_DBus_Pending_Call_Data
+{
+  int                     serial;
+
+  E_DBus_Method_Return_Cb cb_return;
+  void                   *data;
+};
+
+static void
+cb_pending(DBusPendingCall *pending, void *user_data)
+{
+  DBusMessage *msg;
+  DBusError err;
+  E_DBus_Pending_Call_Data *data = user_data;
+
+  if (!dbus_pending_call_get_completed(pending))
+  {
+    printf("NOT COMPLETED\n");
+    return;
+  }
+
+  dbus_error_init(&err);
+  msg = dbus_pending_call_steal_reply(pending);
+  if (!msg)
+  {
+    if (data->cb_return)
+    {
+      dbus_set_error(&err, "org.enlightenment.DBus.NoReply", "There was no reply to this method call.");
+      data->cb_return(data->data, NULL, &err);
+      dbus_error_free(&err);
+    }
+    return;
+  }
+
+  if (dbus_set_error_from_message(&err, msg))
+  {
+    if (data->cb_return)
+      data->cb_return(data->data, NULL, &err);
+    dbus_error_free(&err);
+  }
+  else
+  {
+    if (data->cb_return)
+      data->cb_return(data->data, msg, &err);
+  }
+
+  dbus_message_unref(msg);
+  dbus_pending_call_unref(pending);
+}
+
+
+/**
+ * @brief Send a DBus message with callbacks
+ * @param conn The DBus connection
+ * @param msg  The message to send
+ * @param cb_return A callback function for returns (only used if @a msg is a method-call)
+ * @param timeout   A timeout in milliseconds, after which a synthetic error will be generated
+ * @return a DBusPendingCall that can be used to cancel the current call
+ */
+EAPI DBusPendingCall *
+e_dbus_message_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Method_Return_Cb cb_return, int timeout, void *data)
+{
+  DBusPendingCall *pending;
+
+  if (!dbus_connection_send_with_reply(conn->conn, msg, &pending, timeout))
+    return NULL;
+
+  if (cb_return)
+  {
+    E_DBus_Pending_Call_Data *pdata;
+
+    pdata = calloc(1, sizeof(E_DBus_Pending_Call_Data));
+    pdata->cb_return = cb_return;
+    pdata->data = data;
+
+    dbus_pending_call_set_notify(pending, cb_pending, pdata, free);
+  }
+
+  return pending;
+}
+
+static void
+cb_method_call(void *data, DBusMessage *msg, DBusError *err)
+{
+  E_DBus_Callback *cb = data;
+  void *method_return = NULL;
+  DBusError new_err;
+  if (!cb) return;
+
+  dbus_error_init(&new_err);
+  if (!dbus_error_is_set(err))
+    method_return = e_dbus_callback_unmarshal(cb, msg, &new_err);
+  else
+    dbus_move_error(err, &new_err);
+
+  e_dbus_callback_call(cb, method_return, &new_err);
+  e_dbus_callback_return_free(cb, method_return);
+
+  if (dbus_error_is_set(&new_err))
+    dbus_error_free(&new_err);
+
+  e_dbus_callback_free(cb);
+}
+
+EAPI DBusPendingCall *
+e_dbus_method_call_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Unmarshal_Func unmarshal_func, E_DBus_Callback_Func cb_func, E_DBus_Free_Func free_func, int timeout, void *data)
+{
+  E_DBus_Callback *cb;
+  cb = e_dbus_callback_new(cb_func, unmarshal_func, free_func, data);
+  return e_dbus_message_send(conn, msg, cb_method_call, timeout, cb);
+}
diff --git a/src/lib/dbus/e_dbus_methods.c b/src/lib/dbus/e_dbus_methods.c
new file mode 100644 (file)
index 0000000..1b3b71f
--- /dev/null
@@ -0,0 +1,76 @@
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+
+EAPI void
+e_dbus_request_name(E_DBus_Connection *conn, const char *name, unsigned int flags, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+  dbus_uint32_t u_flags;
+
+  u_flags = flags;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_UINT32, &u_flags, DBUS_TYPE_INVALID);
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+EAPI void
+e_dbus_release_name(E_DBus_Connection *conn, const char *name, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ReleaseName");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+
+EAPI void
+e_dbus_get_name_owner(E_DBus_Connection *conn, const char *name, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetNameOwner");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+EAPI void
+e_dbus_list_names(E_DBus_Connection *conn, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames");
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+
+EAPI void
+e_dbus_list_activatable_names(E_DBus_Connection *conn, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListActivatableNames");
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+EAPI void
+e_dbus_name_has_owner(E_DBus_Connection *conn, const char *name, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameHasOwner");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
+
+
+EAPI void
+e_dbus_start_service_by_name(E_DBus_Connection *conn, const char *name, E_DBus_Method_Return_Cb cb_return, void *data)
+{
+  DBusMessage *msg;
+
+  msg = dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "StartServiceByName");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
+  e_dbus_message_send(conn, msg, cb_return, -1, data);
+}
diff --git a/src/lib/dbus/e_dbus_object.c b/src/lib/dbus/e_dbus_object.c
new file mode 100644 (file)
index 0000000..ea2c926
--- /dev/null
@@ -0,0 +1,572 @@
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+#include <Ecore_Data.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static E_DBus_Interface *introspectable_interface = NULL;
+static E_DBus_Interface *properties_interface = NULL;
+
+typedef struct E_DBus_Method E_DBus_Method;
+
+Ecore_Strbuf * e_dbus_object_introspect(E_DBus_Object *obj);
+
+static void e_dbus_object_unregister(DBusConnection *conn, void *user_data);
+static DBusHandlerResult e_dbus_object_handler(DBusConnection *conn, DBusMessage *message, void *user_data);
+
+static void e_dbus_interface_free(E_DBus_Interface *iface);
+
+static E_DBus_Method *e_dbus_method_new(const char *member, const char *signature, const char *reply_signature, E_DBus_Method_Cb func);
+static void e_dbus_object_method_free(E_DBus_Method *m);
+
+static void _introspect_indent_append(Ecore_Strbuf *buf, int level);
+static void _introspect_interface_append(Ecore_Strbuf *buf, E_DBus_Interface *iface, int level);
+static void _introspect_method_append(Ecore_Strbuf *buf, E_DBus_Method *method, int level);
+static void _introspect_arg_append(Ecore_Strbuf *buf, const char *type, const char *direction, int level);
+
+
+//static Ecore_List *standard_methods = NULL;
+
+
+static DBusObjectPathVTable vtable = {
+  e_dbus_object_unregister,
+  e_dbus_object_handler,
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
+
+struct E_DBus_Object
+{
+  E_DBus_Connection *conn;
+  char *path;
+  Ecore_List *interfaces;
+  char *introspection_data;
+  int introspection_dirty;
+
+  E_DBus_Object_Property_Get_Cb cb_property_get;
+  E_DBus_Object_Property_Set_Cb cb_property_set;
+
+  void *data;
+};
+
+struct E_DBus_Interface
+{
+  char *name;
+  Ecore_List *methods;
+  int refcount;
+};
+
+struct E_DBus_Method
+{
+  char *member;
+  char *signature;
+  char *reply_signature;
+  E_DBus_Method_Cb func;
+};
+
+static DBusMessage *
+cb_introspect(E_DBus_Object *obj, DBusMessage *msg)
+{
+  DBusMessage *ret;
+  Ecore_Strbuf *buf;
+
+  if (obj->introspection_dirty || !obj->introspection_data)
+  {
+    buf = e_dbus_object_introspect(obj);
+    if (!buf)
+    {
+      ret = dbus_message_new_error(msg, "org.enlightenment.NotIntrospectable", "This object does not provide introspection data");
+      return ret;
+    }
+
+    if (obj->introspection_data) free(obj->introspection_data);
+    obj->introspection_data = strdup(ecore_strbuf_string_get(buf));
+    ecore_strbuf_free(buf);
+  }
+  //printf("XML: \n\n%s\n\n", obj->introspection_data);
+  ret = dbus_message_new_method_return(msg);
+  dbus_message_append_args(ret, DBUS_TYPE_STRING, &(obj->introspection_data), DBUS_TYPE_INVALID);
+
+  return ret;
+}
+
+static DBusMessage *
+cb_properties_get(E_DBus_Object *obj, DBusMessage *msg)
+{
+  DBusMessage *reply;
+  DBusMessageIter iter, sub;
+  DBusError err;
+  int type;
+  void *value;
+  char *property;
+
+  dbus_error_init(&err);
+  dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
+
+  if (dbus_error_is_set(&err))
+  {
+    return dbus_message_new_error(msg, err.name, err.message);
+  }
+
+  obj->cb_property_get(obj, property, &type, &value);
+  if (type == DBUS_TYPE_INVALID)
+  {
+    return dbus_message_new_error_printf(msg, "org.enlightenment.DBus.InvalidProperty", "The property '%s' does not exist on this object.", property);
+  }
+
+  if (dbus_type_is_basic(type))
+  {
+    reply = dbus_message_new_method_return(msg);
+    dbus_message_iter_init_append(msg, &iter);
+    dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, e_dbus_basic_type_as_string(type), &sub);
+    dbus_message_iter_append_basic(&sub, type, &value);
+    dbus_message_iter_close_container(&iter, &sub);
+    return reply;
+  }
+  else
+  {
+    return dbus_message_new_error(msg, "org.enlightenment.DBus.UnsupportedType", "E_DBus currently only supports properties of a basic type.");
+  }
+}
+
+static DBusMessage *
+cb_properties_set(E_DBus_Object *obj, DBusMessage *msg)
+{
+  DBusMessageIter iter, sub;
+  int type;
+  void *value;
+  char *property;
+
+  dbus_message_iter_init(msg, &iter);
+  dbus_message_iter_get_basic(&iter, &property);
+  dbus_message_iter_recurse(&iter, &sub);
+  type = dbus_message_iter_get_arg_type(&sub);
+  if (dbus_type_is_basic(type))
+  {
+    dbus_message_iter_get_basic(&sub, &value);
+    if (obj->cb_property_set(obj, property, type, value))
+    {
+      return dbus_message_new_method_return(msg);
+    }
+    else
+    {
+      return dbus_message_new_error_printf(msg, "org.enlightenment.DBus.InvalidProperty", "The property '%s' does not exist on this object.", property);
+    }
+  }
+  else
+  {
+    return dbus_message_new_error(msg, "org.enlightenment.DBus.UnsupportedType", "E_DBus currently only supports properties of a basic type.");
+  }
+
+}
+
+int
+e_dbus_object_init(void)
+{
+  introspectable_interface = e_dbus_interface_new("org.freedesktop.DBus.Introspectable");
+  properties_interface = e_dbus_interface_new("org.freedesktop.DBus.Properties");
+  if (!introspectable_interface || !properties_interface)
+  {
+    if (introspectable_interface) e_dbus_interface_unref(introspectable_interface);
+    introspectable_interface = NULL;
+    if (properties_interface) e_dbus_interface_unref(properties_interface);
+    properties_interface = NULL;
+    return 0;
+  }
+
+  e_dbus_interface_method_add(introspectable_interface, "Introspect", "", "s", cb_introspect);
+  e_dbus_interface_method_add(properties_interface, "Get", "s", "v", cb_properties_get);
+  e_dbus_interface_method_add(properties_interface, "Set", "sv", "", cb_properties_set);
+  return 1;
+}
+
+void
+e_dbus_object_shutdown(void)
+{
+  e_dbus_interface_unref(introspectable_interface);
+  introspectable_interface = NULL;
+
+  e_dbus_interface_unref(properties_interface);
+  properties_interface = NULL;
+}
+
+/**
+ * Add a dbus object.
+ *
+ * @param conn the connection on with the object should listen
+ * @param object_path a unique string identifying an object (e.g. org/enlightenment/WindowManager
+ * @param data custom data to set on the object (retrievable via
+ *             e_dbus_object_data_get())
+ */
+EAPI E_DBus_Object *
+e_dbus_object_add(E_DBus_Connection *conn, const char *object_path, void *data)
+{
+  E_DBus_Object *obj;
+
+  obj = calloc(1, sizeof(E_DBus_Object));
+  if (!obj) return NULL;
+
+  if (!dbus_connection_register_object_path(conn->conn, object_path, &vtable, obj))
+  {
+    free(obj);
+    return NULL;
+  }
+
+  obj->conn = conn;
+  e_dbus_connection_ref(conn);
+  obj->path = strdup(object_path);
+  obj->data = data;
+  obj->interfaces = ecore_list_new();
+  ecore_list_free_cb_set(obj->interfaces, (Ecore_Free_Cb)e_dbus_interface_unref);
+
+  e_dbus_object_interface_attach(obj, introspectable_interface);
+
+  return obj;
+}
+
+/**
+ * Free a dbus object
+ *
+ * @param obj the object to free
+ */
+EAPI void
+e_dbus_object_free(E_DBus_Object *obj)
+{
+  if (!obj) return;
+
+  DEBUG(5, "e_dbus_object_free (%s)\n", obj->path);
+  dbus_connection_unregister_object_path(obj->conn->conn, obj->path);
+  e_dbus_connection_close(obj->conn);
+
+  if (obj->path) free(obj->path);
+  ecore_list_destroy(obj->interfaces);
+  if (obj->introspection_data) free(obj->introspection_data);
+
+  free(obj);
+}
+
+/**
+ * @brief Fetch the data pointer for a dbus object
+ * @param obj the dbus object
+ */
+EAPI void *
+e_dbus_object_data_get(E_DBus_Object *obj)
+{
+  return obj->data;
+}
+
+/**
+ * @brief Sets the callback to fetch properties from an object
+ * @param obj the object
+ * @param func the callback
+ */
+EAPI void
+e_dbus_object_property_get_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Get_Cb func)
+{
+  obj->cb_property_get = func;
+}
+
+/**
+ * @brief Sets the callback to set properties on an object
+ * @param obj the object
+ * @param func the callback
+ */
+EAPI void
+e_dbus_object_property_set_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Set_Cb func)
+{
+  obj->cb_property_set = func;
+}
+
+EAPI void
+e_dbus_object_interface_attach(E_DBus_Object *obj, E_DBus_Interface *iface)
+{
+  e_dbus_interface_ref(iface);
+  ecore_list_append(obj->interfaces, iface);
+  obj->introspection_dirty = 1;
+  DEBUG(4, "e_dbus_object_interface_attach (%s, %s) ", obj->path, iface->name);
+}
+
+EAPI void
+e_dbus_object_interface_detach(E_DBus_Object *obj, E_DBus_Interface *iface)
+{
+  E_DBus_Interface *found;
+
+  DEBUG(4, "e_dbus_object_interface_detach (%s, %s) ", obj->path, iface->name);
+  found = ecore_list_goto(obj->interfaces, iface);
+  if (found == NULL) return;
+
+  ecore_list_remove(obj->interfaces);
+  obj->introspection_dirty = 1;
+  e_dbus_interface_unref(iface);
+}
+
+EAPI void
+e_dbus_interface_ref(E_DBus_Interface *iface)
+{
+  iface->refcount++;
+  DEBUG(4, "e_dbus_interface_ref (%s) = %d\n", iface->name, iface->refcount);
+}
+
+EAPI void
+e_dbus_interface_unref(E_DBus_Interface *iface)
+{
+  DEBUG(4, "e_dbus_interface_unref (%s) = %d\n", iface->name, iface->refcount - 1);
+  if (--(iface->refcount) == 0)
+    e_dbus_interface_free(iface);
+}
+
+static void
+e_dbus_interface_free(E_DBus_Interface *iface)
+{
+  if (iface->name) free(iface->name);
+  if (iface->methods) ecore_list_destroy(iface->methods);
+  free(iface);
+}
+
+
+/**
+ * Add a method to an object
+ *
+ * @param iface the E_DBus_Interface to which this method belongs
+ * @param member the name of the method
+ * @param signature  an optional message signature. if provided, then messages
+ *                   with invalid signatures will be automatically rejected 
+ *                   (an Error response will be sent) and introspection data
+ *                   will be available.
+ *
+ * @return 1 if successful, 0 if failed (e.g. no memory)
+ */
+EAPI int
+e_dbus_interface_method_add(E_DBus_Interface *iface, const char *member, const char *signature, const char *reply_signature, E_DBus_Method_Cb func)
+{
+  E_DBus_Method *m;
+
+  m = e_dbus_method_new(member, signature, reply_signature, func);
+  DEBUG(4, "Add method %s: %p\n", member, m);
+  if (!m) return 0;
+
+  ecore_list_append(iface->methods, m);
+  return 1;
+}
+
+EAPI E_DBus_Interface *
+e_dbus_interface_new(const char *interface)
+{
+  E_DBus_Interface *iface;
+
+  if (!interface) return NULL;
+
+  iface = calloc(1, sizeof(E_DBus_Interface));
+  if (!iface) return NULL;
+
+  iface->refcount = 1;
+  iface->name = strdup(interface);
+  iface->methods = ecore_list_new();
+  ecore_list_free_cb_set(iface->methods, (Ecore_Free_Cb)e_dbus_object_method_free);
+
+  return iface;
+}
+
+static E_DBus_Method *
+e_dbus_method_new(const char *member, const char *signature, const char *reply_signature, E_DBus_Method_Cb func)
+{
+  E_DBus_Method *m;
+
+  if (!member || !func) return NULL;
+
+  if (signature && !dbus_signature_validate(signature, NULL)) return NULL;
+  if (reply_signature && !dbus_signature_validate(reply_signature, NULL)) return NULL;
+  m = calloc(1, sizeof(E_DBus_Method));
+  if (!m) return NULL;
+
+  m->member = strdup(member);
+  if (signature)
+    m->signature = strdup(signature);
+  if (reply_signature)
+    m->reply_signature = strdup(reply_signature);
+  m->func = func;
+
+  return m;
+}
+
+static void
+e_dbus_object_method_free(E_DBus_Method *m)
+{
+  if (!m) return;
+  if (m->member) free(m->member);
+  if (m->signature) free(m->signature);
+  if (m->reply_signature) free(m->reply_signature);
+
+  free(m);
+}
+
+static E_DBus_Method *
+e_dbus_object_method_find(E_DBus_Object *obj, const char *interface, const char *member)
+{
+  E_DBus_Method *m;
+  E_DBus_Interface *iface;
+  if (!obj || !member) return NULL;
+
+  ecore_list_first_goto(obj->interfaces);
+  while ((iface = ecore_list_next(obj->interfaces)))
+  {
+    if (strcmp(interface, iface->name)) continue;
+    ecore_list_first_goto(iface->methods);
+    while ((m = ecore_list_next(iface->methods)))
+    {
+      if (!strcmp(member, m->member))
+        return m;
+    }
+  }
+  return NULL;
+}
+
+static DBusHandlerResult
+e_dbus_object_handler(DBusConnection *conn, DBusMessage *message, void *user_data) 
+{
+  E_DBus_Object *obj;
+  E_DBus_Method *m;
+  DBusMessage *reply;
+  dbus_uint32_t serial;
+
+  obj = user_data;
+  if (!obj)
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+  m = e_dbus_object_method_find(obj, dbus_message_get_interface(message), dbus_message_get_member(message));
+
+  /* XXX should this send an 'invalid method' error instead? */
+  if (!m) 
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+  if (m->signature && !dbus_message_has_signature(message, m->signature))
+    reply = dbus_message_new_error_printf(message, "org.enlightenment.InvalidSignature", "Expected signature: %s", m->signature);
+  else
+    reply = m->func(obj, message);
+
+  dbus_connection_send(conn, reply, &serial);
+  dbus_message_unref(reply);
+
+  return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static void
+e_dbus_object_unregister(DBusConnection *conn, void *user_data)
+{
+  /* free up the object struct? */
+}
+
+Ecore_Strbuf *
+e_dbus_object_introspect(E_DBus_Object *obj)
+{
+  Ecore_Strbuf *buf;
+  int level = 0;
+  E_DBus_Interface *iface;
+
+  buf = ecore_strbuf_new();
+
+  /* Doctype */
+  ecore_strbuf_append(buf, "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n");
+
+  ecore_strbuf_append(buf, "<node name=\"");
+  ecore_strbuf_append(buf, obj->path);
+  ecore_strbuf_append(buf, "\">\n");
+  level++;
+
+  ecore_list_first_goto(obj->interfaces);
+  while ((iface = ecore_list_next(obj->interfaces)))
+    _introspect_interface_append(buf, iface, level);
+
+  ecore_strbuf_append(buf, "</node>\n");
+  return buf;
+}
+
+static void
+_introspect_indent_append(Ecore_Strbuf *buf, int level)
+{
+  /* XXX optimize this? */
+  int i = level * 2;
+  while (i-- > 0)
+    ecore_strbuf_append_char(buf, ' ');
+}
+static void
+_introspect_interface_append(Ecore_Strbuf *buf, E_DBus_Interface *iface, int level)
+{
+  E_DBus_Method *method;
+  _introspect_indent_append(buf, level);
+  ecore_strbuf_append(buf, "<interface name=\"");
+  ecore_strbuf_append(buf, iface->name);
+  ecore_strbuf_append(buf, "\">\n");
+  level++;
+
+  DEBUG(4, "introspect iface: %s\n", iface->name);
+  ecore_list_first_goto(iface->methods);
+  while ((method = ecore_list_next(iface->methods))) 
+    _introspect_method_append(buf, method, level);
+
+  level--;
+  _introspect_indent_append(buf, level);
+  ecore_strbuf_append(buf, "</interface>\n");
+}
+static void
+_introspect_method_append(Ecore_Strbuf *buf, E_DBus_Method *method, int level)
+{
+  DBusSignatureIter iter;
+  char *type;
+
+  _introspect_indent_append(buf, level);
+  DEBUG(4, "introspect method: %s\n", method->member);
+  ecore_strbuf_append(buf, "<method name=\"");
+  ecore_strbuf_append(buf, method->member);
+  ecore_strbuf_append(buf, "\">\n");
+  level++;
+
+  /* append args */
+  if (method->signature && 
+      method->signature[0] &&
+      dbus_signature_validate(method->signature, NULL))
+  {
+    dbus_signature_iter_init(&iter, method->signature);
+    while ((type = dbus_signature_iter_get_signature(&iter)))
+    {
+      _introspect_arg_append(buf, type, "in", level);
+
+      dbus_free(type);
+      if (!dbus_signature_iter_next(&iter)) break;
+    }
+  }
+
+  /* append reply args */
+  if (method->reply_signature &&
+      method->reply_signature[0] &&
+      dbus_signature_validate(method->reply_signature, NULL))
+  {
+    dbus_signature_iter_init(&iter, method->reply_signature);
+    while ((type = dbus_signature_iter_get_signature(&iter)))
+    {
+      _introspect_arg_append(buf, type, "out", level);
+
+      dbus_free(type);
+      if (!dbus_signature_iter_next(&iter)) break;
+    }
+  }
+
+  level--;
+  _introspect_indent_append(buf, level);
+  ecore_strbuf_append(buf, "</method>\n");
+}
+
+static void
+_introspect_arg_append(Ecore_Strbuf *buf, const char *type, const char *direction, int level)
+{
+  _introspect_indent_append(buf, level);
+  ecore_strbuf_append(buf, "<arg type=\"");
+  ecore_strbuf_append(buf, type);
+  ecore_strbuf_append(buf, "\" direction=\"");
+  ecore_strbuf_append(buf, direction);
+  ecore_strbuf_append(buf, "\"/>\n");
+}
+
diff --git a/src/lib/dbus/e_dbus_private.h b/src/lib/dbus/e_dbus_private.h
new file mode 100644 (file)
index 0000000..24248f0
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef E_DBUS_PRIVATE_H
+#define E_DBUS_PRIVATE_H
+
+#include "dbus/dbus.h"
+#include "Ecore_Data.h"
+
+#define DEBUG_LVL 0
+#define DEBUG(lvl, ...) if (lvl <= DEBUG_LVL) printf(__VA_ARGS__)
+
+struct E_DBus_Connection
+{
+  DBusBusType shared_type;
+  DBusConnection *conn;
+  char *conn_name;
+
+  Ecore_List *fd_handlers;
+  Ecore_List *timeouts;
+
+  Ecore_Idler *idler;
+
+  int refcount;
+};
+
+struct E_DBus_Callback
+{
+  E_DBus_Callback_Func cb_func;
+  E_DBus_Unmarshal_Func unmarshal_func;
+  E_DBus_Free_Func free_func;
+  void *user_data;
+};
+
+int  e_dbus_signal_init(void);
+void e_dbus_signal_shutdown(void);
+int  e_dbus_object_init(void);
+void e_dbus_object_shutdown(void);
+
+extern int e_dbus_idler_active;
+void e_dbus_signal_handlers_clean(E_DBus_Connection *conn);
+
+const char *e_dbus_basic_type_as_string(int type);
+
+  
+#endif
diff --git a/src/lib/dbus/e_dbus_signal.c b/src/lib/dbus/e_dbus_signal.c
new file mode 100644 (file)
index 0000000..fe3221f
--- /dev/null
@@ -0,0 +1,250 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <Ecore.h>
+#include <Ecore_Data.h>
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+#include "dbus/dbus.h"
+
+static Ecore_List *signal_handlers = NULL;
+
+static Ecore_Event_Handler *event_handler = NULL;
+static int init = 0;
+
+
+struct E_DBus_Signal_Handler
+{
+  char *sender;
+  char *path;
+  char *interface;
+  char *member;
+
+  E_DBus_Signal_Cb cb_signal;
+  void *data;
+  unsigned char delete_me : 1;
+};
+
+static int cb_signal_event(void *data, int type, void *event);
+
+void e_dbus_signal_handler_free(E_DBus_Signal_Handler *sh);
+
+
+/**
+ * Initialize the signal subsystem
+ * @internal
+ */
+int
+e_dbus_signal_init(void)
+{
+  if (++init != 1) return init;
+  signal_handlers = ecore_list_new();
+  if (!signal_handlers) {--init; return 0;};
+  ecore_list_free_cb_set(signal_handlers, ECORE_FREE_CB(e_dbus_signal_handler_free));
+
+  event_handler = ecore_event_handler_add(E_DBUS_EVENT_SIGNAL, cb_signal_event, NULL);
+  return init;
+}
+
+/**
+ * Shutdown the signal subsystem
+ * @internal
+ */
+void
+e_dbus_signal_shutdown(void)
+{
+  if (--init) return;
+  ecore_list_destroy(signal_handlers);
+
+  if (event_handler) ecore_event_handler_del(event_handler);
+  event_handler = NULL;
+}
+
+/**
+ * Free a signal handler
+ * @param sh the signal handler to free
+ */
+void
+e_dbus_signal_handler_free(E_DBus_Signal_Handler *sh)
+{
+  if (sh->sender) free(sh->sender);
+  if (sh->path) free(sh->path);
+  if (sh->interface) free(sh->interface);
+  if (sh->member) free(sh->member);
+
+  free(sh);
+}
+
+static void
+cb_name_owner(void *data, DBusMessage *msg, DBusError *err)
+{
+  const char *unique_name = NULL;
+  E_DBus_Signal_Handler *sh;
+
+  sh = data;
+
+  if (dbus_error_is_set(err))
+  {
+    if (ecore_list_goto(signal_handlers, sh))
+      ecore_list_remove(signal_handlers);
+    dbus_error_free(err);
+    return;
+  }
+
+  dbus_message_get_args(msg, err, DBUS_TYPE_STRING, &unique_name, DBUS_TYPE_INVALID);
+
+  if (dbus_error_is_set(err))
+  {
+    DEBUG(1, "Invalid signature in reply to name owner call\n");
+    dbus_error_free(err);
+    return;
+  }
+
+  if (unique_name)
+  {
+    if (sh->sender) free(sh->sender);
+    sh->sender = strdup(unique_name);
+  }
+  else DEBUG(1, "Error, no unique name?\n");
+
+}
+
+/**
+ * Add a signal handler
+ *
+ * @param conn the dbus connection
+ * @param bus name of the signal's sender
+ * @param path the object path of the signal's sender
+ * @param interface the signal's interface
+ * @param memeber the signal's name
+ * @param cb_signal a callback to call when the signal is received
+ * @param data custom data to pass in to the callback
+ */
+EAPI E_DBus_Signal_Handler *
+e_dbus_signal_handler_add(E_DBus_Connection *conn, const char *sender, const char *path, const char *interface, const char *member, E_DBus_Signal_Cb cb_signal, void *data)
+{
+  E_DBus_Signal_Handler *sh;
+  char match[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
+  int started = 0;
+  int len = 0;
+  DBusError err;
+
+  sh = calloc(1, sizeof(E_DBus_Signal_Handler));
+
+  strcpy(match, "type='signal'");
+  len = 13;
+
+#undef ADD_MATCH_PIECE
+#define ADD_MATCH_PIECE(PIECE) \
+  if (PIECE) \
+  {\
+    len += strlen("," #PIECE "=''") + strlen(PIECE);\
+    if (len >= sizeof(match)) return NULL;\
+    strcat(match, "," #PIECE "='");\
+    strcat(match, PIECE);\
+    strcat(match, "'");\
+    sh->PIECE = strdup(PIECE);\
+    started = 1;\
+  }
+
+  ADD_MATCH_PIECE(sender)
+  ADD_MATCH_PIECE(path)
+  ADD_MATCH_PIECE(interface)
+  ADD_MATCH_PIECE(member)
+
+  sh->cb_signal = cb_signal;
+  sh->data = data;
+
+  dbus_error_init(&err);
+  dbus_bus_add_match(conn->conn, match, NULL);
+  ecore_list_append(signal_handlers, sh);
+
+  /* if we have a sender, and it is not a unique name, we need to know the unique name to match since signals will have the name owner as ther sender. */
+  if (sender && sender[0] != ':')
+    e_dbus_get_name_owner(conn, sender, cb_name_owner, sh);
+
+  return sh;
+}
+
+static int e_dbus_handler_deletions = 0;
+
+/**
+ * Delete a signal handler
+ *
+ * @param conn the dbus connection
+ * @param sh the handler to delete
+ */
+EAPI void
+e_dbus_signal_handler_del(E_DBus_Connection *conn, E_DBus_Signal_Handler *sh)
+{
+  char match[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
+  int len = 0;
+
+  sh->delete_me = 1;
+  if (e_dbus_idler_active)
+  {
+    e_dbus_handler_deletions = 1;
+    return;
+  }
+
+  strcpy(match, "type='signal'");
+  len = 13;
+
+#undef ADD_MATCH_PIECE
+#define ADD_MATCH_PIECE(PIECE) \
+  if (PIECE) \
+  {\
+    len += strlen("," #PIECE "=''") + strlen(PIECE);\
+    if (len >= sizeof(match)) return;\
+    strcat(match, "," #PIECE "='");\
+    strcat(match, PIECE);\
+    strcat(match, "'");\
+  }
+
+  ADD_MATCH_PIECE(sh->sender)
+  ADD_MATCH_PIECE(sh->path)
+  ADD_MATCH_PIECE(sh->interface)
+  ADD_MATCH_PIECE(sh->member)
+
+  dbus_bus_remove_match(conn->conn, match, NULL);
+
+  if (!ecore_list_goto(signal_handlers, sh)) return;
+  ecore_list_remove(signal_handlers);
+}
+
+static int
+cb_signal_event(void *data, int type, void *event)
+{
+  DBusMessage *msg = event;
+  E_DBus_Signal_Handler *sh;
+
+  ecore_list_first_goto(signal_handlers);
+  while ((sh = ecore_list_next(signal_handlers)))
+  {
+    if ((!sh->cb_signal) || (sh->delete_me)) continue;
+
+    if (sh->sender && !dbus_message_has_sender(msg, sh->sender)) continue;
+    if (sh->path && !dbus_message_has_path(msg, sh->path)) continue;
+    if (sh->interface && !dbus_message_has_interface(msg, sh->interface)) continue;
+    if (sh->member && !dbus_message_has_member(msg, sh->member)) continue;
+
+    sh->cb_signal(sh->data, msg);
+  }
+
+  return 1;
+}
+
+void
+e_dbus_signal_handlers_clean(E_DBus_Connection *conn)
+{
+  E_DBus_Signal_Handler *sh;
+
+  if (!e_dbus_handler_deletions) return;
+  ecore_list_first_goto(signal_handlers);
+  while ((sh = ecore_list_next(signal_handlers)))
+  {
+    if (sh->delete_me)
+      e_dbus_signal_handler_del(conn, sh);
+  }
+  e_dbus_handler_deletions = 0;
+}
diff --git a/src/lib/dbus/e_dbus_util.c b/src/lib/dbus/e_dbus_util.c
new file mode 100644 (file)
index 0000000..27c08fa
--- /dev/null
@@ -0,0 +1,92 @@
+#include "E_DBus.h"
+#include "e_dbus_private.h"
+
+/**
+ * @internal
+ * @brief Create a callback structure
+ * @param cb_func the callback function
+ * @param user_data data to pass to the callback
+ */
+EAPI E_DBus_Callback *
+e_dbus_callback_new(E_DBus_Callback_Func cb_func, E_DBus_Unmarshal_Func unmarshal_func, E_DBus_Free_Func free_func, void *user_data)
+{
+  E_DBus_Callback *cb;
+
+  if (!cb_func) return NULL;
+
+  cb = calloc(1, sizeof(E_DBus_Callback));
+  if (!cb) return NULL;
+  cb->cb_func = cb_func;
+  cb->unmarshal_func = unmarshal_func;
+  cb->free_func = free_func;
+  cb->user_data = user_data;
+  return cb;
+}
+
+/**
+ * @internal
+ * @brief Free a callback structure
+ * @param callback the callback to free
+ */
+EAPI void
+e_dbus_callback_free(E_DBus_Callback *callback)
+{
+  free(callback);
+}
+
+EAPI void
+e_dbus_callback_call(E_DBus_Callback *cb, void *data, DBusError *error)
+{
+  if (cb && cb->cb_func)
+    cb->cb_func(cb->user_data, data, error);
+}
+
+EAPI void *
+e_dbus_callback_unmarshal(E_DBus_Callback *cb, DBusMessage *msg, DBusError *err)
+{
+  if (cb && cb->unmarshal_func)
+    return cb->unmarshal_func(msg, err);
+  else
+    return NULL;
+}
+
+EAPI void
+e_dbus_callback_return_free(E_DBus_Callback *cb, void *data)
+{
+  if (cb && cb->free_func)
+    cb->free_func(data);
+}
+
+const char *
+e_dbus_basic_type_as_string(int type)
+{
+  switch (type)
+  {
+    case DBUS_TYPE_BYTE:
+      return DBUS_TYPE_BYTE_AS_STRING;
+    case DBUS_TYPE_BOOLEAN:
+      return DBUS_TYPE_BOOLEAN_AS_STRING;
+    case DBUS_TYPE_INT16:
+      return DBUS_TYPE_INT16_AS_STRING;
+    case DBUS_TYPE_UINT16:
+      return DBUS_TYPE_UINT16_AS_STRING;
+    case DBUS_TYPE_INT32:
+      return DBUS_TYPE_INT32_AS_STRING;
+    case DBUS_TYPE_UINT32:
+      return DBUS_TYPE_UINT32_AS_STRING;
+    case DBUS_TYPE_INT64:
+      return DBUS_TYPE_INT64_AS_STRING;
+    case DBUS_TYPE_UINT64:
+      return DBUS_TYPE_UINT64_AS_STRING;
+    case DBUS_TYPE_DOUBLE:
+      return DBUS_TYPE_DOUBLE_AS_STRING;
+    case DBUS_TYPE_STRING:
+      return DBUS_TYPE_STRING_AS_STRING;
+    case DBUS_TYPE_OBJECT_PATH:
+      return DBUS_TYPE_OBJECT_PATH_AS_STRING;
+    case DBUS_TYPE_SIGNATURE:
+      return DBUS_TYPE_SIGNATURE_AS_STRING;
+    default:
+      return NULL;
+  }
+}
diff --git a/src/lib/hal/.cvsignore b/src/lib/hal/.cvsignore
new file mode 100644 (file)
index 0000000..07d6b3d
--- /dev/null
@@ -0,0 +1,8 @@
+.deps
+Makefile
+Makefile.in
+.libs
+e_hal_device.lo
+e_hal_manager.lo
+e_hal_util.lo
+libehal.la
diff --git a/src/lib/hal/E_Hal.h b/src/lib/hal/E_Hal.h
new file mode 100644 (file)
index 0000000..6feb79a
--- /dev/null
@@ -0,0 +1,134 @@
+#ifndef E_HAL_H
+#define E_HAL_H
+#include <E_DBus.h>
+#include <Ecore_Data.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
+
+#define E_HAL_SENDER "org.freedesktop.Hal"
+#define E_HAL_MANAGER_PATH "/org/freedesktop/Hal/Manager"
+#define E_HAL_MANAGER_INTERFACE "org.freedesktop.Hal.Manager"
+#define E_HAL_DEVICE_INTERFACE "org.freedesktop.Hal.Device"
+#define E_HAL_DEVICE_VOLUME_INTERFACE "org.freedesktop.Hal.Device.Volume"
+
+/* message return types */
+
+typedef struct E_Hal_Property E_Hal_Property;
+typedef struct E_Hal_Properties E_Hal_Properties;
+
+struct E_Hal_String_List_Return
+{
+  Ecore_List *strings; /* list of const char * */
+};
+
+struct E_Hal_Bool_Return
+{
+  char boolean;
+};
+
+struct E_Hal_UDI_Return
+{
+  const char *udi;
+};
+
+struct E_Hal_Capability
+{
+  const char *udi;
+  const char *capability;
+};
+
+typedef enum
+{
+  E_HAL_PROPERTY_TYPE_STRING,
+  E_HAL_PROPERTY_TYPE_INT,
+  E_HAL_PROPERTY_TYPE_UINT64,
+  E_HAL_PROPERTY_TYPE_BOOL,
+  E_HAL_PROPERTY_TYPE_DOUBLE,
+  E_HAL_PROPERTY_TYPE_STRLIST
+} E_Hal_Property_Type;
+
+struct E_Hal_Property
+{
+  E_Hal_Property_Type type;
+  union 
+  {
+    const char *s;
+    int i;
+    dbus_bool_t b;
+    double d;
+    dbus_uint64_t u64;
+    Ecore_List *strlist;
+  } val;
+};
+
+struct E_Hal_Properties
+{
+  Ecore_Hash *properties;
+};
+
+typedef struct E_Hal_Properties E_Hal_Device_Get_All_Properties_Return;
+typedef struct E_Hal_Property E_Hal_Device_Get_Property_Return;
+typedef struct E_Hal_Bool_Return E_Hal_Device_Query_Capability_Return;
+typedef struct E_Hal_String_List_Return E_Hal_String_List_Return;
+typedef struct E_Hal_String_List_Return E_Hal_Manager_Get_All_Devices_Return;
+typedef struct E_Hal_Bool_Return E_Hal_Manager_Device_Exists_Return;
+typedef struct E_Hal_String_List_Return E_Hal_Manager_Find_Device_String_Match_Return;
+typedef struct E_Hal_String_List_Return E_Hal_Manager_Find_Device_By_Capability_Return;
+
+
+typedef struct E_Hal_UDI_Return E_Hal_Manager_Device_Added;
+typedef struct E_Hal_UDI_Return E_Hal_Manager_Device_Removed;
+typedef struct E_Hal_Capability E_Hal_Manager_New_Capability;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* org.freedesktop.Hal.Device */
+   EAPI int e_hal_device_get_property(E_DBus_Connection *conn, const char *udi, const char *property, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_hal_device_get_all_properties(E_DBus_Connection *conn, const char *udi, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_hal_device_query_capability(E_DBus_Connection *conn, const char *udi, const char *capability, E_DBus_Callback_Func cb_func, void *data);
+
+/* org.freedesktop.Hal.Manager */
+   EAPI int e_hal_manager_get_all_devices(E_DBus_Connection *conn, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_hal_manager_device_exists(E_DBus_Connection *conn, const char *udi, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_hal_manager_find_device_string_match(E_DBus_Connection *conn, const char *key, const char *value, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_hal_manager_find_device_by_capability(E_DBus_Connection *conn, const char *capability, E_DBus_Callback_Func cb_func, void *data);
+
+/* utility functions */
+   EAPI void           e_hal_property_free(E_Hal_Property *prop);
+   EAPI char          *e_hal_property_string_get(E_Hal_Properties *properties, const char *key, int *err);
+   EAPI char           e_hal_property_bool_get(E_Hal_Properties *properties, const char *key, int *err);
+   EAPI int            e_hal_property_int_get(E_Hal_Properties *properties, const char *key, int *err);
+   EAPI dbus_uint64_t  e_hal_property_uint64_get(E_Hal_Properties *properties, const char *key, int *err);
+   EAPI double         e_hal_property_double_get(E_Hal_Properties *properties, const char *key, int *err);
+   EAPI Ecore_List    *e_hal_property_strlist_get(E_Hal_Properties *properties, const char *key, int *err);
+
+/* (un)mount */
+   EAPI int e_hal_device_volume_mount(E_DBus_Connection *conn, const char *udi, const char *mount_point, const char *fstype, Ecore_List *options, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_hal_device_volume_unmount(E_DBus_Connection *conn, const char *udi, Ecore_List *options, E_DBus_Callback_Func cb_func, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/hal/Makefile.am b/src/lib/hal/Makefile.am
new file mode 100644 (file)
index 0000000..d03cdea
--- /dev/null
@@ -0,0 +1,23 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I $(top_srcdir)/src/lib/dbus \
+@EDBUS_CFLAGS@
+
+if BUILD_EHAL
+
+lib_LTLIBRARIES = libehal.la
+include_HEADERS = E_Hal.h
+
+libehal_la_SOURCES = \
+E_Hal.h \
+e_hal_device.c  \
+e_hal_manager.c \
+e_hal_util.c 
+
+libehal_la_LIBADD = \
+@EDBUS_LIBS@ \
+$(top_builddir)/src/lib/dbus/libedbus.la
+libehal_la_LDFLAGS      = -version-info @version_info@
+
+endif
diff --git a/src/lib/hal/e_hal_device.c b/src/lib/hal/e_hal_device.c
new file mode 100644 (file)
index 0000000..68a9dc1
--- /dev/null
@@ -0,0 +1,307 @@
+#include <E_Hal.h>
+
+#define e_hal_device_call_new(udi, member) dbus_message_new_method_call(E_HAL_SENDER, udi, E_HAL_DEVICE_INTERFACE, member)
+#define e_hal_device_volume_call_new(udi, member) dbus_message_new_method_call(E_HAL_SENDER, udi, E_HAL_DEVICE_VOLUME_INTERFACE, member)
+
+#if 0
+static void cb_device_get_property(void *data, DBusMessage *msg, DBusError *err);
+static void cb_device_get_all_properties(void *data, DBusMessage *msg, DBusError *err);
+static void cb_device_query_capability(void *data, DBusMessage *msg, DBusError *err);
+#endif
+
+/* Device.GetProperty */
+static void *
+unmarshal_device_get_property(DBusMessage *msg, DBusError *err)
+{
+  E_Hal_Device_Get_Property_Return *ret = NULL;
+  DBusMessageIter iter;
+  int type;
+
+  ret = calloc(1, sizeof(E_Hal_Device_Get_Property_Return));
+  if (!ret) 
+  {
+    dbus_set_error(err, DBUS_ERROR_NO_MEMORY, "");
+    return NULL;
+  }
+
+  dbus_message_iter_init(msg, &iter);
+  type = dbus_message_iter_get_arg_type(&iter);
+  switch(type)
+  {
+    case 's':
+      dbus_message_iter_get_basic(&iter, &(ret->val.s));
+      break;
+    case 'i':
+      dbus_message_iter_get_basic(&iter, &(ret->val.i));
+      break;
+    case 'b':
+      dbus_message_iter_get_basic(&iter, &(ret->val.b));
+      break;
+    case 'd':
+      dbus_message_iter_get_basic(&iter, &(ret->val.d));
+      break;
+  }
+
+  return ret;
+}
+
+static void 
+free_device_get_property(void *data)
+{
+  E_Hal_Device_Get_Property_Return *ret = data;
+
+  if (!ret) return;
+  free(ret);
+}
+
+EAPI int
+e_hal_device_get_property(E_DBus_Connection *conn, const char *udi, const char *property, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_hal_device_call_new(udi, "GetProperty");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_device_get_property, cb_func, free_device_get_property, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+/* Device.GetAllProperties */
+
+static void *
+unmarshal_device_get_all_properties(DBusMessage *msg, DBusError *err)
+{
+  E_Hal_Device_Get_All_Properties_Return *ret = NULL;
+  DBusMessageIter iter, a_iter, s_iter, v_iter;
+
+  if (!dbus_message_has_signature(msg, "a{sv}")) 
+  {
+    dbus_set_error(err, DBUS_ERROR_INVALID_SIGNATURE, "");
+    return NULL;
+  }
+
+  ret = calloc(1, sizeof(E_Hal_Device_Get_All_Properties_Return));
+  if (!ret) 
+  {
+    dbus_set_error(err, DBUS_ERROR_NO_MEMORY, "");
+    return NULL;
+  }
+
+  ret->properties = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+  ecore_hash_free_key_cb_set(ret->properties, ECORE_FREE_CB(ecore_string_release));
+  ecore_hash_free_value_cb_set(ret->properties, ECORE_FREE_CB(e_hal_property_free));
+
+
+  dbus_message_iter_init(msg, &iter);
+  dbus_message_iter_recurse(&iter, &a_iter);
+  while (dbus_message_iter_get_arg_type(&a_iter) != DBUS_TYPE_INVALID)
+  {
+    const char *name;
+    E_Hal_Property *prop = calloc(1, sizeof(E_Hal_Property));
+    dbus_message_iter_recurse(&a_iter, &s_iter);
+    dbus_message_iter_get_basic(&s_iter, &name);
+    dbus_message_iter_next(&s_iter);
+    dbus_message_iter_recurse(&s_iter, &v_iter);
+    
+    switch(dbus_message_iter_get_arg_type(&v_iter))
+    {
+      case 's':
+        prop->type = E_HAL_PROPERTY_TYPE_STRING;
+        dbus_message_iter_get_basic(&v_iter, &(prop->val.s));
+        break;
+      case 'i':
+        prop->type = E_HAL_PROPERTY_TYPE_INT;
+        dbus_message_iter_get_basic(&v_iter, &(prop->val.i));
+        break;
+      case 't':
+        prop->type = E_HAL_PROPERTY_TYPE_UINT64;
+        dbus_message_iter_get_basic(&v_iter, &(prop->val.u64));
+        break;
+      case 'b':
+        prop->type = E_HAL_PROPERTY_TYPE_BOOL;
+        dbus_message_iter_get_basic(&v_iter, &(prop->val.b));
+        break;
+      case 'd':
+        prop->type = E_HAL_PROPERTY_TYPE_DOUBLE;
+        dbus_message_iter_get_basic(&v_iter, &(prop->val.d));
+        break;
+      case 'a':
+        prop->type = E_HAL_PROPERTY_TYPE_STRLIST;
+        {
+          DBusMessageIter list_iter;
+          prop->val.strlist = ecore_list_new();
+          dbus_message_iter_recurse(&v_iter, &list_iter);
+          while (dbus_message_iter_get_arg_type(&list_iter) != DBUS_TYPE_INVALID)
+          {
+            char *str;
+            dbus_message_iter_get_basic(&list_iter, &str);
+            ecore_list_append(prop->val.strlist, str);
+            dbus_message_iter_next(&list_iter);
+          }
+        }
+        break;
+      default:
+        printf("Error: unexpected property type (%s): %c\n", name, dbus_message_iter_get_arg_type(&v_iter));
+        break;
+    }
+    ecore_hash_set(ret->properties, (void *)ecore_string_instance(name), prop);
+
+    dbus_message_iter_next(&a_iter);
+  }
+
+  return ret;
+}
+
+static void
+free_device_get_all_properties(void *data)
+{
+  E_Hal_Device_Get_All_Properties_Return *ret = data;
+
+  if (!ret) return;
+  ecore_hash_destroy(ret->properties);
+  free(ret);
+}
+
+EAPI int
+e_hal_device_get_all_properties(E_DBus_Connection *conn, const char *udi, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_hal_device_call_new(udi, "GetAllProperties");
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_device_get_all_properties, cb_func, free_device_get_all_properties, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+
+
+/* bool Device.QueryCapability(string udi) */
+
+// XXX this is same as Device_Exists in manager.
+static void *
+unmarshal_device_query_capability(DBusMessage *msg, DBusError *err)
+{
+  E_Hal_Device_Query_Capability_Return *ret = NULL;
+  dbus_bool_t val;
+
+  ret = calloc(1, sizeof(E_Hal_Manager_Device_Exists_Return));
+  if (!ret) 
+  {
+    dbus_set_error(err, DBUS_ERROR_NO_MEMORY, "");
+    return NULL;
+  }
+
+  dbus_message_get_args(msg, err, DBUS_TYPE_BOOLEAN, &val, DBUS_TYPE_INVALID);
+
+  if (dbus_error_is_set(err))
+  {
+    free(ret);
+    return NULL;
+  }
+
+  ret->boolean = val;
+  return ret;
+}
+
+static void
+free_device_query_capability(void *data)
+{
+  E_Hal_Device_Query_Capability_Return *ret = data;
+
+  if (!ret) return;
+  free(ret);
+}
+
+EAPI int
+e_hal_device_query_capability(E_DBus_Connection *conn, const char *udi, const char *capability, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_hal_device_call_new(udi, "QueryCapability");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &capability, DBUS_TYPE_INVALID);
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_device_query_capability, cb_func, free_device_query_capability, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+
+
+/* void Device.Mount(string mount_point, string fstype, array{string}options) */
+
+/**
+ * @brief Mount a Volume
+ *
+ * @param conn the E_DBus_Connection
+ * @param udi the udi of the device object
+ * @param mount_point the path to mount to, or null for default
+ * @param fstype the fstype of the device (e.g. volume.fstype property)
+ * @param options a list of additional options (not sure... fstype dependant?)
+ */
+EAPI int
+e_hal_device_volume_mount(E_DBus_Connection *conn, const char *udi, const char *mount_point, const char *fstype, Ecore_List *options, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  DBusMessageIter iter, subiter;
+  int ret;
+
+  msg = e_hal_device_volume_call_new(udi, "Mount");
+
+  dbus_message_iter_init_append(msg, &iter);
+  dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &mount_point);
+  dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &fstype);
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &subiter);
+
+  if (options)
+  {
+    const char *opt;
+    ecore_list_first_goto(options);
+    while ((opt = ecore_list_next(options)))
+    {
+      dbus_message_iter_append_basic(&subiter, DBUS_TYPE_STRING, &opt);
+    }
+  }
+  dbus_message_iter_close_container(&iter, &subiter) ;
+
+  ret = e_dbus_method_call_send(conn, msg, NULL, cb_func, NULL, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+/* void Unmount(array{string} options) */
+
+/**
+ * @brief Mount a Volume
+ *
+ * @param conn the E_DBus_Connection
+ * @param udi the udi of the device object
+ * @param options a list of additional options (not sure... fstype dependant?)
+ */
+EAPI int
+e_hal_device_volume_unmount(E_DBus_Connection *conn, const char *udi, Ecore_List *options, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  DBusMessageIter iter, subiter;
+  int ret;
+
+  msg = e_hal_device_volume_call_new(udi, "Unmount");
+
+  dbus_message_iter_init_append(msg, &iter);
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &subiter);
+  if (options)
+  {
+    const char *opt;
+    ecore_list_first_goto(options);
+    while ((opt = ecore_list_next(options)))
+    {
+      dbus_message_iter_append_basic(&subiter, DBUS_TYPE_STRING, &opt);
+    }
+  }
+  dbus_message_iter_close_container(&iter, &subiter) ;
+
+  ret = e_dbus_method_call_send(conn, msg, NULL, cb_func, NULL, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
diff --git a/src/lib/hal/e_hal_device.h b/src/lib/hal/e_hal_device.h
new file mode 100644 (file)
index 0000000..3fc478a
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef E_HAL_DEVICE_H
+#define E_HAL_DEVICE_H
+
+#include "E_Hal.h"
+
+typedef struct E_Hal_Properties E_Hal_Device_Get_All_Properties_Return;
+typedef struct E_Hal_Property E_Hal_Device_Get_Property_Return;
+typedef struct E_Hal_Bool_Return E_Hal_Device_Query_Capability_Return;
+
+int e_hal_device_get_property(E_DBus_Connection *conn, const char *udi, const char *property, E_Hal_Callback_Func cb_func, void *data);
+int e_hal_device_get_all_properties(E_DBus_Connection *conn, const char *udi, E_Hal_Callback_Func cb_func, void *data);
+int e_hal_device_query_capability(E_DBus_Connection *conn, const char *udi, const char *capability, E_Hal_Callback_Func cb_func, void *data);
+
+#endif
diff --git a/src/lib/hal/e_hal_manager.c b/src/lib/hal/e_hal_manager.c
new file mode 100644 (file)
index 0000000..ff52311
--- /dev/null
@@ -0,0 +1,146 @@
+#include "E_Hal.h"
+
+#define e_hal_manager_call_new(member) dbus_message_new_method_call(E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, member)
+
+/* GetAllDevices */
+
+static void *
+unmarshal_string_list(DBusMessage *msg, DBusError *err)
+{
+  E_Hal_String_List_Return *ret = NULL;
+  DBusMessageIter iter, sub;
+
+  if (!dbus_message_has_signature(msg, "as")) 
+  {
+    dbus_set_error(err, DBUS_ERROR_INVALID_SIGNATURE, "");
+    return NULL;
+  }
+
+  ret = calloc(1, sizeof(E_Hal_String_List_Return));
+  if (!ret) 
+  {
+    dbus_set_error(err, DBUS_ERROR_NO_MEMORY, "");
+    return NULL;
+  }
+
+  ret->strings = ecore_list_new();
+  if (!ret->strings)
+  {
+    dbus_set_error(err, DBUS_ERROR_NO_MEMORY, "");
+    free(ret);
+    return NULL;
+  }
+
+  dbus_message_iter_init(msg, &iter);
+  dbus_message_iter_recurse(&iter, &sub);
+  while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID)
+  {
+    char *dev = NULL;
+
+    dbus_message_iter_get_basic(&sub, &dev);
+    if (dev) ecore_list_append(ret->strings, dev);
+    dbus_message_iter_next(&sub);
+  }
+
+  return ret;
+}
+
+static void
+free_string_list(void *data)
+{
+  E_Hal_String_List_Return *ret = data;
+
+  if (!ret) return;
+  ecore_list_destroy(ret->strings);
+  free(ret);
+}
+
+EAPI int
+e_hal_manager_get_all_devices(E_DBus_Connection *conn, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_hal_manager_call_new("GetAllDevices");
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_string_list, cb_func, free_string_list, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+/* Manager.DeviceExists(string udi) */
+
+static void *
+unmarshal_manager_device_exists(DBusMessage *msg, DBusError *err)
+{
+  E_Hal_Manager_Device_Exists_Return *ret = NULL;
+  dbus_bool_t val;
+
+  ret = calloc(1, sizeof(E_Hal_Manager_Device_Exists_Return));
+  if (!ret) 
+  {
+    dbus_set_error(err, DBUS_ERROR_NO_MEMORY, "");
+    return NULL;
+  }
+
+  dbus_message_get_args(msg, err, DBUS_TYPE_BOOLEAN, &val, DBUS_TYPE_INVALID);
+
+  if (dbus_error_is_set(err))
+  {
+    free(ret);
+    return NULL;
+  }
+
+  ret->boolean = val;
+  return ret;
+}
+
+static void
+free_manager_device_exists(void *data)
+{
+  E_Hal_Manager_Device_Exists_Return *ret = data;
+
+  if (!ret) return;
+  free(ret);
+}
+
+EAPI int
+e_hal_manager_device_exists(E_DBus_Connection *conn, const char *udi, E_DBus_Callback_Func cb_func, void *data)
+{
+  int ret;
+  DBusMessage *msg;
+
+  msg = e_hal_manager_call_new("DeviceExists");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID);
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_manager_device_exists, cb_func, free_manager_device_exists, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+/* Manager.FindDeviceStringMatch */
+EAPI int
+e_hal_manager_find_device_string_match(E_DBus_Connection *conn, const char *key, const char *value, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_hal_manager_call_new("FindDeviceStringMatch");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID);
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_string_list, cb_func, free_string_list, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+/* Manager.FindDeviceByCapability */
+
+EAPI int
+e_hal_manager_find_device_by_capability(E_DBus_Connection *conn, const char *capability, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_hal_manager_call_new("FindDeviceByCapability");
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &capability, DBUS_TYPE_INVALID);
+  ret = e_dbus_method_call_send(conn, msg, unmarshal_string_list, cb_func, free_string_list, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
diff --git a/src/lib/hal/e_hal_manager.h b/src/lib/hal/e_hal_manager.h
new file mode 100644 (file)
index 0000000..3714dde
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef E_HAL_MANAGER_H
+#define E_HAL_MANAGER_H
+
+#include "E_Hal.h"
+
+typedef struct E_Hal_String_List_Return E_Hal_Manager_Get_All_Devices_Return;
+typedef struct E_Hal_Bool_Return E_Hal_Manager_Device_Exists_Return;
+typedef struct E_Hal_String_List_Return E_Hal_Manager_Find_Device_String_Match_Return;
+typedef struct E_Hal_String_List_Return E_Hal_Manager_Find_Device_By_Capability_Return;
+
+typedef struct E_Hal_UDI_Return E_Hal_Manager_Device_Added;
+typedef struct E_Hal_UDI_Return E_Hal_Manager_Device_Removed;
+typedef struct E_Hal_Capability E_Hal_Manager_New_Capability;
+
+
+int e_hal_manager_get_all_devices(E_DBus_Connection *conn, E_Hal_Callback_Func cb_func, void *data);
+int e_hal_manager_device_exists(E_DBus_Connection *conn, const char *udi, E_Hal_Callback_Func cb_func, void *data);
+int e_hal_manager_find_device_string_match(E_DBus_Connection *conn, const char *key, const char *value, E_Hal_Callback_Func cb_func, void *data);
+int e_hal_manager_find_device_by_capability(E_DBus_Connection *conn, const char *capability, E_Hal_Callback_Func cb_func, void *data);
+
+#endif
diff --git a/src/lib/hal/e_hal_util.c b/src/lib/hal/e_hal_util.c
new file mode 100644 (file)
index 0000000..cf10126
--- /dev/null
@@ -0,0 +1,99 @@
+#include <E_Hal.h>
+#include <string.h>
+
+/**
+ * @internal
+ * @brief free a property structure
+ * @param prop the property to free
+ */
+EAPI void
+e_hal_property_free(E_Hal_Property *prop)
+{
+  if (prop->type == E_HAL_PROPERTY_TYPE_STRLIST)
+    ecore_list_destroy(prop->val.strlist);
+  free(prop);
+}
+
+/**
+ * @brief Retrive a string from an element of a property hash
+ * @param properties the E_Hal_Properties structure
+ * @param key the key of the property to retrieve
+ * @param err a pointer to an int, which if supplied, will be set to 0 on success and 1 on an error
+ */
+EAPI char *
+e_hal_property_string_get(E_Hal_Properties *properties, const char *key, int *err)
+{
+  E_Hal_Property *prop;
+  if (err) *err = 0;
+  if (!properties->properties) return NULL;
+  prop = ecore_hash_get(properties->properties, key);
+  if (prop) return strdup(prop->val.s);
+
+  if (err) *err = 1;
+  return NULL;
+}
+
+EAPI char
+e_hal_property_bool_get(E_Hal_Properties *properties, const char *key, int *err)
+{
+  E_Hal_Property *prop;
+  if (err) *err = 0;
+  if (!properties->properties) return 0;
+  prop = ecore_hash_get(properties->properties, key);
+  if (prop) return prop->val.b;
+  
+  if (err) *err = 1;
+  return 0;
+}
+
+EAPI int
+e_hal_property_int_get(E_Hal_Properties *properties, const char *key, int *err)
+{
+  E_Hal_Property *prop;
+  if (err) *err = 0;
+  if (!properties->properties) return 0;
+  prop = ecore_hash_get(properties->properties, key);
+  if (prop) return prop->val.i;
+
+  if (err) *err = 1;
+  return 0;
+}
+
+EAPI dbus_uint64_t
+e_hal_property_uint64_get(E_Hal_Properties *properties, const char *key, int *err)
+{
+  E_Hal_Property *prop;
+  if (err) *err = 0;
+  if (!properties->properties) return 0;
+  prop = ecore_hash_get(properties->properties, key);
+  if (prop) return prop->val.u64;
+
+  if (err) *err = 1;
+  return 0;
+}
+
+EAPI double
+e_hal_property_double_get(E_Hal_Properties *properties, const char *key, int *err)
+{
+  E_Hal_Property *prop;
+  if (err) *err = 0;
+  if (!properties->properties) return 0;
+  prop = ecore_hash_get(properties->properties, key);
+  if (prop) return prop->val.d;
+
+  if (err) *err = 1;
+  return 0;
+}
+
+EAPI Ecore_List *
+e_hal_property_strlist_get(E_Hal_Properties *properties, const char *key, int *err)
+{
+  E_Hal_Property *prop;
+  if (err) *err = 0;
+  if (!properties->properties) return NULL;
+  prop = ecore_hash_get(properties->properties, key);
+  if (prop) return prop->val.strlist;
+
+  if (err) *err = 1;
+  return NULL;
+}
diff --git a/src/lib/hal/e_hal_util.h b/src/lib/hal/e_hal_util.h
new file mode 100644 (file)
index 0000000..fa0f471
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef E_HAL_UTIL_H
+#define E_HAL_UTIL_H
+
+#include "E_Hal.h"
+
+void e_hal_property_free(E_Hal_Property *prop);
+char *e_hal_property_string_get(E_Hal_Properties *properties, const char *key, int *err);
+char e_hal_property_bool_get(E_Hal_Properties *properties, const char *key, int *err);
+int e_hal_property_int_get(E_Hal_Properties *properties, const char *key, int *err);
+dbus_uint64_t e_hal_property_uint64_get(E_Hal_Properties *properties, const char *key, int *err);
+double e_hal_property_double_get(E_Hal_Properties *properties, const char *key, int *err);
+Ecore_List *e_hal_property_strlist_get(E_Hal_Properties *properties, const char *key, int *err);
+
+#endif
diff --git a/src/lib/nm/.cvsignore b/src/lib/nm/.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/nm/E_Nm.h b/src/lib/nm/E_Nm.h
new file mode 100644 (file)
index 0000000..46d637d
--- /dev/null
@@ -0,0 +1,176 @@
+#ifndef E_NM_H
+#define E_NM_H
+
+#include <E_DBus.h>
+#include <Ecore_Data.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
+
+typedef struct E_NM_Context E_NM_Context;
+
+/**
+ * Matching structs for the new "object" based DBus API
+ * VPN is missing as this was still missing the redesign for the new 0.7 API
+ */
+typedef struct E_NM_Device E_NM_Device;
+struct E_NM_Device
+{
+  char *udi; /* object_path */
+  char *interface;
+  char *driver;
+  uint capabilities;
+  int  ip4address;
+  uint state;
+  char *ip4config; /* object_path */
+  int  carrier;
+  uint type;
+};
+
+typedef struct E_NM_Device_Wireless E_NM_Device_Wireless;
+struct E_NM_Device_Wireless
+{
+  char *hwaddress;
+  int   mode;
+  uint bitrate;
+  char *activeaccesspoint; /* object_path */
+  uint wirelesscapabilities;
+};
+
+typedef struct E_NM_Device_Wired E_NM_Device_Wired;
+struct E_NM_Device_Wired
+{
+  char *hwaddress;
+  uint speed;
+};
+
+typedef struct E_NM_Access_Point E_NM_Access_Point;
+struct E_NM_Access_Point
+{
+  uint flags;
+  uint wpaflags;
+  uint rsnflags;
+  char *ssid;
+  uint frequency;
+  char *hwaddress;
+  int  mode;
+  uint rate;
+  uint strength;
+};
+
+typedef struct E_NM_IP4Config E_NM_IP4Config;
+struct E_NM_IP4Config
+{
+  uint address;
+  uint gateway;
+  uint netmask;
+  uint broadcast;
+  char *hostname;
+  Ecore_List *nameserver;  /* uints */
+  Ecore_List *domains; /* char* */
+  char *nisdomain;
+  Ecore_List *nisserver; /* uints */
+};
+
+typedef struct E_NM_Manager E_NM_Manager;
+struct E_NM_Manager
+{
+  int wirelessenabled; /* writeable*/
+  int wirelesshardwareenabled;
+  uint state;
+};
+
+typedef void (*E_NM_Cb_Manager_State_Change) (void *data, int state);
+typedef void (*E_NM_Cb_Manager_Device_Added) (void *data, const char *device);
+typedef void (*E_NM_Cb_Manager_Device_Removed) (void *data, const char *device);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+   EAPI E_NM_Context *e_nm_new(void);
+   EAPI void          e_nm_free(E_NM_Context *ctx);
+
+
+/**
+ * A callback function for a Network Manager call
+ * @param user_data the data passed in to the method call
+ * @param event_data a struct containing the return data.
+ *
+ * For method calls, the return structs use the following naming convention:
+ *   E_NM_<Interface>_<Method_Call_Name>_Return
+ */
+
+/* org.freedesktop.NetworkManager api */
+/* methods */
+   EAPI int e_nm_get_devices(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_get_active_device(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data);
+/* TODO: EAPI int e_nm_set_active_device() */
+   EAPI int e_nm_status(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data);
+/* signals */
+/* TODO: These have changed! */
+   /* deprecated */EAPI void e_nm_callback_manager_state_change_set(E_NM_Context *ctx, E_NM_Cb_Manager_State_Change cb_func, void *user_data);
+   /* deprecated */EAPI void e_nm_callback_manager_device_added_set(E_NM_Context *ctx, E_NM_Cb_Manager_Device_Added cb_func, void *user_data);
+   /* deprecated */EAPI void e_nm_callback_manager_device_removed_set(E_NM_Context *ctx, E_NM_Cb_Manager_Device_Removed cb_func, void *user_data);
+/* TODO: EAPI void e_nm_callback_device_no_longer_active() */
+/* TODO: EAPI void e_nm_callback_device_now_active() */
+/* TODO: EAPI void e_nm_callback_device_activating() */
+/* TODO: EAPI void e_nm_callback_devices_changed() */
+/* TODO: EAPI void e_nm_callback_device_activation_failed() */
+/* TODO: EAPI void e_nm_callback_device_strength_changed() */
+/* TODO: EAPI void e_nm_callback_device_ipv4_address_changed() */
+/* TODO: EAPI void e_nm_callback_wireless_network_appeared() */
+/* TODO: EAPI void e_nm_callback_wireless_network_disappeared() */
+
+
+/* org.freedesktop.NetworkManager.Device api */
+   EAPI int e_nm_device_get_udi(E_NM_Context *ctx, const char *device,
+                                E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_interface(E_NM_Context *ctx, const char *device,
+                                      E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_driver(E_NM_Context *ctx, const char *device,
+                                   E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_capabilities(E_NM_Context *ctx, const char *device,
+                                         E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_ip4address(E_NM_Context *ctx, const char *device,
+                                       E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_state(E_NM_Context *ctx, const char *device,
+                                  E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_ip4config(E_NM_Context *ctx, const char *device,
+                                      E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_carrier(E_NM_Context *ctx, const char *device,
+                                    E_DBus_Callback_Func cb_func, void *data);
+   EAPI int e_nm_device_get_type(E_NM_Context *ctx, const char *device,
+                                 E_DBus_Callback_Func cb_func, void *data);
+
+/* org.freedesktop.NetworkManager.Devices api */
+/* TODO: EAPI int e_nm_network_get_name() */
+/* TODO: EAPI int e_nm_network_get_address() */
+/* TODO: EAPI int e_nm_network_get_strength() */
+/* TODO: EAPI int e_nm_network_get_frequency() */
+/* TODO: EAPI int e_nm_network_get_rate() */
+/* TODO: EAPI int e_nm_network_get_encrypted() */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/nm/Makefile.am b/src/lib/nm/Makefile.am
new file mode 100644 (file)
index 0000000..dc2ff55
--- /dev/null
@@ -0,0 +1,30 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I $(top_srcdir)/src/lib/dbus \
+@EDBUS_CFLAGS@
+
+if BUILD_ENM
+
+lib_LTLIBRARIES = libenm.la
+include_HEADERS = E_Nm.h
+
+libenm_la_SOURCES = \
+e_nm_private.h \
+e_nm.c \
+e_nm_manager.c \
+e_nm_device.c \
+e_nm_network.c \
+e_nm_util.c
+
+
+libenm_la_LIBADD = \
+@EDBUS_LIBS@ \
+$(top_builddir)/src/lib/dbus/libedbus.la
+libenm_la_LDFLAGS      = -version-info @version_info@
+
+
+libenm_la_DEPENDENCIES = \
+$(top_builddir)/src/lib/dbus/libedbus.la
+
+endif
diff --git a/src/lib/nm/README b/src/lib/nm/README
new file mode 100644 (file)
index 0000000..e4b566f
--- /dev/null
@@ -0,0 +1,2 @@
+This depends on NetworkManager 0.7, which was unrealeased as of 2007-03-20.
+It is only a start, and can't really be finished until the NetworkManagerInfo interface is reworked. So, for now, ignore it :)
diff --git a/src/lib/nm/e_nm.c b/src/lib/nm/e_nm.c
new file mode 100644 (file)
index 0000000..82da6f1
--- /dev/null
@@ -0,0 +1,120 @@
+#include "E_Nm.h"
+#include "e_nm_private.h"
+
+EAPI E_NM_Context *
+e_nm_new(void)
+{
+  E_NM_Context *ctx;
+
+  ctx = calloc(1, sizeof(E_NM_Context));
+  if (!ctx) return NULL;
+
+  ctx->conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+  if (!ctx->conn)
+    goto error;
+
+  return ctx;
+
+error:
+  free(ctx);
+  return NULL;
+
+}
+
+EAPI void
+e_nm_free(E_NM_Context *ctx)
+{
+  e_dbus_connection_close(ctx->conn);
+  free(ctx);
+}
+
+static void
+cb_signal_manager_state_change(void *data, DBusMessage *msg)
+{
+  E_NM_Context *ctx;
+  dbus_uint32_t state;
+  DBusError err;
+  if (!msg || !data) return;
+
+  ctx = data;
+  dbus_error_init(&err);
+  dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(&err))
+  {
+    printf("Error: %s - %s\n", err.name, err.message);
+    return;
+  }
+
+  if (ctx->cb_manager_state_change)
+    ctx->cb_manager_state_change(ctx->data_manager_state_change, (int)state);
+}
+
+static void
+cb_signal_manager_device_added(void *data, DBusMessage *msg)
+{
+  E_NM_Context *ctx;
+  const char *device;
+  DBusError err;
+  if (!msg || !data) return;
+
+  ctx = data;
+  dbus_error_init(&err);
+  dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &device, DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(&err))
+  {
+    printf("Error: %s - %s\n", err.name, err.message);
+    return;
+  }
+
+  if (ctx->cb_manager_device_added)
+    ctx->cb_manager_device_added(ctx->data_manager_device_added, device);
+}
+
+static void
+cb_signal_manager_device_removed(void *data, DBusMessage *msg)
+{
+  E_NM_Context *ctx;
+  const char *device;
+  DBusError err;
+  if (!msg || !data) return;
+
+  ctx = data;
+  dbus_error_init(&err);
+  dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &device, DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(&err))
+  {
+    printf("Error: %s - %s\n", err.name, err.message);
+    return;
+  }
+
+  if (ctx->cb_manager_device_removed)
+    ctx->cb_manager_device_removed(ctx->data_manager_device_removed, device);
+}
+
+
+EAPI void
+e_nm_callback_manager_state_change_set(E_NM_Context *ctx, E_NM_Cb_Manager_State_Change cb_func, void *user_data)
+{
+  ctx->cb_manager_state_change = cb_func;
+  ctx->data_manager_state_change = user_data;
+
+  e_dbus_signal_handler_add(ctx->conn, E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, "StateChange", cb_signal_manager_state_change, ctx);
+}
+
+EAPI void
+e_nm_callback_manager_device_added_set(E_NM_Context *ctx, E_NM_Cb_Manager_Device_Added cb_func, void *user_data)
+{
+  ctx->cb_manager_device_added = cb_func;
+  ctx->data_manager_device_added = user_data;
+
+  e_dbus_signal_handler_add(ctx->conn, E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, "DeviceAdded", cb_signal_manager_device_added, ctx);
+}
+
+EAPI void
+e_nm_callback_manager_device_removed_set(E_NM_Context *ctx, E_NM_Cb_Manager_Device_Removed cb_func, void *user_data)
+{
+  ctx->cb_manager_device_removed = cb_func;
+  ctx->data_manager_device_removed = user_data;
+
+  e_dbus_signal_handler_add(ctx->conn, E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, "DeviceRemoved", cb_signal_manager_device_removed, ctx);
+}
diff --git a/src/lib/nm/e_nm_device.c b/src/lib/nm/e_nm_device.c
new file mode 100644 (file)
index 0000000..1af65e0
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * This file defines functions that query each of the functions provided by
+ * the org.freedesktop.NetworkManager.Device DBus interface.
+ */
+
+#include "E_Nm.h"
+#include "e_nm_private.h"
+#include <Ecore_Data.h>
+
+
+/**
+ * Get the UDI of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_udi(E_NM_Context *ctx, const char *device,
+                    E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Udi", cb_func, data);
+}
+
+
+/**
+ * Get the interface name of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_interface(E_NM_Context *ctx, const char *device,
+                          E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Interface", cb_func, data);
+}
+
+
+/**
+ * Get the driver name of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_driver(E_NM_Context *ctx, const char *device,
+                       E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Driver", cb_func, data);
+}
+
+
+/**
+ * Get the capabilities of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_capabilities(E_NM_Context *ctx, const char *device,
+                             E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Capabilities", cb_func, data);
+}
+
+
+/**
+ * Get the IPv4 address of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_ip4address(E_NM_Context *ctx, const char *device,
+                           E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Ip4Address", cb_func, data);
+}
+
+
+/**
+ * Get the state of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_state(E_NM_Context *ctx, const char *device,
+                      E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "State", cb_func, data);
+}
+
+
+/**
+ * Get the IPv4 config object path of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_ip4config(E_NM_Context *ctx, const char *device,
+                          E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Ip4Config", cb_func, data);
+}
+
+
+/**
+ * Get the carrier status of a NetworkManager device
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_carrier(E_NM_Context *ctx, const char *device,
+                        E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "Carrier", cb_func, data);
+}
+
+
+/**
+ * Return the type of a an NM device:
+ *
+ * 0: unknown
+ * 1: wired
+ * 2: wireless
+ *
+ * @param ctx an e_nm context
+ * @param device a NetworkManager device to communicate with
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ */
+EAPI int
+e_nm_device_get_type(E_NM_Context *ctx, const char *device, 
+                     E_DBus_Callback_Func cb_func, void *data)
+{
+  /* FIXME: Decide how to handle the return value for this functions */
+  e_nm_device_properties_get(ctx->conn, device, "DeviceType", cb_func, data);
+}
diff --git a/src/lib/nm/e_nm_manager.c b/src/lib/nm/e_nm_manager.c
new file mode 100644 (file)
index 0000000..265249e
--- /dev/null
@@ -0,0 +1,76 @@
+#include "E_Nm.h"
+#include "e_nm_private.h"
+
+
+/**
+ * Get all network devices.
+ *
+ * Returns an Ecore_List of dbus object paths for network devices. This list is
+ * of const char *, and is freed automatically after the callback returns.
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+EAPI int
+e_nm_get_devices(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_nm_manager_call_new("GetDevices");
+
+  ret = e_dbus_method_call_send(ctx->conn, msg, cb_nm_string_list, cb_func, free_nm_string_list, -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+
+/**
+ * Find the active device that NM has chosen
+ * 
+ * Returns a single string containing the dbus path to the active device
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+EAPI int
+e_nm_get_active_device(E_NM_Context *ctx, E_DBus_Callback_Func cb_func,
+                       void *data)
+{
+  return e_nm_get_from_nm(ctx, cb_func, data,
+                          "getActiveDevice", DBUS_TYPE_STRING);
+}
+
+
+/**
+ * Query the current state of the network
+ * 
+ * Returns a single string containing the status:
+ *
+ *  "connecting":  there is a pending network connection (waiting for a DHCP
+ *                  request to complete, waiting for an encryption
+ *                  key/passphrase, waiting for a wireless network, etc)
+ *
+ *  "connected":    there is an active network connection
+ *
+ *  "scanning":     there is no active network connection, but NetworkManager
+ *                  is looking for an access point to associate with
+ *
+ *  "disconnected": there is no network connection
+ * 
+ *
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+EAPI int
+e_nm_status(E_NM_Context *ctx, E_DBus_Callback_Func cb_func,
+                       void *data)
+{
+
+  return e_nm_get_from_nm(ctx, cb_func, data,
+                          "status", DBUS_TYPE_STRING);
+}
diff --git a/src/lib/nm/e_nm_network.c b/src/lib/nm/e_nm_network.c
new file mode 100644 (file)
index 0000000..1f37a80
--- /dev/null
@@ -0,0 +1,96 @@
+#include "E_Nm.h"
+#include "e_nm_private.h"
+
+/**
+ * Get the ESSID of a wireless network
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+int
+e_nm_network_get_name(E_NM_Context *ctx, const char *device,
+                      E_DBus_Callback_Func cb_func, void *data)
+{
+  return e_nm_get_from_device(ctx, device, cb_func, data, "getName",
+                              DBUS_TYPE_STRING);
+}
+
+/**
+ * Get the MAC address of a wireless network's AP
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+int
+e_nm_network_get_address(E_NM_Context *ctx, const char *device,
+                         E_DBus_Callback_Func cb_func, void *data)
+{
+  return e_nm_get_from_device(ctx, device, cb_func, data, "getAddress",
+                              DBUS_TYPE_STRING);
+}
+
+
+/**
+ * Get the strength of the network; given out of 100
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+int
+e_nm_network_get_strength(E_NM_Context *ctx, const char *device,
+                          E_DBus_Callback_Func cb_func, void *data)
+{
+  return e_nm_get_from_device(ctx, device, cb_func, data, "getStrength",
+                              DBUS_TYPE_INT32);
+}
+
+
+/**
+ * Get the frequency of the network; given in GHz
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+int
+e_nm_network_get_frequency(E_NM_Context *ctx, const char *device,
+                           E_DBus_Callback_Func cb_func, void *data)
+{
+  return e_nm_get_from_device(ctx, device, cb_func, data, "getFrequency",
+                              DBUS_TYPE_DOUBLE);
+}
+
+
+/**
+ * Get the data rate of the network; given in Mbps
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+int
+e_nm_network_get_rate(E_NM_Context *ctx, const char *device,
+                         E_DBus_Callback_Func cb_func, void *data)
+{
+  return e_nm_get_from_device(ctx, device, cb_func, data, "getRate",
+                              DBUS_TYPE_INT32);
+}
+
+
+/**
+ * Return true if the network requires encryption
+ *
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ **/
+int
+e_nm_network_get_encryption(E_NM_Context *ctx, const char *device,
+                            E_DBus_Callback_Func cb_func, void *data)
+{
+  return e_nm_get_from_device(ctx, device, cb_func, data, "getEncryption",
+                              DBUS_TYPE_BOOLEAN);
+}
diff --git a/src/lib/nm/e_nm_private.h b/src/lib/nm/e_nm_private.h
new file mode 100644 (file)
index 0000000..b7970c9
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef E_NM_PRIVATE_H
+#define E_NM_PRIVATE_H
+
+#define E_NM_SERVICE "org.freedesktop.NetworkManager"
+#define E_NM_PATH_NETWORK_MANAGER "/org/freedesktop/NetworkManager"
+#define E_NM_INTERFACE_NETWORK_MANAGER "org.freedesktop.NetworkManager"
+#define E_NM_INTERFACE_ACCESSPOINT "org.freedesktop.NetworkManager.AccessPoint"
+#define E_NM_INTERFACE_DEVICE "org.freedesktop.NetworkManager.Device"
+#define E_NM_INTERFACE_DEVICE_WIRELESS "org.freedesktop.NetworkManager.Device.Wireless"
+#define E_NM_INTERFACE_DEVICE_WIRED "org.freedesktop.NetworkManager.Device.Wired"
+#define E_NM_INTERFACE_IP4CONFIG "org.freedesktop.NetworkManager.IP4Config"
+
+#define e_nm_manager_call_new(member) dbus_message_new_method_call(E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, member)
+
+#define e_nm_device_call_new(path, member) dbus_message_new_method_call(E_NM_SERVICE, path, E_NM_INTERFACE_DEVICE, member)
+
+#define e_nm_network_call_new(member) dbus_message_new_method_call(E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, member)
+
+#define e_nm_device_properties_get(con, dev, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, dev, E_NM_INTERFACE_DEVICE, prop, (E_DBus_Method_Return_Cb) cb, data)
+
+struct E_NM_Context
+{
+  E_DBus_Connection *conn;
+
+  E_NM_Cb_Manager_State_Change cb_manager_state_change;
+  void *data_manager_state_change;
+
+  E_NM_Cb_Manager_Device_Added cb_manager_device_added;
+  void *data_manager_device_added;
+
+  E_NM_Cb_Manager_Device_Removed cb_manager_device_removed;
+  void *data_manager_device_removed;
+};
+
+
+int e_nm_get_from_nm(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data,
+                     const char *method, int rettype);
+int e_nm_get_from_device(E_NM_Context *ctx, const char *device,
+                         E_DBus_Callback_Func cb_func, void *data,
+                         const char *method, int rettype);
+
+void *cb_nm_generic(DBusMessage *msg, DBusError *err);
+void  free_nm_generic(void *data);
+void *cb_nm_int32(DBusMessage *msg, DBusError *err);
+void *cb_nm_uint32(DBusMessage *msg, DBusError *err);
+void *cb_nm_string(DBusMessage *msg, DBusError *err);
+void *cb_nm_boolean(DBusMessage *msg, DBusError *err);
+void *cb_nm_string_list(DBusMessage *msg, DBusError *err);
+void  free_nm_string_list(void *data);
+#endif
diff --git a/src/lib/nm/e_nm_util.c b/src/lib/nm/e_nm_util.c
new file mode 100644 (file)
index 0000000..740186e
--- /dev/null
@@ -0,0 +1,232 @@
+#include "E_Nm.h"
+#include "e_nm_private.h"
+#include "E_DBus.h"
+#include <string.h>
+#include <Ecore_Data.h>
+
+/**
+ * @internal
+ * @brief returns an e_dbus callback for a given dbus type
+ * @param rettype the return type we want to find a callback for
+ **/
+static E_DBus_Unmarshal_Func
+e_nm_callback_by_type(int rettype)
+{
+  switch (rettype)
+  {
+    case DBUS_TYPE_STRING:
+      return cb_nm_string;
+      
+    case DBUS_TYPE_INT32:
+      return cb_nm_int32;
+      
+    case DBUS_TYPE_UINT32:
+      return cb_nm_uint32;
+      
+    case DBUS_TYPE_BOOLEAN:
+      return cb_nm_boolean;
+
+    default:
+      return cb_nm_generic;
+  }
+}
+
+/**
+ * @internal
+ * @brief returns an e_dbus free for a given dbus type
+ * @param rettype the return type we want to find a free for
+ **/
+static E_DBus_Free_Func
+e_nm_free_by_type(int rettype)
+{
+  switch (rettype)
+  {
+    case DBUS_TYPE_STRING:
+      return NULL;
+    case DBUS_TYPE_INT32:
+    case DBUS_TYPE_UINT32:
+    case DBUS_TYPE_BOOLEAN:
+    default:
+      return free_nm_generic;
+  }
+}
+
+/**
+ * @internal
+ * @brief Send "get" messages to NetworkManager via e_dbus
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ * @param method the name of the method that should be called
+ * @param rettype the type of the data that will be returned to the callback
+ **/
+int
+e_nm_get_from_nm(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data,
+                 const char *method, int rettype)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_nm_manager_call_new(method);
+  ret = e_dbus_method_call_send(ctx->conn, msg, e_nm_callback_by_type(rettype),
+                                cb_func, e_nm_free_by_type(rettype), -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+
+/**
+ * @internal
+ * @brief Send "get" messages to a Device via e_dbus
+ * @param ctx an e_nm context
+ * @param cb a callback, used when the method returns (or an error is received)
+ * @param data user data to pass to the callback function
+ * @param method the name of the method that should be called
+ * @param rettype the type of the data that will be returned to the callback
+ **/
+int
+e_nm_get_from_device(E_NM_Context *ctx, const char *device,
+                     E_DBus_Callback_Func cb_func, void *data,
+                     const char *method, int rettype)
+{
+  DBusMessage *msg;
+  int ret;
+
+  msg = e_nm_device_call_new(device, method);
+  ret = e_dbus_method_call_send(ctx->conn, msg, e_nm_callback_by_type(rettype),
+                                cb_func,
+                               e_nm_free_by_type(rettype),
+                               -1, data) ? 1 : 0;
+  dbus_message_unref(msg);
+  return ret;
+}
+
+/**
+ * @internal
+ * @brief Generic callback for methods that return nothing
+ */
+void *
+cb_nm_generic(DBusMessage *msg, DBusError *err)
+{
+  return NULL;
+}
+
+/**
+ * @internal
+ * @brief Generic free for methods
+ */
+void
+free_nm_generic(void *data)
+{
+  if (!data) return;
+  free(data);
+}
+
+/**
+ * @internal
+ * @brief Callback for methods that return DBUS_TYPE_INT32
+ */
+void *
+cb_nm_int32(DBusMessage *msg, DBusError *err)
+{
+  dbus_int32_t *i;
+
+  i = malloc(sizeof(dbus_int32_t));
+  /* Actually emit the integer */
+  dbus_message_get_args(msg, err,
+                        DBUS_TYPE_INT32, i,
+                        DBUS_TYPE_INVALID);
+
+  return i;
+}
+
+/**
+ * @internal
+ * @brief Callback for methods that return DBUS_TYPE_UINT32
+ */
+void *
+cb_nm_uint32(DBusMessage *msg, DBusError *err)
+{
+  dbus_uint32_t *i;
+
+  i = malloc(sizeof(dbus_uint32_t));
+  /* Actually emit the unsigned integer */
+  dbus_message_get_args(msg, err,
+                        DBUS_TYPE_UINT32, i,
+                        DBUS_TYPE_INVALID);
+
+  return i;
+}
+
+/**
+ * @internal
+ * @brief Callback for methods that return DBUS_TYPE_BOOLEAN
+ */
+void *
+cb_nm_boolean(DBusMessage *msg, DBusError *err)
+{
+  dbus_bool_t *i;
+
+  i = malloc(sizeof(dbus_bool_t));
+  /* Actually emit the unsigned integer */
+  dbus_message_get_args(msg, err,
+                        DBUS_TYPE_BOOLEAN, i,
+                        DBUS_TYPE_INVALID);
+  
+  return i;
+}
+
+/**
+ * @internal
+ * @brief Callback for methods returning a single string
+ */
+void *
+cb_nm_string(DBusMessage *msg, DBusError *err)
+{
+  char *str;
+
+  /* Actually emit the string */
+  dbus_message_get_args(msg, err,
+                        DBUS_TYPE_STRING, &str,
+                        DBUS_TYPE_INVALID);
+
+  return str;
+}
+
+
+/**
+ * @internal
+ * @brief Callback for methods returning a list of strings or object paths
+ */
+void *
+cb_nm_string_list(DBusMessage *msg, DBusError *err)
+{
+  Ecore_List *devices;
+  DBusMessageIter iter, sub;
+
+  dbus_message_iter_init(msg, &iter);
+  if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
+      dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_OBJECT_PATH) return NULL;
+
+  devices = ecore_list_new();
+  dbus_message_iter_recurse(&iter, &sub);
+  while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID)
+  {
+    char *dev = NULL;
+
+    dbus_message_iter_get_basic(&sub, &dev);
+    if (dev) ecore_list_append(devices, dev);
+    dbus_message_iter_next(&sub);
+  }
+
+  return devices;
+}
+
+void
+free_nm_string_list(void *data)
+{
+  Ecore_List *list = data;
+
+  if (list) ecore_list_destroy(list);
+}
+
diff --git a/src/lib/notification/.cvsignore b/src/lib/notification/.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/notification/E_Notification_Daemon.h b/src/lib/notification/E_Notification_Daemon.h
new file mode 100644 (file)
index 0000000..5a4a113
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef E_NOTIFICATION_DAEMON_H
+#define E_NOTIFICATION_DAEMON_H
+
+#define E_NOTIFICATION_DAEMON_VERSION "0.9"
+
+#include <E_Notify.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
+
+
+typedef struct E_Notification_Daemon E_Notification_Daemon;
+
+/* daemon callbacks */
+typedef int (*E_Notification_Daemon_Callback_Notify) (E_Notification_Daemon *daemon, E_Notification *notification);
+typedef void (*E_Notification_Daemon_Callback_Close_Notification) (E_Notification_Daemon *daemon, unsigned int notification_id);
+
+/* gui */
+typedef struct E_Notification_View E_Notification_View;
+
+struct E_Notification_Daemon
+{
+  E_DBus_Connection *conn;
+  E_DBus_Interface *iface;
+  E_DBus_Object *obj;
+
+  char *name;
+  char *vendor;
+
+  struct 
+  {
+    E_Notification_Daemon_Callback_Notify notify;
+    E_Notification_Daemon_Callback_Close_Notification close_notification;
+  } func;
+  void *data;
+
+  int state;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* daemon */
+   EAPI E_Notification_Daemon *e_notification_daemon_add(const char *name, const char *vendor);
+   EAPI void e_notification_daemon_free(E_Notification_Daemon *d);
+/* TODO
+   void e_notification_daemon_close(E_Notification_Daemon *d,
+   E_Notification *n, unsigned int reason);
+   void e_notification_daemon_action_invoke(E_Notification_Daemon *d,
+   E_Notification *n, const char *action_id);
+*/
+
+   EAPI void  e_notification_daemon_data_set(E_Notification_Daemon *daemon, void *data);
+   EAPI void *e_notification_daemon_data_get(E_Notification_Daemon *daemon);
+
+   EAPI void e_notification_daemon_callback_notify_set(E_Notification_Daemon *daemon, E_Notification_Daemon_Callback_Notify func);
+   EAPI void e_notification_daemon_callback_close_notification_set(E_Notification_Daemon *daemon, E_Notification_Daemon_Callback_Close_Notification func);
+
+   EAPI void e_notification_daemon_signal_notification_closed(E_Notification_Daemon *daemon, unsigned int id, E_Notification_Closed_Reason reason);
+   EAPI void e_notification_daemon_signal_action_invoked(E_Notification_Daemon *daemon, unsigned int notification_id, const char *action_id);
+
+/***** gui *****/
+/* TODO
+   E_Notification_View *e_notification_view_add(E_Notification_Daemon *d, E_Notification *n);
+   void e_notification_view_close(E_Notification_View *nv);
+   Evas_Object * e_notification_view_icon_get(Evas *evas, E_Notification *n);
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/notification/E_Notify.h b/src/lib/notification/E_Notify.h
new file mode 100644 (file)
index 0000000..36bcbd2
--- /dev/null
@@ -0,0 +1,188 @@
+#ifndef E_NOTIFY_H
+#define E_NOTIFY_H
+
+#include <Ecore_Data.h>
+#include <Evas.h>
+#include <E_DBus.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
+
+
+/* notifications */
+typedef struct E_Notification_Image E_Notification_Image;
+typedef struct E_Notification E_Notification;
+typedef struct E_Notification_Action E_Notification_Action;
+
+typedef enum E_Notification_Urgency E_Notification_Urgency;
+typedef enum E_Notification_Hint_Type E_Notification_Hint_Type;
+typedef enum E_Notification_Closed_Reason E_Notification_Closed_Reason;
+
+/* method returns */
+typedef struct E_Notification_Return_Notify E_Notification_Return_Notify;
+typedef struct E_Notification_Return_Get_Capabilities E_Notification_Return_Get_Capabilities;
+typedef struct E_Notification_Return_Get_Server_Information E_Notification_Return_Get_Server_Information;
+
+
+/* signal events */
+typedef struct E_Notification_Event_Action_Invoked E_Notification_Event_Action_Invoked;
+typedef struct E_Notification_Event_Notification_Closed E_Notification_Event_Notification_Closed;
+
+/* enums */
+
+enum E_Notification_Urgency
+{
+  E_NOTIFICATION_URGENCY_LOW,
+  E_NOTIFICATION_URGENCY_NORMAL,
+  E_NOTIFICATION_URGENCY_CRITICAL
+};
+
+enum E_Notification_Closed_Reason
+{
+  E_NOTIFICATION_CLOSED_EXPIRED,
+  E_NOTIFICATION_CLOSED_DISMISSED,
+  E_NOTIFICATION_CLOSED_REQUESTED,
+  E_NOTIFICATION_CLOSED_UNDEFINED
+};
+
+enum E_Notification_Hint_Type
+{
+  E_NOTIFICATION_HINT_URGENCY        = 0x1,
+  E_NOTIFICATION_HINT_CATEGORY       = 0x2,
+  E_NOTIFICATION_HINT_DESKTOP        = 0x4,
+  E_NOTIFICATION_HINT_SOUND_FILE     = 0x8,
+  E_NOTIFICATION_HINT_SUPPRESS_SOUND = 0x10,
+  E_NOTIFICATION_HINT_XY             = 0x20,
+  E_NOTIFICATION_HINT_IMAGE_DATA     = 0x40
+};
+
+/* client method returns */
+struct E_Notification_Return_Notify
+{
+  unsigned int notification_id;
+  E_Notification *notification;
+};
+
+struct E_Notification_Return_Get_Capabilities
+{
+  Ecore_List *capabilities;
+};
+
+struct E_Notification_Return_Get_Server_Information
+{
+  const char *name;
+  const char *vendor;
+  const char *version;
+};
+
+/* signals */
+struct E_Notification_Event_Notification_Closed
+{
+  unsigned int notification_id;
+  E_Notification_Closed_Reason reason;
+};
+
+struct E_Notification_Event_Action_Invoked
+{
+  unsigned int notification_id;
+  char *action_id;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+   EAPI int e_notification_init();
+   EAPI int e_notification_shutdown();
+
+/* client */
+   EAPI void e_notification_send(E_Notification *n, E_DBus_Callback_Func func, void *data);
+   EAPI void e_notification_get_capabilities(E_DBus_Callback_Func func, void *data);
+   EAPI void e_notification_get_server_information(E_DBus_Callback_Func func, void *data);
+
+
+/* Notifications */
+
+   EAPI E_Notification *e_notification_new();
+   EAPI void e_notification_ref(E_Notification *n);
+   EAPI void e_notification_unref(E_Notification *n);
+   EAPI void e_notification_free(E_Notification *n);
+
+   EAPI E_Notification *e_notification_full_new(const char *app_name,
+                                                unsigned int replaces_id,
+                                                const char *app_icon,
+                                                const char *summary,
+                                                const char *body,
+                                                int expire_timeout);
+
+/* notification mutators */
+   EAPI void e_notification_id_set(E_Notification *note, unsigned int id);
+   EAPI void e_notification_app_name_set(E_Notification *n, const char *app_name);
+   EAPI void e_notification_app_icon_set(E_Notification *n, const char *app_icon);
+   EAPI void e_notification_summary_set(E_Notification *n, const char *summary);
+   EAPI void e_notification_body_set(E_Notification *n, const char *body);
+   EAPI void e_notification_replaces_id_set(E_Notification *n, int replaces_id);
+   EAPI void e_notification_timeout_set(E_Notification *n, int timeout);
+   EAPI void e_notification_closed_set(E_Notification *note, unsigned char closed);
+
+/* notification accessors */
+   EAPI unsigned int e_notification_id_get(E_Notification *note);
+   EAPI const char *e_notification_app_name_get(E_Notification *n);
+   EAPI const char *e_notification_app_icon_get(E_Notification *n);
+   EAPI const char *e_notification_summary_get(E_Notification *n);
+   EAPI const char *e_notification_body_get(E_Notification *n);
+   EAPI int e_notification_replaces_id_get(E_Notification *note);
+   EAPI int e_notification_timeout_get(E_Notification *note);
+   EAPI unsigned char e_notification_closed_get(E_Notification *note);
+
+/* actions */
+   EAPI void e_notification_action_add(E_Notification *n, const char *action_id, const char *action_name);
+   EAPI Ecore_List *e_notification_actions_get(E_Notification *n);
+
+/* hint mutators */
+   EAPI void e_notification_hint_urgency_set(E_Notification *n, char urgency);
+   EAPI void e_notification_hint_category_set(E_Notification *n, const char *category);
+   EAPI void e_notification_hint_desktop_set(E_Notification *n, const char *desktop);
+   EAPI void e_notification_hint_sound_file_set(E_Notification *n, const char *sound_file);
+   EAPI void e_notification_hint_suppress_sound_set(E_Notification *n, char suppress_sound);
+   EAPI void e_notification_hint_xy_set(E_Notification *n, int x, int y);
+   EAPI void e_notification_hint_image_data_set(E_Notification *n, E_Notification_Image *image);
+
+/* hint accessors */
+   EAPI char  e_notification_hint_urgency_get(E_Notification *n);
+   EAPI const char *e_notification_hint_category_get(E_Notification *n);
+   EAPI const char *e_notification_hint_desktop_get(E_Notification *n);
+   EAPI const char *e_notification_hint_sound_file_get(E_Notification *n);
+   EAPI char  e_notification_hint_suppress_sound_get(E_Notification *n);
+   EAPI int   e_notification_hint_xy_get(E_Notification *n, int *x, int *y);
+   EAPI E_Notification_Image *e_notification_hint_image_data_get(E_Notification *n);
+   EAPI E_Notification_Image *e_notification_hint_icon_data_get(E_Notification *n);
+
+/* image hint */
+   EAPI E_Notification_Image *e_notification_image_new();
+   EAPI void e_notification_image_free(E_Notification_Image *img);
+   EAPI Evas_Object *e_notification_image_evas_object_add(Evas *evas, E_Notification_Image *img);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/notification/Makefile.am b/src/lib/notification/Makefile.am
new file mode 100644 (file)
index 0000000..dd47d49
--- /dev/null
@@ -0,0 +1,26 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I $(top_srcdir)/src/lib/dbus \
+@EDBUS_CFLAGS@ @EVAS_CFLAGS@
+
+if BUILD_ENOTIFY
+
+lib_LTLIBRARIES = libenotify.la
+include_HEADERS = E_Notify.h E_Notification_Daemon.h
+
+libenotify_la_SOURCES = \
+E_Notify.h \
+E_Notification_Daemon.h \
+e_notify_private.h \
+notification.c \
+marshal.c \
+client.c \
+daemon.c
+
+libenotify_la_LIBADD = \
+@EDBUS_LIBS@ @EVAS_LIBS@ \
+$(top_builddir)/src/lib/dbus/libedbus.la
+libenotify_la_LDFLAGS      = -version-info @version_info@
+
+endif
diff --git a/src/lib/notification/client.c b/src/lib/notification/client.c
new file mode 100644 (file)
index 0000000..319702f
--- /dev/null
@@ -0,0 +1,61 @@
+#include "E_Notify.h"
+#include "e_notify_private.h"
+static E_DBus_Connection *client_conn;
+static int init_count = 0;
+  
+EAPI int
+e_notification_init(void)
+{
+  if (init_count) return ++init_count;
+
+  if (!e_dbus_init()) return 0;
+  client_conn = e_dbus_bus_get(DBUS_BUS_SESSION);
+  if (!client_conn)
+  {
+    e_dbus_shutdown();
+    return 0;
+  }
+
+  return ++init_count;
+}
+
+EAPI int
+e_notification_shutdown(void)
+{
+  if (--init_count) return init_count;
+  e_dbus_connection_close(client_conn);
+  client_conn = NULL;
+  e_dbus_shutdown();
+  return 0;
+}
+
+/**** client api ****/
+EAPI void
+e_notification_send(E_Notification *n, E_DBus_Callback_Func func, void *data)
+{
+  DBusMessage *msg;
+
+  msg = e_notify_marshal_notify(n);
+  e_dbus_method_call_send(client_conn, msg, e_notify_unmarshal_notify_return, func, e_notify_free_notify_return, -1, data);
+  dbus_message_unref(msg);
+}
+
+EAPI void
+e_notification_get_capabilities(E_DBus_Callback_Func func, void *data)
+{
+  DBusMessage *msg;
+
+  msg = e_notify_marshal_get_capabilities();
+  e_dbus_method_call_send(client_conn, msg, e_notify_unmarshal_get_capabilities_return, func, e_notify_free_get_capabilities_return, -1, data);
+  dbus_message_unref(msg);
+}
+
+EAPI void
+e_notification_get_server_information(E_DBus_Callback_Func func, void *data)
+{
+  DBusMessage *msg;
+
+  msg = e_notify_marshal_get_server_information();
+  e_dbus_method_call_send(client_conn, msg, e_notify_unmarshal_get_server_information_return, func, e_notify_free_get_server_information_return, -1, data);
+  dbus_message_unref(msg);
+}
diff --git a/src/lib/notification/daemon.c b/src/lib/notification/daemon.c
new file mode 100644 (file)
index 0000000..c7cfba9
--- /dev/null
@@ -0,0 +1,219 @@
+#include "E_Notify.h"
+#include "E_Notification_Daemon.h"
+#include "e_notify_private.h"
+#include <string.h>
+
+static int e_notification_daemon_bus_init(E_Notification_Daemon *daemon);
+static int e_notification_daemon_object_init(E_Notification_Daemon *daemon);
+
+DBusMessage *
+method_get_capabilities(E_DBus_Object *obj, DBusMessage *message)
+{
+  const char *capabilities[] = {
+    "body",
+    "actions",
+    NULL
+  };
+  return e_notify_marshal_get_capabilities_return(message, capabilities);
+}
+
+DBusMessage *
+method_notify(E_DBus_Object *obj, DBusMessage *message)
+{
+  E_Notification *n;
+  E_Notification_Daemon *daemon;
+  int id = -1;
+  
+  daemon = e_dbus_object_data_get(obj);
+  n = e_notify_unmarshal_notify(message, NULL);
+  if (daemon->func.notify)
+    id = daemon->func.notify(daemon, n);
+  else
+    return dbus_message_new_error(message, E_NOTIFICATION_INTERFACE".Unimplemented", "This functionality has not yet been implemented");
+
+  e_notification_unref(n);
+  return e_notify_marshal_notify_return(message, id);
+}
+
+DBusMessage *
+method_close_notification(E_DBus_Object *obj, DBusMessage *message)
+{
+  E_Notification_Daemon *daemon;
+  dbus_uint32_t id;
+
+  daemon = e_dbus_object_data_get(obj);
+  id = e_notify_unmarshal_close_notification(message, NULL);
+  if (daemon->func.close_notification)
+    daemon->func.close_notification(daemon, id);
+  return dbus_message_new_method_return(message);
+}
+
+DBusMessage *
+method_get_server_information(E_DBus_Object *obj, DBusMessage *message)
+{
+  E_Notification_Daemon *daemon;
+
+  daemon = e_dbus_object_data_get(obj);
+
+  return e_notify_marshal_get_server_information_return(message, daemon->name, daemon->vendor, E_NOTIFICATION_DAEMON_VERSION);
+}
+
+
+/**** daemon api ****/
+
+
+EAPI E_Notification_Daemon *
+e_notification_daemon_add(const char *name, const char *vendor)
+{
+  E_Notification_Daemon *daemon;
+
+  if (!e_dbus_init()) return NULL;
+  daemon = calloc(1, sizeof(E_Notification_Daemon));
+  if (daemon)
+    e_notification_daemon_bus_init(daemon);
+
+  if (!daemon || !daemon->conn)
+  {
+    if (daemon) free(daemon);
+    e_dbus_shutdown();
+    return NULL;
+  }
+
+  daemon->name = strdup(name);
+  daemon->vendor = strdup(vendor);
+
+  daemon->iface = e_dbus_interface_new(E_NOTIFICATION_INTERFACE);
+  e_dbus_interface_method_add(daemon->iface, "GetCapabilities", "", "as", method_get_capabilities);
+  e_dbus_interface_method_add(daemon->iface, "Notify", "susssasa{sv}i", "u", method_notify);
+  e_dbus_interface_method_add(daemon->iface, "CloseNotification", "u", "u", method_close_notification);
+  e_dbus_interface_method_add(daemon->iface, "GetServerInformation", "", "sss", method_get_server_information);
+
+  return daemon;
+}
+
+
+EAPI void
+e_notification_daemon_free(E_Notification_Daemon *daemon)
+{
+  e_dbus_release_name(daemon->conn, E_NOTIFICATION_BUS_NAME, NULL, NULL);
+  if (daemon->obj) 
+    {
+      e_dbus_object_interface_detach(daemon->obj, daemon->iface);
+      e_dbus_object_free(daemon->obj);
+    }
+  if (daemon->conn) e_dbus_connection_close(daemon->conn);
+  if (daemon->name) free(daemon->name);
+  if (daemon->vendor) free(daemon->vendor);
+  if (daemon->iface) e_dbus_interface_unref(daemon->iface);
+  free(daemon);
+  e_dbus_shutdown();
+}
+
+EAPI void
+e_notification_daemon_data_set(E_Notification_Daemon *daemon, void *data)
+{
+  daemon->data = data;
+}
+
+EAPI void *
+e_notification_daemon_data_get(E_Notification_Daemon *daemon)
+{
+  return daemon->data;
+}
+
+EAPI void
+e_notification_daemon_callback_notify_set(E_Notification_Daemon *daemon, E_Notification_Daemon_Callback_Notify func)
+{
+  daemon->func.notify = func;
+}
+
+EAPI void
+e_notification_daemon_callback_close_notification_set(E_Notification_Daemon *daemon, E_Notification_Daemon_Callback_Close_Notification func)
+{
+  daemon->func.close_notification = func;
+}
+
+
+static void
+cb_request_name(void *data, DBusMessage *msg, DBusError *err)
+{
+  E_Notification_Daemon *daemon = data;
+  dbus_uint32_t ret;
+  DBusError new_err;
+
+  if (dbus_error_is_set(err))
+  {
+    printf("Error (request_name): %s\n", err->message);
+    dbus_error_free(err);
+    return;
+  }
+
+  printf("received response with signature: '%s'\n", dbus_message_get_signature(msg));
+  dbus_error_init(&new_err);
+  dbus_message_get_args(msg, &new_err, DBUS_TYPE_UINT32, &ret, DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(&new_err))
+  {
+    printf("Error (req name unmarshal): %s\n", new_err.message);
+    dbus_error_free(&new_err);
+    return;
+  }
+
+  switch(ret)
+  {
+    case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
+    case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
+      e_notification_daemon_object_init(daemon);
+      break;
+    case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
+      //XXX mark daemon as queued?
+      break;
+    case DBUS_REQUEST_NAME_REPLY_EXISTS:
+      //XXX exit?
+      break;
+  }
+}
+
+static int
+e_notification_daemon_bus_init(E_Notification_Daemon *daemon)
+{
+  daemon->conn = e_dbus_bus_get(DBUS_BUS_SESSION);
+  if (!daemon->conn) return 0;
+
+  // this blocks... make it async, and handle failure, etc
+  e_dbus_request_name(daemon->conn, E_NOTIFICATION_BUS_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, cb_request_name, daemon);
+
+  return 1;
+}
+
+static int
+e_notification_daemon_object_init(E_Notification_Daemon *daemon)
+{
+  if (!daemon || !daemon->conn) return 0;
+  daemon->obj = e_dbus_object_add(daemon->conn, E_NOTIFICATION_PATH, daemon);
+  if (!daemon->obj) return 0;
+
+  e_dbus_object_interface_attach(daemon->obj, daemon->iface);
+
+  return 1;
+}
+
+
+EAPI void
+e_notification_daemon_signal_notification_closed(E_Notification_Daemon *daemon, unsigned int id, E_Notification_Closed_Reason reason)
+{
+  DBusMessage *msg = e_notify_marshal_notification_closed_signal(id, reason);
+  e_dbus_message_send(daemon->conn, 
+                      msg,
+                      NULL, -1, NULL);
+  dbus_message_unref(msg);
+}
+
+EAPI void
+e_notification_daemon_signal_action_invoked(E_Notification_Daemon *daemon, unsigned int notification_id, const char *action_id)
+{
+  DBusMessage *msg = e_notify_marshal_action_invoked_signal(notification_id, action_id);
+  e_dbus_message_send(daemon->conn, 
+                      msg,
+                      NULL, -1, NULL);
+  dbus_message_unref(msg);
+}
diff --git a/src/lib/notification/e_notify_private.h b/src/lib/notification/e_notify_private.h
new file mode 100644 (file)
index 0000000..e68fac7
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef E_NOTIFY_PRIVATE_H
+#define E_NOTIFY_PRIVATE_H
+
+#define E_NOTIFICATION_BUS_NAME "org.freedesktop.Notifications"
+#define E_NOTIFICATION_INTERFACE "org.freedesktop.Notifications"
+#define E_NOTIFICATION_PATH "/org/freedesktop/Notifications"
+
+#define e_notification_call_new(member) dbus_message_new_method_call(E_NOTIFICATION_BUS_NAME, E_NOTIFICATION_PATH, E_NOTIFICATION_INTERFACE, member)
+
+typedef void (*E_DBus_Variant_Marshaller) (DBusMessageIter *iter, void *data);
+#define E_DBUS_VARIANT_MARSHALLER(x) ((E_DBus_Variant_Marshaller)(x))
+
+void e_notify_marshal_dict_variant(DBusMessageIter *iter, const char *key, char *type_str, E_DBus_Variant_Marshaller func, void *data);
+void e_notify_marshal_dict_string(DBusMessageIter *iter, const char *key, const char *value);
+void e_notify_marshal_dict_byte(DBusMessageIter *iter, const char *key, char value);
+void e_notify_marshal_dict_int(DBusMessageIter *iter, const char *key, int value);
+
+void e_notify_marshal_string_array(DBusMessageIter *iter, const char **strings);
+void e_notify_marshal_string_list_as_array(DBusMessageIter *iter, Ecore_List *strings);
+Ecore_List * e_notify_unmarshal_string_array_as_list(DBusMessageIter *iter, DBusError *err);
+DBusMessage * e_notify_marshal_get_capabilities();
+DBusMessage * e_notify_marshal_get_capabilities_return(DBusMessage *method_call, const char **capabilities);
+void * e_notify_unmarshal_get_capabilities_return(DBusMessage *msg, DBusError *err);
+void   e_notify_free_get_capabilities_return(void *data);
+DBusMessage * e_notify_marshal_get_server_information();
+DBusMessage * e_notify_marshal_get_server_information_return(DBusMessage *method_call, const char *name, const char *vendor, const char *version);
+void * e_notify_unmarshal_get_server_information_return(DBusMessage *msg, DBusError *err);
+void   e_notify_free_get_server_information_return(void *data);
+DBusMessage * e_notify_marshal_close_notification(dbus_uint32_t id);
+dbus_uint32_t e_notify_unmarshal_close_notification(DBusMessage *msg, DBusError *err);
+DBusMessage * e_notify_marshal_notification_closed_signal(dbus_uint32_t id, dbus_uint32_t reason);
+E_Notification_Event_Notification_Closed * e_notify_unmarshal_notification_closed_signal(DBusMessage *msg, DBusError *err);
+DBusMessage * e_notify_marshal_action_invoked_signal(dbus_uint32_t id, const char *action_id);
+E_Notification_Event_Action_Invoked * e_notify_unmarshal_action_invoked_signal(DBusMessage *msg, DBusError *err);
+DBusMessage * e_notify_marshal_notify(E_Notification *n);
+E_Notification * e_notify_unmarshal_notify(DBusMessage *msg, DBusError *err);
+DBusMessage * e_notify_marshal_notify_return(DBusMessage *method_call, dbus_uint32_t notification_id);
+void * e_notify_unmarshal_notify_return(DBusMessage *msg, DBusError *err);
+void   e_notify_free_notify_return(void *data);
+void e_notify_unmarshal_notify_actions(E_Notification *n, DBusMessageIter *iter);
+void e_notify_unmarshal_notify_hints(E_Notification *n, DBusMessageIter *iter);
+void e_notify_marshal_hint_image(DBusMessageIter *iter, E_Notification_Image *img);
+E_Notification_Image * e_notify_unmarshal_hint_image(DBusMessageIter *iter);
+
+struct E_Notification_Image
+{
+  int   width;
+  int   height;
+  int   rowstride;
+  char  has_alpha;
+  int   bits_per_sample;
+  int   channels;
+  unsigned char *data;
+};
+
+struct E_Notification
+{
+  int id;
+  char *app_name;
+  unsigned int replaces_id;
+  char *app_icon;
+  char *summary;
+  char *body;
+  int expire_timeout;
+
+  Ecore_List *actions;
+
+  struct
+  {
+    char urgency;
+    char *category;
+    char *desktop;
+    char *sound_file;
+    char suppress_sound;
+    int x, y;
+    E_Notification_Image *image_data;
+    E_Notification_Image *icon_data;
+  } hints;
+
+  int hint_flags;
+  unsigned char closed;
+
+  int refcount;
+};
+
+struct E_Notification_Action 
+{
+  char *id;
+  char *name;
+};
+
+#endif
diff --git a/src/lib/notification/marshal.c b/src/lib/notification/marshal.c
new file mode 100644 (file)
index 0000000..a14ef99
--- /dev/null
@@ -0,0 +1,590 @@
+#include "E_Notify.h"
+#include <string.h>
+#include "e_notify_private.h"
+
+void
+e_notify_marshal_dict_variant(DBusMessageIter *iter, const char *key, char *type_str, E_DBus_Variant_Marshaller func, void *data)
+{
+  DBusMessageIter entry, variant;
+
+  dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, "sv", &entry);
+  dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+  func(&entry, data);
+  dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, type_str, &variant);
+  func(&variant, data);
+  dbus_message_iter_close_container(&entry, &variant);
+  dbus_message_iter_close_container(iter, &entry);
+}
+
+void
+e_notify_marshal_dict_string(DBusMessageIter *iter, const char *key, const char *value)
+{
+  DBusMessageIter entry, variant;
+
+  dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, "sv", &entry);
+  dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+  dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "s", &variant);
+  dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &value);
+  dbus_message_iter_close_container(&entry, &variant);
+  dbus_message_iter_close_container(iter, &entry);
+}
+
+void
+e_notify_marshal_dict_byte(DBusMessageIter *iter, const char *key, char value)
+{
+  DBusMessageIter entry, variant;
+
+  if (!key || !value) return;
+
+  dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+  dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+  dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "y", &variant);
+  dbus_message_iter_append_basic(&variant, DBUS_TYPE_BYTE, &value);
+  dbus_message_iter_close_container(&entry, &variant);
+  dbus_message_iter_close_container(iter, &entry);
+}
+
+void
+e_notify_marshal_dict_int(DBusMessageIter *iter, const char *key, int value)
+{
+  DBusMessageIter entry, variant;
+
+  if (!key || !value) return;
+
+  dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, "sv", &entry);
+  dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+  dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "i", &variant);
+  dbus_message_iter_append_basic(&variant, DBUS_TYPE_INT32, &value);
+  dbus_message_iter_close_container(&entry, &variant);
+  dbus_message_iter_close_container(iter, &entry);
+}
+
+void
+e_notify_marshal_string_array(DBusMessageIter *iter, const char **strings)
+{
+  const char **str;
+  DBusMessageIter arr;
+
+  dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "s", &arr);
+
+  for (str = strings; *str; str++)
+    dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, str);
+
+  dbus_message_iter_close_container(iter, &arr);
+}
+
+void
+e_notify_marshal_string_list_as_array(DBusMessageIter *iter, Ecore_List *strings)
+{
+  const char *str;
+  DBusMessageIter arr;
+
+  dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "s", &arr);
+
+  ecore_list_first_goto(strings);
+  while((str = ecore_list_next(strings)))
+    dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &str);
+
+  dbus_message_iter_close_container(iter, &arr);
+}
+
+Ecore_List *
+e_notify_unmarshal_string_array_as_list(DBusMessageIter *iter, DBusError *err)
+{
+  Ecore_List *strings;
+  char *sig;
+  int ret;
+  DBusMessageIter arr;
+
+  sig = dbus_message_iter_get_signature(iter);
+  ret = !strcmp(sig, "as");
+  dbus_free(sig);
+  if (!ret) return NULL;
+
+  strings = ecore_list_new();
+  ecore_list_free_cb_set(strings, ECORE_FREE_CB(free)); //XXX use ecore_string_release?
+
+  dbus_message_iter_recurse(iter, &arr);
+  while(dbus_message_iter_has_next(&arr))
+  {
+    const char *str;
+    dbus_message_iter_get_basic(&arr, &str);
+    ecore_list_append(strings, strdup(str)); //XXX use ecore_string_instance?
+    dbus_message_iter_next(&arr);
+  }
+  return strings;
+}
+
+
+
+DBusMessage *
+e_notify_marshal_get_capabilities()
+{
+  DBusMessage *msg;
+
+  msg = e_notification_call_new("GetCapabilities");
+  return msg;
+}
+
+DBusMessage *
+e_notify_marshal_get_capabilities_return(DBusMessage *method_call, const char **capabilities)
+{
+  DBusMessage *msg;
+  DBusMessageIter iter;
+
+  msg = dbus_message_new_method_return(method_call);
+  dbus_message_iter_init_append(msg, &iter);
+  e_notify_marshal_string_array(&iter, capabilities);
+
+  return msg;
+}
+
+void *
+e_notify_unmarshal_get_capabilities_return(DBusMessage *msg, DBusError *err)
+{
+  DBusMessageIter iter;
+  E_Notification_Return_Get_Capabilities *ret;
+
+  if (!dbus_message_has_signature(msg, "as")) return NULL;
+
+  ret = calloc(1, sizeof(E_Notification_Return_Get_Capabilities));
+  dbus_message_iter_init(msg, &iter);
+  ret->capabilities = e_notify_unmarshal_string_array_as_list(&iter, err);
+
+  return ret;
+}
+
+void
+e_notify_free_get_capabilities_return(void *data)
+{
+  E_Notification_Return_Get_Capabilities *ret = data;
+
+  if (!ret) return;
+  ecore_list_destroy(ret->capabilities);
+  free(ret);
+}
+
+DBusMessage *
+e_notify_marshal_get_server_information()
+{
+  DBusMessage *msg;
+
+  msg = e_notification_call_new("GetServerInformation");
+  return msg;
+}
+
+DBusMessage *
+e_notify_marshal_get_server_information_return(DBusMessage *method_call, const char *name, const char *vendor, const char *version)
+{
+  DBusMessage *msg;
+  msg = dbus_message_new_method_return(method_call);
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &vendor, DBUS_TYPE_STRING, &version, DBUS_TYPE_INVALID);
+  return msg;
+}
+
+void *
+e_notify_unmarshal_get_server_information_return(DBusMessage *msg, DBusError *err)
+{
+  E_Notification_Return_Get_Server_Information *info;
+  if (!dbus_message_has_signature(msg, "sss")) return NULL;
+
+  info = calloc(1, sizeof(E_Notification_Return_Get_Server_Information));
+  dbus_message_get_args(msg, err,
+    DBUS_TYPE_STRING, &(info->name),
+    DBUS_TYPE_STRING, &(info->vendor),
+    DBUS_TYPE_STRING, &(info->version),
+    DBUS_TYPE_INVALID
+  );
+  if (dbus_error_is_set(err))
+  {
+    free(info);
+    return NULL;
+  }
+
+  return info;
+}
+
+void
+e_notify_free_get_server_information_return(void *data)
+{
+  E_Notification_Return_Get_Server_Information *info = data;
+
+  if (!info) return;
+  free(info);
+}
+
+DBusMessage *
+e_notify_marshal_close_notification(dbus_uint32_t id)
+{
+  DBusMessage *msg;
+
+  msg = e_notification_call_new("CloseNotification");
+  dbus_message_append_args(msg, DBUS_TYPE_UINT32, &id, DBUS_TYPE_INVALID);
+  return msg;
+}
+
+dbus_uint32_t
+e_notify_unmarshal_close_notification(DBusMessage *msg, DBusError *err)
+{
+  dbus_uint32_t id;
+  if (!dbus_message_has_signature(msg, "u")) return 0;
+  dbus_message_get_args(msg, err, DBUS_TYPE_UINT32, &id, DBUS_TYPE_INVALID);
+  if (err && dbus_error_is_set(err))
+    return 0;
+
+  return id;
+}
+
+DBusMessage *
+e_notify_marshal_notification_closed_signal(dbus_uint32_t id, dbus_uint32_t reason)
+{
+  DBusMessage *msg;
+  msg = dbus_message_new_signal(E_NOTIFICATION_PATH, E_NOTIFICATION_INTERFACE, "NotificationClosed");
+  dbus_message_append_args(msg, DBUS_TYPE_UINT32, &id, DBUS_TYPE_UINT32, &reason, DBUS_TYPE_INVALID);
+  return msg;
+}
+
+E_Notification_Event_Notification_Closed *
+e_notify_unmarshal_notification_closed_signal(DBusMessage *msg, DBusError *err)
+{
+  E_Notification_Event_Notification_Closed *ev;
+
+  if (!dbus_message_has_signature(msg, "uu")) 
+  {
+    dbus_set_error(err, DBUS_ERROR_INVALID_SIGNATURE, "");
+    return NULL;
+  }
+  ev = calloc(1, sizeof(E_Notification_Event_Notification_Closed));
+  dbus_message_get_args(msg, err, DBUS_TYPE_UINT32, &(ev->notification_id), DBUS_TYPE_UINT32, &(ev->reason), DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(err))
+  {
+    free(ev);
+    return NULL;
+  }
+  return ev;
+}
+
+DBusMessage *
+e_notify_marshal_action_invoked_signal(dbus_uint32_t id, const char *action_id)
+{
+  DBusMessage *msg;
+  msg = dbus_message_new_signal(E_NOTIFICATION_PATH, E_NOTIFICATION_INTERFACE, "ActionInvoked");
+  dbus_message_append_args(msg, DBUS_TYPE_UINT32, &id, DBUS_TYPE_STRING, &action_id, DBUS_TYPE_INVALID);
+  return msg;
+}
+
+E_Notification_Event_Action_Invoked *
+e_notify_unmarshal_action_invoked_signal(DBusMessage *msg, DBusError *err)
+{
+  E_Notification_Event_Action_Invoked *ev;
+
+  if (!dbus_message_has_signature(msg, "us")) 
+  {
+    dbus_set_error(err, DBUS_ERROR_INVALID_SIGNATURE, "");
+    return NULL;
+  }
+  ev = calloc(1, sizeof(E_Notification_Event_Action_Invoked));
+  dbus_message_get_args(msg, err, DBUS_TYPE_UINT32, &(ev->notification_id), DBUS_TYPE_STRING, &(ev->action_id), DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(err))
+  {
+    free(ev);
+    return NULL;
+  }
+  return ev;
+}
+
+DBusMessage *
+e_notify_marshal_notify(E_Notification *n)
+{
+  DBusMessage *msg;
+  DBusMessageIter iter, sub;
+
+  if (!n->app_name) n->app_name = strdup("");
+  if (!n->app_icon) n->app_icon = strdup("");
+  if (!n->summary) n->summary = strdup("");
+  if (!n->body) n->body = strdup("");
+
+  msg = e_notification_call_new("Notify");
+  dbus_message_append_args(msg, 
+    DBUS_TYPE_STRING, &(n->app_name),
+    DBUS_TYPE_UINT32, &(n->replaces_id),
+    DBUS_TYPE_STRING, &(n->app_icon),
+    DBUS_TYPE_STRING, &(n->summary),
+    DBUS_TYPE_STRING, &(n->body),
+    DBUS_TYPE_INVALID
+  );
+
+  dbus_message_iter_init_append(msg, &iter);
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub);
+  if (n->actions)
+  {
+    E_Notification_Action *action;
+    ecore_list_first_goto(n->actions);
+    while ((action = ecore_list_next(n->actions)))
+    {
+      dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &(action->id));
+      dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &(action->name));
+    }
+  }
+  dbus_message_iter_close_container(&iter, &sub);
+
+  /* hints */
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &sub);
+  if (n->hints.urgency) /* we only need to send this if its non-zero*/
+    e_notify_marshal_dict_byte(&sub, "urgency", n->hints.urgency);
+  if (n->hints.category)
+    e_notify_marshal_dict_string(&sub, "category", n->hints.category);
+  if (n->hints.desktop)
+    e_notify_marshal_dict_string(&sub, "desktop_entry", n->hints.desktop);
+  if (n->hints.image_data)
+    e_notify_marshal_dict_variant(&sub, "image_data", "(iiibiiay)", E_DBUS_VARIANT_MARSHALLER(e_notify_marshal_hint_image), n->hints.image_data);
+  if (n->hints.icon_data)
+    e_notify_marshal_dict_variant(&sub, "icon_data", "(iiibiiay)", E_DBUS_VARIANT_MARSHALLER(e_notify_marshal_hint_image), n->hints.icon_data);
+  if (n->hints.sound_file)
+    e_notify_marshal_dict_string(&sub, "sound_file", n->hints.sound_file);
+  if (n->hints.suppress_sound) /* we only need to send this if its true */
+    e_notify_marshal_dict_byte(&sub, "suppress_sound", n->hints.suppress_sound);
+  if (n->hints.x > -1 && n->hints.y > -1)
+  {
+    e_notify_marshal_dict_int(&sub, "x", n->hints.x);
+    e_notify_marshal_dict_int(&sub, "y", n->hints.y);
+  }
+
+  dbus_message_iter_close_container(&iter, &sub);
+  dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &(n->expire_timeout));
+  return msg;
+}
+
+E_Notification *
+e_notify_unmarshal_notify(DBusMessage *msg, DBusError *err)
+{
+  E_Notification *n;
+  const char *s_val;
+  dbus_uint32_t u_val;
+  dbus_int32_t i_val;
+  DBusMessageIter iter;
+  if (!dbus_message_has_signature(msg, "susssasa{sv}i")) return NULL;
+
+  n = e_notification_new();
+  if (!n) return NULL;
+  dbus_message_iter_init(msg, &iter);
+
+  dbus_message_iter_get_basic(&iter, &s_val);
+  e_notification_app_name_set(n, s_val); 
+  dbus_message_iter_next(&iter);
+
+  dbus_message_iter_get_basic(&iter, &u_val);
+  e_notification_replaces_id_set(n, u_val); 
+  dbus_message_iter_next(&iter);
+
+  dbus_message_iter_get_basic(&iter, &s_val);
+  e_notification_app_icon_set(n, s_val); 
+  dbus_message_iter_next(&iter);
+
+  dbus_message_iter_get_basic(&iter, &s_val);
+  e_notification_summary_set(n, s_val); 
+  dbus_message_iter_next(&iter);
+
+  dbus_message_iter_get_basic(&iter, &s_val);
+  e_notification_body_set(n, s_val); 
+  dbus_message_iter_next(&iter);
+
+  e_notify_unmarshal_notify_actions(n, &iter);
+  dbus_message_iter_next(&iter);
+
+  e_notify_unmarshal_notify_hints(n, &iter);
+  dbus_message_iter_next(&iter);
+
+  dbus_message_iter_get_basic(&iter, &i_val);
+  e_notification_timeout_set(n, i_val);
+  
+  return n;
+}
+
+DBusMessage *
+e_notify_marshal_notify_return(DBusMessage *method_call, dbus_uint32_t notification_id)
+{
+  DBusMessage *msg;
+  msg = dbus_message_new_method_return(method_call);
+  dbus_message_append_args(msg, DBUS_TYPE_UINT32, &notification_id, DBUS_TYPE_INVALID);
+  return msg;
+}
+
+void *
+e_notify_unmarshal_notify_return(DBusMessage *msg, DBusError *err)
+{
+  E_Notification_Return_Notify *ret;
+  ret = calloc(1, sizeof(E_Notification_Return_Notify));
+  dbus_message_get_args(msg, err, DBUS_TYPE_UINT32, &(ret->notification_id), DBUS_TYPE_INVALID);
+  if (dbus_error_is_set(err))
+  {
+    free(ret);
+    return NULL;
+  }
+  return ret;
+}
+
+void
+e_notify_free_notify_return(void *data)
+{
+  E_Notification_Return_Notify *ret = data;
+
+  if (!ret) return;
+  free(ret);
+}
+
+void
+e_notify_unmarshal_notify_actions(E_Notification *n, DBusMessageIter *iter)
+{
+  DBusMessageIter arr;
+  const char *id, *name;
+  dbus_message_iter_recurse(iter, &arr);
+  while (dbus_message_iter_has_next(&arr))
+  {
+    dbus_message_iter_get_basic(&arr, &id);
+    dbus_message_iter_next(&arr);
+    dbus_message_iter_get_basic(&arr, &name);
+    dbus_message_iter_next(&arr);
+    e_notification_action_add(n, id, name);
+  }
+}
+
+void
+e_notify_unmarshal_notify_hints(E_Notification *n, DBusMessageIter *iter)
+{
+  DBusMessageIter arr;
+  const char *key;
+  int x_set = 0, y_set = 0;
+  int x, y;
+  dbus_message_iter_recurse(iter, &arr);
+  
+  if (dbus_message_iter_get_arg_type(&arr) == DBUS_TYPE_INVALID)
+    return;
+  
+  do
+  {
+    DBusMessageIter dict;
+    dbus_message_iter_recurse(&arr, &dict);
+    do
+    {
+      DBusMessageIter variant;
+      const char *s_val;
+      char y_val;
+      dbus_bool_t b_val;
+
+      dbus_message_iter_get_basic(&dict, &key);
+      dbus_message_iter_next(&dict);
+      dbus_message_iter_recurse(&dict, &variant);
+     
+      if (!strcmp(key, "urgency"))
+        {
+          dbus_message_iter_get_basic(&variant, &y_val);
+          e_notification_hint_urgency_set(n, y_val);
+        }
+      else if (!strcmp(key, "category"))
+        {
+          dbus_message_iter_get_basic(&variant, &s_val);
+          e_notification_hint_category_set(n, s_val);
+        }
+      else if (!strcmp(key, "desktop-entry"))
+        {
+          e_notification_hint_desktop_set(n, s_val);
+        }
+      else if (!strcmp(key, "sound-file"))
+        {
+          dbus_message_iter_get_basic(&variant, &s_val);
+          e_notification_hint_sound_file_set(n, s_val);
+        }
+      else if (!strcmp(key, "suppress-sound"))
+        {
+          dbus_message_iter_get_basic(&variant, &b_val);
+          e_notification_hint_suppress_sound_set(n, b_val);
+        }
+      else if (!strcmp(key, "x"))
+      {
+        dbus_message_iter_get_basic(&variant, &x);
+        x_set = 1;
+      }
+      else if (!strcmp(key, "y"))
+      {
+        dbus_message_iter_get_basic(&variant, &y);
+        y_set = 1;
+      }
+      else if (!strcmp(key, "image_data"))
+        {
+          dbus_message_iter_recurse(&dict, &variant);
+          n->hints.image_data = e_notify_unmarshal_hint_image(&variant);
+        }
+      else if (!strcmp(key, "icon_data"))
+        {
+          dbus_message_iter_recurse(&dict, &variant);
+          n->hints.icon_data = e_notify_unmarshal_hint_image(&variant);
+        }
+    }
+    while (dbus_message_iter_next(&dict));
+  } 
+  while (dbus_message_iter_next(&arr));
+
+  if (x_set && y_set)
+    e_notification_hint_xy_set(n, x, y);
+}
+
+void
+e_notify_marshal_hint_image(DBusMessageIter *iter, E_Notification_Image *img)
+{
+  DBusMessageIter sub, arr;
+  int data_len = 0; 
+
+  data_len = ((img->height - 1) * img->rowstride) + (img->width * ((img->channels * (img->bits_per_sample + 7)) / 8));
+  dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &sub);
+  dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(img->width));
+  dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(img->height));
+  dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(img->rowstride));
+  dbus_message_iter_append_basic(&sub, DBUS_TYPE_BOOLEAN, &(img->has_alpha));
+  dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(img->bits_per_sample));
+  dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(img->channels));
+  dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, NULL, &arr);
+  dbus_message_iter_append_fixed_array(&arr, DBUS_TYPE_BYTE, &(img->data), data_len);
+  dbus_message_iter_close_container(&sub, &arr);
+}
+
+E_Notification_Image *
+e_notify_unmarshal_hint_image(DBusMessageIter *iter)
+{
+  DBusMessageIter sub, arr;
+  char *byte_array;
+  int array_len;
+  E_Notification_Image *img;
+  char *sig;
+  int sig_matches;
+
+  sig = dbus_message_iter_get_signature(iter);
+  sig_matches = strcmp(sig, "(iiibiiay)");
+  dbus_free(sig);
+  if (sig_matches) return NULL;
+
+  img = e_notification_image_new();
+  if (!img) return NULL;
+
+  dbus_message_iter_recurse(iter, &sub);
+  dbus_message_iter_get_basic(&sub, &(img->width));
+  dbus_message_iter_next(&sub);
+  dbus_message_iter_get_basic(&sub, &(img->height));
+  dbus_message_iter_next(&sub);
+  dbus_message_iter_get_basic(&sub, &(img->rowstride));
+  dbus_message_iter_next(&sub);
+  dbus_message_iter_get_basic(&sub, &(img->has_alpha));
+  dbus_message_iter_next(&sub);
+  dbus_message_iter_get_basic(&sub, &(img->bits_per_sample));
+  dbus_message_iter_next(&sub);
+  dbus_message_iter_get_basic(&sub, &(img->channels));
+  dbus_message_iter_next(&sub);
+
+  dbus_message_iter_recurse(&sub, &arr);
+  dbus_message_iter_get_fixed_array(&arr, &(byte_array), &array_len);
+  img->data = malloc(array_len);
+  memcpy(img->data, byte_array, array_len);
+
+  return img;
+}
+
diff --git a/src/lib/notification/notification-spec-0.9.txt b/src/lib/notification/notification-spec-0.9.txt
new file mode 100644 (file)
index 0000000..f392c8c
--- /dev/null
@@ -0,0 +1,827 @@
+                      Desktop Notifications Specification
+
+  Mike Hearn
+
+         <[1]mike@navi.cx>
+
+
+  Christian Hammond
+
+         <[2]chipx86@chipx86.com>
+
+
+   Version 0.9
+
+   Revision History
+   Revision 0.9           15 January 2006            Revised by: cdh
+   Clarify the naming for the application IDs. Put back a number of things
+   that probably shouldn't have been removed from the spec.
+   Revision 0.8           23 September 2005          Revised by: J5
+   Major overhaul of spec to work with the newer D-Bus recursive type system.
+   Simplify protocol. Changed the verbage notification type to category
+   Revision 0.7           28 July 2005               Revised by: cdh
+   Added "x" and "y" hints. Talk about the variant type for hint values.
+   Revision 0.6           1 April 2005               Revised by: cdh
+   Updated to work with D-BUS 0.31+.
+   Revision 0.5           2 October 2004             Revised by: cdh
+   Added a "suppress-sound" hint. Added a "sound" capability. Renamed the
+   "soundfile" hint to sound-file".
+   Revision 0.4           29 September 2004          Revised by: cdh
+   Added image support in markup, and made the restrictions on markup more
+   clear. Removed the High urgency. Added new notification types. Fixed
+   notification expiration.
+   Revision 0.3           15 September 2004          Revised by: cdh
+   Added hint and notification type sections
+   Revision 0.2           foo                        Revised by: mh
+   Added replaces field to protocol
+   Revision 0.1           foo                        Revised by: mh
+   Initial version
+
+   --------------------------------------------------------------------------
+
+   Table of Contents
+
+   1. [3]Introduction
+
+   2. [4]Basic Design
+
+   3. [5]Backwards Compatibility
+
+   4. [6]Markup
+
+                4.1. [7]Hyperlinks
+
+                4.2. [8]Images
+
+   5. [9]Icons
+
+   6. [10]Categories
+
+   7. [11]Urgency Levels
+
+   8. [12]Hints
+
+   9. [13]D-BUS Protocol
+
+                9.1. [14]Message commands
+
+                             9.1.1.
+                             [15]org.freedesktop.Notifications.GetCapabilities
+
+                             9.1.2. [16]org.freedesktop.Notifications.Notify
+
+                             9.1.3.
+                             [17]org.freedesktop.Notifications.CloseNotification
+
+                             9.1.4.
+                             [18]org.freedesktop.Notifications.GetServerInformation
+
+                9.2. [19]Signals
+
+                             9.2.1.
+                             [20]org.freedesktop.Notifications.NotificationClosed
+
+                             9.2.2.
+                             [21]org.freedesktop.Notifications.ActionInvoked
+
+1. Introduction
+
+     This is a draft standard for a desktop notifications service, through
+   which applications can generate passive popups (sometimes known as
+   "poptarts") to notify the user in an asynchronous manner of events.
+
+     This specification explicitly does not include other types of
+   notification presentation such as modal message boxes, window manager
+   decorations or window list annotations.
+
+     Example use cases include:
+
+     *   Presence changes in IM programs: for instance, MSN Messenger on
+       Windows pioneered the use of passive popups to indicate presence
+       changes.
+
+     * Scheduled alarm
+
+     * Completed file transfer
+
+     * New mail notification
+
+     * Low disk space/battery warnings
+
+   --------------------------------------------------------------------------
+
+2. Basic Design
+
+     In order to ensure that multiple notifications can easily be displayed
+   at once, and to provide a convenient implementation, all notifications are
+   controlled by a single session-scoped service which exposes a D-BUS
+   interface.
+
+     On startup, a conforming implementation should take the
+   org.freedesktop.Notifications service on the session bus. This service
+   will be referred to as the "notification server" or just "the server" in
+   this document. It can optionally be activated automatically by the bus
+   process, however this is not required and notification server clients must
+   not assume that it is available.
+
+     The server should implement the org.freedesktop.Notifications interface
+   on an object with the path "/org/freedesktop/Notifications". This is the
+   only interface required by this version of the specification.
+
+     A notification has the following components:
+
+   Table 1. Notification Components
+
+   +------------------------------------------------------------------------+
+   |     Component      |                    Description                    |
+   |--------------------+---------------------------------------------------|
+   |                    |   This is the optional name of the application    |
+   |                    | sending the notification. This should be the      |
+   | Application Name   | application's formal name, rather than some sort  |
+   |                    | of ID. An example would be "FredApp E-Mail        |
+   |                    | Client," rather than "fredapp-email-client."      |
+   |--------------------+---------------------------------------------------|
+   | Replaces ID        |   An optional ID of an existing notification that |
+   |                    | this notification is intended to replace.         |
+   |--------------------+---------------------------------------------------|
+   |                    |   The notification icon. This is represented      |
+   |                    | either as a URI (file:// is the only URI schema   |
+   | Notification Icon  | supported right now) or a name in a               |
+   |                    | freedesktop.org-compliant icon theme (not a GTK+  |
+   |                    | stock ID).                                        |
+   |--------------------+---------------------------------------------------|
+   |                    |   This is a single line overview of the           |
+   |                    | notification. For instance, "You have mail" or "A |
+   |                    | friend has come online". It should generally not  |
+   | Summary            | be longer than 40 characters, though this is not  |
+   |                    | a requirement, and server implementations should  |
+   |                    | word wrap if necessary. The summary must be       |
+   |                    | encoded using UTF-8.                              |
+   |--------------------+---------------------------------------------------|
+   |                    |                                                   |
+   |                    |                                                   |
+   |                    |   This is a multi-line body of text. Each line is |
+   |                    | a paragraph, server implementations are free to   |
+   |                    | word wrap them as they see fit.                   |
+   | Body               |                                                   |
+   |                    |   The body may contain simple markup as specified |
+   |                    | in [22]Markup. It must be encoded using UTF-8.    |
+   |                    |                                                   |
+   |                    |   If the body is omitted, just the summary is     |
+   |                    | displayed.                                        |
+   |--------------------+---------------------------------------------------|
+   |                    |                                                   |
+   |                    |                                                   |
+   |                    |   The actions send a request message back to the  |
+   |                    | notification client when invoked. This            |
+   |                    | functionality may not be implemented by the       |
+   |                    | notification server, conforming clients should    |
+   |                    | check if it is available before using it (see the |
+   |                    | GetCapabilities message in [23]Protocol). An      |
+   |                    | implementation is free to ignore any requested by |
+   |                    | the client. As an example one possible rendering  |
+   |                    | of actions would be as buttons in the             |
+   | Actions            | notification popup.                               |
+   |                    |                                                   |
+   |                    |   Actions are sent over as a list of pairs. Each  |
+   |                    | even element in the list (starting at index 0)    |
+   |                    | represents the identifier for the action. Each    |
+   |                    | odd element in the list is the localized string   |
+   |                    | that will be displayed to the user.               |
+   |                    |                                                   |
+   |                    |   The default action (usually invoked my clicking |
+   |                    | the notification) should have a key named         |
+   |                    | "default". The name can be anything, though       |
+   |                    | implementations are free not to display it.       |
+   |--------------------+---------------------------------------------------|
+   |                    |                                                   |
+   |                    |                                                   |
+   |                    | See [24]Hints.                                    |
+   |                    |                                                   |
+   |                    |   Beyond the core protocol is the hints table. A  |
+   |                    | couple of core elements have been moved to hints  |
+   |                    | mostly because in a huge number of cases their    |
+   |                    | default values would be sufficent. The elements   |
+   |                    | moved to hints are:                               |
+   |                    |                                                   |
+   |                    | Elements Moved to Hints                           |
+   |                    |                                                   |
+   |                    | Element: Category ID                              |
+   |                    |                                                   |
+   | Hints              | Description: An optional ID representing the type |
+   |                    | of notification (the name has been changed from   |
+   |                    | Notification Type ID in pervious versions). See   |
+   |                    | [25]Categories.                                   |
+   |                    |                                                   |
+   |                    | Element: Urgency Level                            |
+   |                    |                                                   |
+   |                    | Description: The urgency of the notification. See |
+   |                    | [26]Urgency Levels. (Defaults to 1 - Normal)      |
+   |                    |                                                   |
+   |                    | Element: Icon Data                                |
+   |                    |                                                   |
+   |                    | Description: Instead of overloading the icon      |
+   |                    | field we now have an icon_data field that is used |
+   |                    | when icon is blank.                               |
+   |--------------------+---------------------------------------------------|
+   |                    |                                                   |
+   |                    |                                                   |
+   |                    |   The timeout time in milliseconds since the      |
+   |                    | display of the notification at which the          |
+   |                    | notification should automatically close.          |
+   | Expiration Timeout |                                                   |
+   |                    |   If -1, the notification's expiration time is    |
+   |                    | dependent on the notification server's settings,  |
+   |                    | and may vary for the type of notification.        |
+   |                    |                                                   |
+   |                    |   If 0, the notification never expires.           |
+   +------------------------------------------------------------------------+
+
+     Each notification displayed is allocated a unique ID by the server. This
+   is unique within the session. While the notification server is running,
+   the ID will not be recycled unless the capacity of a uint32 is exceeded.
+
+     This can be used to hide the notification before the expiration timeout
+   is reached. It can also be used to atomically replace the notification
+   with another. This allows you to (for instance) modify the contents of a
+   notification while it's on-screen.
+
+   --------------------------------------------------------------------------
+
+3. Backwards Compatibility
+
+     Clients should try and avoid making assumptions about the presentation
+   and abilities of the notification server. The message content is the most
+   important thing.
+
+     Clients can check with the server what capabilities are supported using
+   the GetCapabilities message. See [27]Protocol.
+
+     If a client requires a response from a passive popup, it should be coded
+   such that a non-focus-stealing message box can be used in the case that
+   the notification server does not support this feature.
+
+   --------------------------------------------------------------------------
+
+4. Markup
+
+     Body text may contain markup. The markup is XML-based, and consists of a
+   small subset of HTML along with a few additional tags.
+
+     The following tags should be supported by the notification server.
+   Though it is optional, it is recommended. Notification servers that do not
+   support these tags should filter them out.
+
+   +------------------------------------------+
+   |   <b> ... </b>               | Bold      |
+   |------------------------------+-----------|
+   |   <i> ... </i>               | Italic    |
+   |------------------------------+-----------|
+   |   <u> ... </u>               | Underline |
+   |------------------------------+-----------|
+   |   <a href="..."> ... </a>    | Hyperlink |
+   |------------------------------+-----------|
+   |   <img src="..." alt="..."/> | Image     |
+   +------------------------------------------+
+
+     A full-blown HTML implementation is not required of this spec, and
+   notifications should never take advantage of tags that are not listed
+   above. As notifications are not a substitute for web browsers or complex
+   dialogs, advanced layout is not necessary, and may in fact limit the
+   number of systems that notification services can run on, due to memory
+   usage and screen space. Such examples are PDAs, certain cell phones, and
+   slow PCs or laptops with little memory.
+
+     For the same reason, a full XML or XHTML implementation using XSLT or
+   CSS stylesheets is not part of this specification. Information that must
+   be presented in a more complex form should use an application-specific
+   dialog, a web browser, or some other display mechanism.
+
+     The tags specified above mark up the content in a way that allows them
+   to be stripped out on some implementations without impacting the actual
+   content.
+
+   --------------------------------------------------------------------------
+
+  4.1. Hyperlinks
+
+     Hyperlinks allow for linking one or more words to a URI. There is no
+   requirement to allow for images to be linked, and it is highly suggested
+   that implementations do not allow this, as there is no clean-looking,
+   standard visual indicator for a hyperlinked image.
+
+     Hyperlinked text should appear in the standard blue underline format.
+
+     Hyperlinks cannot function as a replacement for actions. They are used
+   to link to local directories or remote sites using standard URI schemes.
+
+     Implementations are not required to support hyperlinks.
+
+   --------------------------------------------------------------------------
+
+  4.2. Images
+
+     Images may be placed in the notification, but this should be done with
+   caution. The image should never exceed 200x100, but this should be thought
+   of as a maximum size. Images should always have alternative text provided
+   through the alt="..." attribute.
+
+     Image data cannot be embedded in the message itself. Images referenced
+   must always be local files.
+
+     Implementations are not required to support images.
+
+   --------------------------------------------------------------------------
+
+5. Icons
+
+     A notification can optionally have an icon specified by the Notification
+   Icon field or by the icon_data hint.
+
+     The icon_data field should be a raw image data structure of signature
+   (iiibiiay) which describes the width, height, rowstride, has alpha, bits
+   per sample, channels and image data respectively.
+
+   --------------------------------------------------------------------------
+
+6. Categories
+
+     Notifications can optionally have a type indicator. Although neither
+   client or nor server must support this, some may choose to. Those servers
+   implementing categories may use them to intelligently display the
+   notification in a certain way, or group notifications of similar types.
+
+     Categories are in class.specific form. class specifies the generic type
+   of notification, and specific specifies the more specific type of
+   notification.
+
+     If a specific type of notification does not exist for your notification,
+   but the generic kind does, a notification of type class is acceptable.
+
+     Third parties, when defining their own categories, should discuss the
+   possibility of standardizing on the hint with other parties, preferably in
+   a place such as the [28]xdg mailing list at [29]freedesktop.org. If it
+   warrants a standard, it will be added to the table above. If no consensus
+   is reached, the category should be in the form of "x-vendor.class.name."
+
+     The following table lists standard notifications as defined by this
+   spec. More will be added in time.
+
+   Table 2. Categories
+
+   +------------------------------------------------------------------------+
+   |          Type          |                  Description                  |
+   |------------------------+-----------------------------------------------|
+   | "device"               |   A generic device-related notification that  |
+   |                        | doesn't fit into any other category.          |
+   |------------------------+-----------------------------------------------|
+   | "device.added"         | A device, such as a USB device, was added to  |
+   |                        | the system.                                   |
+   |------------------------+-----------------------------------------------|
+   | "device.error"         | A device had some kind of error.              |
+   |------------------------+-----------------------------------------------|
+   | "device.removed"       |   A device, such as a USB device, was removed |
+   |                        | from the system.                              |
+   |------------------------+-----------------------------------------------|
+   | "email"                |   A generic e-mail-related notification that  |
+   |                        | doesn't fit into any other category.          |
+   |------------------------+-----------------------------------------------|
+   | "email.arrived"        | A new e-mail notification.                    |
+   |------------------------+-----------------------------------------------|
+   | "email.bounced"        | A notification stating that an e-mail has     |
+   |                        | bounced.                                      |
+   |------------------------+-----------------------------------------------|
+   |                        |   A generic instant message-related           |
+   | "im"                   | notification that doesn't fit into any other  |
+   |                        | category.                                     |
+   |------------------------+-----------------------------------------------|
+   | "im.error"             | An instant message error notification.        |
+   |------------------------+-----------------------------------------------|
+   | "im.received"          | A received instant message notification.      |
+   |------------------------+-----------------------------------------------|
+   | "network"              |   A generic network notification that doesn't |
+   |                        | fit into any other category.                  |
+   |------------------------+-----------------------------------------------|
+   |                        |   A network connection notification, such as  |
+   | "network.connected"    | successful sign-on to a network service. This |
+   |                        | should not be confused with device.added for  |
+   |                        | new network devices.                          |
+   |------------------------+-----------------------------------------------|
+   |                        |   A network disconnected notification. This   |
+   | "network.disconnected" | should not be confused with device.removed    |
+   |                        | for disconnected network devices.             |
+   |------------------------+-----------------------------------------------|
+   | "network.error"        |   A network-related or connection-related     |
+   |                        | error.                                        |
+   |------------------------+-----------------------------------------------|
+   |                        |   A generic presence change notification that |
+   | "presence"             | doesn't fit into any other category, such as  |
+   |                        | going away or idle.                           |
+   |------------------------+-----------------------------------------------|
+   | "presence.offline"     | An offline presence change notification.      |
+   |------------------------+-----------------------------------------------|
+   | "presence.online"      | An online presence change notification.       |
+   |------------------------+-----------------------------------------------|
+   |                        |   A generic file transfer or download         |
+   | "transfer"             | notification that doesn't fit into any other  |
+   |                        | category.                                     |
+   |------------------------+-----------------------------------------------|
+   | "transfer.complete"    | A file transfer or download complete          |
+   |                        | notification.                                 |
+   |------------------------+-----------------------------------------------|
+   | "transfer.error"       | A file transfer or download error.            |
+   +------------------------------------------------------------------------+
+
+   --------------------------------------------------------------------------
+
+7. Urgency Levels
+
+     Notifications have an urgency level associated with them. This defines
+   the importance of the notification. For example, "Joe Bob signed on" would
+   be a low urgency. "You have new mail" or "A USB device was unplugged"
+   would be a normal urgency. "Your computer is on fire" would be a critical
+   urgency.
+
+   Urgency levels are defined as follows:
+
+   Table 3. Urgency Levels
+
+   +--------------------+
+   | Type | Description |
+   |------+-------------|
+   | 0    | Low         |
+   |------+-------------|
+   | 1    | Normal      |
+   |------+-------------|
+   | 2    | Critical    |
+   +--------------------+
+
+     Developers must use their own judgement when deciding the urgency of a
+   notification. Typically, if the majority of programs are using the same
+   level for a specific type of urgency, other applications should follow
+   them.
+
+     For low and normal urgencies, server implementations may display the
+   notifications how they choose. They should, however, have a sane
+   expiration timeout dependent on the urgency level.
+
+     Critical notifications should not automatically expire, as they are
+   things that the user will most likely want to know about. They should only
+   be closed when the user dismisses them, for example, by clicking on the
+   notification.
+
+   --------------------------------------------------------------------------
+
+8. Hints
+
+     Hints are a way to provide extra data to a notification server that the
+   server may be able to make use of.
+
+     Neither clients nor notification servers are required to support any
+   hints. Both sides should assume that hints are not passed, and should
+   ignore any hints they do not understand.
+
+     Third parties, when defining their own hints, should discuss the
+   possibility of standardizing on the hint with other parties, preferably in
+   a place such as the [30]xdg mailing list at [31]freedesktop.org. If it
+   warrants a standard, it will be added to the table above. If no consensus
+   is reached, the hint name should be in the form of "x-vendor-name."
+
+     The value type for the hint dictionary in D-BUS is of the
+   DBUS_TYPE_VARIANT container type. This allows different data types
+   (string, integer, boolean, etc.) to be used for hints. When adding a
+   dictionary of hints, this type must be used, rather than putting the
+   actual hint value in as the dictionary value.
+
+     The following table lists the standard hints as defined by this
+   specification. Future hints may be proposed and added to this list over
+   time. Once again, implementations are not required to support these.
+
+   Table 4. Standard Hints
+
+   +------------------------------------------------------------------------+
+   |       Name       | Value Type |              Description               |
+   |------------------+------------+----------------------------------------|
+   | "urgency"        | byte       |   The urgency level.                   |
+   |------------------+------------+----------------------------------------|
+   | "category"       | string     |   The type of notification this is.    |
+   |------------------+------------+----------------------------------------|
+   |                  |            |   This specifies the name of the       |
+   |                  |            | desktop filename representing the      |
+   |                  |            | calling program. This should be the    |
+   |                  |            | same as the prefix used for the        |
+   | "desktop-entry"> | string     | application's .desktop file. An        |
+   |                  |            | example would be "rhythmbox" from      |
+   |                  |            | "rhythmbox.desktop". This can be used  |
+   |                  |            | by the daemon to retrieve the correct  |
+   |                  |            | icon for the application, for logging  |
+   |                  |            | purposes, etc.                         |
+   |------------------+------------+----------------------------------------|
+   |                  |            |   This is a raw data image format      |
+   |                  |            | which describes the width, height,     |
+   | "image_data"     | (iiibiiay) | rowstride, has alpha, bits per sample, |
+   |                  |            | channels and image data respectively.  |
+   |                  |            | We use this value if the icon field is |
+   |                  |            | left blank.                            |
+   |------------------+------------+----------------------------------------|
+   | "sound-file"     | string     |   The path to a sound file to play     |
+   |                  |            | when the notification pops up.         |
+   |------------------+------------+----------------------------------------|
+   |                  |            |   Causes the server to suppress        |
+   |                  |            | playing any sounds, if it has that     |
+   | "suppress-sound" | boolean    | ability. This is usually set when the  |
+   |                  |            | client itself is going to play its own |
+   |                  |            | sound.                                 |
+   |------------------+------------+----------------------------------------|
+   |                  |            |   Specifies the X location on the      |
+   | "x"              | int        | screen that the notification should    |
+   |                  |            | point to. The "y" hint must also be    |
+   |                  |            | specified.                             |
+   |------------------+------------+----------------------------------------|
+   |                  |            |   Specifies the Y location on the      |
+   | "y"              | int        | screen that the notification should    |
+   |                  |            | point to. The "x" hint must also be    |
+   |                  |            | specified.                             |
+   +------------------------------------------------------------------------+
+
+   --------------------------------------------------------------------------
+
+9. D-BUS Protocol
+
+     The following messages must be supported by all implementations.
+
+   --------------------------------------------------------------------------
+
+  9.1. Message commands
+
+    9.1.1. org.freedesktop.Notifications.GetCapabilities
+
+   STRING_ARRAY org.freedesktop.Notifications.GetCapabilities (void);
+
+     This message takes no parameters.
+
+     It returns an array of strings. Each string describes an optional
+   capability implemented by the server. The following values are defined by
+   this spec:
+
+   Table 5. Server Capabilities
+
+   +------------------------------------------------------------------------+
+   |                   |   The server will provide the specified actions to |
+   | "actions"         | the user. Even if this cap is missing, actions may |
+   |                   | still be specified by the client, however the      |
+   |                   | server is free to ignore them.                     |
+   |-------------------+----------------------------------------------------|
+   |                   |   Supports body text. Some implementations may     |
+   | "body"            | only show the summary (for instance, onscreen      |
+   |                   | displays, marquee/scrollers)                       |
+   |-------------------+----------------------------------------------------|
+   | "body-hyperlinks" |   The server supports hyperlinks in the            |
+   |                   | notifications.                                     |
+   |-------------------+----------------------------------------------------|
+   | "body-images"     |   The server supports images in the notifications. |
+   |-------------------+----------------------------------------------------|
+   |                   |   Supports markup in the body text. If marked up   |
+   | "body-markup"     | text is sent to a server that does not give this   |
+   |                   | cap, the markup will show through as regular text  |
+   |                   | so must be stripped clientside.                    |
+   |-------------------+----------------------------------------------------|
+   |                   |   The server will render an animation of all the   |
+   |                   | frames in a given image array. The client may      |
+   | "icon-multi"      | still specify multiple frames even if this cap     |
+   |                   | and/or "icon-static" is missing, however the       |
+   |                   | server is free to ignore them and use only the     |
+   |                   | primary frame.                                     |
+   |-------------------+----------------------------------------------------|
+   |                   |   Supports display of exactly 1 frame of any given |
+   | "icon-static"     | image array. This value is mutually exclusive with |
+   |                   | "icon-multi", it is a protocol error for the       |
+   |                   | server to specify both.                            |
+   |-------------------+----------------------------------------------------|
+   |                   |   The server supports sounds on notifications. If  |
+   | "sound"           | returned, the server must support the "sound-file" |
+   |                   | and "suppress-sound" hints.                        |
+   +------------------------------------------------------------------------+
+
+     New vendor-specific caps may be specified as long as they start with
+   "x-vendor". For instance, "x-gnome-foo-cap". Capability names must not
+   contain spaces. They are limited to alpha-numeric characters and dashes
+   ("-").
+
+   --------------------------------------------------------------------------
+
+    9.1.2. org.freedesktop.Notifications.Notify
+
+   UINT32 org.freedesktop.Notifications.Notify (STRING app_name, UINT32
+   replaces_id, STRING app_icon, STRING summary, STRING body, ARRAY actions,
+   DICT hints, INT32 expire_timeout);
+
+     Sends a notification to the notification server.
+
+   Table 6. Notify Parameters
+
+   +------------------------------------------------------------------------+
+   |      Name      |  Type  |                 Description                  |
+   |----------------+--------+----------------------------------------------|
+   | app_name       | STRING |   The optional name of the application       |
+   |                |        | sending the notification. Can be blank.      |
+   |----------------+--------+----------------------------------------------|
+   |                |        |   The optional notification ID that this     |
+   |                |        | notification replaces. The server must       |
+   |                |        | atomically (ie with no flicker or other      |
+   |                |        | visual cues) replace the given notification  |
+   | replaces_id    | UINT32 | with this one. This allows clients to        |
+   |                |        | effectively modify the notification while    |
+   |                |        | it's active. A value of value of 0 means     |
+   |                |        | that this notification won't replace any     |
+   |                |        | existing notifications.                      |
+   |----------------+--------+----------------------------------------------|
+   |                |        |   The optional program icon of the calling   |
+   | app_icon       | STRING | application. See [32]Icons. Can be an empty  |
+   |                |        | string, indicating no icon.                  |
+   |----------------+--------+----------------------------------------------|
+   | summary        | STRING | The summary text briefly describing the      |
+   |                |        | notification.                                |
+   |----------------+--------+----------------------------------------------|
+   | body           | STRING | The optional detailed body text. Can be      |
+   |                |        | empty.                                       |
+   |----------------+--------+----------------------------------------------|
+   |                |        |   Actions are sent over as a list of pairs.  |
+   |                |        | Each even element in the list (starting at   |
+   | actions        | ARRAY  | index 0) represents the identifier for the   |
+   |                |        | action. Each odd element in the list is the  |
+   |                |        | localized string that will be displayed to   |
+   |                |        | the user.                                    |
+   |----------------+--------+----------------------------------------------|
+   |                |        |   Optional hints that can be passed to the   |
+   |                |        | server from the client program. Although     |
+   |                |        | clients and servers should never assume each |
+   | hints          | DICT   | other supports any specific hints, they can  |
+   |                |        | be used to pass along information, such as   |
+   |                |        | the process PID or window ID, that the       |
+   |                |        | server may be able to make use of. See       |
+   |                |        | [33]Hints. Can be empty.                     |
+   |----------------+--------+----------------------------------------------|
+   |                |        |                                              |
+   |                |        |                                              |
+   |                |        |   The timeout time in milliseconds since the |
+   |                |        | display of the notification at which the     |
+   | expire_timeout | INT32  | notification should automatically close.     |
+   |                |        |                                              |
+   |                |        |   If -1, the notification's expiration time  |
+   |                |        | is dependent on the notification server's    |
+   |                |        | settings, and may vary for the type of       |
+   |                |        | notification. If 0, never expire.            |
+   +------------------------------------------------------------------------+
+
+     If replaces_id is 0, the return value is a UINT32 that represent the
+   notification. It is unique, and will not be reused unless a MAXINT number
+   of notifications have been generated. An acceptable implementation may
+   just use an incrementing counter for the ID. The returned ID is always
+   greater than zero. Servers must make sure not to return zero as an ID.
+
+     If replaces_id is not 0, the returned value is the same value as
+   replaces_id.
+
+   --------------------------------------------------------------------------
+
+    9.1.3. org.freedesktop.Notifications.CloseNotification
+
+   void org.freedesktop.Notifications.CloseNotification (UINT32 id);
+
+     Causes a notification to be forcefully closed and removed from the
+   user's view. It can be used, for example, in the event that what the
+   notification pertains to is no longer relevant, or to cancel a
+   notification with no expiration time.
+
+     The NotificationClosed signal is emitted by this method.
+
+     If the notification no longer exists, an empty D-BUS Error message is
+   sent back.
+
+   --------------------------------------------------------------------------
+
+    9.1.4. org.freedesktop.Notifications.GetServerInformation
+
+     void org.freedesktop.Notifications.GetServerInformation (out STRING
+   name, out STRING vendor, out STRING version);
+
+     This message returns the information on the server. Specifically, the
+   server name, vendor, and version number.
+
+   Table 7. GetServerInformation Return Values
+
+   +------------------------------------------------------------------------+
+   |  Name   |  Type  |                     Description                     |
+   |---------+--------+-----------------------------------------------------|
+   | name    | STRING | The product name of the server.                     |
+   |---------+--------+-----------------------------------------------------|
+   | vendor  | STRING |   The vendor name. For example, "KDE," "GNOME,"     |
+   |         |        | "freedesktop.org," or "Microsoft."                  |
+   |---------+--------+-----------------------------------------------------|
+   | version | STRING | The server's version number.                        |
+   +------------------------------------------------------------------------+
+
+   --------------------------------------------------------------------------
+
+  9.2. Signals
+
+    9.2.1. org.freedesktop.Notifications.NotificationClosed
+
+     org.freedesktop.Notifications.NotificationClosed (UINT32 id, UINT32
+   reason);
+
+     A completed notification is one that has timed out, or has been
+   dismissed by the user.
+
+   Table 8. NotificationClosed Parameters
+
+   +------------------------------------------------------------------------+
+   |  Name  |  Type  |                     Description                      |
+   |--------+--------+------------------------------------------------------|
+   | id     | UINT32 | The ID of the notification that was closed.          |
+   |--------+--------+------------------------------------------------------|
+   |        |        |                                                      |
+   |        |        |                                                      |
+   |        |        | The reason the notification was closed.              |
+   |        |        |                                                      |
+   |        |        | 1 - The notification expired.                        |
+   | reason | UINT32 |                                                      |
+   |        |        | 2 - The notification was dismissed by the user.      |
+   |        |        |                                                      |
+   |        |        | 3 - The notification was closed by a call to         |
+   |        |        | CloseNotification.                                   |
+   |        |        |                                                      |
+   |        |        | 4 - Undefined/reserved reasons.                      |
+   +------------------------------------------------------------------------+
+
+     The ID specified in the signal is invalidated before the signal is sent
+   and may not be used in any further communications with the server.
+
+   --------------------------------------------------------------------------
+
+    9.2.2. org.freedesktop.Notifications.ActionInvoked
+
+     org.freedesktop.Notifications.ActionInvoked (UINT32 id, STRING
+   action_key);
+
+     This signal is emitted when one of the following occurs:
+
+     *   The user performs some global "invoking" action upon a notification.
+       For instance, clicking somewhere on the notification itself.
+
+     *   The user invokes a specific action as specified in the original
+       Notify request. For example, clicking on an action button.
+
+   Table 9. ActionInvoked Parameters
+
+   +------------------------------------------------------------------------+
+   |    Name    |  Type  |                   Description                    |
+   |------------+--------+--------------------------------------------------|
+   | id         | UINT32 |   The ID of the notification emitting the        |
+   |            |        | ActionInvoked signal.                            |
+   |------------+--------+--------------------------------------------------|
+   | action_key | STRING |   The key of the action invoked. These match the |
+   |            |        | keys sent over in the list of actions.           |
+   +------------------------------------------------------------------------+
+
+   [34]Note   Clients should not assume the server will generate this signal.
+            Some servers may not support user interaction at all, or may not
+            support the concept of being able to "invoke" a notification.
+
+References
+
+   Visible links
+   1. mailto:mike@navi.cx
+   2. mailto:chipx86@chipx86.com
+   3. file:///tmp/html-A2Tahl#introduction
+   4. file:///tmp/html-A2Tahl#basic-design
+   5. file:///tmp/html-A2Tahl#backwards-compat
+   6. file:///tmp/html-A2Tahl#markup
+   7. file:///tmp/html-A2Tahl#hyperlinks
+   8. file:///tmp/html-A2Tahl#images
+   9. file:///tmp/html-A2Tahl#icons
+  10. file:///tmp/html-A2Tahl#categories
+  11. file:///tmp/html-A2Tahl#urgency-levels
+  12. file:///tmp/html-A2Tahl#hints
+  13. file:///tmp/html-A2Tahl#protocol
+  14. file:///tmp/html-A2Tahl#commands
+  15. file:///tmp/html-A2Tahl#command-get-capabilities
+  16. file:///tmp/html-A2Tahl#command-notify
+  17. file:///tmp/html-A2Tahl#command-close-notification
+  18. file:///tmp/html-A2Tahl#command-get-server-information
+  19. file:///tmp/html-A2Tahl#signals
+  20. file:///tmp/html-A2Tahl#signal-notification-closed
+  21. file:///tmp/html-A2Tahl#signal-action-invoked
+  22. file:///tmp/html-A2Tahl#markup
+  23. file:///tmp/html-A2Tahl#protocol
+  24. file:///tmp/html-A2Tahl#hints
+  25. file:///tmp/html-A2Tahl#categories
+  26. file:///tmp/html-A2Tahl#urgency-levels
+  27. file:///tmp/html-A2Tahl#protocol
+  28. http://freedesktop.org/mailman/listinfo/xdg
+  29. http://freedesktop.org/
+  30. http://freedesktop.org/mailman/listinfo/xdg
+  31. http://freedesktop.org/
+  32. file:///tmp/html-A2Tahl#icons
+  33. file:///tmp/html-A2Tahl#hints
diff --git a/src/lib/notification/notification.c b/src/lib/notification/notification.c
new file mode 100644 (file)
index 0000000..cf2f40d
--- /dev/null
@@ -0,0 +1,402 @@
+#include "E_Notify.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <Ecore_Data.h>
+#include "e_notify_private.h"
+
+/* private functions */
+static Ecore_List * e_notification_action_list_new();
+static E_Notification_Action *e_notification_action_new(const char *id, const char *name);
+static void e_notification_action_free(E_Notification_Action *act);
+
+/* (con|de)structor */
+
+EAPI E_Notification *
+e_notification_full_new(const char *app_name, unsigned int replaces_id, const char *app_icon, const char *summary, const char *body, int expire_timeout)
+{
+  E_Notification *n;
+
+  n = e_notification_new();
+  if (!n) return NULL;
+
+  if (app_name) n->app_name = strdup(app_name); 
+  n->replaces_id = replaces_id;
+  if (app_icon) n->app_icon = strdup(app_icon); 
+  if (summary) n->summary = strdup(summary); 
+  if (body) n->body = strdup(body);
+  n->expire_timeout = expire_timeout;
+
+
+  return n;
+}
+
+EAPI E_Notification *
+e_notification_new()
+{
+  E_Notification *n;
+  n = calloc(1, sizeof(E_Notification));
+  if (!n) return NULL;
+  n->refcount = 1;
+
+  return n;
+}
+
+EAPI void
+e_notification_ref(E_Notification *n)
+{
+  n->refcount++;
+}
+
+EAPI void
+e_notification_unref(E_Notification *n)
+{
+  if (--n->refcount == 0) e_notification_free(n);
+}
+
+EAPI void
+e_notification_free(E_Notification *n)
+{
+  if (!n) return;
+
+  if (n->app_name) free(n->app_name);
+  if (n->app_icon) free(n->app_icon);
+  if (n->summary) free(n->summary);
+  if (n->body) free(n->body);
+
+  if (n->actions) ecore_list_destroy(n->actions);
+
+  if (n->hints.category) free(n->hints.category);
+  if (n->hints.desktop) free(n->hints.desktop);
+  if (n->hints.sound_file) free(n->hints.sound_file);
+  if (n->hints.image_data) e_notification_image_free(n->hints.image_data);
+  if (n->hints.icon_data) e_notification_image_free(n->hints.icon_data);
+  free(n);
+}
+
+/* mutators */
+EAPI void
+e_notification_id_set(E_Notification *note, unsigned int id)
+{
+  note->id = id;
+}
+
+EAPI void
+e_notification_app_name_set(E_Notification *note, const char *app_name)
+{
+  if (note->app_name) free(note->app_name);
+  if (app_name) note->app_name = strdup(app_name);
+}
+
+EAPI void
+e_notification_app_icon_set(E_Notification *note, const char *app_icon)
+{
+  if (note->app_icon) free(note->app_icon);
+  if (app_icon) note->app_icon = strdup(app_icon);
+}
+
+EAPI void
+e_notification_summary_set(E_Notification *note, const char *summary)
+{
+  if (note->summary) free(note->summary);
+  if (summary) note->summary = strdup(summary);
+}
+
+EAPI void
+e_notification_body_set(E_Notification *note, const char *body)
+{
+  if (note->body) free(note->body);
+  if (body) note->body = strdup(body);
+}
+
+EAPI void
+e_notification_action_add(E_Notification *n, const char *action_id, const char *action_name)
+{
+  E_Notification_Action *a;
+
+  if (!n->actions) 
+    n->actions = e_notification_action_list_new();
+
+  a = e_notification_action_new(action_id, action_name);
+  ecore_list_append(n->actions, a);
+}
+
+
+EAPI void
+e_notification_replaces_id_set(E_Notification *note, int replaces_id)
+{
+  note->replaces_id = replaces_id;
+}
+
+EAPI void
+e_notification_timeout_set(E_Notification *note, int timeout)
+{
+  note->expire_timeout = timeout;
+}
+
+EAPI void
+e_notification_closed_set(E_Notification *note, unsigned char closed)
+{
+  note->closed = closed;
+}
+
+
+/* accessors */
+EAPI unsigned int
+e_notification_id_get(E_Notification *note)
+{
+  return note->id;
+}
+
+EAPI const char *
+e_notification_app_name_get(E_Notification *note)
+{
+  return note->app_name;
+}
+
+EAPI const char *
+e_notification_app_icon_get(E_Notification *note)
+{
+  return note->app_icon;
+}
+
+EAPI const char *
+e_notification_summary_get(E_Notification *note)
+{
+  return note->summary;
+}
+
+EAPI const char *
+e_notification_body_get(E_Notification *note)
+{
+  return note->body;
+}
+
+EAPI Ecore_List *
+e_notification_actions_get(E_Notification *note)
+{
+  return note->actions;
+}
+
+EAPI int
+e_notification_replaces_id_get(E_Notification *note)
+{
+  return note->replaces_id;
+}
+
+EAPI int
+e_notification_timeout_get(E_Notification *note)
+{
+  return note->expire_timeout;
+}
+
+EAPI unsigned char
+e_notification_closed_get(E_Notification *note)
+{
+  return note->closed;
+}
+
+/***** actions *****/
+
+static Ecore_List *
+e_notification_action_list_new()
+{
+  Ecore_List *alist;
+  alist = ecore_list_new();
+  ecore_list_free_cb_set(alist, (Ecore_Free_Cb)e_notification_action_free);
+  return alist;
+}
+
+static E_Notification_Action *
+e_notification_action_new(const char *id, const char *name)
+{
+  E_Notification_Action *act;
+  act = malloc(sizeof(E_Notification_Action));
+  act->id = strdup(id);
+  act->name = strdup(name);
+  return act;
+}
+
+
+static void
+e_notification_action_free(E_Notification_Action *act)
+{
+  if (!act) return;
+  if (act->id) free(act->id);
+  if (act->name) free(act->name);
+  free(act);
+}
+
+
+/********* hints *******/
+
+
+EAPI void 
+e_notification_hint_urgency_set(E_Notification *n, char urgency)
+{
+  n->hints.urgency = urgency;
+  n->hint_flags |= E_NOTIFICATION_HINT_URGENCY;
+}
+
+EAPI void 
+e_notification_hint_category_set(E_Notification *n, const char *category)
+{
+  if (n->hints.category) free(n->hints.category);
+  n->hints.category = strdup(category);
+  n->hint_flags |= E_NOTIFICATION_HINT_CATEGORY;
+}
+
+EAPI void 
+e_notification_hint_desktop_set(E_Notification *n, const char *desktop)
+{
+  if (n->hints.desktop) free(n->hints.desktop);
+  n->hints.desktop = strdup(desktop);
+  n->hint_flags |= E_NOTIFICATION_HINT_DESKTOP;
+}
+
+EAPI void 
+e_notification_hint_sound_file_set(E_Notification *n, const char *sound_file)
+{
+  if (n->hints.sound_file) free(n->hints.sound_file);
+  n->hints.sound_file = strdup(sound_file);
+  n->hint_flags |= E_NOTIFICATION_HINT_SOUND_FILE;
+}
+
+EAPI void 
+e_notification_hint_suppress_sound_set(E_Notification *n, char suppress_sound)
+{
+  n->hints.suppress_sound = suppress_sound;
+  n->hint_flags |= E_NOTIFICATION_HINT_SUPPRESS_SOUND;
+}
+
+EAPI void 
+e_notification_hint_xy_set(E_Notification *n, int x, int y)
+{
+  n->hints.x = x;
+  n->hints.y = y;
+  n->hint_flags |= E_NOTIFICATION_HINT_XY;
+}
+
+EAPI void 
+e_notification_hint_image_data_set(E_Notification *n, E_Notification_Image *image)
+{
+  n->hints.image_data = image;
+}
+
+
+EAPI char  
+e_notification_hint_urgency_get(E_Notification *n)
+{
+  return (n->hint_flags & E_NOTIFICATION_HINT_URGENCY ? n->hints.urgency : 1);
+}
+
+EAPI const char *
+e_notification_hint_category_get(E_Notification *n)
+{
+  return n->hints.category;
+}
+
+EAPI const char *
+e_notification_hint_desktop_get(E_Notification *n)
+{
+  return n->hints.desktop;
+}
+
+EAPI const char *
+e_notification_hint_sound_file_get(E_Notification *n)
+{
+  return n->hints.sound_file;
+}
+
+EAPI char  
+e_notification_hint_suppress_sound_get(E_Notification *n)
+{
+  return n->hints.suppress_sound;
+}
+
+EAPI int  
+e_notification_hint_xy_get(E_Notification *n, int *x, int *y)
+{
+  if (x) *x = n->hints.x;
+  if (y) *y = n->hints.y;
+
+  return (n->hint_flags & E_NOTIFICATION_HINT_XY ? 1 : 0);
+}
+
+EAPI E_Notification_Image *
+e_notification_hint_image_data_get(E_Notification *n)
+{
+  return n->hints.image_data;
+}
+
+
+EAPI E_Notification_Image *
+e_notification_hint_icon_data_get(E_Notification *n)
+{
+  return n->hints.icon_data;
+}
+
+EAPI E_Notification_Image *
+e_notification_image_new()
+{
+  E_Notification_Image *img;
+
+  img = calloc(1, sizeof(E_Notification_Image));
+  return img;
+}
+
+EAPI void
+e_notification_image_free(E_Notification_Image *img)
+{
+  if (img->data) free(img->data);
+  if (img) free(img);
+}
+
+
+EAPI Evas_Object *
+e_notification_image_evas_object_add(Evas *evas, E_Notification_Image *img)
+{
+  int *imgdata;
+  Evas_Object *o = NULL;
+
+  if (!evas || !img) return NULL;
+
+  o = evas_object_image_add(evas);
+  evas_object_resize(o, img->width, img->height);
+  evas_object_image_alpha_set(o, img->has_alpha);
+  evas_object_image_size_set(o, img->width, img->height);
+  evas_object_image_fill_set(o, 0, 0, img->width, img->height);
+  imgdata = evas_object_image_data_get(o, 1);
+
+  if (img->bits_per_sample == 8)
+    {
+      /* Although not specified.
+       * The data are very likely to come from a GdkPixbuf
+       * which align each row on a 4-bytes boundary when using RGB.
+       * And is RGBA otherwise.
+       */
+      int x, y;
+      int32_t *dest;
+      unsigned char *src;
+      for (y = 0; y < img->height; y++)
+        {
+          src  = img->data + y * img->rowstride;
+          dest = imgdata + y * img->width;
+
+          for (x = 0; x < img->width; x++, src += img->channels, dest++)
+            {
+              *dest  = *(src + 2);
+              *dest += *(src + 1) << 8;
+              *dest += *(src + 0) << 16;
+              if (img->has_alpha)
+                *dest += *(src + 3) << 24;
+              else
+                *dest += 255 << 24;
+            }
+        }
+    }
+  evas_object_image_data_update_add(o, 0, 0, img->width, img->height);
+  evas_object_image_data_set(o, imgdata);
+  return o;
+}