|
1 /* |
|
2 * Copyright (c) 2008 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: rtcMessages |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef RTCMESSAGES_H |
|
19 #define RTCMESSAGES_H |
|
20 |
|
21 #include "logger.h" |
|
22 #include "comms.h" |
|
23 #include "commsmessage.h" |
|
24 |
|
25 #include "javauid.h" |
|
26 |
|
27 using namespace java::comms; |
|
28 |
|
29 using java::util::Uid; |
|
30 |
|
31 namespace java |
|
32 { |
|
33 namespace captain |
|
34 { |
|
35 // Message IDs of all RTC services |
|
36 const int RTC_MSG_ID_LAUNCH_APPLICATION_REQ = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 1; // 101 |
|
37 const int RTC_MSG_ID_TERMINATE_APPLICATION_REQ = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 2; // 102 |
|
38 const int RTC_MSG_ID_APPLICATION_RUNNING_IND = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 3; // 103 |
|
39 const int RTC_MSG_ID_APPLICATION_TERMINATED_IND = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 4; // 104 |
|
40 const int RTC_MSG_ID_ADD_PUSH_CONNECTION_IND = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 5; // 105 |
|
41 |
|
42 const int RTC_MSG_ID_SET_EXTRA_ARGUMENTS = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 50; // 150 |
|
43 const int RTC_MSG_ID_GET_EXTRA_ARGUMENTS = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 51; // 151 |
|
44 const int RTC_MSG_ID_GET_EXTRA_ARGUMENTS_ACK = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 52; // 152 |
|
45 |
|
46 const int RTC_LAUNCH_TYPE_NORMAL_C = 0; |
|
47 const int RTC_LAUNCH_TYPE_PUSH_C = 1; |
|
48 const int RTC_LAUNCH_TYPE_AUTO_INVOCATION_C = 2; |
|
49 const int RTC_LAUNCH_TYPE_BACKGROUND_C = 3; |
|
50 const int RTC_LAUNCH_TYPE_DEBUG_C = 4; |
|
51 const int RTC_LAUNCH_TYPE_PREWARM_C = 5; |
|
52 |
|
53 #define PREWARM_UID java::util::Uid(L"prewarm") |
|
54 |
|
55 const int RTC_LAUNCH_OPTIONS_NONE_C = 0x00; |
|
56 const int RTC_LAUNCH_OPTIONS_RUNNING_IND_REQ_C = 0x01; |
|
57 const int RTC_LAUNCH_OPTIONS_TERMINATE_IND_REQ_C = 0x02; |
|
58 |
|
59 const char* const RTC_LAUNCH_RUNTIME_MIDP_C = "midp"; |
|
60 |
|
61 const int RTC_LAUNCH_OPTIONS_INDICATION_MASK = RTC_LAUNCH_OPTIONS_RUNNING_IND_REQ_C | |
|
62 RTC_LAUNCH_OPTIONS_TERMINATE_IND_REQ_C; |
|
63 |
|
64 const int RTC_TERMINATE_OPTIONS_NONE_C = 0x00; |
|
65 const int RTC_TERMINATE_OPTIONS_TERMINATE_IND_REQ_C = 0x02; |
|
66 |
|
67 const int RTC_TERMINATE_OPTIONS_INDICATION_MASK = RTC_TERMINATE_OPTIONS_TERMINATE_IND_REQ_C; |
|
68 |
|
69 // Launch application request |
|
70 inline void setLaunchApplicationReqParams(CommsMessage& aMessage, |
|
71 const Uid& aUid, const int& aType, const int& aOptions, |
|
72 const std::string& aRtc = RTC_LAUNCH_RUNTIME_MIDP_C, |
|
73 const std::wstring& aApplicationArguments = L"", |
|
74 const std::wstring& aRuntimeArguments = L"") |
|
75 { |
|
76 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
77 aMessage.setMessageId(RTC_MSG_ID_LAUNCH_APPLICATION_REQ); |
|
78 aMessage << aUid << aType << aOptions << aRtc; |
|
79 aMessage << aApplicationArguments << aRuntimeArguments; |
|
80 |
|
81 LOG4(EJavaCaptain, EInfoHeavyLoad, |
|
82 "RTC_MSG_ID_LAUNCH_APPLICATION_REQ (uid=%S, rtc=%s, type=%d, options=%d) encoded", |
|
83 aUid.toString().c_str(), aRtc.c_str(), aType, aOptions); |
|
84 } |
|
85 |
|
86 inline void getLaunchApplicationReqParams(CommsMessage& aMessage, |
|
87 Uid& aUid, int& aType, int& aOptions, std::string& aRtc, |
|
88 std::wstring& aApplicationArguments, std::wstring& aRuntimeArguments) |
|
89 { |
|
90 if (aMessage.getMessageId() == RTC_MSG_ID_LAUNCH_APPLICATION_REQ) |
|
91 { |
|
92 aMessage >> aUid >> aType >> aOptions >> aRtc; |
|
93 aMessage >> aApplicationArguments >> aRuntimeArguments; |
|
94 |
|
95 LOG4(EJavaCaptain, EInfoHeavyLoad, |
|
96 "RTC_MSG_ID_LAUNCH_APPLICATION_REQ (uid=%S, rtc=%s, type=%d, options=%d) decoded", |
|
97 aUid.toString().c_str(), aRtc.c_str(), aType, aOptions); |
|
98 } |
|
99 else |
|
100 { |
|
101 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
102 aMessage.getMessageId(), RTC_MSG_ID_LAUNCH_APPLICATION_REQ); |
|
103 } |
|
104 } |
|
105 |
|
106 // Terminate application request |
|
107 inline void setTerminateApplicationReqParams(CommsMessage& aMessage, |
|
108 const Uid& aUid, const int& aOptions) |
|
109 { |
|
110 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
111 aMessage.setMessageId(RTC_MSG_ID_TERMINATE_APPLICATION_REQ); |
|
112 aMessage << aUid << aOptions; |
|
113 LOG2(EJavaCaptain, EInfoHeavyLoad, |
|
114 "RTC_MSG_ID_TERMINATE_APPLICATION_REQ (uid=%S, options=%d) encoded", |
|
115 aUid.toString().c_str(), aOptions); |
|
116 } |
|
117 inline void getTerminateApplicationReqParams(CommsMessage& aMessage, |
|
118 Uid& aUid, int& aOptions) |
|
119 { |
|
120 if (aMessage.getMessageId() == RTC_MSG_ID_TERMINATE_APPLICATION_REQ) |
|
121 { |
|
122 aMessage >> aUid >> aOptions; |
|
123 LOG2(EJavaCaptain, EInfoHeavyLoad, |
|
124 "RTC_MSG_ID_TERMINATE_APPLICATION_REQ (uid=%S, options=%d) decoded", |
|
125 aUid.toString().c_str(), aOptions); |
|
126 } |
|
127 else |
|
128 { |
|
129 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
130 aMessage.getMessageId(), RTC_MSG_ID_TERMINATE_APPLICATION_REQ); |
|
131 } |
|
132 } |
|
133 |
|
134 // Application running indication |
|
135 inline void setApplicationRunningIndParams(CommsMessage& aMessage, |
|
136 const Uid& aUid, const int& aStatus, const int& aPid = 0) |
|
137 { |
|
138 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
139 aMessage.setMessageId(RTC_MSG_ID_APPLICATION_RUNNING_IND); |
|
140 aMessage << aUid << aStatus << aPid; |
|
141 LOG3(EJavaCaptain, EInfoHeavyLoad, |
|
142 "RTC_MSG_ID_APPLICATION_RUNNING_IND (uid=%S, status=%d, pid=%d) encoded", |
|
143 aUid.toString().c_str(), aStatus, aPid); |
|
144 } |
|
145 inline void getApplicationRunningIndParams(CommsMessage& aMessage, |
|
146 Uid& aUid, int& aStatus) |
|
147 { |
|
148 if (aMessage.getMessageId() == RTC_MSG_ID_APPLICATION_RUNNING_IND) |
|
149 { |
|
150 aMessage >> aUid >> aStatus; |
|
151 LOG2(EJavaCaptain, EInfoHeavyLoad, |
|
152 "RTC_MSG_ID_APPLICATION_RUNNING_IND (uid=%S, status=%d) decoded", |
|
153 aUid.toString().c_str(), aStatus); |
|
154 } |
|
155 else |
|
156 { |
|
157 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
158 aMessage.getMessageId(), RTC_MSG_ID_APPLICATION_RUNNING_IND); |
|
159 } |
|
160 } |
|
161 |
|
162 // Application terminated indication |
|
163 inline void setApplicationTerminatedIndParams(CommsMessage& aMessage, |
|
164 const Uid& aUid, const int& aStatus) |
|
165 { |
|
166 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
167 aMessage.setMessageId(RTC_MSG_ID_APPLICATION_TERMINATED_IND); |
|
168 aMessage << aUid << aStatus; |
|
169 LOG2(EJavaCaptain, EInfoHeavyLoad, |
|
170 "RTC_MSG_ID_APPLICATION_TERMINATED_IND (uid=%S, status=%d) encoded", |
|
171 aUid.toString().c_str(), aStatus); |
|
172 } |
|
173 inline void getApplicationTerminatedIndParams(CommsMessage& aMessage, |
|
174 Uid& aUid, int& aStatus) |
|
175 { |
|
176 if (aMessage.getMessageId() == RTC_MSG_ID_APPLICATION_TERMINATED_IND) |
|
177 { |
|
178 aMessage >> aUid >> aStatus; |
|
179 LOG2(EJavaCaptain, EInfoHeavyLoad, |
|
180 "RTC_MSG_ID_APPLICATION_TERMINATED_IND (uid=%S, status=%d) decoded", |
|
181 aUid.toString().c_str(), aStatus); |
|
182 } |
|
183 else |
|
184 { |
|
185 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
186 aMessage.getMessageId(), RTC_MSG_ID_APPLICATION_TERMINATED_IND); |
|
187 } |
|
188 } |
|
189 |
|
190 // Indication of adding a new push listener to already running MIDlet |
|
191 inline void setUpdatePushReqParams(CommsMessage& aMessage, const Uid& aUid) |
|
192 { |
|
193 aMessage.setModuleId(PLUGIN_ID_RTC_PUSH_C); |
|
194 aMessage.setMessageId(RTC_MSG_ID_ADD_PUSH_CONNECTION_IND); |
|
195 aMessage << aUid; |
|
196 } |
|
197 |
|
198 inline void getUpdatePushReqParams(CommsMessage& aMessage, Uid& aUid) |
|
199 { |
|
200 if (aMessage.getMessageId() == RTC_MSG_ID_ADD_PUSH_CONNECTION_IND) |
|
201 { |
|
202 aMessage >> aUid; |
|
203 } |
|
204 else |
|
205 { |
|
206 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
207 aMessage.getMessageId(), RTC_MSG_ID_ADD_PUSH_CONNECTION_IND); |
|
208 } |
|
209 } |
|
210 |
|
211 inline void setSetExtraArguments(CommsMessage& aMessage, |
|
212 const std::wstring& aRuntimeArguments, |
|
213 const std::wstring& aApplicationArguments) |
|
214 { |
|
215 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
216 aMessage.setMessageId(RTC_MSG_ID_SET_EXTRA_ARGUMENTS); |
|
217 |
|
218 aMessage << aRuntimeArguments << aApplicationArguments; |
|
219 } |
|
220 |
|
221 inline void getSetExtraArguments(CommsMessage& aMessage, |
|
222 std::wstring& aRuntimeArguments, |
|
223 std::wstring& aApplicationArguments) |
|
224 { |
|
225 if (aMessage.getMessageId() == RTC_MSG_ID_SET_EXTRA_ARGUMENTS) |
|
226 { |
|
227 aMessage >> aRuntimeArguments >> aApplicationArguments; |
|
228 } |
|
229 else |
|
230 { |
|
231 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
232 aMessage.getMessageId(), RTC_MSG_ID_SET_EXTRA_ARGUMENTS); |
|
233 } |
|
234 } |
|
235 |
|
236 inline void setGetExtraArguments(CommsMessage& aMessage) |
|
237 { |
|
238 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
239 aMessage.setMessageId(RTC_MSG_ID_GET_EXTRA_ARGUMENTS); |
|
240 } |
|
241 |
|
242 // Not needed (yet) ; inline void getGetRuntimeAttributes() |
|
243 |
|
244 inline void setGetExtraArgumentsAck(CommsMessage& aMessage, |
|
245 const std::wstring& aRuntimeArguments, |
|
246 const std::wstring& aApplicationArguments) |
|
247 { |
|
248 aMessage.setModuleId(PLUGIN_ID_RTC_C); |
|
249 aMessage.setMessageId(RTC_MSG_ID_GET_EXTRA_ARGUMENTS_ACK); |
|
250 |
|
251 aMessage << aRuntimeArguments << aApplicationArguments; |
|
252 } |
|
253 |
|
254 inline void getGetExtraArgumentsAck(CommsMessage& aMessage, |
|
255 std::wstring& aRuntimeArguments, |
|
256 std::wstring& aApplicationArguments) |
|
257 { |
|
258 if (aMessage.getMessageId() == RTC_MSG_ID_GET_EXTRA_ARGUMENTS_ACK) |
|
259 { |
|
260 aMessage >> aRuntimeArguments >> aApplicationArguments; |
|
261 } |
|
262 else |
|
263 { |
|
264 ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", |
|
265 aMessage.getMessageId(), RTC_MSG_ID_GET_EXTRA_ARGUMENTS_ACK); |
|
266 } |
|
267 } |
|
268 |
|
269 } // namespace captain |
|
270 } // namespace java |
|
271 |
|
272 #endif // RTCMESSAGES_H |
|
273 |