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 #include "HtiSystemH.h" |
|
17 #include "hticommon.h" |
|
18 #include "HtiPlugin.h" |
|
19 #include "HtiSoapHandlerInterface.h" |
|
20 |
|
21 // Command codes |
|
22 const int CMD_HTI_AUTH = 0x01; |
|
23 const int CMD_HTI_VERSION = 0x02; |
|
24 const int CMD_HTI_SERVICE_LIST = 0x03; |
|
25 const int CMD_HTI_STOP = 0x04; |
|
26 const int CMD_HTI_REBOOT = 0x05; |
|
27 const int CMD_HTI_FORMAT = 0x06; |
|
28 const int CMD_HTI_RESET = 0x07; |
|
29 const int CMD_HTI_SHOW_CONSOLE = 0x08; |
|
30 const int CMD_HTI_HIDE_CONSOLE = 0x09; |
|
31 const int CMD_HTI_INSTANCE_ID = 0x0A; |
|
32 const int CMD_HTI_DEBUG_PRINT = 0x0B; |
|
33 const int CMD_HTI_ERROR = 0xFF; |
|
34 |
|
35 const int SERVICE_NAME_LEN = 124; |
|
36 const int SERVICE_UID_LEN = 4; |
|
37 const int SERVICE_DESCR_LEN = SERVICE_NAME_LEN + SERVICE_UID_LEN; |
|
38 |
|
39 //********************************************************************************** |
|
40 // SOAP FUNCTIONS |
|
41 // |
|
42 //********************************************************************************** |
|
43 //********************************************************************************** |
|
44 // ns1__authentication() |
|
45 //********************************************************************************** |
|
46 int ns1__authentication(struct soap *soap, |
|
47 char* securityToken, |
|
48 char** result) |
|
49 { |
|
50 // Construct & send & receive HTI message |
|
51 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_AUTH ); |
|
52 msg.AddString( securityToken ); |
|
53 if ( msg.SendReceiveMsg( HTIMSG_TIMEOUT_30_SECONDS ) ) |
|
54 return SOAP_FAULT; |
|
55 |
|
56 // Check response |
|
57 if ( msg.CheckCommandCode( CMD_HTI_AUTH ) ) |
|
58 return SOAP_FAULT; |
|
59 |
|
60 *result = msg.GetSoapString( 1, msg.GetMsgLen() - 1 ); |
|
61 |
|
62 return SOAP_OK; |
|
63 } |
|
64 //********************************************************************************** |
|
65 // ns1__getVersion() |
|
66 //********************************************************************************** |
|
67 int ns1__getVersion(struct soap* soap, |
|
68 void *_, |
|
69 char **result) |
|
70 { |
|
71 // Construct & send & receive HTI message |
|
72 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_VERSION ); |
|
73 if ( msg.SendReceiveMsg( HTIMSG_TIMEOUT_30_SECONDS ) ) |
|
74 return SOAP_FAULT; |
|
75 |
|
76 // Fill version string |
|
77 *result = (char*)soap_malloc(soap, 8 ); |
|
78 sprintf(*result, "%u.%u", msg.GetByte(0), msg.GetByte(1)); |
|
79 |
|
80 return SOAP_OK; |
|
81 } |
|
82 //********************************************************************************** |
|
83 // ns1__stop() |
|
84 //********************************************************************************** |
|
85 int ns1__stop(struct soap* soap, |
|
86 void *_, |
|
87 struct ns1__stopResponse *out) |
|
88 { |
|
89 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_STOP ); |
|
90 msg.SendMsg(); |
|
91 return SOAP_OK; |
|
92 } |
|
93 |
|
94 //********************************************************************************** |
|
95 // ns1__reset() |
|
96 //********************************************************************************** |
|
97 int ns1__reset(struct soap* soap, |
|
98 void *_, |
|
99 struct ns1__resetResponse *out) |
|
100 { |
|
101 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_RESET ); |
|
102 msg.SendMsg(); |
|
103 return SOAP_OK; |
|
104 } |
|
105 //********************************************************************************** |
|
106 // ns1__reboot() |
|
107 //********************************************************************************** |
|
108 int ns1__reboot(struct soap* soap, |
|
109 void *_, |
|
110 struct ns1__rebootResponse *out) |
|
111 { |
|
112 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_REBOOT ); |
|
113 msg.SendMsg(); |
|
114 return SOAP_OK; |
|
115 } |
|
116 //********************************************************************************** |
|
117 // ns1__listServices() |
|
118 //********************************************************************************** |
|
119 int ns1__listServices(struct soap* soap, |
|
120 void *_, |
|
121 struct ArrayOfHtiService &array) |
|
122 { |
|
123 // Construct & send & receive HTI message |
|
124 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_SERVICE_LIST ); |
|
125 if ( msg.SendReceiveMsg( HTIMSG_TIMEOUT_30_SECONDS ) ) |
|
126 return SOAP_FAULT; |
|
127 |
|
128 // get services |
|
129 array.__size = msg.GetMsgLen()/SERVICE_DESCR_LEN; |
|
130 array.__ptrHtiService = |
|
131 (ns1__HtiService*)soap_malloc( soap, sizeof(ns1__HtiService)*array.__size ); |
|
132 for( int i=0; i<array.__size; ++i) |
|
133 { |
|
134 array.__ptrHtiService[i].serviceUid = msg.GetDWord( i*SERVICE_DESCR_LEN ); |
|
135 array.__ptrHtiService[i].serviceName = |
|
136 msg.GetSoapString( i*SERVICE_DESCR_LEN + SERVICE_UID_LEN, SERVICE_NAME_LEN ); |
|
137 } |
|
138 |
|
139 return SOAP_OK; |
|
140 } |
|
141 //********************************************************************************** |
|
142 // ns1__restoreFactorySettings() |
|
143 //********************************************************************************** |
|
144 int ns1__restoreFactorySettings(struct soap* soap, |
|
145 enum ns1__restoreMode mode, |
|
146 struct ns1__restoreFactorySettingsResponse *out) |
|
147 { |
|
148 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_FORMAT ); |
|
149 msg.AddByte( mode ); |
|
150 msg.SendMsg(); |
|
151 return SOAP_OK; |
|
152 } |
|
153 //********************************************************************************** |
|
154 // ns1__restoreFactorySettings() |
|
155 //********************************************************************************** |
|
156 int ns1__instanceID(struct soap* soap, |
|
157 void *_, |
|
158 unsigned int &instanceID) |
|
159 { |
|
160 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_INSTANCE_ID ); |
|
161 if ( msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ) ) |
|
162 return SOAP_FAULT; |
|
163 instanceID = (unsigned int) msg.GetInt( 0 ); |
|
164 return SOAP_OK; |
|
165 } |
|
166 //********************************************************************************** |
|
167 // ns1__showConsole() |
|
168 //********************************************************************************** |
|
169 int ns1__showConsole(struct soap* soap, |
|
170 void *_, |
|
171 struct ns1__showConsoleResponse *out) |
|
172 { |
|
173 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_SHOW_CONSOLE ); |
|
174 return msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ); |
|
175 } |
|
176 //********************************************************************************** |
|
177 // ns1__hideConsole() |
|
178 //********************************************************************************** |
|
179 int ns1__hideConsole(struct soap* soap, |
|
180 void *_, |
|
181 struct ns1__hideConsoleResponse *out) |
|
182 { |
|
183 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_HIDE_CONSOLE ); |
|
184 return msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ); |
|
185 } |
|
186 //********************************************************************************** |
|
187 // ns1__debugPrint() |
|
188 //********************************************************************************** |
|
189 int ns1__debugPrint(struct soap* soap, |
|
190 char* debugMessage, |
|
191 struct ns1__debugPrintResponse *out) |
|
192 { |
|
193 HtiMsgHelper msg( soap, HTI_SYSTEM_UID, CMD_HTI_DEBUG_PRINT ); |
|
194 msg.AddString( debugMessage ); |
|
195 return msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ); |
|
196 } |
|