|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include<stdio.h> |
|
20 #include <dbus/dbus.h> |
|
21 #include <stdlib.h> |
|
22 #include <string.h> |
|
23 #include <unistd.h> |
|
24 |
|
25 #define LOG_FILE "c:\\logs\\dbus_message_get_no_reply0_log1.txt" |
|
26 #include "std_log_result.h" |
|
27 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
28 |
|
29 void create_xml(int result) |
|
30 { |
|
31 if(result) |
|
32 assert_failed = 1; |
|
33 |
|
34 testResultXml("dbus_message_get_no_reply0"); |
|
35 close_log_file(); |
|
36 } |
|
37 |
|
38 int main() |
|
39 { |
|
40 char error_name[40]; |
|
41 char error_msg[40]; |
|
42 dbus_bool_t noreply = TRUE; |
|
43 FILE *fp; |
|
44 long lsize; |
|
45 char *buffer; |
|
46 size_t result; |
|
47 DBusConnection* connection; |
|
48 DBusError error; |
|
49 DBusMessage* msg; |
|
50 DBusMessage* reply = NULL; |
|
51 |
|
52 |
|
53 dbus_error_init(&error); |
|
54 /*noreply = |
|
55 * TRUE if the " Set reply to be set" / the message doesnt wait for reply |
|
56 FALSE if the " Set reply not to be set" / reply may be expected */ |
|
57 |
|
58 |
|
59 |
|
60 connection = dbus_bus_get_private(DBUS_BUS_SESSION, &error); |
|
61 if(!connection) |
|
62 { |
|
63 std_log(LOG_FILENAME_LINE, "Error_name :%s",error.name); |
|
64 std_log(LOG_FILENAME_LINE, "Error_msg:%s",error.message); |
|
65 create_xml(1); |
|
66 return 1; |
|
67 } |
|
68 msg = dbus_message_new_method_call("Test.Method.Call1", "/Test/Method/Object", "test.Method.Call", "dbus_message_get_no_reply0"); |
|
69 if(msg == NULL) |
|
70 { |
|
71 std_log(LOG_FILENAME_LINE, "Message error"); |
|
72 create_xml(1); |
|
73 return 1; |
|
74 } |
|
75 dbus_message_set_no_reply( msg,noreply); |
|
76 dbus_connection_send(connection, msg, NULL); |
|
77 std_log(LOG_FILENAME_LINE, "Message sent"); |
|
78 sleep (5); |
|
79 fp = fopen("c:\\msggetnorply.txt","rb"); // the file msggetnorply.txt is been written in method1.c |
|
80 if(fp == NULL) |
|
81 std_log(LOG_FILENAME_LINE, "File doesnt exists"); |
|
82 fseek(fp,0,SEEK_END); |
|
83 lsize = ftell(fp); |
|
84 rewind(fp); // Sets the position indicator associated with stream to the beginning of the file. |
|
85 |
|
86 buffer = (char*) malloc (sizeof(char)*lsize); |
|
87 if(buffer == NULL) |
|
88 std_log(LOG_FILENAME_LINE, "Memory Error"); |
|
89 |
|
90 |
|
91 result = fread(buffer,1,lsize,fp); |
|
92 if (result != lsize) |
|
93 std_log(LOG_FILENAME_LINE, "reading error"); |
|
94 std_log(LOG_FILENAME_LINE, "Success"); |
|
95 create_xml(0); |
|
96 dbus_message_unref(msg); |
|
97 |
|
98 dbus_connection_close(connection); |
|
99 dbus_connection_unref(connection); |
|
100 dbus_shutdown(); |
|
101 |
|
102 return 0; |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 } |