Merge upstream branch 2.31.1 into branch origin/tizen
[platform/upstream/at-spi2-core.git] / dbind / dbtest.c
index 9a3ae86..42c1919 100644 (file)
@@ -1,16 +1,33 @@
+/*
+ * Copyright 2008-2011 Novell, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 #include <stdio.h>
 #include <glib.h>
 #include <string.h>
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbind/dbind.h>
-#include <dbind/dbind-any.h>
 
 /* Wow! dbus is unpleasant to use */
 
 #define DESKICE_PATH      "/Novell/ICEDesktop/Daemon"
 #define DESKICE_NAMESPACE "Novell.ICEDesktop.Daemon"
 
-void marshal (DBusMessage *msg, char *type, void *ptr)
+void marshal (DBusMessage *msg, const char *type, void *ptr)
 {
     DBusMessageIter iter;
 
@@ -18,7 +35,7 @@ void marshal (DBusMessage *msg, char *type, void *ptr)
     dbind_any_marshal (&iter, &type, &ptr);
 }
 
-void demarshal (DBusMessage *msg, char *type, void *ptr)
+void demarshal (DBusMessage *msg, const char *type, void *ptr)
 {
     DBusMessageIter iter;
 
@@ -300,8 +317,8 @@ void test_twovals ()
     DBusMessage *msg;
     DBusMessageIter iter;
     TwoVal i, o;
-    char *type_twoval = TYPEOF_TWOVAL;
-    char *type;
+    const char *type_twoval = TYPEOF_TWOVAL;
+    const char *type;
     void *ptr;
 
     msg = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_CALL);
@@ -341,7 +358,7 @@ void test_marshalling ()
     fprintf (stderr, "Marshalling ok\n");
 }
 
-void test_teamspaces (DBindContext *ctx)
+void test_teamspaces (DBusConnection *bus)
 {
     GArray *spaces;
     DBusError error;
@@ -353,9 +370,14 @@ void test_teamspaces (DBindContext *ctx)
     } TeamSpace;
 
     dbus_error_init (&error);
-    if (!dbind_context_method_call (ctx, NULL, DESKICE_PATH, DESKICE_NAMESPACE,
-                                    "GetTeamList", &error,
-                                    "=>a(sss)", &spaces)) {
+    if (!dbind_method_call_reentrant (bus,
+                                      NULL,
+                                      DESKICE_PATH,
+                                      DESKICE_NAMESPACE,
+                                      "GetTeamList",
+                                      &error,
+                                      "=>a(sss)",
+                                      &spaces)) {
         fprintf (stderr, "Error getting team spaces %s: %s\n",
                  error.name, error.message);
         dbus_error_free (&error);
@@ -375,29 +397,24 @@ void test_teamspaces (DBindContext *ctx)
     dbind_any_free_ptr ("a(sss)", spaces);
 }
 
-extern dbind_find_c_alignment (char *type);
-
 void test_helpers ()
 {
     dbind_find_c_alignment ("(sss)");
     dbind_find_c_alignment ("a(sss)");
     dbind_find_c_alignment ("(s(s)yd(d)s)");
+    dbind_find_c_alignment ("a{ss}");
     fprintf (stderr, "helpers passed\n");
 }
 
 int main (int argc, char **argv)
 {
-    DBindContext *ctx;
+    DBusConnection *bus;
 
-    ctx = dbind_create_context (DBUS_BUS_SESSION, NULL);
-    if (!ctx)
-        return 1;
+    bus = dbus_bus_get (DBUS_BUS_SESSION, NULL);
 
     test_helpers ();
     test_marshalling ();
-    test_teamspaces (ctx);
-
-    dbind_context_free (ctx);
+    test_teamspaces (bus);
 
     return 0;
 }