Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include <dbus/dbus.h>
24 #define LOG_FILE "c:\\logs\\file_writecontact0_log1.txt"
25 #include "std_log_result.h"
26 #define LOG_FILENAME_LINE __FILE__, __LINE__
28 void create_xml(int result)
33 testResultXml("file_writecontact0");
39 DBusConnection* connection;
43 DBusMessageIter append_iter;
44 DBusMessageIter return_iter;
45 DBusMessageIter sub_iter;
46 DBusPendingCall* pending;
49 dbus_int32_t return_value;
54 char* arg_str = "DBus Testing";
55 char* arg_obj_path = "\Test\Object\Path";
63 size = sizeof(struct data_contact);
64 std_log(LOG_FILENAME_LINE, "size of struct is %d",size);
69 data.ph_no = "+91234455";
73 dbus_error_init(&error);
75 connection = dbus_bus_get_private(DBUS_BUS_SESSION, &error);
79 std_log(LOG_FILENAME_LINE, "error_name",error.name);
80 std_log(LOG_FILENAME_LINE, "error_msg",error.message);
84 msg = dbus_message_new_method_call("Test.Method.Call1", "/Test/Method/Object", "test.Method.Call", "file_writecontact");
87 std_log(LOG_FILENAME_LINE, "message error");
91 std_log(LOG_FILENAME_LINE, "message created successfully");
94 dbus_message_iter_init_append(msg, &append_iter);
96 if(!dbus_message_iter_append_basic(&append_iter, DBUS_TYPE_STRING, &arg_str))
98 std_log(LOG_FILENAME_LINE, "No memory");
108 if(!dbus_message_iter_open_container(&append_iter, DBUS_TYPE_STRUCT, NULL, &sub_iter))
110 std_log(LOG_FILENAME_LINE, "No memory");
115 if(!dbus_message_iter_append_basic(&sub_iter, DBUS_TYPE_INT32, &data.cnt))
117 std_log(LOG_FILENAME_LINE, "No memory");
121 if(!dbus_message_iter_append_basic(&sub_iter, DBUS_TYPE_STRING, &data.name))
123 std_log(LOG_FILENAME_LINE, "No memory");
127 if(!dbus_message_iter_append_basic(&sub_iter, DBUS_TYPE_STRING, &data.ph_no))
129 std_log(LOG_FILENAME_LINE, "No memory");
133 dbus_message_iter_close_container(&append_iter, &sub_iter); // for 80 structure
137 // send message and get a handle for a reply
138 if (!dbus_connection_send_with_reply (connection, msg, &pending, -1)) { // -1 is default timeout
139 std_log(LOG_FILENAME_LINE, "message send error");
143 if (NULL == pending) {
144 std_log(LOG_FILENAME_LINE, "pending is null");
148 dbus_connection_flush(connection);
151 dbus_message_unref(msg);
153 // block until we recieve a reply
154 dbus_pending_call_block(pending);
156 // get the reply message
157 msg1 = dbus_pending_call_steal_reply(pending);
159 std_log(LOG_FILENAME_LINE, "Reply error");
165 // free the pending message handle
166 dbus_pending_call_unref(pending);
168 dbus_error_init (&error);
169 dbus_message_iter_init(msg1, &return_iter);
171 dbus_message_iter_get_basic(&return_iter, &return_value);
172 std_log(LOG_FILENAME_LINE, "reply = %d",return_value);
174 if(return_value != 50)
176 std_log(LOG_FILENAME_LINE, "return value is not what is sent");
180 dbus_message_unref(msg);
182 dbus_connection_close(connection);
183 dbus_connection_unref(connection);
185 std_log(LOG_FILENAME_LINE, "SUCCESS");