From 882756f1363905c5cec050cacc5a410c85b94e82 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 24 Apr 2007 11:47:23 +0000 Subject: [PATCH] 2007-04-24 Murray Cumming * Makefile.am: * configure.ac: * libmodest-dbus-client/Makefile.am: * libmodest-dbus-client/libmodest-dbus-client.c: * libmodest-dbus-client/libmodest-dbus-client.h: * tests/dbus_api/Makefile.am: * tests/dbus_api/test_hello.c: (main): Added directory structure for a C convenience library for using the modest D-Bus API, and used that from the test. It is still just a helloworld. pmo-trunk-r1649 --- ChangeLog2 | 11 +++++ Makefile.am | 4 +- configure.ac | 2 + libmodest-dbus-client/Makefile.am | 50 +++++++++++++++++++++++ libmodest-dbus-client/libmodest-dbus-client.c | 53 +++++++++++++++++++++++++ libmodest-dbus-client/libmodest-dbus-client.h | 39 ++++++++++++++++++ tests/dbus_api/Makefile.am | 4 +- tests/dbus_api/test_hello.c | 21 +++------- 8 files changed, 166 insertions(+), 18 deletions(-) create mode 100644 libmodest-dbus-client/Makefile.am create mode 100644 libmodest-dbus-client/README create mode 100644 libmodest-dbus-client/libmodest-dbus-client.c create mode 100644 libmodest-dbus-client/libmodest-dbus-client.h diff --git a/ChangeLog2 b/ChangeLog2 index 6a2b3d1..f61482f 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,16 @@ 2007-04-24 Murray Cumming + * Makefile.am: + * configure.ac: + * libmodest-dbus-client/Makefile.am: + * libmodest-dbus-client/libmodest-dbus-client.c: + * libmodest-dbus-client/libmodest-dbus-client.h: + * tests/dbus_api/Makefile.am: + * tests/dbus_api/test_hello.c: (main): Added directory structure for a C convenience library + for using the modest D-Bus API, and used that from the test. It is still just a helloworld. + +2007-04-24 Murray Cumming + * src/maemo/easysetup/modest-easysetup-wizard.c: (create_page_account_details): * src/maemo/modest-account-settings-dialog.c: diff --git a/Makefile.am b/Makefile.am index 226e15b..76b095f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,9 +24,9 @@ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.b +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -SUBDIRS= src man po +SUBDIRS= src libmodest-dbus-client man po if BUILD_TESTS SUBDIRS += tests diff --git a/configure.ac b/configure.ac index 6a282ef..de0ecf4 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,8 @@ tests/Makefile tests/dbus_api/Makefile src/maemo/modest.desktop src/maemo/modest.service +libmodest-dbus-client/Makefile +libmodest-dbus-client/libmodest-dbus-client-1.0.pc ]) diff --git a/libmodest-dbus-client/Makefile.am b/libmodest-dbus-client/Makefile.am new file mode 100644 index 0000000..7e2e8ff --- /dev/null +++ b/libmodest-dbus-client/Makefile.am @@ -0,0 +1,50 @@ +# Copyright (c) 2006,2007 Nokia Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Nokia Corporation nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +INCLUDES=\ + $(MODEST_GSTUFF_CFLAGS)\ + $(MODEST_LIBTINYMAIL_GNOME_DESKTOP_CFLAGS) \ + $(MODEST_LIBTINYMAIL_MAEMO_CFLAGS) \ + -I$(MODEST_PLATFORM) \ + -DPREFIX=\"@prefix@\" \ + -DMODEST_LOCALEDIR=\"$(MODEST_LOCALEDIR)\" \ + -DMODEST_PLATFORM=\"$(MODEST_PLATFORM)\" \ + -DMODEST_PLATFORM_ID=$(MODEST_PLATFORM_ID) \ + -DPIXMAP_PREFIX=\"${datadir}/pixmaps/modest/\" \ + -DMODEST_UIDIR=\"$(datadir)/modest/ui/\" + +lib_LTLIBRARIES = libmodest-dbus-client-1.0.la +libmodest_dbus_client_1_0_la_SOURCES = libmodest-dbus-client.h libmodest-dbus-client.c + +library_includedir=$(includedir)/libmodest-dbus-client-1.0/libmodest-dbus-client +library_include_HEADERS = libmodest-dbus-client.h + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libmodest-dbus-client-1.0.pc + + diff --git a/libmodest-dbus-client/README b/libmodest-dbus-client/README new file mode 100644 index 0000000..e69de29 diff --git a/libmodest-dbus-client/libmodest-dbus-client.c b/libmodest-dbus-client/libmodest-dbus-client.c new file mode 100644 index 0000000..e0c4742 --- /dev/null +++ b/libmodest-dbus-client/libmodest-dbus-client.c @@ -0,0 +1,53 @@ +/* Copyright (c) 2007, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "libmodest-dbus-client.h" + +#define MODEST_DBUS_NAME "modestemail" +#define MODEST_DBUS_EXAMPLE_MESSAGE "HelloWorld" + +gboolean +libmodest_dbus_client_call_helloworld(osso_context_t *osso_context) +{ + osso_rpc_t retval; + const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, + MODEST_DBUS_NAME, + MODEST_DBUS_EXAMPLE_MESSAGE, &retval, DBUS_TYPE_INVALID); + + if (ret != OSSO_OK) { + printf("debug: osso_rpc_run() failed.\n"); + return FALSE; + } else { + printf("debug: osso_rpc_run() succeeded.\n"); + } + + osso_rpc_free_val(&retval); + + return TRUE; +} diff --git a/libmodest-dbus-client/libmodest-dbus-client.h b/libmodest-dbus-client/libmodest-dbus-client.h new file mode 100644 index 0000000..7d8dba7 --- /dev/null +++ b/libmodest-dbus-client/libmodest-dbus-client.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2007, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LIBMODEST_DBUS_CLIENT_H__ +#define __LIBMODEST_DBUS_CLIENT_H__ + +#include +#include + +gboolean +libmodest_dbus_client_call_helloworld(osso_context_t *osso_context); + +#endif /* __LIBMODEST_DBUS_CLIENT_H__ */ diff --git a/tests/dbus_api/Makefile.am b/tests/dbus_api/Makefile.am index d827648..969a0b9 100644 --- a/tests/dbus_api/Makefile.am +++ b/tests/dbus_api/Makefile.am @@ -5,6 +5,7 @@ INCLUDES=\ $(MODEST_LIBTINYMAIL_MAEMO_CFLAGS) \ -I$(MODEST_PLATFORM) \ -I${top_srcdir}/src \ + -I$(top_srcdir) \ -DPREFIX=\"@prefix@\" \ -DMODESTLOCALEDIR=\""$(modestlocaledir)"\" @@ -12,7 +13,8 @@ objects=\ @CHECK_LIBS@ \ $(MODEST_GSTUFF_LIBS) \ $(MODEST_LIBTINYMAIL_GNOME_DESKTOP_LIBS) \ - $(MODEST_LIBTINYMAIL_MAEMO_LIBS) + $(MODEST_LIBTINYMAIL_MAEMO_LIBS) \ + ${top_srcdir}/libmodest-dbus-client/libmodest-dbus-client-1.0.la noinst_PROGRAMS = test_hello diff --git a/tests/dbus_api/test_hello.c b/tests/dbus_api/test_hello.c index bb96b82..73e799c 100644 --- a/tests/dbus_api/test_hello.c +++ b/tests/dbus_api/test_hello.c @@ -1,11 +1,6 @@ -#include +#include #include -#define MODEST_DBUS_NAME "modestemail" -#define MODEST_DBUS_EXAMPLE_MESSAGE "HelloWorld" - - - int main(int argc, char *argv[]) { /* Initialize maemo application */ @@ -19,19 +14,15 @@ int main(int argc, char *argv[]) return OSSO_ERROR; } - osso_rpc_t retval; - osso_return_t ret = osso_rpc_run_with_defaults(osso_context, - MODEST_DBUS_NAME, - MODEST_DBUS_EXAMPLE_MESSAGE, &retval, DBUS_TYPE_INVALID); - if (ret != OSSO_OK) { - printf("osso_rpc_run() failed.\n"); + /* Call the function in libmodest-dbus-client: */ + const gboolean ret = libmodest_dbus_client_call_helloworld (osso_context); + if (!ret) { + printf("libmodest_dbus_client_call_helloworld() failed.\n"); return OSSO_ERROR; } else { - printf("osso_rpc_run() succeeded.\n"); + printf("libmodest_dbus_client_call_helloworld() succeeded.\n"); } - osso_rpc_free_val(&retval); - /* Exit */ return 0; } -- 1.7.9.5