Initial revision
authorFrederic PAUT <frederic.paut@linux.intel.com>
Wed, 8 Feb 2012 15:23:18 +0000 (16:23 +0100)
committerFrederic PAUT <frederic.paut@linux.intel.com>
Wed, 8 Feb 2012 15:23:18 +0000 (16:23 +0100)
35 files changed:
.gitignore [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
README [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
doxygen.cfg.in [new file with mode: 0644]
lib/Makefile.am [new file with mode: 0644]
lib/interface/org.neard.Adapter.xml [new file with mode: 0644]
lib/interface/org.neard.Manager.xml [new file with mode: 0644]
lib/interface/org.neard.Record.xml [new file with mode: 0644]
lib/interface/org.neard.Target.xml [new file with mode: 0644]
lib/neardal.c [new file with mode: 0644]
lib/neardal.h [new file with mode: 0644]
lib/neardal_adapter.c [new file with mode: 0644]
lib/neardal_adapter.h [new file with mode: 0644]
lib/neardal_errors.c [new file with mode: 0644]
lib/neardal_errors.h [new file with mode: 0644]
lib/neardal_manager.c [new file with mode: 0644]
lib/neardal_manager.h [new file with mode: 0644]
lib/neardal_prv.h [new file with mode: 0644]
lib/neardal_record.c [new file with mode: 0644]
lib/neardal_record.h [new file with mode: 0644]
lib/neardal_target.c [new file with mode: 0644]
lib/neardal_target.h [new file with mode: 0644]
lib/neardal_tools.c [new file with mode: 0644]
lib/neardal_tools.h [new file with mode: 0644]
lib/neardal_traces.c [new file with mode: 0644]
lib/neardal_traces_prv.h [new file with mode: 0644]
ncl/Makefile.am [new file with mode: 0644]
ncl/ncl.c [new file with mode: 0644]
ncl/ncl.h [new file with mode: 0644]
ncl/ncl_cmd.c [new file with mode: 0644]
ncl/ncl_cmd.h [new file with mode: 0644]
neardal.pc.in [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..31599b4
--- /dev/null
@@ -0,0 +1,36 @@
+# Specific files
+compile
+configure
+depcomp
+install-sh
+missing
+aclocal.m4
+Makefile
+Makefile.in
+lib/Makefile
+lib/Makefile.in
+lib/libnfc.la
+lib/neard-adapter-proxy.h
+lib/neard-manager-proxy.h
+lib/neard-record-proxy.h
+lib/neard-target-proxy.h
+libnfc.pc
+libtool
+ltmain.sh
+ncl/.deps/
+ncl/.libs/
+ncl/Makefile
+ncl/Makefile.in
+ncl/ncl
+stamp-h1
+
+# Use wildcards as well
+*~
+config.*
+*.lo
+*.o
+
+# Specific directories and files in a directory.
+autom4te.cache/*
+lib/.*
+
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..82c7058
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Frederic PAUT <frederic.paut@intel.com>
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..09ea84e
--- /dev/null
@@ -0,0 +1,18 @@
+EXTRA_DIST = neardal.pc.in
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = neardal.pc
+
+SUBDIRS = lib ncl
+
+#Rule to generate doxygen documentation
+if HAVE_DOXYGEN
+doxyfile.stamp:
+       $(DOXYGEN) doxygen.cfg
+       echo Timestamp > doxyfile.stamp
+
+CLEANFILES = ./doxyfile.stamp
+
+doc: doxyfile.stamp
+endif
+
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..fc4a680
--- /dev/null
+++ b/README
@@ -0,0 +1,40 @@
+Neardal Library
+================
+
+Copyright (C) 2012  Intel Corporation. All rights reserved.
+
+
+
+Provides a simple C APIs to exchange datas with our NFC daemon (Neard) present on the system.
+
+
+Features
+========
+
+Supported Backends:
+       - Neard
+
+Supported Main Loop:
+       - Glib
+
+
+Compiling
+=========
+
+./autogen.sh
+
+./configure   (see ./configure --help for more information)
+
+make
+
+
+Testing
+=======
+
+Compile neardal and get Neard running. 
+under ncl directory (ncl:Neardal Command Line) run:
+
+./ncl
+
+This command line interpretor include a set of the main commands use to test neardal/Neard.
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..798eba2
--- /dev/null
@@ -0,0 +1,6 @@
+aclocal
+libtoolize --copy
+autoheader
+autoconf
+automake --add-missing --copy --foreign
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..f4fa433
--- /dev/null
@@ -0,0 +1,69 @@
+AC_INIT([libneardal], [0.1.0])
+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AC_PROG_LIBTOOL
+AC_CONFIG_HEADERS([config.h])
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+## Default values
+CFLAGS="-W -Wall"
+## Compiled in debug mode
+debug=yes
+## Compiled with traces
+traces=yes
+
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+## Compiler option
+## Debug ?
+AC_ARG_ENABLE(debug, AC_HELP_STRING([--disable-debug],
+                       [disable compiling with debugging information]), [
+       if (test "${enableval}" = "no" &&
+                               test "${ac_cv_prog_cc_g}" = "yes"); then
+               debug=no
+       fi
+])
+
+if (test "${debug}" = "yes"); then
+       CFLAGS="$CFLAGS -g -O0"
+       echo 'NEARDAL will be compiled in debug mode. CFLAGS='${CFLAGS}
+else
+       CFLAGS="$CFLAGS -O2"
+       echo 'NEARDAL will not be compiled in debug mode. CFLAGS='${CFLAGS}
+fi
+
+## Traces ?
+AC_ARG_ENABLE(traces, AC_HELP_STRING([--disable-traces],
+                       [remove traces while compiling]), [
+       if (test "${enableval}" = "no"); then
+               traces=no
+               echo 'NEARDAL will be compiled without traces... ('NEARDAL_TRACES' will not be defined)'
+       fi
+])
+if (test "${traces}" = "yes"); then
+       CFLAGS="$CFLAGS -DNEARDAL_TRACES"
+       echo 'NEARDAL will be compiled with traces...('NEARDAL_TRACES' will be defined)'
+fi
+
+## Check dependances
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.22, dummy=yes,
+                               AC_MSG_ERROR(GLib >= 2.22 is required))
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+PKG_CHECK_MODULES(DBUS, dbus-glib-1, [have_dbus="yes"], [have_dbus="no"])
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
+AC_CHECK_PROGS([DOXYGEN], [doxygen])
+if test -z "$DOXYGEN";
+   then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
+fi
+AM_CONDITIONAL([HAVE_DOXYGEN],
+[test -n "$DOXYGEN"])AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doxygen.cfg])])
+
+AC_CONFIG_FILES([Makefile lib/Makefile ncl/Makefile neardal.pc])
+
+
+AC_OUTPUT
diff --git a/doxygen.cfg.in b/doxygen.cfg.in
new file mode 100644 (file)
index 0000000..e81a907
--- /dev/null
@@ -0,0 +1,1719 @@
+# Doxyfile 1.7.4
+
+# 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
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = "neardal library"
+
+# 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         = 
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description 
+# for a project that appears at the top of each page and should give viewer 
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = "Neard Abstraction Library"
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is 
+# included in the documentation. The maximum height of the logo should not 
+# exceed 55 pixels and the maximum width should not exceed 200 pixels. 
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           = 
+
+# 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: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# 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       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# 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    = NO
+
+# 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        = 
+
+# 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 if your file system 
+# 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 regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_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 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               = 8
+
+# 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
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it 
+# parses. With this tag you can assign which parser to use for a given extension. 
+# Doxygen has a built-in mapping, but you can override or extend it using this 
+# tag. The format is ext=language, where ext is a file extension, and language 
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, 
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make 
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C 
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions 
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# 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 makes the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# 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
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 
+# unions are shown inside the group in which they are included (e.g. using 
+# @ingroup) instead of on a separate page (for HTML and Man pages) or 
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
+# determine which symbols to keep in memory and which to flush to disk. 
+# When the cache is full, less often used symbols will be written to disk. 
+# For small to medium size projects (<1000 input files) the default value is 
+# probably good enough. For larger projects a too small cache size can cause 
+# doxygen to be busy swapping symbols to and from disk most of the time 
+# causing a significant performance penalty. 
+# If the system has enough physical memory increasing the cache will improve the 
+# performance by keeping more symbols in memory. Note that the value works on 
+# a logarithmic scale so increasing the size by one will roughly double the 
+# memory usage. The cache size is given by this formula: 
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# 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 this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES   = 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      = NO
+
+# 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 FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 
+# will list include files with double quotes in the documentation 
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# 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        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 
+# will sort the (brief and detailed) documentation of class members so that 
+# constructors and destructors are listed first. If set to NO (the default) 
+# the constructors will appear in the respective orders defined by 
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# 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
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 
+# do proper type resolution of all parameters of a function it will reject a 
+# match between the prototype and the implementation of a member function even 
+# if there is only one candidate or it is obvious which candidate to choose 
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = 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 macro 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 macros 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
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index 
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# 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    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 
+# by doxygen. The layout file controls the global structure of the generated 
+# output files in an output format independent way. The create the layout file 
+# that represents doxygen's defaults, run doxygen with the -l option. 
+# You can optionally specify a file name after the option, if omitted 
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            = 
+
+#---------------------------------------------------------------------------
+# 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
+
+# The WARN_NO_PARAMDOC option can be enabled 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       = NO
+
+# 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           = 
+
+#---------------------------------------------------------------------------
+# 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                  = lib
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# 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++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS          = neardal.h \
+                         neardal_errors.h
+
+# 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              = NO
+
+# 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 file system 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 EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# 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             = 
+
+# 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 or if 
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+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
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) 
+# and it is also possible to disable source filtering for a specific pattern 
+# using *.ext= (so without naming a filter). This option only has effect when 
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS = 
+
+#---------------------------------------------------------------------------
+# 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 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# 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 documentation.
+
+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          = 
+
+#---------------------------------------------------------------------------
+# 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. Note that when using a custom header you are responsible 
+# for the proper inclusion of any scripts and style sheets that doxygen 
+# needs, which is dependent on the configuration options used. 
+# It is adviced to generate a default header using "doxygen -w html 
+# header.html footer.html stylesheet.css YourConfigFile" and then modify 
+# that header. Note that the header is subject to change so you typically 
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER            = 
+
+# 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            = 
+
+# 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        = 
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 
+# other source files which should be copied to the HTML output directory. Note 
+# that these files will be copied to the base HTML output directory. Use the 
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that 
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       = 
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 
+# Doxygen will adjust the colors in the stylesheet and background images 
+# according to this color. Hue is specified as an angle on a colorwheel, 
+# see http://en.wikipedia.org/wiki/Hue for more information. 
+# For instance the value 0 represents red, 60 is yellow, 120 is green, 
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 
+# the colors in the HTML output. For a value of 0 the output will use 
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 
+# the luminance component of the colors in the HTML output. Values below 
+# 100 gradually make the output lighter, whereas values above 100 make 
+# the output darker. The value divided by 100 is the actual gamma applied, 
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 
+# page will contain the date and time when the page was generated. Setting 
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# 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 HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup. 
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify 
+# the documentation publisher. This should be a reverse domain-name style 
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# 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 compiled 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 CHM_INDEX_ENCODING 
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# 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
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 
+# that can be used as input for Qt's qhelpgenerator to generate a 
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
+# be used to specify the file name of the resulting .qch file. 
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 
+# add. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 
+# custom filter to add. For more information please see 
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> 
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 
+# project's 
+# filter section matches. 
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> 
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
+# be used to specify the location of Qt's qhelpgenerator. 
+# If non-empty doxygen will try to run qhelpgenerator on the generated 
+# .qhp file.
+
+QHG_LOCATION           = 
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files  
+# will be generated, which together with the HTML files, form an Eclipse help 
+# plugin. To install this plugin and make it available under the help contents 
+# menu in Eclipse, the contents of the directory containing the HTML and XML 
+# files needs to be copied into the plugins directory of eclipse. The name of 
+# the directory within the plugins directory should be the same as 
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin 
+# the directory name containing the HTML and XML files should also have 
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# 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          = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML 
+# documentation. Note that a value of 0 will completely suppress the enum 
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
+# structure should be generated to display hierarchical information. 
+# If the tag value 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 (i.e. any modern browser). 
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, 
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = 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
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images 
+# generated for formulas are transparent PNGs. Transparent PNGs are 
+# not supported properly for IE 6.0, but are supported on all modern browsers. 
+# Note that when changing this option you need to delete any form_*.png files 
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 
+# (see http://www.mathjax.org) which uses client side Javascript for the 
+# rendering instead of using prerendered bitmaps. Use this if you do not 
+# have LaTeX installed or if you want to formulas look prettier in the HTML 
+# output. When enabled you also need to install MathJax separately and 
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you need to specify the location relative to the 
+# HTML output directory using the MATHJAX_RELPATH option. The destination 
+# directory should contain the MathJax.js script. For instance, if the mathjax 
+# directory is located at the same level as the HTML output directory, then 
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the 
+# mathjax.org site, so you can quickly see the result without installing 
+# MathJax, but it is strongly recommended to install a local copy of MathJax 
+# before deployment.
+
+MATHJAX_RELPATH        = http://www.mathjax.org/mathjax
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box 
+# for the HTML output. The underlying search engine uses javascript 
+# and DHTML and should work on any modern browser. Note that when using 
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 
+# (GENERATE_DOCSET) there is already a search function so this one should 
+# typically be disabled. For large projects the javascript based search engine 
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be 
+# implemented using a PHP enabled web server instead of at the web client 
+# using Javascript. Doxygen will generate the search PHP script and index 
+# file to put on the web server. The advantage of the server 
+# based approach is that it scales better to large projects and allows 
+# full text search. The disadvantages are that it is more difficult to setup 
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
+#---------------------------------------------------------------------------
+# 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         = NO
+
+# 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           = pdftex
+
+# 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. 
+# Note that when enabling USE_PDFLATEX this option is only used for 
+# generating bitmaps for formulas in the HTML output, but not in the 
+# Makefile that is written to the output directory.
+
+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, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4
+
+# 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           = 
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 
+# the generated latex document. The footer should contain everything after 
+# the last chapter. If it is left blank doxygen will generate a 
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           = 
+
+# 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         = YES
+
+# 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           = YES
+
+# 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
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include 
+# source code with syntax highlighting in the LaTeX output. 
+# Note that which sources are shown also depends on other settings 
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = 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 
+# pointed to by INCLUDE_PATH will be searched when 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             = 
+
+# 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 that 
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all references to function-like macros 
+# that are alone on a line, have an all uppercase name, and do not end with a 
+# semicolon, because these 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 also works with HAVE_DOT disabled, but it is recommended to 
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = NO
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# 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               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 
+# allowed to run in parallel. When set to 0 (the default) doxygen will 
+# base this on the number of processors available in the system. You can set it 
+# explicitly to a value larger than 0 to get control over the balance 
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will write a font called Helvetica to the output 
+# directory and reference it in all dot files that doxygen generates. 
+# When you want a differently looking font you can specify the font name 
+# using DOT_FONTNAME. You need to make sure dot is able to find the font, 
+# which can be done by putting it in a standard location or by setting the 
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 
+# containing the font.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the 
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a 
+# different font using DOT_FONTNAME you can set the path where dot 
+# can find it using this tag.
+
+DOT_FONTPATH           = 
+
+# 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 options 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             = YES
+
+# 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           = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will generate a 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 svg, 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 MSCFILE_DIRS tag can be used to specify one or more directories that 
+# contain msc files that are included in the documentation (see the 
+# \mscfile command).
+
+MSCFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# 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 the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, because dot on Windows does not 
+# seem to support this out of the box. 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
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644 (file)
index 0000000..f643e84
--- /dev/null
@@ -0,0 +1,59 @@
+neardal_LT_CURRENT = 0
+neardal_LT_REVISION = 1
+neardal_LT_AGE = 0
+
+#Rule to generate the binding headers
+neard-manager-proxy.h:  interface/org.neard.Manager.xml
+       dbus-binding-tool --mode=glib-client $<> $@
+
+neard-adapter-proxy.h:  interface/org.neard.Adapter.xml
+       dbus-binding-tool --mode=glib-client $<> $@
+
+neard-target-proxy.h:  interface/org.neard.Target.xml
+       dbus-binding-tool --mode=glib-client $<> $@
+
+neard-record-proxy.h:  interface/org.neard.Record.xml
+       dbus-binding-tool --mode=glib-client $<> $@
+
+BUILT_SOURCES =        neard-manager-proxy.h \
+               neard-adapter-proxy.h \
+               neard-target-proxy.h \
+               neard-record-proxy.h
+
+neardal_PRV_HDR = \
+               neardal_adapter.h \
+               neardal_manager.h \
+               neardal_prv.h \
+               neardal_record.h \
+               neardal_target.h \
+               neardal_tools.h
+
+# We don't want to install this header
+noinst_HEADERS = $(BUILT_SOURCES) $(neardal_PRV_HDR)
+
+# We want to install these headers
+dist_neardalheaders_HEADERS =  neardal.h \
+                               neardal_errors.h
+
+CLEANFILES = $(BUILT_SOURCES)
+EXTRA_DIST = interface/org.neard.Manager.xml interface/org.neard.Adapter.xml interface/org.neard.Target.xml interface/org.neard.Record.xml
+
+lib_LTLIBRARIES =              libneardal.la
+libneardal_la_SOURCES =        neardal.c \
+                               neardal_adapter.c \
+                               neardal_errors.c \
+                               neardal_manager.c \
+                               neardal_record.c \
+                               neardal_target.c \
+                               neardal_tools.c \
+                               neardal_traces.c
+
+libneardal_la_LDFLAGS = -version-info $(neardal_LT_CURRENT):$(neardal_LT_REVISION):$(neardal_LT_AGE)
+libneardal_la_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS)
+
+libneardal_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS)
+
+neardalheadersdir = $(includedir)/neardal
+
+
+
diff --git a/lib/interface/org.neard.Adapter.xml b/lib/interface/org.neard.Adapter.xml
new file mode 100644 (file)
index 0000000..fb99d3b
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+       <interface name="org.neard.Adapter">
+               <method name="GetProperties">
+                       <arg type="a{sv}" direction="out"/>
+               </method>
+               <method name="SetProperty">
+                       <arg type="s" direction="in"/>
+                       <arg type="v" direction="in"/>
+               </method>
+               <method name="StartPoll"/>
+               <method name="StopPoll"/>
+               <method name="Publish">
+                       <arg type="a{sv}" direction="in"/>
+               </method>
+               <signal name="PropertyChanged">
+                       <arg type="s"/>
+                       <arg type="v"/>
+               </signal>
+               <signal name="TargetFound">
+                       <arg type="o"/>
+               </signal>
+               <signal name="TargetLost">
+                       <arg type="o"/>
+               </signal>
+       </interface>
+</node>
diff --git a/lib/interface/org.neard.Manager.xml b/lib/interface/org.neard.Manager.xml
new file mode 100644 (file)
index 0000000..34dabe5
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+       <interface name="org.neard.Manager">
+               <method name="GetProperties">
+                       <arg type="a{sv}" direction="out"/>
+               </method>
+               <method name="SetProperty">
+                       <arg type="s" direction="in"/>
+                       <arg type="v" direction="in"/>
+               </method>
+               <signal name="PropertyChanged">
+                       <arg type="s"/>
+                       <arg type="v"/>
+               </signal>
+               <signal name="AdapterAdded">
+                       <arg type="o"/>
+               </signal>
+               <signal name="AdapterRemoved">
+                       <arg type="o"/>
+               </signal>
+       </interface>
+</node>
+
diff --git a/lib/interface/org.neard.Record.xml b/lib/interface/org.neard.Record.xml
new file mode 100644 (file)
index 0000000..00a71b6
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+       <interface name="org.neard.Record">
+               <method name="GetProperties">
+            <arg type="a{sv}" direction="out"/>
+               </method>
+       </interface>
+</node>
+
diff --git a/lib/interface/org.neard.Target.xml b/lib/interface/org.neard.Target.xml
new file mode 100644 (file)
index 0000000..a07335b
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+       <interface name="org.neard.Target">
+               <method name="GetProperties">
+            <arg type="a{sv}" direction="out"/>
+               </method>
+               <method name="SetProperty">
+                       <arg type="s" direction="in"/>
+                       <arg type="v" direction="in"/>
+               </method>
+               <signal name="PropertyChanged">
+                       <arg type="s"/>
+                       <arg type="v"/>
+               </signal>
+       </interface>
+</node>
+
diff --git a/lib/neardal.c b/lib/neardal.c
new file mode 100644 (file)
index 0000000..a976250
--- /dev/null
@@ -0,0 +1,549 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "dbus/dbus.h"
+
+#include "neard-manager-proxy.h"
+#include "neard-adapter-proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+#include <glib-2.0/glib/glist.h>
+#include <glib-2.0/glib/gerror.h>
+
+/******************************************************************************
+ * neardal_set_cb_adapter_added: setup a client callback for
+ * 'NEARDAL adapter added'.
+ * cb_adp_added = NULL to remove actual callback.
+ *****************************************************************************/
+errorCode_t neardal_set_cb_adapter_added(neardal_t neardalObj,
+                                        adapter_cb cb_adp_added,
+                                        void *user_data)
+{
+       errorCode_t err = NEARDAL_ERROR_INVALID_PARAMETER;
+
+       if (neardalObj != NULL) {
+               neardalObj->cb_adp_added = cb_adp_added;
+               neardalObj->cb_adp_added_ud = user_data;
+               err = NEARDAL_SUCCESS;
+       }
+
+       return err;
+}
+
+/******************************************************************************
+ * neardal_set_cb_adapter_removed: setup a client callback for
+ * 'NEARDAL adapter added'.
+ * cb_adp_removed = NULL to remove actual callback.
+ *****************************************************************************/
+errorCode_t neardal_set_cb_adapter_removed(neardal_t neardalObj,
+                                          adapter_cb cb_adp_removed,
+                                          void *user_data)
+{
+       errorCode_t err = NEARDAL_ERROR_INVALID_PARAMETER;
+
+       if (neardalObj != NULL) {
+               neardalObj->cb_adp_removed      = cb_adp_removed;
+               neardalObj->cb_adp_removed_ud   = user_data;
+               err                             = NEARDAL_SUCCESS;
+       }
+
+       return err;
+}
+
+/******************************************************************************
+ * neardal_set_manager_cb_property_changed: setup a client callback for
+ * 'NEARDAL Adapter Property Change'.
+ * cb_mgr_adp_property_changed = NULL to remove actual callback.
+ *****************************************************************************/
+errorCode_t neardal_set_cb_adapter_property_changed(neardal_t neardalObj,
+                                       adapter_prop_cb cb_adp_property_changed,
+                                       void *user_data)
+{
+       errorCode_t err = NEARDAL_ERROR_INVALID_PARAMETER;
+
+       if (neardalObj != NULL) {
+               neardalObj->cb_adp_prop_changed = cb_adp_property_changed;
+               neardalObj->cb_adp_prop_changed_ud      = user_data;
+               err                                     = NEARDAL_SUCCESS;
+       }
+
+       return err;
+}
+
+/******************************************************************************
+ * neardal_set_cb_adapter_added: setup a client callback for
+ * 'NEARDAL adapter added'.
+ * cb_adp_added = NULL to remove actual callback.
+ *****************************************************************************/
+errorCode_t neardal_set_cb_target_found(neardal_t neardalObj,
+                                       target_cb cb_tgt_found,
+                                       void *user_data)
+{
+       errorCode_t err = NEARDAL_ERROR_INVALID_PARAMETER;
+
+       if (neardalObj != NULL) {
+               neardalObj->cb_tgt_found        = cb_tgt_found;
+               neardalObj->cb_tgt_found_ud     = user_data;
+               err                             = NEARDAL_SUCCESS;
+       }
+
+       return err;
+}
+
+/******************************************************************************
+ * neardal_set_cb_adapter_removed: setup a client callback for
+ * 'NEARDAL adapter added'.
+ * cb_adp_removed = NULL to remove actual callback.
+ *****************************************************************************/
+errorCode_t neardal_set_cb_target_lost(neardal_t neardalObj,
+                                      target_cb cb_tgt_lost, void *user_data)
+{
+       errorCode_t err = NEARDAL_ERROR_INVALID_PARAMETER;
+
+       if (neardalObj != NULL) {
+               neardalObj->cb_tgt_lost         = cb_tgt_lost;
+               neardalObj->cb_tgt_lost_ud      = user_data;
+               err                             = NEARDAL_SUCCESS;
+       }
+
+       return err;
+}
+
+
+/******************************************************************************
+ * neardal_set_cb_record_found: setup a client callback for
+ * 'NEARDAL target record found'.
+ * cb_rcd_found = NULL to remove actual callback.
+ *****************************************************************************/
+errorCode_t neardal_set_cb_record_found(neardal_t neardalObj,
+                                       record_cb cb_rcd_found,
+                                       void *user_data)
+{
+       errorCode_t err = NEARDAL_ERROR_INVALID_PARAMETER;
+
+       if (neardalObj != NULL) {
+               neardalObj->cb_rcd_found        = cb_rcd_found;
+               neardalObj->cb_rcd_found_ud     = user_data;
+               err                             = NEARDAL_SUCCESS;
+       }
+
+       return err;
+}
+
+/******************************************************************************
+ * neardal_free_array: free adapters array, targets array or records array
+ *****************************************************************************/
+errorCode_t neardal_free_array(char ***array)
+{
+       errorCode_t     err = NEARDAL_SUCCESS;
+       char            **adps;
+
+       if (array == NULL)
+               return NEARDAL_ERROR_INVALID_PARAMETER;
+
+       adps = *array;
+       while ((*adps) != NULL) {
+               g_free(*adps);
+               adps++;
+       }
+       g_free(*array);
+       *array = NULL;
+
+       return err;
+}
+
+
+/******************************************************************************
+ * neardal_start_poll: Request Neard to start polling
+ *****************************************************************************/
+void neardal_start_poll(neardal_t neardalObj, char *adpName, errorCode_t *ec)
+{
+       errorCode_t     err             = NEARDAL_ERROR_INVALID_PARAMETER;
+       AdpProp         *adpProp        = NULL;
+
+       if (neardalObj == NULL)
+               goto exit;
+
+       err = neardal_mgr_prv_get_adapter(neardalObj, adpName,
+                                         &adpProp);
+
+       err = NEARDAL_ERROR_NO_ADAPTER;
+       if (adpProp == NULL)
+               goto exit;
+
+       if (adpProp->dbusProxy == NULL)
+               goto exit;
+
+       if (!adpProp->polling) {
+               org_neard_Adapter_start_poll(adpProp->dbusProxy,
+                                            &neardalObj->gerror);
+
+               err = NEARDAL_SUCCESS;
+               if (neardalObj->gerror != NULL) {
+                       NEARDAL_TRACE_ERR(
+                               "Error with neard dbus method (err:%d:'%s')\n"
+                                       , neardalObj->gerror->code
+                                       , neardalObj->gerror->message);
+                       err = NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR;
+                       neardal_tools_prv_free_gerror(neardalObj);
+               }
+       } else
+               err = NEARDAL_ERROR_POLLING_ALREADY_ACTIVE;
+
+exit:
+       if (ec != NULL)
+               *ec = err;
+}
+
+/******************************************************************************
+ * neardal_stop_poll: Request Neard to stop polling
+ *****************************************************************************/
+void neardal_stop_poll(neardal_t neardalObj, char *adpName, errorCode_t *ec)
+{
+       errorCode_t     err = NEARDAL_ERROR_INVALID_PARAMETER;
+       AdpProp         *adpProp        = NULL;
+
+       if (neardalObj == NULL)
+               goto exit;
+
+       err = neardal_mgr_prv_get_adapter(neardalObj, adpName,
+                                                  &adpProp);
+
+       if (adpProp == NULL)
+               goto exit;
+
+       if (adpProp->dbusProxy == NULL)
+               goto exit;
+
+       if (adpProp->polling) {
+               org_neard_Adapter_stop_poll(adpProp->dbusProxy,
+                                           &neardalObj->gerror);
+
+               err = NEARDAL_SUCCESS;
+               if (neardalObj->gerror != NULL) {
+                       NEARDAL_TRACE_ERR(
+                               "Error with neard dbus method (err:%d:'%s')\n"
+                                       , neardalObj->gerror->code
+                                       , neardalObj->gerror->message);
+                       err = NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR;
+                       neardal_tools_prv_free_gerror(neardalObj);
+               }
+       }
+
+exit:
+       if (ec != NULL)
+               *ec = err;
+}
+
+/******************************************************************************
+ * neardal_publish: Write NDEF record to an NFC tag
+ *****************************************************************************/
+errorCode_t neardal_publish(neardal_t neardalObj, neardal_record *record)
+{
+       errorCode_t     err     = NEARDAL_ERROR_INVALID_PARAMETER;
+       AdpProp         *adpProp;
+       RcdProp         rcd;
+
+       if (neardalObj == NULL || record == NULL)
+               goto exit;
+
+       err = neardal_mgr_prv_get_adapter(neardalObj, record->name,
+                                                  &adpProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+       rcd.name                = (char *) record->name;
+       rcd.action              = (char *) record->action;
+       rcd.encoding            = (char *) record->encoding;
+       rcd.handOver            = record->handOver;
+       rcd.language            = (char *) record->language;
+       rcd.type                = (char *) record->type;
+       rcd.representation      = (char *) record->representation;
+       rcd.uri                 = (char *) record->uri;
+       rcd.mime                = (char *) record->mime;
+       rcd.smartPoster         = record->smartPoster;
+
+        neardal_adp_publish(adpProp, &rcd);
+exit:
+       return err;
+}
+
+/******************************************************************************
+ * neardal_get_adapter_properties: Get properties of a specific NEARDAL adapter
+ *****************************************************************************/
+errorCode_t neardal_get_adapter_properties(neardal_t neardalObj,
+                                          const char *adpName,
+                                          neardal_adapter *adapter)
+{
+       errorCode_t     err             = NEARDAL_ERROR_INVALID_PARAMETER;
+       AdpProp         *adpProp        = NULL;
+       TgtProp         *target         = NULL;
+       int             ct              = 0;    /* counter */
+       gsize           size;
+
+       if (neardalObj == NULL || adpName == NULL || adapter == NULL)
+               goto exit;
+
+       err = neardal_mgr_prv_get_adapter(neardalObj, adpName,
+                                         &adpProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       adapter->name           = adpProp->name;
+       adapter->polling        = (short) adpProp->polling;
+       adapter->powered        = (short) adpProp->powered;
+
+       adapter->nbProtocols    = 0;
+       adapter->protocols      = NULL;
+
+       /* Count protocols */
+       while (adpProp->protocols[adapter->nbProtocols++] != NULL);
+
+       if (adapter->nbProtocols > 0) {
+               adapter->nbProtocols--;
+               err = NEARDAL_ERROR_NO_MEMORY;
+               size = (adapter->nbProtocols + 1) * sizeof(char *);
+               adapter->protocols = g_try_malloc0(size);
+               if (adapter->protocols != NULL) {
+                       ct = 0;
+                       while (ct < adapter->nbProtocols) {
+                               gchar *tmp = g_strdup(adpProp->protocols[ct]);
+                               adapter->protocols[ct] = tmp;
+                               ct++;
+                       }
+                       err = NEARDAL_SUCCESS;
+               }
+       }
+
+       adapter->nbTargets      = g_list_length(adpProp->tgtList);
+       adapter->targets        = NULL;
+       if (adapter->nbTargets <= 0)
+               goto exit;
+
+       err = NEARDAL_ERROR_NO_MEMORY;
+       size = (adapter->nbTargets + 1) * sizeof(char *);
+       adapter->targets = g_try_malloc0(size);
+       if (adapter->targets == NULL)
+               goto exit;
+
+       ct = 0;
+       while (ct < adapter->nbTargets) {
+               target = g_list_nth_data(adpProp->tgtList, ct);
+               if (target != NULL)
+                       adapter->targets[ct++] = g_strdup(target->name);
+       }
+       err = NEARDAL_SUCCESS;
+
+exit:
+       return err;
+}
+
+/******************************************************************************
+ * neardal_get_adapter_properties: Get properties of a specific NEARDAL adapter
+ *****************************************************************************/
+errorCode_t neardal_get_target_properties(neardal_t neardalObj,
+                                         const char *tgtName,
+                                         neardal_target *target)
+{
+       errorCode_t     err             = NEARDAL_ERROR_INVALID_PARAMETER;
+       AdpProp         *adpProp        = NULL;
+       TgtProp         *tgtProp        = NULL;
+       int             ct              = 0;    /* counter */
+       RcdProp         *record         = NULL;
+       gsize           size;
+
+       if (neardalObj == NULL || tgtName == NULL || target == NULL)
+               goto exit;
+
+       target->records = NULL;
+       target->tagType = NULL;
+       err = neardal_mgr_prv_get_adapter(neardalObj, tgtName,
+                                                  &adpProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       err = neardal_mgr_prv_get_target(adpProp, tgtName, &tgtProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       target->name            = tgtProp->name;
+       target->type            = tgtProp->type;
+       target->readOnly        = tgtProp->readOnly;
+       target->nbRecords       = g_list_length(tgtProp->rcdList);
+       if (target->nbRecords > 0) {
+               err = NEARDAL_ERROR_NO_MEMORY;
+               size = (target->nbRecords + 1) * sizeof(char *);
+               target->records = g_try_malloc0(size);
+               if (target->records == NULL)
+                       goto exit;
+
+               ct = 0;
+               while (ct < target->nbRecords) {
+                       record = g_list_nth_data(tgtProp->rcdList, ct);
+                       if (record != NULL)
+                               target->records[ct++] = g_strdup(record->name);
+               }
+               err = NEARDAL_SUCCESS;
+       }
+
+       target->nbTagTypes = 0;
+       target->tagType = NULL;
+       /* Count TagTypes */
+       while (tgtProp->tagType[target->nbTagTypes++] != NULL);
+
+       if (target->nbTagTypes <= 0)
+               goto exit;
+
+       target->nbTagTypes--;
+       err = NEARDAL_ERROR_NO_MEMORY;
+       size = (target->nbTagTypes + 1) * sizeof(char *);
+       target->tagType = g_try_malloc0(size);
+       if (target->tagType == NULL)
+               goto exit;
+
+       ct = 0;
+       while (ct < target->nbTagTypes) {
+               target->tagType[ct] = g_strdup(tgtProp->tagType[ct]);
+               ct++;
+       }
+       err = NEARDAL_SUCCESS;
+
+exit:
+       return err;
+}
+
+ /******************************************************************************
+ * neardal_get_record_properties: Get values of a specific target record
+  *****************************************************************************/
+errorCode_t neardal_get_record_properties(neardal_t neardalObj,
+                                         const char *recordName,
+                                         neardal_record *record)
+{
+       errorCode_t     err             = NEARDAL_ERROR_INVALID_PARAMETER;
+       AdpProp         *adpProp        = NULL;
+       TgtProp         *tgtProp        = NULL;
+       RcdProp         *rcdProp        = NULL;
+
+       if (neardalObj == NULL || recordName == NULL || record == NULL)
+               goto exit;
+
+       err = neardal_mgr_prv_get_adapter(neardalObj, recordName,
+                                                  &adpProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       err = neardal_mgr_prv_get_target(adpProp, recordName
+                                               , &tgtProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       err = neardal_mgr_prv_get_record(tgtProp, recordName
+                                       , &rcdProp);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       record->name            = rcdProp->name;
+       record->encoding        = rcdProp->encoding;
+       record->handOver        = (short) rcdProp->handOver;
+       record->language        = rcdProp->language;
+       record->smartPoster     = (short) rcdProp->smartPoster;
+       record->action          = rcdProp->action;
+
+       record->type            = rcdProp->type;
+       record->representation  = rcdProp->representation;
+       record->uri             = rcdProp->uri;
+       record->mime            = rcdProp->mime;
+
+exit:
+       return err;
+}
+
+
+/******************************************************************************
+ * neardal_construct: create NEARDAL object instance, Neard Dbus connection,
+ * register Neard's events
+ *****************************************************************************/
+neardal_t neardal_construct(errorCode_t *ec)
+{
+       neardal_t       neardalObj      = NULL;
+       errorCode_t     err     = NEARDAL_ERROR_NO_MEMORY;
+
+       NEARDAL_TRACEIN();
+       /* Allocate NEARDAL context */
+       neardalObj = g_try_malloc0(sizeof(neardalCtx));
+       if (neardalObj == NULL)
+               goto exit;
+
+       /* Create DBUS connection */
+       g_type_init();
+       neardalObj->conn = dbus_g_bus_get(DBUS_BUS_SYSTEM,
+                                          &neardalObj->gerror);
+       if (neardalObj->conn != NULL) {
+               /* We have a DBUS connection, create proxy on Neard Manager */
+               err =  neardal_mgr_init(neardalObj);
+               if (err != NEARDAL_SUCCESS) {
+                       NEARDAL_TRACEF(
+                               "neardal_mgr_init() exit (err %d: %s)\n",
+                               err, neardal_error_get_text(err));
+
+                       /* No Neard daemon, destroying neardal object... */
+                       if (err == NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY) {
+                               neardal_tools_prv_free_gerror(neardalObj);
+                               g_free(neardalObj);
+                               neardalObj = NULL;
+                       }
+               }
+       } else {
+               NEARDAL_TRACE_ERR("Unable to connect to dbus: %s\n",
+                                neardalObj->gerror->message);
+               neardal_tools_prv_free_gerror(neardalObj);
+               err = NEARDAL_ERROR_DBUS;
+               g_free(neardalObj);
+               neardalObj = NULL;
+       }
+
+exit:
+       if (ec != NULL)
+               *ec = err;
+
+       NEARDAL_TRACEF("Exit\n");
+       return neardalObj;
+}
+
+
+/******************************************************************************
+ * neardal_destroy: destroy NEARDAL object instance, Disconnect Neard Dbus
+ * connection, unregister Neard's events
+ *****************************************************************************/
+void neardal_destroy(neardal_t neardalObj)
+{
+       NEARDAL_TRACEIN();
+       if (neardalObj != NULL) {
+               neardal_mgr_release(neardalObj);
+               neardal_tools_prv_free_gerror(neardalObj);
+               g_free(neardalObj);
+       }
+}
diff --git a/lib/neardal.h b/lib/neardal.h
new file mode 100644 (file)
index 0000000..7187152
--- /dev/null
@@ -0,0 +1,408 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+/*!
+ * @file neardal.h
+ *
+ * @brief Defines main NEARDAL apis and data types.
+ * @author Frederic PAUT, Intel Corporation
+ * @version 0.1
+ *
+ ******************************************************************************/
+
+#ifndef __NEARDAL_H
+#define __NEARDAL_H
+#include "neardal_errors.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/*! @typedef neardal_t
+ *  @brief NEARDAL Context
+ */
+typedef struct neardalCtx      *neardal_t;
+
+/*!
+ * @addtogroup NEARDAL_COMMON_TYPES Types
+ * @ingroup NEARDAL_COMMON
+ * @{
+  */
+/*!
+ * @brief NEARDAL Adapter client properties.
+ **/
+typedef struct {
+/*! \brief DBus interface adapter name (as identifier) */
+       char    *name;
+/*! \brief Neard adapter polling already active ? */
+       short   polling;
+/*! \brief Neard adapter powered ? */
+       short   powered;
+/*! \brief Number of supported protocols */
+       int     nbProtocols;
+/*! \brief Neard adapter supported protocols list (use  @link
+ * neardal_free_array @endlink(& ) to free) */
+       char    **protocols;
+/*! \brief Number of targets managed by this adapter */
+       int     nbTargets;
+/*! \brief Neard adapter targets list (use @link neardal_free_array @endlink
+ *(& ) to free) */
+       char    **targets;
+} neardal_adapter;
+
+/*!
+ * @brief NEARDAL Target client properties.
+*/
+typedef struct {
+/*! @brief DBus interface target name (as identifier) */
+       const char      *name;
+
+/*! @brief Number of records in target */
+       int             nbRecords;
+/*! @brief target records list (use @link neardal_free_array @endlink (& ) to
+ * free) */
+       char            **records;
+/*! @brief Number of supported 'types' in target */
+       int             nbTagTypes;
+/*! @brief types list (use @link neardal_free_array @endlink(& ) to free) */
+       char            **tagType;
+/*! @brief target type */
+       const char      *type;
+/*! @brief Read-Only flag (is target writable?) */
+       short           readOnly;
+} neardal_target;
+
+/*!
+ * @brief NEARDAL Record client properties.
+*/
+typedef struct {
+/*! @brief DBus interface name (as identifier) */
+       const char      *name;
+/*! @brief character encoding */
+       const char      *encoding;
+/*! @brief connection established using other wireless communication
+technologies */
+       short           handOver;
+/*! @brief internation language used */
+       const char      *language;
+/*! @brief is tag smartposter? */
+       short           smartPoster;
+/*! @brief 'Action' Save, Edit, Download... */
+       const char      *action;
+/*! @brief tag type: 'Text', 'Uri', 'MIME Type' */
+       const char      *type;
+/*! @brief Text datas */
+       const char      *representation;
+/*! @brief Uri datas */
+       const char      *uri;
+/*! @brief MIME Type datas */
+       const char      *mime;
+} neardal_record;
+
+/* @}*/
+
+/*! @brief NEARDAL Callbacks
+ * @addtogroup NEARDAL_CALLBACK Callbacks
+ * @{
+*/
+
+/**
+ * @brief Callback prototype for 'NEARDAL adapter added/removed'
+ *
+ * @param adpName DBus interface adapter name (as identifier)
+ * @param user_data Client user data
+ **/
+typedef void (*adapter_cb) (const char *adpName, void *user_data);
+/**
+ * @brief Callback prototype for 'NEARDAL adapter property changed'
+ *
+ * @param adpName DBus interface adapter name (as identifier)
+ * @param propName Property name
+ * @param value Property value
+ * @param user_data Client user data
+ **/
+typedef void (*adapter_prop_cb) (char *adpName, char *propName, void * value,
+                                void *user_data);
+
+/** @brief NEARDAL Target Callbacks (TargetFound/Lost)
+*/
+/**
+ * @brief Callback prototype for 'NEARDAL target found/lost'
+ *
+ * @param tgtName DBus interface target name (as identifier)
+ * @param user_data Client user data
+ **/
+typedef void (*target_cb) (const char *tgtName, void *user_data);
+
+/** @brief NEARDAL Record Callbacks ('RecordFound')
+*/
+/**
+ * @brief Callback prototype for 'NEARDAL record found'
+ *
+ * @param rcdName DBus interface record name (as identifier)
+ * @param user_data Client user data
+ **/
+typedef void (*record_cb) (const char *rcdName, void *user_data);
+
+/* @}*/
+
+
+
+/*! @brief NEARDAL APIs
+ *  @note NEARDAL lib exported functions
+ * @addtogroup NEARDAL_APIS APIs
+ * @{
+*/
+
+/*! \fn neardal_t neardal_construct(errorCode_t *ec)
+*  \brief create NEARDAL object instance, Neard Dbus connection,
+* register Neard's events
+*  \param ec : optional, pointer to store error code
+*  \return the NEARDAL context
+*/
+neardal_t neardal_construct(errorCode_t *ec);
+
+
+/*! \fn void neardal_destroy(neardal_t neardalObj)
+*  \brief destroy NEARDAL object instance, disconnect Neard Dbus connection,
+* unregister Neard's events
+*  \param neardalObj : NEARDAL context to destroy
+*/
+void neardal_destroy(neardal_t neardalObj);
+
+/*! \fn void neardal_start_poll(neardal_t neardalObj, char *adpName,
+ * errorCode_t *ec)
+*  \brief Request Neard to start polling on specific NEARDAL adapter
+*  \param neardalObj : NEARDAL context
+*  \param adpName : DBus interface adapter name (as identifier)
+*  \param ec : optional, pointer to store error code
+*/
+void neardal_start_poll(neardal_t neardalObj, char *adpName,
+                        errorCode_t *ec);
+
+/*! \fn void neardal_stop_poll(neardal_t neardalObj, char *adpName,
+ * errorCode_t *ec)
+*  \brief Request Neard to stop polling on specific NEARDAL adapter
+*  \param neardalObj : NEARDAL context
+*  \param adpName : DBus interface adapter name (as identifier)
+*  \param ec : optional, pointer to store error code
+*/
+void neardal_stop_poll(neardal_t neardalObj, char *adpName, errorCode_t *ec);
+
+/*! \fn errorCode_t neardal_get_adapters(neardal_t neardalObj, char ***array,
+ * int *len)
+ * @brief get an array of NEARDAL adapters present
+ *
+ * @param neardalObj NEARDAL context
+ * @param array array of DBus interface adapter name (as identifier), use @link
+ * neardal_free_array @endlink(& ) to free
+ * @param len (optional), number of adapters
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_adapters(neardal_t neardalObj, char ***array,
+                                 int *len);
+
+/*! \fn errorCode_t neardal_get_targets(neardal_t neardalObj, char *adpName,
+ *                                  char ***array, int *len)
+ * @brief get an array of NEARDAL targets present
+ *
+ * @param neardalObj NEARDAL context
+ * @param adpName adapter name (identifier) on which targets list must be
+ * retrieve
+ * @param array array of DBus interface target name (as identifier), use @link
+ * neardal_free_array @endlink(& ) to free
+ * @param len (optional), number of targets
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_targets(neardal_t neardalObj, char *adpName,
+                                char ***array, int *len);
+
+/*! \fn errorCode_t neardal_get_records(neardal_t neardalObj, char *tgtName,
+ *                                  char ***array, int *len)
+ * @brief get an array of NEARDAL records present
+ *
+ * @param neardalObj NEARDAL context
+ * @param tgtName target name (identifier) on which records list must be
+ * retrieve
+ * @param array array of DBus interface record name (as identifier), use @link
+ * neardal_free_array @endlink(& ) to free
+ * @param len (optional), number of records
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_records(neardal_t neardalObj, char *tgtName,
+                                char ***array, int *len);
+
+/*! @fn errorCode_t neardal_free_array(char ***array)
+ *
+ * @brief free memory used for adapters array, targets array or records array
+ *
+ * @param array adapters array, targets array or records array
+ * @return errorCode_t error code
+ *
+ **/
+errorCode_t neardal_free_array(char ***array);
+
+/*! \fn errorCode_t neardal_get_adapter_properties(neardal_t neardalObj,
+ * const char* adpName, neardal_adapter *adapter)
+ * @brief Get properties of a specific NEARDAL adapter
+ *
+ * @param neardalObj NEARDAL context
+ * @param adpName DBus interface adapter name (as identifier)
+ * @param adapter Pointer on client adapter struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_adapter_properties(neardal_t neardalObj,
+                                           const char *adpName,
+                                           neardal_adapter *adapter);
+
+/*! \fn errorCode_t neardal_set_cb_adapter_added(neardal_t neardalObj,
+ *                                          adapter_cb cb_adp_added,
+ *                                          void * user_data)
+ * @brief setup a client callback for 'NEARDAL adapter added'. cb_adp_added = NULL
+ * to remove actual callback
+ *
+ * @param neardalObj NEARDAL context
+ * @param cb_adp_added Client callback 'adapter added'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_adapter_added(neardal_t neardalObj,
+                                         adapter_cb cb_adp_added,
+                                         void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_adapter_removed(neardal_t neardalObj,
+ *                                            adapter_cb cb_adp_removed,
+ *                                            void * user_data)
+ * @brief setup a client callback for 'NEARDAL adapter removed'.
+ * cb_adp_removed = NULL to remove actual callback
+ *
+ * @param neardalObj NEARDAL context
+ * @param cb_adp_removed Client callback 'adapter removed'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_adapter_removed(neardal_t neardalObj,
+                                           adapter_cb cb_adp_removed,
+                                           void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_adapter_property_changed(
+ * neardal_t neardalObj, adapter_prop_cb cb_adp_property_changed,
+ * void *user_data)
+ * @brief setup a client callback for 'NEARDAL Adapter Property Changed'.
+ * cb_adp_property_changed = NULL to remove actual callback.
+ *
+ * @param neardalObj NEARDAL context
+ * @param cb_adp_property_changed Client callback 'Adapter Property Changed'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_adapter_property_changed(neardal_t neardalObj,
+                                       adapter_prop_cb cb_adp_property_changed,
+                                               void *user_data);
+
+/*! \fn errorCode_t neardal_get_target_properties(neardal_t neardalObj,
+ * const char* tgtName, neardal_target *target)
+ * @brief Get properties of a specific NEARDAL target
+ *
+ * @param neardalObj NEARDAL context
+ * @param tgtName target name (identifier) on which properties must be retrieve
+ * @param target Pointer on client target struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_target_properties(neardal_t neardalObj,
+                                          const char *tgtName,
+                                          neardal_target *target);
+
+/*! \fn errorCode_t neardal_set_cb_target_found(neardal_t neardalObj,
+ * target_cb cb_tgt_found, void * user_data)
+ * @brief setup a client callback for 'NEARDAL target found'.
+ * cb_tgt_found = NULL to remove actual callback.
+ *
+ * @param neardalObj NEARDAL context
+ * @param cb_tgt_found Client callback 'target found'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_target_found(neardal_t neardalObj,
+                                        target_cb cb_tgt_found,
+                                        void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_target_lost(neardal_t neardalObj,
+ * target_cb cb_tgt_lost, void * user_data)
+ * @brief setup a client callback for 'NEARDAL target lost'.
+ * cb_tgt_lost = NULL to remove actual callback.
+ *
+ * @param neardalObj NEARDAL context
+ * @param cb_tgt_lost Client callback 'target lost'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_target_lost(neardal_t neardalObj,
+                                       target_cb cb_tgt_lost,
+                                       void *user_data);
+
+
+/*! \fn errorCode_t neardal_get_record_properties(neardal_t neardalObj,
+ *                                           const char *recordName,
+ *                                           neardal_record *record)
+ * @brief Get properties of a specific NEARDAL target record
+ *
+ * @param neardalObj NEARDAL context
+ * @param recordName DBus interface record name (as identifier)
+ * @param record Pointer on client record struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_record_properties(neardal_t neardalObj,
+                                          const char *recordName,
+                                          neardal_record *record);
+
+/*! \fn errorCode_t neardal_publish(neardal_t neardalObj,
+ * neardal_record *record)
+ * @brief Write NDEF record to an NFC tag
+ *
+ * @param neardalObj NEARDAL context
+ * @param record Pointer on client record used to create NDEF record
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_publish(neardal_t neardalObj, neardal_record *record);
+
+
+/*! \fn errorCode_t neardal_set_cb_record_found(neardal_t neardalObj,
+ * record_cb cb_rcd_found, void * user_data)
+ * @brief Setup a client callback for 'NEARDAL target record found'.
+ * cb_rcd_found = NULL to remove actual callback
+ *
+ * @param neardalObj NEARDAL context
+ * @param cb_rcd_found Client callback 'record found'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_record_found(neardal_t neardalObj,
+                                        record_cb cb_rcd_found,
+                                        void *user_data);
+
+/* @}*/
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_H */
diff --git a/lib/neardal_adapter.c b/lib/neardal_adapter.c
new file mode 100644 (file)
index 0000000..55af121
--- /dev/null
@@ -0,0 +1,549 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "dbus/dbus.h"
+
+#include "neard-adapter-proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+#include <glib-2.0/glib/gerror.h>
+#include <glib-2.0/glib/glist.h>
+
+
+/******************************************************************************
+ * neardal_adp_prv_cb_target_found: Callback called when a NFC target is
+ * found
+ *****************************************************************************/
+static void  neardal_adp_prv_cb_target_found(DBusGProxy  *proxy,
+                                            const char *str0,
+                                            void        *user_data)
+{
+       neardal_t       neardalObj      = user_data;
+       AdpProp         *adpProp        = NULL;
+       errorCode_t     err;
+
+       NEARDAL_TRACEIN();
+       g_assert(str0 != NULL);
+       (void) proxy; /* remove warning */
+
+       neardal_mgr_prv_get_adapter(neardalObj, (char *) str0, &adpProp);
+
+       NEARDAL_TRACEF("Adding target '%s'\n", str0);
+       /* Invoking Callback 'Target Found' before adding it (otherwise
+        * callback 'Record Found' would be called before ) */
+       err = neardal_tgt_add(neardalObj, (char *) str0);
+       if (err != NEARDAL_SUCCESS) {
+               if (neardalObj->cb_tgt_found != NULL)
+                       (neardalObj->cb_tgt_found)((char *) str0,
+                                             neardalObj->cb_tgt_found_ud);
+       }
+       NEARDAL_TRACEF("NEARDAL LIB targetList contains %d elements\n",
+                     g_list_length(adpProp->tgtList));
+}
+
+/******************************************************************************
+ * neardal_adp_prv_cb_target_lost: Callback called when a NFC target is
+ * lost (removed)
+ *****************************************************************************/
+static void neardal_adp_prv_cb_target_lost(DBusGProxy  *proxy,
+                                               const char *str0,
+                                               void *user_data)
+{
+       neardal_t       neardalObj      = user_data;
+       AdpProp         *adpProp        = NULL;
+       TgtProp         *tgtProp        = NULL;
+       errorCode_t     errCode;
+
+       NEARDAL_TRACEIN();
+       g_assert(neardalObj != NULL);
+       g_assert(str0 != NULL);
+       (void) proxy; /* remove warning */
+
+       neardal_mgr_prv_get_adapter(neardalObj, (char *) str0, &adpProp);
+
+       NEARDAL_TRACEF("Removing target '%s'\n", str0);
+       /* Invoking Callback 'Target Found' before adding it (otherwise
+        * callback 'Record Found' would be called before ) */
+       errCode = neardal_mgr_prv_get_target(adpProp, (char *) str0,
+                                                 &tgtProp);
+       if (errCode == NEARDAL_SUCCESS) {
+               if (neardalObj->cb_tgt_lost != NULL)
+                       (neardalObj->cb_tgt_lost)((char *) str0,
+                                             neardalObj->cb_tgt_lost_ud);
+               neardal_tgt_remove(tgtProp);
+               adpProp->tgtList = g_list_remove(adpProp->tgtList,
+                                                    (gconstpointer) tgtProp);
+               NEARDAL_TRACEF("NEARDAL LIB targetList contains %d elements\n",
+                             g_list_length(adpProp->tgtList));
+       }
+}
+
+/******************************************************************************
+ * neardal_adp_prv_cb_property_changed: Callback called when a NFC target
+ * is found
+ *****************************************************************************/
+static void neardal_adp_prv_cb_property_changed(DBusGProxy *proxy,
+                                               const char *str0,
+                                               GValue      *gvalue,
+                                               void        *user_data)
+{
+       neardal_t               neardalObj              = user_data;
+       AdpProp         *adpProp        = user_data;
+       GPtrArray       *pathsGpa       = NULL;
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_TARGET;
+       char            *tgtName        = NULL;
+       void            *clientValue    = NULL;
+       TgtProp         *tgtProp        = NULL;
+
+       NEARDAL_TRACEIN();
+       g_assert(neardalObj != NULL);
+       g_assert(str0 != NULL);
+
+       NEARDAL_TRACEF("str0='%s'\n", str0);
+       errCode = neardal_mgr_prv_get_adapter_from_proxy(neardalObj,
+                                                             proxy, &adpProp);
+       if (errCode != NEARDAL_SUCCESS)
+               goto error;
+
+       if (!strcmp(str0, "Polling")) {
+               adpProp->polling =  g_value_get_boolean(gvalue);
+               clientValue = GUINT_TO_POINTER(adpProp->polling);
+               NEARDAL_TRACEF("neardalObj->polling=%d\n", adpProp->polling);
+       }
+
+       if (!strcmp(str0, "Targets")) {
+               guint tmpLen;
+               if (!G_IS_VALUE(gvalue)) {
+                       NEARDAL_TRACE_ERR(
+                       "Unexpected value returned getting adapters: %s",
+                                         G_VALUE_TYPE_NAME(&gvalue));
+                       errCode = NEARDAL_ERROR_DBUS;
+                       goto error;
+               }
+
+               if (!G_VALUE_HOLDS(gvalue, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) {
+                       NEARDAL_TRACE_ERR(
+                               "Unexpected type returned getting adapters: %s",
+                                         G_VALUE_TYPE_NAME(&gvalue));
+                       errCode = NEARDAL_ERROR_DBUS;
+                       goto error;
+               }
+
+               /* Extract the targets arrays List from the GValue */
+               pathsGpa = g_value_get_boxed(gvalue);
+               errCode = NEARDAL_ERROR_NO_ADAPTER;
+               if (pathsGpa == NULL)
+                       goto error;
+
+               if (pathsGpa->len <= 0) {       /* Remove all targets */
+                       GList *node = NULL;
+                       NEARDAL_TRACEF(
+                               "Target array empty! Removing all targets\n");
+                       while (g_list_length(adpProp->tgtList)) {
+                               node = g_list_first(adpProp->tgtList);
+                               tgtProp = (TgtProp *) node->data;
+                               neardal_adp_prv_cb_target_lost(proxy,
+                                                              tgtProp->name,
+                                                               user_data);
+                       }
+                       errCode = NEARDAL_SUCCESS;
+                       goto exit;
+               }
+
+               tmpLen = 0;
+               while (tmpLen < pathsGpa->len) {
+                       /* Getting last target (targets list not updated with
+                        * targets lost */
+                       gvalue = g_ptr_array_index(pathsGpa, tmpLen++);
+
+                       if (gvalue == NULL)
+                               goto error;
+
+                       tgtName = g_strdup((const gchar *)gvalue);
+
+                       /* TODO : for Neard Workaround, emulate 'TargetFound'
+                        * signals */
+                       errCode = neardal_mgr_prv_get_adapter(neardalObj,
+                                                                  tgtName,
+                                                                  &adpProp);
+                       if (errCode != NEARDAL_SUCCESS)
+                               goto error;
+
+                       errCode = neardal_mgr_prv_get_target(adpProp,
+                                                                 tgtName,
+                                                                 &tgtProp);
+                       if (errCode == NEARDAL_ERROR_NO_TARGET) {
+                               neardal_adp_prv_cb_target_found(proxy,
+                                                                    tgtName,
+                                                                    user_data);
+                               errCode = NEARDAL_SUCCESS;
+                       }
+               }
+       }
+
+       if (neardalObj->cb_adp_prop_changed != NULL)
+               (neardalObj->cb_adp_prop_changed)(adpProp->name, (char *) str0,
+                                             clientValue,
+                                         neardalObj->cb_adp_prop_changed_ud);
+       return;
+
+exit:
+error:
+       if (errCode != NEARDAL_SUCCESS)
+               NEARDAL_TRACEF("Exit with error code %d:%s\n", errCode,
+                             neardal_error_get_text(errCode));
+       return;
+}
+
+/******************************************************************************
+ * neardal_adp_prv_read_properties: Get Neard Adapter Properties
+ *****************************************************************************/
+static errorCode_t neardal_adp_prv_read_properties(AdpProp *adpProp)
+{
+       errorCode_t     errCode                 = NEARDAL_SUCCESS;
+       GHashTable      *neardAdapterPropHash   = NULL;
+       GError          *gerror                 = NULL;
+       void            *tmp                    = NULL;
+
+       NEARDAL_TRACEIN();
+       g_assert(adpProp != NULL);
+       g_assert(adpProp->dbusProxy != NULL);
+
+       org_neard_Adapter_get_properties(adpProp->dbusProxy,
+                                        &neardAdapterPropHash,
+                                        &gerror);
+       if (gerror != NULL) {
+               errCode = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+               NEARDAL_TRACE_ERR(
+                       "Unable to read adapter's properties (%d:%s)\n",
+                                gerror->code, gerror->message);
+               g_error_free(gerror);
+               goto exit;
+       }
+
+       errCode = neardal_tools_prv_hashtable_get(neardAdapterPropHash,
+                                               "Targets",
+                                       DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
+                                       &tmp);
+       if (errCode == NEARDAL_SUCCESS) {
+               neardal_tools_prv_g_ptr_array_copy(&adpProp->tgtArray,
+                                               tmp);
+
+       }
+
+       errCode = neardal_tools_prv_hashtable_get(neardAdapterPropHash,
+                                               "Polling",
+                                               G_TYPE_BOOLEAN,
+                                               &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               adpProp->polling = (gboolean) tmp;
+
+       errCode = neardal_tools_prv_hashtable_get(neardAdapterPropHash,
+                                               "Powered",
+                                               G_TYPE_BOOLEAN,
+                                               &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               adpProp->powered = (gboolean) tmp;
+
+       errCode = neardal_tools_prv_hashtable_get(neardAdapterPropHash,
+                                               "Protocols",
+                                               G_TYPE_STRV,
+                                               &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               adpProp->protocols = g_boxed_copy(G_TYPE_STRV, tmp);
+
+       g_hash_table_destroy(neardAdapterPropHash);
+
+exit:
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_adp_prv_get_current_target: Get current NFC target
+ *****************************************************************************/
+errorCode_t neardal_adp_prv_get_target(AdpProp *adpProp, char *tgtName,
+                                      TgtProp **tgtProp)
+{
+       errorCode_t     errCode = NEARDAL_ERROR_NO_TARGET;
+       guint           len = 0;
+       TgtProp         *tgt;
+
+       g_assert(adpProp != NULL);
+       g_assert(tgtProp != NULL);
+
+       while (len < g_list_length(adpProp->tgtList)) {
+               tgt = g_list_nth_data(adpProp->tgtList, len);
+               if (tgt != NULL) {
+                       if (!strncmp(tgt->name, tgtName, strlen(tgt->name))) {
+                               *tgtProp = tgt;
+                               errCode = NEARDAL_SUCCESS;
+                               break;
+                       }
+               }
+               len++;
+       }
+
+       return errCode;
+}
+
+
+/******************************************************************************
+ * neardal_adp_init: Get Neard Manager Properties = NFC Adapters list.
+ * Create a DBus proxy for the first one NFC adapter if present
+ * Register Neard Manager signals ('PropertyChanged')
+ *****************************************************************************/
+static errorCode_t neardal_adp_prv_init(neardal_t neardalObj,
+                                            AdpProp *adpProp)
+{
+       errorCode_t     errCode = NEARDAL_SUCCESS;
+       char            *tgtName;
+
+       NEARDAL_TRACEIN();
+       g_assert(adpProp != NULL);
+
+       if (adpProp->dbusProxy != NULL) {
+               dbus_g_proxy_disconnect_signal(adpProp->dbusProxy,
+                                              NEARD_ADP_SIG_PROPCHANGED,
+                       G_CALLBACK(neardal_adp_prv_cb_property_changed),
+                                              NULL);
+               g_object_unref(adpProp->dbusProxy);
+       }
+       adpProp->dbusProxy = NULL;
+
+       errCode = NEARDAL_ERROR_NO_ADAPTER;
+       if (adpProp->name == NULL)
+               return errCode;
+
+       errCode = neardal_tools_prv_create_proxy(neardalObj->conn,
+                                                 &adpProp->dbusProxy,
+                                                 adpProp->name,
+                                                 NEARD_ADAPTERS_IF_NAME);
+       if (errCode != NEARDAL_SUCCESS)
+               return errCode;
+
+       errCode = neardal_adp_prv_read_properties(adpProp);
+       if (errCode == NEARDAL_SUCCESS && adpProp->tgtArray->len > 0) {
+               guint len = 0;
+
+               while (len < adpProp->tgtArray->len &&
+                       errCode == NEARDAL_SUCCESS) {
+                       tgtName = g_ptr_array_index(adpProp->tgtArray, len++);
+                       errCode = neardal_tgt_add(neardalObj, tgtName);
+               }
+       }
+
+       /* Register Marshaller for signals (String,Variant) */
+       dbus_g_object_register_marshaller(neardal_marshal_VOID__STRING_BOXED,
+                                               G_TYPE_NONE, G_TYPE_STRING,
+                                               G_TYPE_VALUE, G_TYPE_INVALID);
+
+       NEARDAL_TRACEF("Register Neard-Adapter Signal ");
+       NEARDAL_TRACE("'PropertyChanged'\n");
+       dbus_g_proxy_add_signal(adpProp->dbusProxy, NEARD_ADP_SIG_PROPCHANGED,
+                               G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(adpProp->dbusProxy,
+                                   NEARD_ADP_SIG_PROPCHANGED,
+                        G_CALLBACK(neardal_adp_prv_cb_property_changed),
+                                   neardalObj, NULL);
+
+       /* Register 'TargetFound', 'TargetLost' */
+       NEARDAL_TRACEF("Register Neard-Adapter Signal ");
+       NEARDAL_TRACE("'TargetFound'\n");
+       dbus_g_proxy_add_signal(adpProp->dbusProxy, NEARD_ADP_SIG_TGT_FOUND,
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(adpProp->dbusProxy, NEARD_ADP_SIG_TGT_FOUND,
+               G_CALLBACK(neardal_adp_prv_cb_target_found), neardalObj,
+                                   NULL);
+
+       NEARDAL_TRACEF("Register Neard-Adapter Signal ");
+       NEARDAL_TRACE("'TargetLost'\n");
+       dbus_g_proxy_add_signal(adpProp->dbusProxy, NEARD_ADP_SIG_TGT_LOST,
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(adpProp->dbusProxy, NEARD_ADP_SIG_TGT_LOST,
+                               G_CALLBACK(neardal_adp_prv_cb_target_lost),
+                                       neardalObj, NULL);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_adp_release: unref DBus proxy, disconnect Neard Adapter signals
+ *****************************************************************************/
+static void neardal_adp_prv_release(AdpProp *adpProp)
+{
+       NEARDAL_TRACEIN();
+       if (adpProp->dbusProxy != NULL) {
+               dbus_g_proxy_disconnect_signal(adpProp->dbusProxy,
+                                              NEARD_ADP_SIG_PROPCHANGED,
+                       G_CALLBACK(neardal_adp_prv_cb_property_changed),
+                                              NULL);
+               dbus_g_proxy_disconnect_signal(adpProp->dbusProxy,
+                                              NEARD_ADP_SIG_TGT_FOUND,
+                       G_CALLBACK(neardal_adp_prv_cb_target_found),
+                                              NULL);
+               dbus_g_proxy_disconnect_signal(adpProp->dbusProxy,
+                                              NEARD_ADP_SIG_TGT_LOST,
+                       G_CALLBACK(neardal_adp_prv_cb_target_lost),
+                                              NULL);
+               g_object_unref(adpProp->dbusProxy);
+               adpProp->dbusProxy = NULL;
+       }
+       g_free(adpProp->name);
+       if (adpProp->tgtArray != NULL)
+               neardal_tools_prv_g_ptr_array_free(adpProp->tgtArray);
+       g_boxed_free(G_TYPE_STRV, adpProp->protocols);
+       g_free(adpProp);
+}
+
+/******************************************************************************
+ * neardal_get_adapters: get an array of NFC adapters (adpName) present
+ *****************************************************************************/
+errorCode_t neardal_get_adapters(neardal_t neardalObj, char ***array,
+                                 int *len)
+{
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_ADAPTER;
+       int             adpNb           = 0;
+       int             ct              = 0;    /* counter */
+       char            **adps          = NULL;
+       AdpProp         *adapter        = NULL;
+       gsize           size;
+
+       if (neardalObj == NULL || array == NULL)
+               return NEARDAL_ERROR_INVALID_PARAMETER;
+
+       adpNb = g_list_length(neardalObj->mgrProp.adpList);
+       if (adpNb > 0) {
+               errCode = NEARDAL_ERROR_NO_MEMORY;
+               size = (adpNb + 1) * sizeof(char *);
+               adps = g_try_malloc0(size);
+               if (adps != NULL) {
+                       GList   *list;
+                       while (ct < adpNb) {
+                               list = neardalObj->mgrProp.adpList;
+                               adapter = g_list_nth_data(list, ct);
+                               if (adapter != NULL)
+                                       adps[ct++] = g_strdup(adapter->name);
+                       }
+                       errCode = NEARDAL_SUCCESS;
+               }
+       }
+       if (len != NULL)
+               *len = adpNb;
+       *array  = adps;
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_adp_add: add new NFC adapter, initialize DBus Proxy connection,
+ * register adapter signal
+ *****************************************************************************/
+errorCode_t neardal_adp_add(neardal_t neardalObj, char *adapterName)
+{
+       errorCode_t     errCode = NEARDAL_SUCCESS;
+       AdpProp         *adpProp = NULL;
+
+       g_assert(neardalObj != NULL);
+       NEARDAL_TRACEF("Adding adapter:%s\n", adapterName);
+
+       adpProp = g_try_malloc0(sizeof(AdpProp));
+       if (adpProp == NULL)
+               return NEARDAL_ERROR_NO_MEMORY;
+
+       adpProp->name = g_strdup(adapterName);
+       neardalObj->mgrProp.adpList = g_list_prepend(neardalObj->mgrProp.adpList,
+                                                    (gpointer) adpProp);
+       NEARDAL_TRACEF("NEARDAL LIB adapterList contains %d elements\n",
+                     g_list_length(neardalObj->mgrProp.adpList));
+       errCode = neardal_adp_prv_init(neardalObj, adpProp);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_adp_remove: remove NFC adapter, unref DBus Proxy connection,
+ * unregister adapter signal
+ *****************************************************************************/
+errorCode_t neardal_adp_remove(neardal_t neardalObj, AdpProp *adpProp)
+{
+       TgtProp         *tgtProp;
+       GList           *node = NULL;
+
+       g_assert(neardalObj != NULL);
+       g_assert(adpProp != NULL);
+
+       NEARDAL_TRACEF("Removing adapter:%s\n", adpProp->name);
+
+       /* Remove all targets */
+       while (g_list_length(adpProp->tgtList)) {
+               node = g_list_first(adpProp->tgtList);
+               tgtProp = (TgtProp *) node->data;
+               neardal_tgt_remove(tgtProp);
+               adpProp->tgtList = g_list_remove(adpProp->tgtList,
+                                                (gconstpointer) tgtProp);
+       }
+
+       neardal_adp_prv_release(adpProp);
+       neardalObj->mgrProp.adpList = g_list_remove(neardalObj->mgrProp.adpList,
+                                                   (gconstpointer) adpProp);
+
+       return NEARDAL_SUCCESS;
+}
+
+/******************************************************************************
+ * neardal_adp_publish: Creates and publish NDEF record to be written to
+ * an NFC tag
+ *****************************************************************************/
+errorCode_t neardal_adp_publish(AdpProp *adpProp, RcdProp *rcd)
+{
+       GHashTable      *hash = NULL;
+       errorCode_t     err;
+       GError          *gerror = NULL;
+       
+       g_assert(adpProp != NULL);
+
+       hash = neardal_tools_create_dict();
+       if (hash == NULL)
+               return NEARDAL_ERROR_NO_MEMORY;
+
+       err = neardal_rcd_prv_format(&hash, rcd);
+       if (err != NEARDAL_SUCCESS)
+               goto exit;
+
+       org_neard_Adapter_publish(adpProp->dbusProxy, hash, &gerror);
+
+exit:
+       if (hash != NULL)
+               g_hash_table_destroy(hash);
+       if (gerror != NULL) {
+               NEARDAL_TRACE_ERR("Unable to publish tag record (%d:%s)\n",
+                                gerror->code, gerror->message);
+               g_error_free(gerror);
+               err = NEARDAL_ERROR_DBUS;
+       }
+       
+       return err;
+}
diff --git a/lib/neardal_adapter.h b/lib/neardal_adapter.h
new file mode 100644 (file)
index 0000000..c1596e5
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_ADAPTER_H
+#define __NEARDAL_ADAPTER_H
+
+#include "neardal_target.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_ADAPTERS_IF_NAME                         "org.neard.Adapter"
+#define NEARD_ADP_SIG_PROPCHANGED                      "PropertyChanged"
+#define NEARD_ADP_SIG_TGT_FOUND                                "TargetFound"
+#define NEARD_ADP_SIG_TGT_LOST                         "TargetLost"
+
+/* NEARDAL Adapter Properties */
+typedef struct {
+       DBusGProxy              *dbusProxy;     /* The proxy connected to Neard
+                                               Adapter interface */
+       char                    *name;          /* DBus interface name
+                                               (as id) */
+       gboolean                polling;        /* adapter polling active ? */
+       gboolean                powered;        /* adapter powered ? */
+       char                    **protocols;    /* protocols list */
+       GPtrArray               *tgtArray;      /* temporary storage */
+       GList                   *tgtList;       /* Neard adapter targets list
+                                               available */
+} AdpProp;
+
+/******************************************************************************
+ * neardal_adp_prv_get_target: Get NEARDAL target from name
+ *****************************************************************************/
+errorCode_t neardal_adp_prv_get_target(AdpProp *adpProp, char *tgtName,
+                                      TgtProp **tgtProp);
+
+/******************************************************************************
+ * neardal_adp_add: add new NEARDAL adapter, initialize DBus Proxy
+ * connection, register adapter signal
+ *****************************************************************************/
+errorCode_t neardal_adp_add(neardal_t neardalObj, char *adapterName);
+
+/******************************************************************************
+ * neardal_adp_remove: remove NEARDAL adapter, unref DBus Proxy
+ * connection, unregister adapter signal
+ *****************************************************************************/
+errorCode_t neardal_adp_remove(neardal_t neardalObj, AdpProp *adpProp);
+
+/******************************************************************************
+ * neardal_adp_publish: Creates and publish NDEF record to be written to
+ * an NFC tag
+ *****************************************************************************/
+errorCode_t neardal_adp_publish(AdpProp *adpProp, RcdProp *rcd);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_ADAPTER_H */
diff --git a/lib/neardal_errors.c b/lib/neardal_errors.c
new file mode 100644 (file)
index 0000000..2f2db47
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <glib/gtypes.h>
+#include <neardal_errors.h>
+
+char *neardal_error_get_text(errorCode_t ec)
+{
+       switch (ec) {
+       case NEARDAL_SUCCESS:
+               return "Success";
+
+       case NEARDAL_ERROR_GENERAL_ERROR:
+               return "General error";
+
+       case NEARDAL_ERROR_INVALID_PARAMETER:
+               return "Invalid parameter";
+
+       case NEARDAL_ERROR_NO_MEMORY:
+               return "Memory allocation error";
+
+       case NEARDAL_ERROR_DBUS:
+               return "DBUS general error";
+
+       case NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY:
+               return "Can not create a DBUS proxy";
+
+       case NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD:
+               return "Can not invoke a DBUS method";
+
+       case NEARDAL_ERROR_NO_ADAPTER:
+               return "No NFC adapter found...";
+
+       case NEARDAL_ERROR_NO_TARGET:
+               return "No NFC target found...";
+
+       case NEARDAL_ERROR_NO_RECORD:
+               return "No target record found...";
+
+       case NEARDAL_ERROR_POLLING_ALREADY_ACTIVE:
+               return "Polling already active";
+
+       case NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR:
+               return "Error while invoking method";
+       }
+
+       return "UNKNOWN ERROR !!!";
+}
diff --git a/lib/neardal_errors.h b/lib/neardal_errors.h
new file mode 100644 (file)
index 0000000..3ae3283
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+/*!
+ * @file neardal_errors.h
+ *
+ * @brief Defines NEARDAL error code and api helper
+ *
+ ******************************************************************************/
+
+#ifndef __NEARDAL_ERRORS_H
+#define __NEARDAL_ERRORS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*!
+ * @addtogroup NEARDAL_ERROR_CODES NEARDAL Error codes
+ * @ingroup NEARDAL_COMMON
+ * @{
+  */
+/**
+ * @brief Type used for NEARDAL lib error codes
+ **/
+typedef                int     errorCode_t;
+
+/*! @brief Success! (It's not an error) */
+#define NEARDAL_SUCCESS                                ((errorCode_t) 1)
+
+/*! @brief General error */
+#define NEARDAL_ERROR_GENERAL_ERROR                    ((errorCode_t) -1)
+/*! @brief Invalid parameter */
+#define NEARDAL_ERROR_INVALID_PARAMETER                ((errorCode_t) -2)
+/*! @brief Memory allocation error */
+#define NEARDAL_ERROR_NO_MEMORY                        ((errorCode_t) -3)
+/*! @brief DBUS general error */
+#define NEARDAL_ERROR_DBUS                             ((errorCode_t) -4)
+/*! @brief DBUS error (Can not create a proxy to dbus interface) */
+#define NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY         ((errorCode_t) -5)
+/*! @brief DBUS error (Can not invoke a method) */
+#define NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD        ((errorCode_t) -6)
+
+/*! @brief Neard service, no NEARDAL adapter present */
+#define NEARDAL_ERROR_NO_ADAPTER                       ((errorCode_t) -7)
+/*! @brief Neard service, polling already active */
+#define NEARDAL_ERROR_POLLING_ALREADY_ACTIVE           ((errorCode_t) -8)
+/*! @brief Neard service, no NEARDAL target present */
+#define NEARDAL_ERROR_NO_TARGET                        ((errorCode_t) -9)
+/*! @brief Neard service, no NEARDAL record present */
+#define NEARDAL_ERROR_NO_RECORD                        ((errorCode_t) -10)
+
+/*! @brief Neard service, Error while invoking error */
+#define NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR         ((errorCode_t) -11)
+/* @}*/
+
+
+/*!
+ * @addtogroup NEARDAL_APIS APIs
+ * @{
+*/
+/**
+ * @brief map NEARDAL error value to NEARDAL error message string
+ *
+ * @param ec error code
+ * @return NEARDAL error message string
+ **/
+char *neardal_error_get_text(errorCode_t ec);
+/* @}*/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_ERRORS_H */
diff --git a/lib/neardal_manager.c b/lib/neardal_manager.c
new file mode 100644 (file)
index 0000000..0488ec6
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "dbus/dbus.h"
+
+#include "neard-manager-proxy.h"
+#include "neard-adapter-proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+#include <glib-2.0/glib/glist.h>
+#include <glib-2.0/glib/garray.h>
+
+/******************************************************************************
+ * neardal_mgr_prv_cb_property_changed: Callback called when a NFC Manager
+ * Property is changed
+ *****************************************************************************/
+static void neardal_mgr_prv_cb_property_changed(DBusGProxy  *proxy,
+                                                    const char  *str0,
+                                                    GValue      *gvalue,
+                                                    void        *user_data)
+{
+       neardal_t       neardalObj      = user_data;
+
+       NEARDAL_TRACEIN();
+
+       g_assert(neardalObj != NULL);
+       g_assert(str0 != NULL);
+       (void) proxy; /* remove warning */
+       (void) gvalue; /* remove warning */
+
+       NEARDAL_TRACEF("str0='%s'\n", str0);
+       /* Adapters List ignored... */
+}
+
+/******************************************************************************
+ * neardal_mgr_prv_cb_adapter_added: Callback called when a NFC adapter is
+ * added
+ *****************************************************************************/
+static void neardal_mgr_prv_cb_adapter_added(DBusGProxy  *proxy,
+                                                 const char  *str0,
+                                                 void        *user_data)
+{
+       neardal_t       neardalObj      = user_data;
+       errorCode_t     errCode = NEARDAL_SUCCESS;
+
+       NEARDAL_TRACEIN();
+       g_assert(neardalObj != NULL);
+       g_assert(str0 != NULL);
+       (void) proxy; /* remove warning */
+
+       errCode = neardal_adp_add(neardalObj, (char *) str0);
+       if (errCode != NEARDAL_SUCCESS)
+               return;
+
+       /* Invoke client cb 'adapter added' */
+       if (neardalObj->cb_adp_added != NULL)
+                       (neardalObj->cb_adp_added)((char *) str0,
+                                              neardalObj->cb_adp_added_ud);
+       NEARDAL_TRACEF("NEARDAL LIB adapterList contains %d elements\n",
+                     g_list_length(neardalObj->mgrProp.adpList));
+}
+
+/******************************************************************************
+ * neardal_mgr_prv_cb_adapter_removed: Callback called when a NFC adapter
+ * is removed
+ *****************************************************************************/
+static void neardal_mgr_prv_cb_adapter_removed(DBusGProxy  *proxy,
+                                                   const char  *str0,
+                                                   void *user_data)
+{
+       neardal_t       neardalObj      = user_data;
+       GList   *node   = NULL;
+
+       NEARDAL_TRACEIN();
+       g_assert(neardalObj != NULL);
+       g_assert(str0 != NULL);
+       (void) proxy; /* remove warning */
+
+       node = g_list_first(neardalObj->mgrProp.adpList);
+       if (node == NULL) {
+               NEARDAL_TRACE_ERR("NFC adapter not found! (%s)\n", str0);
+               return;
+       }
+
+       neardal_adp_remove(neardalObj, ((AdpProp *)node->data));
+       /* Invoke client cb 'adapter removed' */
+       if (neardalObj->cb_adp_removed != NULL)
+               (neardalObj->cb_adp_removed)((char *) str0,
+                                        neardalObj->cb_adp_removed_ud);
+
+       NEARDAL_TRACEF("NEARDAL LIB adapterList contains %d elements\n",
+                     g_list_length(neardalObj->mgrProp.adpList));
+}
+
+/******************************************************************************
+ * neardal_mgr_prv_get_all_adapters: Check if neard has an adapter
+ *****************************************************************************/
+static errorCode_t neardal_mgr_prv_get_all_adapters(neardal_t neardalObj,
+                                                        GPtrArray **adpArray)
+{
+       GHashTable      *neardAdapterHash       = NULL;
+       GPtrArray       *pathsGpa               = NULL;
+       errorCode_t     errCode                 = NEARDAL_ERROR_NO_ADAPTER;
+
+       g_assert(neardalObj != NULL);
+       g_assert(adpArray != NULL);
+
+       /* Invoking method 'GetProperties' on Neard Manager */
+       if (org_neard_Manager_get_properties(neardalObj->mgrProxy,
+                                            &neardAdapterHash,
+                                            &neardalObj->gerror)) {
+               /* Receiving a GPtrArray of GList */
+               NEARDAL_TRACEF("Parsing neard adapters...\n");
+               errCode = neardal_tools_prv_hashtable_get(neardAdapterHash,
+                                                  NEARD_MGR_SECTION_ADAPTERS,
+                                       DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
+                                       &pathsGpa);
+               if (errCode != NEARDAL_SUCCESS || pathsGpa->len <= 0)
+                       errCode = NEARDAL_ERROR_NO_ADAPTER;
+               else
+                       neardal_tools_prv_g_ptr_array_copy(adpArray, pathsGpa);
+
+               g_hash_table_destroy(neardAdapterHash);
+       } else {
+               errCode = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+               NEARDAL_TRACE_ERR("%d:%s\n", neardalObj->gerror->code,
+                                neardalObj->gerror->message);
+               neardal_tools_prv_free_gerror(neardalObj);
+       }
+
+       return errCode;
+}
+
+
+/******************************************************************************
+ * neardal_mgr_prv_get_adapter: Get NFC Adapter from name
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter(neardal_t neardalObj,
+                                            const char *adpName,
+                                            AdpProp **adpProp)
+{
+       errorCode_t     errCode = NEARDAL_ERROR_NO_ADAPTER;
+       guint           len     = 0;
+       AdpProp         *adapter;
+       GList           *tmpList;
+
+       g_assert(neardalObj != NULL);
+       g_assert(adpProp != NULL);
+
+       tmpList = neardalObj->mgrProp.adpList;
+       while (len < g_list_length(tmpList)) {
+               adapter = g_list_nth_data(tmpList, len);
+               if (adapter != NULL) {
+                       if (neardal_tools_prv_cmp_path(adapter->name,
+                                                       adpName)) {
+                               *adpProp = adapter;
+                               errCode = NEARDAL_SUCCESS;
+                               break;
+                       }
+               }
+               len++;
+       }
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_mgr_prv_get_adapter_from_proxy: Get NFC Adapter from proxy
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter_from_proxy(neardal_t neardalObj,
+                                                       DBusGProxy *adpProxy,
+                                                       AdpProp **adpProp)
+{
+       errorCode_t     errCode = NEARDAL_ERROR_NO_ADAPTER;
+       guint           len = 0;
+       AdpProp         *adapter;
+       GList           *tmpList;
+
+       g_assert(neardalObj != NULL);
+       g_assert(adpProp != NULL);
+
+       tmpList = neardalObj->mgrProp.adpList;
+       while (len < g_list_length(tmpList)) {
+               adapter = g_list_nth_data(tmpList, len);
+               if (adapter != NULL) {
+                       if (adapter->dbusProxy == adpProxy) {
+                               *adpProp = adapter;
+                               errCode = NEARDAL_SUCCESS;
+                               break;
+                       }
+               }
+               len++;
+       }
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_mgr_prv_get_target: Get specific target from adapter
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_target(AdpProp *adpProp,
+                                           const char *tgtName,
+                                           TgtProp **tgtProp)
+{
+       errorCode_t     errCode = NEARDAL_ERROR_NO_TARGET;
+       guint           len;
+       TgtProp         *tgt    = NULL;
+       GList           *tmpList;
+
+       g_assert(adpProp != NULL);
+       g_assert(tgtName != NULL);
+       g_assert(tgtProp != NULL);
+
+       len = 0;
+       tmpList = adpProp->tgtList;
+       while (len < g_list_length(tmpList)) {
+               tgt = g_list_nth_data(tmpList, len);
+               if (neardal_tools_prv_cmp_path(tgt->name, tgtName)) {
+                       *tgtProp = tgt;
+                       errCode = NEARDAL_SUCCESS;
+                       break;
+               }
+               len++;
+       }
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_mgr_prv_get_record: Get specific record from target
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_record(TgtProp *tgtProp,
+                                           const char *rcdName,
+                                           RcdProp **rcdProp)
+{
+       errorCode_t     errCode = NEARDAL_ERROR_NO_RECORD;
+       guint           len;
+       RcdProp *rcd    = NULL;
+
+       g_assert(tgtProp != NULL);
+       g_assert(rcdName != NULL);
+       g_assert(rcdProp != NULL);
+
+       len = 0;
+       while (len < g_list_length(tgtProp->rcdList)) {
+               rcd = g_list_nth_data(tgtProp->rcdList, len);
+               if (neardal_tools_prv_cmp_path(rcd->name, rcdName)) {
+                       *rcdProp = rcd;
+                       errCode = NEARDAL_SUCCESS;
+                       break;
+               }
+               len++;
+       }
+
+       return errCode;
+}
+
+
+/******************************************************************************
+ * neardal_mgr_init: Get Neard Manager Properties = NFC Adapters list.
+ * Create a DBus proxy for the first one NFC adapter if present
+ * Register Neard Manager signals ('PropertyChanged')
+ *****************************************************************************/
+errorCode_t neardal_mgr_init(neardal_t neardalObj)
+{
+       errorCode_t     errCode;
+       GPtrArray       *adpArray = NULL;
+       char            *adpName;
+       guint           len;
+       DBusGProxy      *proxyTmp;
+
+       NEARDAL_TRACEIN();
+       errCode = neardal_tools_prv_create_proxy(neardalObj->conn,
+                                                 &neardalObj->mgrProxy,
+                                                 "/", NEARD_MGR_IF_NAME);
+
+       if (errCode != NEARDAL_SUCCESS)
+               return errCode;
+
+       /* Check if a NFC adapter is present */
+       errCode = neardal_mgr_prv_get_all_adapters(neardalObj, &adpArray);
+       if (adpArray != NULL && adpArray->len > 0) {
+               len = 0;
+               while (len < adpArray->len && errCode == NEARDAL_SUCCESS) {
+                       adpName =  g_ptr_array_index(adpArray, len++);
+                       errCode = neardal_adp_add(neardalObj, adpName);
+               }
+               neardal_tools_prv_g_ptr_array_free(adpArray);
+       }
+
+       /* Register Marshaller for signals (String,Variant) */
+       dbus_g_object_register_marshaller(neardal_marshal_VOID__STRING_BOXED,
+                                         G_TYPE_NONE, G_TYPE_STRING,
+                                         G_TYPE_VALUE, G_TYPE_INVALID);
+
+
+       /* Register for manager signals 'PropertyChanged(String,Variant)' */
+       proxyTmp = neardalObj->mgrProxy;
+       NEARDAL_TRACEF("Register Neard-Manager Signal 'PropertyChanged'\n");
+       dbus_g_proxy_add_signal(proxyTmp, NEARD_MGR_SIG_PROPCHANGED,
+                               G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(proxyTmp, NEARD_MGR_SIG_PROPCHANGED,
+                         G_CALLBACK(neardal_mgr_prv_cb_property_changed),
+                                  neardalObj, NULL);
+
+
+       /* Register for manager signals 'AdapterAdded(ObjectPath)' */
+       NEARDAL_TRACEF("Register Neard-Manager Signal 'AdapterAdded'\n");
+       dbus_g_proxy_add_signal(proxyTmp, NEARD_MGR_SIG_ADP_ADDED,
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(proxyTmp, NEARD_MGR_SIG_ADP_ADDED,
+                       G_CALLBACK(neardal_mgr_prv_cb_adapter_added),
+                                   neardalObj, NULL);
+
+       /* Register for manager signals 'AdapterRemoved(ObjectPath)' */
+       NEARDAL_TRACEF("Register Neard-Manager Signal 'AdapterRemoved'\n");
+       dbus_g_proxy_add_signal(proxyTmp, NEARD_MGR_SIG_ADP_RM,
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(proxyTmp, NEARD_MGR_SIG_ADP_RM,
+                       G_CALLBACK(neardal_mgr_prv_cb_adapter_removed),
+                                   neardalObj, NULL);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_mgr_release: unref DBus proxy, disconnect Neard Manager signals
+ *****************************************************************************/
+void neardal_mgr_release(neardal_t neardalObj)
+{
+       GList   *node;
+       GList   *tmpList;
+
+       NEARDAL_TRACEIN();
+       /* Remove all adapters */
+       tmpList = neardalObj->mgrProp.adpList;
+       while (g_list_length(tmpList)) {
+               node = g_list_first(tmpList);
+               neardal_adp_remove(neardalObj, ((AdpProp *)node->data));
+               tmpList = g_list_remove(tmpList, node->data);
+       }
+       neardalObj->mgrProp.adpList = tmpList;
+
+       if (neardalObj->mgrProxy == NULL)
+               return;
+
+       dbus_g_proxy_disconnect_signal(neardalObj->mgrProxy,
+                                      NEARD_MGR_SIG_PROPCHANGED,
+                       G_CALLBACK(neardal_mgr_prv_cb_property_changed),
+                                      NULL);
+       dbus_g_proxy_disconnect_signal(neardalObj->mgrProxy,
+                                      NEARD_MGR_SIG_ADP_ADDED,
+                       G_CALLBACK(neardal_mgr_prv_cb_adapter_added),
+                                      NULL);
+       dbus_g_proxy_disconnect_signal(neardalObj->mgrProxy,
+                                      NEARD_MGR_SIG_ADP_RM,
+                       G_CALLBACK(neardal_mgr_prv_cb_adapter_removed),
+                                      NULL);
+       g_object_unref(neardalObj->mgrProxy);
+       neardalObj->mgrProxy = NULL;
+}
diff --git a/lib/neardal_manager.h b/lib/neardal_manager.h
new file mode 100644 (file)
index 0000000..0b9b128
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_MANAGER_H
+#define __NEARDAL_MANAGER_H
+
+#include "neardal_adapter.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_DBUS_SERVICE                     "org.neard"
+#define NEARD_MGR_IF_NAME                      "org.neard.Manager"
+#define NEARD_MGR_SECTION_ADAPTERS             "Adapters"
+#define NEARD_MGR_SIG_PROPCHANGED              "PropertyChanged"
+#define NEARD_MGR_SIG_ADP_ADDED                        "AdapterAdded"
+#define NEARD_MGR_SIG_ADP_RM                   "AdapterRemoved"
+
+/* NEARDAL Manager Properties */
+typedef struct {
+       GList   *adpList;       /* List of available NEARDAL adapter */
+} MgrProp;
+
+/******************************************************************************
+ * neardal_mgr_prv_get_adapter: Get NEARDAL Adapter from name
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter(neardal_t neardalObj,
+                                            const char *adpName,
+                                            AdpProp **adpProp);
+
+/******************************************************************************
+ * neardal_mgr_prv_get_adapter_from_proxy: Get NEARDAL Adapter from proxy
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter_from_proxy(neardal_t neardalObj,
+                                                       DBusGProxy *adpProxy,
+                                                       AdpProp **adpProp);
+
+/******************************************************************************
+ * neardal_mgr_prv_get_target: Get specific target from adapter
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_target(AdpProp *adpProp,
+                                           const char *tgtName,
+                                           TgtProp **tgtProp);
+
+/******************************************************************************
+ * neardal_mgr_prv_get_record: Get specific record from target
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_record(TgtProp *tgtProp,
+                                           const char *rcdName,
+                                           RcdProp **rcdProp);
+
+/******************************************************************************
+ * neardal_mgr_init: Get Neard Manager Properties = NEARDAL Adapters list.
+ * Create a DBus proxy for the first one NEARDAL adapter if present
+ * Register Neard Manager signals ('PropertyChanged')
+ *****************************************************************************/
+errorCode_t neardal_mgr_init(neardal_t neardalObj);
+
+/******************************************************************************
+ * neardal_mgr_release: unref DBus proxy, disconnect Neard Manager signals
+ *****************************************************************************/
+void neardal_mgr_release(neardal_t neardalObj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_MANAGER_H */
diff --git a/lib/neardal_prv.h b/lib/neardal_prv.h
new file mode 100644 (file)
index 0000000..280e96e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_PRV_H
+#define __NEARDAL_PRV_H
+
+#include "neardal_manager.h"
+#include "neardal_tools.h"
+#include "neardal_traces_prv.h"
+#include "neardal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* GType for Dict(string, variant) */
+#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH    (dbus_g_type_get_collection( \
+                                               "GPtrArray", \
+                                               DBUS_TYPE_G_OBJECT_PATH))
+
+/* NEARDAL context */
+typedef struct neardalCtx {
+       DBusGConnection *conn;                  /* The DBus connection */
+       DBusGProxy      *mgrProxy;              /* dbus proxy to Neard Mgr */
+       MgrProp         mgrProp;                /* Mgr Properties
+                                               (adapter list) */
+       adapter_cb      cb_adp_added;           /* Client callback for
+                                               'NEARDAL adapter added' */
+       void            *cb_adp_added_ud;       /* User data for client
+                                               callback 'adapter added'*/
+       adapter_cb      cb_adp_removed;         /* Client callback for
+                                               'NEARDAL adapter removed' */
+       void            *cb_adp_removed_ud;     /* User data for client
+                                               callback 'adapter removed'*/
+       adapter_prop_cb cb_adp_prop_changed;    /* Client callback for
+                                               'adapter property changed' */
+       void            *cb_adp_prop_changed_ud;/* User data for client callback
+                                               'adapter property changed' */
+
+       target_cb       cb_tgt_found;           /* Client callback for
+                                               'NEARDAL target found' */
+       void            *cb_tgt_found_ud;       /* User data for client callback
+                                               'NEARDAL target found' */
+       target_cb       cb_tgt_lost;            /* Client callback for
+                                               'NEARDAL target lost' */
+       void            *cb_tgt_lost_ud;        /* User data for client callback
+                                               'NEARDAL target lost' */
+
+       record_cb       cb_rcd_found;           /* Client callback for
+                                               'NEARDAL target record found'*/
+       void            *cb_rcd_found_ud;       /* User data for client callback
+                                               'NEARDAL target record found'*/
+
+       errorCode_t     ec;                     /* The last NEARDAL Library
+                                               error code */
+       GError          *gerror;                /* The last GError when
+                                               available */
+} neardalCtx;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_PRV_H */
diff --git a/lib/neardal_record.c b/lib/neardal_record.c
new file mode 100644 (file)
index 0000000..3c31962
--- /dev/null
@@ -0,0 +1,372 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "dbus/dbus.h"
+
+#include "neard-record-proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+#include <glib-2.0/glib/gerror.h>
+#include <glib-2.0/glib/glist.h>
+
+/******************************************************************************
+ * neardal_rcd_prv_read_std_properties: Get Neard Record Properties for non
+ * smartPoster tag
+ *****************************************************************************/
+static errorCode_t neardal_rcd_prv_read_std_properties(GHashTable *rcdHash,
+                                                     RcdProp *rcd)
+{
+       errorCode_t     errCode;
+       char            *tmp    = NULL;
+
+       errCode = neardal_tools_prv_hashtable_get(rcdHash, "Type",
+                                             G_TYPE_STRING, &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               rcd->type = g_strdup(tmp);
+
+       if (!strcmp(rcd->type, "Text")) {
+               errCode = neardal_tools_prv_hashtable_get(rcdHash,
+                                                     "Representation",
+                                                     G_TYPE_STRING, &tmp);
+               if (errCode == NEARDAL_SUCCESS)
+                       rcd->representation = g_strdup(tmp);
+       }
+
+       if (!strcmp(rcd->type, "URI")) {
+               errCode = neardal_tools_prv_hashtable_get(rcdHash, "URI",
+                                                     G_TYPE_STRING, &tmp);
+               if (errCode == NEARDAL_SUCCESS)
+                       rcd->uri = g_strdup(tmp);
+       }
+
+       if (!strcmp(rcd->type, "MIME Type (RFC 2046)")) {
+               errCode = neardal_tools_prv_hashtable_get(rcdHash, "MIME",
+                                                     G_TYPE_STRING, &tmp);
+               if (errCode == NEARDAL_SUCCESS)
+                       rcd->mime = g_strdup(tmp);
+       }
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_rcd_prv_read_sp_properties: Get Neard Record Properties
+ * for smartPoster tag
+ *****************************************************************************/
+static errorCode_t neardal_rcd_prv_read_sp_properties(GHashTable *rcdHash,
+                                                      RcdProp *rcd)
+{
+       /* TODO */
+       (void) rcdHash; /* remove warning */
+       (void) rcd; /* remove warning */
+
+       return NEARDAL_ERROR_GENERAL_ERROR;
+}
+
+/******************************************************************************
+ * neardal_rcd_prv_read_properties: Get Neard Record Properties
+ *****************************************************************************/
+static errorCode_t neardal_rcd_prv_read_properties(RcdProp *rcd)
+{
+       errorCode_t     errCode         = NEARDAL_SUCCESS;
+       GHashTable      *rcdHash        = NULL;
+       GError          *gerror         = NULL;
+       char            *tmp            = NULL;
+       gboolean        dbusCall;
+
+
+       NEARDAL_TRACEIN();
+       g_assert(rcd != NULL);
+       g_assert(rcd->dbusProxy != NULL);
+
+       dbusCall = org_neard_Record_get_properties(rcd->dbusProxy, &rcdHash,
+                                                  &gerror);
+       if (dbusCall != TRUE || gerror != NULL) {
+               errCode = NEARDAL_ERROR_DBUS;
+               NEARDAL_TRACE_ERR(
+                       "Unable to read record's properties (%d:%s)\n",
+                                  gerror->code, gerror->message);
+               g_error_free(gerror);
+               return errCode;
+       }
+
+       errCode = neardal_tools_prv_hashtable_get(rcdHash, "Encoding",
+                                             G_TYPE_STRING, &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               rcd->encoding = g_strdup(tmp);
+       errCode = neardal_tools_prv_hashtable_get(rcdHash, "HandOver",
+                                             G_TYPE_BOOLEAN,
+                                             &rcd->handOver);
+       errCode = neardal_tools_prv_hashtable_get(rcdHash, "Language",
+                                             G_TYPE_STRING, &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               rcd->language = g_strdup(tmp);
+       errCode = neardal_tools_prv_hashtable_get(rcdHash, "SmartPoster",
+                                             G_TYPE_BOOLEAN,
+                                             &rcd->smartPoster);
+       if (rcd->smartPoster == FALSE)
+               errCode = neardal_rcd_prv_read_std_properties(rcdHash,
+                                                                 rcd);
+       else
+               errCode = neardal_rcd_prv_read_sp_properties(rcdHash,
+                                                                      rcd);
+
+       g_hash_table_destroy(rcdHash);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_rcd_init: Get Neard Manager Properties = NFC Records list.
+ * Create a DBus proxy for the first one NFC record if present
+ * Register Neard Manager signals ('PropertyChanged')
+ *****************************************************************************/
+static errorCode_t neardal_rcd_prv_init(neardal_t neardalObj,
+                                           RcdProp *rcd)
+{
+       errorCode_t     errCode = NEARDAL_SUCCESS;
+
+       NEARDAL_TRACEIN();
+       g_assert(rcd != NULL);
+
+       if (rcd->dbusProxy != NULL)
+               g_object_unref(rcd->dbusProxy);
+       rcd->dbusProxy = NULL;
+
+       errCode = neardal_tools_prv_create_proxy(neardalObj->conn,
+                                                 &rcd->dbusProxy,
+                                                 rcd->name,
+                                                 NEARD_RECORDS_IF_NAME);
+       if (errCode == NEARDAL_SUCCESS)
+               errCode = neardal_rcd_prv_read_properties(rcd);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_rcd_release: unref DBus proxy, disconnect Neard Record signals
+ *****************************************************************************/
+static void neardal_rcd_prv_release(RcdProp *rcd)
+{
+       NEARDAL_TRACEIN();
+       if (rcd->dbusProxy != NULL)
+               g_object_unref(rcd->dbusProxy);
+       rcd->dbusProxy = NULL;
+       g_free(rcd->name);
+       g_free(rcd->language);
+       g_free(rcd->encoding);
+       g_free(rcd->mime);
+       g_free(rcd->representation);
+       g_free(rcd->type);
+       g_free(rcd->uri);
+       g_free(rcd);
+}
+/******************************************************************************
+ * neardal_rcd_prv_read_std_properties: Insert key/value in a GHashTable for
+ * non smartPoster tag
+ *****************************************************************************/
+static errorCode_t neardal_rcd_prv_format_std_properties(GHashTable **hash,
+                                                         RcdProp *rcd)
+{
+       if (rcd->action != NULL)
+               neardal_tools_add_dict_entry(*hash, "Action", rcd->action);
+
+       if (rcd->encoding != NULL)
+               neardal_tools_add_dict_entry(*hash, "Encoding", rcd->encoding);
+
+       if (rcd->language != NULL)
+               neardal_tools_add_dict_entry(*hash, "Language", rcd->language);
+
+       if (rcd->mime != NULL)
+               neardal_tools_add_dict_entry(*hash, "MIME", rcd->mime);
+
+       if (rcd->representation != NULL)
+               neardal_tools_add_dict_entry(*hash, "Representation",
+                                             rcd->representation);
+
+       if (rcd->type != NULL)
+               neardal_tools_add_dict_entry(*hash, "Type", rcd->type);
+
+       if (rcd->uri != NULL)
+               neardal_tools_add_dict_entry(*hash, "URI", rcd->uri);
+       
+       return NEARDAL_SUCCESS;
+}
+
+/******************************************************************************
+ * neardal_rcd_prv_read_sp_properties: Insert key/value in a GHashTable for
+ * smartPoster tag
+ *****************************************************************************/
+static errorCode_t neardal_rcd_prv_format_sp_properties(GHashTable **hash,
+                                                        RcdProp *rcd)
+{
+       /* TODO */
+       (void) hash; /* remove warning */
+       (void) rcd; /* remove warning */
+
+       return NEARDAL_ERROR_GENERAL_ERROR;
+}
+
+
+/******************************************************************************
+ * neardal_rcd_prv_format: Insert key/value in a GHashTable
+ *****************************************************************************/
+errorCode_t neardal_rcd_prv_format(GHashTable **hash, RcdProp *rcd)
+{
+       errorCode_t     errCode         = NEARDAL_SUCCESS;
+
+
+       NEARDAL_TRACEIN();
+       g_assert(rcd != NULL);
+       g_assert(rcd->dbusProxy != NULL);
+
+       if (rcd->smartPoster == FALSE)
+               errCode = neardal_rcd_prv_format_std_properties(hash, rcd);
+       else
+               errCode = neardal_rcd_prv_format_sp_properties(hash, rcd);
+
+       return errCode;
+}
+
+
+/******************************************************************************
+ * neardal_get_records: get an array of target records
+ *****************************************************************************/
+errorCode_t neardal_get_records(neardal_t neardalObj, char *tgtName,
+                                char ***array, int *len)
+{
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_RECORD;
+       AdpProp         *adpProp        = NULL;
+       TgtProp         *tgtProp        = NULL;
+       int             rcdNb           = 0;
+       int             ct              = 0;    /* counter */
+       char            **rcds          = NULL;
+       RcdProp         *rcd            = NULL;
+
+
+       if (neardalObj == NULL || tgtName == NULL || array == NULL)
+               return NEARDAL_ERROR_INVALID_PARAMETER;
+
+       errCode = neardal_mgr_prv_get_adapter(neardalObj, tgtName,
+                                                  &adpProp);
+       if (errCode != NEARDAL_SUCCESS)
+               goto exit;
+
+       errCode = neardal_adp_prv_get_target(adpProp, tgtName, &tgtProp);
+       if (errCode != NEARDAL_SUCCESS)
+               goto exit;
+
+       errCode         = NEARDAL_ERROR_NO_RECORD;
+       rcdNb = g_list_length(tgtProp->rcdList);
+       if (rcdNb <= 0)
+               goto exit;
+
+       errCode = NEARDAL_ERROR_NO_MEMORY;
+       rcds = g_try_malloc0((rcdNb + 1) * sizeof(char *));
+       if (rcds == NULL)
+               goto exit;
+
+       while (ct < rcdNb) {
+               rcd = g_list_nth_data(tgtProp->rcdList, ct);
+               if (rcd != NULL)
+                       rcds[ct++] = g_strdup(rcd->name);
+       }
+       errCode = NEARDAL_SUCCESS;
+
+exit:
+       if (len != NULL)
+               *len = rcdNb;
+       *array  = rcds;
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_rcd_add: add new NFC record, initialize DBus Proxy connection,
+ * register record signal
+ *****************************************************************************/
+errorCode_t neardal_rcd_add(neardal_t neardalObj, char *rcdName)
+{
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_MEMORY;
+       AdpProp         *adpProp        = NULL;
+       RcdProp         *rcd    = NULL;
+       TgtProp         *tgtProp        = NULL;
+
+       g_assert(neardalObj != NULL);
+       g_assert(rcdName != NULL);
+
+       NEARDAL_TRACEF("Adding record:%s\n", rcdName);
+       rcd = g_try_malloc0(sizeof(RcdProp));
+       if (rcd == NULL)
+               goto exit;
+
+       rcd->name       = g_strdup(rcdName);
+       if (rcd->name == NULL)
+               goto exit;
+
+       errCode = neardal_rcd_prv_init(neardalObj, rcd);
+       if (errCode != NEARDAL_SUCCESS)
+               goto exit;
+
+       errCode = neardal_mgr_prv_get_adapter(neardalObj, rcdName,
+                                                  &adpProp);
+       if (errCode != NEARDAL_SUCCESS)
+               goto exit;
+
+       errCode = neardal_adp_prv_get_target(adpProp, rcdName, &tgtProp);
+       if (errCode != NEARDAL_SUCCESS)
+               goto exit;
+
+       tgtProp->rcdList = g_list_prepend(tgtProp->rcdList, (gpointer) rcd);
+       NEARDAL_TRACEF("NEARDAL LIB recordList contains %d elements\n",
+                     g_list_length(tgtProp->rcdList));
+       errCode = NEARDAL_SUCCESS;
+
+exit:
+       if (errCode != NEARDAL_SUCCESS) {
+               if (rcd->name != NULL) {
+                       g_free(rcd->name);
+                       rcd->name = NULL;
+               }
+               if (rcd != NULL)
+                       g_free(rcd);
+       }
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_rcd_remove: remove NFC record, unref DBus Proxy connection,
+ * unregister record signal
+ *****************************************************************************/
+void neardal_rcd_remove(RcdProp *rcd)
+{
+       NEARDAL_TRACEIN();
+       g_assert(rcd != NULL);
+
+       NEARDAL_TRACEF("Removing record:%s\n", rcd->name);
+       /* Remove all records */
+       neardal_rcd_prv_release(rcd);
+}
diff --git a/lib/neardal_record.h b/lib/neardal_record.h
new file mode 100644 (file)
index 0000000..b316cce
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_RECORD_H
+#define __NEARDAL_RECORD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_RECORDS_IF_NAME          "org.neard.Record"
+#define NEARD_TGT_SIG_PROPCHANGED      "PropertyChanged"
+
+/* NEARDAL Record Properties */
+typedef struct {
+       DBusGProxy      *dbusProxy;     /* proxy to Neard NFC Record
+                                       interface */
+       char            *name;          /* DBus interface name
+                                       (as identifier) */
+
+       char            *encoding;
+       gboolean        handOver;
+       char            *language;
+       gboolean        smartPoster;
+       char            *action;
+       char            *type;
+       char            *representation;
+       char            *uri;
+       char            *mime;
+} RcdProp;
+
+/******************************************************************************
+ * neardal_rcd_add: add new NFC record, initialize DBus Proxy connection,
+ * register record signal
+ *****************************************************************************/
+errorCode_t neardal_rcd_add(neardal_t neardalObj, char *rcdName);
+
+/******************************************************************************
+ * neardal_rcd_remove: remove NFC record, unref DBus Proxy connection,
+ * unregister record signal
+ *****************************************************************************/
+void neardal_rcd_remove(RcdProp *rcdProp);
+
+/******************************************************************************
+ * neardal_rcd_prv_format: Insert key/value in a GHashTable
+ *****************************************************************************/
+errorCode_t neardal_rcd_prv_format(GHashTable ** hash, RcdProp *rcdProp);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_RECORD_H */
diff --git a/lib/neardal_target.c b/lib/neardal_target.c
new file mode 100644 (file)
index 0000000..a44c0aa
--- /dev/null
@@ -0,0 +1,357 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "dbus/dbus.h"
+
+#include "neard-target-proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+#include <glib-2.0/glib/gerror.h>
+#include <glib-2.0/glib/glist.h>
+#include <glib-2.0/glib/garray.h>
+
+
+/******************************************************************************
+ * neardal_tgt_prv_cb_property_changed: Callback called when a NFC target
+ * property is changed
+ *****************************************************************************/
+static void neardal_tgt_prv_cb_property_changed(DBusGProxy     *proxy,
+                                              const char       *str0,
+                                              GValue           *gvalue,
+                                              void             *user_data)
+{
+       GPtrArray       *pathsGpa       = NULL;
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_TARGET;
+       TgtProp         *tgtProp        = NULL;
+
+       (void) proxy; /* remove warning */
+       (void) user_data; /* remove warning */
+
+       NEARDAL_TRACEIN();
+
+       if (tgtProp == NULL || str0 == NULL)
+               return;
+
+       NEARDAL_TRACEF("str0='%s'\n", str0);
+       if (!strcmp(str0, "Targets")) {
+               if (!G_VALUE_HOLDS(gvalue, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) {
+                       NEARDAL_TRACE_ERR("Unexpected type: %s",
+                                         G_VALUE_TYPE_NAME(&gvalue));
+                       errCode = NEARDAL_ERROR_DBUS;
+                       return;
+               }
+
+               /* Extract the targets arrays List from the GValue */
+               errCode = NEARDAL_ERROR_NO_TARGET;
+               pathsGpa = g_value_get_boxed(gvalue);
+               if (pathsGpa == NULL)
+                       goto error;
+
+               if (pathsGpa->len <= 0)
+                       goto error;
+
+               /* Getting last target */
+               gvalue = g_ptr_array_index(pathsGpa, pathsGpa->len - 1);
+               if (gvalue != NULL)
+                       errCode = NEARDAL_SUCCESS;
+               else
+                       errCode = NEARDAL_ERROR_NO_TARGET;
+       }
+
+       return;
+
+error:
+       if (errCode != NEARDAL_SUCCESS) {
+               NEARDAL_TRACE_ERR("Exit with error code %d:%s\n", errCode,
+                               neardal_error_get_text(errCode));
+               if (pathsGpa != NULL)
+                       g_boxed_free(G_TYPE_STRV, pathsGpa);
+       }
+
+       return;
+}
+
+/******************************************************************************
+ * neardal_tgt_prv_read_properties: Get Neard Target Properties
+ *****************************************************************************/
+static errorCode_t neardal_tgt_prv_read_properties(TgtProp *tgtProp)
+{
+       errorCode_t     errCode                 = NEARDAL_SUCCESS;
+       GHashTable      *neardTargetPropHash    = NULL;
+       GError          *gerror                 = NULL;
+       void            *tmp                    = NULL;
+
+       NEARDAL_TRACEIN();
+       g_assert(tgtProp != NULL);
+       g_assert(tgtProp->dbusProxy != NULL);
+
+       org_neard_Target_get_properties(tgtProp->dbusProxy,
+                                       &neardTargetPropHash,
+                                       &gerror);
+       if (gerror != NULL) {
+               errCode = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+               NEARDAL_TRACE_ERR(
+                       "Unable to read target's properties (%d:%s)\n",
+                                gerror->code, gerror->message);
+               g_error_free(gerror);
+               goto exit;
+       }
+
+       errCode = neardal_tools_prv_hashtable_get(neardTargetPropHash,
+                                                  "Records",
+                                           DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
+                                           &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               neardal_tools_prv_g_ptr_array_copy(&tgtProp->rcdArray, tmp);
+
+       errCode = neardal_tools_prv_hashtable_get(neardTargetPropHash,
+                                                  "TagType",
+                                                   G_TYPE_STRV, &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               tgtProp->tagType = g_boxed_copy(G_TYPE_STRV, tmp);
+
+       errCode = neardal_tools_prv_hashtable_get(neardTargetPropHash, "Type",
+                                                  G_TYPE_STRING, &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               tgtProp->type = g_strdup(tmp);
+
+       errCode = neardal_tools_prv_hashtable_get(neardTargetPropHash,
+                                                  "ReadOnly", G_TYPE_BOOLEAN,
+                                                  &tmp);
+       if (errCode == NEARDAL_SUCCESS)
+               tgtProp->readOnly = (gboolean) tmp;
+
+       g_hash_table_destroy(neardTargetPropHash);
+
+exit:
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_tgt_init: Get Neard Manager Properties = NFC Targets list.
+ * Create a DBus proxy for the first one NFC target if present
+ * Register Neard Manager signals ('PropertyChanged')
+ *****************************************************************************/
+static errorCode_t neardal_tgt_prv_init(neardal_t neardalObj,
+                                           TgtProp *tgtProp)
+{
+       errorCode_t     errCode = NEARDAL_SUCCESS;
+       guint           len = 0;
+       char            *rcdName;
+
+       NEARDAL_TRACEIN();
+       g_assert(tgtProp != NULL);
+
+       if (tgtProp->dbusProxy != NULL) {
+               dbus_g_proxy_disconnect_signal(tgtProp->dbusProxy,
+                                              NEARD_TGT_SIG_PROPCHANGED,
+                       G_CALLBACK(neardal_tgt_prv_cb_property_changed),
+                                              NULL);
+               g_object_unref(tgtProp->dbusProxy);
+       }
+       tgtProp->dbusProxy = NULL;
+
+       errCode = neardal_tools_prv_create_proxy(neardalObj->conn,
+                                                 &tgtProp->dbusProxy,
+                                                 tgtProp->name,
+                                                 NEARD_TARGETS_IF_NAME);
+       if (errCode != NEARDAL_SUCCESS)
+               return errCode;
+
+       /* Populate Target datas... */
+       errCode = neardal_tgt_prv_read_properties(tgtProp);
+       if (errCode != NEARDAL_SUCCESS)
+               return errCode;
+
+       if (tgtProp->rcdArray == NULL)
+               return NEARDAL_ERROR_GENERAL_ERROR;
+
+       if (tgtProp->rcdArray->len <= 0)
+               return NEARDAL_ERROR_NO_TARGET;
+
+       len = 0;
+       while (len < tgtProp->rcdArray->len && errCode == NEARDAL_SUCCESS) {
+               rcdName = tgtProp->rcdArray->pdata[len];
+               errCode = neardal_rcd_add(neardalObj, rcdName);
+               if (errCode == NEARDAL_SUCCESS &&
+                       neardalObj->cb_tgt_found != NULL)
+                       (neardalObj->cb_tgt_found)(tgtProp->name,
+                                              neardalObj->cb_tgt_found_ud);
+               if (neardalObj->cb_rcd_found != NULL)
+                       (neardalObj->cb_rcd_found)(rcdName,
+                                              neardalObj->cb_rcd_found_ud);
+               len++;
+       }
+
+       /* Register Marshaller for signals (String,Variant) */
+       dbus_g_object_register_marshaller(neardal_marshal_VOID__STRING_BOXED,
+                                          G_TYPE_NONE, G_TYPE_STRING,
+                                          G_TYPE_VALUE, G_TYPE_INVALID);
+
+       NEARDAL_TRACEF("Register Neard-Target Signal 'PropertyChanged'\n");
+       dbus_g_proxy_add_signal(tgtProp->dbusProxy, NEARD_TGT_SIG_PROPCHANGED,
+                                G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(tgtProp->dbusProxy,
+                                   NEARD_TGT_SIG_PROPCHANGED,
+                         G_CALLBACK(neardal_tgt_prv_cb_property_changed),
+                                   neardalObj, NULL);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_tgt_release: unref DBus proxy, disconnect Neard Target signals
+ *****************************************************************************/
+static void neardal_tgt_prv_release(TgtProp *tgtProp)
+{
+       NEARDAL_TRACEIN();
+       if (tgtProp->dbusProxy != NULL) {
+               dbus_g_proxy_disconnect_signal(tgtProp->dbusProxy,
+                                              NEARD_TGT_SIG_PROPCHANGED,
+                       G_CALLBACK(neardal_tgt_prv_cb_property_changed),
+                                              NULL);
+               g_object_unref(tgtProp->dbusProxy);
+               tgtProp->dbusProxy = NULL;
+       }
+       g_free(tgtProp->name);
+       g_free(tgtProp->type);
+       neardal_tools_prv_g_ptr_array_free(tgtProp->rcdArray);
+       g_boxed_free(G_TYPE_STRV, tgtProp->tagType);
+}
+
+/******************************************************************************
+ * neardal_get_targets: get an array of NFC targets present
+ *****************************************************************************/
+errorCode_t neardal_get_targets(neardal_t neardalObj, char *adpName,
+                                char ***array, int *len)
+{
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_TARGET;
+       AdpProp         *adpProp        = NULL;
+       int             tgtNb           = 0;
+       int             ct              = 0;    /* counter */
+       char            **tgts          = NULL;
+       TgtProp         *target         = NULL;
+
+
+       if (neardalObj == NULL || adpName == NULL || array == NULL)
+               return NEARDAL_ERROR_INVALID_PARAMETER;
+
+       errCode = neardal_mgr_prv_get_adapter(neardalObj, adpName,
+                                                  &adpProp);
+       if (errCode != NEARDAL_SUCCESS)
+               return errCode;
+
+       tgtNb = g_list_length(adpProp->tgtList);
+       if (tgtNb <= 0)
+               return NEARDAL_ERROR_NO_TARGET;
+
+       errCode = NEARDAL_ERROR_NO_MEMORY;
+       tgts = g_try_malloc0((tgtNb + 1) * sizeof(char *));
+
+       if (tgts == NULL)
+               return NEARDAL_ERROR_NO_MEMORY;
+
+       while (ct < tgtNb) {
+               target = g_list_nth_data(adpProp->tgtList, ct);
+               if (target != NULL)
+                       tgts[ct++] = g_strdup(target->name);
+       }
+       errCode = NEARDAL_SUCCESS;
+
+       if (len != NULL)
+               *len = tgtNb;
+       *array  = tgts;
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_tgt_add: add new NFC target, initialize DBus Proxy connection,
+ * register target signal
+ *****************************************************************************/
+errorCode_t neardal_tgt_add(neardal_t neardalObj, char *tgtName)
+{
+       errorCode_t     errCode         = NEARDAL_ERROR_NO_MEMORY;
+       TgtProp         *tgtProp        = NULL;
+       AdpProp         *adpProp;
+
+       g_assert(neardalObj != NULL);
+       g_assert(tgtName != NULL);
+
+       NEARDAL_TRACEF("Adding target:%s\n", tgtName);
+       tgtProp = g_try_malloc0(sizeof(TgtProp));
+       if (tgtProp == NULL)
+               goto error;
+
+       tgtProp->name   = g_strdup(tgtName);
+       errCode = neardal_mgr_prv_get_adapter(neardalObj, tgtName,
+                                                  &adpProp);
+       if (errCode != NEARDAL_SUCCESS)
+               goto error;
+
+       adpProp->tgtList = g_list_prepend(adpProp->tgtList, tgtProp);
+       errCode = neardal_tgt_prv_init(neardalObj, tgtProp);
+       if (errCode != NEARDAL_SUCCESS) {
+               adpProp->tgtList = g_list_remove(adpProp->tgtList, tgtProp);
+               goto error;
+       }
+
+       NEARDAL_TRACEF("NEARDAL LIB targetList contains %d elements\n",
+                     g_list_length(adpProp->tgtList));
+
+       return errCode;
+
+error:
+       if (tgtProp->name != NULL)
+               g_free(tgtProp->name);
+       if (tgtProp != NULL)
+               g_free(tgtProp);
+
+       return errCode;
+}
+
+/******************************************************************************
+ * neardal_tgt_remove: remove NFC target, unref DBus Proxy connection,
+ * unregister target signal
+ *****************************************************************************/
+void neardal_tgt_remove(TgtProp *tgtProp)
+{
+       RcdProp         *rcdProp        = NULL;
+       GList           *node;
+
+       g_assert(tgtProp != NULL);
+
+       NEARDAL_TRACEF("Removing target:%s\n", tgtProp->name);
+       /* Remove all targets */
+       while (g_list_length(tgtProp->rcdList)) {
+               node = g_list_first(tgtProp->rcdList);
+               rcdProp = (RcdProp *) node->data;
+               tgtProp->rcdList = g_list_remove(tgtProp->rcdList,
+                                                (gconstpointer) rcdProp);
+               neardal_rcd_remove(rcdProp);
+       }
+       neardal_tgt_prv_release(tgtProp);
+}
diff --git a/lib/neardal_target.h b/lib/neardal_target.h
new file mode 100644 (file)
index 0000000..73a111e
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_TARGET_H
+#define __NEARDAL_TARGET_H
+
+#include "neardal_record.h"
+#include <glib-2.0/glib/glist.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_TARGETS_IF_NAME          "org.neard.Target"
+#define NEARD_TGT_SIG_PROPCHANGED      "PropertyChanged"
+
+/* NEARDAL Target Properties */
+typedef struct {
+       DBusGProxy      *dbusProxy;     /* proxy to Neard NEARDAL Target
+                                       interface */
+       char            *name;          /* DBus interface name
+                                       (as identifier) */
+       GPtrArray       *rcdArray;      /* temporary storage */
+       GList           *rcdList;       /* target's records paths */
+       char            **tagType;      /* array of tag types */
+       char            *type;
+       gboolean        readOnly;       /* Read-Only flag */
+} TgtProp;
+
+/******************************************************************************
+ * neardal_tgt_add: add new NEARDAL target, initialize DBus Proxy connection,
+ * register target signal
+ *****************************************************************************/
+errorCode_t neardal_tgt_add(neardal_t neardalObj, char *tgtName);
+
+/******************************************************************************
+ * neardal_tgt_remove: remove NEARDAL target, unref DBus Proxy connection,
+ * unregister target signal
+ *****************************************************************************/
+void neardal_tgt_remove(TgtProp *tgtProp);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_TARGET_H */
diff --git a/lib/neardal_tools.c b/lib/neardal_tools.c
new file mode 100644 (file)
index 0000000..34a9db0
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "dbus/dbus.h"
+
+#include "neard-manager-proxy.h"
+#include "neard-adapter-proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+#define g_marshal_value_peek_string(v)   (char *) g_value_get_string(v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed(v)
+
+void
+neardal_marshal_VOID__STRING_BOXED(GClosure *closure, GValue *return_value,
+                                   guint               n_param_values,
+                                   const GValue        *param_values,
+                                   gpointer            invocation_hint,
+                                   gpointer            marshal_data)
+{
+typedef void (*GMarshalFunc_VOID__STRING_BOXED)(gpointer data1, gpointer arg_1,
+                                               gpointer arg_2, gpointer data2);
+
+       register GMarshalFunc_VOID__STRING_BOXED callback;
+       register gpointer                       data1, data2;
+       register GCClosure                      *cc     = (GCClosure *)closure;
+       GValue                                  *value  = NULL;
+
+       g_return_if_fail(n_param_values == 3);
+       (void) return_value; /* remove warning */
+       (void) invocation_hint; /* remove warning */
+
+       if (G_CCLOSURE_SWAP_DATA(closure)) {
+               data1 = closure->data;
+               data2 = g_value_peek_pointer(param_values + 0);
+       } else {
+               data1 = g_value_peek_pointer(param_values + 0);
+               data2 = closure->data;
+       }
+       callback = (GMarshalFunc_VOID__STRING_BOXED) (marshal_data ?
+       marshal_data : cc->callback);
+
+       if (G_IS_VALUE(g_marshal_value_peek_boxed(param_values + 2)))
+               value = g_marshal_value_peek_boxed(param_values + 2);
+
+       callback(data1, g_marshal_value_peek_string(param_values + 1), value,
+                data2);
+}
+
+/******************************************************************************
+ * neardal_tools_prv__g_ptr_array_copy: duplicate a 'GPtrArray' array
+ *****************************************************************************/
+static void neardal_tools_g_ptr_array_add(gpointer data, gpointer array)
+{
+       char *tmp;
+       tmp = g_strdup(data);
+       g_ptr_array_add(array, tmp);
+}
+void neardal_tools_prv_g_ptr_array_copy(GPtrArray **target, GPtrArray *source)
+{
+       if (*target == NULL)
+               *target = g_ptr_array_sized_new(source->len);
+       g_ptr_array_foreach(source, neardal_tools_g_ptr_array_add, *target);
+}
+
+/******************************************************************************
+ * neardal_tools_prv_g_ptr_array_free: free a 'GPtrArray' array
+ *****************************************************************************/
+static void neardal_tools_g_ptr_array_free_node(gpointer data, gpointer array)
+{
+       (void) array; /* remove warning */
+       g_free(data);
+}
+void neardal_tools_prv_g_ptr_array_free(GPtrArray *array)
+{
+       g_ptr_array_foreach(array, neardal_tools_g_ptr_array_free_node, NULL);
+       g_ptr_array_free(array, TRUE);
+}
+
+/******************************************************************************
+ * neardal_tools_prv_create_proxy: create dbus proxy to Neard daemon
+ *****************************************************************************/
+errorCode_t neardal_tools_prv_create_proxy(DBusGConnection *conn,
+                                      DBusGProxy **oProxy, const char *path,
+                                      const char *iface)
+{
+       DBusGProxy      *proxy  = NULL;
+       GError          *gerror = NULL;
+
+       g_assert(conn != NULL);
+       g_assert(oProxy != NULL);
+       g_assert(path != NULL);
+       g_assert(iface != NULL);
+
+       NEARDAL_TRACEIN();
+       NEARDAL_TRACEF("Trying connection to (path:'%s', interface:'%s')...\n",
+                     path, iface);
+       proxy = dbus_g_proxy_new_for_name_owner(conn, NEARD_DBUS_SERVICE, path,
+                                               iface, &gerror);
+       if (proxy == NULL) {
+               NEARDAL_TRACE_ERR(
+               "Unable to connect to (path:'%s', interface:'%s') (err:'%s')\n",
+                                path, iface, gerror->message);
+               g_error_free(gerror);
+               return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
+       }
+       NEARDAL_TRACEF("Connection to (path:'%s', interface:'%s') OK!\n", path,
+                     iface);
+/*TODO g_signal_connect (G_OBJECT (proxy), "destroy",
+ *                     G_CALLBACK(destroy_signal), proxy); */
+
+       *oProxy = proxy;
+
+       return NEARDAL_SUCCESS;
+}
+
+/******************************************************************************
+ * neardal_tools_prv_free_gerror: freeing gerror in neardal context
+ *****************************************************************************/
+void neardal_tools_prv_free_gerror(neardal_t neardalObj)
+{
+       g_assert(neardalObj != NULL);
+
+       if (neardalObj->gerror != NULL)
+               g_error_free(neardalObj->gerror);
+       neardalObj->gerror = NULL;
+}
+
+/******************************************************************************
+ * neardal_tools_prv_cmp_path: Compare dbus path.
+ * return true (<>0) if path is same, 0 otherwise
+ *****************************************************************************/
+int neardal_tools_prv_cmp_path(const char *neardalPath, const char *reqPath)
+{
+       const char      *shortest;
+       const char      *longest;
+       int             len, lenNfcPath, lenReqPath;
+       int             ret = FALSE;
+
+       g_assert(neardalPath != NULL);
+       g_assert(reqPath != NULL);
+
+       lenNfcPath = strlen(neardalPath);
+       lenReqPath = strlen(reqPath);
+       if (lenNfcPath  > lenReqPath) {
+               shortest        = reqPath;
+               longest         = neardalPath;
+               len             = lenReqPath;
+       } else {
+               shortest        = neardalPath;
+               longest         = reqPath;
+               len             = lenNfcPath;
+       }
+
+       if (!strncmp(shortest, longest, len)) {
+               if (longest[len] == '/' || longest[len] == '\0')
+                       ret = TRUE;
+               else
+                       ret = FALSE;
+       }
+       return ret;
+}
+
+
+/******************************************************************************
+ * neardal_tools_prv_hashtable_get: Parse a hashtable and get value of GType
+ * 'type' with a specific key
+ *****************************************************************************/
+errorCode_t neardal_tools_prv_hashtable_get(GHashTable *hashTable,
+                                       gconstpointer key, GType gtype,
+                                       void *value)
+{
+       gpointer        valueGp = NULL;
+       errorCode_t     errCode = NEARDAL_ERROR_GENERAL_ERROR;
+       gboolean        found;
+
+       NEARDAL_TRACEF("key'%s'=", key);
+       found = g_hash_table_lookup_extended(hashTable, key, NULL, &valueGp);
+       if (found == FALSE) {
+               NEARDAL_TRACE_ERR("key '%s' NOT FOUND!!!\n", key);
+               return errCode;
+       }
+
+       if (valueGp == NULL)
+               goto error;
+
+       if (G_VALUE_HOLDS(valueGp, gtype) != TRUE) {
+               NEARDAL_TRACE_ERR(
+               "Unknown GType (waiting 0x%X='%s' instead of 0x%X='%s')",
+                                gtype, g_type_name(gtype),
+                               G_VALUE_TYPE(valueGp),
+                                g_type_name(G_VALUE_TYPE(valueGp)));
+               goto error;
+       }
+
+       if (value == NULL)
+               goto error;
+
+       switch (gtype) {
+       case G_TYPE_BOOLEAN:
+               *((gboolean *)value) = g_value_get_boolean(valueGp);
+               NEARDAL_TRACE("(boolean) %d", *(gboolean *)value);
+               errCode = NEARDAL_SUCCESS;
+               break;
+       case G_TYPE_STRING:
+               *((const gchar * *)value) = g_value_get_string(valueGp);
+               NEARDAL_TRACE("(string) %s", *(const gchar * *)value);
+               errCode = NEARDAL_SUCCESS;
+               break;
+       default:
+               if (gtype == G_TYPE_STRV) {
+                       void *tmp;
+
+                       tmp = g_value_get_boxed(valueGp);
+                       *((gchar ***)value) = tmp;
+                       NEARDAL_TRACE("(array of strings, first string =) %s",
+                                       ((gchar **) tmp)[0]);
+                       errCode = NEARDAL_SUCCESS;
+                       break;
+               }
+               if (gtype == DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH) {
+                       GPtrArray       *tmp = NULL;
+                       tmp = g_value_get_boxed(valueGp);
+
+                       errCode = NEARDAL_ERROR_GENERAL_ERROR;
+                       if (tmp == NULL)
+                               break;
+
+                       NEARDAL_TRACE("(array of DBusGObjectPath: ");
+                       if (tmp->len > 0)
+                               NEARDAL_TRACE(
+                                       "%d elements, first path=%s)",
+                                       tmp->len,
+                                       g_ptr_array_index(tmp, 0));
+                       else
+                               NEARDAL_TRACE(" (Empty!)");
+                       *((GPtrArray **)value) = tmp;
+                       errCode = NEARDAL_SUCCESS;
+                       break;
+               }
+
+               NEARDAL_TRACE_ERR(
+               "Unknown GType (waiting 0x%X='%s' instead of 0x%X='%s')",
+                                       gtype, g_type_name(gtype),
+                                       G_VALUE_TYPE(valueGp),
+                                       g_type_name(G_VALUE_TYPE(valueGp)));
+               break;
+       }
+
+       NEARDAL_TRACE("\n");
+
+       return errCode;
+
+error:
+       NEARDAL_TRACE_ERR("key '%s' NOT FOUND!!!\n", key);
+       return errCode;
+
+}
+
+/******************************************************************************
+ * neardal_tools_create_dict: Create a GHashTable for dict_entries.
+ *****************************************************************************/
+GHashTable *neardal_tools_create_dict(void)
+{
+       return g_hash_table_new(g_str_hash, g_str_equal);
+}
+
+/******************************************************************************
+ * neardal_tools_add_dict_entry: add an entry in a dictionnary
+ *****************************************************************************/
+errorCode_t neardal_tools_add_dict_entry(GHashTable *hash, gchar *key,
+                                         gchar *value)
+{      
+       errorCode_t     err = NEARDAL_ERROR_NO_MEMORY;
+       GValue          *gvalue;
+
+       g_assert(hash != NULL);
+
+       gvalue = g_try_malloc0(sizeof(GValue));
+       if (gvalue == NULL)
+               goto error;
+       
+       g_value_init (gvalue, G_TYPE_STRING);
+       g_value_set_string (gvalue, value);
+       g_hash_table_insert (hash, (char *) key, gvalue);
+
+       err = NEARDAL_SUCCESS;
+
+error:
+       return err;
+}
+
diff --git a/lib/neardal_tools.h b/lib/neardal_tools.h
new file mode 100644 (file)
index 0000000..385d197
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_TOOLS_H
+#define __NEARDAL_TOOLS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+ * neardal_tools_prv_free_gerror: freeing gerror in neardal context
+ *****************************************************************************/
+void neardal_tools_prv_free_gerror(neardal_t neardalObj);
+
+/******************************************************************************
+ * neardal_tools_prv_cmp_path: Compare dbus path.
+ * return true (<>0) if path is same, 0 otherwise
+ *****************************************************************************/
+int neardal_tools_prv_cmp_path(const char *neardalPath, const char *reqPath);
+
+/******************************************************************************
+ * neardal_tools_prv_hashtable_get: Parse a hashtable and get value of GType
+ * 'type' with a specific key
+ *****************************************************************************/
+errorCode_t neardal_tools_prv_hashtable_get(GHashTable *hashTable,
+                                       gconstpointer key, GType gtype,
+                                       void *value);
+
+/******************************************************************************
+ * neardal_tools_prv_create_proxy: create dbus proxy to Neard daemon
+ *****************************************************************************/
+errorCode_t neardal_tools_prv_create_proxy(DBusGConnection *conn,
+                                      DBusGProxy **oProxy, const char *path,
+                                      const char *iface);
+
+/******************************************************************************
+ * neardal_marshal_VOID__STRING_BOXED: marshaller function for signal
+ * invocations
+ *****************************************************************************/
+void neardal_marshal_VOID__STRING_BOXED(GClosure       *closure,
+                                        GValue         *return_value,
+                                        guint          n_param_values,
+                                        const GValue   *param_values,
+                                        gpointer       invocation_hint,
+                                        gpointer       marshal_data);
+
+/******************************************************************************
+ * neardal_tools_prv__g_ptr_array_copy: duplicate a 'GPtrArray' array
+ *****************************************************************************/
+void neardal_tools_prv_g_ptr_array_copy(GPtrArray **target, GPtrArray *source);
+
+/******************************************************************************
+ * neardal_tools_prv_g_ptr_array_free: free a 'GPtrArray' array
+ *****************************************************************************/
+void neardal_tools_prv_g_ptr_array_free(GPtrArray *array);
+
+/******************************************************************************
+ * neardal_tools_create_dict: Create a GHashTable for dict_entries.
+ *****************************************************************************/
+GHashTable *neardal_tools_create_dict(void);
+
+/******************************************************************************
+ * neardal_tools_add_dict_entry: add an entry in a dictionnary
+ *****************************************************************************/
+errorCode_t neardal_tools_add_dict_entry(GHashTable *hash, gchar *key,
+                                         gchar *value);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_TOOLS_H */
diff --git a/lib/neardal_traces.c b/lib/neardal_traces.c
new file mode 100644 (file)
index 0000000..379672b
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <glib.h>
+
+#include "neardal_traces_prv.h"
+
+#define NB_COLUMN              16
+
+/*
+ * neardal_trace
+ *
+ * trace function.
+ *
+ */
+
+
+void neardal_trace(FILE *stream, char *format, ...)
+{
+       va_list ap;
+       gchar   *bufTrace;
+
+       va_start(ap, format);
+
+       bufTrace = g_strdup_vprintf(format, ap);
+       if (bufTrace != NULL) {
+               fprintf(stream, "%s", bufTrace);
+               fflush(stream);
+       }
+       va_end(ap);
+       g_free(bufTrace);
+}
+
+static void neardal_prv_dump_data_as_binary_format(char *bufToReadP,
+                                                   int remainingSize,
+                                                   GString *bufDestP,
+                                                   int nbColumn)
+{
+       int offset = 0;
+
+       while (offset < nbColumn && offset < remainingSize) {
+               g_string_append_printf(bufDestP, "%02hX ",
+                                      ((unsigned char) bufToReadP[offset]));
+               offset++;
+       }
+       /* Adding space to align ascii format */
+       if (offset < nbColumn) {
+               /* 3 space because each byte in binary format as 2 digit and
+               1 space */
+               g_string_append_len(bufDestP, "   ", nbColumn - offset);
+       }
+}
+
+static void neardal_prv_dump_data_as_ascii_format(char *bufToReadP,
+                                             int remainingSize,
+                                             GString *bufDestP, int nbColumn)
+{
+       int             offset = 0;
+
+       while (offset < nbColumn && offset < remainingSize) {
+               if (g_ascii_isprint(((unsigned char) bufToReadP[offset])))
+                       g_string_append_c(bufDestP,
+                                         ((unsigned char) bufToReadP[offset]));
+               else
+                       g_string_append_c(bufDestP, '.');
+               offset++;
+       }
+       /* Adding space to finish ascii column */
+       if (offset < nbColumn)
+               g_string_append_len(bufDestP, " ", nbColumn - offset);
+}
+
+
+void neardal_trace_dump_mem(char *bufToReadP, int size)
+{
+       char    *memP = bufToReadP;
+       int             len = size;
+       int             offset = 0;
+       GString *bufTrace;
+
+       if (!memP || size <= 0)
+               return;
+
+       offset  = 0;
+
+       bufTrace = g_string_new(NULL);
+       while (len > 0) {
+               g_string_append_printf(bufTrace, "%08lX : ",
+                                      (unsigned long) (&bufToReadP[offset]));
+               neardal_prv_dump_data_as_binary_format(&bufToReadP[offset],
+                                                       len, bufTrace,
+                                                       NB_COLUMN);
+               neardal_prv_dump_data_as_ascii_format(&bufToReadP[offset],
+                                                      len, bufTrace,
+                                                      NB_COLUMN);
+               NEARDAL_TRACE("%s\n", bufTrace->str);
+               len             -= NB_COLUMN;
+               offset  += NB_COLUMN;
+               g_string_truncate(bufTrace, 0);
+       }
+       g_string_free(bufTrace, TRUE);
+}
diff --git a/lib/neardal_traces_prv.h b/lib/neardal_traces_prv.h
new file mode 100644 (file)
index 0000000..c3c7508
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *     NEARDAL (Neard Abstraction Library)
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NEARDAL_TRACES_PRV_H
+#define __NEARDAL_TRACES_PRV_H
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* a debug output macro */
+#ifdef NEARDAL_TRACES
+       #define NEARDAL_TRACE(msg, ...) neardal_trace(stdout, \
+                                               msg, ##__VA_ARGS__)
+       #define NEARDAL_TRACEDUMP(adr, size)    neardal_trace_dump_mem(adr, \
+                                               size)
+
+       /* Macro including function name before traces */
+       #define NEARDAL_TRACEF(msg, ...)        neardal_trace(stdout, \
+                               "%s() : " msg, __func__, ## __VA_ARGS__)
+       #define NEARDAL_TRACEIN()               neardal_trace(stdout, \
+       "%s() : Processing...\n", __func__)
+#else
+
+       #define NEARDAL_TRACE(msg, ...) (void)0
+       #define NEARDAL_TRACEDUMP(adr, size)    (void)0
+
+       #define NEARDAL_TRACEF(msg, ...)        (void)0
+       #define NEARDAL_TRACEIN()               (void)0
+#endif /* NEARDAL_DEBUG */
+/* always defined */
+#define NEARDAL_TRACE_ERR(msg, ...)            neardal_trace(stderr, \
+                               "%s(ERR) : " msg, __func__, ##__VA_ARGS__)
+
+void neardal_trace(FILE *stream, char *format, ...);
+void neardal_trace_dump_mem(char *dataP, int size);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_TRACES_PRV_H */
diff --git a/ncl/Makefile.am b/ncl/Makefile.am
new file mode 100644 (file)
index 0000000..b75a2c9
--- /dev/null
@@ -0,0 +1,7 @@
+noinst_PROGRAMS=ncl
+
+ncl_SOURCES =  ncl.c \
+               ncl_cmd.c
+
+ncl_CFLAGS = $(GLIB_CFLAGS) -I../lib
+ncl_LDADD = $(GLIB_LIBS) ../lib/libneardal.la
diff --git a/ncl/ncl.c b/ncl/ncl.c
new file mode 100644 (file)
index 0000000..dec7697
--- /dev/null
+++ b/ncl/ncl.c
@@ -0,0 +1,433 @@
+/*
+ *     NEARDAL Tester command line interpreter
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <signal.h>
+
+#include <neardal.h>
+#include "neardal_traces_prv.h"
+
+#include "ncl.h"
+#include "ncl_cmd.h"
+#include <glib-2.0/glib/gstrfuncs.h>
+
+#define PROMPT_PREFIX          "NCL> "
+#define NB_MAX_PARAMETERS      20      /* Max number of parameters in a
+                                       command */
+
+NCLContext     gNclCtx;
+
+char *ncl_error_get_text(NCLError ec)
+{
+       switch (ec) {
+       case NCLERR_NOERROR:
+               return "Success";
+
+       case NCLERR_GLOBAL_ERROR:
+               return "General error";
+
+       case NCLERR_PARSING_PARAMETERS:
+               return "Invalid parameter";
+
+       case NCLERR_MEM_ALLOC:
+               return "Memory allocation error";
+
+       case NCLERR_INIT:
+               return "Error while initializing command line interpretor";
+
+       case NCLERR_LIB_ERROR:
+               return "Error from Linked Library";
+
+       default:
+               return "UNKNOWN ERROR !!!";
+       }
+}
+
+static NCLError ncl_prv_split_cmdLine(gchar  *cmdLine, int *iArgc,
+                                     char *iArgv[])
+{
+       NCLError        err     = NCLERR_NOERROR;
+       gssize          splitPos;
+       char            **argv  = NULL;
+       int             *argc;
+       char            *bufPos;
+       char            *prevBufPos;
+       bool            split;
+
+       /* Test input parameters */
+       if (!cmdLine || !iArgc || !iArgv)
+               return NCLERR_PARSING_PARAMETERS;
+       argv = iArgv;
+       argc = iArgc;
+
+       /* Splitting parameters list like argc/argv style */
+       splitPos = 0;
+       split = true;
+       *argc = 0;
+       (((char **)(argv))[(*argc)++]) = cmdLine;
+       prevBufPos = cmdLine;
+       bufPos = prevBufPos;
+       if (bufPos == NULL)
+               return NCLERR_PARSING_PARAMETERS;
+       
+       while ((*argc) < NB_MAX_PARAMETERS && *bufPos != '\0') {
+               while(*bufPos != ' ' && *bufPos != '"' && *bufPos != '\0') {
+                       bufPos++;
+               }
+               if (*bufPos == '"') {
+                       if (split)
+                               split = false;
+                       else
+                               split = true;
+                       bufPos++;
+               }
+               if (bufPos && split == true) {
+                       splitPos += ((gssize)((long)bufPos - (long)prevBufPos));
+                       cmdLine[splitPos] = '\0';
+                       bufPos++;
+                       splitPos++;
+                       if (((gssize)((long)bufPos - (long)prevBufPos)) > 0)
+                               (((char **)(argv))[(*argc)++]) = bufPos;
+                       prevBufPos = bufPos;
+               } else
+                       bufPos++;
+       }
+
+       return err;
+}
+
+static ncl_cmd_func ncl_prv_find_func(char *cmd)
+{
+       int                     index;
+       NCLCmdInterpretor       *it; /* commands interpretor array */
+       int                     nbClCmd;
+
+       it = ncl_cmd_get_list(&nbClCmd);
+       if (it == NULL)
+               return NULL;
+
+       for (index = 0; index < nbClCmd; index++)
+               if (!strncmp(it[index].cmdName, cmd, strlen(cmd)))
+                       return it[index].func;
+
+       return NULL;
+}
+
+NCLError ncl_exec(char *cmdName)
+{
+       NCLError                ret             = NCLERR_NOERROR;
+       GError                  *gerror         = NULL;
+       ncl_cmd_func            funcList        = NULL;
+       char                    *cmd            = NULL;
+       char                    *argv[NB_MAX_PARAMETERS];
+       int                     argc;
+
+       /* Duplicate Command line before split */
+       cmd = g_strdup(cmdName);
+       if (cmd == NULL)
+               return NCLERR_MEM_ALLOC;
+
+       /* Invoking 'list' command to display interpretor commands list */
+       memset(argv, 0, sizeof(argv));
+       ret = ncl_prv_split_cmdLine(cmd, &argc, argv);
+       if (ret != NCLERR_NOERROR) {
+               NCL_CMD_PRINTERR("Error while parsing '%s'\n", cmdName);
+               goto error;
+       }
+
+       funcList = ncl_prv_find_func(argv[0]);
+       if (funcList != NULL) {
+               ret = (*funcList)(argc, argv);
+               if (ret < NCLERR_NOERROR)
+                       NCL_CMD_PRINTERR(
+                               "Error command '%s' return err %d (%s)\n",
+                                        argv[0], ret, ncl_error_get_text(ret));
+       } else {
+               NCL_CMD_PRINTERR("Unknow NCL function '%s', trying shell...\n",
+                                cmdName);
+               g_spawn_command_line_async(cmdName, &gerror);
+               if (gerror != NULL) {
+                       NCL_CMD_PRINTERR("Shell return error %d:%s\n",
+                                        gerror->code, gerror->message);
+                       g_error_free(gerror);
+               }
+       }
+       g_free(cmd);
+
+       return ret;
+
+error:
+       if (cmd != NULL)
+               g_free(cmd);
+       return ret;
+}
+
+
+static gboolean ncl_prv_kbinput_cb(GIOChannel *source, GIOCondition condition,
+                                  gpointer data)
+{
+       NCLContext      *nclCtx = (NCLContext *) data;
+       GError          *error  = NULL;
+
+       switch (condition) {
+       case G_IO_IN: {
+               gsize           terminator_pos;
+               GIOStatus       status;
+               NCLCmdContext   *nclCmdCtx;
+
+               nclCmdCtx = ncl_cmd_get_ctx();
+               if (!nclCmdCtx)
+                       return FALSE;
+
+               status = g_io_channel_read_line_string(source,
+                                                       nclCmdCtx->clBuf,
+                                                       &terminator_pos,
+                                                       &error);
+               (void) status; /* Remove warning */
+               if (nclCmdCtx->clBuf->str) {
+                       nclCmdCtx->clBuf->str[terminator_pos] = '\0';
+
+                       if (nclCmdCtx->clBuf->str[0] != '\0') {
+                               nclCtx->errOnExit = NCLERR_PARSING_PARAMETERS;
+                               nclCtx->errOnExit = ncl_exec(
+                                                       nclCmdCtx->clBuf->str);
+                       }
+                       g_string_erase(nclCmdCtx->clBuf, 0, -1);
+               } else
+                       NCL_CMD_PRINTERR("buf is NULL!!!\n");
+       }
+       break;
+       case G_IO_PRI:
+       case G_IO_ERR:
+       case G_IO_HUP:
+       case G_IO_NVAL:
+       default:
+               NCL_CMD_PRINTERR("unhandled condition (%d)\n", condition);
+       break;
+       }
+       ncl_prompt();
+
+       return TRUE;
+}
+
+void ncl_prompt(void)
+{
+       ncl_cmd_print(stdout, PROMPT_PREFIX);
+}
+
+NCLContext *ncl_get_ctx(void)
+{
+       return &gNclCtx;
+}
+
+
+void ncl_finalize(void)
+{
+       NCL_CMD_PRINTIN();
+
+       /* Freeing command line interpretor context */
+       ncl_cmd_finalize();
+
+       if (gNclCtx.channel) {
+               g_io_channel_unref(gNclCtx.channel);
+               g_io_channel_shutdown(gNclCtx.channel, TRUE, NULL);
+               g_source_remove(gNclCtx.tag);
+       }
+       if (gNclCtx.main_loop)
+               g_main_loop_unref(gNclCtx.main_loop);
+}
+
+/*
+static void signal_handler(int signum)
+{
+       NCL_CMD_PRINTERR("Receive signal %d\n", signum);
+}
+*/
+static NCLError ncl_prv_init(char *execCmdLineStr)
+{
+/*     struct sigaction        sa;
+       int                     err = NCLERR_NOERROR; */
+
+       /* Initialize Test App context... */
+       memset(&gNclCtx, 0, sizeof(gNclCtx));
+
+/*
+       sa.sa_handler = signal_handler;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_RESTART;
+    if (sigaction(SIGINT, &sa, NULL) == -1)
+       {
+               NCL_CMD_PRINTERR("Unable to handle system signals\n");
+               return NCLERR_INIT;
+       }
+*/
+
+       gNclCtx.main_loop = g_main_loop_new(NULL, FALSE);
+
+       /* Initialize command line interpretor context */
+       return ncl_cmd_init(execCmdLineStr);
+}
+
+static void ncl_prv_parse_script_file(char *scriptFileStr)
+{
+       FILE    *scriptFile;
+       char    *cmdLineStr     = NULL;
+       size_t  cmdLineSize;
+       ssize_t nbRead;
+
+       /* Opening file */
+       scriptFile = fopen(scriptFileStr, "r");
+       if (scriptFile == NULL) {
+               gNclCtx.errOnExit = NCLERR_GLOBAL_ERROR;
+               return;
+       }
+
+       do {
+               /* Reading command line script file */
+               nbRead = getline(&cmdLineStr, &cmdLineSize, scriptFile);
+               if (nbRead > 0 && strlen(cmdLineStr) > 1) {
+                       cmdLineSize = strlen(cmdLineStr);
+                       if (cmdLineStr[0] != '#') {
+                               if (cmdLineStr[cmdLineSize - 1] == '\n')
+                                       cmdLineStr[cmdLineSize - 1] = '\0';
+
+                               /* Executing command line */
+                               ncl_cmd_print(stdout,
+                                             "$$$$$$$$$$$$$$$$$$$$$$$$$'\n");
+                               ncl_cmd_print(stdout,
+                                             "Executing '%s'\n", cmdLineStr);
+                               ncl_cmd_print(stdout,
+                                             "$$$$$$$$$$$$$$$$$$$$$$$$$'\n");
+                               gNclCtx.errOnExit = ncl_exec(cmdLineStr);
+
+                               /* Main loop */
+                               do {
+                                       g_main_context_iteration(NULL, false);
+                               } while (g_main_context_pending(NULL));
+                       }
+               }
+               /* Freeing command line */
+               if (cmdLineStr != NULL) {
+                       free(cmdLineStr);
+                       cmdLineStr = NULL;
+               }
+       } while (nbRead > 0 && gNclCtx.errOnExit == NCLERR_NOERROR);
+       g_free(scriptFile);
+}
+
+int main(int argc, char *argv[])
+{
+       NCLError        err;
+       int             fd;
+       GOptionContext  *context;
+       GError          *error          = NULL;
+       static char     *execCmdLineStr;
+       static char     *scriptFileStr;
+static GOptionEntry    options[] = {
+               { "exec"        , 'e', 0, G_OPTION_ARG_STRING, &execCmdLineStr,
+               "Execute specific command line function", "Command Line" },
+               { "script", 's', 0, G_OPTION_ARG_STRING , &scriptFileStr
+                                 , "Script file to execute", "filename" },
+               { NULL, 0, 0, 0, NULL, NULL, NULL} /* End of List */
+       };
+
+       execCmdLineStr  = NULL;
+       scriptFileStr   = NULL;
+       NCL_CMD_PRINTIN();
+
+       context = g_option_context_new("");
+       g_option_context_add_main_entries(context, options, "");
+       if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+               if (error != NULL) {
+                       NCL_CMD_PRINTERR("%s\n", error->message);
+                       g_error_free(error);
+               } else
+                       NCL_CMD_PRINTERR("An unknown error occurred\n");
+               return NCLERR_INIT;
+       }
+       g_option_context_free(context);
+
+       err = ncl_prv_init(execCmdLineStr);
+       if (err != NCLERR_NOERROR) {
+               ncl_finalize();
+               return NCLERR_INIT;
+       }
+
+       /* Do we have a command line in parameters list ? */
+       if (scriptFileStr == NULL) {
+               /* No, test application executed without a command line in
+               parameter. Do we have a command in parameters list ? */
+               if (execCmdLineStr == NULL) {
+                       /* No, test application executed without a command
+                       line in parameter */
+
+                       /* Wrap stdin (keyboard) on callback */
+                       fd = fileno(stdin);
+                       gNclCtx.channel = g_io_channel_unix_new(fd);
+                       g_io_channel_set_encoding(gNclCtx.channel, NULL, NULL);
+                       g_io_channel_set_buffered(gNclCtx.channel, TRUE);
+                       gNclCtx.tag = g_io_add_watch(gNclCtx.channel, G_IO_IN,
+                                               (GIOFunc) ncl_prv_kbinput_cb,
+                                                    &gNclCtx);
+
+                       /* Invoking 'help' command to display commands line
+                        * list */
+                       ncl_exec(LISTCMD_NAME);
+                       ncl_prompt();
+
+                       /* Launch main-loop */
+                       g_main_loop_run(gNclCtx.main_loop);
+               } else {
+                       int eventsCount = 0;
+
+                       /* Yes, test application executed with a command line
+                        * in parameter */
+                       NCL_CMD_PRINTF("Executing command ('%s')...\n",
+                                      execCmdLineStr);
+                       gNclCtx.errOnExit = ncl_exec(execCmdLineStr);
+
+                       NCL_CMD_PRINT(
+                               "Command executed('%s'), processing events...",
+                                     execCmdLineStr);
+                       do {
+                               NCL_CMD_PRINT("*");
+                               eventsCount++;
+                       } while (g_main_context_iteration(NULL, false) == true);
+                       NCL_CMD_PRINT("\n");
+                       NCL_CMD_PRINTF("All events have been processed (%d).\n",
+                                      eventsCount);
+                       g_free(execCmdLineStr);
+               }
+       } else
+               ncl_prv_parse_script_file(scriptFileStr);
+
+       err = gNclCtx.errOnExit;
+
+       ncl_finalize();
+
+       if (err != NCLERR_NOERROR)
+               NCL_CMD_PRINTERR("Exit with error %d\n", err);
+
+       return err;
+}
diff --git a/ncl/ncl.h b/ncl/ncl.h
new file mode 100644 (file)
index 0000000..f1bf162
--- /dev/null
+++ b/ncl/ncl.h
@@ -0,0 +1,57 @@
+/*
+ *     NEARDAL Tester command line interpreter
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#ifndef __NCL_H__
+#define __NCL_H__
+
+#include <glib.h>
+
+/* Buffer size for the command line interpretor */
+#define        CL_BUF_SIZE                     1024
+
+/* Test Application Errors list (Only negative values are errors) */
+typedef enum {
+       NCLERR_NOERROR_HELP_DISP        = 1,
+       NCLERR_NOERROR                  = 0,
+       NCLERR_GLOBAL_ERROR             = -1,
+       NCLERR_PARSING_PARAMETERS       = -2,
+       NCLERR_INIT                     = -3,
+       NCLERR_MEM_ALLOC                = -4,
+       NCLERR_LIB_ERROR                = -5
+} NCLError;
+
+/* Test Application Context */
+typedef struct {
+       GMainLoop       *main_loop;
+       GIOChannel      *channel;       /* for stdin descriptor */
+       guint           tag;            /* the ID of the source */
+       NCLError        errOnExit;      /* Error returned on exit */
+} NCLContext;
+
+NCLContext *ncl_get_ctx(void);
+
+/* Name of the command interpretor to display commands list */
+#define LISTCMD_NAME   "help"
+
+/* Display prompt */
+void ncl_prompt(void);
+
+#endif /* __NCL_H__ */
diff --git a/ncl/ncl_cmd.c b/ncl/ncl_cmd.c
new file mode 100644 (file)
index 0000000..524088e
--- /dev/null
@@ -0,0 +1,1111 @@
+/*
+ *     NEARDAL Tester command line interpreter
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "neardal.h"
+#include "ncl.h"
+#include "ncl_cmd.h"
+#include <lib/neardal.h>
+#include <glib-2.0/glib/goption.h>
+
+
+static NCLCmdContext  sNclCmdCtx;
+/* Some default values...
+ * Max number of parameters provided in a command */
+#define NB_MAX_PARAMETERS      20
+
+typedef struct {
+       uint32_t        idValue;
+       gchar           *capStr;
+       gchar           *helpStr;
+} list_inf;
+
+#define        DEFSTR(x)               (x, #x)
+
+
+/* Local Utilities functions */
+/******************************************************************************
+ * Tool function : help command to dump parameters command
+ *****************************************************************************/
+static void ncl_cmd_prv_dumpOptions(GOptionEntry *options)
+{
+       GOptionEntry    *optP = options;
+       char            long_nameTmp[20];
+
+       while (optP->description != NULL) {
+               snprintf(long_nameTmp, sizeof(long_nameTmp), "--%s",
+                        optP->long_name);
+
+               ncl_cmd_print(stdout, "-%c,\t%s=%s\t%20s\n", optP->short_name,
+                             long_nameTmp, optP->arg_description,
+                             optP->description);
+               optP++;
+       }
+}
+
+
+/******************************************************************************
+ * Tool function : parse parameters command (like g_option_context_parse but
+ * implicit exit() on '--help' disabled
+ *****************************************************************************/
+static NCLError ncl_cmd_prv_parseOptions(int *argc, char **argv[],
+                                        GOptionEntry *options)
+{
+       GOptionContext  *context;
+       GError          *error          = NULL;
+       NCLError        err             = NCLERR_NOERROR;
+       char            **argvP;
+       int             argn;
+       int             helpRequested   = 0;
+
+       context = g_option_context_new(NULL);
+       g_option_context_add_main_entries(context, options, NULL);
+       /* disable '--help' parameter else function 'exit()' is implicitly
+        * called... */
+       g_option_context_set_help_enabled(context, FALSE);
+
+       /* Searching 'help' in arguments */
+       argvP = *argv;
+       argn  = *argc;
+       while (argn && !helpRequested) {
+               helpRequested = (strstr(*argvP, "help") != NULL);
+               helpRequested |= (strstr(*argvP, "-h") != NULL);
+               helpRequested |= (strstr(*argvP, "/?") != NULL);
+               argn--;
+               argvP++;
+       }
+
+       /* if help requested, generate a 'help' display */
+       if (helpRequested) {
+               ncl_cmd_prv_dumpOptions(options);
+               err = NCLERR_NOERROR_HELP_DISP;
+       } else {
+               if (!g_option_context_parse(context, argc, argv, &error)) {
+                       if (error != NULL) {
+                               NCL_CMD_PRINTERR("%s\n", error->message);
+                               g_error_free(error);
+                       } else
+                               NCL_CMD_PRINTERR("Unknown error occurred\n");
+                       err = NCLERR_GLOBAL_ERROR;
+               }
+       }
+       g_option_context_free(context);
+       return err;
+}
+
+
+
+/* BEGIN : Interpretor commands array */
+static NCLCmdInterpretor itFunc[];
+
+/******************************************************************************
+ * Display Interpretor command list
+ *****************************************************************************/
+NCLError ncl_cmd_list(int argc, char *argv[])
+{
+       int index;
+       char funcName[50];
+       int  nbCmd = ncl_cmd_get_nbCmd();
+
+       (void) argc; /* remove warning */
+       (void) argv; /* remove warning */
+
+       ncl_cmd_print(stdout, "\nCommand line list\n");
+       for (index = 0; index < nbCmd; index++) {
+               snprintf(funcName, sizeof(funcName), "%40s",
+                        itFunc[index].cmdName);
+               ncl_cmd_print(stdout, "%s :\t%s\n", funcName,
+                             itFunc[index].helpStr);
+       }
+
+       return 0;
+}
+
+
+/******************************************************************************
+ * Dump properties of an adapter
+ *****************************************************************************/
+static void ncl_cmd_prv_dump_adapter(neardal_adapter adapter)
+{
+       char **protocols;
+       char **targets;
+
+       NCL_CMD_PRINT("Adapter\n");
+       NCL_CMD_PRINT(".. Name:\t\t'%s'\n", adapter.name);
+
+       NCL_CMD_PRINT(".. Polling:\t\t'%s'\n",
+                     adapter.polling ? "TRUE" : "FALSE");
+       NCL_CMD_PRINT(".. Powered:\t\t'%s'\n",
+                     adapter.powered ? "TRUE" : "FALSE");
+
+       targets = adapter.targets;
+       NCL_CMD_PRINT(".. Number of targets:\t%d\n", adapter.nbTargets);
+       NCL_CMD_PRINT(".. Targets[]:\t\t");
+       if (adapter.nbTargets > 0) {
+               while ((*targets) != NULL) {
+                       NCL_CMD_PRINT("'%s', ", *targets);
+                       targets++;
+               }
+               neardal_free_array(&adapter.targets);
+       } else
+               NCL_CMD_PRINT("No targets!");
+       NCL_CMD_PRINT("\n");
+
+       protocols = adapter.protocols;
+       NCL_CMD_PRINT(".. Number of protocols:\t%d\n", adapter.nbProtocols);
+       NCL_CMD_PRINT(".. Protocols[]:\t\t");
+       if (adapter.nbProtocols > 0) {
+               while ((*protocols) != NULL) {
+                       NCL_CMD_PRINT("'%s', ", *protocols);
+                       protocols++;
+               }
+               neardal_free_array(&adapter.protocols);
+       } else
+               NCL_CMD_PRINT("No protocols!");
+       NCL_CMD_PRINT("\n");
+}
+
+/******************************************************************************
+ * Dump properties of a target
+ *****************************************************************************/
+static void ncl_cmd_prv_dump_target(neardal_target target)
+{
+       char **records;
+       char **tagTypes;
+
+       NCL_CMD_PRINT("Target:\n");
+       NCL_CMD_PRINT(".. Name:\t\t'%s'\n", target.name);
+
+       NCL_CMD_PRINT(".. Type:\t\t'%s'\n", target.type);
+
+       NCL_CMD_PRINT(".. Number of 'Tag Type':%d\n", target.nbTagTypes);
+       tagTypes = target.tagType;
+       if (target.nbTagTypes > 0) {
+               NCL_CMD_PRINT(".. Tags type[]:\t\t");
+               while ((*tagTypes) != NULL) {
+                       NCL_CMD_PRINT("'%s', ", *tagTypes);
+                       tagTypes++;
+               }
+               NCL_CMD_PRINT("\n");
+               neardal_free_array(&target.tagType);
+       }
+
+       records = target.records;
+       NCL_CMD_PRINT(".. Number of records:\t%d\n", target.nbRecords);
+       NCL_CMD_PRINT(".. Records[]:\t\t");
+       if (records != NULL) {
+               while ((*records) != NULL) {
+                       NCL_CMD_PRINT("'%s', ", *records);
+                       records++;
+               }
+               neardal_free_array(&target.records);
+       } else
+               NCL_CMD_PRINT("No records!");
+
+       NCL_CMD_PRINT("\n");
+       NCL_CMD_PRINT(".. ReadOnly:\t\t%s\n"    ,
+                     target.readOnly ? "TRUE" : "FALSE");
+}
+
+/******************************************************************************
+ * Dump properties of a record
+ *****************************************************************************/
+static void ncl_cmd_prv_dump_record(neardal_record record)
+{
+       NCL_CMD_PRINT("Record\n");
+       NCL_CMD_PRINT(".. Name:\t\t%s\n"        , record.name);
+       NCL_CMD_PRINT(".. Encoding:\t\t%s\n"    , record.encoding);
+       NCL_CMD_PRINT(".. HandOver:\t\t%s\n"    ,
+                     record.handOver ? "TRUE" : "FALSE");
+       NCL_CMD_PRINT(".. Language:\t\t%s\n"    , record.language);
+       NCL_CMD_PRINT(".. SmartPoster:\t\t%s\n" ,
+                     record.smartPoster ? "TRUE" : "FALSE");
+       NCL_CMD_PRINT(".. Action:\t\t%s\n"      , record.action);
+
+       NCL_CMD_PRINT(".. Type:\t\t%s\n"        , record.type);
+       NCL_CMD_PRINT(".. Representation:\t%s\n", record.representation);
+       NCL_CMD_PRINT(".. URI:\t\t\t%s\n"       , record.uri);
+       NCL_CMD_PRINT(".. MIME:\t\t%s\n"        , record.mime);
+}
+
+/******************************************************************************
+ * neardal_construct : BEGIN
+ * Instanciate NFC object, create Neard Dbus connection, register Neard's event
+ *****************************************************************************/
+static void ncl_cmd_cb_adapter_added(const char *adpName, void *user_data)
+{
+       neardal_t       neardalObj = user_data;
+       errorCode_t     ec;
+       neardal_adapter adapter;
+
+       NCL_CMD_PRINTF("NFC Adapter added '%s'\n", adpName);
+       ec = neardal_get_adapter_properties(neardalObj, adpName, &adapter);
+       if (ec == NEARDAL_SUCCESS)
+               ncl_cmd_prv_dump_adapter(adapter);
+       else
+               NCL_CMD_PRINTF(
+               "Unable to read adapter properties. (error:%d='%s'). exit...\n",
+                              ec, neardal_error_get_text(ec));
+
+       return;
+}
+
+static void ncl_cmd_cb_adapter_removed(const char *adpName, void * user_data)
+{
+       neardal_t       neardalObj = user_data;
+
+       (void) neardalObj;
+
+       NCL_CMD_PRINTF("NFC Adapter removed '%s'\n", adpName);
+}
+
+static void ncl_cmd_cb_adapter_prop_changed(char *adpName, char *propName,
+                                           void *value, void *user_data)
+{
+       neardal_t       neardalObj = user_data;
+       int             polling;
+
+       (void) neardalObj;
+       if (!strcmp(propName, "Polling")) {
+               polling = (int)value;
+               NCL_CMD_PRINTF("Polling=%d\n", polling);
+       } else
+               NCL_CMD_PRINTF("Adapter '%s' -> Property=%s=0x%X\n", adpName,
+                              propName, value);
+
+       NCL_CMD_PRINT("\n");
+}
+
+static void ncl_cmd_cb_target_found(const char *tgtName, void *user_data)
+{
+       neardal_t       neardalObj = user_data;
+       neardal_target  target;
+       errorCode_t     ec;
+
+       NCL_CMD_PRINTF("NFC Target found (%s)\n", tgtName);
+
+       ec = neardal_get_target_properties(neardalObj, tgtName, &target);
+       if (ec == NEARDAL_SUCCESS)
+               ncl_cmd_prv_dump_target(target);
+       else
+               NCL_CMD_PRINTF(
+               "Unable to read target properties. (error:%d='%s'). exit...\n",
+                              ec, neardal_error_get_text(ec));
+       return;
+}
+
+static void ncl_cmd_cb_target_lost(const char *tgtName, void *user_data)
+{
+       neardal_t       neardalObj = user_data;
+
+       NCL_CMD_PRINTF("NFC Target lost (%s)\n", tgtName);
+       (void) neardalObj;
+
+}
+
+static void ncl_cmd_cb_record_found(const char *rcdName, void *user_data)
+{
+       neardal_t       neardalObj = user_data;
+       errorCode_t     ec;
+       neardal_record  record;
+
+       NCL_CMD_PRINTF("Target Record found (%s)\n", rcdName);
+       ec = neardal_get_record_properties(neardalObj, rcdName, &record);
+       if (ec == NEARDAL_SUCCESS) {
+               ncl_cmd_prv_dump_record(record);
+/*             NCL_CMD_PRINTF("(Re)Start Poll\n");
+               sleep(1);
+               neardal_start_poll(neardalObj, (char *) rcdName, NULL); */
+       } else
+               NCL_CMD_PRINTF("Read record error. (error:%d='%s').\n", ec,
+                              neardal_error_get_text(ec));
+
+       return;
+}
+
+static NCLError ncl_cmd_neardal_construct(int argc, char *argv[])
+{
+       errorCode_t     ec;
+       NCLError        nclErr;
+
+       (void) argc; /* remove warning */
+       (void) argv; /* remove warning */
+
+       /* Construct NEARDAL object */
+       sNclCmdCtx.neardalObj = neardal_construct(&ec);
+       if (sNclCmdCtx.neardalObj != NULL)
+               NCL_CMD_PRINTF("NFC object constructed");
+       else
+               NCL_CMD_PRINTF("NFC object not constructed");
+       if (ec != NEARDAL_SUCCESS)
+               NCL_CMD_PRINT(" with error:%d='%s'.\n", ec,
+                              neardal_error_get_text(ec));
+       NCL_CMD_PRINT("\n");
+
+       if (sNclCmdCtx.neardalObj == NULL)
+               goto exit;
+
+       nclErr = NCLERR_NOERROR;
+       neardal_set_cb_adapter_added(sNclCmdCtx.neardalObj,
+                                     ncl_cmd_cb_adapter_added,
+                                     sNclCmdCtx.neardalObj);
+       neardal_set_cb_adapter_removed(sNclCmdCtx.neardalObj,
+                                       ncl_cmd_cb_adapter_removed,
+                                       sNclCmdCtx.neardalObj);
+       neardal_set_cb_adapter_property_changed(sNclCmdCtx.neardalObj,
+                                       ncl_cmd_cb_adapter_prop_changed,
+                                               sNclCmdCtx.neardalObj);
+       NCL_CMD_PRINTF("NFC adapter callback registered\n");
+       neardal_set_cb_target_found(sNclCmdCtx.neardalObj,
+                                    ncl_cmd_cb_target_found,
+                                    sNclCmdCtx.neardalObj);
+       neardal_set_cb_target_lost(sNclCmdCtx.neardalObj,
+                                   ncl_cmd_cb_target_lost,
+                                   sNclCmdCtx.neardalObj);
+       NCL_CMD_PRINTF("NFC target registered\n");
+       neardal_set_cb_record_found(sNclCmdCtx.neardalObj,
+                                    ncl_cmd_cb_record_found,
+                                    sNclCmdCtx.neardalObj);
+       NCL_CMD_PRINTF("NFC record callback registered\n");
+
+exit:
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       if (ec == NEARDAL_SUCCESS)
+               nclErr =  NCLERR_NOERROR ;
+       else
+               nclErr = NCLERR_LIB_ERROR;
+
+       return nclErr;
+}
+/******************************************************************************
+ * neardal_construct : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * neardal_get_adapters : BEGIN
+ * Get adapters List
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_get_adapters(int argc, char *argv[])
+{
+       errorCode_t     ec;
+       NCLError        nclErr;
+       char            **adpArray = NULL;
+       int             adpLen;
+       int             adpOff;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       ec = neardal_get_adapters(sNclCmdCtx.neardalObj, &adpArray,
+                                       &adpLen);
+       if (ec == NEARDAL_SUCCESS) {
+               adpOff = 0;
+               /* For each adapter */
+               while (adpArray[adpOff] != NULL)
+                       NCL_CMD_PRINT(".. Adapter '%s'\n",
+                                       adpArray[adpOff++]);
+
+               neardal_free_array(&adpArray);
+       } else
+               NCL_CMD_PRINTF("No adapter\n");
+
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       if (ec == NEARDAL_SUCCESS)
+               nclErr =  NCLERR_NOERROR ;
+       else
+               nclErr = NCLERR_LIB_ERROR;
+
+       return nclErr;
+}
+/******************************************************************************
+ * neardal_get_adapters : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * ncl_cmd_neardal_get_adapter_properties : BEGIN
+ * Read adapter properties
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_get_adapter_properties(int argc, char *argv[])
+{
+       errorCode_t ec;
+       NCLError        nclErr;
+       char            *adapterName    = NULL;
+       neardal_adapter adapter;
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       adapterName = argv[1];
+       ec = neardal_get_adapter_properties(sNclCmdCtx.neardalObj,
+                                            adapterName, &adapter);
+
+       if (ec == NEARDAL_SUCCESS)
+               ncl_cmd_prv_dump_adapter(adapter);
+       else {
+               NCL_CMD_PRINTF("Read adapter properties error:%d='%s'.\n", ec,
+                              neardal_error_get_text(ec));
+               return NCLERR_LIB_ERROR;
+       }
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       return NCLERR_NOERROR;
+}
+/******************************************************************************
+ * ncl_cmd_neardal_get_adapter_properties : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * neardal_get_targets : BEGIN
+ * Get targets List
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_get_targets(int argc, char *argv[])
+{
+       errorCode_t     ec;
+       NCLError        nclErr;
+       char            **tgtArray = NULL;
+       int             tgtLen;
+       int             tgtOff;
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       ec = neardal_get_targets(sNclCmdCtx.neardalObj, argv[1],
+                                       &tgtArray, &tgtLen);
+       if (ec == NEARDAL_SUCCESS) {
+               tgtOff = 0;
+                       /* For each target */
+               while (tgtArray[tgtOff] != NULL)
+                       NCL_CMD_PRINT(".. Target '%s'\n",
+                                       tgtArray[tgtOff++]);
+
+               neardal_free_array(&tgtArray);
+       } else
+               NCL_CMD_PRINTF("No target\n");
+
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       if (ec == NEARDAL_SUCCESS)
+               nclErr =  NCLERR_NOERROR ;
+       else
+               nclErr = NCLERR_LIB_ERROR;
+
+       return nclErr;
+}
+/******************************************************************************
+ * neardal_get_targets : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * ncl_cmd_neardal_get_target_properties : BEGIN
+ * Read target properties
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_get_target_properties(int argc, char *argv[])
+{
+       errorCode_t     ec;
+       NCLError        nclErr;
+       char            *targetName     = NULL;
+       neardal_target  target;
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+
+       targetName = argv[1];
+       ec = neardal_get_target_properties(sNclCmdCtx.neardalObj, targetName,
+                                           &target);
+
+       if (ec == NEARDAL_SUCCESS)
+               ncl_cmd_prv_dump_target(target);
+       else {
+               NCL_CMD_PRINTF("Read target properties error:%d='%s'.\n", ec,
+                              neardal_error_get_text(ec));
+               return NCLERR_LIB_ERROR;
+       }
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       return NCLERR_NOERROR;
+}
+/******************************************************************************
+ * ncl_cmd_neardal_get_target_properties : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * neardal_get_records : BEGIN
+ * Get records List
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_get_records(int argc, char *argv[])
+{
+       errorCode_t     ec;
+       NCLError        nclErr;
+       char            **rcdArray = NULL;
+       int             rcdLen;
+       int             rcdOff;
+
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       ec = neardal_get_records(sNclCmdCtx.neardalObj, argv[1],
+                                       &rcdArray, &rcdLen);
+       if (ec == NEARDAL_SUCCESS) {
+               rcdOff = 0;
+               /* For each record */
+               while (rcdArray[rcdOff] != NULL)
+                       NCL_CMD_PRINT(".. Record '%s'\n",
+                                       rcdArray[rcdOff++]);
+               neardal_free_array(&rcdArray);
+       } else
+               NCL_CMD_PRINTF("No record\n");
+
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       if (ec == NEARDAL_SUCCESS)
+               nclErr =  NCLERR_NOERROR ;
+       else
+               nclErr = NCLERR_LIB_ERROR;
+
+       return nclErr;
+}
+/******************************************************************************
+ * neardal_get_records : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * ncl_cmd_neardal_get_record_properties : BEGIN
+ * Read a specific target
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_get_record_properties(int argc, char *argv[])
+{
+       errorCode_t ec;
+       NCLError        nclErr;
+       char            *recordName     = NULL;
+       neardal_record  record;
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       recordName = argv[1];
+       ec = neardal_get_record_properties(sNclCmdCtx.neardalObj, recordName,
+                                           &record);
+       if (ec == NEARDAL_SUCCESS)
+               ncl_cmd_prv_dump_record(record);
+       else {
+               NCL_CMD_PRINTF("Read record error:%d='%s'.\n", ec,
+                              neardal_error_get_text(ec));
+               return NCLERR_LIB_ERROR;
+       }
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       return NCLERR_NOERROR;
+}
+/******************************************************************************
+ * ncl_cmd_neardal_get_record_properties : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * ncl_cmd_neardal_publish : BEGIN
+ * write NDEF record to tag
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_publish(int argc, char *argv[])
+{
+       errorCode_t             ec = NEARDAL_SUCCESS;
+       NCLError                nclErr;
+       static neardal_record   rcd;
+       static int              smartPoster;
+
+static GOptionEntry options[] = {
+               { "act", 'c', 0, G_OPTION_ARG_STRING, &rcd.action
+                                 , "Action", "save"},
+
+               { "adp", 'a', 0, G_OPTION_ARG_STRING, &rcd.name
+                                 , "Adapter name", "/org/neard/nfc0"},
+
+               { "encoding", 'e', 0, G_OPTION_ARG_STRING, &rcd.encoding
+                               , "Encoding", "UTF-8" },
+
+               { "lang", 'l', 0, G_OPTION_ARG_STRING   , &rcd.language
+                               , "Language", "en" },
+
+               { "mime", 'm', 0, G_OPTION_ARG_STRING   , &rcd.mime
+                               , "Mime-type", "audio/mp3"},
+
+               { "rep" , 'r', 0, G_OPTION_ARG_STRING , &rcd.representation
+                               , "Representation", "sample text" },
+
+               { "smt" , 's', 0, G_OPTION_ARG_INT , &smartPoster
+                               , "SmartPoster", "0 or <>0" },
+
+               { "type", 't', 0, G_OPTION_ARG_STRING, &rcd.type
+                                 , "Record type (Text, URI,...", "Text" },
+
+               { "uri", 'u', 0, G_OPTION_ARG_STRING, &rcd.uri
+                                 , "URI", "http://www.intel.com" },
+
+               { NULL, 0, 0, 0, NULL, NULL, NULL} /* End of List */
+       };
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Parse options */
+       memset(&rcd, 0, sizeof(neardal_record));
+       nclErr = ncl_cmd_prv_parseOptions(&argc, &argv, options);
+       if (nclErr != NCLERR_NOERROR)
+               goto exit;
+       rcd.smartPoster = (smartPoster != 0) ? true : false;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               goto exit;
+
+       ec = neardal_publish(sNclCmdCtx.neardalObj, &rcd);
+
+exit:
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+       if (rcd.action != NULL)
+               g_free((gchar *) rcd.action);
+       if (rcd.name != NULL)
+               g_free((gchar *) rcd.name);
+       if (rcd.encoding != NULL)
+               g_free((gchar *) rcd.encoding);
+       if (rcd.language != NULL)
+               g_free((gchar *) rcd.language);
+       if (rcd.mime != NULL)
+               g_free((gchar *) rcd.mime);
+       if (rcd.representation != NULL)
+               g_free((gchar *) rcd.representation);
+       if (rcd.type != NULL)
+               g_free((gchar *) rcd.type);
+       if (rcd.uri != NULL)
+               g_free((gchar *) rcd.uri);
+
+       return nclErr;
+}
+/******************************************************************************
+ * ncl_cmd_neardal_publish : END
+ *****************************************************************************/
+
+
+/******************************************************************************
+ * ncl_cmd_neardal_start_poll : BEGIN
+ * Request Neard to start polling
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_start_poll(int argc, char *argv[])
+{
+       errorCode_t     ec              = NEARDAL_SUCCESS;
+       char            *adpName        = NULL;
+       NCLError        nclErr;
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       /* Start polling if adapter present */
+       adpName = argv[1];
+       neardal_start_poll(sNclCmdCtx.neardalObj, adpName, &ec);
+       if (ec != NEARDAL_SUCCESS) {
+               NCL_CMD_PRINTF("NFC polling activation error:%d='%s'\n",
+                               ec, neardal_error_get_text(ec));
+               if (ec == NEARDAL_ERROR_POLLING_ALREADY_ACTIVE)
+                       ec = NEARDAL_SUCCESS;
+       }
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       return NCLERR_NOERROR;
+}
+/******************************************************************************
+ * ncl_cmd_neardal_start_poll : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * ncl_cmd_neardal_stop_poll : BEGIN
+ * Request Neard to stop polling
+ *****************************************************************************/
+static NCLError ncl_cmd_neardal_stop_poll(int argc, char *argv[])
+{
+       errorCode_t     ec              = NEARDAL_SUCCESS;
+       NCLError        nclErr          = NCLERR_NOERROR;
+       char            *adpName        = NULL;
+
+       if (argc <= 1)
+               return NCLERR_PARSING_PARAMETERS;
+
+       /* Check if NEARDAL object exist */
+       if (sNclCmdCtx.neardalObj == NULL) {
+               NCL_CMD_PRINTERR("Construct NEARDAL object...\n");
+               nclErr = ncl_cmd_neardal_construct(argc, argv);
+       }
+       if ((nclErr != NCLERR_NOERROR) && (sNclCmdCtx.neardalObj == NULL))
+               return nclErr;
+
+       adpName = argv[1];
+       neardal_stop_poll(sNclCmdCtx.neardalObj, adpName, &ec);
+       if (ec != NEARDAL_SUCCESS) {
+               NCL_CMD_PRINTF("Stop NFC polling error:%d='%s'.\n", ec,
+                              neardal_error_get_text(ec));
+               return NCLERR_LIB_ERROR;
+       }
+       NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+                     neardal_error_get_text(ec));
+
+       return NCLERR_NOERROR;
+}
+/******************************************************************************
+ * ncl_cmd_neardal_stop_poll : END
+ *****************************************************************************/
+
+/******************************************************************************
+ * test parameter type (sample code) : BEGIN
+ *****************************************************************************/
+static gboolean test_cb(const gchar *opt, const gchar *arg, gpointer data,
+                       GError **err)
+{
+       gboolean success = TRUE;
+
+       NCL_CMD_PRINT("Callback invoked from g_option_context_parse()\n");
+       NCL_CMD_PRINT("opt = '%s'\n", opt);
+       NCL_CMD_PRINT("arg = '%s'\n", arg);
+       NCL_CMD_PRINT("data = 0x%08X\n", data);
+       NCL_CMD_PRINT("err = 0x%08X\n", err);
+       if (*err) {
+               NCL_CMD_PRINT("*err->domain = %d\n", (*err)->domain);
+               NCL_CMD_PRINT("*err->code = %d\n", (*err)->code);
+               NCL_CMD_PRINT("*err->message = '%s'\n", (*err)->message);
+       }
+
+       /* If no parameter, emulate an error */
+       if (arg[0] == 0) {
+               if (err) {
+                       NCL_CMD_PRINTERR(
+                               "missing argument with parameter '%s'\n", opt);
+                       NCL_CMD_PRINTERR("Emulating parsing error\n");
+                       g_set_error(err, G_OPTION_ERROR,
+                                   G_OPTION_ERROR_UNKNOWN_OPTION,
+                               "Missing option (False Error, emulation)");
+
+                       success = FALSE;
+               }
+       }
+
+       return success;
+}
+
+/* Parameters Command line test */
+static NCLError ncl_cmd_test_parameters(int argc, char *argv[])
+{
+       static int              intTmp;
+       static char             *stringTmp;
+       static double           doubleTmp;
+       static long long        int64Tmp;
+       NCLError                err             = NCLERR_NOERROR;
+static GOptionEntry options[] = {
+               { "int" , 'i', 0, G_OPTION_ARG_INT              , &intTmp
+                                 , "Integer parameter", "9999" },
+
+               { "string", 's', 0, G_OPTION_ARG_STRING , &stringTmp
+                               , "String parameter", "STRING" },
+
+               { "double", 'd', 0, G_OPTION_ARG_DOUBLE , &doubleTmp
+                               , "Double parameter", "9.99" },
+
+               { "int64"       , 'l', 0, G_OPTION_ARG_INT64 , &int64Tmp
+                               , "Integer64 parameter", "9999" },
+               { "cb"  , 'c', 0, G_OPTION_ARG_CALLBACK , test_cb
+                               , "Callback test", "9999" },
+               { NULL, 0, 0, 0, NULL, NULL, NULL} /* End of List */
+       };
+
+       /* Parse input parameters... */
+       intTmp          = 0;
+       stringTmp       = NULL;
+       doubleTmp       = 0;
+       int64Tmp        = 0ll;
+       err = ncl_cmd_prv_parseOptions(&argc, &argv, options);
+       if (err != NCLERR_NOERROR)
+               return err;
+
+       /* Check 'int' parameter type... */
+       NCL_CMD_PRINT("Integer parameter = %d\n", intTmp);
+
+       /* Check 'string' parameter type... */
+       if (stringTmp) {
+               NCL_CMD_PRINT("String parameter = %s\n", stringTmp);
+               g_free(stringTmp); stringTmp = NULL;
+       }
+
+       /* Check 'double' parameter type... */
+       NCL_CMD_PRINT("Double parameter = %f\n", doubleTmp);
+
+       /* Check 'int64' parameter type... */
+       NCL_CMD_PRINT("Int64 parameter = %lld\n", int64Tmp);
+
+       NCL_CMD_PRINT("The following type have not been tested :  ");
+       NCL_CMD_PRINT("G_OPTION_ARG_FILENAME, G_OPTION_ARG_STRING_ARRAY");
+       NCL_CMD_PRINT("G_OPTION_ARG_FILENAME_ARRAY.\n");
+       NCL_CMD_PRINT("enjoy...\n");
+
+       return err;
+}
+/******************************************************************************
+ * test parameter type : END
+ *****************************************************************************/
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+/* Exiting from command line interpretor */
+static NCLError ncl_cmd_quit(int argc, char *argv[])
+{
+       NCLError        err             = NCLERR_NOERROR;
+       NCLContext      *nclCtxP        = NULL;
+
+       (void) argc; /* remove warning */
+       (void) argv; /* remove warning */
+       nclCtxP = ncl_get_ctx();
+
+       /* Release NEARDAL object */
+       neardal_destroy(sNclCmdCtx.neardalObj);
+       sNclCmdCtx.neardalObj = NULL;
+
+       /* Quit Main Loop */
+       if (nclCtxP)
+               g_main_loop_quit(nclCtxP->main_loop);
+       else
+               err = NCLERR_GLOBAL_ERROR;
+
+       return err;
+}
+/* END : Interpretor commands */
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+/* Array of command line functions interpretor (alphabetical order) */
+static NCLCmdInterpretor itFunc[] = {
+       { "get_adapters",
+       ncl_cmd_neardal_get_adapters,
+       "Get adapters list"},
+
+       { "get_adapter_properties",
+       ncl_cmd_neardal_get_adapter_properties,
+       "Get adapter properties (1st parameter is adapter name)"},
+
+       { "get_records",
+       ncl_cmd_neardal_get_records,
+       "Get records list (1st parameter is target name)"},
+
+       { "get_record_properties",
+       ncl_cmd_neardal_get_record_properties,
+       "Read a specific record. (1st parameter is record name)"},
+
+       { "get_targets",
+       ncl_cmd_neardal_get_targets,
+       "Get targets list (1st parameter is adapter name)"},
+
+       { "get_target_properties",
+       ncl_cmd_neardal_get_target_properties,
+       "Get target properties (1st parameter is target name)"},
+
+       { LISTCMD_NAME,
+       ncl_cmd_list,
+       "List all available commands. 'cmd' --help -h /? for a specific help" },
+
+       { "publish",
+       ncl_cmd_neardal_publish,
+       "Creates a NDEF record from parametersto be written to an NFC tag"},
+
+       { "quit",
+       ncl_cmd_quit,
+       "Exit from command line interpretor" },
+
+       { "start_poll",
+       ncl_cmd_neardal_start_poll,
+       "Request Neard to start polling (1st parameter is adapter name)"},
+
+       { "stop_poll",
+       ncl_cmd_neardal_stop_poll,
+       "Request Neard to stop polling (1st parameter is adapter name)"},
+
+       { "test_parameters",
+       ncl_cmd_test_parameters,
+       "Simple test to parse input parameters"}
+};
+#define NB_CL_FUNC             (sizeof(itFunc) / sizeof(NCLCmdInterpretor))
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+void ncl_cmd_print(FILE *stream, char *format, ...)
+{
+       gchar   *bufTrace;
+       va_list ap;
+
+       va_start(ap, format);
+
+       bufTrace = g_strdup_vprintf(format, ap);
+       if (bufTrace != NULL) {
+               fprintf(stream, "%s", bufTrace);
+               fflush(stream);
+       }
+       va_end(ap);
+       g_free(bufTrace);
+}
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+NCLCmdInterpretor *ncl_cmd_get_list(int *nbCmd)
+{
+       if (nbCmd != NULL)
+               *nbCmd = NB_CL_FUNC;
+       return itFunc;
+}
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+int ncl_cmd_get_nbCmd(void)
+{
+       return NB_CL_FUNC;
+}
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+NCLCmdContext *ncl_cmd_get_ctx(void)
+{
+       return &sNclCmdCtx;
+}
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+NCLError ncl_cmd_init(char *execCmdLineStr)
+{
+       memset(&sNclCmdCtx, 0, sizeof(sNclCmdCtx));
+
+       if (!execCmdLineStr)
+               sNclCmdCtx.clBuf = g_string_sized_new(CL_BUF_SIZE);
+       else
+               sNclCmdCtx.clBuf = g_string_new(execCmdLineStr);
+
+       if (sNclCmdCtx.clBuf == NULL) {
+               NCL_CMD_PRINTERR("Unable to allocate %d bytes\n", CL_BUF_SIZE);
+               return NCLERR_INIT;
+       }
+
+       return NCLERR_NOERROR;
+}
+
+
+/******************************************************************************
+ *
+ *****************************************************************************/
+void ncl_cmd_finalize(void)
+{
+
+       if (sNclCmdCtx.clBuf != NULL)
+               g_string_free(sNclCmdCtx.clBuf, TRUE);
+
+       /* Release NFC object */
+       if (sNclCmdCtx.neardalObj != NULL)
+               neardal_destroy(sNclCmdCtx.neardalObj);
+
+}
diff --git a/ncl/ncl_cmd.h b/ncl/ncl_cmd.h
new file mode 100644 (file)
index 0000000..4d6e6c9
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ *     NEARDAL Tester command line interpreter
+ *
+ *     Copyright 2012 Intel Corporation. All rights reserved.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU Lesser General Public License version 2
+ *     as published by the Free Software Foundation.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software Foundation,
+ *     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __NCL_CMD_H__
+#define __NCL_CMD_H__
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+#include "neardal.h"
+#include "ncl.h"
+
+/* Command Line Interpretor context... */
+typedef struct {
+       /* NEARDAL Object */
+       neardal_t       neardalObj;
+
+       /* command line interpretor context */
+       GString         *clBuf;         /* Command line buffer */
+
+} NCLCmdContext;
+
+/* Array prototype of command line functions interpretor */
+typedef        NCLError(*ncl_cmd_func)(int argc, char *argv[]);
+typedef struct {
+       char            *cmdName;       /* Command name */
+       ncl_cmd_func    func;           /* Address of processing function */
+       char            *helpStr;       /* Minimal help */
+} NCLCmdInterpretor;
+
+/* Initialize/Destroy command line interpretor context */
+NCLError               ncl_cmd_init(char *execCmdLineStr);
+void                   ncl_cmd_finalize(void);
+
+/* Return command line functions */
+NCLCmdInterpretor      *ncl_cmd_get_list(int *nbCmd);
+int                    ncl_cmd_get_nbCmd(void);
+NCLCmdContext          *ncl_cmd_get_ctx(void);
+
+/* Print out used by command line functions (and prompt) */
+void                   ncl_cmd_print(FILE *fprintout, char *format, ...);
+
+#define                NCL_CMD_PRINT(format, ...) \
+                       ncl_cmd_print(stdout, format, ## __VA_ARGS__)
+
+#define                NCL_CMD_PRINTF(format, ...) \
+                       ncl_cmd_print(stdout, "%s(): " format, __func__, \
+                       ## __VA_ARGS__)
+
+#define                NCL_CMD_PRINTIN() \
+                       ncl_cmd_print(stdout, "%s(): Processing...\n", \
+                       __func__)
+
+#define                NCL_CMD_PRINTERR(format, ...) \
+                       ncl_cmd_print(stderr, "ERR in %s(): " format, \
+                       __func__, ## __VA_ARGS__)
+
+#endif /* __NCL_CMD_H__ */
diff --git a/neardal.pc.in b/neardal.pc.in
new file mode 100644 (file)
index 0000000..39b3d14
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libneardal
+Description: The Neard (Near Field Communication daemon) Abstraction Library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lneardal
+Cflags: -I${includedir}/neardal