From 869118ce19e041f8a54a413496e8d5a473836796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <rafael.carre@savoirfairelinux.com> Date: Mon, 8 Aug 2011 15:52:41 -0400 Subject: [PATCH] Remove copy of dbus-c++ from libs/ It is packaged in most distributions --- sflphone-common/configure.ac | 47 +- sflphone-common/globals.mak | 4 +- sflphone-common/libs/Makefile.am | 2 +- sflphone-common/libs/README.dbus | 4 - sflphone-common/libs/dbus-c++/AUTHORS | 2 - sflphone-common/libs/dbus-c++/COPYING | 504 ------------ sflphone-common/libs/dbus-c++/Makefile.am | 6 - sflphone-common/libs/dbus-c++/README | 8 - .../libs/dbus-c++/data/Makefile.am | 4 - .../dbus-c++/data/org.freedesktop.DBus.xml | 90 --- .../libs/dbus-c++/include/dbus-c++/api.h | 38 - .../dbus-c++/include/dbus-c++/connection.h | 468 ------------ .../libs/dbus-c++/include/dbus-c++/dbus.h | 46 -- .../libs/dbus-c++/include/dbus-c++/debug.h | 38 - .../dbus-c++/include/dbus-c++/dispatcher.h | 314 -------- .../include/dbus-c++/ecore-integration.h | 114 --- .../libs/dbus-c++/include/dbus-c++/error.h | 285 ------- .../include/dbus-c++/eventloop-integration.h | 98 --- .../dbus-c++/include/dbus-c++/eventloop.h | 176 ----- .../include/dbus-c++/glib-integration.h | 123 --- .../dbus-c++/include/dbus-c++/interface.h | 195 ----- .../dbus-c++/include/dbus-c++/introspection.h | 86 --- .../libs/dbus-c++/include/dbus-c++/message.h | 308 -------- .../libs/dbus-c++/include/dbus-c++/object.h | 234 ------ .../dbus-c++/include/dbus-c++/pendingcall.h | 132 ---- .../libs/dbus-c++/include/dbus-c++/pipe.h | 69 -- .../libs/dbus-c++/include/dbus-c++/property.h | 102 --- .../dbus-c++/include/dbus-c++/refptr_impl.h | 46 -- .../libs/dbus-c++/include/dbus-c++/server.h | 74 -- .../libs/dbus-c++/include/dbus-c++/types.h | 500 ------------ .../libs/dbus-c++/include/dbus-c++/util.h | 297 ------- sflphone-common/libs/dbus-c++/src/Makefile.am | 47 -- .../libs/dbus-c++/src/connection.cpp | 464 ----------- .../libs/dbus-c++/src/connection_p.h | 76 -- sflphone-common/libs/dbus-c++/src/debug.cpp | 56 -- .../libs/dbus-c++/src/dispatcher.cpp | 273 ------- .../libs/dbus-c++/src/dispatcher_p.h | 57 -- .../libs/dbus-c++/src/ecore-integration.cpp | 213 ------ sflphone-common/libs/dbus-c++/src/error.cpp | 89 --- .../dbus-c++/src/eventloop-integration.cpp | 224 ------ .../libs/dbus-c++/src/eventloop.cpp | 262 ------- .../libs/dbus-c++/src/glib-integration.cpp | 314 -------- .../libs/dbus-c++/src/interface.cpp | 169 ---- .../libs/dbus-c++/src/internalerror.h | 77 -- .../libs/dbus-c++/src/introspection.cpp | 193 ----- sflphone-common/libs/dbus-c++/src/message.cpp | 642 ---------------- sflphone-common/libs/dbus-c++/src/message_p.h | 52 -- sflphone-common/libs/dbus-c++/src/object.cpp | 385 ---------- .../libs/dbus-c++/src/pendingcall.cpp | 142 ---- .../libs/dbus-c++/src/pendingcall_p.h | 54 -- sflphone-common/libs/dbus-c++/src/pipe.cpp | 84 -- .../libs/dbus-c++/src/property.cpp | 155 ---- sflphone-common/libs/dbus-c++/src/server.cpp | 129 ---- sflphone-common/libs/dbus-c++/src/server_p.h | 57 -- sflphone-common/libs/dbus-c++/src/types.cpp | 106 --- .../libs/dbus-c++/tools/Makefile.am | 28 - .../libs/dbus-c++/tools/generate_adaptor.cpp | 722 ------------------ .../libs/dbus-c++/tools/generate_adaptor.h | 32 - .../libs/dbus-c++/tools/generate_proxy.cpp | 665 ---------------- .../libs/dbus-c++/tools/generate_proxy.h | 31 - .../libs/dbus-c++/tools/generator_utils.cpp | 166 ---- .../libs/dbus-c++/tools/generator_utils.h | 46 -- .../libs/dbus-c++/tools/introspect.cpp | 79 -- .../libs/dbus-c++/tools/introspect.h | 44 -- sflphone-common/libs/dbus-c++/tools/xml.cpp | 315 -------- sflphone-common/libs/dbus-c++/tools/xml.h | 142 ---- .../libs/dbus-c++/tools/xml2cpp.cpp | 130 ---- sflphone-common/libs/dbus-c++/tools/xml2cpp.h | 37 - sflphone-common/src/Makefile.am | 4 +- sflphone-common/src/dbus/Makefile.am | 11 +- 70 files changed, 15 insertions(+), 11171 deletions(-) delete mode 100644 sflphone-common/libs/README.dbus delete mode 100644 sflphone-common/libs/dbus-c++/AUTHORS delete mode 100644 sflphone-common/libs/dbus-c++/COPYING delete mode 100644 sflphone-common/libs/dbus-c++/Makefile.am delete mode 100644 sflphone-common/libs/dbus-c++/README delete mode 100644 sflphone-common/libs/dbus-c++/data/Makefile.am delete mode 100644 sflphone-common/libs/dbus-c++/data/org.freedesktop.DBus.xml delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/api.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/connection.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/dbus.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/debug.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/dispatcher.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/ecore-integration.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/error.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop-integration.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/glib-integration.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/interface.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/introspection.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/message.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/object.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/pendingcall.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/pipe.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/property.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/refptr_impl.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/server.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/types.h delete mode 100644 sflphone-common/libs/dbus-c++/include/dbus-c++/util.h delete mode 100644 sflphone-common/libs/dbus-c++/src/Makefile.am delete mode 100644 sflphone-common/libs/dbus-c++/src/connection.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/connection_p.h delete mode 100644 sflphone-common/libs/dbus-c++/src/debug.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/dispatcher.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/dispatcher_p.h delete mode 100644 sflphone-common/libs/dbus-c++/src/ecore-integration.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/error.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/eventloop-integration.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/eventloop.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/glib-integration.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/interface.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/internalerror.h delete mode 100644 sflphone-common/libs/dbus-c++/src/introspection.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/message.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/message_p.h delete mode 100644 sflphone-common/libs/dbus-c++/src/object.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/pendingcall.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/pendingcall_p.h delete mode 100644 sflphone-common/libs/dbus-c++/src/pipe.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/property.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/server.cpp delete mode 100644 sflphone-common/libs/dbus-c++/src/server_p.h delete mode 100644 sflphone-common/libs/dbus-c++/src/types.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/Makefile.am delete mode 100644 sflphone-common/libs/dbus-c++/tools/generate_adaptor.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/generate_adaptor.h delete mode 100644 sflphone-common/libs/dbus-c++/tools/generate_proxy.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/generate_proxy.h delete mode 100644 sflphone-common/libs/dbus-c++/tools/generator_utils.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/generator_utils.h delete mode 100644 sflphone-common/libs/dbus-c++/tools/introspect.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/introspect.h delete mode 100644 sflphone-common/libs/dbus-c++/tools/xml.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/xml.h delete mode 100644 sflphone-common/libs/dbus-c++/tools/xml2cpp.cpp delete mode 100644 sflphone-common/libs/dbus-c++/tools/xml2cpp.h diff --git a/sflphone-common/configure.ac b/sflphone-common/configure.ac index cfb4df434f..63ec0cc3d0 100644 --- a/sflphone-common/configure.ac +++ b/sflphone-common/configure.ac @@ -36,10 +36,6 @@ AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([libs/Makefile \ libs/utilspp/Makefile \ libs/utilspp/singleton/Makefile \ - libs/dbus-c++/Makefile \ - libs/dbus-c++/src/Makefile \ - libs/dbus-c++/tools/Makefile \ - libs/dbus-c++/data/Makefile \ libs/iax2/Makefile]) AC_CONFIG_FILES([src/Makefile \ @@ -204,28 +200,12 @@ dnl Check for libzrtpcpp, a ccRTP extension providing zrtp key exchange LIBZRTPCPP_MIN_VERSION=1.3.0 PKG_CHECK_MODULES(ZRTPCPP, libzrtpcpp >= ${LIBZRTPCPP_MIN_VERSION},, AC_MSG_ERROR([Missing zrtp development package: libzrtpcpp-dev])) - -dnl DBus-C++ detection (used to be in library own build system) -DBUS_REQUIRED_VERSION=0.60 -PKG_CHECK_MODULES(dbus, [dbus-1 >= $DBUS_REQUIRED_VERSION],, - AC_MSG_ERROR([You need the DBus libraries (version 0.6 or better)] - [http://gitorious.org/dbus-cplusplus])) - -DBUS_API_STABLE_VERSION=1.0.0 -PKG_CHECK_EXISTS([dbus-1 < $DBUS_API_STABLE_VERSION], - [AC_DEFINE(DBUS_API_SUBJECT_TO_CHANGE, , [unstable DBus])] - ) - -DBUS_THREADS_INIT_DEFAULT_VERSION=0.93 -PKG_CHECK_EXISTS([dbus-1 >= $DBUS_THREADS_INIT_DEFAULT_VERSION], - [AC_DEFINE(DBUS_HAS_THREADS_INIT_DEFAULT, , [dbus_threads_init_default (needs DBus >= 0.93)])] - ) - -DBUS_RECURSIVE_MUTEX_VERSION=0.95 -PKG_CHECK_EXISTS([dbus-1 >= $DBUS_RECURSIVE_MUTEX_VERSION], - [AC_DEFINE(DBUS_HAS_RECURSIVE_MUTEX, , [DBus supports recursive mutexes (needs DBus >= 0.95)])] - ) - +dnl DBus-C++ detection +dnl pkg-config doesn't like 0.6.0-pre1 version number, it assumes that it is +dnl more recent than (unreleased) 0.6.0 +DBUS_CPP_REQUIRED_VERSION=0.6.0-pre1 +PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,, + AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)])) AC_ARG_WITH(debug, AS_HELP_STRING( @@ -291,21 +271,6 @@ AC_MSG_ERROR([You need the Perl-Compatible Regular Expressions library (pcre)]) AC_SUBST(PCRE_LIBS) AC_SUBST(PCRE_CFLAGS) - - - -# For the tools/, we need libdbus-c++ for the "build" architecture as well - - AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = "yes") - - AC_ARG_WITH(build-libdbus-cxx, - AS_HELP_STRING([--with-build-libdbus-cxx], - [For cross compilation: path to libdbus-cxx which was compiled for the 'build' system.]), - [ BUILD_LIBDBUS_CXX_DIR=${withval} ], - [ BUILD_LIBDBUS_CXX_DIR="\$(top_builddir)" ] - ) -AC_SUBST(BUILD_LIBDBUS_CXX_DIR) - dnl Check for libcppunit-dev CPPUNIT_MIN_VERSION=1.12 PKG_CHECK_MODULES(CPPUNIT, cppunit >= ${CPPUNIT_MIN_VERSION}, AM_CONDITIONAL(BUILD_TEST, test 1 = 1 ), AM_CONDITIONAL(BUILD_TEST, test 0 = 1 )) diff --git a/sflphone-common/globals.mak b/sflphone-common/globals.mak index 2f9056b08f..365e49dc1c 100644 --- a/sflphone-common/globals.mak +++ b/sflphone-common/globals.mak @@ -33,8 +33,6 @@ SIP_CFLAGS=-I$(src)/libs/pjproject/pjsip/include \ -I$(src)/libs/pjproject/pjmedia/include \ -I$(src)/libs/pjproject/pjnath/include -DBUSCPP_CFLAGS=$(top_srcdir)/libs/dbus-c++/include/dbus-c++ - if BUILD_SPEEX SPEEXCODEC=-DHAVE_SPEEX_CODEC else @@ -50,13 +48,13 @@ endif # Preprocessor flags AM_CPPFLAGS = \ -I$(src)/libs \ - -I$(src)/libs/dbus-c++/include \ -I$(src)/libs/iax2 \ -I$(src)/libs/pjproject \ -I$(src)/src \ -I$(src)/src/config \ -I$(src)/test \ $(SIP_CFLAGS) \ + @DBUSCPP_CFLAGS@ \ -DPREFIX=\"$(prefix)\" \ -DPROGSHAREDIR=\"${datadir}/sflphone\" \ -DCODECS_DIR=\""$(sflcodecdir)"\" \ diff --git a/sflphone-common/libs/Makefile.am b/sflphone-common/libs/Makefile.am index eb4a6b9b9a..b88a3bf3f9 100644 --- a/sflphone-common/libs/Makefile.am +++ b/sflphone-common/libs/Makefile.am @@ -1 +1 @@ -SUBDIRS = utilspp iax2 dbus-c++ +SUBDIRS = utilspp iax2 diff --git a/sflphone-common/libs/README.dbus b/sflphone-common/libs/README.dbus deleted file mode 100644 index 10d8d54a4d..0000000000 --- a/sflphone-common/libs/README.dbus +++ /dev/null @@ -1,4 +0,0 @@ -Fetched from (30 septembre 2008): - -git clone git://anongit.freedesktop.org/git/dbus/dbus-c++/ - diff --git a/sflphone-common/libs/dbus-c++/AUTHORS b/sflphone-common/libs/dbus-c++/AUTHORS deleted file mode 100644 index 87435a48c6..0000000000 --- a/sflphone-common/libs/dbus-c++/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Paolo Durante <shackan@gmail.com> -Andreas Volz <andreas.volz@tux-style.com> diff --git a/sflphone-common/libs/dbus-c++/COPYING b/sflphone-common/libs/dbus-c++/COPYING deleted file mode 100644 index 5ab7695ab8..0000000000 --- a/sflphone-common/libs/dbus-c++/COPYING +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 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 Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - 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 Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -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 other code 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. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - 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, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser 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. - - 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. - - 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. - - 6. As an exception to the Sections above, you may also combine 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) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) 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. - - d) 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. - - e) 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 materials to be 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. - - 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 with -this License. - - 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 Lesser 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. - - 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 - - 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser 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! - - diff --git a/sflphone-common/libs/dbus-c++/Makefile.am b/sflphone-common/libs/dbus-c++/Makefile.am deleted file mode 100644 index 6e4fa0f138..0000000000 --- a/sflphone-common/libs/dbus-c++/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS = src tools data - -MAINTAINERCLEANFILES = \ - Makefile.in - - diff --git a/sflphone-common/libs/dbus-c++/README b/sflphone-common/libs/dbus-c++/README deleted file mode 100644 index 54a041d893..0000000000 --- a/sflphone-common/libs/dbus-c++/README +++ /dev/null @@ -1,8 +0,0 @@ -Debugging ---------- -To compile debugging code configure the project with the --enable-debug option. Then at runtime you may set the environment variable "DBUSXX_VERBOSE=1" to activate debugging and to '0' to deactivate debugging. - - -BUGS: ------ -test diff --git a/sflphone-common/libs/dbus-c++/data/Makefile.am b/sflphone-common/libs/dbus-c++/data/Makefile.am deleted file mode 100644 index 23df86ec8d..0000000000 --- a/sflphone-common/libs/dbus-c++/data/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -EXTRA_DIST = org.freedesktop.DBus.xml - -MAINTAINERCLEANFILES = \ - Makefile.in diff --git a/sflphone-common/libs/dbus-c++/data/org.freedesktop.DBus.xml b/sflphone-common/libs/dbus-c++/data/org.freedesktop.DBus.xml deleted file mode 100644 index cbb38abfff..0000000000 --- a/sflphone-common/libs/dbus-c++/data/org.freedesktop.DBus.xml +++ /dev/null @@ -1,90 +0,0 @@ -<!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.freedesktop.DBus.Introspectable"> - <method name="Introspect"> - <arg name="data" direction="out" type="s"/> - </method> - </interface> - <interface name="org.freedesktop.DBus.Properties"> - <method name="Get"> - <arg name="interface_name" direction="in" type="s"/> - <arg name="property_name" direction="in" type="s"/> - <arg name="value" direction="out" type="v"/> - </method> - <method name="Set"> - <arg name="interface_name" direction="in" type="s"/> - <arg name="property_name" direction="in" type="s"/> - <arg name="value" direction="in" type="v"/> - </method> - <method name="GetAll"> - <arg name="interface_name" direction="in" type="s"/> - <arg name="props" direction="out" type="a{sv}"/> - </method> - </interface> - <interface name="org.freedesktop.DBus"> - <method name="RequestName"> - <arg direction="in" type="s"/> - <arg direction="in" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="ReleaseName"> - <arg direction="in" type="s"/> - <arg direction="out" type="u"/> - </method> - <method name="StartServiceByName"> - <arg direction="in" type="s"/> - <arg direction="in" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="Hello"> - <arg direction="out" type="s"/> - </method> - <method name="NameHasOwner"> - <arg direction="in" type="s"/> - <arg direction="out" type="b"/> - </method> - <method name="ListNames"> - <arg direction="out" type="as"/> - </method> - <method name="AddMatch"> - <arg direction="in" type="s"/> - </method> - <method name="RemoveMatch"> - <arg direction="in" type="s"/> - </method> - <method name="GetNameOwner"> - <arg direction="in" type="s"/> - <arg direction="out" type="s"/> - </method> - <method name="ListQueuedOwners"> - <arg direction="in" type="s"/> - <arg direction="out" type="as"/> - </method> - <method name="GetConnectionUnixUser"> - <arg direction="in" type="s"/> - <arg direction="out" type="u"/> - </method> - <method name="GetConnectionUnixProcessID"> - <arg direction="in" type="s"/> - <arg direction="out" type="u"/> - </method> - <method name="GetConnectionSELinuxSecurityContext"> - <arg direction="in" type="s"/> - <arg direction="out" type="ay"/> - </method> - <method name="ReloadConfig"> - </method> - <signal name="NameOwnerChanged"> - <arg type="s"/> - <arg type="s"/> - <arg type="s"/> - </signal> - <signal name="NameLost"> - <arg type="s"/> - </signal> - <signal name="NameAcquired"> - <arg type="s"/> - </signal> - </interface> -</node> diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/api.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/api.h deleted file mode 100644 index 48904e81b0..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/api.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_API_H -#define __DBUSXX_API_H - -#ifdef GCC_HASCLASSVISIBILITY -# define DXXAPILOCAL __attribute__ ((visibility("hidden"))) -# define DXXAPIPUBLIC __attribute__ ((visibility("default"))) -#else -# define DXXAPILOCAL -# define DXXAPIPUBLIC -#endif - -#define DXXAPI DXXAPIPUBLIC - -#endif//__DBUSXX_API_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/connection.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/connection.h deleted file mode 100644 index 3f8aaf61da..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/connection.h +++ /dev/null @@ -1,468 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_CONNECTION_H -#define __DBUSXX_CONNECTION_H - -#include <list> - -#include "api.h" -#include "types.h" -#include "util.h" -#include "message.h" -#include "pendingcall.h" - -namespace DBus { - -class Connection; - -typedef Slot<bool, const Message&> MessageSlot; - -typedef std::list<Connection> ConnectionList; - -class ObjectAdaptor; -class Dispatcher; - -class DXXAPI Connection -{ -public: - - static Connection SystemBus(); - - static Connection SessionBus(); - - static Connection ActivationBus(); - - struct Private; - - typedef std::list<Private*> PrivatePList; - - Connection( Private* ); - - Connection( const char* address, bool priv = true ); - - Connection( const Connection& c ); - - virtual ~Connection(); - - Dispatcher* setup( Dispatcher* ); - - bool operator == ( const Connection& ) const; - - /*! - * \brief Adds a match rule to match messages going through the message bus. - * - * The "rule" argument is the string form of a match rule. - * - * If you pass NULL for the error, this function will not block; the match - * thus won't be added until you flush the connection, and if there's an error - * adding the match (only possible error is lack of resources in the bus), you - * won't find out about it. - * - * Normal API conventions would have the function return a boolean value - * indicating whether the error was set, but that would require blocking always - * to determine the return value. - * - * The AddMatch method is fully documented in the D-Bus specification. For - * quick reference, the format of the match rules is discussed here, but the - * specification is the canonical version of this information. - * - * Rules are specified as a string of comma separated key/value pairs. An - * example is "type='signal',sender='org.freedesktop.DBus', - * interface='org.freedesktop.DBus',member='Foo', path='/bar/foo',destination=':452345.34'" - * - * Possible keys you can match on are type, sender, interface, member, path, - * destination and numbered keys to match message args (keys are 'arg0', 'arg1', etc.). - * Omitting a key from the rule indicates a wildcard match. For instance omitting - * the member from a match rule but adding a sender would let all messages from - * that sender through regardless of the member. - * - * Matches are inclusive not exclusive so as long as one rule matches the - * message will get through. It is important to note this because every time a - * essage is received the application will be paged into memory to process it. - * This can cause performance problems such as draining batteries on embedded platforms. - * - * If you match message args ('arg0', 'arg1', and so forth) only string arguments - * will match. That is, arg0='5' means match the string "5" not the integer 5. - * - * Currently there is no way to match against non-string arguments. - * - * Matching on interface is tricky because method call messages only optionally - * specify the interface. If a message omits the interface, then it will NOT - * match if the rule specifies an interface name. This means match rules on - * method calls should not usually give an interface. - * - * However, signal messages are required to include the interface so when - * matching signals usually you should specify the interface in the match rule. - * - * For security reasons, you can match arguments only up to DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER. - * - * Match rules have a maximum length of DBUS_MAXIMUM_MATCH_RULE_LENGTH bytes. - * - * Both of these maximums are much higher than you're likely to need, they only - * exist because the D-Bus bus daemon has fixed limits on all resource usage. - * - * \param rule Textual form of match rule. - * \throw Error - */ - void add_match( const char* rule ); - - /*! - * \brief Removes a previously-added match rule "by value" (the most - * recently-added identical rule gets removed). - * - * The "rule" argument is the string form of a match rule. - * - * The bus compares match rules semantically, not textually, so whitespace and - * ordering don't have to be identical to the rule you passed to add_match(). - * - * \param rule Textual form of match rule. - * \throw Error - */ - void remove_match( const char* rule ); - - /*! - * \brief Adds a message filter. - * - * Filters are handlers that are run on all incoming messages, prior to the - * objects registered with ObjectAdaptor::register_obj(). Filters are - * run in the order that they were added. The same handler can be added as a - * filter more than once, in which case it will be run more than once. Filters - * added during a filter callback won't be run on the message being processed. - * - * \param s The MessageSlot to add. - */ - bool add_filter( MessageSlot& s); - - /*! - * \brief Removes a previously-added message filter. - * - * It is a programming error to call this function for a handler that has not - * been added as a filter. If the given handler was added more than once, only - * one instance of it will be removed (the most recently-added instance). - * - * \param s The MessageSlot to remove. - */ - void remove_filter( MessageSlot& s); - - /*! - * \brief Sets the unique name of the connection, as assigned by the message bus. - * - * Can only be used if you registered with the bus manually (i.e. if you did - * not call register_bus()). Can only be called once per connection. After - * the unique name is set, you can get it with unique_name(void). - * - * The only reason to use this function is to re-implement the equivalent of - * register_bus() yourself. One (probably unusual) reason to do that might - * be to do the bus registration call asynchronously instead of synchronously. - * - * \note Just use dbus_bus_get() or dbus_bus_get_private(), or worst case - * register_bus(), instead of messing with this function. There's - * really no point creating pain for yourself by doing things manually. - * (Not sure if this is yet wrapped.) - * - * It's hard to use this function safely on shared connections (created by - * Connection()) in a multithreaded application, because only one - * registration attempt can be sent to the bus. If two threads are both - * sending the registration message, there is no mechanism in libdbus itself - * to avoid sending it twice. - * - * Thus, you need a way to coordinate which thread sends the registration - * attempt; which also means you know which thread will call - * unique_name(const char*). If you don't know about all threads in the app - * (for example, if some libraries you're using might start libdbus-using - * threads), then you need to avoid using this function on shared connections. - * - * \param n The unique name. - */ - bool unique_name( const char* n ); - - /*! - * \brief Gets the unique name of the connection as assigned by the message bus. - * - * Only possible after the connection has been registered with the message bus. - * All connections returned by dbus_bus_get() or dbus_bus_get_private() have - * been successfully registered. (Not sure if this is yet wrapped.) - * - * The name remains valid until the connection is freed, and should not be - * freed by the caller. - * - * Other than dbus_bus_get(), there are two ways to set the unique name; one - * is register_bus(), the other is unique_name(const char*). You are - * responsible for calling unique_name(const char*) if you register by hand - * instead of using register_bus(). - */ - const char* unique_name() const; - - /*! - * \brief Registers a connection with the bus. - * - * This must be the first thing an application does when connecting to the - * message bus. If registration succeeds, the unique name will be set, and - * can be obtained using unique_name(void). - * - * This function will block until registration is complete. - * - * If the connection has already registered with the bus (determined by - * checking whether unique_name(void) returns a non-NULL value), - * then this function does nothing. - * - * If you use dbus_bus_get() or dbus_bus_get_private() this function will be - * called for you. (Not sure if this is yet wrapped.) - * - * \note Just use dbus_bus_get() or dbus_bus_get_private() instead of - * register_bus() and save yourself some pain. Using register_bus() - * manually is only useful if you have your own custom message bus not found - * in DBusBusType. - * - * If you open a bus connection by the contructor of Connection() you will have to register_bus() - * yourself, or make the appropriate registration method calls yourself. If - * you send the method calls yourself, call unique_name(const char*) with - * the unique bus name you get from the bus. - * - * For shared connections (created with dbus_connection_open()) in a - * multithreaded application, you can't really make the registration calls - * yourself, because you don't know whether some other thread is also - * registering, and the bus will kick you off if you send two registration - * messages. (TODO: how is this done in the wrapper?) - * - * If you use register_bus() however, there is a lock that keeps both - * apps from registering at the same time. - * - * The rule in a multithreaded app, then, is that register_bus() must be - * used to register, or you need to have your own locks that all threads in - * the app will respect. - * - * In a single-threaded application you can register by hand instead of using - * register_bus(), as long as you check unique_name(void) to - * see if a unique name has already been stored by another thread before you - * send the registration messages. - */ - bool register_bus(); - - /*! - * \brief Gets whether the connection is currently open. - * - * A connection may become disconnected when the remote application closes its - * end, or exits; a connection may also be disconnected with disconnect(). - * - * There are not separate states for "closed" and "disconnected," the two - * terms are synonymous. - * - * \return true If the connection is still alive. - */ - bool connected() const; - - /*! - * \brief Closes a private connection, so no further data can be sent or received. - * - * This disconnects the transport (such as a socket) underlying the connection. - * - * Attempts to send messages after closing a connection are safe, but will - * result in error replies generated locally in libdbus. - * - * This function does not affect the connection's reference count. It's safe - * to close a connection more than once; all calls after the first do nothing. - * It's impossible to "reopen" a connection, a new connection must be created. - * This function may result in a call to the DBusDispatchStatusFunction set - * with Private::init(), as the disconnect - * message it generates needs to be dispatched. - * - * If a connection is dropped by the remote application, it will close itself. - * - * You must close a connection prior to releasing the last reference to the - * connection. - * - * You may not close a shared connection. Connections created with - * dbus_connection_open() or dbus_bus_get() are shared. These connections are - * owned by libdbus, and applications should only unref them, never close them. - * Applications can know it is safe to unref these connections because libdbus - * will be holding a reference as long as the connection is open. Thus, either - * the connection is closed and it is OK to drop the last reference, or the - * connection is open and the app knows it does not have the last reference. - * - * Connections created with dbus_connection_open_private() or - * dbus_bus_get_private() are not kept track of or referenced by libdbus. - * The creator of these connections is responsible for calling - * dbus_connection_close() prior to releasing the last reference, if the - * connection is not already disconnected. - * - * \todo dbus_connection_disconnect() was removed in dbus 0.9x. Maybe this - * function should be renamed to close(). - */ - void disconnect(); - - /*! - * \brief Set whether _exit() should be called when the connection receives a - * disconnect signal. - * - * The call to _exit() comes after any handlers for the disconnect signal run; - * handlers can cancel the exit by calling this function. - * - * By default, exit_on_disconnect is false; but for message bus connections - * returned from dbus_bus_get() it will be toggled on by default. - * - * \param exit true If _exit() should be called after a disconnect signal. - */ - void exit_on_disconnect( bool exit ); - - /*! - * \brief Blocks until the outgoing message queue is empty. - */ - void flush(); - - /*! - * \brief Adds a message to the outgoing message queue. - * - * Does not block to write the message to the network; that happens - * asynchronously. To force the message to be written, call - * dbus_connection_flush(). Because this only queues the message, the only - * reason it can fail is lack of memory. Even if the connection is disconnected, - * no error will be returned. - * - * If the function fails due to lack of memory, it returns FALSE. The function - * will never fail for other reasons; even if the connection is disconnected, - * you can queue an outgoing message, though obviously it won't be sent. - * - * The message serial is used by the remote application to send a reply; see - * Message::serial() or the D-Bus specification. - * - * \param msg The Message to write. - * \param serial Return location for message serial, or NULL if you don't care. - * \return true On success. - */ - bool send( const Message& msg, unsigned int* serial = NULL ); - - /*! - * \brief Sends a message and blocks a certain time period while waiting for a reply. - * - * This function does not reenter the main loop, i.e. messages other than the - * reply are queued up but not processed. This function is used to invoke - * method calls on a remote object. - * - * If a normal reply is received, it is returned, and removed from the - * incoming message queue. If it is not received, NULL is returned and the - * error is set to DBUS_ERROR_NO_REPLY. If an error reply is received, it is - * converted to a DBusError and returned as an error, then the reply message - * is deleted and NULL is returned. If something else goes wrong, result is - * set to whatever is appropriate, such as DBUS_ERROR_NO_MEMORY or DBUS_ERROR_DISCONNECTED. - * - * \warning While this function blocks the calling thread will not be - * processing the incoming message queue. This means you can end up - * deadlocked if the application you're talking to needs you to reply - * to a method. To solve this, either avoid the situation, block in a - * separate thread from the main connection-dispatching thread, or - * use PendingCall to avoid blocking. - * - * \param msg The Message to write. - * \param timeout Timeout in milliseconds (omit for default). - * \throw Error - */ - Message send_blocking( Message& msg, int timeout = -1); - - /*! - * \brief Queues a message to send, as with send(), but also - * returns a DBusPendingCall used to receive a reply to the message. - * - * If no reply is received in the given timeout_milliseconds, this function - * expires the pending reply and generates a synthetic error reply (generated - * in-process, not by the remote application) indicating that a timeout occurred. - * - * A PendingCall will see a reply message before any filters or registered - * object path handlers. See Connection::Private::do_dispatch() in dbus documentation - * for details on when handlers are run. (here: Connection::Private::do_dispatch()) - * - * A PendingCall will always see exactly one reply message, unless it's - * cancelled with PendingCall::cancel(). - * - * If -1 is passed for the timeout, a sane default timeout is used. -1 is - * typically the best value for the timeout for this reason, unless you want - * a very short or very long timeout. There is no way to avoid a timeout - * entirely, other than passing INT_MAX for the timeout to mean "very long - * timeout." libdbus clamps an INT_MAX timeout down to a few hours timeout though. - * - * \param msg The Message to write. - * \param timeout Timeout in milliseconds (omit for default). - * \throw ErrorNoMemory - */ - PendingCall send_async( Message& msg, int timeout = -1); - - void request_name( const char* name, int flags = 0 ); - - unsigned long sender_unix_uid(const char *sender); - - /*! - * \brief Asks the bus whether a certain name has an owner. - * - * Using this can easily result in a race condition, since an owner can appear - * or disappear after you call this. - * - * If you want to request a name, just request it; if you want to avoid - * replacing a current owner, don't specify DBUS_NAME_FLAG_REPLACE_EXISTING - * and you will get an error if there's already an owner. - * - * \param name The name. - * \throw Error - */ - bool has_name( const char* name ); - - /*! - * \brief Starts a service that will request ownership of the given name. - * - * The returned result will be one of be one of DBUS_START_REPLY_SUCCESS or - * DBUS_START_REPLY_ALREADY_RUNNING if successful. Pass NULL if you don't - * care about the result. - * - * The flags parameter is for future expansion, currently you should specify 0. - * - * It's often easier to avoid explicitly starting services, and just send a - * method call to the service's bus name instead. Method calls start a service - * to handle them by default unless you call dbus_message_set_auto_start() to - * disable this behavior. - * - * \todo dbus_message_set_auto_start() not yet wrapped! - */ - bool start_service( const char* name, unsigned long flags ); - - const std::vector<std::string>& names(); - - void set_timeout(int timeout); - - int get_timeout(); - -private: - - DXXAPILOCAL void init(); - -private: - - RefPtrI<Private> _pvt; - int _timeout; - -friend class ObjectAdaptor; // needed in order to register object paths for a connection -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_CONNECTION_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/dbus.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/dbus.h deleted file mode 100644 index 80893cb739..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/dbus.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_DBUS_H -#define __DBUSXX_DBUS_H - -#include "types.h" -#include "interface.h" -#include "object.h" -#include "property.h" -#include "connection.h" -#include "server.h" -#include "error.h" -#include "message.h" -#include "debug.h" -#include "pendingcall.h" -#include "server.h" -#include "util.h" -#include "dispatcher.h" -#include "eventloop.h" -#include "eventloop-integration.h" -#include "introspection.h" -#include "pipe.h" - -#endif//__DBUSXX_DBUS_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/debug.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/debug.h deleted file mode 100644 index e66c79b3cf..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/debug.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_DEBUG_H -#define __DBUSXX_DEBUG_H - -#include "api.h" - -namespace DBus { - -typedef void (*LogFunction)(const char *format, ...); - -extern DXXAPI LogFunction debug_log; - -} /* namespace DBus */ - -#endif diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/dispatcher.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/dispatcher.h deleted file mode 100644 index 728f9d82f5..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/dispatcher.h +++ /dev/null @@ -1,314 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_DISPATCHER_H -#define __DBUSXX_DISPATCHER_H - -#include "api.h" -#include "connection.h" -#include "eventloop.h" - -namespace DBus { - -class DXXAPI Timeout -{ -public: - - class Internal; - - Timeout(Internal *i); - - virtual ~Timeout(){} - - /*! - * \brief Gets the timeout interval. - * - * The handle() should be called each time this interval elapses, - * starting after it elapses once. - * - * The interval may change during the life of the timeout; if so, the timeout - * will be disabled and re-enabled (calling the "timeout toggled function") to - * notify you of the change. - * - * return The interval in miliseconds. - */ - int interval() const; - - bool enabled() const; - - /*! - * \brief Calls the timeout handler for this timeout. - * - * This function should be called when the timeout occurs. - * - * If this function returns FALSE, then there wasn't enough memory to handle - * the timeout. Typically just letting the timeout fire again next time it - * naturally times out is an adequate response to that problem, but you could - * try to do more if you wanted. - * - * return false If there wasn't enough memory. - */ - bool handle(); - - virtual void toggle() = 0; - -private: - - DXXAPILOCAL Timeout(const Timeout &); - -private: - - Internal *_int; -}; - -class DXXAPI Watch -{ -public: - - class Internal; - - Watch(Internal *i); - - virtual ~Watch(){} - - /*! - * \brief A main loop could poll this descriptor to integrate dbus-c++. - * - * This function calls dbus_watch_get_socket() on win32 and - * dbus_watch_get_unix_fd() on all other systems. (see dbus documentation) - * - * @return The file descriptor. - */ - int descriptor() const; - - /*! - * \brief Gets flags from DBusWatchFlags indicating what conditions should be - * monitored on the file descriptor. - * - * The flags returned will only contain DBUS_WATCH_READABLE and DBUS_WATCH_WRITABLE, - * never DBUS_WATCH_HANGUP or DBUS_WATCH_ERROR; all watches implicitly include - * a watch for hangups, errors, and other exceptional conditions. - * - * @return The conditions to watch. - */ - int flags() const; - - bool enabled() const; - - /*! - * \brief Called to notify the D-Bus library when a previously-added watch - * is ready for reading or writing, or has an exception such as a hangup. - * - * If this function returns FALSE, then the file descriptor may still be - * ready for reading or writing, but more memory is needed in order to do the - * reading or writing. If you ignore the FALSE return, your application may - * spin in a busy loop on the file descriptor until memory becomes available, - * but nothing more catastrophic should happen. - * - * dbus_watch_handle() cannot be called during the DBusAddWatchFunction, as the - * connection will not be ready to handle that watch yet. - * - * It is not allowed to reference a DBusWatch after it has been passed to remove_function. - * - * @param flags The poll condition using DBusWatchFlags values. - * @return false If there wasn't enough memory. - */ - bool handle(int flags); - - virtual void toggle() = 0; - -private: - - DXXAPILOCAL Watch(const Watch &); - -private: - - Internal *_int; -}; - -class DXXAPI Dispatcher -{ -public: - - virtual ~Dispatcher() - {} - - void queue_connection(Connection::Private *); - - void dispatch_pending(); - bool has_something_to_dispatch(); - - virtual void enter() = 0; - - virtual void leave() = 0; - - virtual Timeout *add_timeout(Timeout::Internal *) = 0; - - virtual void rem_timeout(Timeout *) = 0; - - virtual Watch *add_watch(Watch::Internal *) = 0; - - virtual void rem_watch(Watch *) = 0; - - struct Private; - -private: - - DefaultMutex _mutex_p; - Connection::PrivatePList _pending_queue; -}; - -extern DXXAPI Dispatcher *default_dispatcher; - -/* classes for multithreading support -*/ - -class DXXAPI Mutex -{ -public: - - virtual ~Mutex() {} - - virtual void lock() = 0; - - virtual void unlock() = 0; - - struct Internal; - -protected: - - Internal *_int; -}; - -class DXXAPI CondVar -{ -public: - - virtual ~CondVar() {} - - virtual void wait(Mutex *) = 0; - - virtual bool wait_timeout(Mutex *, int timeout) = 0; - - virtual void wake_one() = 0; - - virtual void wake_all() = 0; - - struct Internal; - -protected: - - Internal *_int; -}; - -typedef Mutex *(*MutexNewFn)(); -typedef void (*MutexUnlockFn)(Mutex *mx); - -#ifndef DBUS_HAS_RECURSIVE_MUTEX -typedef bool (*MutexFreeFn)(Mutex *mx); -typedef bool (*MutexLockFn)(Mutex *mx); -#else -typedef void (*MutexFreeFn)(Mutex *mx); -typedef void (*MutexLockFn)(Mutex *mx); -#endif//DBUS_HAS_RECURSIVE_MUTEX - -typedef CondVar *(*CondVarNewFn)(); -typedef void (*CondVarFreeFn)(CondVar *cv); -typedef void (*CondVarWaitFn)(CondVar *cv, Mutex *mx); -typedef bool (*CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout); -typedef void (*CondVarWakeOneFn)(CondVar *cv); -typedef void (*CondVarWakeAllFn)(CondVar *cv); - -void DXXAPI _init_threading(); - -void DXXAPI _init_threading( - MutexNewFn, MutexFreeFn, MutexLockFn, MutexUnlockFn, - CondVarNewFn, CondVarFreeFn, CondVarWaitFn, CondVarWaitTimeoutFn, CondVarWakeOneFn, CondVarWakeAllFn -); - -template<class Mx, class Cv> -struct Threading -{ - static void init() - { - _init_threading( - mutex_new, mutex_free, mutex_lock, mutex_unlock, - condvar_new, condvar_free, condvar_wait, condvar_wait_timeout, condvar_wake_one, condvar_wake_all - ); - } - - static Mutex *mutex_new() - { - return new Mx; - } - - static void mutex_free(Mutex *mx) - { - delete mx; - } - - static void mutex_lock(Mutex *mx) - { - mx->lock(); - } - - static void mutex_unlock(Mutex *mx) - { - mx->unlock(); - } - - static CondVar *condvar_new() - { - return new Cv; - } - - static void condvar_free(CondVar *cv) - { - delete cv; - } - - static void condvar_wait(CondVar *cv, Mutex *mx) - { - cv->wait(mx); - } - - static bool condvar_wait_timeout(CondVar *cv, Mutex *mx, int timeout) - { - return cv->wait_timeout(mx, timeout); - } - - static void condvar_wake_one(CondVar *cv) - { - cv->wake_one(); - } - - static void condvar_wake_all(CondVar *cv) - { - cv->wake_all(); - } -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_DISPATCHER_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/ecore-integration.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/ecore-integration.h deleted file mode 100644 index 2b14b27853..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/ecore-integration.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_ECORE_INTEGRATION_H -#define __DBUSXX_ECORE_INTEGRATION_H - -#include <Ecore.h> - -#include "api.h" -#include "dispatcher.h" -#include "Ecore.h" - -namespace DBus { - -namespace Ecore { - -class BusDispatcher; - -class DXXAPI BusTimeout : public Timeout -{ -private: - - BusTimeout( Timeout::Internal*); - - ~BusTimeout(); - - void toggle(); - - static Eina_Bool timeout_handler( void* ); - - void _enable(); - - void _disable(); - -private: - Ecore_Timer *_etimer; - -friend class BusDispatcher; -}; - -class DXXAPI BusWatch : public Watch -{ -private: - - BusWatch( Watch::Internal*); - - ~BusWatch(); - - void toggle(); - - static Eina_Bool watch_handler_read ( void*, Ecore_Fd_Handler *fdh); - - static Eina_Bool watch_handler_error ( void*, Ecore_Fd_Handler *fdh); - - void _enable(); - - void _disable(); - -private: - Ecore_Fd_Handler *fd_handler_read; - Ecore_Fd_Handler *fd_handler_error; - -friend class BusDispatcher; -}; - -class DXXAPI BusDispatcher : public Dispatcher -{ -public: - BusDispatcher() {} - - void attach(); - - void enter() {} - - void leave() {} - - Timeout* add_timeout( Timeout::Internal* ); - - void rem_timeout( Timeout* ); - - Watch* add_watch( Watch::Internal* ); - - void rem_watch( Watch* ); - -private: - -}; - -} /* namespace Ecore */ - -} /* namespace DBus */ - -#endif//__DBUSXX_ECORE_INTEGRATION_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/error.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/error.h deleted file mode 100644 index 7dec7bfe72..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/error.h +++ /dev/null @@ -1,285 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_ERROR_H -#define __DBUSXX_ERROR_H - -#include "api.h" -#include "util.h" - -#include <exception> - -namespace DBus { - -class Message; -class InternalError; - -class DXXAPI Error : public std::exception -{ -public: - - Error(); - - Error(InternalError &); - - Error(const char *name, const char *message); - - Error(Message &); - - ~Error() throw(); - - const char *what() const throw(); - - const char *name() const; - - const char *message() const; - - void set(const char *name, const char *message); - // parameters MUST be static strings - - bool is_set() const; - - operator bool() const - { - return is_set(); - } - -private: - - RefPtrI<InternalError> _int; -}; - -struct DXXAPI ErrorFailed : public Error -{ - ErrorFailed(const char *message) - : Error("org.freedesktop.DBus.Error.Failed", message) - {} -}; - -struct DXXAPI ErrorNoMemory : public Error -{ - ErrorNoMemory(const char *message) - : Error("org.freedesktop.DBus.Error.NoMemory", message) - {} -}; - -struct DXXAPI ErrorServiceUnknown : public Error -{ - ErrorServiceUnknown(const char *message) - : Error("org.freedesktop.DBus.Error.ServiceUnknown", message) - {} -}; - -struct DXXAPI ErrorNameHasNoOwner : public Error -{ - ErrorNameHasNoOwner(const char *message) - : Error("org.freedesktop.DBus.Error.NameHasNoOwner", message) - {} -}; - -struct DXXAPI ErrorNoReply : public Error -{ - ErrorNoReply(const char *message) - : Error("org.freedesktop.DBus.Error.NoReply", message) - {} -}; - -struct DXXAPI ErrorIOError : public Error -{ - ErrorIOError(const char *message) - : Error("org.freedesktop.DBus.Error.IOError", message) - {} -}; - -struct DXXAPI ErrorBadAddress : public Error -{ - ErrorBadAddress(const char *message) - : Error("org.freedesktop.DBus.Error.BadAddress", message) - {} -}; - -struct DXXAPI ErrorNotSupported : public Error -{ - ErrorNotSupported(const char *message) - : Error("org.freedesktop.DBus.Error.NotSupported", message) - {} -}; - -struct DXXAPI ErrorLimitsExceeded : public Error -{ - ErrorLimitsExceeded(const char *message) - : Error("org.freedesktop.DBus.Error.LimitsExceeded", message) - {} -}; - -struct DXXAPI ErrorAccessDenied : public Error -{ - ErrorAccessDenied(const char *message) - : Error("org.freedesktop.DBus.Error.AccessDenied", message) - {} -}; - -struct DXXAPI ErrorAuthFailed : public Error -{ - ErrorAuthFailed(const char *message) - : Error("org.freedesktop.DBus.Error.AuthFailed", message) - {} -}; - -struct DXXAPI ErrorNoServer : public Error -{ - ErrorNoServer(const char *message) - : Error("org.freedesktop.DBus.Error.NoServer", message) - {} -}; - -struct DXXAPI ErrorTimeout : public Error -{ - ErrorTimeout(const char *message) - : Error("org.freedesktop.DBus.Error.Timeout", message) - {} -}; - -struct DXXAPI ErrorNoNetwork : public Error -{ - ErrorNoNetwork(const char *message) - : Error("org.freedesktop.DBus.Error.NoNetwork", message) - {} -}; - -struct DXXAPI ErrorAddressInUse : public Error -{ - ErrorAddressInUse(const char *message) - : Error("org.freedesktop.DBus.Error.AddressInUse", message) - {} -}; - -struct DXXAPI ErrorDisconnected : public Error -{ - ErrorDisconnected(const char *message) - : Error("org.freedesktop.DBus.Error.Disconnected", message) - {} -}; - -struct DXXAPI ErrorInvalidArgs : public Error -{ - ErrorInvalidArgs(const char *message) - : Error("org.freedesktop.DBus.Error.InvalidArgs", message) - {} -}; - -struct DXXAPI ErrorFileNotFound : public Error -{ - ErrorFileNotFound(const char *message) - : Error("org.freedesktop.DBus.Error.FileNotFound", message) - {} -}; - -struct DXXAPI ErrorUnknownMethod : public Error -{ - ErrorUnknownMethod(const char *message) - : Error("org.freedesktop.DBus.Error.UnknownMethod", message) - {} -}; - -struct DXXAPI ErrorTimedOut : public Error -{ - ErrorTimedOut(const char *message) - : Error("org.freedesktop.DBus.Error.TimedOut", message) - {} -}; - -struct DXXAPI ErrorMatchRuleNotFound : public Error -{ - ErrorMatchRuleNotFound(const char *message) - : Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message) - {} -}; - -struct DXXAPI ErrorMatchRuleInvalid : public Error -{ - ErrorMatchRuleInvalid(const char *message) - : Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message) - {} -}; - -struct DXXAPI ErrorSpawnExecFailed : public Error -{ - ErrorSpawnExecFailed(const char *message) - : Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message) - {} -}; - -struct DXXAPI ErrorSpawnForkFailed : public Error -{ - ErrorSpawnForkFailed(const char *message) - : Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message) - {} -}; - -struct DXXAPI ErrorSpawnChildExited : public Error -{ - ErrorSpawnChildExited(const char *message) - : Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message) - {} -}; - -struct DXXAPI ErrorSpawnChildSignaled : public Error -{ - ErrorSpawnChildSignaled(const char *message) - : Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message) - {} -}; - -struct DXXAPI ErrorSpawnFailed : public Error -{ - ErrorSpawnFailed(const char *message) - : Error("org.freedesktop.DBus.Error.Spawn.Failed", message) - {} -}; - -struct DXXAPI ErrorInvalidSignature : public Error -{ - ErrorInvalidSignature(const char *message) - : Error("org.freedesktop.DBus.Error.InvalidSignature", message) - {} -}; - -struct DXXAPI ErrorUnixProcessIdUnknown : public Error -{ - ErrorUnixProcessIdUnknown(const char *message) - : Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message) - {} -}; - -struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error -{ - ErrorSELinuxSecurityContextUnknown(const char *message) - : Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message) - {} -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_ERROR_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop-integration.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop-integration.h deleted file mode 100644 index 0459ebf3d7..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop-integration.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_EVENTLOOP_INTEGRATION_H -#define __DBUSXX_EVENTLOOP_INTEGRATION_H - -#include <errno.h> -#include "api.h" -#include "dispatcher.h" -#include "util.h" -#include "eventloop.h" - -namespace DBus { - -/* - * Glue between the event loop and the DBus library - */ - -class BusDispatcher; -class Pipe; - -class DXXAPI BusTimeout : public Timeout, public DefaultTimeout -{ - BusTimeout(Timeout::Internal *, BusDispatcher *); - - void toggle(); - -friend class BusDispatcher; -}; - -class DXXAPI BusWatch : public Watch, public DefaultWatch -{ - BusWatch(Watch::Internal *, BusDispatcher *); - - void toggle(); - -friend class BusDispatcher; -}; - -class DXXAPI BusDispatcher : public Dispatcher, public DefaultMainLoop -{ -public: - BusDispatcher(); - - ~BusDispatcher() {} - - virtual void enter(); - - virtual void leave(); - - virtual Pipe *add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data); - - virtual void del_pipe (Pipe *pipe); - - virtual void do_iteration(); - - virtual Timeout *add_timeout(Timeout::Internal *); - - virtual void rem_timeout(Timeout *); - - virtual Watch *add_watch(Watch::Internal *); - - virtual void rem_watch(Watch *); - - void watch_ready(DefaultWatch &); - - void timeout_expired(DefaultTimeout &); - -private: - bool _running; - int _pipe[2]; - std::list <Pipe*> pipe_list; -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_EVENTLOOP_INTEGRATION_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop.h deleted file mode 100644 index 5b1b80814a..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/eventloop.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_EVENTLOOP_H -#define __DBUSXX_EVENTLOOP_H - -#include <pthread.h> -#include <list> - -#include "api.h" -#include "util.h" - -namespace DBus { - -/* - * these Default *classes implement a very simple event loop which - * is used here as the default main loop, if you want to hook - * a different one use the Bus *classes in eventloop-integration.h - * or the Glib::Bus *classes as a reference - */ - -class DefaultMainLoop; - -class DXXAPI DefaultTimeout -{ -public: - - DefaultTimeout(int interval, bool repeat, DefaultMainLoop *); - - virtual ~DefaultTimeout(); - - bool enabled(){ return _enabled; } - void enabled(bool e){ _enabled = e; } - - int interval(){ return _interval; } - void interval(int i){ _interval = i; } - - bool repeat(){ return _repeat; } - void repeat(bool r){ _repeat = r; } - - void *data(){ return _data; } - void data(void *d){ _data = d; } - - Slot<void, DefaultTimeout &> expired; - -private: - - bool _enabled; - - int _interval; - bool _repeat; - - double _expiration; - - void *_data; - - DefaultMainLoop *_disp; - -friend class DefaultMainLoop; -}; - -typedef std::list< DefaultTimeout *> DefaultTimeouts; - -class DXXAPI DefaultWatch -{ -public: - - DefaultWatch(int fd, int flags, DefaultMainLoop *); - - virtual ~DefaultWatch(); - - bool enabled(){ return _enabled; } - void enabled(bool e){ _enabled = e; } - - int descriptor(){ return _fd; } - - int flags(){ return _flags; } - void flags(int f){ _flags = f; } - - int state(){ return _state; } - - void *data(){ return _data; } - void data(void *d){ _data = d; } - - Slot<void, DefaultWatch &> ready; - -private: - - bool _enabled; - - int _fd; - int _flags; - int _state; - - void *_data; - - DefaultMainLoop *_disp; - -friend class DefaultMainLoop; -}; - -typedef std::list< DefaultWatch *> DefaultWatches; - -class DXXAPI DefaultMutex -{ -public: - - /*! - * Constructor for non recursive Mutex - */ - DefaultMutex(); - - /*! - * Constructor - * \param recursive Set if Mutex should be recursive or not. - */ - DefaultMutex(bool recursive); - - ~DefaultMutex(); - - void lock(); - - void unlock(); - -private: - - pthread_mutex_t _mutex; -}; - -class DXXAPI DefaultMainLoop -{ -public: - - DefaultMainLoop(); - - virtual ~DefaultMainLoop(); - - virtual void dispatch(); - - int _fdunlock[2]; -private: - - DefaultMutex _mutex_t; - DefaultTimeouts _timeouts; - - DefaultMutex _mutex_w; - DefaultWatches _watches; - -friend class DefaultTimeout; -friend class DefaultWatch; -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_EVENTLOOP_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/glib-integration.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/glib-integration.h deleted file mode 100644 index 0f688520dc..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/glib-integration.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_GLIB_INTEGRATION_H -#define __DBUSXX_GLIB_INTEGRATION_H - -#include <glib.h> - -#include "api.h" -#include "dispatcher.h" - -namespace DBus { - -namespace Glib { - -class BusDispatcher; - -class DXXAPI BusTimeout : public Timeout -{ -private: - - BusTimeout(Timeout::Internal *, GMainContext *, int); - - ~BusTimeout(); - - void toggle(); - - static gboolean timeout_handler(gpointer); - - void _enable(); - - void _disable(); - -private: - - GMainContext *_ctx; - int _priority; - GSource *_source; - -friend class BusDispatcher; -}; - -class DXXAPI BusWatch : public Watch -{ -private: - - BusWatch(Watch::Internal *, GMainContext *, int); - - ~BusWatch(); - - void toggle(); - - static gboolean watch_handler(gpointer); - - void _enable(); - - void _disable(); - -private: - - GMainContext *_ctx; - int _priority; - GSource *_source; - -friend class BusDispatcher; -}; - -class DXXAPI BusDispatcher : public Dispatcher -{ -public: - - BusDispatcher(); - ~BusDispatcher(); - - void attach(GMainContext *); - - void enter() {} - - void leave() {} - - Timeout *add_timeout(Timeout::Internal *); - - void rem_timeout(Timeout *); - - Watch *add_watch(Watch::Internal *); - - void rem_watch(Watch *); - - void set_priority(int priority); - -private: - - GMainContext *_ctx; - int _priority; - GSource *_source; -}; - -} /* namespace Glib */ - -} /* namespace DBus */ - -#endif//__DBUSXX_GLIB_INTEGRATION_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/interface.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/interface.h deleted file mode 100644 index 86c8d18d1b..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/interface.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_INTERFACE_H -#define __DBUSXX_INTERFACE_H - -#include <string> -#include <map> -#include "api.h" -#include "util.h" -#include "types.h" - -#include "message.h" - -namespace DBus { - -//todo: this should belong to to properties.h -struct DXXAPI PropertyData -{ - bool read; - bool write; - std::string sig; - Variant value; -}; - -typedef std::map<std::string, PropertyData> PropertyTable; - -class IntrospectedInterface; - -class ObjectAdaptor; -class InterfaceAdaptor; -class SignalMessage; - -typedef std::map<std::string, InterfaceAdaptor *> InterfaceAdaptorTable; - -class DXXAPI AdaptorBase -{ -public: - - virtual const ObjectAdaptor *object() const = 0 ; - -protected: - - InterfaceAdaptor *find_interface(const std::string &name); - - virtual ~AdaptorBase() - {} - - virtual void _emit_signal(SignalMessage &) = 0; - - InterfaceAdaptorTable _interfaces; -}; - -/* -*/ - -class ObjectProxy; -class InterfaceProxy; -class CallMessage; - -typedef std::map<std::string, InterfaceProxy *> InterfaceProxyTable; - -class DXXAPI ProxyBase -{ -public: - - virtual const ObjectProxy *object() const = 0 ; - -protected: - - InterfaceProxy *find_interface(const std::string &name); - - virtual ~ProxyBase() - {} - - virtual Message _invoke_method(CallMessage &) = 0; - - virtual bool _invoke_method_noreply(CallMessage &call) = 0; - - InterfaceProxyTable _interfaces; -}; - -class DXXAPI Interface -{ -public: - - Interface(const std::string &name); - - virtual ~Interface(); - - inline const std::string &name() const; - -private: - - std::string _name; -}; - -/* -*/ - -const std::string &Interface::name() const -{ - return _name; -} - -/* -*/ - -typedef std::map< std::string, Slot<Message, const CallMessage &> > MethodTable; - -class DXXAPI InterfaceAdaptor : public Interface, public virtual AdaptorBase -{ -public: - - InterfaceAdaptor(const std::string &name); - - Message dispatch_method(const CallMessage &); - - void emit_signal(const SignalMessage &); - - Variant *get_property(const std::string &name); - - void set_property(const std::string &name, Variant &value); - - virtual IntrospectedInterface *const introspect() const - { - return NULL; - } - -protected: - - MethodTable _methods; - PropertyTable _properties; -}; - -/* -*/ - -typedef std::map< std::string, Slot<void, const SignalMessage &> > SignalTable; - -class DXXAPI InterfaceProxy : public Interface, public virtual ProxyBase -{ -public: - - InterfaceProxy(const std::string &name); - - Message invoke_method(const CallMessage &); - - bool invoke_method_noreply(const CallMessage &call); - - bool dispatch_signal(const SignalMessage &); - -protected: - - SignalTable _signals; -}; - -# define register_method(interface, method, callback) \ - InterfaceAdaptor::_methods[ #method ] = \ - new ::DBus::Callback< interface, ::DBus::Message, const ::DBus::CallMessage &>(this, & interface :: callback); - -# define bind_property(variable, type, can_read, can_write) \ - InterfaceAdaptor::_properties[ #variable ].read = can_read; \ - InterfaceAdaptor::_properties[ #variable ].write = can_write; \ - InterfaceAdaptor::_properties[ #variable ].sig = type; \ - variable.bind(InterfaceAdaptor::_properties[ #variable ]); - -# define connect_signal(interface, signal, callback) \ - InterfaceProxy::_signals[ #signal ] = \ - new ::DBus::Callback< interface, void, const ::DBus::SignalMessage &>(this, & interface :: callback); - -} /* namespace DBus */ - -#endif//__DBUSXX_INTERFACE_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/introspection.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/introspection.h deleted file mode 100644 index 5f0d1e4dff..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/introspection.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_INTROSPECTION_H -#define __DBUSXX_INTROSPECTION_H - -#include "api.h" -#include "interface.h" - -namespace DBus { - -struct DXXAPI IntrospectedArgument -{ - const char *name; - const char *type; - const bool in; -}; - -struct DXXAPI IntrospectedMethod -{ - const char *name; - const IntrospectedArgument *args; -}; - -struct DXXAPI IntrospectedProperty -{ - const char *name; - const char *type; - const bool read; - const bool write; -}; - -struct DXXAPI IntrospectedInterface -{ - const char *name; - const IntrospectedMethod *methods; - const IntrospectedMethod *signals; - const IntrospectedProperty *properties; -}; - -class DXXAPI IntrospectableAdaptor : public InterfaceAdaptor -{ -public: - - IntrospectableAdaptor(); - - Message Introspect(const CallMessage &); - -protected: - - IntrospectedInterface *const introspect() const; -}; - -class DXXAPI IntrospectableProxy : public InterfaceProxy -{ -public: - - IntrospectableProxy(); - - std::string Introspect(); -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_INTROSPECTION_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/message.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/message.h deleted file mode 100644 index ba326b7db8..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/message.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_MESSAGE_H -#define __DBUSXX_MESSAGE_H - -#include <string> -#include <map> - -#include "api.h" -#include "util.h" - -namespace DBus { - -class Message; -class ErrorMessage; -class SignalMessage; -class ReturnMessage; -class Error; -class Connection; - -class DXXAPI MessageIter -{ -public: - - MessageIter() {} - - int type(); - - bool at_end(); - - bool has_next(); - - MessageIter &operator ++(); - - MessageIter operator ++(int); - - bool append_byte(unsigned char byte); - - unsigned char get_byte(); - - bool append_bool(bool b); - - bool get_bool(); - - bool append_int16(signed short i); - - signed short get_int16(); - - bool append_uint16(unsigned short u); - - unsigned short get_uint16(); - - bool append_int32(signed int i); - - signed int get_int32(); - - bool append_uint32(unsigned int u); - - unsigned int get_uint32(); - - bool append_int64(signed long long i); - - signed long long get_int64(); - - bool append_uint64(unsigned long long i); - - unsigned long long get_uint64(); - - bool append_double(double d); - - double get_double(); - - bool append_string(const char *chars); - - const char *get_string(); - - bool append_path(const char *chars); - - const char *get_path(); - - bool append_signature(const char *chars); - - const char *get_signature(); - - char *signature() const; //returned string must be manually free()'d - - MessageIter recurse(); - - bool append_array(char type, const void *ptr, size_t length); - - int array_type(); - - int get_array(void *ptr); - - bool is_array(); - - bool is_dict(); - - MessageIter new_array(const char *sig); - - MessageIter new_variant(const char *sig); - - MessageIter new_struct(); - - MessageIter new_dict_entry(); - - void close_container(MessageIter &container); - - void copy_data(MessageIter &to); - - Message &msg() const - { - return *_msg; - } - -private: - - DXXAPILOCAL MessageIter(Message &msg) : _msg(&msg) {} - - DXXAPILOCAL bool append_basic(int type_id, void *value); - - DXXAPILOCAL void get_basic(int type_id, void *ptr); - -private: - - /* I'm sorry, but don't want to include dbus.h in the public api - */ - unsigned char _iter[sizeof(void *)*3+sizeof(int)*11]; - - Message *_msg; - -friend class Message; -}; - -class DXXAPI Message -{ -public: - - struct Private; - - Message(Private *, bool incref = true); - - Message(const Message &m); - - ~Message(); - - Message &operator = (const Message &m); - - Message copy(); - - int type() const; - - int serial() const; - - int reply_serial() const; - - bool reply_serial(int); - - const char *sender() const; - - bool sender(const char *s); - - const char *destination() const; - - bool destination(const char *s); - - bool is_error() const; - - bool is_signal(const char *interface, const char *member) const; - - MessageIter reader() const; - - MessageIter writer(); - - bool append(int first_type, ...); - - void terminate(); - -protected: - - Message(); - -protected: - - RefPtrI<Private> _pvt; - -/* classes who need to read `_pvt` directly -*/ -friend class ErrorMessage; -friend class ReturnMessage; -friend class MessageIter; -friend class Error; -friend class Connection; -}; - -/* -*/ - -class DXXAPI ErrorMessage : public Message -{ -public: - - ErrorMessage(); - - ErrorMessage(const Message &, const char *name, const char *message); - - const char *name() const; - - bool name(const char *n); - - bool operator == (const ErrorMessage &) const; -}; - -/* -*/ - -class DXXAPI SignalMessage : public Message -{ -public: - - SignalMessage(const char *name); - - SignalMessage(const char *path, const char *interface, const char *name); - - const char *interface() const; - - bool interface(const char *i); - - const char *member() const; - - bool member(const char *m); - - const char *path() const; - - char ** path_split() const; - - bool path(const char *p); - - bool operator == (const SignalMessage &) const; -}; - -/* -*/ - -class DXXAPI CallMessage : public Message -{ -public: - - CallMessage(); - - CallMessage(const char *dest, const char *path, const char *iface, const char *method); - - const char *interface() const; - - bool interface(const char *i); - - const char *member() const; - - bool member(const char *m); - - const char *path() const; - - char ** path_split() const; - - bool path(const char *p); - - const char *signature() const; - - bool operator == (const CallMessage &) const; -}; - -/* -*/ - -class DXXAPI ReturnMessage : public Message -{ -public: - - ReturnMessage(const CallMessage &callee); - - const char *signature() const; -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_MESSAGE_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/object.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/object.h deleted file mode 100644 index 494aa82de4..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/object.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_OBJECT_H -#define __DBUSXX_OBJECT_H - -#include <string> -#include <list> - -#include "api.h" -#include "interface.h" -#include "connection.h" -#include "message.h" -#include "types.h" - -namespace DBus { - -class DXXAPI Object -{ -protected: - - Object(Connection &conn, const Path &path, const char *service); - -public: - - virtual ~Object(); - - inline const DBus::Path &path() const; - - inline const std::string &service() const; - - inline Connection &conn(); - - void set_timeout(int new_timeout = -1); - - inline int get_timeout() const; - -private: - - DXXAPILOCAL virtual bool handle_message(const Message &) = 0; - DXXAPILOCAL virtual void register_obj() = 0; - DXXAPILOCAL virtual void unregister_obj() = 0; - -private: - - Connection _conn; - DBus::Path _path; - std::string _service; - int _default_timeout; -}; - -/* -*/ - -Connection &Object::conn() -{ - return _conn; -} - -const DBus::Path &Object::path() const -{ - return _path; -} - -const std::string &Object::service() const -{ - return _service; -} - -int Object::get_timeout() const -{ - return _default_timeout; -} - -/* -*/ - -class DXXAPI Tag -{ -public: - - virtual ~Tag() - {} -}; - -/* -*/ - -class ObjectAdaptor; - -typedef std::list<ObjectAdaptor *> ObjectAdaptorPList; -typedef std::list<std::string> ObjectPathList; - -class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase -{ -public: - - static ObjectAdaptor *from_path(const Path &path); - - static ObjectAdaptorPList from_path_prefix(const std::string &prefix); - - static ObjectPathList child_nodes_from_prefix(const std::string &prefix); - - struct Private; - - ObjectAdaptor(Connection &conn, const Path &path); - - ~ObjectAdaptor(); - - inline const ObjectAdaptor *object() const; - -protected: - - class DXXAPI Continuation - { - public: - - inline MessageIter &writer(); - - inline Tag *tag(); - - private: - - Continuation(Connection &conn, const CallMessage &call, const Tag *tag); - - Connection _conn; - CallMessage _call; - MessageIter _writer; - ReturnMessage _return; - const Tag *_tag; - - friend class ObjectAdaptor; - }; - - void return_later(const Tag *tag); - - void return_now(Continuation *ret); - - void return_error(Continuation *ret, const Error error); - - Continuation *find_continuation(const Tag *tag); - -private: - - void _emit_signal(SignalMessage &); - - bool handle_message(const Message &); - - void register_obj(); - void unregister_obj(); - - typedef std::map<const Tag *, Continuation *> ContinuationMap; - ContinuationMap _continuations; - -friend struct Private; -}; - -const ObjectAdaptor *ObjectAdaptor::object() const -{ - return this; -} - -Tag *ObjectAdaptor::Continuation::tag() -{ - return const_cast<Tag *>(_tag); -} - -MessageIter &ObjectAdaptor::Continuation::writer() -{ - return _writer; -} - -/* -*/ - -class ObjectProxy; - -typedef std::list<ObjectProxy *> ObjectProxyPList; - -class DXXAPI ObjectProxy : public Object, public virtual ProxyBase -{ -public: - - ObjectProxy(Connection &conn, const Path &path, const char *service = ""); - - ~ObjectProxy(); - - inline const ObjectProxy *object() const; - -private: - - Message _invoke_method(CallMessage &); - - bool _invoke_method_noreply(CallMessage &call); - - bool handle_message(const Message &); - - void register_obj(); - void unregister_obj(); - -private: - - MessageSlot _filtered; -}; - -const ObjectProxy *ObjectProxy::object() const -{ - return this; -} - -} /* namespace DBus */ - -#endif//__DBUSXX_OBJECT_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/pendingcall.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/pendingcall.h deleted file mode 100644 index bfe5545adb..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/pendingcall.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_PENDING_CALL_H -#define __DBUSXX_PENDING_CALL_H - -#include "api.h" -#include "util.h" -#include "message.h" - -namespace DBus { - -class Connection; - -class DXXAPI PendingCall -{ -public: - - struct Private; - - PendingCall(Private *); - - PendingCall(const PendingCall &); - - virtual ~PendingCall(); - - PendingCall &operator = (const PendingCall &); - - /*! - * \brief Checks whether the pending call has received a reply yet, or not. - * - * \return true If a reply has been received. - */ - bool completed(); - - /*! - * \brief Cancels the pending call, such that any reply or error received will - * just be ignored. - * - * Drops the dbus library's internal reference to the DBusPendingCall so will - * free the call if nobody else is holding a reference. However you usually - * get a reference from Connection::send_async() so probably your app - * owns a ref also. - * - * Note that canceling a pending call will not simulate a timed-out call; if a - * call times out, then a timeout error reply is received. If you cancel the - * call, no reply is received unless the the reply was already received before - * you canceled. - */ - void cancel(); - - /*! - * \brief Block until the pending call is completed. - * - * The blocking is as with Connection::send_blocking(); it - * does not enter the main loop or process other messages, it simply waits for - * the reply in question. - * - * If the pending call is already completed, this function returns immediately. - */ - void block(); - - /*! - * \brief Stores a pointer on a PendingCall, along with an optional function to - * be used for freeing the data when the data is set again, or when the - * pending call is finalized. - * - * The slot is allocated automatic. - * - * \param data The data to store. - * \throw ErrorNoMemory - */ - void data( void* data ); - - /*! - * \brief Retrieves data previously set with dbus_pending_call_set_data(). - * - * The slot must still be allocated (must not have been freed). - * - * \return The data, or NULL if not found. - */ - void *data(); - - /*! - * \return The data slot. - */ - Slot<void, PendingCall &>& slot(); - - /*! - * \brief Gets the reply - * - * Ownership of the reply message passes to the caller. This function can only - * be called once per pending call, since the reply message is tranferred to - * the caller. - * - * \return The reply Message. - * \throw ErrorNoReply - */ - Message steal_reply(); - -private: - - RefPtrI<Private> _pvt; - -friend struct Private; -friend class Connection; -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_PENDING_CALL_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/pipe.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/pipe.h deleted file mode 100644 index 752d48d8b4..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/pipe.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef DBUSXX_PIPE_H -#define DBUSXX_PIPE_H - -/* Project */ -#include "api.h" - -/* STD */ -#include <cstdlib> - -namespace DBus { - -class DXXAPI Pipe -{ -public: - /*! - * Write some data into the communication pipe. - * - * @param buffer The raw data to write. - * @param nbytes The number of bytes to write from the buffer. - */ - void write(const void *buffer, unsigned int nbytes); - - ssize_t read(void *buffer, unsigned int &nbytes); - - /*! - * Simply write one single byte into the pipe. This is a shortcut - * if there's really no data to transport, but to activate the handler. - */ - void signal(); - -private: - void(*_handler)(const void *data, void *buffer, unsigned int nbyte); - int _fd_write; - int _fd_read; - const void *_data; - - // allow construction only in BusDispatcher - Pipe (void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data); - ~Pipe () {}; - -friend class BusDispatcher; -}; - -} /* namespace DBus */ - -#endif // DBUSXX_PIPE_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/property.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/property.h deleted file mode 100644 index 847ae89c78..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/property.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_PROPERTY_H -#define __DBUSXX_PROPERTY_H - -#include "api.h" -#include "types.h" -#include "interface.h" - -namespace DBus { - -template <typename T> -class PropertyAdaptor -{ -public: - - PropertyAdaptor() : _data(0) - {} - - void bind(PropertyData &data) - { - _data = &data; - } - - T operator() (void) const - { - return _data->value.operator T(); - } - - PropertyAdaptor &operator = (const T &t) - { - _data->value.clear(); - MessageIter wi = _data->value.writer(); - wi << t; - return *this; - } - -private: - - PropertyData *_data; -}; - -struct IntrospectedInterface; - -class DXXAPI PropertiesAdaptor : public InterfaceAdaptor -{ -public: - - PropertiesAdaptor(); - - Message Get(const CallMessage &); - - Message Set(const CallMessage &); - -protected: - - virtual void on_get_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, Variant &/*value*/) - {} - - virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/) - {} - - IntrospectedInterface *const introspect() const; -}; - -class DXXAPI PropertiesProxy : public InterfaceProxy -{ -public: - - PropertiesProxy(); - - Variant Get(const std::string &interface, const std::string &property); - - void Set(const std::string &interface, const std::string &property, const Variant &value); -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_PROPERTY_H - diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/refptr_impl.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/refptr_impl.h deleted file mode 100644 index fc10cef825..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/refptr_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_REFPTR_IMPL_H -#define __DBUSXX_REFPTR_IMPL_H - -#include "api.h" -#include "util.h" - -namespace DBus { - -template <class T> -RefPtrI<T>::RefPtrI(T *ptr) -: __ptr(ptr) -{} - -template <class T> -RefPtrI<T>::~RefPtrI() -{ - if (__cnt.one()) delete __ptr; -} - -} /* namespace DBus */ - -#endif//__DBUSXX_REFPTR_IMPL_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/server.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/server.h deleted file mode 100644 index 30879bf379..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/server.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_SERVER_H -#define __DBUSXX_SERVER_H - -#include <list> - -#include "api.h" -#include "error.h" -#include "connection.h" -#include "util.h" -#include "dispatcher.h" - -namespace DBus { - -class Server; - -typedef std::list<Server> ServerList; - -class DXXAPI Server -{ -public: - - Server(const char *address); - - Dispatcher *setup(Dispatcher *); - - virtual ~Server(); - - bool listening() const; - - bool operator == (const Server &) const; - - void disconnect(); - - struct Private; - -protected: - - Server(const Server &s) - {} - - virtual void on_new_connection(Connection &c) = 0; - -private: - - RefPtrI<Private> _pvt; -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_SERVER_H diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/types.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/types.h deleted file mode 100644 index c795891f14..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/types.h +++ /dev/null @@ -1,500 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_TYPES_H -#define __DBUSXX_TYPES_H - -#include <stdint.h> -#include <string> -#include <vector> -#include <map> - -#include "api.h" -#include "util.h" -#include "message.h" -#include "error.h" - -namespace DBus { - -struct DXXAPI Path : public std::string -{ - Path() {} - Path(const std::string &s) : std::string(s) {} - Path(const char *c) : std::string(c) {} - Path &operator = (std::string &s) - { - std::string::operator = (s); - return *this; - } -}; - -struct DXXAPI Signature : public std::string -{ - Signature() {} - Signature(const std::string &s) : std::string(s) {} - Signature(const char *c) : std::string(c) {} - Signature &operator = (std::string &s) - { - std::string::operator = (s); - return *this; - } -}; - -struct DXXAPI Invalid {}; - -class DXXAPI Variant -{ -public: - - Variant(); - - Variant(MessageIter &it); - - Variant &operator = (const Variant &v); - - const Signature signature() const; - - void clear(); - - MessageIter reader() const - { - return _msg.reader(); - } - - MessageIter writer() - { - return _msg.writer(); - } - - template <typename T> - operator T() const - { - T cast; - MessageIter ri = _msg.reader(); - ri >> cast; - return cast; - } - -private: - - Message _msg; -}; - -template < - typename T1, - typename T2 = Invalid, - typename T3 = Invalid, - typename T4 = Invalid, - typename T5 = Invalid, - typename T6 = Invalid, - typename T7 = Invalid, - typename T8 = Invalid // who needs more than eight? -> -struct Struct -{ - T1 _1; T2 _2; T3 _3; T4 _4; T5 _5; T6 _6; T7 _7; T8 _8; -}; - -template<typename K, typename V> -inline bool dict_has_key(const std::map<K,V>& map, const K &key) -{ - return map.find(key) != map.end(); -} - -template <typename T> -struct type -{ - static std::string sig() - { - throw ErrorInvalidArgs("unknown type"); - return ""; - } -}; - -template <> struct type<Variant> { static std::string sig(){ return "v"; } }; -template <> struct type<uint8_t> { static std::string sig(){ return "y"; } }; -template <> struct type<bool> { static std::string sig(){ return "b"; } }; -template <> struct type<int16_t> { static std::string sig(){ return "n"; } }; -template <> struct type<uint16_t> { static std::string sig(){ return "q"; } }; -template <> struct type<int32_t> { static std::string sig(){ return "i"; } }; -template <> struct type<uint32_t> { static std::string sig(){ return "u"; } }; -template <> struct type<int64_t> { static std::string sig(){ return "x"; } }; -template <> struct type<uint64_t> { static std::string sig(){ return "t"; } }; -template <> struct type<double> { static std::string sig(){ return "d"; } }; -template <> struct type<std::string> { static std::string sig(){ return "s"; } }; -template <> struct type<Path> { static std::string sig(){ return "o"; } }; -template <> struct type<Signature> { static std::string sig(){ return "g"; } }; -template <> struct type<Invalid> { static std::string sig(){ return ""; } }; - -template <typename E> -struct type< std::vector<E> > -{ static std::string sig(){ return "a" + type<E>::sig(); } }; - -template <typename K, typename V> -struct type< std::map<K,V> > -{ static std::string sig(){ return "a{" + type<K>::sig() + type<V>::sig() + "}"; } }; - -template < - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8 // who needs more than eight? -> -struct type< Struct<T1,T2,T3,T4,T5,T6,T7,T8> > -{ - static std::string sig() - { - return "(" - + type<T1>::sig() - + type<T2>::sig() - + type<T3>::sig() - + type<T4>::sig() - + type<T5>::sig() - + type<T6>::sig() - + type<T7>::sig() - + type<T8>::sig() - + ")"; - } -}; - -} /* namespace DBus */ - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Invalid &) -{ - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint8_t &val) -{ - iter.append_byte(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const bool &val) -{ - iter.append_bool(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int16_t& val) -{ - iter.append_int16(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint16_t& val) -{ - iter.append_uint16(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int32_t& val) -{ - iter.append_int32(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint32_t& val) -{ - iter.append_uint32(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int64_t& val) -{ - iter.append_int64(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint64_t& val) -{ - iter.append_uint64(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const double &val) -{ - iter.append_double(val); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::string &val) -{ - iter.append_string(val.c_str()); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Path &val) -{ - iter.append_path(val.c_str()); - return iter; -} - -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Signature &val) -{ - iter.append_signature(val.c_str()); - return iter; -} - -template<typename E> -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector<E>& val) -{ - const std::string sig = DBus::type<E>::sig(); - DBus::MessageIter ait = iter.new_array(sig.c_str()); - - typename std::vector<E>::const_iterator vit; - for (vit = val.begin(); vit != val.end(); ++vit) - { - ait << *vit; - } - - iter.close_container(ait); - return iter; -} - -template<> -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector<uint8_t>& val) -{ - DBus::MessageIter ait = iter.new_array("y"); - ait.append_array('y', &val.front(), val.size()); - iter.close_container(ait); - return iter; -} - -template<typename K, typename V> -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::map<K,V>& val) -{ - const std::string sig = "{" + DBus::type<K>::sig() + DBus::type<V>::sig() + "}"; - DBus::MessageIter ait = iter.new_array(sig.c_str()); - - typename std::map<K,V>::const_iterator mit; - for (mit = val.begin(); mit != val.end(); ++mit) - { - DBus::MessageIter eit = ait.new_dict_entry(); - - eit << mit->first << mit->second; - - ait.close_container(eit); - } - - iter.close_container(ait); - return iter; -} - -template < - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8 -> -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8>& val) -{ -/* const std::string sig = - DBus::type<T1>::sig() + DBus::type<T2>::sig() + DBus::type<T3>::sig() + DBus::type<T4>::sig() + - DBus::type<T5>::sig() + DBus::type<T6>::sig() + DBus::type<T7>::sig() + DBus::type<T8>::sig(); -*/ - DBus::MessageIter sit = iter.new_struct(/*sig.c_str()*/); - - sit << val._1 << val._2 << val._3 << val._4 << val._5 << val._6 << val._7 << val._8; - - iter.close_container(sit); - - return iter; -} - -extern DXXAPI DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Variant &val); - -/* - */ - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Invalid &) -{ - return iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint8_t &val) -{ - val = iter.get_byte(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, bool &val) -{ - val = iter.get_bool(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int16_t& val) -{ - val = iter.get_int16(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint16_t& val) -{ - val = iter.get_uint16(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int32_t& val) -{ - val = iter.get_int32(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint32_t& val) -{ - val = iter.get_uint32(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int64_t& val) -{ - val = iter.get_int64(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint64_t& val) -{ - val = iter.get_uint64(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, double &val) -{ - val = iter.get_double(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::string &val) -{ - val = iter.get_string(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Path &val) -{ - val = iter.get_path(); - return ++iter; -} - -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Signature &val) -{ - val = iter.get_signature(); - return ++iter; -} - -template<typename E> -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<E>& val) -{ - if (!iter.is_array()) - throw DBus::ErrorInvalidArgs("array expected"); - - DBus::MessageIter ait = iter.recurse(); - - while (!ait.at_end()) - { - E elem; - - ait >> elem; - - val.push_back(elem); - } - return ++iter; -} - -template<> -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<uint8_t>& val) -{ - if (!iter.is_array()) - throw DBus::ErrorInvalidArgs("array expected"); - - if (iter.array_type() != 'y') - throw DBus::ErrorInvalidArgs("byte-array expected"); - - DBus::MessageIter ait = iter.recurse(); - - uint8_t *array; - size_t length = ait.get_array(&array); - - val.insert(val.end(), array, array+length); - - return ++iter; -} - -template<typename K, typename V> -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::map<K,V>& val) -{ - if (!iter.is_dict()) - throw DBus::ErrorInvalidArgs("dictionary value expected"); - - DBus::MessageIter mit = iter.recurse(); - - while (!mit.at_end()) - { - K key; V value; - - DBus::MessageIter eit = mit.recurse(); - - eit >> key >> value; - - val[key] = value; - - ++mit; - } - - return ++iter; -} - -template < - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8 -> -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8>& val) -{ - DBus::MessageIter sit = iter.recurse(); - - sit >> val._1 >> val._2 >> val._3 >> val._4 >> val._5 >> val._6 >> val._7 >> val._8; - - return ++iter; -} - -extern DXXAPI DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Variant &val); - -#endif//__DBUSXX_TYPES_H - diff --git a/sflphone-common/libs/dbus-c++/include/dbus-c++/util.h b/sflphone-common/libs/dbus-c++/include/dbus-c++/util.h deleted file mode 100644 index 87fa7e5867..0000000000 --- a/sflphone-common/libs/dbus-c++/include/dbus-c++/util.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_UTIL_H -#define __DBUSXX_UTIL_H - -#include <sstream> -#include <iostream> -#include <iomanip> -#include <cassert> - -#include "api.h" -#include "debug.h" - -namespace DBus { - -/* - * Very simple reference counting - */ - -class DXXAPI RefCnt -{ -public: - - RefCnt() - { - __ref = new int; - (*__ref) = 1; - } - - RefCnt(const RefCnt &rc) - { - __ref = rc.__ref; - ref(); - } - - virtual ~RefCnt() - { - unref(); - } - - RefCnt &operator = (const RefCnt &ref) - { - ref.ref(); - unref(); - __ref = ref.__ref; - return *this; - } - - bool noref() const - { - return (*__ref) == 0; - } - - bool one() const - { - return (*__ref) == 1; - } - -private: - - DXXAPILOCAL void ref() const - { - ++ (*__ref); - } - DXXAPILOCAL void unref() const - { - -- (*__ref); - - if ((*__ref) < 0) - { - debug_log("%p: refcount dropped below zero!", __ref); - } - - if (noref()) - { - delete __ref; - } - } - -private: - - int *__ref; -}; - -/* - * Reference counting pointers (emulate boost::shared_ptr) - */ - -template <class T> -class RefPtrI // RefPtr to incomplete type -{ -public: - - RefPtrI(T *ptr = 0); - - ~RefPtrI(); - - RefPtrI &operator = (const RefPtrI &ref) - { - if (this != &ref) - { - if (__cnt.one()) delete __ptr; - - __ptr = ref.__ptr; - __cnt = ref.__cnt; - } - return *this; - } - - T &operator *() const - { - return *__ptr; - } - - T *operator ->() const - { - if (__cnt.noref()) return 0; - - return __ptr; - } - - T *get() const - { - if (__cnt.noref()) return 0; - - return __ptr; - } - -private: - - T *__ptr; - RefCnt __cnt; -}; - -template <class T> -class RefPtr -{ -public: - - RefPtr(T *ptr = 0) - : __ptr(ptr) - {} - - ~RefPtr() - { - if (__cnt.one()) delete __ptr; - } - - RefPtr &operator = (const RefPtr &ref) - { - if (this != &ref) - { - if (__cnt.one()) delete __ptr; - - __ptr = ref.__ptr; - __cnt = ref.__cnt; - } - return *this; - } - - T &operator *() const - { - return *__ptr; - } - - T *operator ->() const - { - if (__cnt.noref()) return 0; - - return __ptr; - } - - T *get() const - { - if (__cnt.noref()) return 0; - - return __ptr; - } - -private: - - T *__ptr; - RefCnt __cnt; -}; - -/* - * Typed callback template - */ - -template <class R, class P> -class Callback_Base -{ -public: - - virtual R call(P param) const = 0; - - virtual ~Callback_Base() - {} -}; - -template <class R, class P> -class Slot -{ -public: - - Slot &operator = (Callback_Base<R,P>* s) - { - _cb = s; - - return *this; - } - - R operator()(P param) const - { - if (!empty()) - { - return _cb->call(param); - } - - return; - } - - R call(P param) const - { - if (!empty()) - { - return _cb->call(param); - } - - return (R) NULL; - } - - bool empty() const - { - return _cb.get() == 0; - } - -private: - - RefPtr< Callback_Base<R,P> > _cb; -}; - -template <class C, class R, class P> -class Callback : public Callback_Base<R,P> -{ -public: - - typedef R (C::*M)(P); - - Callback(C *c, M m) - : _c(c), _m(m) - {} - - R call(P param) const - { - /*if (_c)*/ return (_c->*_m)(param); - } - -private: - - C *_c; M _m; -}; - -/// create std::string from any number -template <typename T> -std::string toString (const T &thing, int w = 0, int p = 0) -{ - std::ostringstream os; - os << std::setw(w) << std::setprecision(p) << thing; - return os.str(); -} - -} /* namespace DBus */ - -#endif//__DBUSXX_UTIL_H diff --git a/sflphone-common/libs/dbus-c++/src/Makefile.am b/sflphone-common/libs/dbus-c++/src/Makefile.am deleted file mode 100644 index 1ac9fc682b..0000000000 --- a/sflphone-common/libs/dbus-c++/src/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -AM_CPPFLAGS = \ - $(dbus_CFLAGS) \ - $(glib_CFLAGS) \ - $(PRIVATE_CFLAGS) \ - -I$(top_srcdir)/libs/dbus-c++/include \ - -I$(top_builddir)/libs/dbus-c++/include - -#if ENABLE_GLIB -#GLIB_H = $(HEADER_DIR)/glib-integration.h -#GLIB_CPP = glib-integration.cpp -#endif - -CONFIG_H = $(top_builddir)/libs/dbus-c++/include/dbus-c++/config.h - -HEADER_DIR = $(top_builddir)/libs/dbus-c++/include/dbus-c++ -HEADER_FILES = \ - $(HEADER_DIR)/dbus.h \ - $(HEADER_DIR)/types.h \ - $(HEADER_DIR)/connection.h \ - $(HEADER_DIR)/property.h \ - $(HEADER_DIR)/debug.h \ - $(HEADER_DIR)/error.h \ - $(HEADER_DIR)/interface.h \ - $(HEADER_DIR)/message.h \ - $(HEADER_DIR)/dispatcher.h \ - $(HEADER_DIR)/object.h \ - $(HEADER_DIR)/pendingcall.h \ - $(HEADER_DIR)/server.h \ - $(HEADER_DIR)/util.h \ - $(HEADER_DIR)/refptr_impl.h \ - $(HEADER_DIR)/introspection.h \ - $(HEADER_DIR)/api.h \ - $(HEADER_DIR)/eventloop.h \ - $(HEADER_DIR)/eventloop-integration.h \ - $(GLIB_H) - - - -# noinst_lib_includedir=$(includedir)/dbus-c++-1/dbus-c++/ -noinst_HEADERS = $(HEADER_FILES) - -noinst_LTLIBRARIES = libdbus-c++-1.la -libdbus_c___1_la_SOURCES = $(HEADER_FILES) interface.cpp object.cpp introspection.cpp debug.cpp types.cpp connection.cpp connection_p.h property.cpp dispatcher.cpp dispatcher_p.h pendingcall.cpp pendingcall_p.h error.cpp pipe.cpp internalerror.h message.cpp message_p.h server.cpp server_p.h eventloop.cpp eventloop-integration.cpp $(GLIB_CPP) $(ECORE_CPP) -libdbus_c___1_la_LIBADD = $(dbus_LIBS) $(glib_LIBS) $(pthread_LIBS) - -MAINTAINERCLEANFILES = \ - Makefile.in diff --git a/sflphone-common/libs/dbus-c++/src/connection.cpp b/sflphone-common/libs/dbus-c++/src/connection.cpp deleted file mode 100644 index e1eec7e68c..0000000000 --- a/sflphone-common/libs/dbus-c++/src/connection.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/debug.h> -#include <dbus-c++/connection.h> - -#include <dbus/dbus.h> -#include <string> - -#include "internalerror.h" - -#include "connection_p.h" -#include "dispatcher_p.h" -#include "server_p.h" -#include "message_p.h" -#include "pendingcall_p.h" - -using namespace DBus; - -Connection::Private::Private(DBusConnection *c, Server::Private *s) -: conn(c) , dispatcher(0), server(s) -{ - init(); -} - -Connection::Private::Private(DBusBusType type) -{ - InternalError e; - - conn = dbus_bus_get_private(type, e); - - if (e) throw Error(e); - - init(); -} - -Connection::Private::~Private() -{ - debug_log("terminating connection 0x%08x", conn); - - detach_server(); - - if (dbus_connection_get_is_connected(conn)) - { - std::vector<std::string>::iterator i = names.begin(); - - while (i != names.end()) - { - debug_log("%s: releasing bus name %s", dbus_bus_get_unique_name(conn), i->c_str()); - dbus_bus_release_name(conn, i->c_str(), NULL); - ++i; - } - dbus_connection_close(conn); - } - dbus_connection_unref(conn); -} - -void Connection::Private::init() -{ - dbus_connection_ref(conn); - dbus_connection_ref(conn); //todo: the library has to own another reference - - disconn_filter = new Callback<Connection::Private, bool, const Message &>( - this, &Connection::Private::disconn_filter_function - ); - - dbus_connection_add_filter(conn, message_filter_stub, &disconn_filter, NULL); // TODO: some assert at least - - dbus_connection_set_dispatch_status_function(conn, dispatch_status_stub, this, 0); - dbus_connection_set_exit_on_disconnect(conn, false); //why was this set to true?? -} - -void Connection::Private::detach_server() -{ -/* Server::Private *tmp = server; - - server = NULL; - - if (tmp) - { - ConnectionList::iterator i; - - for (i = tmp->connections.begin(); i != tmp->connections.end(); ++i) - { - if (i->_pvt.get() == this) - { - tmp->connections.erase(i); - break; - } - } - }*/ -} - -bool Connection::Private::do_dispatch() -{ - debug_log("dispatching on %p", conn); - - if (!dbus_connection_get_is_connected(conn)) - { - debug_log("connection terminated"); - - detach_server(); - - return true; - } - - return dbus_connection_dispatch(conn) != DBUS_DISPATCH_DATA_REMAINS; -} - -void Connection::Private::dispatch_status_stub(DBusConnection *dc, DBusDispatchStatus status, void *data) -{ - Private *p = static_cast<Private *>(data); - - switch (status) - { - case DBUS_DISPATCH_DATA_REMAINS: - debug_log("some dispatching to do on %p", dc); - p->dispatcher->queue_connection(p); - break; - - case DBUS_DISPATCH_COMPLETE: - debug_log("all dispatching done on %p", dc); - break; - - case DBUS_DISPATCH_NEED_MEMORY: //uh oh... - debug_log("connection %p needs memory", dc); - break; - } -} - -DBusHandlerResult Connection::Private::message_filter_stub(DBusConnection *conn, DBusMessage *dmsg, void *data) -{ - MessageSlot *slot = static_cast<MessageSlot *>(data); - - Message msg = Message(new Message::Private(dmsg)); - - return slot && !slot->empty() && slot->call(msg) - ? DBUS_HANDLER_RESULT_HANDLED - : DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -bool Connection::Private::disconn_filter_function(const Message &msg) -{ - if (msg.is_signal(DBUS_INTERFACE_LOCAL,"Disconnected")) - { - debug_log("%p disconnected by local bus", conn); - dbus_connection_close(conn); - - return true; - } - return false; -} - -DBusDispatchStatus Connection::Private::dispatch_status() -{ - return dbus_connection_get_dispatch_status(conn); -} - -bool Connection::Private::has_something_to_dispatch() -{ - return dispatch_status() == DBUS_DISPATCH_DATA_REMAINS; -} - - -Connection Connection::SystemBus() -{ - return Connection(new Private(DBUS_BUS_SYSTEM)); -} - -Connection Connection::SessionBus() -{ - return Connection(new Private(DBUS_BUS_SESSION)); -} - -Connection Connection::ActivationBus() -{ - return Connection(new Private(DBUS_BUS_STARTER)); -} - -Connection::Connection(const char *address, bool priv) -: _timeout(-1) -{ - InternalError e; - DBusConnection *conn = priv - ? dbus_connection_open_private(address, e) - : dbus_connection_open(address, e); - - if (e) throw Error(e); - - _pvt = new Private(conn); - - setup(default_dispatcher); - - debug_log("connected to %s", address); -} - -Connection::Connection(Connection::Private *p) -: _pvt(p), _timeout(-1) -{ - setup(default_dispatcher); -} - -Connection::Connection(const Connection &c) -: _pvt(c._pvt),_timeout(c._timeout) -{ - dbus_connection_ref(_pvt->conn); -} - -Connection::~Connection() -{ - dbus_connection_unref(_pvt->conn); -} - -Dispatcher *Connection::setup(Dispatcher *dispatcher) -{ - debug_log("registering stubs for connection %p", _pvt->conn); - - if (!dispatcher) dispatcher = default_dispatcher; - - if (!dispatcher) throw ErrorFailed("no default dispatcher set for new connection"); - - Dispatcher *prev = _pvt->dispatcher; - - _pvt->dispatcher = dispatcher; - - dispatcher->queue_connection(_pvt.get()); - - dbus_connection_set_watch_functions( - _pvt->conn, - Dispatcher::Private::on_add_watch, - Dispatcher::Private::on_rem_watch, - Dispatcher::Private::on_toggle_watch, - dispatcher, - 0 - ); - - dbus_connection_set_timeout_functions( - _pvt->conn, - Dispatcher::Private::on_add_timeout, - Dispatcher::Private::on_rem_timeout, - Dispatcher::Private::on_toggle_timeout, - dispatcher, - 0 - ); - - return prev; -} - -bool Connection::operator == (const Connection &c) const -{ - return _pvt->conn == c._pvt->conn; -} - -bool Connection::register_bus() -{ - InternalError e; - - bool r = dbus_bus_register(_pvt->conn, e); - - if (e) throw (e); - - return r; -} - -bool Connection::connected() const -{ - return dbus_connection_get_is_connected(_pvt->conn); -} - -void Connection::disconnect() -{ -// dbus_connection_disconnect(_pvt->conn); // disappeared in 0.9x - dbus_connection_close(_pvt->conn); -} - -void Connection::exit_on_disconnect(bool exit) -{ - dbus_connection_set_exit_on_disconnect(_pvt->conn, exit); -} - -bool Connection::unique_name(const char *n) -{ - return dbus_bus_set_unique_name(_pvt->conn, n); -} - -const char *Connection::unique_name() const -{ - return dbus_bus_get_unique_name(_pvt->conn); -} - -void Connection::flush() -{ - dbus_connection_flush(_pvt->conn); -} - -void Connection::add_match(const char *rule) -{ - InternalError e; - - dbus_bus_add_match(_pvt->conn, rule, e); - - debug_log("%s: added match rule %s", unique_name(), rule); - - if (e) throw Error(e); -} - -void Connection::remove_match(const char *rule) -{ - InternalError e; - - dbus_bus_remove_match(_pvt->conn, rule, e); - - debug_log("%s: removed match rule %s", unique_name(), rule); - - if (e) throw Error(e); -} - -bool Connection::add_filter(MessageSlot &s) -{ - debug_log("%s: adding filter", unique_name()); - return dbus_connection_add_filter(_pvt->conn, Private::message_filter_stub, &s, NULL); -} - -void Connection::remove_filter(MessageSlot &s) -{ - debug_log("%s: removing filter", unique_name()); - dbus_connection_remove_filter(_pvt->conn, Private::message_filter_stub, &s); -} - -bool Connection::send(const Message &msg, unsigned int *serial) -{ - return dbus_connection_send(_pvt->conn, msg._pvt->msg, serial); -} - -Message Connection::send_blocking(Message &msg, int timeout) -{ - DBusMessage *reply; - InternalError e; - - if (this->_timeout != -1) - { - reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, this->_timeout, e); - } - else - { - reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e); - } - - if (e) throw Error(e); - - return Message(new Message::Private(reply), false); -} - -PendingCall Connection::send_async(Message &msg, int timeout) -{ - DBusPendingCall *pending; - - if (!dbus_connection_send_with_reply(_pvt->conn, msg._pvt->msg, &pending, timeout)) - { - throw ErrorNoMemory("Unable to start asynchronous call"); - } - return PendingCall(new PendingCall::Private(pending)); -} - -void Connection::request_name(const char *name, int flags) -{ - InternalError e; - - debug_log("%s: registering bus name %s", unique_name(), name); - - /* - * TODO: - * Think about giving back the 'ret' value. Some people on the list - * requested about this... - */ - int ret = dbus_bus_request_name(_pvt->conn, name, flags, e); - - if (ret == -1) - { - if (e) throw Error(e); - } - -// this->remove_match("destination"); - - if (name) - { - _pvt->names.push_back(name); - std::string match = "destination='" + _pvt->names.back() + "'"; - add_match(match.c_str()); - } -} - -unsigned long Connection::sender_unix_uid(const char *sender) -{ - InternalError e; - - unsigned long ul = dbus_bus_get_unix_user(_pvt->conn, sender, e); - - if (e) throw Error(e); - - return ul; -} - -bool Connection::has_name(const char *name) -{ - InternalError e; - - bool b = dbus_bus_name_has_owner(_pvt->conn, name, e); - - if (e) throw Error(e); - - return b; -} - -const std::vector<std::string>& Connection::names() -{ - return _pvt->names; -} - -bool Connection::start_service(const char *name, unsigned long flags) -{ - InternalError e; - - bool b = dbus_bus_start_service_by_name(_pvt->conn, name, flags, NULL, e); - - if (e) throw Error(e); - - return b; -} - -void Connection::set_timeout(int timeout) -{ - _timeout=timeout; -} - -int Connection::get_timeout() -{ - return _timeout; -} - diff --git a/sflphone-common/libs/dbus-c++/src/connection_p.h b/sflphone-common/libs/dbus-c++/src/connection_p.h deleted file mode 100644 index a6ea96cdd0..0000000000 --- a/sflphone-common/libs/dbus-c++/src/connection_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_CONNECTION_P_H -#define __DBUSXX_CONNECTION_P_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/connection.h> -#include <dbus-c++/server.h> -#include <dbus-c++/dispatcher.h> -#include <dbus-c++/refptr_impl.h> - -#include <dbus/dbus.h> - -#include <string> - -namespace DBus { - -struct DXXAPILOCAL Connection::Private -{ - DBusConnection * conn; - - std::vector<std::string> names; - - Dispatcher *dispatcher; - bool do_dispatch(); - - MessageSlot disconn_filter; - bool disconn_filter_function(const Message &); - - Server::Private *server; - void detach_server(); - - Private(DBusConnection *, Server::Private * = NULL); - - Private(DBusBusType); - - ~Private(); - - void init(); - - DBusDispatchStatus dispatch_status(); - bool has_something_to_dispatch(); - - static void dispatch_status_stub(DBusConnection *, DBusDispatchStatus, void *); - - static DBusHandlerResult message_filter_stub(DBusConnection *, DBusMessage *, void *); -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_CONNECTION_P_H diff --git a/sflphone-common/libs/dbus-c++/src/debug.cpp b/sflphone-common/libs/dbus-c++/src/debug.cpp deleted file mode 100644 index 4f97dae2dd..0000000000 --- a/sflphone-common/libs/dbus-c++/src/debug.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/debug.h> - -#include <stdarg.h> -#include <cstdio> -#include <stdlib.h> - -static void _debug_log_default(const char *format, ...) -{ -#ifdef DEBUG - - static int debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0; - - if (debug_env) - { - va_list args; - va_start(args, format); - - fprintf(stderr, "dbus-c++: "); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); - - va_end(args); - } - -#endif//DEBUG -} - -DBus::LogFunction DBus::debug_log = _debug_log_default; - diff --git a/sflphone-common/libs/dbus-c++/src/dispatcher.cpp b/sflphone-common/libs/dbus-c++/src/dispatcher.cpp deleted file mode 100644 index 2da4e86720..0000000000 --- a/sflphone-common/libs/dbus-c++/src/dispatcher.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/dispatcher.h> - -#include <dbus/dbus.h> - -#include "dispatcher_p.h" -#include "server_p.h" -#include "connection_p.h" - -DBus::Dispatcher *DBus::default_dispatcher = NULL; - -using namespace DBus; - -Timeout::Timeout(Timeout::Internal *i) -: _int(i) -{ - dbus_timeout_set_data((DBusTimeout *)i, this, NULL); -} - -int Timeout::interval() const -{ - return dbus_timeout_get_interval((DBusTimeout *)_int); -} - -bool Timeout::enabled() const -{ - return dbus_timeout_get_enabled((DBusTimeout *)_int); -} - -bool Timeout::handle() -{ - return dbus_timeout_handle((DBusTimeout *)_int); -} - -/* -*/ - -Watch::Watch(Watch::Internal *i) -: _int(i) -{ - dbus_watch_set_data((DBusWatch *)i, this, NULL); -} - -int Watch::descriptor() const -{ -#if HAVE_WIN32 - return dbus_watch_get_socket((DBusWatch*)_int); -#else - return dbus_watch_get_unix_fd((DBusWatch*)_int); -#endif -} - -int Watch::flags() const -{ - return dbus_watch_get_flags((DBusWatch *)_int); -} - -bool Watch::enabled() const -{ - return dbus_watch_get_enabled((DBusWatch *)_int); -} - -bool Watch::handle(int flags) -{ - return dbus_watch_handle((DBusWatch *)_int, flags); -} - -/* -*/ - -dbus_bool_t Dispatcher::Private::on_add_watch(DBusWatch *watch, void *data) -{ - Dispatcher *d = static_cast<Dispatcher *>(data); - - Watch::Internal *w = reinterpret_cast<Watch::Internal *>(watch); - - d->add_watch(w); - - return true; -} - -void Dispatcher::Private::on_rem_watch(DBusWatch *watch, void *data) -{ - Dispatcher *d = static_cast<Dispatcher *>(data); - - Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch)); - - d->rem_watch(w); -} - -void Dispatcher::Private::on_toggle_watch(DBusWatch *watch, void *data) -{ - Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch)); - - w->toggle(); -} - -dbus_bool_t Dispatcher::Private::on_add_timeout(DBusTimeout *timeout, void *data) -{ - Dispatcher *d = static_cast<Dispatcher *>(data); - - Timeout::Internal *t = reinterpret_cast<Timeout::Internal *>(timeout); - - d->add_timeout(t); - - return true; -} - -void Dispatcher::Private::on_rem_timeout(DBusTimeout *timeout, void *data) -{ - Dispatcher *d = static_cast<Dispatcher *>(data); - - Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout)); - - d->rem_timeout(t); -} - -void Dispatcher::Private::on_toggle_timeout(DBusTimeout *timeout, void *data) -{ - Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout)); - - t->toggle(); -} - -void Dispatcher::queue_connection(Connection::Private *cp) -{ - _mutex_p.lock(); - _pending_queue.push_back(cp); - _mutex_p.unlock(); -} - - -bool Dispatcher::has_something_to_dispatch() -{ - _mutex_p.lock(); - bool has_something = false; - for(Connection::PrivatePList::iterator it = _pending_queue.begin(); - it != _pending_queue.end() && !has_something; - ++it) - { - has_something = (*it)->has_something_to_dispatch(); - } - - _mutex_p.unlock(); - return has_something; -} - - -void Dispatcher::dispatch_pending() -{ - _mutex_p.lock(); - - // SEEME: dbus-glib is dispatching only one message at a time to not starve the loop/other things... - - while (_pending_queue.size() > 0) - { - Connection::PrivatePList::iterator i, j; - - i = _pending_queue.begin(); - - while (i != _pending_queue.end()) - { - j = i; - - ++j; - - if ((*i)->do_dispatch()) - _pending_queue.erase(i); - - i = j; - } - } - _mutex_p.unlock(); -} - -void DBus::_init_threading() -{ -#ifdef DBUS_HAS_THREADS_INIT_DEFAULT - dbus_threads_init_default(); -#else - debug_log("Thread support is not enabled! Your D-Bus version is too old!"); -#endif//DBUS_HAS_THREADS_INIT_DEFAULT -} - -void DBus::_init_threading( - MutexNewFn m1, - MutexFreeFn m2, - MutexLockFn m3, - MutexUnlockFn m4, - CondVarNewFn c1, - CondVarFreeFn c2, - CondVarWaitFn c3, - CondVarWaitTimeoutFn c4, - CondVarWakeOneFn c5, - CondVarWakeAllFn c6 -) -{ -#ifndef DBUS_HAS_RECURSIVE_MUTEX - DBusThreadFunctions functions = { - DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK| - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK, - (DBusMutexNewFunction) m1, - (DBusMutexFreeFunction) m2, - (DBusMutexLockFunction) m3, - (DBusMutexUnlockFunction) m4, - (DBusCondVarNewFunction) c1, - (DBusCondVarFreeFunction) c2, - (DBusCondVarWaitFunction) c3, - (DBusCondVarWaitTimeoutFunction) c4, - (DBusCondVarWakeOneFunction) c5, - (DBusCondVarWakeAllFunction) c6 - }; -#else - DBusThreadFunctions functions = { - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK | - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK | - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK | - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK| - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK, - 0, 0, 0, 0, - (DBusCondVarNewFunction) c1, - (DBusCondVarFreeFunction) c2, - (DBusCondVarWaitFunction) c3, - (DBusCondVarWaitTimeoutFunction) c4, - (DBusCondVarWakeOneFunction) c5, - (DBusCondVarWakeAllFunction) c6, - (DBusRecursiveMutexNewFunction) m1, - (DBusRecursiveMutexFreeFunction) m2, - (DBusRecursiveMutexLockFunction) m3, - (DBusRecursiveMutexUnlockFunction) m4 - }; -#endif//DBUS_HAS_RECURSIVE_MUTEX - dbus_threads_init(&functions); -} diff --git a/sflphone-common/libs/dbus-c++/src/dispatcher_p.h b/sflphone-common/libs/dbus-c++/src/dispatcher_p.h deleted file mode 100644 index 33c0cac390..0000000000 --- a/sflphone-common/libs/dbus-c++/src/dispatcher_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_DISPATCHER_P_H -#define __DBUSXX_DISPATCHER_P_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/dispatcher.h> - -#include <dbus/dbus.h> - -#include "internalerror.h" - -namespace DBus { - -struct DXXAPILOCAL Dispatcher::Private -{ - static dbus_bool_t on_add_watch(DBusWatch *watch, void *data); - - static void on_rem_watch(DBusWatch *watch, void *data); - - static void on_toggle_watch(DBusWatch *watch, void *data); - - static dbus_bool_t on_add_timeout(DBusTimeout *timeout, void *data); - - static void on_rem_timeout(DBusTimeout *timeout, void *data); - - static void on_toggle_timeout(DBusTimeout *timeout, void *data); -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_DISPATCHER_P_H diff --git a/sflphone-common/libs/dbus-c++/src/ecore-integration.cpp b/sflphone-common/libs/dbus-c++/src/ecore-integration.cpp deleted file mode 100644 index f1e24e7db6..0000000000 --- a/sflphone-common/libs/dbus-c++/src/ecore-integration.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/ecore-integration.h> - -#include <dbus/dbus.h> // for DBUS_WATCH_* - -using namespace DBus; - -Ecore::BusTimeout::BusTimeout( Timeout::Internal* ti) -: Timeout(ti) -{ - _enable(); -} - -Ecore::BusTimeout::~BusTimeout() -{ - _disable(); -} - -void Ecore::BusTimeout::toggle() -{ - debug_log("ecore: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off"); - - if(Timeout::enabled()) _enable(); - else _disable(); -} - -Eina_Bool Ecore::BusTimeout::timeout_handler( void *data ) -{ - Ecore::BusTimeout* t = reinterpret_cast<Ecore::BusTimeout*>(data); - - debug_log("Ecore::BusTimeout::timeout_handler( void *data )"); - - t->handle(); - - return 1; // 1 -> reshedule in ecore for next timer interval -} - -void Ecore::BusTimeout::_enable() -{ - debug_log("Ecore::BusTimeout::_enable()"); - - _etimer = ecore_timer_add (((double)Timeout::interval())/1000, timeout_handler, this); -} - -void Ecore::BusTimeout::_disable() -{ - debug_log("Ecore::BusTimeout::_disable()"); - - ecore_timer_del (_etimer); -} - -/*static bool watch_prepare( int *timeout ) -{ - debug_log("ecore: watch_prepare"); - - *timeout = -1; - return false; -}*/ - -/*static bool watch_check( ) -{ - debug_log("ecore: watch_check"); - - return true; -}*/ - -static bool watch_dispatch( void *data ) -{ - debug_log("ecore: watch_dispatch"); - - bool cb = true; - DBus::default_dispatcher->dispatch_pending(); //TODO: won't work in case of multiple dispatchers - return cb; -} - -Ecore::BusWatch::BusWatch( Watch::Internal* wi) -: Watch(wi) -{ - _enable(); -} - -Ecore::BusWatch::~BusWatch() -{ - _disable(); -} - -void Ecore::BusWatch::toggle() -{ - debug_log("ecore: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off"); - - if(Watch::enabled()) _enable(); - else _disable(); -} - -Eina_Bool Ecore::BusWatch::watch_handler_read( void *data, Ecore_Fd_Handler *fdh ) -{ - Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data); - - debug_log("ecore: watch_handler_read"); - - int flags = DBUS_WATCH_READABLE; - - watch_dispatch(NULL); - - w->handle(flags); - - return 1; -} - -Eina_Bool Ecore::BusWatch::watch_handler_error( void *data, Ecore_Fd_Handler *fdh ) -{ - //Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data); - - debug_log("ecore: watch_handler_error"); - - //int flags = DBUS_WATCH_ERROR; - - watch_dispatch(NULL); - - return 1; -} - -void Ecore::BusWatch::_enable() -{ - debug_log("Ecore::BusWatch::_enable()"); - - //int flags = Watch::flags(); - - fd_handler_read = ecore_main_fd_handler_add (Watch::descriptor(), - ECORE_FD_READ, - watch_handler_read, - this, - NULL, NULL); - - ecore_main_fd_handler_active_set(fd_handler_read, ECORE_FD_READ); - - fd_handler_error = ecore_main_fd_handler_add (Watch::descriptor(), - ECORE_FD_ERROR, - watch_handler_error, - this, - NULL, NULL); - - ecore_main_fd_handler_active_set(fd_handler_error, ECORE_FD_ERROR); -} - -void Ecore::BusWatch::_disable() -{ - ecore_main_fd_handler_del (fd_handler_read); - ecore_main_fd_handler_del (fd_handler_error); -} - -void Ecore::BusDispatcher::attach( ) -{ -} - -Timeout* Ecore::BusDispatcher::add_timeout( Timeout::Internal* wi ) -{ - Timeout* t = new Ecore::BusTimeout( wi ); - - debug_log("ecore: added timeout %p (%s)", t, t->enabled() ? "on":"off"); - - return t; -} - -void Ecore::BusDispatcher::rem_timeout( Timeout* t ) -{ - debug_log("ecore: removed timeout %p", t); - - delete t; -} - -Watch* Ecore::BusDispatcher::add_watch( Watch::Internal* wi ) -{ - Watch* w = new Ecore::BusWatch(wi); - - debug_log("ecore: added watch %p (%s) fd=%d flags=%d", - w, w->enabled() ? "on":"off", w->descriptor(), w->flags() - ); - return w; -} - -void Ecore::BusDispatcher::rem_watch( Watch* w ) -{ - debug_log("ecore: removed watch %p", w); - - delete w; -} diff --git a/sflphone-common/libs/dbus-c++/src/error.cpp b/sflphone-common/libs/dbus-c++/src/error.cpp deleted file mode 100644 index 840365bad4..0000000000 --- a/sflphone-common/libs/dbus-c++/src/error.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/message.h> -#include <dbus-c++/error.h> - -#include <dbus/dbus.h> - -#include "message_p.h" -#include "internalerror.h" - -using namespace DBus; - -/* -*/ - -Error::Error() -: _int(new InternalError) -{} - -Error::Error(InternalError &i) -: _int(new InternalError(i)) -{} - -Error::Error(const char *name, const char *message) -: _int(new InternalError) -{ - set(name, message); -} - -Error::Error(Message &m) -: _int(new InternalError) -{ - dbus_set_error_from_message(&(_int->error), m._pvt->msg); -} - -Error::~Error() throw() -{ -} - -const char *Error::name() const -{ - return _int->error.name; -} - -const char *Error::message() const -{ - return _int->error.message; -} - -bool Error::is_set() const -{ - return *(_int); -} - -void Error::set(const char *name, const char *message) -{ - dbus_set_error_const(&(_int->error), name, message); -} - -const char *Error::what() const throw() -{ - return _int->error.message; -} - diff --git a/sflphone-common/libs/dbus-c++/src/eventloop-integration.cpp b/sflphone-common/libs/dbus-c++/src/eventloop-integration.cpp deleted file mode 100644 index 0c86ffbb30..0000000000 --- a/sflphone-common/libs/dbus-c++/src/eventloop-integration.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -/* Project */ -#include <dbus-c++/eventloop-integration.h> -#include <dbus-c++/debug.h> -#include <dbus-c++/pipe.h> - -/* DBus */ -#include <dbus/dbus.h> - -/* STD */ -#include <string.h> -#include <cassert> -#include <sys/poll.h> -#include <fcntl.h> - -using namespace DBus; -using namespace std; - -BusTimeout::BusTimeout(Timeout::Internal *ti, BusDispatcher *bd) -: Timeout(ti), DefaultTimeout(Timeout::interval(), true, bd) -{ - DefaultTimeout::enabled(Timeout::enabled()); -} - -void BusTimeout::toggle() -{ - debug_log("timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off"); - - DefaultTimeout::enabled(Timeout::enabled()); -} - -BusWatch::BusWatch(Watch::Internal *wi, BusDispatcher *bd) -: Watch(wi), DefaultWatch(Watch::descriptor(), 0, bd) -{ - int flags = POLLHUP | POLLERR; - - if (Watch::flags() & DBUS_WATCH_READABLE) - flags |= POLLIN; - if (Watch::flags() & DBUS_WATCH_WRITABLE) - flags |= POLLOUT; - - DefaultWatch::flags(flags); - DefaultWatch::enabled(Watch::enabled()); -} - -void BusWatch::toggle() -{ - debug_log("watch %p toggled (%s)", this, Watch::enabled() ? "on":"off"); - - DefaultWatch::enabled(Watch::enabled()); -} - -BusDispatcher::BusDispatcher() : - _running(false) -{ - // pipe to create a new fd used to unlock a dispatcher at any - // moment (used by leave function) - int ret = pipe(_pipe); - if (ret == -1) throw Error("PipeError:errno", toString(errno).c_str()); - - _fdunlock[0] = _pipe[0]; - _fdunlock[1] = _pipe[1]; -} - -void BusDispatcher::enter() -{ - debug_log("entering dispatcher %p", this); - - _running = true; - - while (_running) - { - do_iteration(); - - for (std::list <Pipe*>::iterator p_it = pipe_list.begin (); - p_it != pipe_list.end (); - ++p_it) - { - Pipe* read_pipe = *p_it; - char buffer[1024]; // TODO: should be max pipe size - unsigned int nbytes = 0; - - while (read_pipe->read(buffer, nbytes) > 0) - { - read_pipe->_handler (read_pipe->_data, buffer, nbytes); - } - - } - } - - debug_log("leaving dispatcher %p", this); -} - -void BusDispatcher::leave() -{ - _running = false; - - int ret = write(_fdunlock[1],"exit",strlen("exit")); - if (ret == -1) throw Error("WriteError:errno", toString(errno).c_str()); - - close(_fdunlock[1]); - close(_fdunlock[0]); -} - -Pipe *BusDispatcher::add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data) -{ - Pipe *new_pipe = new Pipe (handler, data); - pipe_list.push_back (new_pipe); - - return new_pipe; -} - -void BusDispatcher::del_pipe (Pipe *pipe) -{ - pipe_list.remove (pipe); - delete pipe; -} - -void BusDispatcher::do_iteration() -{ - dispatch_pending(); - dispatch(); -} - -Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti) -{ - BusTimeout *bt = new BusTimeout(ti, this); - - bt->expired = new Callback<BusDispatcher, void, DefaultTimeout &>(this, &BusDispatcher::timeout_expired); - bt->data(bt); - - debug_log("added timeout %p (%s) (%d millies)", - bt, - ((Timeout*)bt)->enabled() ? "on":"off", - ((Timeout*)bt)->interval() - ); - - return bt; -} - -void BusDispatcher::rem_timeout(Timeout *t) -{ - debug_log("removed timeout %p", t); - - delete t; -} - -Watch *BusDispatcher::add_watch(Watch::Internal *wi) -{ - BusWatch *bw = new BusWatch(wi, this); - - bw->ready = new Callback<BusDispatcher, void, DefaultWatch &>(this, &BusDispatcher::watch_ready); - bw->data(bw); - - debug_log("added watch %p (%s) fd=%d flags=%d", - bw, ((Watch *)bw)->enabled() ? "on":"off", ((Watch *)bw)->descriptor(), ((Watch *)bw)->flags()); - - return bw; -} - -void BusDispatcher::rem_watch(Watch *w) -{ - debug_log("removed watch %p", w); - - delete w; -} - -void BusDispatcher::timeout_expired(DefaultTimeout &et) -{ - debug_log("timeout %p expired", &et); - - BusTimeout *timeout = reinterpret_cast<BusTimeout *>(et.data()); - - timeout->handle(); -} - -void BusDispatcher::watch_ready(DefaultWatch &ew) -{ - BusWatch *watch = reinterpret_cast<BusWatch *>(ew.data()); - - debug_log("watch %p ready, flags=%d state=%d", - watch, ((Watch *)watch)->flags(), watch->state() - ); - - int flags = 0; - - if (watch->state() & POLLIN) - flags |= DBUS_WATCH_READABLE; - if (watch->state() & POLLOUT) - flags |= DBUS_WATCH_WRITABLE; - if (watch->state() & POLLHUP) - flags |= DBUS_WATCH_HANGUP; - if (watch->state() & POLLERR) - flags |= DBUS_WATCH_ERROR; - - watch->handle(flags); -} - diff --git a/sflphone-common/libs/dbus-c++/src/eventloop.cpp b/sflphone-common/libs/dbus-c++/src/eventloop.cpp deleted file mode 100644 index eb2ce85f5b..0000000000 --- a/sflphone-common/libs/dbus-c++/src/eventloop.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/eventloop.h> -#include <dbus-c++/debug.h> - -#include <sys/poll.h> -#include <sys/time.h> - -#include <dbus/dbus.h> - -using namespace DBus; -using namespace std; - -static double millis(timeval tv) -{ - return (tv.tv_sec *1000.0 + tv.tv_usec/1000.0); -} - -DefaultTimeout::DefaultTimeout(int interval, bool repeat, DefaultMainLoop *ed) -: _enabled(true), _interval(interval), _repeat(repeat), _expiration(0), _data(0), _disp(ed) -{ - timeval now; - gettimeofday(&now, NULL); - - _expiration = millis(now) + interval; - - _disp->_mutex_t.lock(); - _disp->_timeouts.push_back(this); - _disp->_mutex_t.unlock(); -} - -DefaultTimeout::~DefaultTimeout() -{ - _disp->_mutex_t.lock(); - _disp->_timeouts.remove(this); - _disp->_mutex_t.unlock(); -} - -DefaultWatch::DefaultWatch(int fd, int flags, DefaultMainLoop *ed) -: _enabled(true), _fd(fd), _flags(flags), _state(0), _data(0), _disp(ed) -{ - _disp->_mutex_w.lock(); - _disp->_watches.push_back(this); - _disp->_mutex_w.unlock(); -} - -DefaultWatch::~DefaultWatch() -{ - _disp->_mutex_w.lock(); - _disp->_watches.remove(this); - _disp->_mutex_w.unlock(); -} - -DefaultMutex::DefaultMutex() -{ - pthread_mutex_init(&_mutex, NULL); -} - -DefaultMutex::DefaultMutex(bool recursive) -{ - if (recursive) - { - pthread_mutex_t recmutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; - _mutex = recmutex; - } - else - { - pthread_mutex_init(&_mutex, NULL); - } -} - -DefaultMutex::~DefaultMutex() -{ - pthread_mutex_destroy(&_mutex); -} - -void DefaultMutex::lock() -{ - pthread_mutex_lock(&_mutex); -} - -void DefaultMutex::unlock() -{ - pthread_mutex_unlock(&_mutex); -} - -DefaultMainLoop::DefaultMainLoop() : - _mutex_w(true) -{ -} - -DefaultMainLoop::~DefaultMainLoop() -{ - _mutex_w.lock(); - - DefaultWatches::iterator wi = _watches.begin(); - while (wi != _watches.end()) - { - DefaultWatches::iterator wmp = wi; - ++wmp; - _mutex_w.unlock(); - delete (*wi); - _mutex_w.lock(); - wi = wmp; - } - _mutex_w.unlock(); - - _mutex_t.lock(); - - DefaultTimeouts::iterator ti = _timeouts.begin(); - while (ti != _timeouts.end()) - { - DefaultTimeouts::iterator tmp = ti; - ++tmp; - _mutex_t.unlock(); - delete (*ti); - _mutex_t.lock(); - ti = tmp; - } - _mutex_t.unlock(); -} - -void DefaultMainLoop::dispatch() -{ - _mutex_w.lock(); - - int nfd = _watches.size(); - - if(_fdunlock) - { - nfd=nfd+2; - } - - pollfd fds[nfd]; - - DefaultWatches::iterator wi = _watches.begin(); - - for (nfd = 0; wi != _watches.end(); ++wi) - { - if ((*wi)->enabled()) - { - fds[nfd].fd = (*wi)->descriptor(); - fds[nfd].events = (*wi)->flags(); - fds[nfd].revents = 0; - - ++nfd; - } - } - - if(_fdunlock){ - fds[nfd].fd = _fdunlock[0]; - fds[nfd].events = POLLIN | POLLOUT | POLLPRI ; - fds[nfd].revents = 0; - - nfd++; - fds[nfd].fd = _fdunlock[1]; - fds[nfd].events = POLLIN | POLLOUT | POLLPRI ; - fds[nfd].revents = 0; - } - - _mutex_w.unlock(); - - int wait_min = 10000; - - DefaultTimeouts::iterator ti; - - _mutex_t.lock(); - - for (ti = _timeouts.begin(); ti != _timeouts.end(); ++ti) - { - if ((*ti)->enabled() && (*ti)->interval() < wait_min) - wait_min = (*ti)->interval(); - } - - _mutex_t.unlock(); - - poll(fds, nfd, wait_min); - - timeval now; - gettimeofday(&now, NULL); - - double now_millis = millis(now); - - _mutex_t.lock(); - - ti = _timeouts.begin(); - - while (ti != _timeouts.end()) - { - DefaultTimeouts::iterator tmp = ti; - ++tmp; - - if ((*ti)->enabled() && now_millis >= (*ti)->_expiration) - { - (*ti)->expired(*(*ti)); - - if ((*ti)->_repeat) - { - (*ti)->_expiration = now_millis + (*ti)->_interval; - } - - } - - ti = tmp; - } - - _mutex_t.unlock(); - - _mutex_w.lock(); - - for (int j = 0; j < nfd; ++j) - { - DefaultWatches::iterator wi; - - for (wi = _watches.begin(); wi != _watches.end();) - { - DefaultWatches::iterator tmp = wi; - ++tmp; - - if ((*wi)->enabled() && (*wi)->_fd == fds[j].fd) - { - if (fds[j].revents) - { - (*wi)->_state = fds[j].revents; - - (*wi)->ready(*(*wi)); - - fds[j].revents = 0; - } - } - - wi = tmp; - } - } - _mutex_w.unlock(); -} - diff --git a/sflphone-common/libs/dbus-c++/src/glib-integration.cpp b/sflphone-common/libs/dbus-c++/src/glib-integration.cpp deleted file mode 100644 index 491c950129..0000000000 --- a/sflphone-common/libs/dbus-c++/src/glib-integration.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <dbus-c++/glib-integration.h> - -#include <dbus/dbus.h> // for DBUS_WATCH_* - -using namespace DBus; - -Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority) -: Timeout(ti), _ctx(ctx), _priority(priority), _source(NULL) -{ - if (Timeout::enabled()) - _enable(); -} - -Glib::BusTimeout::~BusTimeout() -{ - _disable(); -} - -void Glib::BusTimeout::toggle() -{ - debug_log("glib: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off"); - - if (Timeout::enabled()) _enable(); - else _disable(); -} - -gboolean Glib::BusTimeout::timeout_handler(gpointer data) -{ - Glib::BusTimeout *t = reinterpret_cast<Glib::BusTimeout *>(data); - - t->handle(); - - return TRUE; -} - -void Glib::BusTimeout::_enable() -{ - if (_source) - _disable(); // be sane - - _source = g_timeout_source_new(Timeout::interval()); - g_source_set_priority(_source, _priority); - g_source_set_callback(_source, timeout_handler, this, NULL); - g_source_attach(_source, _ctx); -} - -void Glib::BusTimeout::_disable() -{ - if (_source) - { - g_source_destroy(_source); - _source = NULL; - } -} - -struct BusSource -{ - GSource source; - GPollFD poll; -}; - -static gboolean watch_prepare(GSource *source, gint *timeout) -{ - //debug_log("glib: watch_prepare"); - - *timeout = -1; - return FALSE; -} - -static gboolean watch_check(GSource *source) -{ - //debug_log("glib: watch_check"); - - BusSource *io = (BusSource *)source; - return io->poll.revents ? TRUE : FALSE; -} - -static gboolean watch_dispatch(GSource *source, GSourceFunc callback, gpointer data) -{ - debug_log("glib: watch_dispatch"); - - gboolean cb = callback(data); - return cb; -} - -static GSourceFuncs watch_funcs = { - watch_prepare, - watch_check, - watch_dispatch, - NULL -}; - -Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority) -: Watch(wi), _ctx(ctx), _priority(priority), _source(NULL) -{ - if (Watch::enabled()) - _enable(); -} - -Glib::BusWatch::~BusWatch() -{ - _disable(); -} - -void Glib::BusWatch::toggle() -{ - debug_log("glib: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off"); - - if (Watch::enabled()) _enable(); - else _disable(); -} - -gboolean Glib::BusWatch::watch_handler(gpointer data) -{ - Glib::BusWatch *w = reinterpret_cast<Glib::BusWatch *>(data); - - BusSource *io = (BusSource *)(w->_source); - - int flags = 0; - if (io->poll.revents &G_IO_IN) - flags |= DBUS_WATCH_READABLE; - if (io->poll.revents &G_IO_OUT) - flags |= DBUS_WATCH_WRITABLE; - if (io->poll.revents &G_IO_ERR) - flags |= DBUS_WATCH_ERROR; - if (io->poll.revents &G_IO_HUP) - flags |= DBUS_WATCH_HANGUP; - - w->handle(flags); - - return TRUE; -} - -void Glib::BusWatch::_enable() -{ - if (_source) - _disable(); // be sane - _source = g_source_new(&watch_funcs, sizeof(BusSource)); - g_source_set_priority(_source, _priority); - g_source_set_callback(_source, watch_handler, this, NULL); - - int flags = Watch::flags(); - int condition = 0; - - if (flags &DBUS_WATCH_READABLE) - condition |= G_IO_IN; - if (flags &DBUS_WATCH_WRITABLE) - condition |= G_IO_OUT; - if (flags &DBUS_WATCH_ERROR) - condition |= G_IO_ERR; - if (flags &DBUS_WATCH_HANGUP) - condition |= G_IO_HUP; - - GPollFD *poll = &(((BusSource *)_source)->poll); - poll->fd = Watch::descriptor(); - poll->events = condition; - poll->revents = 0; - - g_source_add_poll(_source, poll); - g_source_attach(_source, _ctx); -} - -void Glib::BusWatch::_disable() -{ - if (!_source) - return; - GPollFD *poll = &(((BusSource *)_source)->poll); - g_source_remove_poll(_source, poll); - g_source_destroy(_source); - _source = NULL; -} - -/* - * We need this on top of the IO handlers, because sometimes - * there are messages to dispatch queued up but no IO pending. - * (fixes also a previous problem of code not working in case of multiple dispatchers) -*/ -struct DispatcherSource -{ - GSource source; - Dispatcher *dispatcher; -}; - - -static gboolean dispatcher_prepare(GSource *source, gint *timeout) -{ - Dispatcher *dispatcher = ((DispatcherSource*)source)->dispatcher; - - *timeout = -1; - - return dispatcher->has_something_to_dispatch()? TRUE:FALSE; -} - -static gboolean dispatcher_check(GSource *source) -{ - return FALSE; -} - -static gboolean -dispatcher_dispatch(GSource *source, - GSourceFunc callback, - gpointer user_data) -{ - Dispatcher *dispatcher = ((DispatcherSource*)source)->dispatcher; - - dispatcher->dispatch_pending(); - return TRUE; -} - -static const GSourceFuncs dispatcher_funcs = { - dispatcher_prepare, - dispatcher_check, - dispatcher_dispatch, - NULL -}; - -Glib::BusDispatcher::BusDispatcher() -: _ctx(NULL), _priority(G_PRIORITY_DEFAULT), _source(NULL) -{ -} - -Glib::BusDispatcher::~BusDispatcher() -{ - if (_source) - { - GSource *temp = _source; - _source = NULL; - - g_source_destroy (temp); - g_source_unref (temp); - } - - if (_ctx) - g_main_context_unref(_ctx); -} - -void Glib::BusDispatcher::attach(GMainContext *ctx) -{ - g_assert(_ctx == NULL); // just to be sane - - _ctx = ctx ? ctx : g_main_context_default(); - g_main_context_ref(_ctx); - - // create the source for dispatching messages - _source = g_source_new((GSourceFuncs *) &dispatcher_funcs, - sizeof(DispatcherSource)); - - ((DispatcherSource*)_source)->dispatcher = this; - g_source_attach (_source, _ctx); -} - -Timeout *Glib::BusDispatcher::add_timeout(Timeout::Internal *wi) -{ - Timeout *t = new Glib::BusTimeout(wi, _ctx, _priority); - - debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off"); - - return t; -} - -void Glib::BusDispatcher::rem_timeout(Timeout *t) -{ - debug_log("glib: removed timeout %p", t); - - delete t; -} - -Watch *Glib::BusDispatcher::add_watch(Watch::Internal *wi) -{ - Watch *w = new Glib::BusWatch(wi, _ctx, _priority); - - debug_log("glib: added watch %p (%s) fd=%d flags=%d", - w, w->enabled() ? "on":"off", w->descriptor(), w->flags() - ); - return w; -} - -void Glib::BusDispatcher::rem_watch(Watch *w) -{ - debug_log("glib: removed watch %p", w); - - delete w; -} - -void Glib::BusDispatcher::set_priority(int priority) -{ - _priority = priority; -} diff --git a/sflphone-common/libs/dbus-c++/src/interface.cpp b/sflphone-common/libs/dbus-c++/src/interface.cpp deleted file mode 100644 index b0360ac979..0000000000 --- a/sflphone-common/libs/dbus-c++/src/interface.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/debug.h> -#include <dbus-c++/interface.h> - -#include "internalerror.h" - -using namespace DBus; - -Interface::Interface(const std::string &name) -: _name(name) -{} - -Interface::~Interface() -{} - -InterfaceAdaptor *AdaptorBase::find_interface(const std::string &name) -{ - InterfaceAdaptorTable::const_iterator ii = _interfaces.find(name); - - return ii != _interfaces.end() ? ii->second : NULL; -} - -InterfaceAdaptor::InterfaceAdaptor(const std::string &name) -: Interface(name) -{ - debug_log("adding interface %s", name.c_str()); - - _interfaces[name] = this; -} - -Message InterfaceAdaptor::dispatch_method(const CallMessage &msg) -{ - const char *name = msg.member(); - - MethodTable::iterator mi = _methods.find(name); - if (mi != _methods.end()) - { - return mi->second.call(msg); - } - else - { - return ErrorMessage(msg, DBUS_ERROR_UNKNOWN_METHOD, name); - } -} - -void InterfaceAdaptor::emit_signal(const SignalMessage &sig) -{ - SignalMessage &sig2 = const_cast<SignalMessage &>(sig); - - if (sig2.interface() == NULL) - sig2.interface(name().c_str()); - - _emit_signal(sig2); -} - -Variant *InterfaceAdaptor::get_property(const std::string &name) -{ - PropertyTable::iterator pti = _properties.find(name); - - if (pti != _properties.end()) - { - if (!pti->second.read) - throw ErrorAccessDenied("property is not readable"); - - return &(pti->second.value); - } - return NULL; -} - -void InterfaceAdaptor::set_property(const std::string &name, Variant &value) -{ - PropertyTable::iterator pti = _properties.find(name); - - if (pti != _properties.end()) - { - if (!pti->second.write) - throw ErrorAccessDenied("property is not writeable"); - - Signature sig = value.signature(); - - if (pti->second.sig != sig) - throw ErrorInvalidSignature("property expects a different type"); - - pti->second.value = value; - return; - } - throw ErrorFailed("requested property not found"); -} - -InterfaceProxy *ProxyBase::find_interface(const std::string &name) -{ - InterfaceProxyTable::const_iterator ii = _interfaces.find(name); - - return ii != _interfaces.end() ? ii->second : NULL; -} - -InterfaceProxy::InterfaceProxy(const std::string &name) -: Interface(name) -{ - debug_log("adding interface %s", name.c_str()); - - _interfaces[name] = this; -} - -bool InterfaceProxy::dispatch_signal(const SignalMessage &msg) -{ - const char *name = msg.member(); - - SignalTable::iterator si = _signals.find(name); - if (si != _signals.end()) - { - si->second.call(msg); - // Here we always return false because there might be - // another InterfaceProxy listening for the same signal. - // This way we instruct libdbus-1 to go on dispatching - // the signal. - return false; - } - else - { - return false; - } -} - -Message InterfaceProxy::invoke_method(const CallMessage &call) -{ - CallMessage &call2 = const_cast<CallMessage &>(call); - - if (call.interface() == NULL) - call2.interface(name().c_str()); - - return _invoke_method(call2); -} - -bool InterfaceProxy::invoke_method_noreply(const CallMessage &call) -{ - CallMessage &call2 = const_cast<CallMessage &>(call); - - if (call.interface() == NULL) - call2.interface(name().c_str()); - - return _invoke_method_noreply(call2); -} diff --git a/sflphone-common/libs/dbus-c++/src/internalerror.h b/sflphone-common/libs/dbus-c++/src/internalerror.h deleted file mode 100644 index 36fe20c6d2..0000000000 --- a/sflphone-common/libs/dbus-c++/src/internalerror.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_INTERNALERROR_H -#define __DBUSXX_INTERNALERROR_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/error.h> - -#include <dbus/dbus.h> - -namespace DBus { - -struct DXXAPI InternalError -{ - DBusError error; - - InternalError() - { - dbus_error_init(&error); - } - - explicit InternalError(DBusError *e) - { - dbus_error_init(&error); - dbus_move_error(e, &error); - } - - InternalError(const InternalError &ie) - { - dbus_error_init(&error); - dbus_move_error(const_cast<DBusError *>(&(ie.error)), &error); - } - - ~InternalError() - { - dbus_error_free(&error); - } - - operator DBusError *() - { - return &error; - } - - operator bool() - { - return dbus_error_is_set(&error); - } -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_INTERNALERROR_H diff --git a/sflphone-common/libs/dbus-c++/src/introspection.cpp b/sflphone-common/libs/dbus-c++/src/introspection.cpp deleted file mode 100644 index 11fa883af8..0000000000 --- a/sflphone-common/libs/dbus-c++/src/introspection.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/introspection.h> -#include <dbus-c++/object.h> -#include <dbus-c++/message.h> - -#include <dbus/dbus.h> - -#include <sstream> - -using namespace DBus; - -static const char *introspectable_name = "org.freedesktop.DBus.Introspectable"; - -IntrospectableAdaptor::IntrospectableAdaptor() -: InterfaceAdaptor(introspectable_name) -{ - register_method(IntrospectableAdaptor, Introspect, Introspect); -} - -Message IntrospectableAdaptor::Introspect(const CallMessage &call) -{ - debug_log("requested introspection data"); - - std::ostringstream xml; - - xml << DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE; - - const std::string path = object()->path(); - - xml << "<node name=\"" << path << "\">"; - - InterfaceAdaptorTable::const_iterator iti; - - for (iti = _interfaces.begin(); iti != _interfaces.end(); ++iti) - { - debug_log("introspecting interface %s", iti->first.c_str()); - - IntrospectedInterface *const intro = iti->second->introspect(); - if (intro) - { - xml << "\n\t<interface name=\"" << intro->name << "\">"; - - for (const IntrospectedProperty *p = intro->properties; p->name; ++p) - { - std::string access; - - if (p->read) access += "read"; - if (p->write) access += "write"; - - xml << "\n\t\t<property name=\"" << p->name << "\"" - << " type=\"" << p->type << "\"" - << " access=\"" << access << "\"/>"; - } - - for (const IntrospectedMethod *m = intro->methods; m->args; ++m) - { - xml << "\n\t\t<method name=\"" << m->name << "\">"; - - for (const IntrospectedArgument *a = m->args; a->type; ++a) - { - xml << "\n\t\t\t<arg direction=\"" << (a->in ? "in" : "out") << "\"" - << " type=\"" << a->type << "\""; - - if (a->name) xml << " name=\"" << a->name << "\""; - - xml << "/>"; - } - - xml << "\n\t\t</method>"; - } - - for (const IntrospectedMethod *m = intro->signals; m->args; ++m) - { - xml << "\n\t\t<signal name=\"" << m->name << "\">"; - - for (const IntrospectedArgument *a = m->args; a->type; ++a) - { - xml << "<arg type=\"" << a->type << "\""; - - if (a->name) xml << " name=\"" << a->name << "\""; - - xml << "/>"; - } - xml << "\n\t\t</signal>"; - } - - xml << "\n\t</interface>"; - } - } - - const ObjectPathList nodes = ObjectAdaptor::child_nodes_from_prefix(path + '/'); - ObjectPathList::const_iterator oni; - - for (oni = nodes.begin(); oni != nodes.end(); ++oni) - { - xml << "\n\t<node name=\"" << (*oni) << "\"/>"; - } - - /* broken - const ObjectAdaptorPList children = ObjectAdaptor::from_path_prefix(path + '/'); - - ObjectAdaptorPList::const_iterator oci; - - for (oci = children.begin(); oci != children.end(); ++oci) - { - std::string name = (*oci)->path().substr(path.length()+1); - name.substr(name.find('/')); - - xml << "<node name=\"" << name << "\"/>"; - } - */ - - xml << "\n</node>"; - - ReturnMessage reply(call); - MessageIter wi = reply.writer(); - wi.append_string(xml.str().c_str()); - return reply; -} - -IntrospectedInterface *const IntrospectableAdaptor::introspect() const -{ - static IntrospectedArgument Introspect_args[] = - { - { "data", "s", false }, - { 0, 0, 0 } - }; - static IntrospectedMethod Introspectable_methods[] = - { - { "Introspect", Introspect_args }, - { 0, 0 } - }; - static IntrospectedMethod Introspectable_signals[] = - { - { 0, 0 } - }; - static IntrospectedProperty Introspectable_properties[] = - { - { 0, 0, 0, 0 } - }; - static IntrospectedInterface Introspectable_interface = - { - introspectable_name, - Introspectable_methods, - Introspectable_signals, - Introspectable_properties - }; - return &Introspectable_interface; -} - -IntrospectableProxy::IntrospectableProxy() -: InterfaceProxy(introspectable_name) -{} - -std::string IntrospectableProxy::Introspect() -{ - DBus::CallMessage call; - - call.member("Introspect"); - - DBus::Message ret = invoke_method(call); - - DBus::MessageIter ri = ret.reader(); - const char *str = ri.get_string(); - - return str; -} diff --git a/sflphone-common/libs/dbus-c++/src/message.cpp b/sflphone-common/libs/dbus-c++/src/message.cpp deleted file mode 100644 index aa920b3767..0000000000 --- a/sflphone-common/libs/dbus-c++/src/message.cpp +++ /dev/null @@ -1,642 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/message.h> - -#include <dbus/dbus.h> -#include <cstdlib> - -#include "internalerror.h" -#include "message_p.h" - -using namespace DBus; - -/* -*/ - -int MessageIter::type() -{ - return dbus_message_iter_get_arg_type((DBusMessageIter *)&_iter); -} - -bool MessageIter::at_end() -{ - return type() == DBUS_TYPE_INVALID; -} - -bool MessageIter::has_next() -{ - return dbus_message_iter_has_next((DBusMessageIter *)&_iter); -} - -MessageIter &MessageIter::operator ++() -{ - dbus_message_iter_next((DBusMessageIter *)&_iter); - return (*this); -} - -MessageIter MessageIter::operator ++(int) -{ - MessageIter copy(*this); - ++(*this); - return copy; -} - -bool MessageIter::append_basic(int type_id, void *value) -{ - return dbus_message_iter_append_basic((DBusMessageIter *)&_iter, type_id, value); -} - -void MessageIter::get_basic(int type_id, void *ptr) -{ - if (type() != type_id) - throw ErrorInvalidArgs("type mismatch"); - - dbus_message_iter_get_basic((DBusMessageIter *)_iter, ptr); -} - -bool MessageIter::append_byte(unsigned char b) -{ - return append_basic(DBUS_TYPE_BYTE, &b); -} - -unsigned char MessageIter::get_byte() -{ - unsigned char b; - get_basic(DBUS_TYPE_BYTE, &b); - return b; -} - -bool MessageIter::append_bool(bool b) -{ - dbus_bool_t db = b; - return append_basic(DBUS_TYPE_BOOLEAN, &db); -} - -bool MessageIter::get_bool() -{ - dbus_bool_t db; - get_basic(DBUS_TYPE_BOOLEAN, &db); - return (bool)db; -} - -bool MessageIter::append_int16(signed short i) -{ - return append_basic(DBUS_TYPE_INT16, &i); -} - -signed short MessageIter::get_int16() -{ - signed short i; - get_basic(DBUS_TYPE_INT16, &i); - return i; -} - -bool MessageIter::append_uint16(unsigned short u) -{ - return append_basic(DBUS_TYPE_UINT16, &u); -} - -unsigned short MessageIter::get_uint16() -{ - unsigned short u; - get_basic(DBUS_TYPE_UINT16, &u); - return u; -} - -bool MessageIter::append_int32(signed int i) -{ - return append_basic(DBUS_TYPE_INT32, &i); -} - -signed int MessageIter::get_int32() -{ - signed int i; - get_basic(DBUS_TYPE_INT32, &i); - return i; -} - -bool MessageIter::append_uint32(unsigned int u) -{ - return append_basic(DBUS_TYPE_UINT32, &u); -} - -unsigned int MessageIter::get_uint32() -{ - unsigned int u; - get_basic(DBUS_TYPE_UINT32, &u); - return u; -} - -signed long long MessageIter::get_int64() -{ - signed long long i; - get_basic(DBUS_TYPE_INT64, &i); - return i; -} - -bool MessageIter::append_int64(signed long long i) -{ - return append_basic(DBUS_TYPE_INT64, &i); -} - -unsigned long long MessageIter::get_uint64() -{ - unsigned long long u; - get_basic(DBUS_TYPE_UINT64, &u); - return u; -} - -bool MessageIter::append_uint64(unsigned long long u) -{ - return append_basic(DBUS_TYPE_UINT64, &u); -} - -double MessageIter::get_double() -{ - double d; - get_basic(DBUS_TYPE_DOUBLE, &d); - return d; -} - -bool MessageIter::append_double(double d) -{ - return append_basic(DBUS_TYPE_DOUBLE, &d); -} - -bool MessageIter::append_string(const char *chars) -{ - return append_basic(DBUS_TYPE_STRING, &chars); -} - -const char *MessageIter::get_string() -{ - char *chars; - get_basic(DBUS_TYPE_STRING, &chars); - return chars; -} - -bool MessageIter::append_path(const char *chars) -{ - return append_basic(DBUS_TYPE_OBJECT_PATH, &chars); -} - -const char *MessageIter::get_path() -{ - char *chars; - get_basic(DBUS_TYPE_OBJECT_PATH, &chars); - return chars; -} - -bool MessageIter::append_signature(const char *chars) -{ - return append_basic(DBUS_TYPE_SIGNATURE, &chars); -} - -const char *MessageIter::get_signature() -{ - char *chars; - get_basic(DBUS_TYPE_SIGNATURE, &chars); - return chars; -} - -MessageIter MessageIter::recurse() -{ - MessageIter iter(msg()); - dbus_message_iter_recurse((DBusMessageIter *)&_iter, (DBusMessageIter *)&(iter._iter)); - return iter; -} - -char *MessageIter::signature() const -{ - return dbus_message_iter_get_signature((DBusMessageIter *)&_iter); -} - -bool MessageIter::append_array(char type, const void *ptr, size_t length) -{ - return dbus_message_iter_append_fixed_array((DBusMessageIter *)&_iter, type, &ptr, length); -} - -int MessageIter::array_type() -{ - return dbus_message_iter_get_element_type((DBusMessageIter *)&_iter); -} - -int MessageIter::get_array(void *ptr) -{ - int length; - dbus_message_iter_get_fixed_array((DBusMessageIter *)&_iter, ptr, &length); - return length; -} - -bool MessageIter::is_array() -{ - return dbus_message_iter_get_arg_type((DBusMessageIter *)&_iter) == DBUS_TYPE_ARRAY; -} - -bool MessageIter::is_dict() -{ - return is_array() && dbus_message_iter_get_element_type((DBusMessageIter *)_iter) == DBUS_TYPE_DICT_ENTRY; -} - -MessageIter MessageIter::new_array(const char *sig) -{ - MessageIter arr(msg()); - dbus_message_iter_open_container( - (DBusMessageIter *)&_iter, DBUS_TYPE_ARRAY, sig, (DBusMessageIter *)&(arr._iter) - ); - return arr; -} - -MessageIter MessageIter::new_variant(const char *sig) -{ - MessageIter var(msg()); - dbus_message_iter_open_container( - (DBusMessageIter *)_iter, DBUS_TYPE_VARIANT, sig, (DBusMessageIter *)&(var._iter) - ); - return var; -} - -MessageIter MessageIter::new_struct() -{ - MessageIter stu(msg()); - dbus_message_iter_open_container( - (DBusMessageIter *)_iter, DBUS_TYPE_STRUCT, NULL, (DBusMessageIter *)&(stu._iter) - ); - return stu; -} - -MessageIter MessageIter::new_dict_entry() -{ - MessageIter ent(msg()); - dbus_message_iter_open_container( - (DBusMessageIter *)_iter, DBUS_TYPE_DICT_ENTRY, NULL, (DBusMessageIter *)&(ent._iter) - ); - return ent; -} - -void MessageIter::close_container(MessageIter &container) -{ - dbus_message_iter_close_container((DBusMessageIter *)&_iter, (DBusMessageIter *)&(container._iter)); -} - -static bool is_basic_type(int typecode) -{ - switch (typecode) - { - case 'y': - case 'b': - case 'n': - case 'q': - case 'i': - case 'u': - case 'x': - case 't': - case 'd': - case 's': - case 'o': - case 'g': - return true; - default: - return false; - } -} - -void MessageIter::copy_data(MessageIter &to) -{ - for (MessageIter &from = *this; !from.at_end(); ++from) - { - if (is_basic_type(from.type())) - { - debug_log("copying basic type: %c", from.type()); - - unsigned char value[8]; - from.get_basic(from.type(), &value); - to.append_basic(from.type(), &value); - } - else - { - MessageIter from_container = from.recurse(); - char *sig = from_container.signature(); - - debug_log("copying compound type: %c[%s]", from.type(), sig); - - MessageIter to_container (to.msg()); - dbus_message_iter_open_container - ( - (DBusMessageIter *)&(to._iter), - from.type(), - from.type() == DBUS_TYPE_VARIANT ? NULL : sig, - (DBusMessageIter *)&(to_container._iter) - ); - - from_container.copy_data(to_container); - to.close_container(to_container); - free(sig); - } - } -} - -/* -*/ - -Message::Message() -: _pvt(new Private) -{ -} - -Message::Message(Message::Private *p, bool incref) -: _pvt(p) -{ - if (_pvt->msg && incref) dbus_message_ref(_pvt->msg); -} - -Message::Message(const Message &m) -: _pvt(m._pvt) -{ - dbus_message_ref(_pvt->msg); -} - -Message::~Message() -{ - dbus_message_unref(_pvt->msg); -} - -Message &Message::operator = (const Message &m) -{ - if (&m != this) - { - dbus_message_unref(_pvt->msg); - _pvt = m._pvt; - dbus_message_ref(_pvt->msg); - } - return *this; -} - -Message Message::copy() -{ - Private *pvt = new Private(dbus_message_copy(_pvt->msg)); - return Message(pvt); -} - -bool Message::append(int first_type, ...) -{ - va_list vl; - va_start(vl, first_type); - - bool b = dbus_message_append_args_valist(_pvt->msg, first_type, vl); - - va_end(vl); - return b; -} - -void Message::terminate() -{ - dbus_message_append_args(_pvt->msg, DBUS_TYPE_INVALID); -} - -int Message::type() const -{ - return dbus_message_get_type(_pvt->msg); -} - -int Message::serial() const -{ - return dbus_message_get_serial(_pvt->msg); -} - -int Message::reply_serial() const -{ - return dbus_message_get_reply_serial(_pvt->msg); -} - -bool Message::reply_serial(int s) -{ - return dbus_message_set_reply_serial(_pvt->msg, s); -} - -const char *Message::sender() const -{ - return dbus_message_get_sender(_pvt->msg); -} - -bool Message::sender(const char *s) -{ - return dbus_message_set_sender(_pvt->msg, s); -} - -const char *Message::destination() const -{ - return dbus_message_get_destination(_pvt->msg); -} - -bool Message::destination(const char *s) -{ - return dbus_message_set_destination(_pvt->msg, s); -} - -bool Message::is_error() const -{ - return type() == DBUS_MESSAGE_TYPE_ERROR; -} - -bool Message::is_signal(const char *interface, const char *member) const -{ - return dbus_message_is_signal(_pvt->msg, interface, member); -} - -MessageIter Message::writer() -{ - MessageIter iter(*this); - dbus_message_iter_init_append(_pvt->msg, (DBusMessageIter *)&(iter._iter)); - return iter; -} - -MessageIter Message::reader() const -{ - MessageIter iter(const_cast<Message &>(*this)); - dbus_message_iter_init(_pvt->msg, (DBusMessageIter *)&(iter._iter)); - return iter; -} - -/* -*/ - -ErrorMessage::ErrorMessage() -{ - _pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR); -} - -ErrorMessage::ErrorMessage(const Message &to_reply, const char *name, const char *message) -{ - _pvt->msg = dbus_message_new_error(to_reply._pvt->msg, name, message); -} - -bool ErrorMessage::operator == (const ErrorMessage &m) const -{ - return dbus_message_is_error(_pvt->msg, m.name()); -} - -const char *ErrorMessage::name() const -{ - return dbus_message_get_error_name(_pvt->msg); -} - -bool ErrorMessage::name(const char *n) -{ - return dbus_message_set_error_name(_pvt->msg, n); -} - -/* -*/ - -SignalMessage::SignalMessage(const char *name) -{ - _pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL); - member(name); -} - -SignalMessage::SignalMessage(const char *path, const char *interface, const char *name) -{ - _pvt->msg = dbus_message_new_signal(path, interface, name); -} - -bool SignalMessage::operator == (const SignalMessage &m) const -{ - return dbus_message_is_signal(_pvt->msg, m.interface(), m.member()); -} - -const char *SignalMessage::interface() const -{ - return dbus_message_get_interface(_pvt->msg); -} - -bool SignalMessage::interface(const char *i) -{ - return dbus_message_set_interface(_pvt->msg, i); -} - -const char *SignalMessage::member() const -{ - return dbus_message_get_member(_pvt->msg); -} - -bool SignalMessage::member(const char *m) -{ - return dbus_message_set_member(_pvt->msg, m); -} - -const char *SignalMessage::path() const -{ - return dbus_message_get_path(_pvt->msg); -} - -char ** SignalMessage::path_split() const -{ - char ** p; - dbus_message_get_path_decomposed(_pvt->msg, &p); //todo: return as a std::vector ? - return p; -} - -bool SignalMessage::path(const char *p) -{ - return dbus_message_set_path(_pvt->msg, p); -} - -/* -*/ - -CallMessage::CallMessage() -{ - _pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL); -} - -CallMessage::CallMessage(const char *dest, const char *path, const char *iface, const char *method) -{ - _pvt->msg = dbus_message_new_method_call(dest, path, iface, method); -} - -bool CallMessage::operator == (const CallMessage &m) const -{ - return dbus_message_is_method_call(_pvt->msg, m.interface(), m.member()); -} - -const char *CallMessage::interface() const -{ - return dbus_message_get_interface(_pvt->msg); -} - -bool CallMessage::interface(const char *i) -{ - return dbus_message_set_interface(_pvt->msg, i); -} - -const char *CallMessage::member() const -{ - return dbus_message_get_member(_pvt->msg); -} - -bool CallMessage::member(const char *m) -{ - return dbus_message_set_member(_pvt->msg, m); -} - -const char *CallMessage::path() const -{ - return dbus_message_get_path(_pvt->msg); -} - -char ** CallMessage::path_split() const -{ - char ** p; - dbus_message_get_path_decomposed(_pvt->msg, &p); - return p; -} - -bool CallMessage::path(const char *p) -{ - return dbus_message_set_path(_pvt->msg, p); -} - -const char *CallMessage::signature() const -{ - return dbus_message_get_signature(_pvt->msg); -} - -/* -*/ - -ReturnMessage::ReturnMessage(const CallMessage &callee) -{ - _pvt = new Private(dbus_message_new_method_return(callee._pvt->msg)); -} - -const char *ReturnMessage::signature() const -{ - return dbus_message_get_signature(_pvt->msg); -} - diff --git a/sflphone-common/libs/dbus-c++/src/message_p.h b/sflphone-common/libs/dbus-c++/src/message_p.h deleted file mode 100644 index 18fdb8e3ae..0000000000 --- a/sflphone-common/libs/dbus-c++/src/message_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_MESSAGE_P_H -#define __DBUSXX_MESSAGE_P_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/message.h> -#include <dbus-c++/refptr_impl.h> - -#include <dbus/dbus.h> - -namespace DBus { - -struct DXXAPILOCAL Message::Private -{ - DBusMessage *msg; - - Private() : msg(0) - {} - - Private(DBusMessage *m) : msg(m) - {} -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_MESSAGE_P_H diff --git a/sflphone-common/libs/dbus-c++/src/object.cpp b/sflphone-common/libs/dbus-c++/src/object.cpp deleted file mode 100644 index 88c3bb010c..0000000000 --- a/sflphone-common/libs/dbus-c++/src/object.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/debug.h> -#include <dbus-c++/object.h> -#include "internalerror.h" - -#include <cstring> -#include <map> -#include <dbus/dbus.h> - -#include "message_p.h" -#include "server_p.h" -#include "connection_p.h" - -using namespace DBus; - -Object::Object(Connection &conn, const Path &path, const char *service) -: _conn(conn), _path(path), _service(service ? service : ""), _default_timeout(-1) -{ -} - -Object::~Object() -{ -} - -void Object::set_timeout(int new_timeout) -{ - debug_log("%s: %d millies", __PRETTY_FUNCTION__, new_timeout); - if(new_timeout < 0 && new_timeout != -1) - throw ErrorInvalidArgs("Bad timeout, cannot set it"); - _default_timeout = new_timeout; -} - -struct ObjectAdaptor::Private -{ - static void unregister_function_stub(DBusConnection *, void *); - static DBusHandlerResult message_function_stub(DBusConnection *, DBusMessage *, void *); -}; - -static DBusObjectPathVTable _vtable = -{ - ObjectAdaptor::Private::unregister_function_stub, - ObjectAdaptor::Private::message_function_stub, - NULL, NULL, NULL, NULL -}; - -void ObjectAdaptor::Private::unregister_function_stub(DBusConnection *conn, void *data) -{ - //TODO: what do we have to do here ? -} - -DBusHandlerResult ObjectAdaptor::Private::message_function_stub(DBusConnection *, DBusMessage *dmsg, void *data) -{ - ObjectAdaptor *o = static_cast<ObjectAdaptor *>(data); - - if (o) - { - Message msg(new Message::Private(dmsg)); - - debug_log("in object %s", o->path().c_str()); - debug_log(" got message #%d from %s to %s", - msg.serial(), - msg.sender(), - msg.destination() - ); - - return o->handle_message(msg) - ? DBUS_HANDLER_RESULT_HANDLED - : DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - else - { - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } -} - -typedef std::map<Path, ObjectAdaptor *> ObjectAdaptorTable; -static ObjectAdaptorTable _adaptor_table; - -ObjectAdaptor *ObjectAdaptor::from_path(const Path &path) -{ - ObjectAdaptorTable::iterator ati = _adaptor_table.find(path); - - if (ati != _adaptor_table.end()) - return ati->second; - - return NULL; -} - -ObjectAdaptorPList ObjectAdaptor::from_path_prefix(const std::string &prefix) -{ - ObjectAdaptorPList ali; - - ObjectAdaptorTable::iterator ati = _adaptor_table.begin(); - - size_t plen = prefix.length(); - - while (ati != _adaptor_table.end()) - { - if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen)) - ali.push_back(ati->second); - - ++ati; - } - - return ali; -} - -ObjectPathList ObjectAdaptor::child_nodes_from_prefix(const std::string &prefix) -{ - ObjectPathList ali; - - ObjectAdaptorTable::iterator ati = _adaptor_table.begin(); - - size_t plen = prefix.length(); - - while (ati != _adaptor_table.end()) - { - if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen)) - { - std::string p = ati->second->path().substr(plen); - p = p.substr(0,p.find('/')); - ali.push_back(p); - } - ++ati; - } - - ali.sort(); - ali.unique(); - - return ali; -} - -ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path) -: Object(conn, path, conn.unique_name()) -{ - register_obj(); -} - -ObjectAdaptor::~ObjectAdaptor() -{ - unregister_obj(); -} - -void ObjectAdaptor::register_obj() -{ - debug_log("registering local object %s", path().c_str()); - - if (!dbus_connection_register_object_path(conn()._pvt->conn, path().c_str(), &_vtable, this)) - { - throw ErrorNoMemory("unable to register object path"); - } - - _adaptor_table[path()] = this; -} - -void ObjectAdaptor::unregister_obj() -{ - _adaptor_table.erase(path()); - - debug_log("unregistering local object %s", path().c_str()); - - dbus_connection_unregister_object_path(conn()._pvt->conn, path().c_str()); -} - -void ObjectAdaptor::_emit_signal(SignalMessage &sig) -{ - sig.path(path().c_str()); - - conn().send(sig); -} - -struct ReturnLaterError -{ - const Tag *tag; -}; - -bool ObjectAdaptor::handle_message(const Message &msg) -{ - switch (msg.type()) - { - case DBUS_MESSAGE_TYPE_METHOD_CALL: - { - const CallMessage &cmsg = reinterpret_cast<const CallMessage &>(msg); - const char *member = cmsg.member(); - const char *interface = cmsg.interface(); - - debug_log(" invoking method %s.%s", interface, member); - - InterfaceAdaptor *ii = find_interface(interface); - if (ii) - { - try - { - Message ret = ii->dispatch_method(cmsg); - conn().send(ret); - } - catch(Error &e) - { - ErrorMessage em(cmsg, e.name(), e.message()); - conn().send(em); - } - catch(ReturnLaterError &rle) - { - _continuations[rle.tag] = new Continuation(conn(), cmsg, rle.tag); - } - return true; - } - else - { - return false; - } - } - default: - { - return false; - } - } -} - -void ObjectAdaptor::return_later(const Tag *tag) -{ - ReturnLaterError rle = { tag }; - throw rle; -} - -void ObjectAdaptor::return_now(Continuation *ret) -{ - ret->_conn.send(ret->_return); - - ContinuationMap::iterator di = _continuations.find(ret->_tag); - - delete di->second; - - _continuations.erase(di); -} - -void ObjectAdaptor::return_error(Continuation *ret, const Error error) -{ - ret->_conn.send(ErrorMessage(ret->_call, error.name(), error.message())); - - ContinuationMap::iterator di = _continuations.find(ret->_tag); - - delete di->second; - - _continuations.erase(di); -} - -ObjectAdaptor::Continuation *ObjectAdaptor::find_continuation(const Tag *tag) -{ - ContinuationMap::iterator di = _continuations.find(tag); - - return di != _continuations.end() ? di->second : NULL; -} - -ObjectAdaptor::Continuation::Continuation(Connection &conn, const CallMessage &call, const Tag *tag) -: _conn(conn), _call(call), _return(_call), _tag(tag) -{ - _writer = _return.writer(); //todo: verify -} - -/* -*/ - -ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service) -: Object(conn, path, service) -{ - register_obj(); -} - -ObjectProxy::~ObjectProxy() -{ - unregister_obj(); -} - -void ObjectProxy::register_obj() -{ - debug_log("registering remote object %s", path().c_str()); - - _filtered = new Callback<ObjectProxy, bool, const Message &>(this, &ObjectProxy::handle_message); - - conn().add_filter(_filtered); - - InterfaceProxyTable::const_iterator ii = _interfaces.begin(); - while (ii != _interfaces.end()) - { - std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'"; - conn().add_match(im.c_str()); - ++ii; - } -} - -void ObjectProxy::unregister_obj() -{ - debug_log("unregistering remote object %s", path().c_str()); - - InterfaceProxyTable::const_iterator ii = _interfaces.begin(); - while (ii != _interfaces.end()) - { - std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'"; - conn().remove_match(im.c_str()); - ++ii; - } - conn().remove_filter(_filtered); -} - -Message ObjectProxy::_invoke_method(CallMessage &call) -{ - if (call.path() == NULL) - call.path(path().c_str()); - - if (call.destination() == NULL) - call.destination(service().c_str()); - - return conn().send_blocking(call, get_timeout()); -} - -bool ObjectProxy::_invoke_method_noreply(CallMessage &call) -{ - if (call.path() == NULL) - call.path(path().c_str()); - - if (call.destination() == NULL) - call.destination(service().c_str()); - - return conn().send(call); -} - -bool ObjectProxy::handle_message(const Message &msg) -{ - switch (msg.type()) - { - case DBUS_MESSAGE_TYPE_SIGNAL: - { - const SignalMessage &smsg = reinterpret_cast<const SignalMessage &>(msg); - const char *interface = smsg.interface(); - const char *member = smsg.member(); - const char *objpath = smsg.path(); - - if (objpath != path()) return false; - - debug_log("filtered signal %s(in %s) from %s to object %s", - member, interface, msg.sender(), objpath); - - InterfaceProxy *ii = find_interface(interface); - if (ii) - { - return ii->dispatch_signal(smsg); - } - else - { - return false; - } - } - default: - { - return false; - } - } -} diff --git a/sflphone-common/libs/dbus-c++/src/pendingcall.cpp b/sflphone-common/libs/dbus-c++/src/pendingcall.cpp deleted file mode 100644 index 3757d8fd1d..0000000000 --- a/sflphone-common/libs/dbus-c++/src/pendingcall.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/pendingcall.h> - -#include <dbus/dbus.h> - -#include "internalerror.h" -#include "pendingcall_p.h" -#include "message_p.h" - -using namespace DBus; - -PendingCall::Private::Private(DBusPendingCall *dpc) -: call(dpc), dataslot(-1) -{ - if (!dbus_pending_call_allocate_data_slot(&dataslot)) - { - throw ErrorNoMemory("Unable to allocate data slot"); - } -} - -PendingCall::Private::~Private() -{ - if (dataslot != -1) - { - dbus_pending_call_allocate_data_slot(&dataslot); - } -} - -void PendingCall::Private::notify_stub(DBusPendingCall *dpc, void *data) -{ - PendingCall::Private *pvt = static_cast<PendingCall::Private *>(data); - - PendingCall pc(pvt); - pvt->slot(pc); -} - -PendingCall::PendingCall(PendingCall::Private *p) -: _pvt(p) -{ - if (!dbus_pending_call_set_notify(_pvt->call, Private::notify_stub, p, NULL)) - { - throw ErrorNoMemory("Unable to initialize pending call"); - } -} - -PendingCall::PendingCall(const PendingCall &c) -: _pvt(c._pvt) -{ - dbus_pending_call_ref(_pvt->call); -} - -PendingCall::~PendingCall() -{ - dbus_pending_call_unref(_pvt->call); -} - -PendingCall &PendingCall::operator = (const PendingCall &c) -{ - if (&c != this) - { - dbus_pending_call_unref(_pvt->call); - _pvt = c._pvt; - dbus_pending_call_ref(_pvt->call); - } - return *this; -} - -bool PendingCall::completed() -{ - return dbus_pending_call_get_completed(_pvt->call); -} - -void PendingCall::cancel() -{ - dbus_pending_call_cancel(_pvt->call); -} - -void PendingCall::block() -{ - dbus_pending_call_block(_pvt->call); -} - -void PendingCall::data(void *p) -{ - if (!dbus_pending_call_set_data(_pvt->call, _pvt->dataslot, p, NULL)) - { - throw ErrorNoMemory("Unable to initialize data slot"); - } -} - -void *PendingCall::data() -{ - return dbus_pending_call_get_data(_pvt->call, _pvt->dataslot); -} - -Slot<void, PendingCall &>& PendingCall::slot() -{ - return _pvt->slot; -} - -Message PendingCall::steal_reply() -{ - DBusMessage *dmsg = dbus_pending_call_steal_reply(_pvt->call); - if (!dmsg) - { - dbus_bool_t callComplete = dbus_pending_call_get_completed(_pvt->call); - - if (callComplete) - throw ErrorNoReply("No reply available"); - else - throw ErrorNoReply("Call not complete"); - } - - return Message(new Message::Private(dmsg)); -} - diff --git a/sflphone-common/libs/dbus-c++/src/pendingcall_p.h b/sflphone-common/libs/dbus-c++/src/pendingcall_p.h deleted file mode 100644 index 0141c364fd..0000000000 --- a/sflphone-common/libs/dbus-c++/src/pendingcall_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_PENDING_CALL_P_H -#define __DBUSXX_PENDING_CALL_P_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/pendingcall.h> -#include <dbus-c++/refptr_impl.h> - -#include <dbus/dbus.h> - -namespace DBus { - -struct DXXAPILOCAL PendingCall::Private -{ - DBusPendingCall *call; - int dataslot; - Slot<void, PendingCall &> slot; - - Private(DBusPendingCall *); - - ~Private(); - - static void notify_stub(DBusPendingCall *dpc, void *data); -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_PENDING_CALL_P_H diff --git a/sflphone-common/libs/dbus-c++/src/pipe.cpp b/sflphone-common/libs/dbus-c++/src/pipe.cpp deleted file mode 100644 index 96f1b30fd0..0000000000 --- a/sflphone-common/libs/dbus-c++/src/pipe.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -/* Project */ -#include <dbus-c++/pipe.h> -#include <dbus-c++/util.h> -#include <dbus-c++/error.h> - -/* STD */ -#include <unistd.h> -#include <sys/poll.h> -#include <fcntl.h> -#include <errno.h> -#include <cassert> - -using namespace DBus; -using namespace std; - -Pipe::Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data) : - _handler(handler), - _fd_write (0), - _fd_read (0), - _data(data) -{ - int fd[2]; - - if(pipe(fd) == 0) - { - _fd_read = fd[0]; - _fd_write = fd[1]; - fcntl(_fd_read, F_SETFL, O_NONBLOCK); - } - else - { - throw Error("PipeError:errno", toString(errno).c_str()); - } -} - -void Pipe::write(const void *buffer, unsigned int nbytes) -{ - // first write the size into the pipe... - ::write(_fd_write, static_cast <const void*> (&nbytes), sizeof(nbytes)); - - // ...then write the real data - ::write(_fd_write, buffer, nbytes); -} - -ssize_t Pipe::read(void *buffer, unsigned int &nbytes) -{ - // first read the size from the pipe... - ::read(_fd_read, &nbytes, sizeof (nbytes)); - - //ssize_t size = 0; - return ::read(_fd_read, buffer, nbytes); -} - -void Pipe::signal() -{ - ::write(_fd_write, '\0', 1); -} diff --git a/sflphone-common/libs/dbus-c++/src/property.cpp b/sflphone-common/libs/dbus-c++/src/property.cpp deleted file mode 100644 index 15a2f5bcbd..0000000000 --- a/sflphone-common/libs/dbus-c++/src/property.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/debug.h> -#include <dbus-c++/property.h> - -#include <dbus-c++/introspection.h> - -using namespace DBus; - -static const char *properties_name = "org.freedesktop.DBus.Properties"; - -PropertiesAdaptor::PropertiesAdaptor() -: InterfaceAdaptor(properties_name) -{ - register_method(PropertiesAdaptor, Get, Get); - register_method(PropertiesAdaptor, Set, Set); -} - -Message PropertiesAdaptor::Get(const CallMessage &call) -{ - MessageIter ri = call.reader(); - - std::string iface_name; - std::string property_name; - - ri >> iface_name >> property_name; - - debug_log("requesting property %s on interface %s", property_name.c_str(), iface_name.c_str()); - - InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name); - - if (!interface) - throw ErrorFailed("requested interface not found"); - - Variant *value = interface->get_property(property_name); - - if (!value) - throw ErrorFailed("requested property not found"); - - on_get_property(*interface, property_name, *value); - - ReturnMessage reply(call); - - MessageIter wi = reply.writer(); - - wi << *value; - return reply; -} - -Message PropertiesAdaptor::Set(const CallMessage &call) -{ - MessageIter ri = call.reader(); - - std::string iface_name; - std::string property_name; - Variant value; - - ri >> iface_name >> property_name >> value; - - InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name); - - if (!interface) - throw ErrorFailed("requested interface not found"); - - on_set_property(*interface, property_name, value); - - interface->set_property(property_name, value); - - ReturnMessage reply(call); - - return reply; -} - -IntrospectedInterface *const PropertiesAdaptor::introspect() const -{ - static IntrospectedArgument Get_args[] = - { - { "interface_name", "s", true }, - { "property_name", "s", true }, - { "value", "v", false }, - { 0, 0, 0 } - }; - static IntrospectedArgument Set_args[] = - { - { "interface_name", "s", true }, - { "property_name", "s", true }, - { "value", "v", true }, - { 0, 0, 0 } - }; - static IntrospectedMethod Properties_methods[] = - { - { "Get", Get_args }, - { "Set", Set_args }, - { 0, 0 } - }; - static IntrospectedMethod Properties_signals[] = - { - { 0, 0 } - }; - static IntrospectedProperty Properties_properties[] = - { - { 0, 0, 0, 0 } - }; - static IntrospectedInterface Properties_interface = - { - properties_name, - Properties_methods, - Properties_signals, - Properties_properties - }; - return &Properties_interface; -} - -PropertiesProxy::PropertiesProxy() -: InterfaceProxy(properties_name) -{ -} - -Variant PropertiesProxy::Get(const std::string &iface, const std::string &property) -{ -//todo - Variant v; - return v; -} - -void PropertiesProxy::Set(const std::string &iface, const std::string &property, const Variant &value) -{ -//todo -} - diff --git a/sflphone-common/libs/dbus-c++/src/server.cpp b/sflphone-common/libs/dbus-c++/src/server.cpp deleted file mode 100644 index 0c652e5510..0000000000 --- a/sflphone-common/libs/dbus-c++/src/server.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/debug.h> -#include <dbus-c++/server.h> - -#include "internalerror.h" -#include "server_p.h" -#include "connection_p.h" -#include "dispatcher_p.h" - -using namespace DBus; - -Server::Private::Private(DBusServer *s) -: server(s) -{ -} - -Server::Private::~Private() -{ -} - -void Server::Private::on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data) -{ - Server *s = static_cast<Server *>(data); - - Connection nc (new Connection::Private(conn, s->_pvt.get())); - - s->_pvt->connections.push_back(nc); - - s->on_new_connection(nc); - - debug_log("incoming connection 0x%08x", conn); -} - -Server::Server(const char *address) -{ - InternalError e; - DBusServer *server = dbus_server_listen(address, e); - - if (e) throw Error(e); - - debug_log("server 0x%08x listening on %s", server, address); - - _pvt = new Private(server); - - dbus_server_set_new_connection_function(_pvt->server, Private::on_new_conn_cb, this, NULL); - - setup(default_dispatcher); -} -/* -Server::Server(const Server &s) -: _pvt(s._pvt) -{ - dbus_server_ref(_pvt->server); -} -*/ -Server::~Server() -{ - dbus_server_unref(_pvt->server); -} - -Dispatcher *Server::setup(Dispatcher *dispatcher) -{ - debug_log("registering stubs for server %p", _pvt->server); - - Dispatcher *prev = _pvt->dispatcher; - - dbus_server_set_watch_functions( - _pvt->server, - Dispatcher::Private::on_add_watch, - Dispatcher::Private::on_rem_watch, - Dispatcher::Private::on_toggle_watch, - dispatcher, - 0 - ); - - dbus_server_set_timeout_functions( - _pvt->server, - Dispatcher::Private::on_add_timeout, - Dispatcher::Private::on_rem_timeout, - Dispatcher::Private::on_toggle_timeout, - dispatcher, - 0 - ); - - _pvt->dispatcher = dispatcher; - - return prev; -} - -bool Server::operator == (const Server &s) const -{ - return _pvt->server == s._pvt->server; -} - -bool Server::listening() const -{ - return dbus_server_get_is_connected(_pvt->server); -} -void Server::disconnect() -{ - dbus_server_disconnect(_pvt->server); -} - diff --git a/sflphone-common/libs/dbus-c++/src/server_p.h b/sflphone-common/libs/dbus-c++/src/server_p.h deleted file mode 100644 index 826132d2bd..0000000000 --- a/sflphone-common/libs/dbus-c++/src/server_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_SERVER_P_H -#define __DBUSXX_SERVER_P_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/server.h> -#include <dbus-c++/dispatcher.h> -#include <dbus-c++/refptr_impl.h> - -#include <dbus/dbus.h> - -namespace DBus { - -struct DXXAPILOCAL Server::Private -{ - DBusServer *server; - - Dispatcher *dispatcher; - - ConnectionList connections; - - Private(DBusServer *); - - ~Private(); - - static void on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data); -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_SERVER_P_H diff --git a/sflphone-common/libs/dbus-c++/src/types.cpp b/sflphone-common/libs/dbus-c++/src/types.cpp deleted file mode 100644 index 117cca30b5..0000000000 --- a/sflphone-common/libs/dbus-c++/src/types.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dbus-c++/types.h> -#include <dbus-c++/object.h> -#include <dbus/dbus.h> -#include <cstdlib> -#include <stdarg.h> - -#include "message_p.h" -#include "internalerror.h" - -using namespace DBus; - -Variant::Variant() -: _msg(CallMessage()) // dummy message used as temporary storage for variant data -{ -} - -Variant::Variant(MessageIter &it) -: _msg(CallMessage()) -{ - MessageIter vi = it.recurse(); - MessageIter mi = _msg.writer(); - vi.copy_data(mi); -} - -Variant &Variant::operator = (const Variant &v) -{ - if (&v != this) - { - _msg = v._msg; - } - return *this; -} - -void Variant::clear() -{ - CallMessage empty; - _msg = empty; -} - -const Signature Variant::signature() const -{ - char *sigbuf = reader().signature(); - - Signature signature = sigbuf; - - free(sigbuf); - - return signature; -} - -MessageIter &operator << (MessageIter &iter, const Variant &val) -{ - const Signature sig = val.signature(); - - MessageIter rit = val.reader(); - MessageIter wit = iter.new_variant(sig.c_str()); - - rit.copy_data(wit); - - iter.close_container(wit); - - return iter; -} - -MessageIter &operator >> (MessageIter &iter, Variant &val) -{ - if (iter.type() != DBUS_TYPE_VARIANT) - throw ErrorInvalidArgs("variant type expected"); - - val.clear(); - - MessageIter vit = iter.recurse(); - MessageIter mit = val.writer(); - - vit.copy_data(mit); - - return ++iter; -} - diff --git a/sflphone-common/libs/dbus-c++/tools/Makefile.am b/sflphone-common/libs/dbus-c++/tools/Makefile.am deleted file mode 100644 index e8100b373b..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# Hacky, but ... - -# CXX = $(CXX_FOR_BUILD) - -AM_CPPFLAGS = \ - $(dbus_CFLAGS) \ - $(xml_CFLAGS) \ - -I$(top_srcdir)/libs/dbus-c++/include \ - -I$(top_builddir)/libs/dbus-c++/include - -#if CROSS_COMPILING -#libdbus_cxx_la = $(BUILD_LIBDBUS_CXX_DIR)/src/libdbus-c++-1.la -#else -libdbus_cxx_la = $(top_builddir)/libs/dbus-c++/src/libdbus-c++-1.la -#endif - -noinst_PROGRAMS = dbusxx-xml2cpp dbusxx-introspect - -dbusxx_xml2cpp_SOURCES = xml.h xml.cpp xml2cpp.h xml2cpp.cpp \ - generate_adaptor.cpp generate_adaptor.h generate_proxy.cpp\ - generate_proxy.h generator_utils.cpp generator_utils.h -dbusxx_xml2cpp_LDADD = $(libdbus_cxx_la) $(xml_LIBS) - -dbusxx_introspect_SOURCES = introspect.h introspect.cpp -dbusxx_introspect_LDADD = $(libdbus_cxx_la) - -MAINTAINERCLEANFILES = \ - Makefile.in diff --git a/sflphone-common/libs/dbus-c++/tools/generate_adaptor.cpp b/sflphone-common/libs/dbus-c++/tools/generate_adaptor.cpp deleted file mode 100644 index c23ef389ee..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/generate_adaptor.cpp +++ /dev/null @@ -1,722 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <iostream> -#include <fstream> -#include <cstdlib> -#include <algorithm> - -#include "generator_utils.h" -#include "generate_adaptor.h" - -using namespace std; -using namespace DBus; - -extern const char *tab; -extern const char *header; -extern const char *dbus_includes; - -/*! Generate adaptor code for a XML introspection - */ -void generate_adaptor(Xml::Document &doc, const char *filename) -{ - ostringstream body; - ostringstream head; - vector <string> include_vector; - - head << header; - string filestring = filename; - underscorize(filestring); - - string cond_comp = "__dbusxx__" + filestring + "__ADAPTOR_MARSHAL_H"; - - head << "#ifndef " << cond_comp << endl - << "#define " << cond_comp << endl; - - head << dbus_includes; - - Xml::Node &root = *(doc.root); - Xml::Nodes interfaces = root["interface"]; - - // iterate over all interface definitions - for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) - { - Xml::Node &iface = **i; - Xml::Nodes methods = iface["method"]; - Xml::Nodes signals = iface["signal"]; - Xml::Nodes properties = iface["property"]; - Xml::Nodes ms; - ms.insert(ms.end(), methods.begin(), methods.end()); - ms.insert(ms.end(), signals.begin(), signals.end()); - - // gets the name of a interface: <interface name="XYZ"> - string ifacename = iface.get("name"); - - // these interface names are skipped. - if (ifacename == "org.freedesktop.DBus.Introspectable" - ||ifacename == "org.freedesktop.DBus.Properties") - { - cerr << "skipping interface " << ifacename << endl; - continue; - } - - istringstream ss(ifacename); - string nspace; - unsigned int nspaces = 0; - - // prints all the namespaces defined with <interface name="X.Y.Z"> - while (ss.str().find('.', ss.tellg()) != string::npos) - { - getline(ss, nspace, '.'); - - body << "namespace " << nspace << " {" << endl; - - ++nspaces; - } - body << endl; - - string ifaceclass; - - getline(ss, ifaceclass); - - // a "_adaptor" is added to class name to distinguish between proxy and adaptor - ifaceclass += "_adaptor"; - - cerr << "generating code for interface " << ifacename << "..." << endl; - - // the code from class definiton up to opening of the constructor is generated... - body << "class " << ifaceclass << endl - << ": public ::DBus::InterfaceAdaptor" << endl - << "{" << endl - << "public:" << endl - << endl - << tab << ifaceclass << "()" << endl - << tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl - << tab << "{" << endl; - - // generates code to bind the properties - for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) - { - Xml::Node &property = **pi; - - body << tab << tab << "bind_property(" - << property.get("name") << ", " - << "\"" << property.get("type") << "\", " - << (property.get("access").find("read") != string::npos - ? "true" - : "false") - << ", " - << (property.get("access").find("write") != string::npos - ? "true" - : "false") - << ");" << endl; - } - - // generate code to register all methods - for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) - { - Xml::Node &method = **mi; - - body << tab << tab << "register_method(" - << ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name")) - << ");" << endl; - } - - body << tab << "}" << endl - << endl; - - body << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl - << tab << "{" << endl; - - // generate the introspect arguments - for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi) - { - Xml::Node &method = **mi; - Xml::Nodes args = method["arg"]; - - body << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl - << tab << tab << "{" << endl; - - for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai) - { - Xml::Node &arg = **ai; - - body << tab << tab << tab << "{ "; - - if (arg.get("name").length()) - { - body << "\"" << arg.get("name") << "\", "; - } - else - { - body << "0, "; - } - body << "\"" << arg.get("type") << "\", " - << (arg.get("direction") == "in" ? "true" : "false") - << " }," << endl; - } - body << tab << tab << tab << "{ 0, 0, 0 }" << endl - << tab << tab << "};" << endl; - } - - body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl - << tab << tab << "{" << endl; - - // generate the introspect methods - for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) - { - Xml::Node &method = **mi; - - body << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl; - } - - body << tab << tab << tab << "{ 0, 0 }" << endl - << tab << tab << "};" << endl; - - body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl - << tab << tab << "{" << endl; - - for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) - { - Xml::Node &method = **si; - - body << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl; - } - - body << tab << tab << tab << "{ 0, 0 }" << endl - << tab << tab << "};" << endl; - - body << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl - << tab << tab << "{" << endl; - - for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) - { - Xml::Node &property = **pi; - - body << tab << tab << tab << "{ " - << "\"" << property.get("name") << "\", " - << "\"" << property.get("type") << "\", " - << (property.get("access").find("read") != string::npos - ? "true" - : "false") - << ", " - << (property.get("access").find("write") != string::npos - ? "true" - : "false") - << " }," << endl; - } - - - body << tab << tab << tab << "{ 0, 0, 0, 0 }" << endl - << tab << tab << "};" << endl; - - // generate the Introspected interface - body << tab << tab << "static ::DBus::IntrospectedInterface " << ifaceclass << "_interface = " << endl - << tab << tab << "{" << endl - << tab << tab << tab << "\"" << ifacename << "\"," << endl - << tab << tab << tab << ifaceclass << "_methods," << endl - << tab << tab << tab << ifaceclass << "_signals," << endl - << tab << tab << tab << ifaceclass << "_properties" << endl - << tab << tab << "};" << endl - << tab << tab << "return &" << ifaceclass << "_interface;" << endl - << tab << "}" << endl - << endl; - - body << "public:" << endl - << endl - << tab << "/* properties exposed by this interface, use" << endl - << tab << " * property() and property(value) to get and set a particular property" << endl - << tab << " */" << endl; - - // generate the properties code - for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) - { - Xml::Node &property = **pi; - string name = property.get("name"); - string type = property.get("type"); - string type_name = signature_to_type(type); - - body << tab << "::DBus::PropertyAdaptor< " << type_name << " > " << name << ";" << endl; - } - - body << endl; - - body << "public:" << endl - << endl - << tab << "/* methods exported by this interface," << endl - << tab << " * you will have to implement them in your ObjectAdaptor" << endl - << tab << " */" << endl; - - // generate the methods code - for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) - { - Xml::Node &method = **mi; - Xml::Nodes args = method["arg"]; - Xml::Nodes args_in = args.select("direction","in"); - Xml::Nodes args_out = args.select("direction","out"); - Xml::Nodes annotations = args["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - body << tab << "virtual "; - - // return type is 'void' if none or multible return values - if (args_out.size() == 0 || args_out.size() > 1) - { - body << "void "; - } - else if (args_out.size() == 1) - { - // generate basic or object return type - if (arg_object.length()) - { - body << arg_object << " "; - } - else - { - body << signature_to_type(args_out.front()->get("type")) << " "; - } - } - - // generate the method name - body << method.get("name") << "("; - - // generate the methods 'in' variables - unsigned int i = 0; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_name = arg.get("name"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate basic signature only if no object name available... - if (!arg_object.length()) - { - body << "const " << signature_to_type(arg.get("type")) << "& "; - } - // ...or generate object style if available - else - { - body << "const " << arg_object << "& "; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - - if (arg_name.length()) - body << arg_name; - - if ((i+1 != args_in.size() || args_out.size() > 1)) - body << ", "; - } - - // generate the method 'out' variables if multibe 'out' values exist - if (args_out.size() > 1) - { - unsigned int i = 0; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) - { - Xml::Node &arg = **ao; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_name = arg.get("name"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate basic signature only if no object name available... - if (!arg_object.length()) - { - body << signature_to_type(arg.get("type")) << "& "; - } - // ...or generate object style if available - else - { - body << arg_object << "& "; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - - if (arg_name.length()) - body << arg_name; - - if (i+1 != args_out.size()) - body << ", "; - } - } - body << ") = 0;" << endl; - } - - body << endl - << "public:" << endl - << endl - << tab << "/* signal emitters for this interface" << endl - << tab << " */" << endl; - - // generate the signals code - for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) - { - Xml::Node &signal = **si; - Xml::Nodes args = signal["arg"]; - - body << tab << "void " << signal.get("name") << "("; - - // generate the signal arguments - unsigned int i = 0; - for (Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i) - { - Xml::Node &arg = **a; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate basic signature only if no object name available... - if (!arg_object.length()) - { - body << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1; - } - // ...or generate object style if available - else - { - body << "const " << arg_object << "& arg" << i+1; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - - if (i+1 != args.size()) - body << ", "; - } - - body << ")" << endl - << tab << "{" << endl - << tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl; - - // generate the signal body - if (args.size() > 0) - { - body << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl; - - unsigned int i = 0; - for (Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i) - { - Xml::Node &arg = **a; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (arg_object.length()) - { - body << tab << tab << signature_to_type(arg.get("type")) << " _arg" << i+1 << ";" << endl; - body << tab << tab << "_arg" << i+1 << " << " << "arg" << i+1 << ";" << endl; - - body << tab << tab << "wi << _arg" << i+1 << ";" << endl; - } - else - { - body << tab << tab << "wi << arg" << i+1 << ";" << endl; - } - } - } - - // emit the signal in method body - body << tab << tab << "emit_signal(sig);" << endl - << tab << "}" << endl; - } - - body << endl - << "private:" << endl - << endl - << tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl - << tab << " */" << endl; - - // generate the unmarshalers - for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) - { - Xml::Node &method = **mi; - Xml::Nodes args = method["arg"]; - Xml::Nodes args_in = args.select("direction","in"); - Xml::Nodes args_out = args.select("direction","out"); - - body << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl - << tab << "{" << endl - << tab << tab << "::DBus::MessageIter ri = call.reader();" << endl - << endl; - - // generate the 'in' variables - unsigned int i = 1; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - - body << tab << tab << signature_to_type(arg.get("type")) << " argin" << i << ";" << " "; - body << "ri >> argin" << i << ";" << endl; - } - - // generate the 'in' object variables - i = 1; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (arg_object.length()) - { - body << tab << tab << arg_object << " _argin" << i << ";"; - body << " " << "_argin" << i << " << " << "argin" << i << ";" << endl; - } - } - - // generate 'out' variables - if (args_out.size() > 0) - { - unsigned int i = 1; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) - { - Xml::Node &arg = **ao; - - body << tab << tab << signature_to_type(arg.get("type")) << " argout" << i; - - if (args_out.size() == 1) // a single 'out' parameter will be assigned - { - body << " = "; - } - else // multible 'out' parameters will be handled as parameters below - { - body << ";" << endl; - } - } - } - - // generate 'out' object variables - if (args_out.size() > 0) - { - unsigned int i = 1; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) - { - Xml::Node &arg = **ao; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate object types - if (arg_object.length()) - { - body << tab << tab << arg_object << " _argout" << i << ";" << endl; - } - } - } - - // generate in '<<' operation - i = 0; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - } - - // do correct indent - if (args_out.size() != 1 ) - { - body << tab << tab; - } - - body << method.get("name") << "("; - - // generate call stub parameters - i = 0; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (arg_object.length()) - { - body << "_argin" << i+1; - } - else - { - body << "argin" << i+1; - } - - if ((i+1 != args_in.size() || args_out.size() > 1)) - body << ", "; - } - - if (args_out.size() > 1) - { - i = 0; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) - { - Xml::Node &arg = **ao; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (arg_object.length()) - { - body << "_argout" << i+1; - } - else - { - body << "argout" << i+1; - } - - if (i+1 != args_out.size()) - body << ", "; - } - } - - body << ");" << endl; - - body << tab << tab << "::DBus::ReturnMessage reply(call);" << endl; - - if (args_out.size() > 0) - { - body << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl; - - // generate out '<<' operation - i = 0; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) - { - Xml::Node &arg = **ao; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (arg_object.length()) - { - body << tab << tab << "argout" << i+1 << " << " << "_argout" << i+1 << ";" << endl; - } - } - - for (unsigned int i = 0; i < args_out.size(); ++i) - { - body << tab << tab << "wi << argout" << i+1 << ";" << endl; - } - } - - body << tab << tab << "return reply;" << endl; - - body << tab << "}" << endl; - } - - body << "};" << endl - << endl; - - for (unsigned int i = 0; i < nspaces; ++i) - { - body << "} "; - } - body << endl; - } - - body << "#endif //" << cond_comp << endl; - - // remove all duplicates in the header include vector - vector<string>::const_iterator vec_end_it = unique (include_vector.begin (), include_vector.end ()); - - for (vector<string>::const_iterator vec_it = include_vector.begin (); - vec_it != vec_end_it; - ++vec_it) - { - const string &include = *vec_it; - - head << "#include " << "\"" << include << ".h" << "\"" << endl; - } - head << endl; - - ofstream file(filename); - if (file.bad()) - { - cerr << "unable to write file " << filename << endl; - exit(-1); - } - - file << head.str (); - file << body.str (); - - file.close(); -} diff --git a/sflphone-common/libs/dbus-c++/tools/generate_adaptor.h b/sflphone-common/libs/dbus-c++/tools/generate_adaptor.h deleted file mode 100644 index fd888f0206..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/generate_adaptor.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef __DBUSXX_TOOLS_GENERATE_ADAPTOR_H -#define __DBUSXX_TOOLS_GENERATE_ADAPTOR_H - -#include <string> -#include "xml.h" - -void generate_adaptor(DBus::Xml::Document &doc, const char *filename); - -#endif//__DBUSXX_TOOLS_GENERATE_ADAPTOR_H diff --git a/sflphone-common/libs/dbus-c++/tools/generate_proxy.cpp b/sflphone-common/libs/dbus-c++/tools/generate_proxy.cpp deleted file mode 100644 index a46fc32473..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/generate_proxy.cpp +++ /dev/null @@ -1,665 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <iostream> -#include <fstream> -#include <cstdlib> -#include <algorithm> - -#include "generator_utils.h" -#include "generate_proxy.h" - -using namespace std; -using namespace DBus; - -extern const char *tab; -extern const char *header; -extern const char *dbus_includes; - -/*! Generate proxy code for a XML introspection - */ -void generate_proxy(Xml::Document &doc, const char *filename) -{ - ostringstream body; - ostringstream head; - vector <string> include_vector; - - head << header; - string filestring = filename; - underscorize(filestring); - - string cond_comp = "__dbusxx__" + filestring + "__PROXY_MARSHAL_H"; - - head << "#ifndef " << cond_comp << endl - << "#define " << cond_comp << endl; - - head << dbus_includes; - - Xml::Node &root = *(doc.root); - Xml::Nodes interfaces = root["interface"]; - - // iterate over all interface definitions - for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) - { - Xml::Node &iface = **i; - Xml::Nodes methods = iface["method"]; - Xml::Nodes signals = iface["signal"]; - Xml::Nodes properties = iface["property"]; - Xml::Nodes ms; - ms.insert(ms.end(), methods.begin(), methods.end()); - ms.insert(ms.end(), signals.begin(), signals.end()); - - // gets the name of a interface: <interface name="XYZ"> - string ifacename = iface.get("name"); - - // these interface names are skipped. - if (ifacename == "org.freedesktop.DBus.Introspectable" - ||ifacename == "org.freedesktop.DBus.Properties") - { - cerr << "skipping interface " << ifacename << endl; - continue; - } - - istringstream ss(ifacename); - string nspace; - unsigned int nspaces = 0; - - // prints all the namespaces defined with <interface name="X.Y.Z"> - while (ss.str().find('.', ss.tellg()) != string::npos) - { - getline(ss, nspace, '.'); - - body << "namespace " << nspace << " {" << endl; - - ++nspaces; - } - body << endl; - - string ifaceclass; - - getline(ss, ifaceclass); - - // a "_proxy" is added to class name to distinguish between proxy and adaptor - ifaceclass += "_proxy"; - - cerr << "generating code for interface " << ifacename << "..." << endl; - - // the code from class definiton up to opening of the constructor is generated... - body << "class " << ifaceclass << endl - << ": public ::DBus::InterfaceProxy" << endl - << "{" << endl - << "public:" << endl - << endl - << tab << ifaceclass << "()" << endl - << tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl - << tab << "{" << endl; - - // generates code to connect all the signal stubs; this is still inside the constructor - for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) - { - Xml::Node &signal = **si; - - string marshname = "_" + signal.get("name") + "_stub"; - - body << tab << tab << "connect_signal(" - << ifaceclass << ", " << signal.get("name") << ", " << stub_name(signal.get("name")) - << ");" << endl; - } - - // the constructor ends here - body << tab << "}" << endl - << endl; - - // write public block header for properties - body << "public:" << endl << endl - << tab << "/* properties exported by this interface */" << endl; - - // this loop generates all properties - for (Xml::Nodes::iterator pi = properties.begin (); - pi != properties.end (); ++pi) - { - Xml::Node & property = **pi; - string prop_name = property.get ("name"); - string property_access = property.get ("access"); - if (property_access == "read" || property_access == "readwrite") - { - body << tab << tab << "const " << signature_to_type (property.get("type")) - << " " << prop_name << "() {" << endl; - body << tab << tab << tab << "::DBus::CallMessage call ;\n "; - body << tab << tab << tab - << "call.member(\"Get\"); call.interface(\"org.freedesktop.DBus.Properties\");" - << endl; - body << tab << tab << tab - << "::DBus::MessageIter wi = call.writer(); " << endl; - body << tab << tab << tab - << "const std::string interface_name = \"" << ifacename << "\";" - << endl; - body << tab << tab << tab - << "const std::string property_name = \"" << prop_name << "\";" - << endl; - body << tab << tab << tab << "wi << interface_name;" << endl; - body << tab << tab << tab << "wi << property_name;" << endl; - body << tab << tab << tab - << "::DBus::Message ret = this->invoke_method (call);" << endl; - // TODO: support invoke_method_NoReply for properties - body << tab << tab << tab - << "::DBus::MessageIter ri = ret.reader ();" << endl; - body << tab << tab << tab << "::DBus::Variant argout; " << endl; - body << tab << tab << tab << "ri >> argout;" << endl; - body << tab << tab << tab << "return argout;" << endl; - body << tab << tab << "};" << endl; - } - - if (property_access == "write" || property_access == "readwrite") - { - body << tab << tab << "void " << prop_name << "( const "<< signature_to_type (property.get("type")) << " & input" << ") {" << endl; - body << tab << tab << tab << "::DBus::CallMessage call ;\n "; - body << tab << tab << tab <<"call.member(\"Set\"); call.interface( \"org.freedesktop.DBus.Properties\");"<< endl; - body << tab << tab << tab <<"::DBus::MessageIter wi = call.writer(); " << endl; - body << tab << tab << tab <<"::DBus::Variant value;" << endl; - body << tab << tab << tab <<"::DBus::MessageIter vi = value.writer ();" << endl; - body << tab << tab << tab <<"vi << input;" << endl; - body << tab << tab << tab <<"const std::string interface_name = \"" << ifacename << "\";" << endl; - body << tab << tab << tab <<"const std::string property_name = \"" << prop_name << "\";"<< endl; - body << tab << tab << tab <<"wi << interface_name;" << endl; - body << tab << tab << tab <<"wi << property_name;" << endl; - body << tab << tab << tab <<"wi << value;" << endl; - body << tab << tab << tab <<"::DBus::Message ret = this->invoke_method (call);" << endl; - // TODO: support invoke_method_noreply for properties - body << tab << tab << "};" << endl; - } - } - - // write public block header for methods - body << "public:" << endl - << endl - << tab << "/* methods exported by this interface," << endl - << tab << " * this functions will invoke the corresponding methods on the remote objects" << endl - << tab << " */" << endl; - - // this loop generates all methods - for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) - { - Xml::Node &method = **mi; - Xml::Nodes args = method["arg"]; - Xml::Nodes args_in = args.select("direction","in"); - Xml::Nodes args_out = args.select("direction","out"); - Xml::Nodes annotations = args["annotation"]; - Xml::Nodes method_annotations = method["annotation"]; - Xml::Nodes annotations_noreply = method_annotations.select("name","org.freedesktop.DBus.Method.NoReply"); - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - bool annotation_noreply_value = false; - - // parse method level noreply annotations - if (annotations_noreply.size() > 0) - { - string annotation_noreply_value_str = annotations_noreply.front()->get("value"); - - if (annotation_noreply_value_str == "true") - { - annotation_noreply_value = true; - } - } - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (args_out.size() == 0 || args_out.size() > 1) - { - body << tab << "void "; - } - else if (args_out.size() == 1) - { - if (arg_object.length()) - { - body << tab << arg_object << " "; - } - else - { - body << tab << signature_to_type(args_out.front()->get("type")) << " "; - } - } - - body << method.get("name") << "("; - - // generate all 'in' arguments for a method signature - unsigned int i = 0; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate basic signature only if no object name available... - if (!arg_object.length()) - { - body << "const " << signature_to_type(arg.get("type")) << "& "; - } - // ...or generate object style if available - else - { - body << "const " << arg_object << "& "; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - - string arg_name = arg.get("name"); - if (arg_name.length()) - body << arg_name; - else - body << "argin" << i; - - if ((i+1 != args_in.size() || args_out.size() > 1)) - body << ", "; - } - - if (args_out.size() > 1) - { - // generate all 'out' arguments for a method signature - unsigned int j = 0; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++j) - { - Xml::Node &arg = **ao; - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate basic signature only if no object name available... - if (!arg_object.length()) - { - body << signature_to_type(arg.get("type")) << "&"; - } - // ...or generate object style if available - else - { - body << arg_object << "& "; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - - string arg_name = arg.get("name"); - if (arg_name.length()) - body << " " << arg_name; - else - body << " argout" << j; - - if (j+1 != args_out.size()) - body << ", "; - } - } - body << ")" << endl; - - body << tab << "{" << endl - << tab << tab << "::DBus::CallMessage call;" << endl; - - if (args_in.size() > 0) - { - body << tab << tab << "::DBus::MessageIter wi = call.writer();" << endl - << endl; - } - - // generate all 'in' arguments for a method body - i = 0; - for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - string arg_name = arg.get("name"); - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (!arg_name.length()) - { - arg_name = "argin"; - arg_name += toString <uint> (i); - } - - // generate extra code to wrap object - if (arg_object.length()) - { - body << tab << tab << signature_to_type(arg.get("type")) << "_" << arg_name << ";" << endl; - body << tab << tab << "_" << arg_name << " << " << arg_name << ";" << endl; - - arg_name = string ("_") + arg_name; - } - - body << tab << tab << "wi << " << arg_name << ";" << endl; - } - - body << tab << tab << "call.member(\"" << method.get("name") << "\");" << endl; - - // generate noreply/reply method calls - if (annotation_noreply_value) - { - if (args_out.size ()) - { - cerr << "Function: " << method.get("name") << ":" << endl; - cerr << "Option 'org.freedesktop.DBus.Method.NoReply' not allowed for methods with 'out' variables!" << endl << "-> Option ignored!" << endl; - - body << tab << tab << "::DBus::Message ret = invoke_method (call);" << endl; - } - else - { - body << tab << tab << "assert (invoke_method_noreply (call));" << endl; // will only assert in case of no memory - } - } - else - { - body << tab << tab << "::DBus::Message ret = invoke_method (call);" << endl; - } - - if (args_out.size() > 0) - { - body << tab << tab << "::DBus::MessageIter ri = ret.reader();" << endl - << endl; - } - - // generate 'out' values as return if only one existing - if (args_out.size() == 1) - { - Xml::Nodes annotations = args_out["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (arg_object.length()) - { - body << tab << tab << arg_object << " _argout;" << endl; - } - - body << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout;" << endl; - - body << tab << tab << "ri >> argout;" << endl; - - if (arg_object.length()) - { - body << tab << tab << "_argout << argout;" << endl; - body << tab << tab << "return _argout;" << endl; - } - else - { - body << tab << tab << "return argout;" << endl; - } - } - else if (args_out.size() > 1) - { - // generate multible 'out' value - unsigned int i = 0; - for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) - { - Xml::Node &arg = **ao; - string arg_name = arg.get("name"); - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (!arg_name.length()) - { - arg_name = "argout" + toString <uint> (i); - } - - if (arg_object.length()) - { - body << tab << tab << signature_to_type(arg.get("type")) << "_" << arg_name << ";" << endl; - } - - if (arg_object.length()) - { - body << tab << tab << "ri >> " << "_" << arg_name << ";" << endl; - } - else - { - body << tab << tab << "ri >> " << arg_name << ";" << endl; - } - - if (arg_object.length()) - { - body << tab << tab << arg_name << " << " << "_" << arg_name << ";" << endl; - } - } - } - - body << tab << "}" << endl - << endl; - } - - // write public block header for signals - body << endl - << "public:" << endl - << endl - << tab << "/* signal handlers for this interface" << endl - << tab << " */" << endl; - - // this loop generates all signals - for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) - { - Xml::Node &signal = **si; - Xml::Nodes args = signal["arg"]; - - body << tab << "virtual void " << signal.get("name") << "("; - - // this loop generates all argument for a signal - unsigned int i = 0; - for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - string arg_name = arg.get("name"); - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - // generate basic signature only if no object name available... - if (!arg_object.length()) - { - body << "const " << signature_to_type(arg.get("type")) << "& "; - } - // ...or generate object style if available - else - { - body << "const " << arg_object << "& "; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - - if (arg_name.length()) - body << arg_name; - else - body << "argin" << i; - - if ((ai+1 != args.end())) - body << ", "; - } - body << ") = 0;" << endl; - } - - // write private block header for unmarshalers - body << endl - << "private:" << endl - << endl - << tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl - << tab << " */" << endl; - - // generate all the unmarshalers - for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) - { - Xml::Node &signal = **si; - Xml::Nodes args = signal["arg"]; - - body << tab << "void " << stub_name(signal.get("name")) << "(const ::DBus::SignalMessage &sig)" << endl - << tab << "{" << endl; - - if (args.size() > 0) - { - body << tab << tab << "::DBus::MessageIter ri = sig.reader();" << endl - << endl; - } - - unsigned int i = 0; - for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) - { - Xml::Node &arg = **ai; - string arg_name = arg.get("name"); - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - body << tab << tab << signature_to_type(arg.get("type")) << " " ; - - // use a default if no arg name given - if (!arg_name.length()) - { - arg_name = "arg" + toString <uint> (i); - } - - body << arg_name << ";" << endl; - body << tab << tab << "ri >> " << arg_name << ";" << endl; - - // if a object type is used create a local variable and insert values with '<<' operation - if (arg_object.length()) - { - body << tab << tab << arg_object << " _" << arg_name << ";" << endl; - body << tab << tab << "_" << arg_name << " << " << arg_name << ";" << endl; - - // store a object name to later generate header includes - include_vector.push_back (arg_object); - } - } - - body << tab << tab << signal.get("name") << "("; - - // generate all arguments for the call to the virtual function - unsigned int j = 0; - for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j) - { - Xml::Node &arg = **ai; - string arg_name = arg.get("name"); - Xml::Nodes annotations = arg["annotation"]; - Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object"); - string arg_object; - - if (annotations_object.size() > 0) - { - arg_object = annotations_object.front()->get("value"); - } - - if (!arg_name.length()) - { - arg_name = "arg" + toString <uint> (j); - } - - if (arg_object.length()) - { - body << "_" << arg_name; - } - else - { - body << arg_name; - } - - if (ai+1 != args.end()) - body << ", "; - } - - body << ");" << endl; - - body << tab << "}" << endl; - } - - body << "};" << endl - << endl; - - for (unsigned int i = 0; i < nspaces; ++i) - { - body << "} "; - } - body << endl; - } - - body << "#endif //" << cond_comp << endl; - - // remove all duplicates in the header include vector - vector<string>::const_iterator vec_end_it = unique (include_vector.begin (), include_vector.end ()); - - for (vector<string>::const_iterator vec_it = include_vector.begin (); - vec_it != vec_end_it; - ++vec_it) - { - const string &include = *vec_it; - - head << "#include " << "\"" << include << ".h" << "\"" << endl; - } - head << endl; - - ofstream file(filename); - if (file.bad()) - { - cerr << "unable to write file " << filename << endl; - exit(-1); - } - - file << head.str (); - file << body.str (); - - file.close(); -} diff --git a/sflphone-common/libs/dbus-c++/tools/generate_proxy.h b/sflphone-common/libs/dbus-c++/tools/generate_proxy.h deleted file mode 100644 index 0224f4df17..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/generate_proxy.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef __DBUSXX_TOOLS_GENERATE_PROXY_H -#define __DBUSXX_TOOLS_GENERATE_PROXY_H - -#include "xml.h" - -void generate_proxy(DBus::Xml::Document &doc, const char *filename); - -#endif//__DBUSXX_TOOLS_GENERATE_PROXY_H diff --git a/sflphone-common/libs/dbus-c++/tools/generator_utils.cpp b/sflphone-common/libs/dbus-c++/tools/generator_utils.cpp deleted file mode 100644 index e08ad27227..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/generator_utils.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <iostream> -#include <cstdlib> - -#include "generator_utils.h" - -using namespace std; - -const char *tab = " "; - -const char *header = "\n\ -/*\n\ - * This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!\n\ - */\n\ -\n\ -"; - -const char *dbus_includes = "\n\ -#include <dbus-c++/dbus.h>\n\ -#include <cassert>\n\ -"; - -void underscorize(string &str) -{ - for (unsigned int i = 0; i < str.length(); ++i) - { - if (!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_'; - } -} - -string stub_name(string name) -{ - underscorize(name); - - return "_" + name + "_stub"; -} - -const char *atomic_type_to_string(char t) -{ - static struct { char type; const char *name; } atos[] = - { - { 'y', "uint8_t" }, - { 'b', "bool" }, - { 'n', "int16_t" }, - { 'q', "uint16_t" }, - { 'i', "int32_t" }, - { 'u', "uint32_t" }, - { 'x', "int64_t" }, - { 't', "uint64_t" }, - { 'd', "double" }, - { 's', "std::string" }, - { 'o', "::DBus::Path" }, - { 'g', "::DBus::Signature" }, - { 'v', "::DBus::Variant" }, - { '\0', "" } - }; - int i; - - for (i = 0; atos[i].type; ++i) - { - if (atos[i].type == t) break; - } - return atos[i].name; -} - -void _parse_signature(const string &signature, string &type, unsigned int &i) -{ - for (; i < signature.length(); ++i) - { - switch (signature[i]) - { - case 'a': - { - switch (signature[++i]) - { - case '{': - { - type += "std::map< "; - - const char *atom = atomic_type_to_string(signature[++i]); - if (!atom) - { - cerr << "invalid signature" << endl; - exit(-1); - } - type += atom; - type += ", "; - ++i; - break; - } - default: - { - type += "std::vector< "; - break; - } - } - _parse_signature(signature, type, i); - type += " >"; - continue; - } - case '(': - { - type += "::DBus::Struct< "; - ++i; - _parse_signature(signature, type, i); - type += " >"; - if (signature[i+1]) - { - type += ", "; - } - continue; - } - case ')': - case '}': - { - return; - } - default: - { - const char *atom = atomic_type_to_string(signature[i]); - if (!atom) - { - cerr << "invalid signature" << endl; - exit(-1); - } - type += atom; - - if (signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length()) - { - type += ", "; - } - break; - } - } - } -} - -string signature_to_type(const string &signature) -{ - string type; - unsigned int i = 0; - _parse_signature(signature, type, i); - return type; -} diff --git a/sflphone-common/libs/dbus-c++/tools/generator_utils.h b/sflphone-common/libs/dbus-c++/tools/generator_utils.h deleted file mode 100644 index b232b56dd9..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/generator_utils.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef __DBUSXX_TOOLS_GENERATOR_UTILS_H -#define __DBUSXX_TOOLS_GENERATOR_UTILS_H - -#include <string> -#include <sstream> -#include <iomanip> - -const char *atomic_type_to_string(char t); -std::string stub_name(std::string name); -std::string signature_to_type(const std::string &signature); -void _parse_signature(const std::string &signature, std::string &type, unsigned int &i); -void underscorize(std::string &str); - -/// create std::string from any number -template <typename T> -std::string toString (const T &thing, int w = 0, int p = 0) -{ - std::ostringstream os; - os << std::setw(w) << std::setprecision(p) << thing; - return os.str(); -} - -#endif//__DBUSXX_TOOLS_GENERATOR_UTILS_H diff --git a/sflphone-common/libs/dbus-c++/tools/introspect.cpp b/sflphone-common/libs/dbus-c++/tools/introspect.cpp deleted file mode 100644 index 8ce9f3a74c..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/introspect.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <cstring> -#include <signal.h> -#include <unistd.h> -#include <iostream> -#include "introspect.h" - -DBus::BusDispatcher dispatcher; -static bool systembus; -static char *path; -static char *service; - -void niam(int sig) -{ - DBus::Connection conn = systembus ? DBus::Connection::SystemBus() : DBus::Connection::SessionBus(); - - IntrospectedObject io(conn, path, service); - - std::cout << io.Introspect(); - - dispatcher.leave(); -} - -int main(int argc, char ** argv) -{ - signal(SIGTERM, niam); - signal(SIGINT, niam); - signal(SIGALRM, niam); - - if (argc == 1) - { - std::cerr << std::endl << "Usage: " << argv[0] << " [--system] <object_path> [<destination>]" << std::endl << std::endl; - } - else - { - if (strcmp(argv[1], "--system")) - { - systembus = false; - path = argv[1]; - service = argc > 2 ? argv[2] : 0; - } - else - { - systembus = true; - path = argv[2]; - service = argc > 3 ? argv[3] : 0; - } - - DBus::default_dispatcher = &dispatcher; - - alarm(1); - - dispatcher.enter(); - } - - return 0; -} diff --git a/sflphone-common/libs/dbus-c++/tools/introspect.h b/sflphone-common/libs/dbus-c++/tools/introspect.h deleted file mode 100644 index 1c6e326414..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/introspect.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_TOOLS_INTROSPECT_H -#define __DBUSXX_TOOLS_INTROSPECT_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <dbus-c++/dbus.h> -#include <string> - -class IntrospectedObject : public DBus::IntrospectableProxy, public DBus::ObjectProxy -{ -public: - - IntrospectedObject(DBus::Connection &conn, const char *path, const char *service) - : DBus::ObjectProxy(conn, path, service) - {} -}; - -#endif//__DBUSXX_TOOLS_INTROSPECT_H diff --git a/sflphone-common/libs/dbus-c++/tools/xml.cpp b/sflphone-common/libs/dbus-c++/tools/xml.cpp deleted file mode 100644 index 68ae5a64da..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/xml.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#include "xml.h" - -#include <dbus-c++/debug.h> - -#include <expat.h> - -std::istream &operator >> (std::istream &in, DBus::Xml::Document &doc) -{ - std::stringbuf xmlbuf; - in.get(xmlbuf, '\0'); - doc.from_xml(xmlbuf.str()); - - return in; -} - -std::ostream &operator << (std::ostream &out, const DBus::Xml::Document &doc) -{ - return out << doc.to_xml(); -} - -using namespace DBus; -using namespace DBus::Xml; - -Error::Error(const char *error, int line, int column) -{ - std::ostringstream estream; - - estream << "line " << line << ", column " << column << ": " << error; - - _error = estream.str(); -} - -Node::Node(const char *n, const char ** a) -: name(n) -{ - if (a) - for (int i = 0; a[i]; i += 2) - { - _attrs[a[i]] = a[i+1]; - - //debug_log("xml:\t%s = %s", a[i], a[i+1]); - } -} - -Nodes Nodes::operator[](const std::string &key) -{ - Nodes result; - - for (iterator i = begin(); i != end(); ++i) - { - Nodes part = (**i)[key]; - - result.insert(result.end(), part.begin(), part.end()); - } - return result; -} - -Nodes Nodes::select(const std::string &attr, const std::string &value) -{ - Nodes result; - - for (iterator i = begin(); i != end(); ++i) - { - if ((*i)->get(attr) == value) - result.insert(result.end(), *i); - } - return result; -} - -Nodes Node::operator[](const std::string &key) -{ - Nodes result; - - if (key.length() == 0) return result; - - for (Children::iterator i = children.begin(); i != children.end(); ++i) - { - if (i->name == key) - result.push_back(&(*i)); - } - return result; -} - -std::string Node::get(const std::string &attribute) -{ - if (_attrs.find(attribute) != _attrs.end()) - return _attrs[attribute]; - else - return ""; -} - -void Node::set(const std::string &attribute, std::string value) -{ - if (value.length()) - _attrs[attribute] = value; - else - _attrs.erase(value); -} - -std::string Node::to_xml() const -{ - std::string xml; - int depth = 0; - - _raw_xml(xml, depth); - - return xml; -} - -void Node::_raw_xml(std::string &xml, int &depth) const -{ - xml.append(depth *2, ' '); - xml.append("<"+name); - - for (Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i) - { - xml.append(" "+i->first+"=\""+i->second+"\""); - } - - if (cdata.length() == 0 && children.size() == 0) - { - xml.append("/>\n"); - } - else - { - xml.append(">"); - - if (cdata.length()) - { - xml.append(cdata); - } - - if (children.size()) - { - xml.append("\n"); - depth++; - - for (Children::const_iterator i = children.begin(); i != children.end(); ++i) - { - i->_raw_xml(xml, depth); - } - - depth--; - xml.append(depth *2, ' '); - } - xml.append("</"+name+">\n"); - } -} - -Document::Document() -: root(0), _depth(0) -{ -} - -Document::Document(const std::string &xml) -: root(0), _depth(0) -{ - from_xml(xml); -} - -Document::~Document() -{ - delete root; -} - -struct Document::Expat -{ - static void start_doctype_decl_handler( - void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset - ); - static void end_doctype_decl_handler(void *data); - static void start_element_handler(void *data, const XML_Char *name, const XML_Char **atts); - static void character_data_handler(void *data, const XML_Char *chars, int len); - static void end_element_handler(void *data, const XML_Char *name); -}; - -void Document::from_xml(const std::string &xml) -{ - _depth = 0; - delete root; - root = 0; - - XML_Parser parser = XML_ParserCreate("UTF-8"); - - XML_SetUserData(parser, this); - - XML_SetDoctypeDeclHandler( - parser, - Document::Expat::start_doctype_decl_handler, - Document::Expat::end_doctype_decl_handler - ); - - XML_SetElementHandler( - parser, - Document::Expat::start_element_handler, - Document::Expat::end_element_handler - ); - - XML_SetCharacterDataHandler( - parser, - Document::Expat::character_data_handler - ); - - XML_Status status = XML_Parse(parser, xml.c_str(), xml.length(), true); - - if (status == XML_STATUS_ERROR) - { - const char *error = XML_ErrorString(XML_GetErrorCode(parser)); - int line = XML_GetCurrentLineNumber(parser); - int column = XML_GetCurrentColumnNumber(parser); - - XML_ParserFree(parser); - - throw Error(error, line, column); - } - else - { - XML_ParserFree(parser); - } -} - -std::string Document::to_xml() const -{ - return root->to_xml(); -} - -void Document::Expat::start_doctype_decl_handler( - void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset -) -{ -} - -void Document::Expat::end_doctype_decl_handler(void *data) -{ -} - -void Document::Expat::start_element_handler(void *data, const XML_Char *name, const XML_Char **atts) -{ - Document *doc = (Document *)data; - - //debug_log("xml:%d -> %s", doc->_depth, name); - - if (!doc->root) - { - doc->root = new Node(name, atts); - } - else - { - Node::Children *cld = &(doc->root->children); - - for (int i = 1; i < doc->_depth; ++i) - { - cld = &(cld->back().children); - } - cld->push_back(Node(name, atts)); - - //std::cerr << doc->to_xml() << std::endl; - } - doc->_depth++; -} - -void Document::Expat::character_data_handler(void *data, const XML_Char *chars, int len) -{ - Document *doc = (Document *)data; - - Node *nod = doc->root; - - for (int i = 1; i < doc->_depth; ++i) - { - nod = &(nod->children.back()); - } - int x, y; - - x = 0; - y = len-1; - - while (isspace(chars[y]) && y > 0) --y; - while (isspace(chars[x]) && x < y) ++x; - - nod->cdata = std::string(chars, x, y+1); -} - -void Document::Expat::end_element_handler(void *data, const XML_Char *name) -{ - Document *doc = (Document *)data; - - //debug_log("xml:%d <- %s", doc->_depth, name); - - doc->_depth--; -} - diff --git a/sflphone-common/libs/dbus-c++/tools/xml.h b/sflphone-common/libs/dbus-c++/tools/xml.h deleted file mode 100644 index 6a8e69c19f..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/xml.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_XML_H -#define __DBUSXX_XML_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <exception> -#include <string> -#include <vector> -#include <map> -#include <iostream> -#include <sstream> - -namespace DBus { - -namespace Xml { - -class Error : public std::exception -{ -public: - - Error(const char *error, int line, int column); - - ~Error() throw() - {} - - const char *what() const throw() - { - return _error.c_str(); - } - -private: - - std::string _error; -}; - -class Node; - -class Nodes : public std::vector<Node *> -{ -public: - - Nodes operator[](const std::string &key); - - Nodes select(const std::string &attr, const std::string &value); -}; - -class Node -{ -public: - - typedef std::map<std::string, std::string> Attributes; - - typedef std::vector<Node> Children; - - std::string name; - std::string cdata; - Children children; - - Node(std::string &n, Attributes &a) - : name(n), _attrs(a) - {} - - Node(const char *n, const char ** a = NULL); - - Nodes operator[](const std::string &key); - - std::string get(const std::string &attribute); - - void set(const std::string &attribute, std::string value); - - std::string to_xml() const; - - Node &add(Node child) - { - children.push_back(child); - return children.back(); - } - -private: - - void _raw_xml(std::string &xml, int &depth) const; - - Attributes _attrs; -}; - -class Document -{ -public: - - struct Expat; - - Node *root; - - Document(); - - Document(const std::string &xml); - - ~Document(); - - void from_xml(const std::string &xml); - - std::string to_xml() const; - -private: - - int _depth; -}; - -} /* namespace Xml */ - -} /* namespace DBus */ - -std::istream &operator >> (std::istream &, DBus::Xml::Document &); -std::ostream &operator << (std::ostream &, DBus::Xml::Document &); - -#endif//__DBUSXX_XML_H diff --git a/sflphone-common/libs/dbus-c++/tools/xml2cpp.cpp b/sflphone-common/libs/dbus-c++/tools/xml2cpp.cpp deleted file mode 100644 index 32481d8e99..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/xml2cpp.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <dbus/dbus.h> - -#include <cstdlib> -#include <cstring> -#include <string> -#include <map> -#include <iostream> -#include <fstream> -#include <sstream> - -#include "xml2cpp.h" -#include "generate_adaptor.h" -#include "generate_proxy.h" - -using namespace std; -using namespace DBus; - -//typedef map<string,string> TypeCache; - -void usage(const char *argv0) -{ - cerr << endl << "Usage: " << argv0 << " <xmlfile> [ --proxy=<outfile.h> ] [ --adaptor=<outfile.h> ]" - << endl << endl; - exit(-1); -} - -/*int char_to_atomic_type(char t) -{ - if (strchr("ybnqiuxtdsgavre", t)) - return t; - - return DBUS_TYPE_INVALID; -}*/ - - - -/*bool is_atomic_type(const string &type) -{ - return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID; -}*/ - - -int main(int argc, char ** argv) -{ - if (argc < 2) - { - usage(argv[0]); - } - - bool proxy_mode, adaptor_mode; - char *proxy, *adaptor; - - proxy_mode = false; - proxy = 0; - - adaptor_mode = false; - adaptor = 0; - - for (int a = 1; a < argc; ++a) - { - if (!strncmp(argv[a], "--proxy=", 8)) - { - proxy_mode = true; - proxy = argv[a] +8; - } - else - if (!strncmp(argv[a], "--adaptor=", 10)) - { - adaptor_mode = true; - adaptor = argv[a] +10; - } - } - - if (!proxy_mode && !adaptor_mode) usage(argv[0]); - - ifstream xmlfile(argv[1]); - - if (xmlfile.bad()) - { - cerr << "unable to open file " << argv[1] << endl; - return -1; - } - - Xml::Document doc; - - try - { - xmlfile >> doc; - //cout << doc.to_xml(); - } - catch(Xml::Error &e) - { - cerr << "error parsing " << argv[1] << ": " << e.what() << endl; - return -1; - } - - if (!doc.root) - { - cerr << "empty document" << endl; - return -1; - } - - if (proxy_mode) generate_proxy(doc, proxy); - if (adaptor_mode) generate_adaptor(doc, adaptor); - - return 0; -} diff --git a/sflphone-common/libs/dbus-c++/tools/xml2cpp.h b/sflphone-common/libs/dbus-c++/tools/xml2cpp.h deleted file mode 100644 index 84f53feacf..0000000000 --- a/sflphone-common/libs/dbus-c++/tools/xml2cpp.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_TOOLS_XML2CPP_H -#define __DBUSXX_TOOLS_XML2CPP_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <dbus-c++/dbus.h> -#include <dbus/dbus.h> - -#include "xml.h" - -#endif//__DBUSXX_TOOLS_XML2CPP_H diff --git a/sflphone-common/src/Makefile.am b/sflphone-common/src/Makefile.am index d14c7eb21f..ad0c777f65 100644 --- a/sflphone-common/src/Makefile.am +++ b/sflphone-common/src/Makefile.am @@ -51,7 +51,6 @@ noinst_HEADERS = \ libsflphone_la_LIBADD = \ $(src)/libs/utilspp/libutilspp.la \ $(src)/libs/iax2/libiax2.la \ - $(src)/libs/dbus-c++/src/libdbus-c++-1.la \ $(IAX_LIB) \ ./im/libim.la \ ./sip/libsiplink.la \ @@ -74,7 +73,8 @@ libsflphone_la_LDFLAGS = \ @libssl_LIBS@ \ @UUID_LIBS@ \ @yaml_LIBS@ \ - @xml_LIBS@ + @xml_LIBS@ \ + @DBUSCPP_LIBS@ libsflphone_la_CFLAGS = \ @CCGNU2_CFLAGS@ \ diff --git a/sflphone-common/src/dbus/Makefile.am b/sflphone-common/src/dbus/Makefile.am index a3c5dbbf0c..a5658aad9e 100644 --- a/sflphone-common/src/dbus/Makefile.am +++ b/sflphone-common/src/dbus/Makefile.am @@ -1,7 +1,5 @@ include $(top_srcdir)/globals.mak -DBUSXX=$(top_srcdir)/libs/dbus-c++/tools/dbusxx-xml2cpp - noinst_LTLIBRARIES = libdbus.la BUILT_SOURCES= \ @@ -11,7 +9,7 @@ BUILT_SOURCES= \ # Rule to generate the binding headers %-glue.h: %-introspec.xml Makefile.am - $(DBUSXX) $< --adaptor=$@ + dbusxx-xml2cpp $< --adaptor=$@ libdbus_la_SOURCES = \ callmanager.cpp \ @@ -26,9 +24,10 @@ else NETWORKMANAGER= endif -libdbus_la_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(NETWORKMANAGER) - -libdbus_la_LIBADD = $(top_srcdir)/libs/dbus-c++/src/libdbus-c++-1.la +libdbus_la_CXXFLAGS = \ + -DPREFIX=\"$(prefix)\" \ + -DPROGSHAREDIR=\"${datadir}/sflphone\" \ + $(NETWORKMANAGER) noinst_HEADERS = \ callmanager.h \ -- GitLab