--- /dev/null
+Frederic PAUT <frederic.paut@linux.intel.com>
+Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
--- /dev/null
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+\f
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+\f
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+\f
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+\f
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+\f
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
--- /dev/null
+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
+
--- /dev/null
+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.
+
--- /dev/null
+aclocal
+libtoolize --copy
+autoheader
+autoconf
+automake --add-missing --copy --foreign
+
--- /dev/null
+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=no
+
+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 -DNEARDAL_DEBUG"
+ 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([--enable-traces],
+ [add debugging traces while compiling]), [
+ if (test "${enableval}" = "yes"); then
+ traces=yes
+ fi
+])
+if (test "${traces}" = "yes"); then
+ CFLAGS="$CFLAGS -DNEARDAL_TRACES"
+ echo 'NEARDAL will be compiled with debugging traces...('NEARDAL_TRACES' will be defined)'
+else
+ echo 'NEARDAL will be compiled without debugging traces... ('NEARDAL_TRACES' will not be defined)'
+fi
+
+## Check dependances
+GLIB_REQUIRED=2.30.0
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED, dummy=yes,
+ AC_MSG_ERROR(GLib >= $GLIB_REQUIRED is required))
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+PKG_CHECK_MODULES(GIO_UNIX, gio-unix-2.0 >= $GLIB_REQUIRED, dummy=yes,
+ AC_MSG_ERROR(gio-unix >= $GLIB_REQUIRED is required))
+AC_SUBST(GIO_UNIX_CFLAGS)
+AC_SUBST(GIO_UNIX_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
--- /dev/null
+# 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
--- /dev/null
+neardal_LT_CURRENT = 0
+neardal_LT_REVISION = 1
+neardal_LT_AGE = 0
+
+#Rule to generate the binding headers
+neard_adapter_proxy.h: interface/org.neard.Adapter.xml
+ gdbus-codegen --generate-c-code neard_adapter_proxy \
+ --c-namespace orgNeardAdp \
+ --interface-prefix org.neard.Adapter \
+ $<
+
+neard_device_proxy.h: interface/org.neard.Device.xml
+ gdbus-codegen --generate-c-code neard_device_proxy \
+ --c-namespace orgNeardDev \
+ --interface-prefix org.neard.Device \
+ $<
+
+neard_manager_proxy.h: interface/org.neard.Manager.xml
+ gdbus-codegen --generate-c-code neard_manager_proxy \
+ --c-namespace orgNeardMgr \
+ --interface-prefix org.neard.Manager \
+ $<
+
+neard_tag_proxy.h: interface/org.neard.Tag.xml
+ gdbus-codegen --generate-c-code neard_tag_proxy \
+ --c-namespace orgNeardTag \
+ --interface-prefix org.neard.Tag \
+ $<
+
+neard_record_proxy.h: interface/org.neard.Record.xml
+ gdbus-codegen --generate-c-code neard_record_proxy \
+ --c-namespace orgNeardRcd \
+ --interface-prefix org.neard.Record \
+ $<
+
+BUILT_SOURCES = neard_adapter_proxy.h \
+ neard_device_proxy.h \
+ neard_manager_proxy.h \
+ neard_tag_proxy.h \
+ neard_record_proxy.h
+
+neardal_PRV_HDR = \
+ neardal_adapter.h \
+ neardal_device.h \
+ neardal_manager.h \
+ neardal_prv.h \
+ neardal_record.h \
+ neardal_tag.h \
+ neardal_traces_prv.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) \
+ neard_adapter_proxy.c \
+ neard_device_proxy.c \
+ neard_manager_proxy.c \
+ neard_tag_proxy.c \
+ neard_record_proxy.c
+
+EXTRA_DIST = interface/org.neard.Manager.xml interface/org.neard.Adapter.xml \
+ interface/org.neard.Tag.xml interface/org.neard.Device.xml \
+ interface/org.neard.Record.xml
+
+lib_LTLIBRARIES = libneardal.la
+libneardal_la_SOURCES = neardal.c \
+ neardal_adapter.c \
+ neard_adapter_proxy.c \
+ neardal_device.c \
+ neard_device_proxy.c \
+ neardal_manager.c \
+ neard_manager_proxy.c \
+ neardal_record.c \
+ neard_record_proxy.c \
+ neardal_tag.c \
+ neard_tag_proxy.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) $(GIO_UNIX_CFLAGS)
+
+libneardal_la_LIBADD = $(GLIB_LIBS) $(GIO_UNIX_LIBS)
+
+neardalheadersdir = $(includedir)/neardal
+
+
+
--- /dev/null
+<!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 name="properties" type="a{sv}" direction="out"/>
+ </method>
+ <method name="SetProperty">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="in"/>
+ </method>
+ <method name="StartPollLoop">
+ <arg name="name" type="s" direction="in"/>
+ </method>
+ <method name="StopPollLoop"/>
+ <signal name="PropertyChanged">
+ <arg name="name" type="s"/>
+ <arg name="value" type="v"/>
+ </signal>
+ <signal name="TagFound">
+ <arg name="address" type="o"/>
+ </signal>
+ <signal name="TagLost">
+ <arg name="address" type="o"/>
+ </signal>
+ </interface>
+</node>
+
--- /dev/null
+<!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.Device">
+ <method name="GetProperties">
+ <arg name="properties" type="a{sv}" direction="out"/>
+ </method>
+ <method name="SetProperty">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="in"/>
+ </method>
+ <method name="Push">
+ <arg name="attributes" type="a{sv}" direction="in"/>
+ </method>
+ <signal name="PropertyChanged">
+ <arg name="name" type="s"/>
+ <arg name="value" type="v"/>
+ </signal>
+ </interface>
+</node>
--- /dev/null
+<!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 name="properties" type="a{sv}" direction="out"/>
+ </method>
+ <method name="SetProperty">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="in"/>
+ </method>
+ <method name="RegisterHandoverAgent">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ <method name="UnregisterHandoverAgent">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ <method name="RegisterNDEFAgent">
+ <arg name="path" type="o" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ </method>
+ <method name="UnregisterNDEFAgent">
+ <arg name="path" type="o" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ </method>
+ <signal name="PropertyChanged">
+ <arg name="name" type="s"/>
+ <arg name="value" type="v"/>
+ </signal>
+ <signal name="AdapterAdded">
+ <arg name="adapter" type="o"/>
+ </signal>
+ <signal name="AdapterRemoved">
+ <arg name="adapter" type="o"/>
+ </signal>
+ </interface>
+</node>
--- /dev/null
+<!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>
--- /dev/null
+<!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.Tag">
+ <method name="GetProperties">
+ <arg name="properties" type="a{sv}" direction="out"/>
+ </method>
+ <method name="SetProperty">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="in"/>
+ </method>
+ <method name="Write">
+ <arg name="attributes" type="a{sv}" direction="in"/>
+ </method>
+ <method name="GetRawNDEF">
+ <arg name="NDEF" type="ay" direction="out"/>
+ </method>
+ <signal name="PropertyChanged">
+ <arg name="name" type="s"/>
+ <arg name="value" type="v"/>
+ </signal>
+ </interface>
+ <node name="record0"/>
+</node>
--- /dev/null
+/*
+ * 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.
+ *
+ * This file contains all Public APIs
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "neard_manager_proxy.h"
+#include "neard_adapter_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+#define NEARDAL_SET_STRING_VALUE(gValue, value) do { \
+ gValue = g_variant_new_string(value); \
+ } while (0);
+
+#define NEARDAL_SET_BOOL_VALUE(gValue, value) do { \
+ gValue = g_variant_new_boolean((gboolean) value); \
+ } while (0);
+
+#define ADP_MODE_INITIATOR "Initiator"
+#define ADP_MODE_TARGET "Target"
+#define ADP_MODE_DUAL "Dual"
+
+neardalCtx neardalMgr = {.proxy = NULL};
+
+/*---------------------------------------------------------------------------
+ * Context Management
+ ---------------------------------------------------------------------------*/
+/*****************************************************************************
+ * neardal_prv_construct: create NEARDAL object instance, Neard Dbus
+ * connection, register Neard's events
+ ****************************************************************************/
+void neardal_prv_construct(errorCode_t *ec)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+
+ if (neardalMgr.proxy != NULL)
+ return;
+
+ NEARDAL_TRACEIN();
+ memset(&neardalMgr.conn, 0, sizeof(neardalCtx) - sizeof(neardalCb));
+ /* Create DBUS connection */
+ g_type_init();
+ neardalMgr.conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL,
+ &neardalMgr.gerror);
+ if (neardalMgr.conn != NULL) {
+ /* We have a DBUS connection, create proxy on Neard Manager */
+ err = neardal_mgr_create();
+ if (err != NEARDAL_SUCCESS) {
+ NEARDAL_TRACEF(
+ "neardal_mgr_create() 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(&neardalMgr.gerror);
+ } else {
+ NEARDAL_TRACE_ERR("Unable to connect to dbus: %s\n",
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ err = NEARDAL_ERROR_DBUS;
+ }
+
+ if (ec != NULL)
+ *ec = err;
+
+ NEARDAL_TRACEF("Exit\n");
+ return;
+}
+
+
+/*****************************************************************************
+ * neardal_destroy: destroy NEARDAL object instance, Disconnect Neard Dbus
+ * connection, unregister Neard's events
+ ****************************************************************************/
+void neardal_destroy(void)
+{
+ NEARDAL_TRACEIN();
+ if (neardalMgr.proxy != NULL) {
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ neardal_mgr_destroy();
+ }
+}
+
+/*****************************************************************************
+ * 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(adapter_cb cb_adp_added,
+ void *user_data)
+{
+ neardalMgr.cb.adp_added = cb_adp_added;
+ neardalMgr.cb.adp_added_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * 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(adapter_cb cb_adp_removed,
+ void *user_data)
+{
+
+ neardalMgr.cb.adp_removed = cb_adp_removed;
+ neardalMgr.cb.adp_removed_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * 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(
+ adapter_prop_cb cb_adp_property_changed,
+ void *user_data)
+{
+ neardalMgr.cb.adp_prop_changed = cb_adp_property_changed;
+ neardalMgr.cb.adp_prop_changed_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * neardal_set_cb_tag_found: setup a client callback for
+ * 'NEARDAL TAG FOUND'.
+ * cb_tag_found = NULL to remove actual callback.
+ ****************************************************************************/
+errorCode_t neardal_set_cb_tag_found(tag_cb cb_tag_found,
+ void *user_data)
+{
+ neardalMgr.cb.tag_found = cb_tag_found;
+ neardalMgr.cb.tag_found_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * neardal_set_cb_tag_lost: setup a client callback for
+ * 'NEARDAL TAG LOST'.
+ * cb_tag_lost = NULL to remove actual callback.
+ ****************************************************************************/
+errorCode_t neardal_set_cb_tag_lost(tag_cb cb_tag_lost,
+ void *user_data)
+{
+ neardalMgr.cb.tag_lost = cb_tag_lost;
+ neardalMgr.cb.tag_lost_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * neardal_set_cb_dev_found: setup a client callback for
+ * 'NEARDAL DEVICE FOUND'.
+ * cb_dev_found = NULL to remove actual callback.
+ ****************************************************************************/
+errorCode_t neardal_set_cb_dev_found(dev_cb cb_dev_found,
+ void *user_data)
+{
+ neardalMgr.cb.dev_found = cb_dev_found;
+ neardalMgr.cb.dev_found_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * neardal_set_cb_dev_lost: setup a client callback for
+ * 'NEARDAL DEVICE LOST'.
+ * cb_dev_lost = NULL to remove actual callback.
+ ****************************************************************************/
+errorCode_t neardal_set_cb_dev_lost(dev_cb cb_dev_lost,
+ void *user_data)
+{
+ neardalMgr.cb.dev_lost = cb_dev_lost;
+ neardalMgr.cb.dev_lost_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+
+/*****************************************************************************
+ * neardal_set_cb_record_found: setup a client callback for
+ * 'NEARDAL tag record found'.
+ * cb_rcd_found = NULL to remove actual callback.
+ ****************************************************************************/
+errorCode_t neardal_set_cb_record_found(record_cb cb_rcd_found,
+ void *user_data)
+{
+ neardalMgr.cb.rcd_found = cb_rcd_found;
+ neardalMgr.cb.rcd_found_ud = user_data;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(NULL);
+
+ return NEARDAL_SUCCESS;
+}
+
+/*****************************************************************************
+ * neardal_free_array: free adapters array, tags 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;
+
+ if (*array == NULL)
+ return NEARDAL_ERROR_GENERAL_ERROR;
+
+ adps = *array;
+ while ((*adps) != NULL) {
+ g_free(*adps);
+ adps++;
+ }
+ g_free(*array);
+ *array = NULL;
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_error_get_text: return string error form error code
+ ****************************************************************************/
+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_TAG:
+ return "No NFC tag found...";
+
+ case NEARDAL_ERROR_NO_DEV:
+ return "No NFC device found...";
+
+ case NEARDAL_ERROR_NO_RECORD:
+ return "No tag record found...";
+
+ case NEARDAL_ERROR_INVALID_RECORD:
+ return "Tag record has an invalid format...";
+
+ 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 !!!";
+}
+
+
+/*---------------------------------------------------------------------------
+ * NFC Adapter Management
+ ---------------------------------------------------------------------------*/
+/*****************************************************************************
+ * neardal_get_adapters: get an array of NFC adapters (adpName) present
+ ****************************************************************************/
+errorCode_t neardal_get_adapters(char ***array, int *len)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ int adpNb = 0;
+ int ct = 0; /* counter */
+ char **adps = NULL;
+ AdpProp *adapter = NULL;
+ gsize size;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || array == NULL)
+ return NEARDAL_ERROR_INVALID_PARAMETER;
+
+ adpNb = g_list_length(neardalMgr.prop.adpList);
+ if (adpNb > 0) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ size = (adpNb + 1) * sizeof(char *);
+ adps = g_try_malloc0(size);
+ if (adps != NULL) {
+ GList *list;
+ while (ct < adpNb) {
+ list = neardalMgr.prop.adpList;
+ adapter = g_list_nth_data(list, ct);
+ if (adapter != NULL)
+ adps[ct++] = g_strdup(adapter->name);
+ }
+ err = NEARDAL_SUCCESS;
+ }
+ } else
+ err = NEARDAL_ERROR_NO_ADAPTER;
+
+ if (len != NULL)
+ *len = adpNb;
+ *array = adps;
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_free_adapter: Release memory allocated for properties of an adapter
+ ****************************************************************************/
+void neardal_free_adapter(neardal_adapter *adapter)
+{
+ int ct = 0; /* counter */
+
+ if (adapter == NULL) {
+ NEARDAL_TRACE_ERR("Adapter provided is NULL!\n");
+ return;
+ }
+
+ /* Freeing adapter name */
+ g_free(adapter->name);
+
+ /* Freeing adapter mode */
+ g_free(adapter->mode);
+
+ // Freeing protocols list
+ ct = 0;
+ while (ct < adapter->nbProtocols)
+ g_free(adapter->protocols[ct++]);
+ g_free(adapter->protocols);
+
+ /* Freeing tags list */
+ ct = 0;
+ while (ct < adapter->nbTags)
+ g_free(adapter->tags[ct++]);
+ g_free(adapter->tags);
+
+ /* Freeing adapter struct */
+ g_free(adapter);
+}
+
+/*****************************************************************************
+ * neardal_get_adapter_properties: Get properties of a specific NEARDAL adapter
+ ****************************************************************************/
+errorCode_t neardal_get_adapter_properties(const char *adpName,
+ neardal_adapter **adapter)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ TagProp *tag = NULL;
+ neardal_adapter *adpClient = NULL;
+ int ct = 0; /* counter */
+ gsize size;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || adpName == NULL || adapter == NULL)
+ goto exit;
+
+ err = neardal_mgr_prv_get_adapter((gchar *) adpName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ adpClient = g_try_malloc0(sizeof(neardal_adapter));
+ if (adpClient == NULL) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ goto exit;
+ }
+ *adapter = adpClient;
+
+ adpClient->name = g_strdup(adpProp->name);
+ adpClient->mode = g_strdup(adpProp->mode);
+ adpClient->polling = (short) adpProp->polling;
+ adpClient->powered = (short) adpProp->powered;
+
+ adpClient->nbProtocols = adpProp->lenProtocols;
+ adpClient->protocols = NULL;
+
+
+ if (adpClient->nbProtocols > 0) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ size = (adpClient->nbProtocols + 1) * sizeof(char *);
+ adpClient->protocols = g_try_malloc0(size);
+ if (adpClient->protocols != NULL) {
+ ct = 0;
+ while (ct < adpClient->nbProtocols) {
+ gchar *tmp = g_strdup(adpProp->protocols[ct]);
+ adpClient->protocols[ct++] = (char *) tmp;
+ }
+ err = NEARDAL_SUCCESS;
+ }
+ }
+
+ adpClient->nbTags = (int) adpProp->tagNb;
+ adpClient->tags = NULL;
+ if (adpClient->nbTags <= 0)
+ goto exit;
+
+ err = NEARDAL_ERROR_NO_MEMORY;
+ size = (adpClient->nbTags + 1) * sizeof(char *);
+ adpClient->tags = g_try_malloc0(size);
+ if (adpClient->tags == NULL)
+ goto exit;
+
+ ct = 0;
+ while (ct < adpClient->nbTags) {
+ tag = g_list_nth_data(adpProp->tagList, ct);
+ if (tag != NULL)
+ adpClient->tags[ct++] = g_strdup(tag->name);
+ }
+ err = NEARDAL_SUCCESS;
+
+exit:
+ if (err != NEARDAL_SUCCESS) {
+ neardal_free_adapter(adpClient);
+ if (adapter != NULL)
+ *adapter = NULL;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_set_adapter_property: Set a property on a specific NEARDAL adapter
+ ****************************************************************************/
+errorCode_t neardal_set_adapter_property(const char *adpName,
+ int adpPropId, void *value)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ const gchar *propKey = NULL;
+ GVariant *propValue = NULL;
+ GVariant *variantTmp = NULL;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || adpName == NULL)
+ goto exit;
+
+ err = neardal_mgr_prv_get_adapter((gchar *) adpName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ switch (adpPropId) {
+ case NEARD_ADP_PROP_POWERED:
+ propKey = "Powered";
+ NEARDAL_SET_BOOL_VALUE(variantTmp, value);
+ break;
+ default:
+ break;
+ }
+
+ propValue = g_variant_new_variant(variantTmp);
+ NEARDAL_TRACE_LOG("Sending:\n%s=%s\n", propKey,
+ g_variant_print(propValue, TRUE));
+ org_neard_adp__call_set_property_sync(adpProp->proxy, propKey,
+ propValue, NULL,
+ &neardalMgr.gerror);
+
+
+ if (neardalMgr.gerror == NULL)
+ err = NEARDAL_SUCCESS;
+ else {
+ NEARDAL_TRACE_ERR(
+ "DBUS Error (%d): %s\n",
+ neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ err = NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR;
+ }
+
+exit:
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_start_poll: Request Neard to start polling
+ ****************************************************************************/
+errorCode_t neardal_start_poll_loop(char *adpName, int mode)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+ if (err != NEARDAL_SUCCESS)
+ return err;
+
+ err = neardal_mgr_prv_get_adapter(adpName, &adpProp);
+
+ if (adpProp == NULL)
+ goto exit;
+
+ if (adpProp->proxy == NULL)
+ goto exit;
+
+ if (adpProp->polling) {
+ err = NEARDAL_ERROR_POLLING_ALREADY_ACTIVE;
+ goto exit;
+ }
+
+ if (mode == NEARD_ADP_MODE_INITIATOR)
+ org_neard_adp__call_start_poll_loop_sync(adpProp->proxy,
+ ADP_MODE_INITIATOR,
+ NULL,
+ &neardalMgr.gerror);
+ else if (mode == NEARD_ADP_MODE_TARGET)
+ org_neard_adp__call_start_poll_loop_sync(adpProp->proxy,
+ ADP_MODE_TARGET, NULL,
+ &neardalMgr.gerror);
+ else if (mode == NEARD_ADP_MODE_DUAL)
+ org_neard_adp__call_start_poll_loop_sync(adpProp->proxy,
+ ADP_MODE_DUAL, NULL,
+ &neardalMgr.gerror);
+ else
+ org_neard_adp__call_start_poll_loop_sync(adpProp->proxy,
+ ADP_MODE_INITIATOR, NULL,
+ &neardalMgr.gerror);
+
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Error with neard dbus method (err:%d:'%s')\n"
+ , neardalMgr.gerror->code
+ , neardalMgr.gerror->message);
+ err = NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR;
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ }
+
+exit:
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_stop_poll: Request Neard to stop polling
+ ****************************************************************************/
+errorCode_t neardal_stop_poll(char *adpName)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err == NEARDAL_SUCCESS)
+ err = neardal_mgr_prv_get_adapter(adpName, &adpProp);
+
+ if (adpProp == NULL)
+ goto exit;
+
+ if (adpProp->proxy == NULL)
+ goto exit;
+
+ if (adpProp->polling) {
+ org_neard_adp__call_stop_poll_loop_sync(adpProp->proxy, NULL,
+ &neardalMgr.gerror);
+
+ err = NEARDAL_SUCCESS;
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Error with neard dbus method (err:%d:'%s')\n"
+ , neardalMgr.gerror->code
+ , neardalMgr.gerror->message);
+ err = NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR;
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ }
+ }
+
+exit:
+ return err;
+}
+
+
+/*---------------------------------------------------------------------------
+ * NFC Tag Management
+ ---------------------------------------------------------------------------*/
+/*****************************************************************************
+ * neardal_get_tags: get an array of NFC tags present
+ ****************************************************************************/
+errorCode_t neardal_get_tags(char *adpName, char ***array, int *len)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ int tagNb = 0;
+ int ct = 0; /* counter */
+ char **tags = NULL;
+ TagProp *tag = NULL;
+
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+ else
+ err = NEARDAL_ERROR_NO_TAG;
+
+ if (adpName == NULL || array == NULL)
+ return NEARDAL_ERROR_INVALID_PARAMETER;
+
+ err = neardal_mgr_prv_get_adapter(adpName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ return err;
+
+ tagNb = g_list_length(adpProp->tagList);
+ if (tagNb <= 0)
+ return NEARDAL_ERROR_NO_TAG;
+
+ err = NEARDAL_ERROR_NO_MEMORY;
+ tags = g_try_malloc0((tagNb + 1) * sizeof(char *));
+
+ if (tags == NULL)
+ return NEARDAL_ERROR_NO_MEMORY;
+
+ while (ct < tagNb) {
+ tag = g_list_nth_data(adpProp->tagList, ct);
+ if (tag != NULL)
+ tags[ct++] = g_strdup(tag->name);
+ }
+ err = NEARDAL_SUCCESS;
+
+ if (len != NULL)
+ *len = tagNb;
+ *array = tags;
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_free_tag: Release memory allocated for properties of a tag
+ ****************************************************************************/
+void neardal_free_tag(neardal_tag *tag)
+{
+ int ct = 0; /* counter */
+
+ if (tag == NULL) {
+ NEARDAL_TRACE_ERR("Tag provided is NULL!\n");
+ return;
+ }
+
+ /* Freeing tag name/type */
+ g_free((gpointer) tag->name);
+ g_free((gpointer) tag->type);
+
+ /* Freeing records list */
+ ct = 0;
+ while (ct < tag->nbRecords)
+ g_free(tag->records[ct++]);
+ g_free(tag->records);
+
+ /* Freeing tag type list */
+ ct = 0;
+ while (ct < tag->nbTagTypes)
+ g_free(tag->tagType[ct++]);
+ g_free(tag->tagType);
+
+ /* Freeing adapter struct */
+ g_free(tag);
+}
+
+/*****************************************************************************
+ * neardal_get_tag_properties: Get properties of a specific NEARDAL
+ * tag
+ ****************************************************************************/
+errorCode_t neardal_get_tag_properties(const char *tagName,
+ neardal_tag **tag)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ TagProp *tagProp = NULL;
+ neardal_tag *tagClient = NULL;
+ int ct = 0; /* counter */
+ RcdProp *record = NULL;
+ gsize size;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || tagName == NULL || tag == NULL)
+ goto exit;
+
+ tagClient = g_try_malloc0(sizeof(neardal_tag));
+ if (tagClient == NULL) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ goto exit;
+ }
+ *tag = tagClient;
+
+ tagClient->records = NULL;
+ tagClient->tagType = NULL;
+ err = neardal_mgr_prv_get_adapter((gchar *) tagName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_adp_prv_get_tag(adpProp, (gchar *) tagName, &tagProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ tagClient->name = g_strdup(tagProp->name);
+ tagClient->type = g_strdup(tagProp->type);
+ tagClient->readOnly = (short) tagProp->readOnly;
+ tagClient->nbRecords = (int) tagProp->rcdLen;
+ if (tagClient->nbRecords > 0) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ size = (tagClient->nbRecords + 1) * sizeof(char *);
+ tagClient->records = g_try_malloc0(size);
+ if (tagClient->records == NULL)
+ goto exit;
+
+ ct = 0;
+ while (ct < tagClient->nbRecords) {
+ record = g_list_nth_data(tagProp->rcdList, ct);
+ if (record != NULL)
+ tagClient->records[ct] = g_strdup(record->name);
+ ct++;
+ }
+ err = NEARDAL_SUCCESS;
+ }
+
+ tagClient->nbTagTypes = 0;
+ tagClient->tagType = NULL;
+ /* Count TagTypes */
+ tagClient->nbTagTypes = (int) tagProp->tagTypeLen;
+
+ if (tagClient->nbTagTypes <= 0)
+ goto exit;
+
+ err = NEARDAL_ERROR_NO_MEMORY;
+ size = (tagClient->nbTagTypes + 1) * sizeof(char *);
+ tagClient->tagType = g_try_malloc0(size);
+ if (tagClient->tagType == NULL)
+ goto exit;
+
+ ct = 0;
+ while (ct < tagClient->nbTagTypes) {
+ tagClient->tagType[ct] = g_strdup(tagProp->tagType[ct]);
+ ct++;
+ }
+ err = NEARDAL_SUCCESS;
+
+exit:
+ if (err != NEARDAL_SUCCESS) {
+ neardal_free_tag(tagClient);
+ if (tag != NULL)
+ *tag = NULL;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_get_rawNDEF: Get tag's NDEF as a raw bytes stream
+ ****************************************************************************/
+errorCode_t neardal_tag_get_rawNDEF(const char *tagName, char **rawNDEF
+ , int *len)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ TagProp *tagProp = NULL;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || tagName == NULL || rawNDEF == NULL)
+ goto exit;
+
+ err = neardal_mgr_prv_get_adapter((gchar *) tagName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_adp_prv_get_tag(adpProp, (gchar *) tagName, &tagProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_tag_prv_get_raw_NDEF(tagProp, rawNDEF, (gsize *) len);
+
+exit:
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_write: Write NDEF record to an NFC tag
+ ****************************************************************************/
+errorCode_t neardal_tag_write(neardal_record *record)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp;
+ TagProp *tagProp;
+ RcdProp rcd;
+ GVariantBuilder *builder;
+ guint32 count;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || record == NULL)
+ goto exit;
+
+ err = neardal_mgr_prv_get_adapter((gchar *) record->name, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+ err = neardal_adp_prv_get_tag(adpProp, (gchar *) record->name,
+ &tagProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ rcd.name = (gchar *) record->name;
+ rcd.action = (gchar *) record->action;
+ rcd.encoding = (gchar *) record->encoding;
+ rcd.language = (gchar *) record->language;
+ rcd.type = (gchar *) record->type;
+ rcd.representation = (gchar *) record->representation;
+ rcd.uri = (gchar *) record->uri;
+ rcd.uriObjSize = record->uriObjSize;
+ rcd.mime = (gchar *) record->mime;
+
+ if (record->rawNDEF != NULL && record->rawNDEFSize > 0) {
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+
+ for (count = 0; count < record->rawNDEFSize; count++)
+ g_variant_builder_add(builder, "y",
+ record->rawNDEF[count]);
+
+ rcd.rawNDEF = g_variant_new("ay", builder);
+ g_variant_builder_unref(builder);
+ }
+
+ err = neardal_tag_prv_write(tagProp, &rcd);
+
+exit:
+ return err;
+}
+
+/*---------------------------------------------------------------------------
+ * NFC Dev Management
+ ---------------------------------------------------------------------------*/
+/*****************************************************************************
+ * neardal_get_devices: get an array of NFC devs present
+ ****************************************************************************/
+errorCode_t neardal_get_devices(char *adpName, char ***array, int *len)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ int devNb = 0;
+ int ct = 0; /* counter */
+ char **devs = NULL;
+ DevProp *dev = NULL;
+
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+ else
+ err = NEARDAL_ERROR_NO_DEV;
+
+ if (adpName == NULL || array == NULL)
+ return NEARDAL_ERROR_INVALID_PARAMETER;
+
+ err = neardal_mgr_prv_get_adapter(adpName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ return err;
+
+ devNb = g_list_length(adpProp->devList);
+ if (devNb <= 0)
+ return NEARDAL_ERROR_NO_DEV;
+
+ err = NEARDAL_ERROR_NO_MEMORY;
+ devs = g_try_malloc0((devNb + 1) * sizeof(char *));
+
+ if (devs == NULL)
+ return NEARDAL_ERROR_NO_MEMORY;
+
+ while (ct < devNb) {
+ dev = g_list_nth_data(adpProp->devList, ct);
+ if (dev != NULL)
+ devs[ct++] = g_strdup(dev->name);
+ }
+ err = NEARDAL_SUCCESS;
+
+ if (len != NULL)
+ *len = devNb;
+ *array = devs;
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_free_device: Release memory allocated for properties of a dev
+ ****************************************************************************/
+void neardal_free_device(neardal_dev *dev)
+{
+ int ct = 0; /* counter */
+
+ if (dev == NULL) {
+ NEARDAL_TRACE_ERR("Dev provided is NULL!\n");
+ return;
+ }
+
+ /* Freeing dev name/type */
+ g_free((gpointer) dev->name);
+
+ /* Freeing records list */
+ ct = 0;
+ while (ct < dev->nbRecords)
+ g_free(dev->records[ct++]);
+ g_free(dev->records);
+
+ /* Freeing adapter struct */
+ g_free(dev);
+}
+
+/*****************************************************************************
+ * neardal_get_dev_properties: Get properties of a specific NEARDAL
+ * dev
+ ****************************************************************************/
+errorCode_t neardal_get_dev_properties(const char *devName,
+ neardal_dev **dev)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ DevProp *devProp = NULL;
+ neardal_dev *devClient = NULL;
+ int ct = 0; /* counter */
+ RcdProp *record = NULL;
+ gsize size;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || devName == NULL || dev == NULL)
+ goto exit;
+
+ devClient = g_try_malloc0(sizeof(neardal_dev));
+ if (devClient == NULL) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ goto exit;
+ }
+ *dev = devClient;
+
+ devClient->records = NULL;
+ err = neardal_mgr_prv_get_adapter((gchar *) devName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_adp_prv_get_dev(adpProp, (gchar *) devName, &devProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ devClient->name = g_strdup(devProp->name);
+ devClient->nbRecords = (int) devProp->rcdLen;
+ if (devClient->nbRecords > 0) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ size = (devClient->nbRecords + 1) * sizeof(char *);
+ devClient->records = g_try_malloc0(size);
+ if (devClient->records == NULL)
+ goto exit;
+
+ ct = 0;
+ while (ct < devClient->nbRecords) {
+ record = g_list_nth_data(devProp->rcdList, ct);
+ if (record != NULL)
+ devClient->records[ct++] = g_strdup(
+ record->name);
+ }
+ err = NEARDAL_SUCCESS;
+ }
+
+ err = NEARDAL_SUCCESS;
+
+exit:
+ if (err != NEARDAL_SUCCESS) {
+ neardal_free_device(devClient);
+ if (dev != NULL)
+ *dev = NULL;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_dev_push: Push NDEF record to an NFC dev
+ ****************************************************************************/
+errorCode_t neardal_dev_push(neardal_record *record)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp;
+ DevProp *devProp;
+ RcdProp rcd;
+
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || record == NULL)
+ goto exit;
+
+ err = neardal_mgr_prv_get_adapter((gchar *) record->name, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+ err = neardal_adp_prv_get_dev(adpProp, (gchar *) record->name,
+ &devProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ rcd.name = (gchar *) record->name;
+ rcd.action = (gchar *) record->action;
+ rcd.encoding = (gchar *) record->encoding;
+ rcd.language = (gchar *) record->language;
+ rcd.type = (gchar *) record->type;
+ rcd.representation = (gchar *) record->representation;
+ rcd.uri = (gchar *) record->uri;
+ rcd.uriObjSize = record->uriObjSize;
+ rcd.mime = (gchar *) record->mime;
+
+ neardal_dev_prv_push(devProp, &rcd);
+exit:
+ return err;
+}
+
+
+
+/*---------------------------------------------------------------------------
+ * NFC Record Management
+ ---------------------------------------------------------------------------*/
+/******************************************************************************
+ * neardal_get_records: get an array of tag records
+ *****************************************************************************/
+errorCode_t neardal_get_records(char *tagName, char ***array, int *len)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ TagProp *tagProp = NULL;
+ int rcdLen = 0;
+ int ct = 0; /* counter */
+ char **rcds = NULL;
+ RcdProp *rcd = NULL;
+
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS || tagName == NULL || array == NULL)
+ return NEARDAL_ERROR_INVALID_PARAMETER;
+
+ err = neardal_mgr_prv_get_adapter(tagName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_adp_prv_get_tag(adpProp, tagName, &tagProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = NEARDAL_ERROR_NO_RECORD;
+ rcdLen = g_list_length(tagProp->rcdList);
+ if (rcdLen <= 0)
+ goto exit;
+
+ err = NEARDAL_ERROR_NO_MEMORY;
+ rcds = g_try_malloc0((rcdLen + 1) * sizeof(char *));
+ if (rcds == NULL)
+ goto exit;
+
+ while (ct < rcdLen) {
+ rcd = g_list_nth_data(tagProp->rcdList, ct);
+ if (rcd != NULL)
+ rcds[ct++] = g_strdup(rcd->name);
+ }
+ err = NEARDAL_SUCCESS;
+
+exit:
+ if (len != NULL)
+ *len = rcdLen;
+ *array = rcds;
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_free_record: Release memory allocated for properties of a record
+ ****************************************************************************/
+void neardal_free_record(neardal_record *record)
+{
+ if (record == NULL) {
+ NEARDAL_TRACE_ERR("Record provided is NULL!\n");
+ return;
+ }
+
+ /* Freeing record properties */
+ g_free((gpointer) record->name);
+ g_free((gpointer) record->encoding);
+ g_free((gpointer) record->language);
+ g_free((gpointer) record->action);
+ g_free((gpointer) record->type);
+ g_free((gpointer) record->representation);
+ g_free((gpointer) record->uri);
+ g_free((gpointer) record->mime);
+ g_free((gpointer) record->rawNDEF);
+
+ /* Freeing record struct */
+ g_free(record);
+}
+
+/*****************************************************************************
+ * neardal_get_record_properties: Get values of a specific tag record
+ ****************************************************************************/
+errorCode_t neardal_get_record_properties(const char *recordName,
+ neardal_record **record)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ TagProp *tagProp = NULL;
+ RcdProp *rcdProp = NULL;
+ neardal_record *rcdClient = NULL;
+
+ if (recordName == NULL || record == NULL)
+ goto exit;
+
+ if (neardalMgr.proxy == NULL)
+ neardal_prv_construct(&err);
+
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_mgr_prv_get_adapter((gchar *) recordName, &adpProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_adp_prv_get_tag(adpProp, (gchar *) recordName,
+ &tagProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ err = neardal_tag_prv_get_record(tagProp, (gchar *) recordName,
+ &rcdProp);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ rcdClient = g_try_malloc0(sizeof(neardal_record));
+ if (rcdClient == NULL) {
+ err = NEARDAL_ERROR_NO_MEMORY;
+ goto exit;
+ }
+ *record = rcdClient;
+
+ rcdClient->name = g_strdup(rcdProp->name);
+ rcdClient->encoding = g_strdup(rcdProp->encoding);
+ rcdClient->language = g_strdup(rcdProp->language);
+ rcdClient->action = g_strdup(rcdProp->action);
+
+ rcdClient->type = g_strdup(rcdProp->type);
+ rcdClient->representation = g_strdup(rcdProp->representation);
+ rcdClient->uri = g_strdup(rcdProp->uri);
+ rcdClient->uriObjSize = (unsigned int) rcdProp->uriObjSize;
+ rcdClient->mime = g_strdup(rcdProp->mime);
+
+exit:
+ if (err != NEARDAL_SUCCESS) {
+ neardal_free_record(rcdClient);
+ if (record != NULL)
+ *record = NULL;
+ }
+
+ return err;
+}
+
+
--- /dev/null
+/*
+ * 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 */
+
+
+/*!
+ * @addtogroup NEARDAL_COMMON_TYPES Types
+ * @ingroup NEARDAL_COMMON
+ * @{
+ */
+/*!
+ * @brief NEARDAL Adapter client properties
+ * release with (@link neardal_free_adapter @endlink)
+ **/
+typedef struct {
+/*! \brief DBus interface adapter name (as identifier) */
+ char *name;
+/*! \brief Neard adapter NFC radio mode */
+ char *mode;
+/*! \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 */
+ char **protocols;
+/*! \brief Number of tags managed by this adapter */
+ int nbTags;
+/*! \brief Neard adapter tags list */
+ char **tags;
+/*! \brief Number of devices managed by this adapter */
+ int nbDevs;
+/*! \brief Neard adapter devices list */
+ char **devs;
+} neardal_adapter;
+
+/*!
+ * @brief NEARDAL Tag client properties.
+ * release with (@link neardal_free_tag @endlink)
+*/
+typedef struct {
+/*! @brief DBus interface tag name (as identifier) */
+ const char *name;
+
+/*! @brief Number of records in tag */
+ int nbRecords;
+/*! @brief tag records list */
+ char **records;
+/*! @brief Number of supported 'types' in tag */
+ int nbTagTypes;
+/*! @brief types list */
+ char **tagType;
+/*! @brief tag type */
+ const char *type;
+/*! @brief Read-Only flag (is tag writable?) */
+ short readOnly;
+} neardal_tag;
+
+/*!
+ * @brief NEARDAL Device client properties.
+ * release with (@link neardal_free_device @endlink)
+*/
+typedef struct {
+/*! @brief DBus interface tag name (as identifier) */
+ const char *name;
+
+/*! @brief Number of records in device */
+ int nbRecords;
+/*! @brief device records list */
+ char **records;
+} neardal_dev;
+
+/*!
+ * @brief NEARDAL Record client properties.
+ * release with (@link neardal_free_record @endlink)
+*/
+typedef struct {
+/*! @brief DBus interface name (as identifier) */
+ const char *name;
+/*! @brief The character encoding */
+ const char *encoding;
+/*! @brief The ISO/IANA language code (For example "en" or "jp") */
+ const char *language;
+/*! @brief 'Action' Save, Edit, Download... */
+ const char *action;
+/*! @brief The NDEF record type name ("SmartPoster", "Text", "URI",
+ * "HandoverRequest", "HandoverSelect", "HandoverCarrier" */
+ const char *type;
+/*! @brief human readable representation of a text or title record. */
+ const char *representation;
+/*! @brief the complete URI, including the scheme and the resource */
+ const char *uri;
+/*! @brief URI object size */
+ unsigned int uriObjSize;
+/*! @brief The URI object MIME type */
+ const char *mime;
+/*! @brief The NDEF raw data*/
+ unsigned char *rawNDEF;
+/*! @brief The NDEF raw size */
+ unsigned int rawNDEFSize;
+} 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=dbus object path)
+ * @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=dbus object path)
+ * @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 Tag Callbacks (TagFound/Lost)
+*/
+/**
+ * @brief Callback prototype for 'NEARDAL tag found/lost'
+ *
+ * @param tagName DBus interface tag name (as identifier=dbus object path)
+ * @param user_data Client user data
+ **/
+typedef void (*tag_cb) (const char *tagName, void *user_data);
+
+/** @brief NEARDAL Device Callbacks (Device Found/Lost)
+*/
+/**
+ * @brief Callback prototype for 'NEARDAL device found/lost'
+ *
+ * @param devName DBus interface dev name (as identifier=dbus object path)
+ * @param user_data Client user data
+ **/
+typedef void (*dev_cb) (const char *devName, void *user_data);
+
+/** @brief NEARDAL Record Callbacks ('RecordFound')
+*/
+/**
+ * @brief Callback prototype for 'NEARDAL record found'
+ *
+ * @param rcdName DBus interface record name (as identifier=dbus object path)
+ * @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 void neardal_destroy()
+* \brief destroy NEARDAL object instance, disconnect Neard Dbus connection,
+* unregister Neard's events
+*/
+void neardal_destroy();
+
+/*! @brief NEARDAL Properties identifiers
+ * @addtogroup NEARDAL_CALLBACK Defines
+ * @{ */
+#define NEARD_ADP_MODE_INITIATOR 0
+#define NEARD_ADP_MODE_TARGET 1
+#define NEARD_ADP_MODE_DUAL 2
+/* @}*/
+
+
+/*! \fn errorCode_t neardal_start_poll_loop(char *adpName, int mode)
+* \brief Request Neard to start polling on specific NEARDAL adapter with
+* specific mode
+* \param adpName : DBus interface adapter name (as identifier=dbus object
+* path)
+* \param mode : Polling mode (see NEARD_ADP_MODE_...)
+* @return errorCode_t error code
+*/
+errorCode_t neardal_start_poll_loop(char *adpName, int mode);
+
+/*! \fn errorCode_t neardal_start_poll(char *adpName)
+* \brief Request Neard to start polling on specific NEARDAL adapter in
+* Initiator mode
+* \param adpName : DBus interface adapter name (as identifier=dbus object path)
+* @return errorCode_t error code
+*/
+#define neardal_start_poll(adpName) neardal_start_poll_loop(adpName, \
+ NEARD_ADP_MODE_INITIATOR);
+
+/*! \fn errorCode_t neardal_stop_poll(char *adpName)
+* \brief Request Neard to stop polling on specific NEARDAL adapter
+* \param adpName : DBus interface adapter name (as identifier=dbus object path)
+* @return errorCode_t error code
+*/
+errorCode_t neardal_stop_poll(char *adpName);
+
+/*! \fn errorCode_t neardal_get_adapters(char ***array, int *len)
+ * @brief get an array of NEARDAL adapters present
+ *
+ * @param array array of DBus interface adapter name (as identifier=dbus
+ * object path). release with @link neardal_free_adapter @endlink(& )
+ * @param len (optional), number of adapters
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_adapters(char ***array, int *len);
+
+/*! \fn errorCode_t neardal_get_devices(char *adpName, char ***array, int *len)
+ * @brief get an array of NEARDAL devices present
+ *
+ * @param adpName adapter name (identifier) on which devices list must be
+ * retrieve
+ * @param array array of DBus interface device name (as identifier=dbus object
+ * path), release with @link neardal_free_device @endlink(& )
+ * @param len (optional), number of devs
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_devices(char *adpName, char ***array, int *len);
+
+
+/*! \fn errorCode_t neardal_get_tags(char *adpName, char ***array, int *len)
+ * @brief get an array of NEARDAL tags present
+ *
+ * @param adpName adapter name (identifier) on which tags list must be
+ * retrieve
+ * @param array array of DBus interface tag name (as identifier=dbus object
+ * path), release with @link neardal_free_tag @endlink(& )
+ * @param len (optional), number of tags
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_tags(char *adpName, char ***array, int *len);
+
+/*! \fn errorCode_t neardal_get_records(char *tagName, char ***array, int *len)
+ * @brief get an array of NEARDAL records present
+ *
+ * @param tagName tag name (identifier) on which records list must be
+ * retrieve
+ * @param array array of DBus interface record name (as identifier=dbus object
+ * path), release with @link neardal_free_record @endlink(& )
+ * @param len (optional), number of records
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_records(char *tagName, char ***array, int *len);
+
+/*! @brief NEARDAL Properties identifiers
+ * @addtogroup NEARDAL_CALLBACK Defines
+ * @{ */
+#define NEARD_ADP_PROP_POWERED 0
+
+
+/* @}*/
+
+
+/*! \fn errorCode_t neardal_get_adapter_properties(const char* adpName,
+ * neardal_adapter **adapter)
+ * @brief Get properties of a specific NEARDAL adapter
+ *
+ * @param adpName DBus interface adapter name (as identifier=dbus object path)
+ * @param adapter Pointer on pointer of client adapter struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_adapter_properties(const char *adpName,
+ neardal_adapter **adapter);
+
+/*! \fn void neardal_free_adapter(neardal_adapter * adapter)
+ * @brief Release memory allocated for properties of an adapter
+ *
+ * @param adapter Pointer on client adapter struct where datas are stored
+ * @return nothing
+ **/
+void neardal_free_adapter(neardal_adapter *adapter);
+
+/*! \fn errorCode_t neardal_set_adapter_properties(const char* adpName,
+ * int adpPropId, void * value)
+ * @brief Set a property on a specific NEARDAL adapter
+ *
+ * @param adpName DBus interface adapter name (as identifier=dbus object path)
+ * @param adpPropId Adapter Property Identifier (see NEARD_ADP_PROP_ ...)
+ * @param value Value
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_adapter_property(const char *adpName,
+ int adpPropId, void *value);
+
+/*! \fn errorCode_t neardal_set_cb_adapter_added( 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 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(adapter_cb cb_adp_added,
+ void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_adapter_removed(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 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(adapter_cb cb_adp_removed,
+ void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_adapter_property_changed(
+ * 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 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(
+ adapter_prop_cb cb_adp_property_changed,
+ void *user_data);
+
+/*! \fn errorCode_t neardal_get_tag_properties(const char* tagName,
+ * neardal_tag **tag)
+ * @brief Get properties of a specific NEARDAL tag
+ *
+ * @param tagName tag name (identifier) on which properties must be retrieve
+ * @param tag Pointer on pointer of client tag struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_tag_properties(const char *tagName,
+ neardal_tag **tag);
+
+/*! \fn errorCode_t neardal_tag_get_rawNDEF(const char* tagName,
+ * char **rawNDEF, int *len)
+ * @brief Get tag's NDEF as a raw bytes stream.
+ *
+ * @param tagName tag name (identifier) on which NDEF raw bytes must be read
+ * @param rawNDEF Pointer on pointer of client bytes array to store datas
+ * @param len (optional), number of bytes
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_tag_get_rawNDEF(const char *tagName, char **rawNDEF
+ , int *len);
+
+/*! \fn errorCode_t neardal_tag_write(neardal_record *record)
+ * @brief Write NDEF record to an NFC tag
+ *
+ * @param record Pointer on client record used to create NDEF record
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_tag_write(neardal_record *record);
+
+/*! \fn void neardal_free_tag(neardal_tag *tag)
+ * @brief Release memory allocated for properties of a tag
+ *
+ * @param tag Pointer on client tag struct where datas are stored
+ * @return nothing
+ **/
+void neardal_free_tag(neardal_tag *tag);
+
+/*! \fn errorCode_t neardal_set_cb_tag_found(tag_cb cb_tag_found,
+ * void * user_data)
+ * @brief setup a client callback for 'NEARDAL tag found'.
+ * cb_tag_found = NULL to remove actual callback.
+ *
+ * @param cb_tag_found Client callback 'tag found'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_tag_found(tag_cb cb_tag_found,
+ void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_tag_lost(tag_cb cb_tag_lost,
+ * void * user_data)
+ * @brief setup a client callback for 'NEARDAL tag lost'.
+ * cb_tag_lost = NULL to remove actual callback.
+ *
+ * @param cb_tag_lost Client callback 'tag lost'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_tag_lost(tag_cb cb_tag_lost,
+ void *user_data);
+
+/*! \fn errorCode_t neardal_get_dev_properties(const char* devName,
+ * neardal_dev **dev)
+ * @brief Get properties of a specific NEARDAL dev
+ *
+ * @param devName dev name (identifier) on which properties must be retrieve
+ * @param dev Pointer on pointer of client dev struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_dev_properties(const char *devName,
+ neardal_dev **dev);
+
+/*! \fn errorCode_t neardal_dev_push(neardal_record *record)
+ * @brief Create and push NDEF record to an NFC device
+ *
+ * @param record Pointer on client record used to create NDEF record
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_dev_push(neardal_record *record);
+
+/*! \fn void neardal_free_device(neardal_dev *dev)
+ * @brief Release memory allocated for properties of a dev
+ *
+ * @param dev Pointer on client dev struct where datas are stored
+ * @return nothing
+ **/
+void neardal_free_device(neardal_dev *dev);
+
+/*! \fn errorCode_t neardal_set_cb_dev_found(dev_cb cb_dev_found,
+ * void * user_data)
+ * @brief setup a client callback for 'NEARDAL dev found'.
+ * cb_dev_found = NULL to remove actual callback.
+ *
+ * @param cb_dev_found Client callback 'dev found'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_dev_found(dev_cb cb_dev_found,
+ void *user_data);
+
+/*! \fn errorCode_t neardal_set_cb_dev_lost(dev_cb cb_dev_lost,
+ * void * user_data)
+ * @brief setup a client callback for 'NEARDAL dev lost'.
+ * cb_dev_lost = NULL to remove actual callback.
+ *
+ * @param cb_dev_lost Client callback 'dev lost'
+ * @param user_data Client user data
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_set_cb_dev_lost(dev_cb cb_dev_lost,
+ void *user_data);
+
+
+/*! \fn errorCode_t neardal_get_record_properties(const char *recordName,
+ * neardal_record **record)
+ * @brief Get properties of a specific NEARDAL tag record
+ *
+ * @param recordName DBus interface record name (as identifier=dbus object path)
+ * @param record Pointer on pointer of client record struct to store datas
+ * @return errorCode_t error code
+ **/
+errorCode_t neardal_get_record_properties(const char *recordName,
+ neardal_record **record);
+
+/*! \fn void neardal_free_record(neardal_record *record)
+ * @brief Release memory allocated for properties of a record
+ *
+ * @param record Pointer on client tag struct where datas are stored
+ * @return nothing
+ **/
+void neardal_free_record(neardal_record *record);
+
+
+/*! \fn errorCode_t neardal_set_cb_record_found( record_cb cb_rcd_found,
+ * void * user_data)
+ * @brief Setup a client callback for 'NEARDAL tag record found'.
+ * cb_rcd_found = NULL to remove actual callback
+ *
+ * @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(record_cb cb_rcd_found,
+ void *user_data);
+
+/*! @fn errorCode_t neardal_free_array(char ***array)
+ *
+ * @brief free memory used by array of adapters/tags/device or records
+ *
+ * @param array array (of adapters/tags/devices or records)
+ * @return errorCode_t error code
+ *
+ **/
+errorCode_t neardal_free_array(char ***array);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_H */
--- /dev/null
+/*
+ * 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 <glib-object.h>
+
+#include "neard_adapter_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+/*****************************************************************************
+ * neardal_adp_prv_cb_tag_found: Callback called when a NFC tag is
+ * found
+ ****************************************************************************/
+static void neardal_adp_prv_cb_tag_found(orgNeardTag *proxy,
+ const gchar *arg_unnamed_arg0,
+ void *user_data)
+{
+ AdpProp *adpProp = user_data;
+ errorCode_t err;
+ TagProp *tagProp;
+
+ NEARDAL_TRACEIN();
+ (void) proxy; /* remove warning */
+
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+ NEARDAL_ASSERT(adpProp != NULL);
+
+ NEARDAL_TRACEF("Adding tag '%s'\n", arg_unnamed_arg0);
+ /* Invoking Callback 'Tag Found' before adding it (otherwise
+ * callback 'Record Found' would be called before ) */
+ err = neardal_tag_prv_add((char *) arg_unnamed_arg0, adpProp);
+ if (err == NEARDAL_SUCCESS) {
+ tagProp = g_list_nth_data(adpProp->tagList, 0);
+ neardal_tag_notify_tag_found(tagProp);
+ }
+ NEARDAL_TRACEF("NEARDAL LIB tagList contains %d elements\n",
+ g_list_length(adpProp->tagList));
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_cb_tag_lost: Callback called when a NFC tag is
+ * lost (removed)
+ ****************************************************************************/
+static void neardal_adp_prv_cb_tag_lost(orgNeardTag *proxy,
+ const gchar *arg_unnamed_arg0,
+ void *user_data)
+{
+ AdpProp *adpProp = user_data;
+ TagProp *tagProp = NULL;
+ errorCode_t err;
+
+ NEARDAL_TRACEIN();
+ (void) proxy; /* remove warning */
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+
+ neardal_mgr_prv_get_adapter((char *) arg_unnamed_arg0, &adpProp);
+
+ NEARDAL_TRACEF("Removing tag '%s'\n", arg_unnamed_arg0);
+ /* Invoking Callback 'Tag Found' before adding it (otherwise
+ * callback 'Record Found' would be called before ) */
+ err = neardal_adp_prv_get_tag(adpProp, (char *) arg_unnamed_arg0,
+ &tagProp);
+ if (err == NEARDAL_SUCCESS) {
+ if (neardalMgr.cb.tag_lost != NULL)
+ (neardalMgr.cb.tag_lost)((char *) arg_unnamed_arg0,
+ neardalMgr.cb.tag_lost_ud);
+ neardal_tag_prv_remove(tagProp);
+ NEARDAL_TRACEF("NEARDAL LIB tagList contains %d elements\n",
+ g_list_length(adpProp->tagList));
+ }
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_cb_dev_found: Callback called when a NFC dev is
+ * found
+ ****************************************************************************/
+static void neardal_adp_prv_cb_dev_found(orgNeardDev *proxy,
+ const gchar *arg_unnamed_arg0,
+ void *user_data)
+{
+ AdpProp *adpProp = user_data;
+ errorCode_t err;
+ DevProp *devProp;
+
+ NEARDAL_TRACEIN();
+ (void) proxy; /* remove warning */
+
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+ NEARDAL_ASSERT(adpProp != NULL);
+
+ NEARDAL_TRACEF("Adding device '%s'\n", arg_unnamed_arg0);
+ /* Invoking Callback 'Dev Found' before adding it (otherwise
+ * callback 'Record Found' would be called before ) */
+ err = neardal_dev_prv_add((char *) arg_unnamed_arg0, adpProp);
+ if (err == NEARDAL_SUCCESS) {
+ devProp = g_list_nth_data(adpProp->devList, 0);
+ neardal_dev_notify_dev_found(devProp);
+ }
+ NEARDAL_TRACEF("NEARDAL LIB devList contains %d elements\n",
+ g_list_length(adpProp->devList));
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_cb_dev_lost: Callback called when a NFC dev is
+ * lost (removed)
+ ****************************************************************************/
+static void neardal_adp_prv_cb_dev_lost(orgNeardDev *proxy,
+ const gchar *arg_unnamed_arg0,
+ void *user_data)
+{
+ AdpProp *adpProp = user_data;
+ DevProp *devProp = NULL;
+ errorCode_t err;
+
+ NEARDAL_TRACEIN();
+ (void) proxy; /* remove warning */
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+
+ neardal_mgr_prv_get_adapter((char *) arg_unnamed_arg0, &adpProp);
+
+ NEARDAL_TRACEF("Removing dev '%s'\n", arg_unnamed_arg0);
+ /* Invoking Callback 'Dev Found' before adding it (otherwise
+ * callback 'Record Found' would be called before ) */
+ err = neardal_adp_prv_get_dev(adpProp, (char *) arg_unnamed_arg0,
+ &devProp);
+ if (err == NEARDAL_SUCCESS) {
+ if (neardalMgr.cb.dev_lost != NULL)
+ (neardalMgr.cb.dev_lost)((char *) arg_unnamed_arg0,
+ neardalMgr.cb.dev_lost_ud);
+ neardal_dev_prv_remove(devProp);
+ NEARDAL_TRACEF("NEARDAL LIB devList contains %d elements\n",
+ g_list_length(adpProp->devList));
+ }
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_cb_property_changed: Callback called when a NFC tag
+ * is found
+ ****************************************************************************/
+static void neardal_adp_prv_cb_property_changed(orgNeardAdp *proxy,
+ const gchar *arg_unnamed_arg0,
+ GVariant *arg_unnamed_arg1,
+ void *user_data)
+{
+ AdpProp *adpProp = NULL;
+ errorCode_t err = NEARDAL_ERROR_NO_TAG;
+ char *dbusObjPath = NULL;
+ void *clientValue = NULL;
+ TagProp *tagProp = NULL;
+ DevProp *devProp = NULL;
+ gchar **array = NULL;
+ GVariant *gvalue = NULL;
+ gsize mode_len;
+
+ (void) proxy; /* remove warning */
+ (void) user_data; /* remove warning */
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+
+ neardal_mgr_prv_get_adapter_from_proxy(proxy, &adpProp);
+ if (adpProp == NULL) {
+ err = NEARDAL_ERROR_GENERAL_ERROR;
+ goto exit;
+ }
+
+ gvalue = g_variant_get_variant(arg_unnamed_arg1);
+ if (gvalue == NULL) {
+ err = NEARDAL_ERROR_GENERAL_ERROR;
+ goto exit;
+ }
+
+ NEARDAL_TRACEF(" arg_unnamed_arg0 : %s\n", arg_unnamed_arg0);
+
+ if (!strcmp(arg_unnamed_arg0, "Mode")) {
+ if (adpProp->mode != NULL) {
+ g_free(adpProp->mode);
+ adpProp->mode = NULL;
+ }
+
+ adpProp->mode = g_strdup(g_variant_get_string(gvalue, &mode_len));
+ clientValue = adpProp->mode;
+ NEARDAL_TRACEF("neardalMgr.mode=%s\n", adpProp->mode);
+ }
+
+ if (!strcmp(arg_unnamed_arg0, "Polling")) {
+ adpProp->polling = g_variant_get_boolean(gvalue);
+ clientValue = GUINT_TO_POINTER(adpProp->polling);
+ NEARDAL_TRACEF("neardalMgr.polling=%d\n", adpProp->polling);
+ }
+
+ if (!strcmp(arg_unnamed_arg0, "Tags")) {
+ guint tmpLen;
+
+ array = g_variant_dup_objv(gvalue, &tmpLen);
+ adpProp->tagNb = tmpLen;
+ if (adpProp->tagNb <= 0) { /* Remove all tags */
+ GList *node = NULL;
+ NEARDAL_TRACEF(
+ "Tag array empty! Removing all tags\n");
+ while (g_list_length(adpProp->tagList)) {
+ node = g_list_first(adpProp->tagList);
+ tagProp = (TagProp *) node->data;
+ neardal_adp_prv_cb_tag_lost(tagProp->proxy,
+ tagProp->name,
+ tagProp->parent);
+ }
+ g_strfreev(array);
+
+ err = NEARDAL_SUCCESS;
+ goto exit;
+ }
+
+ /* Extract the tags arrays List from the GValue */
+ err = NEARDAL_ERROR_NO_ADAPTER;
+ tmpLen = 0;
+ while (tmpLen < adpProp->tagNb) {
+ /* Getting last tag (tags list not updated with
+ * tags lost */
+ dbusObjPath = g_strdup(array[tmpLen++]);
+
+ /* TODO : for Neard Workaround, emulate 'TagFound'
+ * signals */
+ err = neardal_adp_prv_get_tag(adpProp,
+ dbusObjPath,
+ &tagProp);
+ if (err == NEARDAL_ERROR_NO_TAG) {
+ neardal_adp_prv_cb_tag_found(NULL,
+ dbusObjPath,
+ adpProp);
+ err = NEARDAL_SUCCESS;
+ }
+ }
+ g_strfreev(array);
+ array = NULL;
+ }
+
+ if (!strcmp(arg_unnamed_arg0, "Devices")) {
+ guint tmpLen;
+
+ array = g_variant_dup_objv(gvalue, &tmpLen);
+ adpProp->devNb = tmpLen;
+ if (adpProp->devNb <= 0) { /* Remove all devs */
+ GList *node = NULL;
+ NEARDAL_TRACEF(
+ "Dev array empty! Removing all devs\n");
+ while (g_list_length(adpProp->devList)) {
+ node = g_list_first(adpProp->devList);
+ devProp = (DevProp *) node->data;
+ neardal_adp_prv_cb_dev_lost(devProp->proxy,
+ devProp->name,
+ devProp->parent);
+ }
+ g_strfreev(array);
+
+ err = NEARDAL_SUCCESS;
+ goto exit;
+ }
+
+ /* Extract the devs arrays List from the GValue */
+ err = NEARDAL_ERROR_NO_ADAPTER;
+ tmpLen = 0;
+ while (tmpLen < adpProp->devNb) {
+ /* Getting last dev (devs list not updated with
+ * devs lost */
+ dbusObjPath = g_strdup(array[tmpLen++]);
+
+ /* TODO : for Neard Workaround, emulate 'DevFound'
+ * signals */
+ err = neardal_adp_prv_get_dev(adpProp,
+ dbusObjPath,
+ &devProp);
+ if (err == NEARDAL_ERROR_NO_DEV) {
+ neardal_adp_prv_cb_dev_found(NULL,
+ dbusObjPath,
+ adpProp);
+ err = NEARDAL_SUCCESS;
+ }
+ }
+ g_strfreev(array);
+ array = NULL;
+ }
+
+ if (neardalMgr.cb.adp_prop_changed != NULL)
+ (neardalMgr.cb.adp_prop_changed)(adpProp->name,
+ (char *) arg_unnamed_arg0,
+ clientValue,
+ neardalMgr.cb.adp_prop_changed_ud);
+ return;
+
+exit:
+ if (err != NEARDAL_SUCCESS)
+ NEARDAL_TRACEF("Exit with error code %d:%s\n", err,
+ neardal_error_get_text(err));
+ return;
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_read_properties: Get Neard Adapter Properties
+ ****************************************************************************/
+static errorCode_t neardal_adp_prv_read_properties(AdpProp *adpProp)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ GError *gerror = NULL;
+ GVariant *tmp = NULL;
+ GVariant *tmpOut = NULL;
+ gchar **array = NULL;
+ gsize len = 0;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(adpProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(adpProp->proxy != NULL
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+
+ org_neard_adp__call_get_properties_sync(adpProp->proxy, &tmp,
+ NULL, &gerror);
+ if (gerror != NULL) {
+ err = 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;
+ }
+
+ NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));
+ tmpOut = g_variant_lookup_value(tmp, "Tags", G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ array = g_variant_dup_objv(tmpOut, &len);
+ adpProp->tagNb = len;
+ if (adpProp->tagNb == 0) {
+ g_strfreev(array);
+ array = NULL;
+ } else {
+ len = 0;
+ char *tagName;
+
+ while (len < adpProp->tagNb &&
+ err == NEARDAL_SUCCESS) {
+ tagName = array[len++];
+ err = neardal_tag_prv_add(tagName,
+ adpProp);
+ }
+ g_strfreev(array);
+ array = NULL;
+ }
+ }
+
+ tmpOut = g_variant_lookup_value(tmp, "Devices", G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ array = g_variant_dup_objv(tmpOut, &len);
+ adpProp->devNb = len;
+ if (adpProp->devNb == 0) {
+ g_strfreev(array);
+ array = NULL;
+ } else {
+ len = 0;
+ char *devName;
+
+ while (len < adpProp->devNb &&
+ err == NEARDAL_SUCCESS) {
+ devName = array[len++];
+ err = neardal_dev_prv_add(devName,
+ adpProp);
+ }
+ g_strfreev(array);
+ array = NULL;
+ }
+ }
+
+ tmpOut = g_variant_lookup_value(tmp, "Polling", G_VARIANT_TYPE_BOOLEAN);
+ if (tmpOut != NULL)
+ adpProp->polling = g_variant_get_boolean(tmpOut);
+
+ tmpOut = g_variant_lookup_value(tmp, "Powered", G_VARIANT_TYPE_BOOLEAN);
+ if (tmpOut != NULL)
+ adpProp->powered = g_variant_get_boolean(tmpOut);
+
+ tmpOut = g_variant_lookup_value(tmp, "Mode", G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ adpProp->mode = g_variant_dup_string(tmpOut, &len);
+
+ tmpOut = g_variant_lookup_value(tmp, "Protocols",
+ G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ adpProp->protocols = g_variant_dup_strv(tmpOut, &len);
+ adpProp->lenProtocols = len;
+ if (adpProp->lenProtocols == 0) {
+ g_strfreev(adpProp->protocols);
+ adpProp->protocols = NULL;
+ }
+ }
+
+exit:
+ g_variant_unref(tmp);
+ g_variant_unref(tmpOut);
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_get_tag: Get NFC tag from adapter
+ ****************************************************************************/
+errorCode_t neardal_adp_prv_get_tag(AdpProp *adpProp, gchar *tagName,
+ TagProp **tagProp)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_TAG;
+ guint len = 0;
+ TagProp *tag;
+
+ NEARDAL_ASSERT_RET(adpProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(tagProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ while (len < g_list_length(adpProp->tagList)) {
+ tag = g_list_nth_data(adpProp->tagList, len);
+ if (tag != NULL) {
+ if (!strncmp(tag->name, tagName, strlen(tag->name))) {
+ *tagProp = tag;
+ err = NEARDAL_SUCCESS;
+ break;
+ }
+ }
+ len++;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_get_dev: Get NFC device from adapter
+ ****************************************************************************/
+errorCode_t neardal_adp_prv_get_dev(AdpProp *adpProp, gchar *devName,
+ DevProp **devProp)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_DEV;
+ guint len = 0;
+ DevProp *dev;
+
+ NEARDAL_ASSERT_RET(adpProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(devProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ while (len < g_list_length(adpProp->devList)) {
+ dev = g_list_nth_data(adpProp->devList, len);
+ if (dev != NULL) {
+ if (!strncmp(dev->name, devName, strlen(dev->name))) {
+ *devProp = dev;
+ err = NEARDAL_SUCCESS;
+ break;
+ }
+ }
+ len++;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * 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(AdpProp *adpProp)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(adpProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ if (adpProp->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func(adpProp->proxy,
+ G_CALLBACK(neardal_adp_prv_cb_property_changed),
+ NULL);
+ g_signal_handlers_disconnect_by_func(adpProp->proxy,
+ G_CALLBACK(neardal_adp_prv_cb_tag_found),
+ NULL);
+ g_signal_handlers_disconnect_by_func(adpProp->proxy,
+ G_CALLBACK(neardal_adp_prv_cb_tag_lost),
+ NULL);
+ g_object_unref(adpProp->proxy);
+ }
+ adpProp->proxy = NULL;
+
+ err = NEARDAL_ERROR_NO_ADAPTER;
+ if (adpProp->name == NULL)
+ return err;
+
+ adpProp->proxy = org_neard_adp__proxy_new_sync(neardalMgr.conn,
+ G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
+ NEARD_DBUS_SERVICE,
+ adpProp->name,
+ NULL, /* GCancellable */
+ &neardalMgr.gerror);
+
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Unable to create Neard Adapter Proxy (%d:%s)\n",
+ neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
+ }
+
+ err = neardal_adp_prv_read_properties(adpProp);
+
+ NEARDAL_TRACEF("Register Neard-Adapter Signal ");
+ NEARDAL_TRACE("'PropertyChanged'\n");
+ g_signal_connect(adpProp->proxy, NEARD_ADP_SIG_PROPCHANGED,
+ G_CALLBACK(neardal_adp_prv_cb_property_changed),
+ NULL);
+
+ /* Register 'TagFound', 'TagLost' */
+ NEARDAL_TRACEF("Register Neard-Adapter Signal ");
+ NEARDAL_TRACE("'TagFound'\n");
+ g_signal_connect(adpProp->proxy, NEARD_ADP_SIG_TAG_FOUND,
+ G_CALLBACK(neardal_adp_prv_cb_tag_found),
+ adpProp);
+
+ NEARDAL_TRACEF("Register Neard-Adapter Signal ");
+ NEARDAL_TRACE("'TagLost'\n");
+ g_signal_connect(adpProp->proxy, NEARD_ADP_SIG_TAG_LOST,
+ G_CALLBACK(neardal_adp_prv_cb_tag_lost),
+ adpProp);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_adp_prv_free: unref DBus proxy, disconnect Neard Adapter signals
+ ****************************************************************************/
+static void neardal_adp_prv_free(AdpProp **adpProp)
+{
+ NEARDAL_TRACEIN();
+ if ((*adpProp)->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func((*adpProp)->proxy,
+ G_CALLBACK(neardal_adp_prv_cb_property_changed),
+ NULL);
+ g_signal_handlers_disconnect_by_func((*adpProp)->proxy,
+ G_CALLBACK(neardal_adp_prv_cb_tag_found),
+ NULL);
+ g_signal_handlers_disconnect_by_func((*adpProp)->proxy,
+ G_CALLBACK(neardal_adp_prv_cb_tag_lost),
+ NULL);
+ g_object_unref((*adpProp)->proxy);
+ (*adpProp)->proxy = NULL;
+ }
+ g_free((*adpProp)->name);
+ if ((*adpProp)->mode != NULL)
+ g_free((*adpProp)->mode);
+ if ((*adpProp)->protocols != NULL)
+ g_strfreev((*adpProp)->protocols);
+ g_free((*adpProp));
+ (*adpProp) = NULL;
+}
+
+/*****************************************************************************
+ * neardal_adp_add: add new NFC adapter, initialize DBus Proxy connection,
+ * register adapter signal
+ ****************************************************************************/
+errorCode_t neardal_adp_add(gchar *adapterName)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ AdpProp *adpProp = NULL;
+ GList **adpList;
+ TagProp *tagProp;
+ gsize len;
+
+ /* Check if adapter already exist in list... */
+ err = neardal_mgr_prv_get_adapter(adapterName, NULL);
+ if (err != NEARDAL_SUCCESS) {
+ 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);
+ adpProp->parent = &neardalMgr;
+
+ adpList = &neardalMgr.prop.adpList;
+ *adpList = g_list_prepend(*adpList, (gpointer) adpProp);
+ err = neardal_adp_prv_init(adpProp);
+
+ NEARDAL_TRACEF("NEARDAL LIB adapterList contains %d elements\n",
+ g_list_length(*adpList));
+
+ /* Invoke client cb 'adapter added' */
+ if (neardalMgr.cb.adp_added != NULL)
+ (neardalMgr.cb.adp_added)((char *) adapterName,
+ neardalMgr.cb.adp_added_ud);
+
+ /* Notify 'Tag Found' */
+ len = 0;
+ while (len < g_list_length(adpProp->tagList)) {
+ tagProp = g_list_nth_data(adpProp->tagList, len++);
+ neardal_tag_notify_tag_found(tagProp);
+ len++;
+ }
+ } else
+ NEARDAL_TRACEF("Adapter '%s' already added\n", adapterName);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_adp_remove: remove one NFC adapter, unref DBus Proxy connection,
+ * unregister adapter signal
+ ****************************************************************************/
+errorCode_t neardal_adp_remove(AdpProp *adpProp)
+{
+ TagProp *tagProp;
+ GList *node = NULL;
+ GList **adpList;
+
+ NEARDAL_ASSERT_RET(adpProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ NEARDAL_TRACEF("Removing adapter:%s\n", adpProp->name);
+
+ /* Remove all tags */
+ while (g_list_length(adpProp->tagList)) {
+ node = g_list_first(adpProp->tagList);
+ tagProp = (TagProp *) node->data;
+ neardal_tag_prv_remove(tagProp);
+ }
+
+ adpList = &neardalMgr.prop.adpList;
+ (*adpList) = g_list_remove((*adpList), (gconstpointer) adpProp);
+ neardal_adp_prv_free(&adpProp);
+
+ return NEARDAL_SUCCESS;
+}
--- /dev/null
+/*
+ * 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 "neard_adapter_proxy.h"
+#include "neardal_device.h"
+#include "neardal_tag.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_ADP_SIG_PROPCHANGED "property-changed"
+#define NEARD_ADP_SIG_TAG_FOUND "tag-found"
+#define NEARD_ADP_SIG_TAG_LOST "tag-lost"
+
+/* NEARDAL Adapter Properties */
+typedef struct {
+ orgNeardAdp *proxy; /* The proxy connected to Neard
+ Adapter interface */
+ gchar *name; /* DBus interface name
+ (as id) */
+ gchar *mode; /* NFC radio mode */
+ void *parent;
+ gboolean polling; /* adapter polling active ? */
+ gboolean powered; /* adapter powered ? */
+ gchar **protocols; /* protocols list */
+ gsize lenProtocols;
+ gsize tagNb;
+ GList *tagList; /* Neard adapter tags list
+ available */
+ gsize devNb;
+ GList *devList; /* Neard adapter devices list
+ available */
+} AdpProp;
+
+/*****************************************************************************
+ * neardal_adp_prv_get_tag: Get NEARDAL tag from name
+ ****************************************************************************/
+errorCode_t neardal_adp_prv_get_tag(AdpProp * adpProp, gchar *tagName,
+ TagProp * *tagProp);
+
+/*****************************************************************************
+ * neardal_adp_prv_get_dev: Get NEARDAL dev from name
+ ****************************************************************************/
+errorCode_t neardal_adp_prv_get_dev(AdpProp * adpProp, gchar *devName,
+ DevProp * *devProp);
+
+/*****************************************************************************
+ * neardal_adp_add: add new NEARDAL adapter, initialize DBus Proxy
+ * connection, register adapter signal
+ ****************************************************************************/
+errorCode_t neardal_adp_add(gchar *adapterName);
+
+/*****************************************************************************
+ * neardal_adp_remove: remove NEARDAL adapter, unref DBus Proxy
+ * connection, unregister adapter signal
+ ****************************************************************************/
+errorCode_t neardal_adp_remove(AdpProp *adpProp);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_ADAPTER_H */
--- /dev/null
+/*
+ * 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 <glib-object.h>
+
+#include "neard_device_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+/*****************************************************************************
+ * neardal_dev_prv_cb_property_changed: Callback called when a NFC device
+ * property is changed
+ ****************************************************************************/
+static void neardal_dev_prv_cb_property_changed(orgNeardDev *proxy,
+ const gchar *arg_unnamed_arg0,
+ GVariant *arg_unnamed_arg1,
+ void *user_data)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ DevProp *devProp = user_data;
+
+ (void) proxy; /* remove warning */
+ (void) arg_unnamed_arg1; /* remove warning */
+
+ NEARDAL_TRACEIN();
+
+ if (devProp == NULL || arg_unnamed_arg0 == NULL)
+ return;
+
+ NEARDAL_TRACEF("str0='%s'\n", arg_unnamed_arg0);
+ NEARDAL_TRACEF("arg_unnamed_arg1=%s (%s)\n",
+ g_variant_print (arg_unnamed_arg1, TRUE),
+ g_variant_get_type_string(arg_unnamed_arg1));
+
+
+ if (err != NEARDAL_SUCCESS) {
+ NEARDAL_TRACE_ERR("Exit with error code %d:%s\n", err,
+ neardal_error_get_text(err));
+ }
+
+ return;
+}
+
+/*****************************************************************************
+ * neardal_dev_prv_read_properties: Get Neard Dev Properties
+ ****************************************************************************/
+static errorCode_t neardal_dev_prv_read_properties(DevProp *devProp)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ GError *gerror = NULL;
+ GVariant *tmp = NULL;
+ GVariant *tmpOut = NULL;
+ gsize len;
+ gchar **rcdArray = NULL;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(devProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(devProp->proxy != NULL
+ , NEARDAL_ERROR_GENERAL_ERROR);
+
+ org_neard_dev__call_get_properties_sync(devProp->proxy, &tmp, NULL,
+ &gerror);
+ if (gerror != NULL) {
+ err = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+ NEARDAL_TRACE_ERR(
+ "Unable to read dev's properties (%d:%s)\n",
+ gerror->code, gerror->message);
+ g_error_free(gerror);
+ goto exit;
+ }
+ NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));
+ tmpOut = g_variant_lookup_value(tmp, "Records", G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ rcdArray = g_variant_dup_objv(tmpOut, &len);
+ devProp->rcdLen = len;
+ if (len == 0) {
+ g_strfreev(rcdArray);
+ rcdArray = NULL;
+ } else {
+ guint len = 0;
+ char *rcdName;
+
+ while (len < devProp->rcdLen &&
+ err == NEARDAL_SUCCESS) {
+ rcdName = rcdArray[len++];
+ err = neardal_rcd_add(rcdName, devProp);
+ }
+ }
+ }
+
+exit:
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_dev_init: Get Neard Manager Properties = NFC Devs list.
+ * Create a DBus proxy for the first one NFC device if present
+ * Register Neard Manager signals ('PropertyChanged')
+ ****************************************************************************/
+static errorCode_t neardal_dev_prv_init(DevProp *devProp)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(devProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ if (devProp->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func(devProp->proxy,
+ G_CALLBACK(neardal_dev_prv_cb_property_changed),
+ NULL);
+ g_object_unref(devProp->proxy);
+ devProp->proxy = NULL;
+ }
+ devProp->proxy = NULL;
+
+ devProp->proxy = org_neard_dev__proxy_new_sync(neardalMgr.conn,
+ G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
+ NEARD_DBUS_SERVICE,
+ devProp->name,
+ NULL, /* GCancellable */
+ &neardalMgr.gerror);
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Unable to create Neard Dev Proxy (%d:%s)\n",
+ neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
+ }
+
+ /* Populate Dev datas... */
+ err = neardal_dev_prv_read_properties(devProp);
+ if (err != NEARDAL_SUCCESS)
+ return err;
+
+ NEARDAL_TRACEF("Register Neard-Dev Signal 'PropertyChanged'\n");
+ g_signal_connect(devProp->proxy, NEARD_DEV_SIG_PROPCHANGED,
+ G_CALLBACK(neardal_dev_prv_cb_property_changed),
+ devProp);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_dev_prv_free: unref DBus proxy, disconnect Neard Dev signals
+ ****************************************************************************/
+static void neardal_dev_prv_free(DevProp **devProp)
+{
+ NEARDAL_TRACEIN();
+ if ((*devProp)->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func((*devProp)->proxy,
+ G_CALLBACK(neardal_dev_prv_cb_property_changed),
+ NULL);
+ g_object_unref((*devProp)->proxy);
+ (*devProp)->proxy = NULL;
+ }
+ g_free((*devProp)->name);
+ g_free((*devProp));
+ (*devProp) = NULL;
+}
+
+/*****************************************************************************
+ * neardal_dev_notify_dev_found: Invoke client callback for 'record found'
+ * if present, and 'dev found' (if not already nofied)
+ ****************************************************************************/
+void neardal_dev_notify_dev_found(DevProp *devProp)
+{
+ RcdProp *rcdProp;
+ gsize len;
+
+ NEARDAL_ASSERT(devProp != NULL);
+
+ if (devProp->notified == FALSE && neardalMgr.cb.dev_found != NULL) {
+ (neardalMgr.cb.dev_found)(devProp->name,
+ neardalMgr.cb.dev_found_ud);
+ devProp->notified = TRUE;
+ }
+
+ len = 0;
+ if (neardalMgr.cb.rcd_found != NULL)
+ while (len < g_list_length(devProp->rcdList)) {
+ rcdProp = g_list_nth_data(devProp->rcdList, len++);
+ if (rcdProp->notified == FALSE) {
+ (neardalMgr.cb.rcd_found)(rcdProp->name,
+ neardalMgr.cb.rcd_found_ud);
+ rcdProp->notified = TRUE;
+ }
+ }
+}
+
+/*****************************************************************************
+ * neardal_dev_prv_push: Creates and write NDEF record to be pushed to
+ * an NFC device
+ ****************************************************************************/
+errorCode_t neardal_dev_prv_push(DevProp *devProp, RcdProp *rcd)
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *in;
+ errorCode_t err;
+ GError *gerror = NULL;
+
+ NEARDAL_ASSERT_RET(devProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+ if (builder == NULL)
+ return NEARDAL_ERROR_NO_MEMORY;
+
+ g_variant_builder_init(builder, G_VARIANT_TYPE_ARRAY);
+ err = neardal_rcd_prv_format(builder, rcd);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ in = g_variant_builder_end(builder);
+ NEARDAL_TRACE_LOG("Sending:\n%s\n", g_variant_print(in, TRUE));
+ org_neard_dev__call_push_sync(devProp->proxy, in, NULL, &gerror);
+
+exit:
+ if (gerror != NULL) {
+ NEARDAL_TRACE_ERR("Unable to write dev record (%d:%s)\n",
+ gerror->code, gerror->message);
+ g_error_free(gerror);
+ err = NEARDAL_ERROR_DBUS;
+ }
+ if (builder != NULL)
+ g_variant_builder_unref(builder);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_dev_prv_add: add new NFC device, initialize DBus Proxy connection,
+ * register dev signal
+ ****************************************************************************/
+errorCode_t neardal_dev_prv_add(gchar *devName, void *parent)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_MEMORY;
+ DevProp *devProp = NULL;
+ AdpProp *adpProp = parent;
+
+ NEARDAL_ASSERT_RET( ((adpProp != NULL) && (devName != NULL))
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+
+ NEARDAL_TRACEF("Adding dev:%s\n", devName);
+ devProp = g_try_malloc0(sizeof(DevProp));
+ if (devProp == NULL)
+ goto error;
+
+ devProp->name = g_strdup(devName);
+ devProp->parent = adpProp;
+
+ adpProp->devList = g_list_prepend(adpProp->devList, devProp);
+ err = neardal_dev_prv_init(devProp);
+
+ NEARDAL_TRACEF("NEARDAL LIB devList contains %d elements\n",
+ g_list_length(adpProp->devList));
+
+ return err;
+
+error:
+ if (devProp->name != NULL)
+ g_free(devProp->name);
+ if (devProp != NULL)
+ g_free(devProp);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_dev_prv_remove: remove one NFC device, unref DBus Proxy connection,
+ * unregister dev signal
+ ****************************************************************************/
+void neardal_dev_prv_remove(DevProp *devProp)
+{
+ RcdProp *rcdProp = NULL;
+ GList *node;
+ AdpProp *adpProp;
+
+ NEARDAL_ASSERT(devProp != NULL);
+
+ NEARDAL_TRACEF("Removing dev:%s\n", devProp->name);
+ /* Remove all devs */
+ while (g_list_length(devProp->rcdList)) {
+ node = g_list_first(devProp->rcdList);
+ rcdProp = (RcdProp *) node->data;
+ neardal_rcd_remove(rcdProp);
+ }
+ adpProp = devProp->parent;
+ adpProp->devList = g_list_remove(adpProp->devList,
+ (gconstpointer) devProp);
+
+ neardal_dev_prv_free(&devProp);
+}
--- /dev/null
+/*
+ * 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_DEV_H
+#define __NEARDAL_DEV_H
+
+#include "neard_device_proxy.h"
+#include "neardal_record.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_DEV_SIG_PROPCHANGED "property-changed"
+
+/* NEARDAL Dev Properties */
+typedef struct {
+ orgNeardDev *proxy; /* proxy to Neard NEARDAL Dev interface */
+ gchar *name; /* DBus interface name (as identifier) */
+ void *parent; /* parent (adapter ) */
+ gboolean notified; /* Already notified to client? */
+
+ gsize rcdLen;
+ GList *rcdList; /* dev's records paths */
+} DevProp;
+
+/*****************************************************************************
+ * neardal_dev_notify_dev_found: Invoke client callback for 'record found'
+ * if present, and 'dev found' (if not already nofied)
+ ****************************************************************************/
+void neardal_dev_notify_dev_found(DevProp *devProp);
+
+/******************************************************************************
+ * neardal_dev_prv_add: add new NEARDAL dev, initialize DBus Proxy connection,
+ * register dev signal
+ *****************************************************************************/
+errorCode_t neardal_dev_prv_add(gchar *devName, void *parent);
+
+/******************************************************************************
+ * neardal_dev_remove: remove NEARDAL dev, unref DBus Proxy connection,
+ * unregister dev signal
+ *****************************************************************************/
+void neardal_dev_prv_remove(DevProp *devProp);
+
+/******************************************************************************
+ * neardal_dev_prv_push: Creates and write NDEF record to be written to
+ * an NFC dev
+ *****************************************************************************/
+errorCode_t neardal_dev_prv_push(DevProp *devProp, RcdProp *rcd);
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_DEV_H */
--- /dev/null
+/*
+ * 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 tag present */
+#define NEARDAL_ERROR_NO_TAG ((errorCode_t) -9)
+/*! @brief Neard service, no NEARDAL record present */
+#define NEARDAL_ERROR_NO_RECORD ((errorCode_t) -10)
+/*! @brief Invalid record format */
+#define NEARDAL_ERROR_INVALID_RECORD ((errorCode_t) -11)
+/*! @brief Neard service, no NEARDAL device present */
+#define NEARDAL_ERROR_NO_DEV ((errorCode_t) -12)
+
+/*! @brief Neard service, Error while invoking error */
+#define NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR ((errorCode_t) -13)
+
+/* @}*/
+
+
+/*!
+ * @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 */
--- /dev/null
+/*
+ * 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 <glib-object.h>
+
+#include "neard_manager_proxy.h"
+#include "neard_adapter_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+/*****************************************************************************
+ * neardal_mgr_prv_cb_property_changed: Callback called when a NFC Manager
+ * Property is changed
+ ****************************************************************************/
+static void neardal_mgr_prv_cb_property_changed(orgNeardMgr *proxy,
+ const gchar *arg_unnamed_arg0,
+ GVariant *arg_unnamed_arg1,
+ void *user_data)
+{
+ NEARDAL_TRACEIN();
+
+ (void) proxy; /* remove warning */
+ (void) arg_unnamed_arg1; /* remove warning */
+ (void) user_data; /* remove warning */
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+
+ NEARDAL_TRACEF("arg_unnamed_arg0='%s'\n", arg_unnamed_arg0);
+ /* 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(orgNeardMgr *proxy,
+ const gchar *arg_unnamed_arg0,
+ void *user_data)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+
+ NEARDAL_TRACEIN();
+ (void) proxy; /* remove warning */
+ (void) user_data; /* remove warning */
+
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+
+ err = neardal_adp_add((char *) arg_unnamed_arg0);
+ if (err != NEARDAL_SUCCESS)
+ return;
+
+ NEARDAL_TRACEF("NEARDAL LIB adapterList contains %d elements\n",
+ g_list_length(neardalMgr.prop.adpList));
+}
+
+/*****************************************************************************
+ * neardal_mgr_prv_cb_adapter_removed: Callback called when a NFC adapter
+ * is removed
+ ****************************************************************************/
+static void neardal_mgr_prv_cb_adapter_removed(orgNeardMgr *proxy,
+ const gchar *arg_unnamed_arg0,
+ void *user_data)
+{
+ GList *node = NULL;
+
+ NEARDAL_TRACEIN();
+ (void) proxy; /* remove warning */
+ (void) user_data; /* remove warning */
+
+ NEARDAL_ASSERT(arg_unnamed_arg0 != NULL);
+
+ node = g_list_first(neardalMgr.prop.adpList);
+ if (node == NULL) {
+ NEARDAL_TRACE_ERR("NFC adapter not found! (%s)\n",
+ arg_unnamed_arg0);
+ return;
+ }
+
+ /* Invoke client cb 'adapter removed' */
+ if (neardalMgr.cb.adp_removed != NULL)
+ (neardalMgr.cb.adp_removed)((char *) arg_unnamed_arg0,
+ neardalMgr.cb.adp_removed_ud);
+
+ neardal_adp_remove(((AdpProp *)node->data));
+
+ NEARDAL_TRACEF("NEARDAL LIB adapterList contains %d elements\n",
+ g_list_length(neardalMgr.prop.adpList));
+}
+
+/*****************************************************************************
+ * neardal_mgr_prv_get_all_adapters: Check if neard has an adapter
+ ****************************************************************************/
+static errorCode_t neardal_mgr_prv_get_all_adapters(gchar ***adpArray,
+ gsize *len)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_ADAPTER;
+ GVariant *tmp = NULL;
+ GVariant *tmpOut = NULL;
+
+ NEARDAL_ASSERT_RET(adpArray != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ /* Invoking method 'GetProperties' on Neard Manager */
+ if (org_neard_mgr__call_get_properties_sync(neardalMgr.proxy, &tmp,
+ NULL,
+ &neardalMgr.gerror)) {
+ NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));
+ NEARDAL_TRACEF("Parsing neard adapters...\n");
+
+ tmpOut = g_variant_lookup_value(tmp, NEARD_MGR_SECTION_ADAPTERS,
+ G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ *adpArray = g_variant_dup_objv(tmpOut, len);
+ err = NEARDAL_SUCCESS;
+ } else
+ err = NEARDAL_ERROR_NO_ADAPTER;
+ } else {
+ err = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+ NEARDAL_TRACE_ERR("%d:%s\n", neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ }
+
+ return err;
+}
+
+
+/*****************************************************************************
+ * neardal_mgr_prv_get_adapter: Get NFC Adapter from name
+ ****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter(gchar *adpName, AdpProp **adpProp)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_ADAPTER;
+ guint len = 0;
+ AdpProp *adapter;
+ GList *tmpList;
+
+ tmpList = neardalMgr.prop.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)) {
+ if (adpProp != NULL)
+ *adpProp = adapter;
+ err = NEARDAL_SUCCESS;
+ break;
+ }
+ }
+ len++;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_mgr_prv_get_adapter_from_proxy: Get NFC Adapter from proxy
+ ****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter_from_proxy(orgNeardAdp *adpProxy,
+ AdpProp **adpProp)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_ADAPTER;
+ guint len = 0;
+ AdpProp *adapter;
+ GList *tmpList;
+
+ NEARDAL_ASSERT_RET(adpProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ tmpList = neardalMgr.prop.adpList;
+ while (len < g_list_length(tmpList)) {
+ adapter = g_list_nth_data(tmpList, len);
+ if (adapter != NULL) {
+ if (adapter->proxy == adpProxy) {
+ *adpProp = adapter;
+ err = NEARDAL_SUCCESS;
+ break;
+ }
+ }
+ len++;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_mgr_create: 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_create(void)
+{
+ errorCode_t err;
+ gchar **adpArray = NULL;
+ gsize adpArrayLen;
+ char *adpName;
+ guint len;
+
+ NEARDAL_TRACEIN();
+ if (neardalMgr.proxy != NULL) {
+ g_signal_handlers_disconnect_by_func(neardalMgr.proxy,
+ G_CALLBACK(neardal_mgr_prv_cb_property_changed),
+ NULL);
+ g_signal_handlers_disconnect_by_func(neardalMgr.proxy,
+ G_CALLBACK(neardal_mgr_prv_cb_adapter_added),
+ NULL);
+ g_signal_handlers_disconnect_by_func(neardalMgr.proxy,
+ G_CALLBACK(neardal_mgr_prv_cb_adapter_removed),
+ NULL);
+ g_object_unref(neardalMgr.proxy);
+ neardalMgr.proxy = NULL;
+ }
+
+ neardalMgr.proxy = org_neard_mgr__proxy_new_sync(neardalMgr.conn,
+ G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
+ NEARD_DBUS_SERVICE,
+ NEARD_MGR_PATH,
+ NULL, /* GCancellable */
+ &neardalMgr.gerror);
+
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Unable to create Neard Manager Proxy (%d:%s)\n",
+ neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
+ }
+
+ /* Get and store NFC adapters (is present) */
+ err = neardal_mgr_prv_get_all_adapters(&adpArray, &adpArrayLen);
+ if (adpArray != NULL && adpArrayLen > 0) {
+ len = 0;
+ while (len < adpArrayLen && err == NEARDAL_SUCCESS) {
+ adpName = adpArray[len++];
+ err = neardal_adp_add(adpName);
+ }
+ g_strfreev(adpArray);
+ }
+
+ /* Register for manager signals 'PropertyChanged(String,Variant)' */
+ NEARDAL_TRACEF("Register Neard-Manager Signal 'PropertyChanged'\n");
+ g_signal_connect(neardalMgr.proxy,
+ NEARD_MGR_SIG_PROPCHANGED,
+ G_CALLBACK(neardal_mgr_prv_cb_property_changed),
+ NULL);
+
+ /* Register for manager signals 'AdapterAdded(ObjectPath)' */
+ NEARDAL_TRACEF("Register Neard-Manager Signal 'AdapterAdded'\n");
+ g_signal_connect(neardalMgr.proxy,
+ NEARD_MGR_SIG_ADP_ADDED,
+ G_CALLBACK(neardal_mgr_prv_cb_adapter_added),
+ NULL);
+
+ /* Register for manager signals 'AdapterRemoved(ObjectPath)' */
+ NEARDAL_TRACEF("Register Neard-Manager Signal 'AdapterRemoved'\n");
+ g_signal_connect(neardalMgr.proxy,
+ NEARD_MGR_SIG_ADP_RM,
+ G_CALLBACK(neardal_mgr_prv_cb_adapter_removed),
+ NULL);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_mgr_destroy: unref DBus proxy, disconnect Neard Manager signals
+ ****************************************************************************/
+void neardal_mgr_destroy(void)
+{
+ GList *node;
+ GList **tmpList;
+
+ NEARDAL_TRACEIN();
+ /* Remove all adapters */
+ tmpList = &neardalMgr.prop.adpList;
+ while (g_list_length((*tmpList))) {
+ node = g_list_first((*tmpList));
+ neardal_adp_remove(((AdpProp *)node->data));
+ }
+ neardalMgr.prop.adpList = (*tmpList);
+
+ if (neardalMgr.proxy == NULL)
+ return;
+
+ g_signal_handlers_disconnect_by_func(neardalMgr.proxy,
+ G_CALLBACK(neardal_mgr_prv_cb_property_changed),
+ NULL);
+ g_signal_handlers_disconnect_by_func(neardalMgr.proxy,
+ G_CALLBACK(neardal_mgr_prv_cb_adapter_added),
+ NULL);
+ g_signal_handlers_disconnect_by_func(neardalMgr.proxy,
+ G_CALLBACK(neardal_mgr_prv_cb_adapter_removed),
+ NULL);
+ g_object_unref(neardalMgr.proxy);
+ neardalMgr.proxy = NULL;
+}
--- /dev/null
+/*
+ * 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_PATH "/"
+#define NEARD_MGR_SECTION_ADAPTERS "Adapters"
+#define NEARD_MGR_SIG_PROPCHANGED "property-changed"
+#define NEARD_MGR_SIG_ADP_ADDED "adapter-added"
+#define NEARD_MGR_SIG_ADP_RM "adapter-removed"
+
+/* NEARDAL Manager Properties */
+typedef struct {
+ GList *adpList; /* List of available adapter (AdpProp*) */
+} MgrProp;
+
+/*****************************************************************************
+ * neardal_mgr_prv_get_adapter: Get NEARDAL Adapter from name
+ ****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter(gchar *adpName, AdpProp **adpProp);
+
+/*****************************************************************************
+ * neardal_mgr_prv_get_adapter_from_proxy: Get NEARDAL Adapter from proxy
+ *****************************************************************************/
+errorCode_t neardal_mgr_prv_get_adapter_from_proxy(orgNeardAdp *adpProxy,
+ AdpProp **adpProp);
+
+/*****************************************************************************
+ * neardal_tag_prv_get_record: Get specific record from tag
+ *****************************************************************************/
+errorCode_t neardal_tag_prv_get_record(TagProp *tagProp, gchar *rcdName,
+ RcdProp **rcdProp);
+
+/*****************************************************************************
+ * neardal_mgr_create: 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_create(void);
+
+/*****************************************************************************
+ * neardal_mgr_destroy: unref DBus proxy, disconnect Neard Manager signals
+ ****************************************************************************/
+void neardal_mgr_destroy(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_MANAGER_H */
--- /dev/null
+/*
+ * 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 "neard_manager_proxy.h"
+#include "neardal_manager.h"
+#include "neardal_record.h"
+#include "neardal_tools.h"
+#include "neardal_traces_prv.h"
+#include "neardal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* NEARDAL Callbacks */
+typedef struct {
+ adapter_cb adp_added; /* Client callback for
+ 'adapter added' */
+ void *adp_added_ud; /* User data for
+ client callback
+ 'adapter added'*/
+ adapter_cb adp_removed; /* Client callback for
+ 'adapter removed' */
+ void *adp_removed_ud; /* User data for
+ client callback
+ 'adapter removed'*/
+ adapter_prop_cb adp_prop_changed; /* Client callback for
+ 'adapter property changed' */
+ void *adp_prop_changed_ud; /* User data for
+ client callback
+ 'adapter property changed' */
+
+ tag_cb tag_found; /* Client callback for
+ 'tag found' */
+ void *tag_found_ud; /* User data for
+ client callback
+ 'tag found' */
+ tag_cb tag_lost; /* Client callback for
+ 'tag lost' */
+ void *tag_lost_ud; /* User data for
+ client callback
+ 'tag lost' */
+
+ dev_cb dev_found; /* Client callback for
+ 'device found' */
+ void *dev_found_ud; /* User data for
+ client callback
+ 'device found' */
+ dev_cb dev_lost; /* Client callback for
+ 'device lost' */
+ void *dev_lost_ud; /* User data for
+ client callback
+ 'device lost' */
+
+ record_cb rcd_found; /* Client callback for
+ ' 'tag record found'*/
+ void *rcd_found_ud; /* User data for
+ client callback
+ 'tag record found'*/
+} neardalCb;
+
+/* NEARDAL context */
+typedef struct {
+ neardalCb cb; /* Neardal Callbacks */
+ GDBusConnection *conn; /* DBus connection */
+ orgNeardMgr *proxy; /* Neard Mgr dbus proxy */
+ MgrProp prop; /* Mgr Properties
+ (adapter list) */
+ guint OwnerId; /* dbus Id server side */
+ /* (for neard agent Mgnt) */
+ GDBusObjectManagerServer *agentMgr; /* Object 'agent' Manager */
+
+ errorCode_t ec; /* Lastest NEARDAL error */
+ GError *gerror; /* Lastest GError if available */
+} neardalCtx;
+
+extern neardalCtx neardalMgr;
+
+/*! \fn neardal_t neardal_prv_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
+*/
+void neardal_prv_construct(errorCode_t *ec);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_PRV_H */
--- /dev/null
+/*
+ * 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 <glib-object.h>
+
+#include "neard_record_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+/*****************************************************************************
+ * neardal_rcd_prv_read_properties: Get Neard Record Properties
+ ****************************************************************************/
+static errorCode_t neardal_rcd_prv_read_properties(RcdProp *rcd)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ GError *gerror = NULL;
+ GVariant *tmp = NULL;
+ GVariant *tmpOut = NULL;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(rcd != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(rcd->proxy != NULL
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+
+ org_neard_rcd__call_get_properties_sync(rcd->proxy, &tmp, NULL,
+ &gerror);
+ if (gerror != NULL) {
+ err = NEARDAL_ERROR_DBUS;
+ NEARDAL_TRACE_ERR(
+ "Unable to read record's properties (%d:%s)\n",
+ gerror->code, gerror->message);
+ g_error_free(gerror);
+ return err;
+ }
+ NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));
+
+ tmpOut = g_variant_lookup_value(tmp, "Type", G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ rcd->type = g_variant_dup_string(tmpOut, NULL);
+ else
+ goto error;
+
+ tmpOut = g_variant_lookup_value(tmp, "Representation",
+ G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ rcd->representation = g_variant_dup_string(tmpOut,
+ NULL);
+
+ tmpOut = g_variant_lookup_value(tmp, "Encoding", G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ rcd->encoding = g_variant_dup_string(tmpOut, NULL);
+
+ tmpOut = g_variant_lookup_value(tmp, "Language", G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ rcd->language = g_variant_dup_string(tmpOut, NULL);
+
+ tmpOut = g_variant_lookup_value(tmp, "MIME",
+ G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ rcd->mime = g_variant_dup_string(tmpOut, NULL);
+
+ tmpOut = g_variant_lookup_value(tmp, "URI",
+ G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ rcd->uri = g_variant_dup_string(tmpOut, NULL);
+
+ return err;
+error:
+ /* due to error, record content will be destroyed later */
+ return NEARDAL_ERROR_INVALID_RECORD;
+}
+
+/*****************************************************************************
+ * 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(RcdProp *rcd)
+{
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(rcd != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ if (rcd->proxy != NULL)
+ g_object_unref(rcd->proxy);
+ rcd->proxy = NULL;
+
+ rcd->proxy = org_neard_rcd__proxy_new_sync(neardalMgr.conn,
+ G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
+ NEARD_DBUS_SERVICE,
+ rcd->name,
+ NULL, /* GCancellable */
+ &neardalMgr.gerror);
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Unable to create Neard Record Proxy (%d:%s)\n",
+ neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
+ }
+
+ return neardal_rcd_prv_read_properties(rcd);
+}
+
+/*****************************************************************************
+ * neardal_rcd_prv_free: unref DBus proxy, disconnect Neard Record signals
+ ****************************************************************************/
+void neardal_rcd_prv_free(RcdProp **rcd)
+{
+ NEARDAL_TRACEIN();
+ if ((*rcd)->proxy != NULL)
+ g_object_unref((*rcd)->proxy);
+ (*rcd)->proxy = 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));
+ (*rcd) = NULL;
+}
+
+/*****************************************************************************
+ * neardal_rcd_prv_format: Insert key/value in a GHashTable
+ ****************************************************************************/
+errorCode_t neardal_rcd_prv_format(GVariantBuilder *builder, RcdProp *rcd)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(rcd != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ /* Type */
+ if (rcd->type != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "Type", rcd->type,
+ (int) G_TYPE_STRING);
+
+ /* Encoding */
+ if (rcd->encoding != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "Encoding"
+ , rcd->encoding
+ , (int) G_TYPE_STRING);
+
+ /* Language */
+ if (rcd->language != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "Language"
+ , rcd->language
+ , (int) G_TYPE_STRING);
+
+ /* Representation */
+ if (rcd->representation != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "Representation",
+ rcd->representation,
+ (int) G_TYPE_STRING);
+
+ /* URI */
+ if (rcd->uri != NULL) {
+ neardal_tools_prv_add_dict_entry(builder, "URI", rcd->uri,
+ (int) G_TYPE_STRING);
+ neardal_tools_prv_add_dict_entry(builder, "Size",
+ (void *) rcd->uriObjSize,
+ (int) G_TYPE_UINT);
+
+ }
+ /* MIME */
+ if (rcd->mime != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "MIME", rcd->mime,
+ (int) G_TYPE_STRING);
+
+ /* Action */
+ if (rcd->action != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "Action", rcd->action,
+ (int) G_TYPE_STRING);
+
+ /* RawNDEF*/
+ if (rcd->rawNDEF != NULL)
+ neardal_tools_prv_add_dict_entry(builder, "NDEF", rcd->rawNDEF,
+ (int) G_TYPE_VARIANT);
+
+ return err;
+}
+
+
+/******************************************************************************
+ * neardal_rcd_add: add new NFC record, initialize DBus Proxy connection,
+ * register record signal
+ *****************************************************************************/
+errorCode_t neardal_rcd_add(char *rcdName, void *parent)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_MEMORY;
+ RcdProp *rcd = NULL;
+ TagProp *tagProp = parent;
+
+ NEARDAL_ASSERT_RET((rcdName != NULL) && (parent != NULL)
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+
+ 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;
+
+ rcd->parent = tagProp;
+
+ tagProp->rcdList = g_list_prepend(tagProp->rcdList, (gpointer) rcd);
+ err = neardal_rcd_prv_init(rcd);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ NEARDAL_TRACEF("NEARDAL LIB recordList contains %d elements\n",
+ g_list_length(tagProp->rcdList));
+
+ err = NEARDAL_SUCCESS;
+
+exit:
+ if (err != NEARDAL_SUCCESS) {
+ tagProp->rcdList = g_list_remove(tagProp->rcdList,
+ (gpointer) rcd);
+ neardal_rcd_prv_free(&rcd);
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_rcd_remove: remove NFC record, unref DBus Proxy connection,
+ * unregister record signal
+ ****************************************************************************/
+void neardal_rcd_remove(RcdProp *rcd)
+{
+ TagProp *tagProp;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT(rcd != NULL);
+
+ tagProp = rcd->parent;
+ NEARDAL_TRACEF("Removing record:%s\n", rcd->name);
+ tagProp->rcdList = g_list_remove(tagProp->rcdList,
+ (gconstpointer) rcd);
+ /* Remove all records */
+ neardal_rcd_prv_free(&rcd);
+}
--- /dev/null
+/*
+ * 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
+
+#include "neard_record_proxy.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* NEARDAL Record Properties */
+typedef struct {
+ orgNeardRcd *proxy; /* proxy to Neard NFC Record interface */
+ gchar *name; /* DBus interface name (as identifier) */
+ void *parent; /* parent (tag) */
+ gboolean notified; /* Already notified to client? */
+
+ gchar *encoding;
+ gboolean handOver;
+ gchar *language;
+ gboolean smartPoster;
+ gchar *action;
+ gchar *type;
+ gchar *representation;
+ gchar *uri;
+ gsize uriObjSize;
+ gchar *mime;
+ GVariant *rawNDEF;
+} RcdProp;
+
+/*****************************************************************************
+ * neardal_rcd_add: add new NFC record, initialize DBus Proxy connection,
+ * register record signal
+ *****************************************************************************/
+errorCode_t neardal_rcd_add(char *rcdName, void *parent);
+
+/*****************************************************************************
+ * 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(GVariantBuilder *builder, RcdProp *rcd);
+
+/*****************************************************************************
+ * neardal_rcd_prv_free: unref DBus proxy, disconnect Neard Record signals
+ ****************************************************************************/
+void neardal_rcd_prv_free(RcdProp **rcd);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_RECORD_H */
--- /dev/null
+/*
+ * 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 <glib-object.h>
+
+#include "neard_tag_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+/*****************************************************************************
+ * neardal_tag_prv_cb_property_changed: Callback called when a NFC tag
+ * property is changed
+ ****************************************************************************/
+static void neardal_tag_prv_cb_property_changed(orgNeardTag *proxy,
+ const gchar *arg_unnamed_arg0,
+ GVariant *arg_unnamed_arg1,
+ void *user_data)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ TagProp *tagProp = user_data;
+
+ (void) proxy; /* remove warning */
+ (void) arg_unnamed_arg1; /* remove warning */
+
+ NEARDAL_TRACEIN();
+
+ if (tagProp == NULL || arg_unnamed_arg0 == NULL)
+ return;
+
+ NEARDAL_TRACEF("str0='%s'\n", arg_unnamed_arg0);
+ NEARDAL_TRACEF("arg_unnamed_arg1=%s (%s)\n",
+ g_variant_print (arg_unnamed_arg1, TRUE),
+ g_variant_get_type_string(arg_unnamed_arg1));
+
+
+ if (err != NEARDAL_SUCCESS) {
+ NEARDAL_TRACE_ERR("Exit with error code %d:%s\n", err,
+ neardal_error_get_text(err));
+ }
+
+ return;
+}
+
+/*****************************************************************************
+ * org_neard_tag__call_get_raw_ndef_sync_v: Synchronously invokes the
+ * 'neard-Tag.Write' D-Bus method on Tag proxy
+ ****************************************************************************/
+static gboolean org_neard_tag__call_get_raw_ndef_sync_v(orgNeardTag *proxy
+ , gconstpointer *value
+ , gsize *length
+ , GCancellable *cancellable
+ , GError **error)
+{
+ GVariant *_ret;
+
+ _ret = g_dbus_proxy_call_sync(G_DBUS_PROXY(proxy), "GetRawNDEF"
+ , g_variant_new("()")
+ , G_DBUS_CALL_FLAGS_NONE
+ , -1, cancellable , error);
+ if (_ret == NULL)
+ goto _out;
+
+ *value = g_variant_get_data(_ret);
+ *length = g_variant_get_size(_ret);
+
+ return TRUE;
+
+_out:
+ return FALSE;
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_read_properties: Get Neard Tag Properties
+ ****************************************************************************/
+static errorCode_t neardal_tag_prv_read_properties(TagProp *tagProp)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ GError *gerror = NULL;
+ GVariant *tmp = NULL;
+ GVariant *tmpOut = NULL;
+ gsize len;
+ gchar **rcdArray = NULL;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(tagProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(tagProp->proxy != NULL
+ , NEARDAL_ERROR_GENERAL_ERROR);
+
+ org_neard_tag__call_get_properties_sync(tagProp->proxy, &tmp, NULL,
+ &gerror);
+ if (gerror != NULL) {
+ err = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+ NEARDAL_TRACE_ERR(
+ "Unable to read tag's properties (%d:%s)\n",
+ gerror->code, gerror->message);
+ g_error_free(gerror);
+ goto exit;
+ }
+ NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));
+ tmpOut = g_variant_lookup_value(tmp, "Records", G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ rcdArray = g_variant_dup_objv(tmpOut, &len);
+ tagProp->rcdLen = len;
+ if (len == 0) {
+ g_strfreev(rcdArray);
+ rcdArray = NULL;
+ } else {
+ guint len = 0;
+ char *rcdName;
+
+ while (len < tagProp->rcdLen &&
+ err == NEARDAL_SUCCESS) {
+ rcdName = rcdArray[len++];
+ err = neardal_rcd_add(rcdName, tagProp);
+ }
+ }
+ }
+
+ tmpOut = g_variant_lookup_value(tmp, "TagType", G_VARIANT_TYPE_ARRAY);
+ if (tmpOut != NULL) {
+ tagProp->tagType = g_variant_dup_strv(tmpOut, &len);
+ tagProp->tagTypeLen = len;
+ if (len == 0) {
+ g_strfreev(tagProp->tagType);
+ tagProp->tagType = NULL;
+ }
+ }
+
+ tmpOut = g_variant_lookup_value(tmp, "Type", G_VARIANT_TYPE_STRING);
+ if (tmpOut != NULL)
+ tagProp->type = g_variant_dup_string(tmpOut, NULL);
+
+ tmpOut = g_variant_lookup_value(tmp, "ReadOnly",
+ G_VARIANT_TYPE_BOOLEAN);
+ if (tmpOut != NULL)
+ tagProp->readOnly = g_variant_get_boolean(tmpOut);
+
+exit:
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_init: Get Neard Manager Properties = NFC Tags list.
+ * Create a DBus proxy for the first one NFC tag if present
+ * Register Neard Manager signals ('PropertyChanged')
+ ****************************************************************************/
+static errorCode_t neardal_tag_prv_init(TagProp *tagProp)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET(tagProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ if (tagProp->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func(tagProp->proxy,
+ G_CALLBACK(neardal_tag_prv_cb_property_changed),
+ NULL);
+ g_object_unref(tagProp->proxy);
+ tagProp->proxy = NULL;
+ }
+ tagProp->proxy = NULL;
+
+ tagProp->proxy = org_neard_tag__proxy_new_sync(neardalMgr.conn,
+ G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
+ NEARD_DBUS_SERVICE,
+ tagProp->name,
+ NULL, /* GCancellable */
+ &neardalMgr.gerror);
+ if (neardalMgr.gerror != NULL) {
+ NEARDAL_TRACE_ERR(
+ "Unable to create Neard Tag Proxy (%d:%s)\n",
+ neardalMgr.gerror->code,
+ neardalMgr.gerror->message);
+ neardal_tools_prv_free_gerror(&neardalMgr.gerror);
+ return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
+ }
+
+ /* Populate Tag datas... */
+ err = neardal_tag_prv_read_properties(tagProp);
+ if (err != NEARDAL_SUCCESS)
+ return err;
+
+ NEARDAL_TRACEF("Register Neard-Tag Signal 'PropertyChanged'\n");
+ g_signal_connect(tagProp->proxy, NEARD_TAG_SIG_PROPCHANGED,
+ G_CALLBACK(neardal_tag_prv_cb_property_changed),
+ tagProp);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_get_record: Get specific record from tag
+ ****************************************************************************/
+errorCode_t neardal_tag_prv_get_record(TagProp *tagProp, gchar *rcdName,
+ RcdProp **rcdProp)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_RECORD;
+ guint len;
+ RcdProp *rcd = NULL;
+
+ NEARDAL_ASSERT_RET((tagProp != NULL) && (rcdName != NULL)
+ && (rcdProp != NULL)
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+
+ len = 0;
+ while (len < g_list_length(tagProp->rcdList)) {
+ rcd = g_list_nth_data(tagProp->rcdList, len);
+ if (neardal_tools_prv_cmp_path(rcd->name, rcdName)) {
+ *rcdProp = rcd;
+ err = NEARDAL_SUCCESS;
+ break;
+ }
+ len++;
+ }
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_get_raw_NDEF: Get Neard Tag's NDEF as a raw bytes stream
+ ****************************************************************************/
+errorCode_t neardal_tag_prv_get_raw_NDEF(TagProp *tagProp, char **rawNDEF
+ , gsize *len)
+{
+ errorCode_t err = NEARDAL_SUCCESS;
+ GError *gerror = NULL;
+ gconstpointer array = NULL;
+ gsize arraySize;
+ char *raw;
+
+ NEARDAL_TRACEIN();
+ NEARDAL_ASSERT_RET((tagProp != NULL) && (rawNDEF != NULL)
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+ NEARDAL_ASSERT_RET(tagProp->proxy != NULL
+ , NEARDAL_ERROR_GENERAL_ERROR);
+
+ if (org_neard_tag__call_get_raw_ndef_sync_v(tagProp->proxy, &array, len
+ , NULL, &gerror) != TRUE)
+ return NEARDAL_ERROR_DBUS;
+
+ if (gerror != NULL) {
+ err = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
+ NEARDAL_TRACE_ERR(
+ "Unable to read tag's NDEF as a raw bytes stream(%d:%s)\n",
+ gerror->code, gerror->message);
+ g_error_free(gerror);
+ goto exit;
+ }
+
+ arraySize = *len;
+
+ NEARDAL_TRACEDUMP((char *) array, *len);
+
+ if (arraySize > 0) {
+ raw = g_try_malloc0(arraySize);
+ memcpy(raw, array, arraySize);
+ *rawNDEF = raw;
+ } else {
+ *rawNDEF = NULL;
+ *len = 0;
+ }
+
+ NEARDAL_TRACEF("Reading tag's NDEF raw bytes successfull! (len=%d)\n"
+ , arraySize);
+
+exit:
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_free: unref DBus proxy, disconnect Neard Tag signals
+ ****************************************************************************/
+static void neardal_tag_prv_free(TagProp **tagProp)
+{
+ NEARDAL_TRACEIN();
+ if ((*tagProp)->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func((*tagProp)->proxy,
+ G_CALLBACK(neardal_tag_prv_cb_property_changed),
+ NULL);
+ g_object_unref((*tagProp)->proxy);
+ (*tagProp)->proxy = NULL;
+ }
+ g_free((*tagProp)->name);
+ g_free((*tagProp)->type);
+ g_strfreev((*tagProp)->tagType);
+ g_free((*tagProp));
+ (*tagProp) = NULL;
+}
+
+/*****************************************************************************
+ * neardal_tag_notify_tag_found: Invoke client callback for 'record found'
+ * if present, and 'tag found' (if not already nofied)
+ ****************************************************************************/
+void neardal_tag_notify_tag_found(TagProp *tagProp)
+{
+ RcdProp *rcdProp;
+ gsize len;
+
+ NEARDAL_ASSERT(tagProp != NULL);
+
+ if (tagProp->notified == FALSE && neardalMgr.cb.tag_found != NULL) {
+ (neardalMgr.cb.tag_found)(tagProp->name,
+ neardalMgr.cb.tag_found_ud);
+ tagProp->notified = TRUE;
+ }
+
+ len = 0;
+ if (neardalMgr.cb.rcd_found != NULL)
+ while (len < g_list_length(tagProp->rcdList)) {
+ rcdProp = g_list_nth_data(tagProp->rcdList, len++);
+ if (rcdProp->notified == FALSE) {
+ (neardalMgr.cb.rcd_found)(rcdProp->name,
+ neardalMgr.cb.rcd_found_ud);
+ rcdProp->notified = TRUE;
+ }
+ }
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_write: Creates and write NDEF record to be written to a NFC
+ * tag
+ ****************************************************************************/
+errorCode_t neardal_tag_prv_write(TagProp *tagProp, RcdProp *rcd)
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *in;
+ errorCode_t err;
+ GError *gerror = NULL;
+
+ NEARDAL_ASSERT_RET(tagProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+ if (builder == NULL)
+ return NEARDAL_ERROR_NO_MEMORY;
+
+ g_variant_builder_init(builder, G_VARIANT_TYPE_ARRAY);
+ err = neardal_rcd_prv_format(builder, rcd);
+ if (err != NEARDAL_SUCCESS)
+ goto exit;
+
+ in = g_variant_builder_end(builder);
+ NEARDAL_TRACEF("Sending:\n%s\n", g_variant_print(in, TRUE));
+ org_neard_tag__call_write_sync(tagProp->proxy, in, NULL, &gerror);
+
+exit:
+ if (gerror != NULL) {
+ NEARDAL_TRACE_ERR("Unable to write tag record (%d:%s)\n",
+ gerror->code, gerror->message);
+ g_error_free(gerror);
+ err = NEARDAL_ERROR_DBUS;
+ }
+ if (builder != NULL)
+ g_variant_builder_unref(builder);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_add: add new NFC tag, initialize DBus Proxy connection,
+ * register tag signal
+ ****************************************************************************/
+errorCode_t neardal_tag_prv_add(gchar *tagName, void *parent)
+{
+ errorCode_t err = NEARDAL_ERROR_NO_MEMORY;
+ TagProp *tagProp = NULL;
+ AdpProp *adpProp = parent;
+
+ NEARDAL_ASSERT_RET((tagName != NULL) && (parent != NULL)
+ , NEARDAL_ERROR_INVALID_PARAMETER);
+
+ NEARDAL_TRACEF("Adding tag:%s\n", tagName);
+ tagProp = g_try_malloc0(sizeof(TagProp));
+ if (tagProp == NULL)
+ goto error;
+
+ tagProp->name = g_strdup(tagName);
+ tagProp->parent = adpProp;
+
+ adpProp->tagList = g_list_prepend(adpProp->tagList, tagProp);
+ err = neardal_tag_prv_init(tagProp);
+
+ NEARDAL_TRACEF("NEARDAL LIB tagList contains %d elements\n",
+ g_list_length(adpProp->tagList));
+
+ return err;
+
+error:
+ if (tagProp->name != NULL)
+ g_free(tagProp->name);
+ if (tagProp != NULL)
+ g_free(tagProp);
+
+ return err;
+}
+
+/*****************************************************************************
+ * neardal_tag_prv_remove: remove one NFC tag, unref DBus Proxy connection,
+ * unregister tag signal
+ ****************************************************************************/
+void neardal_tag_prv_remove(TagProp *tagProp)
+{
+ RcdProp *rcdProp = NULL;
+ GList *node;
+ AdpProp *adpProp;
+
+ NEARDAL_ASSERT(tagProp != NULL);
+
+ NEARDAL_TRACEF("Removing tag:%s\n", tagProp->name);
+ /* Remove all tags */
+ while (g_list_length(tagProp->rcdList)) {
+ node = g_list_first(tagProp->rcdList);
+ rcdProp = (RcdProp *) node->data;
+ neardal_rcd_remove(rcdProp);
+ }
+ adpProp = tagProp->parent;
+ adpProp->tagList = g_list_remove(adpProp->tagList,
+ (gconstpointer) tagProp);
+
+ neardal_tag_prv_free(&tagProp);
+}
--- /dev/null
+/*
+ * 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_TAG_H
+#define __NEARDAL_TAG_H
+
+#include "neard_tag_proxy.h"
+#include "neardal_record.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NEARD_TAG_SIG_PROPCHANGED "property-changed"
+
+/* NEARDAL Tag Properties */
+typedef struct {
+ orgNeardTag *proxy; /* proxy to Neard NEARDAL Tag interface */
+ gchar *name; /* DBus interface name (as identifier) */
+ void *parent; /* parent (adapter ) */
+ gboolean notified; /* Already notified to client? */
+
+ gchar *type;
+
+ gsize rcdLen;
+ GList *rcdList; /* tag's records paths */
+
+ gchar **tagType; /* array of tag types */
+ gsize tagTypeLen;
+ gboolean readOnly; /* Read-Only flag */
+} TagProp;
+
+/*****************************************************************************
+ * neardal_tag_notify_tag_found: Invoke client callback for 'record found'
+ * if present, and 'tag found' (if not already nofied)
+ ****************************************************************************/
+void neardal_tag_notify_tag_found(TagProp *tagProp);
+
+/******************************************************************************
+ * neardal_tag_prv_add: add new NEARDAL tag, initialize DBus Proxy connection,
+ * register tag signal
+ *****************************************************************************/
+errorCode_t neardal_tag_prv_add(gchar *tagName, void *parent);
+
+/******************************************************************************
+ * neardal_tag_prv_remove: remove NEARDAL tag, unref DBus Proxy connection,
+ * unregister tag signal
+ *****************************************************************************/
+void neardal_tag_prv_remove(TagProp *tagProp);
+
+/******************************************************************************
+ * neardal_tag_prv_write: Creates and write NDEF record to be written to
+ * an NFC tag
+ *****************************************************************************/
+errorCode_t neardal_tag_prv_write(TagProp *tagProp, RcdProp *rcd);
+
+/*****************************************************************************
+ * neardal_tag_prv_get_record: Get specific record from tag
+ ****************************************************************************/
+errorCode_t neardal_tag_prv_get_record(TagProp *tagProp, gchar *rcdName,
+ RcdProp **rcdProp);
+
+/*****************************************************************************
+ * neardal_tag_prv_get_raw_NDEF: Get specific record from tag
+ ****************************************************************************/
+errorCode_t neardal_tag_prv_get_raw_NDEF(TagProp *tagProp, gchar **NDEF
+ , gsize *len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_TAG_H */
--- /dev/null
+/*
+ * 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 <glib-object.h>
+
+#include "neard_manager_proxy.h"
+#include "neard_adapter_proxy.h"
+
+#include "neardal.h"
+#include "neardal_prv.h"
+
+
+/*****************************************************************************
+ * neardal_tools_prv_free_gerror: freeing gerror in neardal context
+ ****************************************************************************/
+void neardal_tools_prv_free_gerror(GError **gerror)
+{
+ NEARDAL_ASSERT(gerror != NULL);
+
+ if (*gerror != NULL)
+ g_error_free(*gerror);
+ *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;
+
+ NEARDAL_ASSERT_RET((neardalPath != NULL) && (reqPath != NULL)
+ , FALSE);
+
+ 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_create_dict: Create a GHashTable for dict_entries.
+ ****************************************************************************/
+GHashTable *neardal_tools_prv_create_dict(void)
+{
+ return g_hash_table_new(g_str_hash, g_str_equal);
+}
+
+/*****************************************************************************
+ * neardal_tools_prv_add_dict_entry: add an entry in a dictionnary
+ ****************************************************************************/
+errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder
+ , gchar *key, void *value
+ , int gVariantType)
+{
+ GVariant *tmp = NULL;
+
+ NEARDAL_ASSERT_RET(builder != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
+
+ switch (gVariantType) {
+ case G_TYPE_STRING:
+ tmp = g_variant_new_string(value);
+ break;
+ case G_TYPE_UINT:
+ tmp = g_variant_new_uint32((guint32) value);
+ break;
+ case G_TYPE_VARIANT:
+ tmp = (GVariant *) value;
+ }
+ g_variant_builder_add(builder, "{sv}", key, tmp);
+
+ return NEARDAL_SUCCESS;
+}
+
--- /dev/null
+/*
+ * 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 */
+
+
+/*****************************************************************************
+ * Debugging macro to manage assertion.
+ *****************************************************************************/
+#define NEARDAL_ASSERT(cond) do { \
+ if (!(cond)) { \
+ neardal_trace(stderr, "\nASSERT!! %s -> %s():l%d: cond=(%s)\n\n" \
+ , __FILE__, __func__, __LINE__, #cond); \
+ return; \
+ } \
+} while (0);
+
+#define NEARDAL_ASSERT_RET(cond, val) do { \
+ if (!(cond)) { \
+ neardal_trace(stderr, "\nASSERT!! %s -> %s():l%d: cond=(%s)\n\n" \
+ , __FILE__, __func__, __LINE__, #cond); \
+ return val; \
+ } \
+} while (0);
+
+/*****************************************************************************
+ * neardal_tools_prv_free_gerror: freeing gerror in neardal context
+ *****************************************************************************/
+void neardal_tools_prv_free_gerror(GError **gerror);
+
+/*****************************************************************************
+ * 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_create_dict: Create a GHashTable for dict_entries.
+ *****************************************************************************/
+GHashTable *neardal_tools_prv_create_dict(void);
+
+/******************************************************************************
+ * neardal_tools_prv_add_dict_entry: add an entry in a dictionnary
+ *****************************************************************************/
+errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder
+ , gchar *key, void *value
+ , int gVariantType);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_TOOLS_H */
--- /dev/null
+/*
+ * 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_prv_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);
+}
--- /dev/null
+/*
+ * 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_prv_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_LOG(msg, ...) neardal_trace(stdout, \
+ "%s() : " msg, __func__, ##__VA_ARGS__)
+#define NEARDAL_TRACE_ERR(msg, ...) neardal_trace(stderr, \
+ "%s(ERR) : " msg, __func__, ##__VA_ARGS__)
+
+void neardal_trace(FILE *stream, char *format, ...);
+void neardal_trace_prv_dump_mem(char *dataP, int size);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NEARDAL_TRACES_PRV_H */
--- /dev/null
+bin_PROGRAMS=ncl
+
+ncl_SOURCES = ncl.c \
+ ncl_cmd.c
+
+noinst_HEADERS = ncl.h
+
+ncl_CFLAGS = $(GLIB_CFLAGS) -I../lib
+ncl_LDADD = $(GLIB_LIBS) ../lib/libneardal.la
--- /dev/null
+/*
+ * 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"
+
+#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;
+ char **argv = NULL;
+ int *argc;
+ char *argEnd;
+ char *argStart;
+ bool inQuotes;
+ gssize argSize;
+ int endParsing = FALSE;
+
+ /* Test input parameters */
+ if (!cmdLine || !iArgc || !iArgv)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Splitting parameters list like argc/argv style */
+ argv = iArgv;
+ argc = iArgc;
+ *argc = 0;
+ inQuotes = false;
+
+ argStart = argEnd = cmdLine;
+ while ((*argc) < NB_MAX_PARAMETERS && *argEnd != '\0' &&
+ endParsing == FALSE) {
+ while (*argEnd != ' ' && *argEnd != '"' && *argEnd != '\0')
+ argEnd++;
+ if (*argEnd == '"') {
+ if (inQuotes == false)
+ argStart = argEnd + 1;
+ inQuotes = !inQuotes;
+ }
+
+ if (inQuotes == false) {
+ if (*argEnd == '\0')
+ endParsing = TRUE;
+ *argEnd = '\0';
+ argSize = argEnd - argStart;
+ if (argSize > 0)
+ ((char **)(argv))[(*argc)++] = argStart;
+ argEnd++;
+ argStart = argEnd;
+ } else
+ argEnd++;
+ }
+
+ 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 || cmd == NULL)
+ return NULL;
+
+ for (index = 0; index < nbClCmd; index++)
+ if (!strncmp(it[index].cmdName, cmd, strlen(it[index].cmdName)))
+ 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);
+ g_string_append_c(nclCmdCtx->clBuf, '\0');
+ } 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();
+ NCL_CMD_PRINT("Compiled at %s : %s\n\n", __DATE__, __TIME__);
+
+ 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;
+}
--- /dev/null
+/*
+ * 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__ */
--- /dev/null
+/*
+ * 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"
+
+
+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;
+ 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++) {
+ ncl_cmd_print(stdout, "%s :\n\t%s\n\n", itFunc[index].cmdName,
+ itFunc[index].helpStr);
+ }
+
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Dump properties of an adapter
+ ****************************************************************************/
+static void ncl_cmd_prv_dump_adapter(neardal_adapter *adapter)
+{
+ char **protocols;
+ char **tags;
+ char **devs;
+
+ 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");
+ if (adapter->mode)
+ NCL_CMD_PRINT(".. NFC Radio Mode:\t'%s'\n", adapter->mode);
+
+ tags = adapter->tags;
+ NCL_CMD_PRINT(".. Number of tags:\t%d\n", adapter->nbTags);
+ NCL_CMD_PRINT(".. Tags[]:\t\t");
+ if (adapter->nbTags > 0) {
+ while ((*tags) != NULL) {
+ NCL_CMD_PRINT("'%s', ", *tags);
+ tags++;
+ }
+ } else
+ NCL_CMD_PRINT("No tags!");
+ NCL_CMD_PRINT("\n");
+
+ devs = adapter->devs;
+ NCL_CMD_PRINT(".. Number of devices:\t%d\n", adapter->nbDevs);
+ NCL_CMD_PRINT(".. Devs[]:\t\t");
+ if (adapter->nbDevs > 0) {
+ while ((*devs) != NULL) {
+ NCL_CMD_PRINT("'%s', ", *devs);
+ devs++;
+ }
+ } else
+ NCL_CMD_PRINT("No devs!");
+ 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++;
+ }
+ } else
+ NCL_CMD_PRINT("No protocols!");
+ NCL_CMD_PRINT("\n");
+}
+
+/*****************************************************************************
+ * Dump properties of a tag
+ ****************************************************************************/
+static void ncl_cmd_prv_dump_tag(neardal_tag *tag)
+{
+ char **records;
+ char **tagTypes;
+
+ NCL_CMD_PRINT("Tag:\n");
+ NCL_CMD_PRINT(".. Name:\t\t'%s'\n", tag->name);
+
+ NCL_CMD_PRINT(".. Type:\t\t'%s'\n", tag->type);
+
+ NCL_CMD_PRINT(".. Number of 'Tag Type':%d\n", tag->nbTagTypes);
+ tagTypes = tag->tagType;
+ if (tag->nbTagTypes > 0) {
+ NCL_CMD_PRINT(".. Tags type[]:\t\t");
+ while ((*tagTypes) != NULL) {
+ NCL_CMD_PRINT("'%s', ", *tagTypes);
+ tagTypes++;
+ }
+ NCL_CMD_PRINT("\n");
+ }
+
+ records = tag->records;
+ NCL_CMD_PRINT(".. Number of records:\t%d\n", tag->nbRecords);
+ NCL_CMD_PRINT(".. Records[]:\t\t");
+ if (records != NULL) {
+ while ((*records) != NULL) {
+ NCL_CMD_PRINT("'%s', ", *records);
+ records++;
+ }
+ } else
+ NCL_CMD_PRINT("No records!");
+
+ NCL_CMD_PRINT("\n");
+ NCL_CMD_PRINT(".. ReadOnly:\t\t%s\n" ,
+ tag->readOnly ? "TRUE" : "FALSE");
+}
+
+/*****************************************************************************
+ * Dump properties of a device
+ ****************************************************************************/
+static void ncl_cmd_prv_dump_dev(neardal_dev *dev)
+{
+ char **records;
+
+ NCL_CMD_PRINT("Dev:\n");
+ NCL_CMD_PRINT(".. Name:\t\t'%s'\n", dev->name);
+
+
+ records = dev->records;
+ NCL_CMD_PRINT(".. Number of records:\t%d\n", dev->nbRecords);
+ NCL_CMD_PRINT(".. Records[]:\t\t");
+ if (records != NULL) {
+ while ((*records) != NULL) {
+ NCL_CMD_PRINT("'%s', ", *records);
+ records++;
+ }
+ } else
+ NCL_CMD_PRINT("No records!");
+
+ NCL_CMD_PRINT("\n");
+
+}
+
+/*****************************************************************************
+ * Dump properties of a record
+ ****************************************************************************/
+static void ncl_cmd_prv_dump_record(neardal_record *record)
+{
+ NCL_CMD_PRINT("Record\n");
+ if (record->name)
+ NCL_CMD_PRINT(".. Name:\t\t%s\n" , record->name);
+ if (record->encoding)
+ NCL_CMD_PRINT(".. Encoding:\t\t%s\n" , record->encoding);
+ if (record->language)
+ NCL_CMD_PRINT(".. Language:\t\t%s\n" , record->language);
+ if (record->action)
+ NCL_CMD_PRINT(".. Action:\t\t%s\n" , record->action);
+ if (record->type)
+ NCL_CMD_PRINT(".. Type:\t\t%s\n" , record->type);
+ if (record->representation)
+ NCL_CMD_PRINT(".. Representation:\t%s\n",
+ record->representation);
+ if (record->uri) {
+ NCL_CMD_PRINT(".. URI:\t\t\t%s\n" , record->uri);
+ NCL_CMD_PRINT(".. URI size:\t\t%d\n" , record->uriObjSize);
+ }
+ if (record->mime)
+ NCL_CMD_PRINT(".. MIME:\t\t%s\n" , record->mime);
+}
+
+/*****************************************************************************
+ * neardal callbacks : BEGIN
+ ****************************************************************************/
+static void ncl_cmd_cb_adapter_added(const char *adpName, void *user_data)
+{
+ errorCode_t ec;
+ neardal_adapter *adapter;
+
+ (void) user_data; /* Remove warning */
+
+ NCL_CMD_PRINTF("NFC Adapter added '%s'\n", adpName);
+ ec = neardal_get_adapter_properties(adpName, &adapter);
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_adapter(adapter);
+ neardal_free_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)
+{
+ (void) user_data; /* remove warning */
+
+ 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)
+{
+ int polling;
+
+ (void) user_data; /* remove warning */
+
+ 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_tag_found(const char *tagName, void *user_data)
+{
+ neardal_tag *tag;
+ errorCode_t ec;
+
+ (void) user_data; /* remove warning */
+
+ NCL_CMD_PRINTF("NFC Tag found (%s)\n", tagName);
+
+ ec = neardal_get_tag_properties(tagName, &tag);
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_tag(tag);
+ neardal_free_tag(tag);
+ } else
+ NCL_CMD_PRINTF(
+ "Unable to read tag properties. (error:%d='%s'). exit...\n",
+ ec, neardal_error_get_text(ec));
+ return;
+}
+
+static void ncl_cmd_cb_tag_lost(const char *tagName, void *user_data)
+{
+ (void) user_data; /* remove warning */
+ NCL_CMD_PRINTF("NFC Tag lost (%s)\n", tagName);
+}
+
+static void ncl_cmd_cb_dev_found(const char *devName, void *user_data)
+{
+ neardal_dev *dev;
+ errorCode_t ec;
+
+ (void) user_data; /* remove warning */
+
+ NCL_CMD_PRINTF("NFC Device found (%s)\n", devName);
+
+ ec = neardal_get_dev_properties(devName, &dev);
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_dev(dev);
+ neardal_free_device(dev);
+ } else
+ NCL_CMD_PRINTF(
+ "Unable to read device properties. (error:%d='%s'). exit...\n",
+ ec, neardal_error_get_text(ec));
+ return;
+}
+
+static void ncl_cmd_cb_dev_lost(const char *devName, void *user_data)
+{
+ (void) user_data; /* remove warning */
+ NCL_CMD_PRINTF("NFC Dev lost (%s)\n", devName);
+}
+
+static void ncl_cmd_cb_record_found(const char *rcdName, void *user_data)
+{
+ errorCode_t ec;
+ neardal_record *record;
+
+ (void) user_data; /* remove warning */
+
+ NCL_CMD_PRINTF("Tag Record found (%s)\n", rcdName);
+ ec = neardal_get_record_properties(rcdName, &record);
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_record(record);
+ neardal_free_record(record);
+ } else
+ NCL_CMD_PRINTF("Read record error. (error:%d='%s').\n", ec,
+ neardal_error_get_text(ec));
+
+ return;
+}
+
+/*****************************************************************************
+ * neardal callbacks : END
+ ****************************************************************************/
+
+static void ncl_cmd_install_callback(void)
+{
+ neardal_set_cb_adapter_added(ncl_cmd_cb_adapter_added, NULL);
+ neardal_set_cb_adapter_removed(ncl_cmd_cb_adapter_removed, NULL);
+ neardal_set_cb_adapter_property_changed(ncl_cmd_cb_adapter_prop_changed,
+ NULL);
+ NCL_CMD_PRINTF("NFC adapter callback registered\n");
+ neardal_set_cb_tag_found(ncl_cmd_cb_tag_found, NULL);
+ neardal_set_cb_tag_lost(ncl_cmd_cb_tag_lost, NULL);
+ NCL_CMD_PRINTF("NFC tag registered\n");
+ neardal_set_cb_dev_found(ncl_cmd_cb_dev_found, NULL);
+ neardal_set_cb_dev_lost(ncl_cmd_cb_dev_lost, NULL);
+ NCL_CMD_PRINTF("NFC dev registered\n");
+ neardal_set_cb_record_found(ncl_cmd_cb_record_found, NULL);
+ NCL_CMD_PRINTF("NFC record callback registered\n\n");
+ sNclCmdCtx.cb_initialized = true;
+}
+
+/*****************************************************************************
+ * neardal_get_adapters : BEGIN
+ * Get adapters List
+ ****************************************************************************/
+static NCLError ncl_cmd_get_adapters(int argc, char *argv[])
+{
+ errorCode_t ec;
+ NCLError nclErr;
+ char **adpArray = NULL;
+ int adpLen;
+ int adpOff;
+
+ (void) argc; /* Remove warning */
+ (void) argv; /* Remove warning */
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ ec = neardal_get_adapters(&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_get_adapter_properties : BEGIN
+ * Read adapter properties
+ ****************************************************************************/
+static NCLError ncl_cmd_get_adapter_properties(int argc, char *argv[])
+{
+ errorCode_t ec;
+ char *adapterName = NULL;
+ neardal_adapter *adapter;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ adapterName = argv[1];
+ ec = neardal_get_adapter_properties(adapterName, &adapter);
+
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_adapter(adapter);
+ neardal_free_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_get_adapter_properties : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_get_devices : BEGIN
+ * Get devices List
+ ****************************************************************************/
+static NCLError ncl_cmd_get_devices(int argc, char *argv[])
+{
+ errorCode_t ec;
+ NCLError nclErr;
+ char **devArray = NULL;
+ int devLen;
+ int devOff;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ ec = neardal_get_devices(argv[1], &devArray, &devLen);
+ if (ec == NEARDAL_SUCCESS) {
+ devOff = 0;
+ /* For each dev */
+ while (devArray[devOff] != NULL)
+ NCL_CMD_PRINT(".. Dev '%s'\n",
+ devArray[devOff++]);
+
+ neardal_free_array(&devArray);
+ } else
+ NCL_CMD_PRINTF("No dev\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;
+}
+/*****************************************************************************
+ * ncl_cmd_get_devices : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_get_device_properties : BEGIN
+ * Read device properties
+ ****************************************************************************/
+static NCLError ncl_cmd_get_device_properties(int argc, char *argv[])
+{
+ errorCode_t ec;
+ char *devName = NULL;
+ neardal_dev *dev;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ devName = argv[1];
+ ec = neardal_get_dev_properties(devName, &dev);
+
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_dev(dev);
+ neardal_free_device(dev);
+ } else {
+ NCL_CMD_PRINTF("Read dev 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_get_device_properties : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * neardal_get_tags : BEGIN
+ * Get tags List
+ ****************************************************************************/
+static NCLError ncl_cmd_get_tags(int argc, char *argv[])
+{
+ errorCode_t ec;
+ NCLError nclErr;
+ char **tagArray = NULL;
+ int tagLen;
+ int tagOff;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ ec = neardal_get_tags(argv[1], &tagArray, &tagLen);
+ if (ec == NEARDAL_SUCCESS) {
+ tagOff = 0;
+ /* For each tag */
+ while (tagArray[tagOff] != NULL)
+ NCL_CMD_PRINT(".. Tag '%s'\n",
+ tagArray[tagOff++]);
+
+ neardal_free_array(&tagArray);
+ } else
+ NCL_CMD_PRINTF("No tag\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_tags : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_get_tag_properties : BEGIN
+ * Read tag properties
+ ****************************************************************************/
+static NCLError ncl_cmd_get_tag_properties(int argc, char *argv[])
+{
+ errorCode_t ec;
+ char *tagName = NULL;
+ neardal_tag *tag;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ tagName = argv[1];
+ ec = neardal_get_tag_properties(tagName, &tag);
+
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_tag(tag);
+ neardal_free_tag(tag);
+ } else {
+ NCL_CMD_PRINTF("Read tag 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_get_tag_properties : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_get_tag_rawNDEF : BEGIN
+ * Read the tag's NDEF as a raw bytes stream
+ ****************************************************************************/
+static NCLError ncl_cmd_get_tag_rawNDEF(int argc, char *argv[])
+{
+ errorCode_t ec;
+ char *tagName = NULL;
+ char *rawNDEF;
+ int len;
+ int count;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ tagName = argv[1];
+ ec = neardal_tag_get_rawNDEF(tagName, &rawNDEF, &len);
+
+ if (ec == NEARDAL_SUCCESS) {
+ if (len > 0) {
+ count = 0;
+ while (count < len) {
+ NCL_CMD_PRINT("[%02hX]'%c', "
+ , (unsigned char) rawNDEF[count]
+ , rawNDEF[count]);
+ count++;
+ }
+ g_free(rawNDEF);
+ } else {
+ NCL_CMD_PRINT("Empty Raw data stream\n");
+ }
+ } else {
+ NCL_CMD_PRINTF("Read tag's NDEF raw data 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_get_tag_rawNDEF : END
+ ****************************************************************************/
+
+
+/*****************************************************************************
+ * neardal_get_records : BEGIN
+ * Get records List
+ ****************************************************************************/
+static NCLError ncl_cmd_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;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ ec = neardal_get_records(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_get_record_properties : BEGIN
+ * Read a specific tag
+ ****************************************************************************/
+static NCLError ncl_cmd_get_record_properties(int argc, char *argv[])
+{
+ errorCode_t ec;
+ char *recordName = NULL;
+ neardal_record *record;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ recordName = argv[1];
+ ec = neardal_get_record_properties(recordName, &record);
+ if (ec == NEARDAL_SUCCESS) {
+ ncl_cmd_prv_dump_record(record);
+ neardal_free_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_get_record_properties : END
+ ****************************************************************************/
+/*****************************************************************************
+ * ncl_cmd_push : BEGIN
+ * Push NDEF record to device
+ ****************************************************************************/
+static NCLError ncl_cmd_push(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"},
+
+ { "dev", 'a', 0, G_OPTION_ARG_STRING, &rcd.name
+ , "Device name", "/org/neard/nfc0/device0"},
+
+ { "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) {
+ /* Parse options */
+ memset(&rcd, 0, sizeof(neardal_record));
+ nclErr = ncl_cmd_prv_parseOptions(&argc, &argv, options);
+ } else
+ nclErr = NCLERR_PARSING_PARAMETERS;
+
+ if (nclErr != NCLERR_NOERROR) {
+ ncl_cmd_print(stdout, "Sample (Type 'Text'):");
+ ncl_cmd_print(stdout, "e.g. < push --type Text --lang en-US \
+--encoding UTF-8 --rep \"Simple text\" --dev /org/neard/nfc0/device0 >\n");
+ ncl_cmd_print(stdout, "Sample (Type 'URI'):");
+ ncl_cmd_print(stdout, "e.g. < push --type URI \
+--uri=http://www.nfc-forum.com --dev /org/neard/nfc0/device0 >\n");
+ ncl_cmd_print(stdout, "Sample (Type 'SmartPoster'):");
+ ncl_cmd_print(stdout, "e.g. < push --type=SmartPoster \
+--uri=http://www.nfc-forum.com > --dev /org/neard/nfc0/device0 >\n");
+ }
+
+ if (nclErr != NCLERR_NOERROR)
+ goto exit;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ ec = neardal_dev_push(&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_push : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_write : BEGIN
+ * write NDEF record to tag
+ ****************************************************************************/
+static NCLError ncl_cmd_write(int argc, char *argv[])
+{
+ errorCode_t ec = NEARDAL_SUCCESS;
+ NCLError nclErr;
+ static neardal_record rcd;
+ static int smartPoster;
+ gchar *ptr;
+ static gchar *rawNDEF;
+ gsize rawNDEFSize;
+ short tmp;
+
+static GOptionEntry options[] = {
+ { "act", 'c', 0, G_OPTION_ARG_STRING, &rcd.action
+ , "Action", "save"},
+
+ { "tag", 'a', 0, G_OPTION_ARG_STRING, &rcd.name
+ , "Tag name", "/org/neard/nfc0/tag0"},
+
+ { "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"},
+
+ { "raw" , 'w', 0, G_OPTION_ARG_STRING , &rawNDEF
+ , "NDEF raw data. hex value, comma separated"
+ , "d1,01,0f,55,01,73,6d,61,72,74,61,67..." },
+
+ { "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) {
+ /* Parse options */
+ rawNDEF = NULL;
+ memset(&rcd, 0, sizeof(neardal_record));
+ nclErr = ncl_cmd_prv_parseOptions(&argc, &argv, options);
+ } else
+ nclErr = NCLERR_PARSING_PARAMETERS;
+
+ if (nclErr != NCLERR_NOERROR) {
+ ncl_cmd_print(stdout, "Sample (Type Text):\n");
+ ncl_cmd_print(stdout, \
+"<< write --type Text --lang en-US --encoding UTF-8 --rep \"Simple text\" \
+--tag /org/neard/nfc0/tag0 >>\n\n");
+ ncl_cmd_print(stdout, "Sample (Type URI):\n");
+ ncl_cmd_print(stdout,
+"<< write --type URI --uri=http://www.nfc-forum.com \
+--tag /org/neard/nfc0/tag0 >>\n\n");
+ ncl_cmd_print(stdout, "Sample (Type SmartPoster):\n");
+ ncl_cmd_print(stdout,
+"<< write --type=SmartPoster --uri=http://www.nfc-forum.com \
+--tag /org/neard/nfc0/tag0 >>\n\n");
+ ncl_cmd_print(stdout, "Sample (NDEF raw data):\n");
+ ncl_cmd_print(stdout,
+"<< write --raw=d1,01,0f,55,01,73,6d,61,72,74,61,67,2e,63,6f,6d,2e,73,67 \
+--type=Raw --tag /org/neard/nfc0/tag0 >>\n\n");
+ }
+
+ if (rawNDEF != NULL) {
+ NCL_CMD_PRINT( \
+"\n'raw' option initialized. All others options will be ignored...\n");
+ /* Count commas to define byte size */
+ rawNDEFSize = 1;
+ ptr = rawNDEF;
+ while (*ptr != '\0') {
+ if ((gchar) *ptr == (gchar) ',') {
+ *ptr = '\0';
+ rawNDEFSize++;
+ }
+ ptr++;
+ }
+ nclErr = NCLERR_MEM_ALLOC;
+ rcd.rawNDEF = g_try_malloc0(rawNDEFSize);
+ if (rcd.rawNDEF == NULL)
+ goto exit;
+
+ nclErr = NCLERR_NOERROR;
+
+ ptr = rawNDEF;
+ while (rcd.rawNDEFSize < rawNDEFSize) {
+ if (sscanf(ptr, "%hx", &tmp) == 1)
+ rcd.rawNDEF[rcd.rawNDEFSize++] = tmp;
+ else
+ NCL_CMD_PRINTERR(\
+ "Error while trying to convert '%s' in hex format", ptr);
+
+ /* next field */
+ while (*ptr != '\0')
+ ptr++;
+ ptr++;
+ }
+ }
+
+ if (nclErr != NCLERR_NOERROR)
+ goto exit;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ ec = neardal_tag_write(&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);
+ if (rcd.rawNDEF != NULL)
+ g_free((gchar *) rcd.rawNDEF);
+ if (rawNDEF != NULL)
+ g_free((gchar *) rawNDEF);
+
+ return nclErr;
+}
+/*****************************************************************************
+ * ncl_cmd_write : END
+ ****************************************************************************/
+
+
+/*****************************************************************************
+ * ncl_cmd_set_adp_property : BEGIN
+ * write NDEF record to tag
+ ****************************************************************************/
+static NCLError ncl_cmd_set_adapter_property(int argc, char *argv[])
+{
+ errorCode_t ec = NEARDAL_SUCCESS;
+ NCLError nclErr;
+ static int powered = -1;
+ char *adapterName = NULL;
+
+static GOptionEntry options[] = {
+ { "powered", 's', 0, G_OPTION_ARG_INT , &powered
+ , "Set Adapter power ON/OFF", "<>0 or =0" },
+ { NULL, 0, 0, 0, NULL, NULL, NULL} /* End of List */
+ };
+
+ if (argc > 2) {
+ /* Parse options */
+ nclErr = ncl_cmd_prv_parseOptions(&argc, &argv, options);
+ } else
+ nclErr = NCLERR_PARSING_PARAMETERS;
+
+ if (nclErr != NCLERR_NOERROR) {
+ ncl_cmd_print(stdout, "e.g. < %s /org/neard/nfc0 --powered=1 \
+>\n", argv[0]);
+ }
+
+ if (nclErr != NCLERR_NOERROR)
+ goto exit;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ adapterName = argv[1];
+ if (powered >= 0)
+ ec = neardal_set_adapter_property(adapterName,
+ NEARD_ADP_PROP_POWERED,
+ (void *) powered);
+
+exit:
+ NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
+ neardal_error_get_text(ec));
+
+ return nclErr;
+}
+/*****************************************************************************
+ * ncl_cmd_set_adp_property : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_start_poll : BEGIN
+ * Request Neard to start polling
+ ****************************************************************************/
+static NCLError ncl_cmd_start_poll(int argc, char *argv[])
+{
+ errorCode_t ec = NEARDAL_SUCCESS;
+ NCLError nclErr;
+ char *adpName = NULL;
+ static char *strMode;
+
+static GOptionEntry options[] = {
+ { "mode", 's', 0, G_OPTION_ARG_STRING , &strMode
+ , "Set Adapter mode initiator/target/dual",
+ "'initiator, target, dual'" },
+ { NULL, 0, 0, 0, NULL, NULL, NULL} /* End of List */
+ };
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ if (argc > 1) {
+ /* Parse options */
+ strMode = NULL;
+ nclErr = ncl_cmd_prv_parseOptions(&argc, &argv, options);
+ } else
+ nclErr = NCLERR_PARSING_PARAMETERS;
+
+ if (nclErr != NCLERR_NOERROR)
+ goto exit;
+
+ /* Start polling if adapter present */
+ adpName = argv[1];
+ if (strMode != NULL) {
+ if (!strcmp(strMode, "initiator"))
+ ec = neardal_start_poll_loop(adpName,
+ NEARD_ADP_MODE_INITIATOR);
+ else if (!strcmp(strMode, "target"))
+ ec = neardal_start_poll_loop(adpName,
+ NEARD_ADP_MODE_TARGET);
+ else if (!strcmp(strMode, "dual"))
+ ec = neardal_start_poll_loop(adpName,
+ NEARD_ADP_MODE_DUAL);
+ else
+ ec = neardal_start_poll_loop(adpName,
+ NEARD_ADP_MODE_INITIATOR);
+ } else
+ ec = neardal_start_poll(adpName);
+
+ 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));
+
+exit:
+ if (strMode != NULL)
+ g_free(strMode);
+
+ if (ec != NEARDAL_SUCCESS)
+ nclErr = NCLERR_LIB_ERROR;
+
+ return nclErr;
+}
+/*****************************************************************************
+ * ncl_cmd_start_poll : END
+ ****************************************************************************/
+
+/*****************************************************************************
+ * ncl_cmd_stop_poll : BEGIN
+ * Request Neard to stop polling
+ ****************************************************************************/
+static NCLError ncl_cmd_stop_poll(int argc, char *argv[])
+{
+ errorCode_t ec = NEARDAL_SUCCESS;
+ char *adpName = NULL;
+
+ if (argc <= 1)
+ return NCLERR_PARSING_PARAMETERS;
+
+ /* Install Neardal Callback*/
+ if (sNclCmdCtx.cb_initialized == false)
+ ncl_cmd_install_callback();
+
+ adpName = argv[1];
+ ec = neardal_stop_poll(adpName);
+ 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_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_exit(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();
+
+ /* 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_get_adapters,
+ "Get adapters list"},
+
+ { "get_adapter_properties",
+ ncl_cmd_get_adapter_properties,
+ "Get adapter properties (1st parameter is adapter name)"},
+
+ { "get_devices",
+ ncl_cmd_get_devices,
+ "Get devices list (1st parameter is adapter name)"},
+
+ { "get_device_properties",
+ ncl_cmd_get_device_properties,
+ "Get device properties (1st parameter is device name)"},
+
+ { "get_records",
+ ncl_cmd_get_records,
+ "Get records list (1st parameter is tag name)"},
+
+ { "get_record_properties",
+ ncl_cmd_get_record_properties,
+ "Read a specific record. (1st parameter is record name)"},
+
+ { "get_tags",
+ ncl_cmd_get_tags,
+ "Get tags list (1st parameter is adapter name)"},
+
+ { "get_tag_properties",
+ ncl_cmd_get_tag_properties,
+ "Get tag properties (1st parameter is tag name)"},
+
+ { "get_tag_rawNDEF",
+ ncl_cmd_get_tag_rawNDEF,
+ "Get tag's NDEF as a raw bytes stream (1st parameter is tag name)"},
+
+ { LISTCMD_NAME,
+ ncl_cmd_list,
+ "List all available commands. 'cmd' --help -h /? for a specific help" },
+
+ { "push",
+ ncl_cmd_push,
+ "Creates and push a NDEF record to a NFC device"},
+
+ { "write",
+ ncl_cmd_write,
+ "Creates and write a NDEF record to a NFC tag"},
+
+ { "exit",
+ ncl_cmd_exit,
+ "Exit from command line interpretor" },
+
+ { "set_adp_property",
+ ncl_cmd_set_adapter_property,
+ "Request Neard to set a proprety on defined adapter"},
+
+ { "start_poll",
+ ncl_cmd_start_poll,
+ "Request Neard to start polling (1st parameter is adapter name)"},
+
+ { "stop_poll",
+ ncl_cmd_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 */
+ neardal_destroy();
+}
--- /dev/null
+/*
+ * 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 Callback already initialized? */
+ gboolean cb_initialized;
+
+ /* 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__ */
--- /dev/null
+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
--- /dev/null
+# >> macros
+%define neardal_dir %{_libdir}
+%define neardal_pkg %{_libdir}/pkgconfig
+%define neardal_inc %{_includedir}/neardal
+
+%define glib2_version 2.30.0
+# << macros
+
+Name: neardal
+Summary: Neard Abstraction Library (for Neard v0.7)
+Version: 0.7.0
+Release: 1.0
+Group: System/Libraries
+License: LGPLv2
+URL: https://github.com/connectivity/neardal.git
+Source0: %{name}-%{version}.tar.bz2
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: python
+BuildRequires: intltool >= %{intltool_version}
+BuildRequires: libtool
+BuildRequires: automake
+BuildRequires: autoconf
+BuildRequires: gettext
+BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
+BuildRequires: pkgconfig(dbus-glib-1)
+
+%description
+This package provides simple C APIs to exchange datas with NFC daemon (Neard) present on the system.
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+autoreconf --force --install
+
+%configure --disable-traces --prefix=/usr
+make
+
+%package dev
+Summary: Headers for neardal
+Group: Development/Libraries
+
+
+%description dev
+Development headers and libraries for neardal
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+# executed after install
+%post
+/sbin/ldconfig
+
+# executed before uninstall
+%postun
+/sbin/ldconfig
+
+# No locale
+# %%find_lang %%{name}
+# %%files -f %%{name}.lang
+
+%files
+%defattr(-,root,root,-)
+%doc README AUTHORS NEWS COPYING
+
+# libraries files
+%{neardal_dir}/libneardal.so
+%{neardal_dir}/libneardal.so.0
+%{neardal_dir}/libneardal.so.0.0.1
+
+%changelog
+
+%files dev
+# headers files
+%{neardal_inc}/*.h
+# pkg-config files
+%{neardal_pkg}/neardal.pc
+
--- /dev/null
+# >> macros
+%define neardal_dir %{_libdir}
+%define neardal_pkg %{_libdir}/pkgconfig
+%define neardal_inc %{_includedir}/neardal
+
+%define glib2_version 2.0.0
+# << macros
+
+Name: neardal
+Summary: Neard Abstraction Library (for Neard v0.7)
+Version: 0.7.0
+Release: 1.0
+Group: System/Libraries
+License: LGPLv2
+URL: https://github.com/connectivity/neardal.git
+Source0: %{name}-%{version}.tar.bz2
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: python
+BuildRequires: intltool >= %{intltool_version}
+BuildRequires: libtool
+BuildRequires: automake
+BuildRequires: autoconf
+BuildRequires: gettext
+BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
+BuildRequires: pkgconfig(dbus-glib-1)
+
+%description
+This package provides simple C APIs to exchange datas with NFC daemon (Neard) present on the system.
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+autoreconf --force --install
+
+%configure --disable-traces --prefix=/usr
+make
+
+%package dev
+Summary: Headers for neardal
+Group: Development/Libraries
+
+
+%description dev
+Development headers and libraries for neardal
+
+%package ncl
+Summary: Neardal Command Line: Simple command line interpretor for neardal/Neard
+Group: Tools
+
+
+%description ncl
+Neardal Command Line: Simple command line interpretor for neardal/Neard
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+# executed after install
+%post
+/sbin/ldconfig
+
+# executed before uninstall
+%postun
+/sbin/ldconfig
+
+# No locale
+# %%find_lang %%{name}
+# %%files -f %%{name}.lang
+
+%files
+%defattr(-,root,root,-)
+%doc README AUTHORS NEWS COPYING
+
+# libraries files
+%{neardal_dir}/libneardal.so
+%{neardal_dir}/libneardal.so.0
+%{neardal_dir}/libneardal.so.0.0.1
+
+%changelog
+
+%files dev
+# headers files
+%{neardal_inc}/*.h
+# pkg-config files
+%{neardal_pkg}/neardal.pc
+
+%files ncl
+%{_bindir}/ncl
--- /dev/null
+* Wed Aug 15 2012 Arron <arron.wang@intel.com> - 0.7
+- Init import for Tizen
--- /dev/null
+# >> macros
+%define neardal_dir %{_libdir}
+%define neardal_pkg %{_libdir}/pkgconfig
+%define neardal_inc %{_includedir}/neardal
+
+%define glib2_version 2.30.0
+# << macros
+
+Name: neardal-tizen
+Summary: Neard Abstraction Library (for Neard v0.7)
+Version: 0.7.0
+Release: 1.0
+Group: System/Libraries
+License: LGPLv2
+URL: https://github.com/connectivity/neardal.git
+Source0: %{name}-%{version}.tar.bz2
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: python
+BuildRequires: intltool >= %{intltool_version}
+BuildRequires: libtool
+BuildRequires: automake
+BuildRequires: autoconf
+BuildRequires: gettext-tools
+BuildRequires: python-xml
+BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
+BuildRequires: pkgconfig(dbus-glib-1)
+
+%description
+This package provides simple C APIs to exchange datas with NFC daemon (Neard) present on the system.
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+autoreconf --force --install
+
+%configure --disable-traces --prefix=/usr
+make
+
+%package devel
+Summary: Headers for neardal
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+
+%description devel
+Development headers and libraries for neardal
+
+%package ncl
+Summary: Neardal Command Line: Simple command line interpretor for neardal/Neard
+Group: Tools
+Requires: %{name} = %{version}-%{release}
+
+
+%description ncl
+Neardal Command Line: Simple command line interpretor for neardal/Neard
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+# executed after install
+%post
+/sbin/ldconfig
+
+# executed before uninstall
+%postun
+/sbin/ldconfig
+
+# No locale
+# %%find_lang %%{name}
+# %%files -f %%{name}.lang
+
+%files
+%defattr(-,root,root,-)
+%doc README AUTHORS NEWS COPYING
+
+# libraries files
+%{neardal_dir}/libneardal.so
+%{neardal_dir}/libneardal.so.0
+%{neardal_dir}/libneardal.so.0.0.1
+
+%changelog
+
+%files devel
+# headers files
+%{neardal_inc}/*.h
+# pkg-config files
+%{neardal_pkg}/neardal.pc
+
+%files ncl
+%{_bindir}/ncl