|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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: isolationserverBlocks.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] - do not remove |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <StifTestInterface.h> |
|
24 #include "isolationserver.h" |
|
25 #include <e32const.h> |
|
26 |
|
27 #include <glib.h> |
|
28 #include <glib/gprintf.h> // for g_stpcpy |
|
29 #include <string.h> |
|
30 #include <stdlib.h> |
|
31 |
|
32 #include <glowmem.h> |
|
33 #include "msgliterals.h" |
|
34 #include "msg_enums.h" |
|
35 #include <math.h> |
|
36 #define ONE_K_OPENC_FIX 1020 |
|
37 |
|
38 typedef enum |
|
39 { |
|
40 RC_OK, |
|
41 RC_ERROR |
|
42 } RC_Code_t; |
|
43 |
|
44 |
|
45 typedef struct |
|
46 { |
|
47 gchar *recipient; |
|
48 gchar *message; |
|
49 } MessageData; |
|
50 |
|
51 typedef struct |
|
52 { |
|
53 gchar *proxy_server; |
|
54 gchar *proxy_port; |
|
55 }ProxyData; |
|
56 |
|
57 typedef struct |
|
58 { |
|
59 gchar *server; |
|
60 gchar *username; |
|
61 gchar *password; |
|
62 gchar *resource; |
|
63 MessageData *msg_data; |
|
64 gchar *port; |
|
65 |
|
66 ProxyData *proxy_data; |
|
67 gchar *contact; |
|
68 gchar *connmgr_bus; |
|
69 gchar *connmgr_path; |
|
70 gchar *protocol; |
|
71 gchar *key_given_name; |
|
72 gchar *key_middle_name; |
|
73 gchar *key_jid; |
|
74 gchar *key_full_name; |
|
75 gchar *mimetype; |
|
76 gchar *image_file_name; |
|
77 |
|
78 } ConnectData; |
|
79 |
|
80 |
|
81 // Function to read data from the cfg file |
|
82 static RC_Code_t read_data ( ConnectData*& connect_data, |
|
83 CStifItemParser& aItem ); |
|
84 |
|
85 // Function to free the allocated resources |
|
86 static void free_data ( ConnectData*& connect_data ); |
|
87 |
|
88 // EXTERNAL DATA STRUCTURES |
|
89 //extern ?external_data; |
|
90 |
|
91 // EXTERNAL FUNCTION PROTOTYPES |
|
92 //extern ?external_function( ?arg_type,?arg_type ); |
|
93 |
|
94 // CONSTANTS |
|
95 //const ?type ?constant_var = ?constant; |
|
96 |
|
97 // MACROS |
|
98 //#define ?macro ?macro_def |
|
99 |
|
100 // LOCAL CONSTANTS AND MACROS |
|
101 //const ?type ?constant_var = ?constant; |
|
102 //#define ?macro_name ?macro_def |
|
103 |
|
104 // MODULE DATA STRUCTURES |
|
105 //enum ?declaration |
|
106 //typedef ?declaration |
|
107 |
|
108 // LOCAL FUNCTION PROTOTYPES |
|
109 //?type ?function_name( ?arg_type, ?arg_type ); |
|
110 |
|
111 // FORWARD DECLARATIONS |
|
112 //class ?FORWARD_CLASSNAME; |
|
113 |
|
114 // ============================= LOCAL FUNCTIONS =============================== |
|
115 |
|
116 |
|
117 |
|
118 //----------------------------------------------------------------------------- |
|
119 // function_name : read_data |
|
120 // description : Reads data from the CFG file |
|
121 // Returns : None |
|
122 //----------------------------------------------------------------------------- |
|
123 // |
|
124 static RC_Code_t |
|
125 read_data ( ConnectData*& connect_data, CStifItemParser& aItem ) |
|
126 { |
|
127 TPtrC string; |
|
128 TBuf8<KMaxFileName> temp; |
|
129 MessageData *msg_data = NULL; |
|
130 |
|
131 |
|
132 ProxyData *proxy_data = NULL; |
|
133 // TInt proxy_port; |
|
134 |
|
135 |
|
136 |
|
137 connect_data = g_new0 ( ConnectData, 1 ); |
|
138 if ( !connect_data ) |
|
139 { |
|
140 return RC_ERROR; |
|
141 } |
|
142 |
|
143 msg_data = g_new0 ( MessageData, 1 ); |
|
144 if ( !msg_data ) |
|
145 { |
|
146 free_data ( connect_data ); |
|
147 return RC_ERROR; |
|
148 } |
|
149 |
|
150 connect_data->msg_data = msg_data; |
|
151 |
|
152 |
|
153 proxy_data = g_new0 ( ProxyData, 1 ); |
|
154 if ( !proxy_data ) |
|
155 { |
|
156 free_data ( connect_data ); |
|
157 return RC_ERROR; |
|
158 } |
|
159 connect_data->proxy_data = proxy_data; |
|
160 |
|
161 |
|
162 // Read server name |
|
163 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
164 { |
|
165 temp.Copy ( string ); |
|
166 temp.Append ( '\0' ); |
|
167 connect_data->server = g_new0 ( gchar, temp.Length() ); |
|
168 if ( !connect_data->server ) |
|
169 { |
|
170 free_data ( connect_data ); |
|
171 return RC_ERROR; |
|
172 } |
|
173 g_stpcpy ( connect_data->server, ( gchar * ) temp.Ptr() ); |
|
174 } |
|
175 |
|
176 // Read Username |
|
177 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
178 { |
|
179 temp.Copy ( string ); |
|
180 temp.Append ( '\0' ); |
|
181 connect_data->username = g_new0 ( gchar, temp.Length() ); |
|
182 if ( !connect_data->username ) |
|
183 { |
|
184 free_data ( connect_data ); |
|
185 return RC_ERROR; |
|
186 } |
|
187 g_stpcpy ( connect_data->username, ( gchar * ) temp.Ptr() ); |
|
188 } |
|
189 |
|
190 // Read Password corresponding to Username |
|
191 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
192 { |
|
193 temp.Copy ( string ); |
|
194 temp.Append ( '\0' ); |
|
195 connect_data->password = g_new0 ( gchar, temp.Length () ); |
|
196 if ( !connect_data->password ) |
|
197 { |
|
198 free_data ( connect_data ); |
|
199 return RC_ERROR; |
|
200 } |
|
201 g_stpcpy ( connect_data->password, ( gchar *) temp.Ptr() ); |
|
202 } |
|
203 |
|
204 // Read recipient |
|
205 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
206 { |
|
207 temp.Copy ( string ); |
|
208 temp.Append ( '\0' ); |
|
209 msg_data->recipient = g_new0 ( gchar, temp.Length() ); |
|
210 if ( !msg_data->recipient ) |
|
211 { |
|
212 free_data ( connect_data ); |
|
213 return RC_ERROR; |
|
214 } |
|
215 g_stpcpy ( msg_data->recipient, ( gchar * ) temp.Ptr() ); |
|
216 } |
|
217 |
|
218 // Read Message |
|
219 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
220 { |
|
221 temp.Copy ( string ); |
|
222 temp.Append ( '\0' ); |
|
223 msg_data->message = g_new0 ( gchar, temp.Length() ); |
|
224 if ( !msg_data->message ) |
|
225 { |
|
226 free_data ( connect_data ); |
|
227 return RC_ERROR; |
|
228 } |
|
229 g_stpcpy ( msg_data->message, ( gchar * ) temp.Ptr() ); |
|
230 } |
|
231 |
|
232 // Read resource identifier |
|
233 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
234 { |
|
235 temp.Copy ( string ); |
|
236 temp.Append ( '\0' ); |
|
237 connect_data->resource = g_new0 ( gchar, temp.Length() ); |
|
238 if ( !connect_data->resource ) |
|
239 { |
|
240 free_data ( connect_data ); |
|
241 return RC_ERROR; |
|
242 } |
|
243 g_stpcpy ( connect_data->resource, ( gchar * ) temp.Ptr() ); |
|
244 } |
|
245 |
|
246 |
|
247 // Read proxy server and proxy port |
|
248 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
249 { |
|
250 temp.Copy ( string ); |
|
251 temp.Append ( '\0' ); |
|
252 proxy_data->proxy_server = g_new0 ( gchar, temp.Length() ); |
|
253 if ( !proxy_data->proxy_server ) |
|
254 { |
|
255 free_data ( connect_data ); |
|
256 return RC_ERROR; |
|
257 } |
|
258 g_stpcpy ( proxy_data->proxy_server, ( gchar * ) temp.Ptr() ); |
|
259 } |
|
260 |
|
261 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
262 { |
|
263 temp.Copy ( string ); |
|
264 temp.Append ( '\0' ); |
|
265 proxy_data->proxy_port = g_new0 ( gchar, temp.Length() ); |
|
266 if ( !proxy_data->proxy_port ) |
|
267 { |
|
268 free_data ( connect_data ); |
|
269 return RC_ERROR; |
|
270 } |
|
271 g_stpcpy ( proxy_data->proxy_port, ( gchar * ) temp.Ptr() ); |
|
272 } |
|
273 |
|
274 |
|
275 |
|
276 /* if ( aItem.GetNextString ( proxy_port ) == KErrNone ) |
|
277 { |
|
278 proxy_data->proxy_port = proxy_port; |
|
279 } */ |
|
280 |
|
281 |
|
282 // Read POrt address |
|
283 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
284 { |
|
285 temp.Copy ( string ); |
|
286 temp.Append ( '\0' ); |
|
287 connect_data->port = g_new0 ( gchar, temp.Length() ); |
|
288 if ( !connect_data->port ) |
|
289 { |
|
290 free_data ( connect_data ); |
|
291 return RC_ERROR; |
|
292 } |
|
293 g_stpcpy ( connect_data->port, ( gchar * ) temp.Ptr() ); |
|
294 } |
|
295 |
|
296 // read Add member |
|
297 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
298 { |
|
299 temp.Copy ( string ); |
|
300 temp.Append ( '\0' ); |
|
301 connect_data->contact = g_new0 ( gchar, temp.Length() ); |
|
302 if ( !connect_data->contact ) |
|
303 { |
|
304 free_data ( connect_data ); |
|
305 return RC_ERROR; |
|
306 } |
|
307 g_stpcpy ( connect_data->contact, ( gchar * ) temp.Ptr() ); |
|
308 } |
|
309 |
|
310 // read CONNMGR_BUS |
|
311 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
312 { |
|
313 temp.Copy ( string ); |
|
314 temp.Append ( '\0' ); |
|
315 connect_data->connmgr_bus = g_new0 ( gchar, temp.Length() ); |
|
316 if ( !connect_data->connmgr_bus ) |
|
317 { |
|
318 free_data ( connect_data ); |
|
319 return RC_ERROR; |
|
320 } |
|
321 g_stpcpy ( connect_data->connmgr_bus, ( gchar * ) temp.Ptr() ); |
|
322 } |
|
323 |
|
324 // read CONNMGR_PATH |
|
325 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
326 { |
|
327 temp.Copy ( string ); |
|
328 temp.Append ( '\0' ); |
|
329 connect_data->connmgr_path = g_new0 ( gchar, temp.Length() ); |
|
330 if ( !connect_data->connmgr_path ) |
|
331 { |
|
332 free_data ( connect_data ); |
|
333 return RC_ERROR; |
|
334 } |
|
335 g_stpcpy ( connect_data->connmgr_path, ( gchar * ) temp.Ptr() ); |
|
336 } |
|
337 |
|
338 // read PROTOCOL |
|
339 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
340 { |
|
341 temp.Copy ( string ); |
|
342 temp.Append ( '\0' ); |
|
343 connect_data->protocol = g_new0 ( gchar, temp.Length() ); |
|
344 if ( !connect_data->protocol ) |
|
345 { |
|
346 free_data ( connect_data ); |
|
347 return RC_ERROR; |
|
348 } |
|
349 g_stpcpy ( connect_data->protocol, ( gchar * ) temp.Ptr() ); |
|
350 } |
|
351 |
|
352 |
|
353 // read given Name |
|
354 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
355 { |
|
356 temp.Copy ( string ); |
|
357 temp.Append ( '\0' ); |
|
358 connect_data->key_given_name = g_new0 ( gchar, temp.Length() ); |
|
359 if ( !connect_data->key_given_name ) |
|
360 { |
|
361 free_data ( connect_data ); |
|
362 return RC_ERROR; |
|
363 } |
|
364 g_stpcpy ( connect_data->key_given_name, ( gchar * ) temp.Ptr() ); |
|
365 } |
|
366 |
|
367 // read middle Name |
|
368 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
369 { |
|
370 temp.Copy ( string ); |
|
371 temp.Append ( '\0' ); |
|
372 connect_data->key_middle_name = g_new0 ( gchar, temp.Length() ); |
|
373 if ( !connect_data->key_middle_name ) |
|
374 { |
|
375 free_data ( connect_data ); |
|
376 return RC_ERROR; |
|
377 } |
|
378 g_stpcpy ( connect_data->key_middle_name, ( gchar * ) temp.Ptr() ); |
|
379 } |
|
380 |
|
381 // read email Name |
|
382 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
383 { |
|
384 temp.Copy ( string ); |
|
385 temp.Append ( '\0' ); |
|
386 connect_data->key_jid = g_new0 ( gchar, temp.Length() ); |
|
387 if ( !connect_data->key_jid ) |
|
388 { |
|
389 free_data ( connect_data ); |
|
390 return RC_ERROR; |
|
391 } |
|
392 g_stpcpy ( connect_data->key_jid, ( gchar * ) temp.Ptr() ); |
|
393 } |
|
394 |
|
395 // read full Name |
|
396 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
397 { |
|
398 temp.Copy ( string ); |
|
399 temp.Append ( '\0' ); |
|
400 connect_data->key_full_name = g_new0 ( gchar, temp.Length() ); |
|
401 if ( !connect_data->key_full_name ) |
|
402 { |
|
403 free_data ( connect_data ); |
|
404 return RC_ERROR; |
|
405 } |
|
406 g_stpcpy ( connect_data->key_full_name, ( gchar * ) temp.Ptr() ); |
|
407 } |
|
408 // read mimetype |
|
409 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
410 { |
|
411 temp.Copy ( string ); |
|
412 temp.Append ( '\0' ); |
|
413 connect_data->mimetype = g_new0 ( gchar, temp.Length() ); |
|
414 if ( !connect_data->mimetype ) |
|
415 { |
|
416 free_data ( connect_data ); |
|
417 return RC_ERROR; |
|
418 } |
|
419 g_stpcpy ( connect_data->mimetype, ( gchar * ) temp.Ptr() ); |
|
420 } |
|
421 // read image filename |
|
422 if ( aItem.GetNextString ( string ) == KErrNone ) |
|
423 { |
|
424 temp.Copy ( string ); |
|
425 temp.Append ( '\0' ); |
|
426 connect_data->image_file_name = g_new0 ( gchar, temp.Length() ); |
|
427 if ( !connect_data->image_file_name ) |
|
428 { |
|
429 free_data ( connect_data ); |
|
430 return RC_ERROR; |
|
431 } |
|
432 g_stpcpy ( connect_data->image_file_name, ( gchar * ) temp.Ptr() ); |
|
433 } |
|
434 return RC_OK; |
|
435 } |
|
436 |
|
437 |
|
438 //----------------------------------------------------------------------------- |
|
439 // function_name : free_data |
|
440 // description : Deallocates all the data |
|
441 // Returns : None |
|
442 //----------------------------------------------------------------------------- |
|
443 // |
|
444 static void |
|
445 free_data ( ConnectData*& connect_data ) |
|
446 { |
|
447 if ( connect_data ) |
|
448 { |
|
449 if ( connect_data->server ) |
|
450 { |
|
451 g_free ( connect_data->server ); |
|
452 connect_data->server = NULL; |
|
453 } |
|
454 |
|
455 if ( connect_data->username ) |
|
456 { |
|
457 g_free ( connect_data->username ); |
|
458 connect_data->username = NULL; |
|
459 } |
|
460 |
|
461 if ( connect_data->password ) |
|
462 { |
|
463 g_free ( connect_data->password ); |
|
464 connect_data->password = NULL; |
|
465 } |
|
466 |
|
467 if ( connect_data->msg_data ) |
|
468 { |
|
469 if ( connect_data->msg_data->recipient ) |
|
470 { |
|
471 g_free ( connect_data->msg_data->recipient ); |
|
472 connect_data->msg_data->recipient = NULL; |
|
473 } |
|
474 if ( connect_data->msg_data->message ) |
|
475 { |
|
476 g_free ( connect_data->msg_data->message ); |
|
477 connect_data->msg_data->message = NULL; |
|
478 } |
|
479 g_free ( connect_data->msg_data ); |
|
480 connect_data->msg_data = NULL; |
|
481 } |
|
482 |
|
483 if ( connect_data->resource ) |
|
484 { |
|
485 g_free ( connect_data->resource ); |
|
486 connect_data->resource = NULL; |
|
487 } |
|
488 |
|
489 |
|
490 if ( connect_data->proxy_data ) |
|
491 { |
|
492 if ( connect_data->proxy_data->proxy_server ) |
|
493 { |
|
494 g_free ( connect_data->proxy_data->proxy_server ); |
|
495 connect_data->proxy_data->proxy_server = NULL; |
|
496 } |
|
497 g_free ( connect_data->proxy_data ); |
|
498 connect_data->proxy_data = NULL; |
|
499 } |
|
500 |
|
501 if ( connect_data->port ) |
|
502 { |
|
503 g_free ( connect_data->port ); |
|
504 connect_data->port = NULL; |
|
505 } |
|
506 |
|
507 |
|
508 if ( connect_data->contact ) |
|
509 { |
|
510 g_free ( connect_data->contact ); |
|
511 connect_data->contact = NULL; |
|
512 } |
|
513 |
|
514 if ( connect_data->key_given_name ) |
|
515 { |
|
516 g_free ( connect_data->key_given_name ); |
|
517 connect_data->key_given_name = NULL; |
|
518 } |
|
519 |
|
520 if ( connect_data->key_middle_name ) |
|
521 { |
|
522 g_free ( connect_data->key_middle_name ); |
|
523 connect_data->key_middle_name = NULL; |
|
524 } |
|
525 |
|
526 if ( connect_data->key_jid ) |
|
527 { |
|
528 g_free ( connect_data->key_jid ); |
|
529 connect_data->key_jid = NULL; |
|
530 } |
|
531 |
|
532 if ( connect_data->key_full_name ) |
|
533 { |
|
534 g_free ( connect_data->key_full_name ); |
|
535 connect_data->key_full_name = NULL; |
|
536 } |
|
537 |
|
538 g_free ( connect_data ); |
|
539 connect_data = NULL; |
|
540 } |
|
541 } |
|
542 |
|
543 //----------------------------------------------------------------------------- |
|
544 // function_name : running isolation server exe |
|
545 // description : Deallocates all the data |
|
546 // Returns : None |
|
547 //----------------------------------------------------------------------------- |
|
548 int run_isoserver() |
|
549 { |
|
550 // running isoserver |
|
551 RProcess isosrv_launcher; |
|
552 TInt lunch_err = 0; |
|
553 _LIT(KProcess, "isoserver.exe"); |
|
554 lunch_err = isosrv_launcher.Create( KProcess, KNullDesC ); |
|
555 if ( KErrNone != lunch_err ) |
|
556 { |
|
557 return KErrGeneral; |
|
558 |
|
559 } |
|
560 isosrv_launcher.Resume(); |
|
561 return KErrNone; |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // ?function_name ?description. |
|
566 // ?description |
|
567 // Returns: ?value_1: ?description |
|
568 // ?value_n: ?description_line1 |
|
569 // ?description_line2 |
|
570 // ----------------------------------------------------------------------------- |
|
571 // |
|
572 /* |
|
573 ?type ?function_name( |
|
574 ?arg_type arg, // ?description |
|
575 ?arg_type arg) // ?description |
|
576 { |
|
577 |
|
578 ?code // ?comment |
|
579 |
|
580 // ?comment |
|
581 ?code |
|
582 } |
|
583 */ |
|
584 |
|
585 // ============================ MEMBER FUNCTIONS =============================== |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // Cisolationserver::Delete |
|
589 // Delete here all resources allocated and opened from test methods. |
|
590 // Called from destructor. |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 void Cisolationserver::Delete() |
|
594 { |
|
595 |
|
596 } |
|
597 |
|
598 // ----------------------------------------------------------------------------- |
|
599 // Cisolationserver::RunMethodL |
|
600 // Run specified method. Contains also table of test mothods and their names. |
|
601 // ----------------------------------------------------------------------------- |
|
602 // |
|
603 TInt Cisolationserver::RunMethodL( |
|
604 CStifItemParser& aItem ) |
|
605 { |
|
606 |
|
607 static TStifFunctionInfo const KFunctions[] = |
|
608 { |
|
609 |
|
610 ENTRY( "SecondSearch", Cisolationserver::SecondSearch), |
|
611 ENTRY( "SearchAndAddContact", Cisolationserver::SearchAndAddContact ), |
|
612 ENTRY( "LoginWithCorrectData", Cisolationserver::LoginWithCorrectdata ), |
|
613 ENTRY( "LoginWithWrongPassword", Cisolationserver::LoginWithWrongPassword ), |
|
614 ENTRY( "LoginWithUnexistUserId", Cisolationserver::LoginWithUnexistUserId), |
|
615 ENTRY( "LoginWithUnexistServer", Cisolationserver::LoginWithUnexistServer), |
|
616 ENTRY( "LoginWithMixedLetterUserId", Cisolationserver::LoginWithMixedletterUserId), |
|
617 ENTRY( "LoginWithMaximumLenghtUserId", Cisolationserver::LoginWithMaximumLengthUserId), |
|
618 ENTRY( "LoginWithMinimumLenghtUserId", Cisolationserver::LoginWithMinimumLengthUserId), |
|
619 ENTRY( "LogoutFromServer", Cisolationserver::LogoutFromServer), |
|
620 ENTRY( "LoginWithBlankUserId", Cisolationserver::LoginWithBlankUserId), |
|
621 ENTRY( "LoginLogOutWithReapitiveSession", Cisolationserver::LoginLogOutWithReapitiveSession), |
|
622 ENTRY( "LoginWithCoreectUserIDWithSpace", Cisolationserver::LoginWithCoreectUserIDWithSpace), |
|
623 ENTRY( "LoginWithInvalidPortAddress", Cisolationserver::LoginWithInvalidPortAddress), |
|
624 ENTRY( "LoginWithMissingSettings", Cisolationserver::LoginWithMissingSettings), |
|
625 ENTRY( "LoginWhenTGAndDDAreNotRunning", Cisolationserver::LoginWhenTGAndDDAreNotRunning), |
|
626 ENTRY( "SendMessageToCorrectUserID", Cisolationserver::SendMessageToCorrectUserID), |
|
627 ENTRY( "SendMaxLenMessageToCorrectUserID", Cisolationserver::SendMaxLenMessageToCorrectUserID), |
|
628 ENTRY( "SendTextMessageUnExistUserID", Cisolationserver::SendTextMessageUnExistUserID), |
|
629 ENTRY( "SendTextMessageWithSpecialCharacter", Cisolationserver::SendTextMessageWithSpecialCharacter), |
|
630 ENTRY( "SendMessageWithBlankUserID", Cisolationserver::SendMessageWithBlankUserID), |
|
631 ENTRY( "SendSmilyToCorrectUserID", Cisolationserver::SendSmilyToCorrectUserID), |
|
632 ENTRY( "SendBlankMessageToUserID", Cisolationserver::SendBlankMessageToUserID), |
|
633 ENTRY( "SendMessageToOfflineContact", Cisolationserver::SendMessageToOfflineContact), |
|
634 ENTRY( "SendContinuousltReapitiveMessage", Cisolationserver::SendContinuousltReapitiveMessage), |
|
635 ENTRY( "SendTextMessageToBlockedUser", Cisolationserver::SendTextMessageToBlockedUser), |
|
636 ENTRY( "SendTextMessageToUserIdWhoIsBlockedSender", Cisolationserver::SendTextMessageToUserIdWhoIsBlockedSender), |
|
637 ENTRY( "SendLongTextMessageToUserId", Cisolationserver::SendLongTextMessageToUserId), |
|
638 ENTRY( "SendTextMessageUserWhoIsNotAddedInContactList", Cisolationserver::SendTextMessageUserWhoIsNotAddedInContactList), |
|
639 ENTRY( "MessageReceiveFromUser", Cisolationserver::MessageReceiveFromUser), |
|
640 ENTRY( "AddExistingContact", Cisolationserver::AddExistingContact), |
|
641 ENTRY( "ClientSendBlankUserIdForADD", Cisolationserver::ClientSendBlankUserIdForADD), |
|
642 ENTRY( "AddContactWhichIsAlreadyAdded", Cisolationserver::AddContactWhichIsAlreadyAdded), |
|
643 ENTRY( "AddExistingContactWIthSpace", Cisolationserver::AddExistingContactWIthSpace), |
|
644 ENTRY( "AddUnexistingUserID", Cisolationserver::AddUnexistingUserID), |
|
645 ENTRY( "AddExistingContactWIthMixedLetter", Cisolationserver::AddExistingContactWIthMixedLetter), |
|
646 ENTRY( "AddInvalidContactWIthSpecialLetter", Cisolationserver::AddInvalidContactWIthSpecialLetter), |
|
647 ENTRY( "DeleteExistingContact", Cisolationserver::DeleteExistingContact), |
|
648 ENTRY( "ClientSendBlankUserIdForDELETE", Cisolationserver::ClientSendBlankUserIdForDELETE), |
|
649 ENTRY( "DeleteContactWhichIsAlreadyDeleted", Cisolationserver::DeleteContactWhichIsAlreadyDeleted), |
|
650 ENTRY( "DeleteExistingContactWIthSpace", Cisolationserver::DeleteExistingContactWIthSpace), |
|
651 ENTRY( "DeleteUnexistingUserID", Cisolationserver::DeleteUnexistingUserID), |
|
652 ENTRY( "DeleteExistingContactWIthMixedLetter", Cisolationserver::DeleteExistingContactWIthMixedLetter), |
|
653 ENTRY( "DeleteInvalidContactWIthSpecialLetter", Cisolationserver::DeleteInvalidContactWIthSpecialLetter), |
|
654 ENTRY( "FetchContatcs", Cisolationserver::FetchContatcs), |
|
655 ENTRY( "AddContatcs", Cisolationserver::AddContatcs), |
|
656 ENTRY( "UpdatePresenceWithAway", Cisolationserver::UpdatePresenceWithAway), |
|
657 ENTRY( "UpdatePresenceWithDnd", Cisolationserver::UpdatePresenceWithDnd), |
|
658 ENTRY( "UpdatePresenceWithAvailable", Cisolationserver::UpdatePresenceWithAvailable), |
|
659 ENTRY( "UpdatePresenceMultipleTimeInSameSession", Cisolationserver::UpdatePresenceMultipleTimeInSameSession), |
|
660 ENTRY( "UpdateOnlyStatusText", Cisolationserver::UpdateOnlyStatusText), |
|
661 ENTRY( "UpdateOnlyUserAvailability", Cisolationserver::UpdateOnlyUserAvailability), |
|
662 ENTRY( "UpdateOwnPresenceWithBlankData", Cisolationserver::UpdateOwnPresenceWithBlankData), |
|
663 ENTRY( "UpdateStatusTextWithMaxLen", Cisolationserver::UpdateStatusTextWithMaxLen), |
|
664 ENTRY( "UpdateStatusTextWithSpecialCharacter", Cisolationserver::UpdateStatusTextWithSpecialCharacter), |
|
665 ENTRY( "HandelingPresenceNotification", Cisolationserver::HandelingPresenceNotification), |
|
666 ENTRY( "SearchKeyValue", Cisolationserver::SearchKeyValue), |
|
667 ENTRY( "SearchKeyValueWithResult", Cisolationserver::SearchKeyValueWithResult ), |
|
668 ENTRY( "SearchKeyValueInvalidParam", Cisolationserver::SearchKeyValueInvalidParam ), |
|
669 ENTRY( "SearchForLargeNoOfResult", Cisolationserver::SearchForLargeNoOfResult ), |
|
670 ENTRY( "SearchKeyValueInvalidParam2", Cisolationserver::SearchKeyValueInvalidParam2 ), |
|
671 ENTRY( "SearchKeyValueInvalidHashValues", Cisolationserver::SearchKeyValueInvalidHashValues ), |
|
672 ENTRY( "SearchKeyValueBlank", Cisolationserver::SearchKeyValueBlank ), |
|
673 ENTRY( "SearchKeyValueSpecialChar", Cisolationserver::SearchKeyValueSpecialChar ), |
|
674 ENTRY( "SearchKeyValueLargeString", Cisolationserver::SearchKeyValueLargeString ), |
|
675 ENTRY( "AcceptAddRequestFromUser", Cisolationserver::AcceptAddRequestFromUser ), |
|
676 ENTRY( "RejectAddRequestFromUser", Cisolationserver::RejectAddRequestFromUser ), |
|
677 ENTRY( "SendAcceptRequestWithoutReceivingAddrequest", Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest ), |
|
678 ENTRY( "SendRejectRequestWithoutReceivingAddrequest", Cisolationserver::SendRejectRequestWithoutReceivingAddrequest ), |
|
679 ENTRY( "SendAcceptRequestWithoutAnyUserID", Cisolationserver::SendAcceptRequestWithoutAnyUserID ), |
|
680 ENTRY( "SendRejectRequestWithoutAnyUserID", Cisolationserver::SendRejectRequestWithoutAnyUserID ), |
|
681 ENTRY( "LogoutWhileUserIsNotLoggedIn", Cisolationserver::LogoutWhileUserIsNotLoggedIn), |
|
682 ENTRY( "GetKeysAndSearch", Cisolationserver::GetKeysAndSearch), |
|
683 ENTRY( "SetOwnAvatar", Cisolationserver::SetOwnAvatar), |
|
684 ENTRY( "ClearOwnAvatar", Cisolationserver::ClearOwnAvatar), |
|
685 ENTRY( "FetchCachedContacts", Cisolationserver::FetchCachedContacts), |
|
686 //ADD NEW ENTRY HERE |
|
687 // [test cases entries] - Do not remove |
|
688 |
|
689 }; |
|
690 |
|
691 const TInt count = sizeof( KFunctions ) / |
|
692 sizeof( TStifFunctionInfo ); |
|
693 |
|
694 return RunInternalL( KFunctions, count, aItem ); |
|
695 |
|
696 } |
|
697 |
|
698 // ----------------------------------------------------------------------------- |
|
699 // Cisolationserver::Login with correct data |
|
700 // Example test method function. |
|
701 // (other items were commented in a header). |
|
702 // ----------------------------------------------------------------------------- |
|
703 // |
|
704 TInt Cisolationserver::LoginWithCorrectdata( CStifItemParser& aItem ) |
|
705 { |
|
706 |
|
707 ConnectData *connect_data = NULL; |
|
708 char smsg[MAX_MSG_SIZE]; |
|
709 char rmsg[MAX_MSG_SIZE]; |
|
710 int index=0; |
|
711 |
|
712 FILE *fp; |
|
713 int timeout = 100; |
|
714 int nBytes; |
|
715 int result = 0; |
|
716 int err = 0; |
|
717 int status = 0; |
|
718 message_hdr_req *msgHdr = NULL; |
|
719 message_hdr_resp* msg_struct = NULL; |
|
720 TInt return_value = 0; |
|
721 // Read data from the CFG file |
|
722 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
723 { |
|
724 iLog->Log ( _L ( "read_data failed" ) ); |
|
725 free_data ( connect_data ); |
|
726 return_value = KErrGeneral; |
|
727 goto return_code; |
|
728 } |
|
729 //request formation |
|
730 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
731 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
732 //message header use |
|
733 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
734 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
735 msgHdr->message_type = ELogin_Request; |
|
736 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
737 index += sizeof( message_hdr_req ); |
|
738 int len = strlen(connect_data->username); |
|
739 strcpy( smsg + index, connect_data->username ); |
|
740 index += len + 1; |
|
741 //appending password |
|
742 len = strlen(connect_data->password ); |
|
743 strcpy( smsg + index, connect_data->password ); |
|
744 index += len + 1; |
|
745 //appending server name |
|
746 len = strlen(connect_data->server ); |
|
747 strcpy( smsg + index, connect_data->server ); |
|
748 index += len + 1; |
|
749 //appending resource |
|
750 len = strlen(connect_data->resource ); |
|
751 strcpy( smsg + index, connect_data->resource ); |
|
752 index += len + 1; |
|
753 //appending ssl |
|
754 smsg[index++]= '1'; |
|
755 smsg[index++]= '\0'; |
|
756 //appending server port |
|
757 len = strlen(connect_data->port ); |
|
758 strcpy( smsg + index, connect_data->port ); |
|
759 index += len + 1; |
|
760 // appending IAP id |
|
761 smsg[index++]= '1'; |
|
762 smsg[index++]= '\0'; |
|
763 //appending connmgr_bus |
|
764 len = strlen(connect_data->connmgr_bus ); |
|
765 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
766 index += len + 1; |
|
767 //appending connmgr_path |
|
768 len = strlen(connect_data->connmgr_path ); |
|
769 strcpy( smsg + index, connect_data->connmgr_path ); |
|
770 index += len + 1; |
|
771 //appending protocol |
|
772 len = strlen(connect_data->protocol ); |
|
773 strcpy( smsg + index, connect_data->protocol ); |
|
774 index += len + 1; |
|
775 #ifdef __WINSCW__ |
|
776 //proxy server |
|
777 len = strlen(connect_data->proxy_data->proxy_server ); |
|
778 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
779 index += len + 1; |
|
780 //proxy port |
|
781 len = strlen(connect_data->proxy_data->proxy_port ); |
|
782 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
783 index += len + 1; |
|
784 #endif |
|
785 //running isoserver |
|
786 run_isoserver(); |
|
787 //create message queue for send request |
|
788 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
789 //create message queue for response request |
|
790 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
791 /* Send Message to queueOne */ |
|
792 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
793 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
794 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
795 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
796 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
797 if (status < 0) |
|
798 { |
|
799 return_value = KErrGeneral; |
|
800 goto return_code; |
|
801 } |
|
802 if( msg_struct->response != 1) |
|
803 { |
|
804 return_value = KErrGeneral; |
|
805 goto return_code; |
|
806 } |
|
807 // login end |
|
808 //fetch req.. |
|
809 for (int i= 0 ;i<3 ;i++) |
|
810 { |
|
811 |
|
812 fp = fopen("c:\\fetch_contact.txt","a"); |
|
813 do { |
|
814 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
815 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
816 fwrite(rmsg,1,status,fp); |
|
817 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
818 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
819 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
820 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
821 fclose(fp); |
|
822 |
|
823 } |
|
824 |
|
825 //fetch end |
|
826 |
|
827 // logout test code from server |
|
828 index=0; |
|
829 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
830 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
831 |
|
832 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
833 |
|
834 msgHdr->message_type = ELogout_Request; |
|
835 |
|
836 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
837 index += sizeof( message_hdr_req ); |
|
838 |
|
839 |
|
840 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
841 |
|
842 do { |
|
843 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
844 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
845 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
846 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
847 |
|
848 if ( msg_struct->response != 1) |
|
849 { |
|
850 return_value = KErrGeneral; |
|
851 goto return_code; |
|
852 } |
|
853 return_value = KErrNone; |
|
854 goto return_code; |
|
855 //killing isoserver |
|
856 return_code: |
|
857 index=0; |
|
858 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
859 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
860 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
861 msgHdr->message_type = EKill_Process; |
|
862 |
|
863 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
864 index += sizeof( message_hdr_req ); |
|
865 |
|
866 |
|
867 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
868 free( msg_struct ); |
|
869 return return_value; |
|
870 |
|
871 } |
|
872 |
|
873 |
|
874 // ----------------------------------------------------------------------------- |
|
875 // Cisolationserver::Logout from server |
|
876 // Example test method function. |
|
877 // (other items were commented in a header). |
|
878 // ----------------------------------------------------------------------------- |
|
879 // |
|
880 TInt Cisolationserver::LogoutFromServer( CStifItemParser& aItem ) |
|
881 { |
|
882 ConnectData *connect_data = NULL; |
|
883 char smsg[MAX_MSG_SIZE]; |
|
884 char rmsg[MAX_MSG_SIZE]; |
|
885 int index=0; |
|
886 |
|
887 FILE *fp; |
|
888 int timeout = 100; |
|
889 int nBytes; |
|
890 int result = 0; |
|
891 int err = 0; |
|
892 int status = 0; |
|
893 message_hdr_req *msgHdr = NULL; |
|
894 message_hdr_resp* msg_struct = NULL; |
|
895 TInt return_value = 0; |
|
896 // Read data from the CFG file |
|
897 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
898 { |
|
899 iLog->Log ( _L ( "read_data failed" ) ); |
|
900 free_data ( connect_data ); |
|
901 return_value = KErrGeneral; |
|
902 goto return_code; |
|
903 } |
|
904 //request formation |
|
905 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
906 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
907 //message header use |
|
908 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
909 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
910 msgHdr->message_type = ELogin_Request; |
|
911 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
912 index += sizeof( message_hdr_req ); |
|
913 int len = strlen(connect_data->username); |
|
914 strcpy( smsg + index, connect_data->username ); |
|
915 index += len + 1; |
|
916 //appending password |
|
917 len = strlen(connect_data->password ); |
|
918 strcpy( smsg + index, connect_data->password ); |
|
919 index += len + 1; |
|
920 //appending server name |
|
921 len = strlen(connect_data->server ); |
|
922 strcpy( smsg + index, connect_data->server ); |
|
923 index += len + 1; |
|
924 //appending resource |
|
925 len = strlen(connect_data->resource ); |
|
926 strcpy( smsg + index, connect_data->resource ); |
|
927 index += len + 1; |
|
928 //appending ssl |
|
929 smsg[index++]= '1'; |
|
930 smsg[index++]= '\0'; |
|
931 //appending server port |
|
932 len = strlen(connect_data->port ); |
|
933 strcpy( smsg + index, connect_data->port ); |
|
934 index += len + 1; |
|
935 // appending IAP id |
|
936 smsg[index++]= '1'; |
|
937 smsg[index++]= '\0'; |
|
938 //appending connmgr_bus |
|
939 len = strlen(connect_data->connmgr_bus ); |
|
940 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
941 index += len + 1; |
|
942 //appending connmgr_path |
|
943 len = strlen(connect_data->connmgr_path ); |
|
944 strcpy( smsg + index, connect_data->connmgr_path ); |
|
945 index += len + 1; |
|
946 //appending protocol |
|
947 len = strlen(connect_data->protocol ); |
|
948 strcpy( smsg + index, connect_data->protocol ); |
|
949 index += len + 1; |
|
950 #ifdef __WINSCW__ |
|
951 //proxy server |
|
952 len = strlen(connect_data->proxy_data->proxy_server ); |
|
953 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
954 index += len + 1; |
|
955 //proxy port |
|
956 len = strlen(connect_data->proxy_data->proxy_port ); |
|
957 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
958 index += len + 1; |
|
959 #endif |
|
960 //running isoserver |
|
961 run_isoserver(); |
|
962 //create message queue for send request |
|
963 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
964 //create message queue for response request |
|
965 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
966 /* Send Message to queueOne */ |
|
967 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
968 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
969 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
970 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
971 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
972 if (status < 0) |
|
973 { |
|
974 return_value = KErrGeneral; |
|
975 goto return_code; |
|
976 } |
|
977 if( msg_struct->response != 1) |
|
978 { |
|
979 return_value = KErrGeneral; |
|
980 goto return_code; |
|
981 } |
|
982 // login end |
|
983 //fetch req.. |
|
984 for (int i= 0 ;i<3 ;i++) |
|
985 { |
|
986 |
|
987 fp = fopen("c:\\fetch_contact.txt","a"); |
|
988 do { |
|
989 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
990 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
991 fwrite(rmsg,1,status,fp); |
|
992 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
993 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
994 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
995 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
996 fclose(fp); |
|
997 |
|
998 } |
|
999 |
|
1000 //fetch end |
|
1001 |
|
1002 // logout test code from server |
|
1003 index=0; |
|
1004 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1005 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1006 |
|
1007 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1008 |
|
1009 msgHdr->message_type = ELogout_Request; |
|
1010 |
|
1011 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1012 index += sizeof( message_hdr_req ); |
|
1013 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1014 |
|
1015 do { |
|
1016 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1017 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1018 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1019 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
1020 |
|
1021 if ( msg_struct->response != 1) |
|
1022 { |
|
1023 return_value = KErrGeneral; |
|
1024 goto return_code; |
|
1025 } |
|
1026 return_value = KErrNone; |
|
1027 goto return_code; |
|
1028 //killing isoserver |
|
1029 return_code: |
|
1030 index=0; |
|
1031 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1032 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1033 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1034 msgHdr->message_type = EKill_Process; |
|
1035 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1036 index += sizeof( message_hdr_req ); |
|
1037 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1038 free( msg_struct ); |
|
1039 return return_value; |
|
1040 |
|
1041 } |
|
1042 |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // Cisolationserver::Login with mixed letter user |
|
1045 // Example test method function. |
|
1046 // (other items were commented in a header). |
|
1047 // ----------------------------------------------------------------------------- |
|
1048 // |
|
1049 TInt Cisolationserver::LoginWithMixedletterUserId( CStifItemParser& aItem ) |
|
1050 { |
|
1051 |
|
1052 ConnectData *connect_data = NULL; |
|
1053 char smsg[MAX_MSG_SIZE]; |
|
1054 char rmsg[MAX_MSG_SIZE]; |
|
1055 int index=0; |
|
1056 |
|
1057 FILE *fp; |
|
1058 int timeout = 100; |
|
1059 int nBytes; |
|
1060 int result = 0; |
|
1061 int err = 0; |
|
1062 int status = 0; |
|
1063 message_hdr_req *msgHdr = NULL; |
|
1064 message_hdr_resp* msg_struct = NULL; |
|
1065 TInt return_value = 0; |
|
1066 // Read data from the CFG file |
|
1067 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
1068 { |
|
1069 iLog->Log ( _L ( "read_data failed" ) ); |
|
1070 free_data ( connect_data ); |
|
1071 return_value = KErrGeneral; |
|
1072 goto return_code; |
|
1073 } |
|
1074 //request formation |
|
1075 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1076 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1077 //message header use |
|
1078 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
1079 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1080 msgHdr->message_type = ELogin_Request; |
|
1081 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1082 index += sizeof( message_hdr_req ); |
|
1083 int len = strlen(connect_data->username); |
|
1084 strcpy( smsg + index, connect_data->username ); |
|
1085 index += len + 1; |
|
1086 //appending password |
|
1087 len = strlen(connect_data->password ); |
|
1088 strcpy( smsg + index, connect_data->password ); |
|
1089 index += len + 1; |
|
1090 //appending server name |
|
1091 len = strlen(connect_data->server ); |
|
1092 strcpy( smsg + index, connect_data->server ); |
|
1093 index += len + 1; |
|
1094 //appending resource |
|
1095 len = strlen(connect_data->resource ); |
|
1096 strcpy( smsg + index, connect_data->resource ); |
|
1097 index += len + 1; |
|
1098 //appending ssl |
|
1099 smsg[index++]= '1'; |
|
1100 smsg[index++]= '\0'; |
|
1101 //appending server port |
|
1102 len = strlen(connect_data->port ); |
|
1103 strcpy( smsg + index, connect_data->port ); |
|
1104 index += len + 1; |
|
1105 // appending IAP id |
|
1106 smsg[index++]= '1'; |
|
1107 smsg[index++]= '\0'; |
|
1108 //appending connmgr_bus |
|
1109 len = strlen(connect_data->connmgr_bus ); |
|
1110 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
1111 index += len + 1; |
|
1112 //appending connmgr_path |
|
1113 len = strlen(connect_data->connmgr_path ); |
|
1114 strcpy( smsg + index, connect_data->connmgr_path ); |
|
1115 index += len + 1; |
|
1116 //appending protocol |
|
1117 len = strlen(connect_data->protocol ); |
|
1118 strcpy( smsg + index, connect_data->protocol ); |
|
1119 index += len + 1; |
|
1120 #ifdef __WINSCW__ |
|
1121 //proxy server |
|
1122 len = strlen(connect_data->proxy_data->proxy_server ); |
|
1123 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
1124 index += len + 1; |
|
1125 //proxy port |
|
1126 len = strlen(connect_data->proxy_data->proxy_port ); |
|
1127 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
1128 index += len + 1; |
|
1129 #endif |
|
1130 //running isoserver |
|
1131 run_isoserver(); |
|
1132 //create message queue for send request |
|
1133 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1134 //create message queue for response request |
|
1135 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1136 /* Send Message to queueOne */ |
|
1137 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1138 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1139 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1140 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1141 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1142 if (status < 0) |
|
1143 { |
|
1144 return_value = KErrGeneral; |
|
1145 goto return_code; |
|
1146 } |
|
1147 if( msg_struct->response != 1) |
|
1148 { |
|
1149 return_value = KErrGeneral; |
|
1150 goto return_code; |
|
1151 } |
|
1152 // login end |
|
1153 //fetch req.. |
|
1154 for (int i= 0 ;i<3 ;i++) |
|
1155 { |
|
1156 |
|
1157 fp = fopen("c:\\fetch_contact.txt","a"); |
|
1158 do { |
|
1159 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1160 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1161 fwrite(rmsg,1,status,fp); |
|
1162 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1163 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
1164 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
1165 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
1166 fclose(fp); |
|
1167 |
|
1168 } |
|
1169 |
|
1170 //fetch end |
|
1171 |
|
1172 // logout test code from server |
|
1173 index=0; |
|
1174 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1175 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1176 |
|
1177 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1178 |
|
1179 msgHdr->message_type = ELogout_Request; |
|
1180 |
|
1181 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1182 index += sizeof( message_hdr_req ); |
|
1183 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1184 |
|
1185 do { |
|
1186 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1187 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1188 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1189 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
1190 |
|
1191 if ( msg_struct->response != 1) |
|
1192 { |
|
1193 return_value = KErrGeneral; |
|
1194 goto return_code; |
|
1195 } |
|
1196 return_value = KErrNone; |
|
1197 goto return_code; |
|
1198 //killing isoserver |
|
1199 return_code: |
|
1200 index=0; |
|
1201 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1202 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1203 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1204 msgHdr->message_type = EKill_Process; |
|
1205 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1206 index += sizeof( message_hdr_req ); |
|
1207 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1208 free( msg_struct ); |
|
1209 return return_value; |
|
1210 |
|
1211 } |
|
1212 |
|
1213 // ----------------------------------------------------------------------------- |
|
1214 // Cisolationserver::Login with mixed letter user |
|
1215 // Example test method function. |
|
1216 // (other items were commented in a header). |
|
1217 // ----------------------------------------------------------------------------- |
|
1218 // |
|
1219 TInt Cisolationserver::LoginWithMinimumLengthUserId( CStifItemParser& aItem ) |
|
1220 { |
|
1221 |
|
1222 ConnectData *connect_data = NULL; |
|
1223 char smsg[MAX_MSG_SIZE]; |
|
1224 char rmsg[MAX_MSG_SIZE]; |
|
1225 int index=0; |
|
1226 |
|
1227 FILE *fp; |
|
1228 int timeout = 100; |
|
1229 int nBytes; |
|
1230 int result = 0; |
|
1231 int err = 0; |
|
1232 int status = 0; |
|
1233 message_hdr_req *msgHdr = NULL; |
|
1234 message_hdr_resp* msg_struct = NULL; |
|
1235 TInt return_value = 0; |
|
1236 // Read data from the CFG file |
|
1237 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
1238 { |
|
1239 iLog->Log ( _L ( "read_data failed" ) ); |
|
1240 free_data ( connect_data ); |
|
1241 return_value = KErrGeneral; |
|
1242 goto return_code; |
|
1243 } |
|
1244 //request formation |
|
1245 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1246 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1247 //message header use |
|
1248 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
1249 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1250 msgHdr->message_type = ELogin_Request; |
|
1251 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1252 index += sizeof( message_hdr_req ); |
|
1253 int len = strlen(connect_data->username); |
|
1254 strcpy( smsg + index, connect_data->username ); |
|
1255 index += len + 1; |
|
1256 //appending password |
|
1257 len = strlen(connect_data->password ); |
|
1258 strcpy( smsg + index, connect_data->password ); |
|
1259 index += len + 1; |
|
1260 //appending server name |
|
1261 len = strlen(connect_data->server ); |
|
1262 strcpy( smsg + index, connect_data->server ); |
|
1263 index += len + 1; |
|
1264 //appending resource |
|
1265 len = strlen(connect_data->resource ); |
|
1266 strcpy( smsg + index, connect_data->resource ); |
|
1267 index += len + 1; |
|
1268 //appending ssl |
|
1269 smsg[index++]= '1'; |
|
1270 smsg[index++]= '\0'; |
|
1271 //appending server port |
|
1272 len = strlen(connect_data->port ); |
|
1273 strcpy( smsg + index, connect_data->port ); |
|
1274 index += len + 1; |
|
1275 // appending IAP id |
|
1276 smsg[index++]= '1'; |
|
1277 smsg[index++]= '\0'; |
|
1278 //appending connmgr_bus |
|
1279 len = strlen(connect_data->connmgr_bus ); |
|
1280 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
1281 index += len + 1; |
|
1282 //appending connmgr_path |
|
1283 len = strlen(connect_data->connmgr_path ); |
|
1284 strcpy( smsg + index, connect_data->connmgr_path ); |
|
1285 index += len + 1; |
|
1286 //appending protocol |
|
1287 len = strlen(connect_data->protocol ); |
|
1288 strcpy( smsg + index, connect_data->protocol ); |
|
1289 index += len + 1; |
|
1290 #ifdef __WINSCW__ |
|
1291 //proxy server |
|
1292 len = strlen(connect_data->proxy_data->proxy_server ); |
|
1293 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
1294 index += len + 1; |
|
1295 //proxy port |
|
1296 len = strlen(connect_data->proxy_data->proxy_port ); |
|
1297 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
1298 index += len + 1; |
|
1299 #endif |
|
1300 //running isoserver |
|
1301 run_isoserver(); |
|
1302 //create message queue for send request |
|
1303 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1304 //create message queue for response request |
|
1305 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1306 /* Send Message to queueOne */ |
|
1307 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1308 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1309 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1310 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1311 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1312 if (status < 0) |
|
1313 { |
|
1314 return_value = KErrGeneral; |
|
1315 goto return_code; |
|
1316 } |
|
1317 if( msg_struct->response != 1) |
|
1318 { |
|
1319 return_value = KErrGeneral; |
|
1320 goto return_code; |
|
1321 } |
|
1322 // login end |
|
1323 //fetch req.. |
|
1324 for (int i= 0 ;i<3 ;i++) |
|
1325 { |
|
1326 |
|
1327 fp = fopen("c:\\fetch_contact.txt","a"); |
|
1328 do { |
|
1329 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1330 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1331 fwrite(rmsg,1,status,fp); |
|
1332 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1333 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
1334 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
1335 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
1336 fclose(fp); |
|
1337 |
|
1338 } |
|
1339 |
|
1340 //fetch end |
|
1341 |
|
1342 // logout test code from server |
|
1343 index=0; |
|
1344 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1345 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1346 |
|
1347 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1348 |
|
1349 msgHdr->message_type = ELogout_Request; |
|
1350 |
|
1351 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1352 index += sizeof( message_hdr_req ); |
|
1353 |
|
1354 |
|
1355 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1356 |
|
1357 do { |
|
1358 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1359 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1360 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1361 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
1362 |
|
1363 if ( msg_struct->response != 1) |
|
1364 { |
|
1365 return_value = KErrGeneral; |
|
1366 goto return_code; |
|
1367 } |
|
1368 return_value = KErrNone; |
|
1369 goto return_code; |
|
1370 //killing isoserver |
|
1371 return_code: |
|
1372 index=0; |
|
1373 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1374 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1375 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1376 msgHdr->message_type = EKill_Process; |
|
1377 |
|
1378 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1379 index += sizeof( message_hdr_req ); |
|
1380 |
|
1381 |
|
1382 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1383 free( msg_struct ); |
|
1384 return return_value; |
|
1385 |
|
1386 } |
|
1387 |
|
1388 // ----------------------------------------------------------------------------- |
|
1389 // Cisolationserver::Login with mixed letter user |
|
1390 // Example test method function. |
|
1391 // (other items were commented in a header). |
|
1392 // ----------------------------------------------------------------------------- |
|
1393 // |
|
1394 TInt Cisolationserver::LoginWithMaximumLengthUserId( CStifItemParser& aItem ) |
|
1395 { |
|
1396 |
|
1397 ConnectData *connect_data = NULL; |
|
1398 char smsg[MAX_MSG_SIZE]; |
|
1399 char rmsg[MAX_MSG_SIZE]; |
|
1400 int index=0; |
|
1401 |
|
1402 FILE *fp; |
|
1403 int timeout = 100; |
|
1404 int nBytes; |
|
1405 int result = 0; |
|
1406 int err = 0; |
|
1407 int status = 0; |
|
1408 message_hdr_req *msgHdr = NULL; |
|
1409 message_hdr_resp* msg_struct = NULL; |
|
1410 TInt return_value = 0; |
|
1411 // Read data from the CFG file |
|
1412 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
1413 { |
|
1414 iLog->Log ( _L ( "read_data failed" ) ); |
|
1415 free_data ( connect_data ); |
|
1416 return_value = KErrGeneral; |
|
1417 goto return_code; |
|
1418 } |
|
1419 //request formation |
|
1420 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1421 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1422 //message header use |
|
1423 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
1424 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1425 msgHdr->message_type = ELogin_Request; |
|
1426 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1427 index += sizeof( message_hdr_req ); |
|
1428 int len = strlen(connect_data->username); |
|
1429 strcpy( smsg + index, connect_data->username ); |
|
1430 index += len + 1; |
|
1431 //appending password |
|
1432 len = strlen(connect_data->password ); |
|
1433 strcpy( smsg + index, connect_data->password ); |
|
1434 index += len + 1; |
|
1435 //appending server name |
|
1436 len = strlen(connect_data->server ); |
|
1437 strcpy( smsg + index, connect_data->server ); |
|
1438 index += len + 1; |
|
1439 //appending resource |
|
1440 len = strlen(connect_data->resource ); |
|
1441 strcpy( smsg + index, connect_data->resource ); |
|
1442 index += len + 1; |
|
1443 //appending ssl |
|
1444 smsg[index++]= '1'; |
|
1445 smsg[index++]= '\0'; |
|
1446 //appending server port |
|
1447 len = strlen(connect_data->port ); |
|
1448 strcpy( smsg + index, connect_data->port ); |
|
1449 index += len + 1; |
|
1450 // appending IAP id |
|
1451 smsg[index++]= '1'; |
|
1452 smsg[index++]= '\0'; |
|
1453 //appending connmgr_bus |
|
1454 len = strlen(connect_data->connmgr_bus ); |
|
1455 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
1456 index += len + 1; |
|
1457 //appending connmgr_path |
|
1458 len = strlen(connect_data->connmgr_path ); |
|
1459 strcpy( smsg + index, connect_data->connmgr_path ); |
|
1460 index += len + 1; |
|
1461 //appending protocol |
|
1462 len = strlen(connect_data->protocol ); |
|
1463 strcpy( smsg + index, connect_data->protocol ); |
|
1464 index += len + 1; |
|
1465 #ifdef __WINSCW__ |
|
1466 //proxy server |
|
1467 len = strlen(connect_data->proxy_data->proxy_server ); |
|
1468 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
1469 index += len + 1; |
|
1470 //proxy port |
|
1471 len = strlen(connect_data->proxy_data->proxy_port ); |
|
1472 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
1473 index += len + 1; |
|
1474 #endif |
|
1475 //running isoserver |
|
1476 run_isoserver(); |
|
1477 //create message queue for send request |
|
1478 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1479 //create message queue for response request |
|
1480 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1481 /* Send Message to queueOne */ |
|
1482 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1483 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1484 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1485 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1486 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1487 if (status < 0) |
|
1488 { |
|
1489 return_value = KErrGeneral; |
|
1490 goto return_code; |
|
1491 } |
|
1492 if( msg_struct->response != 1) |
|
1493 { |
|
1494 return_value = KErrGeneral; |
|
1495 goto return_code; |
|
1496 } |
|
1497 // login end |
|
1498 //fetch req.. |
|
1499 for (int i= 0 ;i<3 ;i++) |
|
1500 { |
|
1501 |
|
1502 fp = fopen("c:\\fetch_contact.txt","a"); |
|
1503 do { |
|
1504 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1505 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1506 fwrite(rmsg,1,status,fp); |
|
1507 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1508 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
1509 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
1510 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
1511 fclose(fp); |
|
1512 |
|
1513 } |
|
1514 |
|
1515 //fetch end |
|
1516 |
|
1517 // logout test code from server |
|
1518 index=0; |
|
1519 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1520 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1521 |
|
1522 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1523 |
|
1524 msgHdr->message_type = ELogout_Request; |
|
1525 |
|
1526 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1527 index += sizeof( message_hdr_req ); |
|
1528 |
|
1529 |
|
1530 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1531 |
|
1532 do { |
|
1533 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
1534 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1535 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1536 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
1537 |
|
1538 if ( msg_struct->response != 1) |
|
1539 { |
|
1540 return_value = KErrGeneral; |
|
1541 goto return_code; |
|
1542 } |
|
1543 return_value = KErrNone; |
|
1544 goto return_code; |
|
1545 //killing isoserver |
|
1546 return_code: |
|
1547 index=0; |
|
1548 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1549 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1550 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1551 msgHdr->message_type = EKill_Process; |
|
1552 |
|
1553 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1554 index += sizeof( message_hdr_req ); |
|
1555 |
|
1556 |
|
1557 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1558 free( msg_struct ); |
|
1559 return return_value; |
|
1560 |
|
1561 } |
|
1562 // ----------------------------------------------------------------------------- |
|
1563 // Cisolationserver::Login with bad password |
|
1564 // Example test method function. |
|
1565 // (other items were commented in a header). |
|
1566 // ----------------------------------------------------------------------------- |
|
1567 // |
|
1568 TInt Cisolationserver::LoginWithWrongPassword( CStifItemParser& aItem ) |
|
1569 { |
|
1570 ConnectData *connect_data = NULL; |
|
1571 char smsg[MAX_MSG_SIZE]; |
|
1572 char rmsg[MAX_MSG_SIZE]; |
|
1573 int index=0; |
|
1574 int timeout = 100; |
|
1575 int nBytes; |
|
1576 int result = 0; |
|
1577 int err = 0; |
|
1578 int status = 0; |
|
1579 message_hdr_req *msgHdr = NULL; |
|
1580 message_hdr_resp* msg_struct = NULL; |
|
1581 TInt return_value = 0; |
|
1582 // Read data from the CFG file |
|
1583 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
1584 { |
|
1585 iLog->Log ( _L ( "read_data failed" ) ); |
|
1586 free_data ( connect_data ); |
|
1587 return_value = KErrGeneral; |
|
1588 goto return_code; |
|
1589 } |
|
1590 //request formation |
|
1591 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1592 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1593 |
|
1594 //message header use |
|
1595 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
1596 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1597 |
|
1598 msgHdr->message_type = ELogin_Request; |
|
1599 |
|
1600 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1601 index += sizeof( message_hdr_req ); |
|
1602 |
|
1603 int len = strlen(connect_data->username); |
|
1604 strcpy( smsg + index, connect_data->username ); |
|
1605 index += len + 1; |
|
1606 |
|
1607 //appending password |
|
1608 |
|
1609 len = strlen(connect_data->password ); |
|
1610 strcpy( smsg + index, connect_data->password ); |
|
1611 index += len + 1; |
|
1612 |
|
1613 //appending server name |
|
1614 |
|
1615 len = strlen(connect_data->server ); |
|
1616 strcpy( smsg + index, connect_data->server ); |
|
1617 index += len + 1; |
|
1618 |
|
1619 //appending resource |
|
1620 len = strlen(connect_data->resource ); |
|
1621 strcpy( smsg + index, connect_data->resource ); |
|
1622 index += len + 1; |
|
1623 |
|
1624 //appending ssl |
|
1625 smsg[index++]= '1'; |
|
1626 smsg[index++]= '\0'; |
|
1627 |
|
1628 //appending server port |
|
1629 len = strlen(connect_data->port ); |
|
1630 strcpy( smsg + index, connect_data->port ); |
|
1631 index += len + 1; |
|
1632 |
|
1633 // appending IAP id |
|
1634 |
|
1635 smsg[index++]= '1'; |
|
1636 smsg[index++]= '\0'; |
|
1637 |
|
1638 //appending connmgr_bus |
|
1639 len = strlen(connect_data->connmgr_bus ); |
|
1640 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
1641 index += len + 1; |
|
1642 |
|
1643 //appending connmgr_path |
|
1644 len = strlen(connect_data->connmgr_path ); |
|
1645 strcpy( smsg + index, connect_data->connmgr_path ); |
|
1646 index += len + 1; |
|
1647 |
|
1648 //appending protocol |
|
1649 len = strlen(connect_data->protocol ); |
|
1650 strcpy( smsg + index, connect_data->protocol ); |
|
1651 index += len + 1; |
|
1652 |
|
1653 #ifdef __WINSCW__ |
|
1654 //proxy server |
|
1655 len = strlen(connect_data->proxy_data->proxy_server ); |
|
1656 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
1657 index += len + 1; |
|
1658 |
|
1659 //proxy port |
|
1660 len = strlen(connect_data->proxy_data->proxy_port ); |
|
1661 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
1662 index += len + 1; |
|
1663 |
|
1664 #endif |
|
1665 //running isoserver |
|
1666 run_isoserver(); |
|
1667 //create message queue for send request |
|
1668 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1669 //create message queue for response request |
|
1670 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1671 /* Send Message to queueOne */ |
|
1672 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1673 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1674 if (status < 0) |
|
1675 { |
|
1676 return_value = KErrGeneral; |
|
1677 goto return_code; |
|
1678 } |
|
1679 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1680 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1681 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1682 if( msg_struct->response != 0) |
|
1683 { |
|
1684 return_value = KErrGeneral; |
|
1685 goto return_code; |
|
1686 } |
|
1687 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1688 if (status < 0) |
|
1689 { |
|
1690 return_value = KErrGeneral; |
|
1691 goto return_code; |
|
1692 } |
|
1693 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1694 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1695 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1696 if( msg_struct->response != 0) |
|
1697 { |
|
1698 return_value = KErrGeneral; |
|
1699 goto return_code; |
|
1700 } |
|
1701 goto return_code; |
|
1702 //killing isoserver |
|
1703 return_code: |
|
1704 index=0; |
|
1705 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1706 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1707 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1708 msgHdr->message_type = EKill_Process; |
|
1709 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1710 index += sizeof( message_hdr_req ); |
|
1711 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1712 free( msg_struct ); |
|
1713 return return_value; |
|
1714 } |
|
1715 |
|
1716 // ----------------------------------------------------------------------------- |
|
1717 // Cisolationserver::Login with unexist user id |
|
1718 // Example test method function. |
|
1719 // (other items were commented in a header). |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 // |
|
1722 TInt Cisolationserver::LoginWithUnexistUserId( CStifItemParser& aItem ) |
|
1723 { |
|
1724 |
|
1725 |
|
1726 ConnectData *connect_data = NULL; |
|
1727 char smsg[MAX_MSG_SIZE]; |
|
1728 char rmsg[MAX_MSG_SIZE]; |
|
1729 int index=0; |
|
1730 |
|
1731 |
|
1732 int timeout = 100; |
|
1733 int nBytes; |
|
1734 |
|
1735 int result = 0; |
|
1736 int err = 0; |
|
1737 int status = 0; |
|
1738 message_hdr_req *msgHdr = NULL; |
|
1739 message_hdr_resp* msg_struct = NULL; |
|
1740 TInt return_value = 0; |
|
1741 // Read data from the CFG file |
|
1742 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
1743 { |
|
1744 iLog->Log ( _L ( "read_data failed" ) ); |
|
1745 free_data ( connect_data ); |
|
1746 return_value = KErrGeneral; |
|
1747 goto return_code; |
|
1748 } |
|
1749 //request formation |
|
1750 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1751 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1752 |
|
1753 //message header use |
|
1754 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
1755 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1756 |
|
1757 msgHdr->message_type = ELogin_Request; |
|
1758 |
|
1759 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1760 index += sizeof( message_hdr_req ); |
|
1761 |
|
1762 int len = strlen(connect_data->username); |
|
1763 strcpy( smsg + index, connect_data->username ); |
|
1764 index += len + 1; |
|
1765 |
|
1766 //appending password |
|
1767 |
|
1768 len = strlen(connect_data->password ); |
|
1769 strcpy( smsg + index, connect_data->password ); |
|
1770 index += len + 1; |
|
1771 |
|
1772 //appending server name |
|
1773 |
|
1774 len = strlen(connect_data->server ); |
|
1775 strcpy( smsg + index, connect_data->server ); |
|
1776 index += len + 1; |
|
1777 |
|
1778 //appending resource |
|
1779 len = strlen(connect_data->resource ); |
|
1780 strcpy( smsg + index, connect_data->resource ); |
|
1781 index += len + 1; |
|
1782 |
|
1783 //appending ssl |
|
1784 smsg[index++]= '1'; |
|
1785 smsg[index++]= '\0'; |
|
1786 |
|
1787 //appending server port |
|
1788 len = strlen(connect_data->port ); |
|
1789 strcpy( smsg + index, connect_data->port ); |
|
1790 index += len + 1; |
|
1791 |
|
1792 // appending IAP id |
|
1793 |
|
1794 smsg[index++]= '1'; |
|
1795 smsg[index++]= '\0'; |
|
1796 |
|
1797 //appending connmgr_bus |
|
1798 len = strlen(connect_data->connmgr_bus ); |
|
1799 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
1800 index += len + 1; |
|
1801 |
|
1802 //appending connmgr_path |
|
1803 len = strlen(connect_data->connmgr_path ); |
|
1804 strcpy( smsg + index, connect_data->connmgr_path ); |
|
1805 index += len + 1; |
|
1806 |
|
1807 //appending protocol |
|
1808 len = strlen(connect_data->protocol ); |
|
1809 strcpy( smsg + index, connect_data->protocol ); |
|
1810 index += len + 1; |
|
1811 |
|
1812 #ifdef __WINSCW__ |
|
1813 //proxy server |
|
1814 len = strlen(connect_data->proxy_data->proxy_server ); |
|
1815 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
1816 index += len + 1; |
|
1817 |
|
1818 //proxy port |
|
1819 len = strlen(connect_data->proxy_data->proxy_port ); |
|
1820 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
1821 index += len + 1; |
|
1822 |
|
1823 #endif |
|
1824 //running isoserver |
|
1825 run_isoserver(); |
|
1826 //create message queue for send request |
|
1827 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1828 //create message queue for response request |
|
1829 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1830 |
|
1831 |
|
1832 /* Send Message to queueOne */ |
|
1833 |
|
1834 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1835 |
|
1836 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1837 |
|
1838 if (status < 0) |
|
1839 { |
|
1840 return_value = KErrGeneral; |
|
1841 } |
|
1842 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1843 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1844 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1845 if( msg_struct->response != 0 ) |
|
1846 { |
|
1847 return_value = KErrGeneral; |
|
1848 goto return_code; |
|
1849 } |
|
1850 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
1851 |
|
1852 if (status < 0) |
|
1853 { |
|
1854 return_value = KErrGeneral; |
|
1855 goto return_code; |
|
1856 } |
|
1857 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
1858 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
1859 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
1860 |
|
1861 if( msg_struct->response != 0) |
|
1862 { |
|
1863 return_value = KErrGeneral; |
|
1864 goto return_code; |
|
1865 } |
|
1866 |
|
1867 //killing isoserver |
|
1868 return_code: |
|
1869 index=0; |
|
1870 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1871 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1872 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1873 msgHdr->message_type = EKill_Process; |
|
1874 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1875 index += sizeof( message_hdr_req ); |
|
1876 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
1877 free( msg_struct ); |
|
1878 return return_value; |
|
1879 } |
|
1880 |
|
1881 |
|
1882 // ----------------------------------------------------------------------------- |
|
1883 // Cisolationserver::connect with unexist server |
|
1884 // Example test method function. |
|
1885 // (other items were commented in a header). |
|
1886 // ----------------------------------------------------------------------------- |
|
1887 // |
|
1888 TInt Cisolationserver::LoginWithUnexistServer( CStifItemParser& aItem ) |
|
1889 { |
|
1890 |
|
1891 /* |
|
1892 ConnectData *connect_data = NULL; |
|
1893 char smsg[MAX_MSG_SIZE]; |
|
1894 char rmsg[MAX_MSG_SIZE]; |
|
1895 int index=0; |
|
1896 |
|
1897 |
|
1898 int timeout = 100; |
|
1899 int nBytes; |
|
1900 |
|
1901 int result = 0; |
|
1902 int err = 0; |
|
1903 int status = 0; |
|
1904 message_hdr_req *msgHdr = NULL; |
|
1905 message_hdr_resp* msg_struct = NULL; |
|
1906 TInt return_value = 0; |
|
1907 // Read data from the CFG file |
|
1908 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
1909 { |
|
1910 iLog->Log ( _L ( "read_data failed" ) ); |
|
1911 free_data ( connect_data ); |
|
1912 return_value = KErrGeneral; |
|
1913 goto return_code; |
|
1914 } |
|
1915 //request formation |
|
1916 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
1917 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
1918 |
|
1919 //message header use |
|
1920 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
1921 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
1922 |
|
1923 msgHdr->message_type = ELogin_Request; |
|
1924 |
|
1925 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
1926 index += sizeof( message_hdr_req ); |
|
1927 |
|
1928 int len = strlen(connect_data->username); |
|
1929 strcpy( smsg + index, connect_data->username ); |
|
1930 index += len + 1; |
|
1931 |
|
1932 //appending password |
|
1933 |
|
1934 len = strlen(connect_data->password ); |
|
1935 strcpy( smsg + index, connect_data->password ); |
|
1936 index += len + 1; |
|
1937 |
|
1938 //appending server name |
|
1939 |
|
1940 len = strlen(connect_data->server ); |
|
1941 strcpy( smsg + index, connect_data->server ); |
|
1942 index += len + 1; |
|
1943 |
|
1944 //appending resource |
|
1945 len = strlen(connect_data->resource ); |
|
1946 strcpy( smsg + index, connect_data->resource ); |
|
1947 index += len + 1; |
|
1948 |
|
1949 //appending ssl |
|
1950 smsg[index++]= '1'; |
|
1951 smsg[index++]= '\0'; |
|
1952 |
|
1953 //appending server port |
|
1954 len = strlen(connect_data->port ); |
|
1955 strcpy( smsg + index, connect_data->port ); |
|
1956 index += len + 1; |
|
1957 |
|
1958 // appending IAP id |
|
1959 |
|
1960 smsg[index++]= '1'; |
|
1961 smsg[index++]= '\0'; |
|
1962 |
|
1963 //appending connmgr_bus |
|
1964 len = strlen(connect_data->connmgr_bus ); |
|
1965 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
1966 index += len + 1; |
|
1967 |
|
1968 //appending connmgr_path |
|
1969 len = strlen(connect_data->connmgr_path ); |
|
1970 strcpy( smsg + index, connect_data->connmgr_path ); |
|
1971 index += len + 1; |
|
1972 |
|
1973 //appending protocol |
|
1974 len = strlen(connect_data->protocol ); |
|
1975 strcpy( smsg + index, connect_data->protocol ); |
|
1976 index += len + 1; |
|
1977 |
|
1978 #ifdef __WINSCW__ |
|
1979 //proxy server |
|
1980 len = strlen(connect_data->proxy_data->proxy_server ); |
|
1981 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
1982 index += len + 1; |
|
1983 |
|
1984 //proxy port |
|
1985 len = strlen(connect_data->proxy_data->proxy_port ); |
|
1986 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
1987 index += len + 1; |
|
1988 |
|
1989 #endif |
|
1990 //running isoserver |
|
1991 run_isoserver(); |
|
1992 //create message queue for send request |
|
1993 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1994 //create message queue for response request |
|
1995 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
1996 |
|
1997 |
|
1998 //Send Message to queueOne |
|
1999 |
|
2000 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2001 |
|
2002 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2003 |
|
2004 if (status < 0) |
|
2005 { |
|
2006 return_value = KErrGeneral; |
|
2007 goto return_code; |
|
2008 } |
|
2009 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2010 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2011 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2012 |
|
2013 if( msg_struct->response != 0) |
|
2014 { |
|
2015 return_value = KErrGeneral; |
|
2016 goto return_code; |
|
2017 } |
|
2018 |
|
2019 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2020 |
|
2021 if (status < 0) |
|
2022 { |
|
2023 return_value = KErrGeneral; |
|
2024 goto return_code; |
|
2025 } |
|
2026 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2027 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2028 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2029 |
|
2030 if( msg_struct->response != 0) |
|
2031 { |
|
2032 return_value = KErrGeneral; |
|
2033 goto return_code; |
|
2034 } |
|
2035 // login end |
|
2036 //killing isoserver |
|
2037 return_code: |
|
2038 index=0; |
|
2039 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2040 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2041 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2042 msgHdr->message_type = EKill_Process; |
|
2043 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2044 index += sizeof( message_hdr_req ); |
|
2045 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2046 free( msg_struct ); |
|
2047 return return_value; |
|
2048 */ |
|
2049 //LM is not getting call back from server so we are just saying KerrGeneral |
|
2050 return KErrGeneral; |
|
2051 } |
|
2052 |
|
2053 |
|
2054 |
|
2055 // ----------------------------------------------------------------------------- |
|
2056 // Cisolationserver::Login with correct data |
|
2057 // Example test method function. |
|
2058 // (other items were commented in a header). |
|
2059 // ----------------------------------------------------------------------------- |
|
2060 // |
|
2061 TInt Cisolationserver::LoginWithBlankUserId( CStifItemParser& aItem ) |
|
2062 { |
|
2063 ConnectData *connect_data = NULL; |
|
2064 char smsg[MAX_MSG_SIZE]; |
|
2065 char rmsg[MAX_MSG_SIZE]; |
|
2066 int index=0; |
|
2067 int timeout = 100; |
|
2068 int nBytes; |
|
2069 int result = 0; |
|
2070 int err = 0; |
|
2071 int status = 0; |
|
2072 message_hdr_req *msgHdr = NULL; |
|
2073 message_hdr_resp* msg_struct = NULL; |
|
2074 TInt return_value = 0; |
|
2075 // Read data from the CFG file |
|
2076 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
2077 { |
|
2078 iLog->Log ( _L ( "read_data failed" ) ); |
|
2079 free_data ( connect_data ); |
|
2080 return_value = KErrGeneral; |
|
2081 goto return_code; |
|
2082 } |
|
2083 |
|
2084 //request formation |
|
2085 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2086 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2087 |
|
2088 //message header use |
|
2089 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
2090 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2091 |
|
2092 msgHdr->message_type = ELogin_Request; |
|
2093 |
|
2094 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2095 index += sizeof( message_hdr_req ); |
|
2096 // blank user id |
|
2097 smsg[index++]='\0'; |
|
2098 smsg[index++]='\0'; |
|
2099 |
|
2100 //appending password |
|
2101 |
|
2102 int len = strlen(connect_data->password ); |
|
2103 strcpy( smsg + index, connect_data->password ); |
|
2104 index += len + 1; |
|
2105 |
|
2106 //appending server name |
|
2107 |
|
2108 len = strlen(connect_data->server ); |
|
2109 strcpy( smsg + index, connect_data->server ); |
|
2110 index += len + 1; |
|
2111 |
|
2112 //appending resource |
|
2113 len = strlen(connect_data->resource ); |
|
2114 strcpy( smsg + index, connect_data->resource ); |
|
2115 index += len + 1; |
|
2116 |
|
2117 //appending ssl |
|
2118 smsg[index++]= '1'; |
|
2119 smsg[index++]= '\0'; |
|
2120 |
|
2121 //appending server port |
|
2122 len = strlen(connect_data->port ); |
|
2123 strcpy( smsg + index, connect_data->port ); |
|
2124 index += len + 1; |
|
2125 |
|
2126 // appending IAP id |
|
2127 |
|
2128 smsg[index++]= '1'; |
|
2129 smsg[index++]= '\0'; |
|
2130 |
|
2131 //appending connmgr_bus |
|
2132 len = strlen(connect_data->connmgr_bus ); |
|
2133 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
2134 index += len + 1; |
|
2135 |
|
2136 //appending connmgr_path |
|
2137 len = strlen(connect_data->connmgr_path ); |
|
2138 strcpy( smsg + index, connect_data->connmgr_path ); |
|
2139 index += len + 1; |
|
2140 |
|
2141 //appending protocol |
|
2142 len = strlen(connect_data->protocol ); |
|
2143 strcpy( smsg + index, connect_data->protocol ); |
|
2144 index += len + 1; |
|
2145 |
|
2146 #ifdef __WINSCW__ |
|
2147 //proxy server |
|
2148 len = strlen(connect_data->proxy_data->proxy_server ); |
|
2149 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
2150 index += len + 1; |
|
2151 |
|
2152 //proxy port |
|
2153 len = strlen(connect_data->proxy_data->proxy_port ); |
|
2154 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
2155 index += len + 1; |
|
2156 |
|
2157 #endif |
|
2158 //running isoserver |
|
2159 run_isoserver(); |
|
2160 //create message queue for send request |
|
2161 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2162 //create message queue for response request |
|
2163 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2164 |
|
2165 |
|
2166 /* Send Message to queueOne */ |
|
2167 |
|
2168 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2169 |
|
2170 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2171 |
|
2172 if (status < 0) |
|
2173 { |
|
2174 return_value = KErrGeneral; |
|
2175 goto return_code; |
|
2176 } |
|
2177 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2178 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2179 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2180 |
|
2181 if( msg_struct->error_type > 0) |
|
2182 { |
|
2183 return_value = KErrGeneral; |
|
2184 goto return_code; |
|
2185 } |
|
2186 goto return_code; |
|
2187 //killing isoserver |
|
2188 return_code: |
|
2189 index=0; |
|
2190 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2191 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2192 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2193 msgHdr->message_type = EKill_Process; |
|
2194 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2195 index += sizeof( message_hdr_req ); |
|
2196 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2197 free( msg_struct ); |
|
2198 return return_value; |
|
2199 } |
|
2200 |
|
2201 // ----------------------------------------------------------------------------- |
|
2202 // Cisolationserver::Logout from server |
|
2203 // Example test method function. |
|
2204 // (other items were commented in a header). |
|
2205 // ----------------------------------------------------------------------------- |
|
2206 // |
|
2207 TInt Cisolationserver::LoginLogOutWithReapitiveSession( CStifItemParser& aItem ) |
|
2208 { |
|
2209 |
|
2210 |
|
2211 ConnectData *connect_data = NULL; |
|
2212 char smsg[MAX_MSG_SIZE]; |
|
2213 char rmsg[MAX_MSG_SIZE]; |
|
2214 int index=0; |
|
2215 FILE *fp; |
|
2216 |
|
2217 int timeout = 100; |
|
2218 int nBytes; |
|
2219 |
|
2220 int result = 0; |
|
2221 int err = 0; |
|
2222 int status = 0; |
|
2223 message_hdr_req *msgHdr = NULL; |
|
2224 message_hdr_resp* msg_struct = NULL; |
|
2225 TInt return_value = 0; |
|
2226 // Read data from the CFG file |
|
2227 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
2228 { |
|
2229 iLog->Log ( _L ( "read_data failed" ) ); |
|
2230 free_data ( connect_data ); |
|
2231 return_value = KErrGeneral; |
|
2232 goto return_code; |
|
2233 } |
|
2234 //request formation |
|
2235 index=0; |
|
2236 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2237 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2238 |
|
2239 //message header use |
|
2240 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
2241 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2242 |
|
2243 msgHdr->message_type = ELogin_Request; |
|
2244 |
|
2245 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2246 index += sizeof( message_hdr_req ); |
|
2247 |
|
2248 int len = strlen(connect_data->username); |
|
2249 strcpy( smsg + index, connect_data->username ); |
|
2250 index += len + 1; |
|
2251 |
|
2252 //appending password |
|
2253 |
|
2254 len = strlen(connect_data->password ); |
|
2255 strcpy( smsg + index, connect_data->password ); |
|
2256 index += len + 1; |
|
2257 |
|
2258 //appending server name |
|
2259 |
|
2260 len = strlen(connect_data->server ); |
|
2261 strcpy( smsg + index, connect_data->server ); |
|
2262 index += len + 1; |
|
2263 |
|
2264 //appending resource |
|
2265 len = strlen(connect_data->resource ); |
|
2266 strcpy( smsg + index, connect_data->resource ); |
|
2267 index += len + 1; |
|
2268 |
|
2269 //appending ssl |
|
2270 smsg[index++]= '1'; |
|
2271 smsg[index++]= '\0'; |
|
2272 |
|
2273 //appending server port |
|
2274 len = strlen(connect_data->port ); |
|
2275 strcpy( smsg + index, connect_data->port ); |
|
2276 index += len + 1; |
|
2277 |
|
2278 // appending IAP id |
|
2279 |
|
2280 smsg[index++]= '1'; |
|
2281 smsg[index++]= '\0'; |
|
2282 |
|
2283 //appending connmgr_bus |
|
2284 len = strlen(connect_data->connmgr_bus ); |
|
2285 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
2286 index += len + 1; |
|
2287 |
|
2288 //appending connmgr_path |
|
2289 len = strlen(connect_data->connmgr_path ); |
|
2290 strcpy( smsg + index, connect_data->connmgr_path ); |
|
2291 index += len + 1; |
|
2292 |
|
2293 //appending protocol |
|
2294 len = strlen(connect_data->protocol ); |
|
2295 strcpy( smsg + index, connect_data->protocol ); |
|
2296 index += len + 1; |
|
2297 |
|
2298 #ifdef __WINSCW__ |
|
2299 //proxy server |
|
2300 len = strlen(connect_data->proxy_data->proxy_server ); |
|
2301 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
2302 index += len + 1; |
|
2303 |
|
2304 //proxy port |
|
2305 len = strlen(connect_data->proxy_data->proxy_port ); |
|
2306 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
2307 index += len + 1; |
|
2308 |
|
2309 #endif |
|
2310 //running isoserver |
|
2311 run_isoserver(); |
|
2312 |
|
2313 |
|
2314 |
|
2315 //create message queue for send request |
|
2316 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2317 //create message queue for response request |
|
2318 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2319 |
|
2320 |
|
2321 /* Send Message to queueOne */ |
|
2322 |
|
2323 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2324 |
|
2325 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2326 |
|
2327 if (status < 0) |
|
2328 { |
|
2329 return_value = KErrGeneral; |
|
2330 goto return_code; |
|
2331 } |
|
2332 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2333 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2334 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2335 |
|
2336 if( msg_struct->response != 1) |
|
2337 { |
|
2338 return_value = KErrGeneral; |
|
2339 goto return_code; |
|
2340 } |
|
2341 |
|
2342 |
|
2343 // login end |
|
2344 //fetch req.. |
|
2345 for (int i= 0 ;i<3 ;i++) |
|
2346 { |
|
2347 |
|
2348 fp = fopen("c:\\fetch_contact.txt","a"); |
|
2349 do { |
|
2350 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
2351 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2352 fwrite(rmsg,1,status,fp); |
|
2353 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2354 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
2355 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
2356 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
2357 fclose(fp); |
|
2358 |
|
2359 } |
|
2360 |
|
2361 //fetch end |
|
2362 // logout test code from server |
|
2363 index=0; |
|
2364 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2365 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2366 |
|
2367 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2368 |
|
2369 msgHdr->message_type = ELogout_Request; |
|
2370 |
|
2371 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2372 index += sizeof( message_hdr_req ); |
|
2373 |
|
2374 |
|
2375 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2376 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2377 |
|
2378 if (status < 0) |
|
2379 { |
|
2380 return_value = KErrGeneral; |
|
2381 goto return_code; |
|
2382 } |
|
2383 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2384 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2385 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2386 if ( msg_struct->response != 1) |
|
2387 { |
|
2388 return_value = KErrGeneral; |
|
2389 goto return_code; |
|
2390 } |
|
2391 //killing isolation server |
|
2392 index=0; |
|
2393 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2394 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2395 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2396 msgHdr->message_type = EKill_Process; |
|
2397 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2398 index += sizeof( message_hdr_req ); |
|
2399 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2400 //request formation |
|
2401 index=0; |
|
2402 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2403 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2404 |
|
2405 //message header use |
|
2406 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
2407 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2408 |
|
2409 msgHdr->message_type = ELogin_Request; |
|
2410 |
|
2411 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2412 index += sizeof( message_hdr_req ); |
|
2413 |
|
2414 len = strlen(connect_data->username); |
|
2415 strcpy( smsg + index, connect_data->username ); |
|
2416 index += len + 1; |
|
2417 |
|
2418 //appending password |
|
2419 |
|
2420 len = strlen(connect_data->password ); |
|
2421 strcpy( smsg + index, connect_data->password ); |
|
2422 index += len + 1; |
|
2423 |
|
2424 //appending server name |
|
2425 |
|
2426 len = strlen(connect_data->server ); |
|
2427 strcpy( smsg + index, connect_data->server ); |
|
2428 index += len + 1; |
|
2429 |
|
2430 //appending resource |
|
2431 len = strlen(connect_data->resource ); |
|
2432 strcpy( smsg + index, connect_data->resource ); |
|
2433 index += len + 1; |
|
2434 |
|
2435 //appending ssl |
|
2436 smsg[index++]= '1'; |
|
2437 smsg[index++]= '\0'; |
|
2438 |
|
2439 //appending server port |
|
2440 len = strlen(connect_data->port ); |
|
2441 strcpy( smsg + index, connect_data->port ); |
|
2442 index += len + 1; |
|
2443 |
|
2444 // appending IAP id |
|
2445 |
|
2446 smsg[index++]= '1'; |
|
2447 smsg[index++]= '\0'; |
|
2448 |
|
2449 //appending connmgr_bus |
|
2450 len = strlen(connect_data->connmgr_bus ); |
|
2451 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
2452 index += len + 1; |
|
2453 |
|
2454 //appending connmgr_path |
|
2455 len = strlen(connect_data->connmgr_path ); |
|
2456 strcpy( smsg + index, connect_data->connmgr_path ); |
|
2457 index += len + 1; |
|
2458 |
|
2459 //appending protocol |
|
2460 len = strlen(connect_data->protocol ); |
|
2461 strcpy( smsg + index, connect_data->protocol ); |
|
2462 index += len + 1; |
|
2463 |
|
2464 #ifdef __WINSCW__ |
|
2465 //proxy server |
|
2466 len = strlen(connect_data->proxy_data->proxy_server ); |
|
2467 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
2468 index += len + 1; |
|
2469 |
|
2470 //proxy port |
|
2471 len = strlen(connect_data->proxy_data->proxy_port ); |
|
2472 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
2473 index += len + 1; |
|
2474 |
|
2475 #endif |
|
2476 |
|
2477 //running isoserver |
|
2478 run_isoserver(); |
|
2479 |
|
2480 |
|
2481 //create message queue for send request |
|
2482 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2483 //create message queue for response request |
|
2484 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2485 |
|
2486 |
|
2487 /* Send Message to queueOne */ |
|
2488 |
|
2489 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2490 |
|
2491 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2492 |
|
2493 if (status < 0) |
|
2494 { |
|
2495 return_value = KErrGeneral; |
|
2496 goto return_code; |
|
2497 } |
|
2498 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2499 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2500 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2501 |
|
2502 if( msg_struct->response != 1) |
|
2503 { |
|
2504 return_value = KErrGeneral; |
|
2505 goto return_code; |
|
2506 } |
|
2507 |
|
2508 |
|
2509 // login end |
|
2510 //fetch req.. |
|
2511 for (int i= 0 ;i<3 ;i++) |
|
2512 { |
|
2513 |
|
2514 fp = fopen("c:\\fetch_contact.txt","a"); |
|
2515 do { |
|
2516 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
2517 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2518 fwrite(rmsg,1,status,fp); |
|
2519 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2520 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
2521 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
2522 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
2523 fclose(fp); |
|
2524 |
|
2525 } |
|
2526 |
|
2527 //fetch end |
|
2528 |
|
2529 // logout test code from server |
|
2530 index=0; |
|
2531 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2532 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2533 |
|
2534 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2535 |
|
2536 msgHdr->message_type = ELogout_Request; |
|
2537 |
|
2538 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2539 index += sizeof( message_hdr_req ); |
|
2540 |
|
2541 |
|
2542 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2543 |
|
2544 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2545 |
|
2546 if (status < 0) |
|
2547 { |
|
2548 return_value = KErrGeneral; |
|
2549 goto return_code; |
|
2550 } |
|
2551 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2552 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2553 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2554 if ( msg_struct->response != 1) |
|
2555 { |
|
2556 return_value = KErrGeneral; |
|
2557 goto return_code; |
|
2558 } |
|
2559 |
|
2560 |
|
2561 //killing isoserver |
|
2562 return_code: |
|
2563 index=0; |
|
2564 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2565 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2566 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2567 msgHdr->message_type = EKill_Process; |
|
2568 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2569 index += sizeof( message_hdr_req ); |
|
2570 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2571 free( msg_struct ); |
|
2572 return return_value; |
|
2573 } |
|
2574 |
|
2575 // ----------------------------------------------------------------------------- |
|
2576 // Cisolationserver::connect with invalid port |
|
2577 // Example test method function. |
|
2578 // (other items were commented in a header). |
|
2579 // ----------------------------------------------------------------------------- |
|
2580 // |
|
2581 TInt Cisolationserver::LoginWithInvalidPortAddress( CStifItemParser& aItem ) |
|
2582 { |
|
2583 |
|
2584 /* |
|
2585 ConnectData *connect_data = NULL; |
|
2586 char smsg[MAX_MSG_SIZE]; |
|
2587 char rmsg[MAX_MSG_SIZE]; |
|
2588 int index=0; |
|
2589 |
|
2590 |
|
2591 int timeout = 100; |
|
2592 int nBytes; |
|
2593 |
|
2594 int result = 0; |
|
2595 int err = 0; |
|
2596 int status = 0; |
|
2597 message_hdr_req *msgHdr = NULL; |
|
2598 message_hdr_resp* msg_struct = NULL; |
|
2599 TInt return_value = 0; |
|
2600 // Read data from the CFG file |
|
2601 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
2602 { |
|
2603 iLog->Log ( _L ( "read_data failed" ) ); |
|
2604 free_data ( connect_data ); |
|
2605 return_value = KErrGeneral; |
|
2606 goto return_code; |
|
2607 } |
|
2608 //request formation |
|
2609 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2610 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2611 |
|
2612 //message header use |
|
2613 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
2614 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2615 |
|
2616 msgHdr->message_type = ELogin_Request; |
|
2617 |
|
2618 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2619 index += sizeof( message_hdr_req ); |
|
2620 |
|
2621 int len = strlen(connect_data->username); |
|
2622 strcpy( smsg + index, connect_data->username ); |
|
2623 index += len + 1; |
|
2624 |
|
2625 //appending password |
|
2626 |
|
2627 len = strlen(connect_data->password ); |
|
2628 strcpy( smsg + index, connect_data->password ); |
|
2629 index += len + 1; |
|
2630 |
|
2631 //appending server name |
|
2632 |
|
2633 len = strlen(connect_data->server ); |
|
2634 strcpy( smsg + index, connect_data->server ); |
|
2635 index += len + 1; |
|
2636 |
|
2637 //appending resource |
|
2638 len = strlen(connect_data->resource ); |
|
2639 strcpy( smsg + index, connect_data->resource ); |
|
2640 index += len + 1; |
|
2641 |
|
2642 //appending ssl |
|
2643 smsg[index++]= '1'; |
|
2644 smsg[index++]= '\0'; |
|
2645 |
|
2646 //appending server port |
|
2647 |
|
2648 smsg[index++]='4'; |
|
2649 smsg[index++]='4'; |
|
2650 smsg[index++]='2'; |
|
2651 |
|
2652 smsg[index++]='\0'; |
|
2653 |
|
2654 // appending IAP id |
|
2655 |
|
2656 smsg[index++]= '1'; |
|
2657 smsg[index++]= '\0'; |
|
2658 |
|
2659 //appending connmgr_bus |
|
2660 len = strlen(connect_data->connmgr_bus ); |
|
2661 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
2662 index += len + 1; |
|
2663 |
|
2664 //appending connmgr_path |
|
2665 len = strlen(connect_data->connmgr_path ); |
|
2666 strcpy( smsg + index, connect_data->connmgr_path ); |
|
2667 index += len + 1; |
|
2668 |
|
2669 //appending protocol |
|
2670 len = strlen(connect_data->protocol ); |
|
2671 strcpy( smsg + index, connect_data->protocol ); |
|
2672 index += len + 1; |
|
2673 |
|
2674 #ifdef __WINSCW__ |
|
2675 //proxy server |
|
2676 len = strlen(connect_data->proxy_data->proxy_server ); |
|
2677 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
2678 index += len + 1; |
|
2679 |
|
2680 //proxy port |
|
2681 len = strlen(connect_data->proxy_data->proxy_port ); |
|
2682 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
2683 index += len + 1; |
|
2684 |
|
2685 #endif |
|
2686 //running isoserver |
|
2687 run_isoserver(); |
|
2688 //create message queue for send request |
|
2689 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2690 //create message queue for response request |
|
2691 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2692 |
|
2693 |
|
2694 // Send Message to queueOne |
|
2695 |
|
2696 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2697 |
|
2698 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2699 |
|
2700 if (status < 0) |
|
2701 { |
|
2702 return_value = KErrGeneral; |
|
2703 goto return_code; |
|
2704 } |
|
2705 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2706 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2707 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2708 |
|
2709 if( msg_struct->response == 1) |
|
2710 { |
|
2711 return_value = KErrGeneral; |
|
2712 goto return_code; |
|
2713 } |
|
2714 |
|
2715 //killing isoserver |
|
2716 return_code: |
|
2717 index=0; |
|
2718 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2719 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2720 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2721 msgHdr->message_type = EKill_Process; |
|
2722 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2723 index += sizeof( message_hdr_req ); |
|
2724 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2725 free( msg_struct ); |
|
2726 return return_value; |
|
2727 */ |
|
2728 //LM is not getting call back from server so we are just saying KerrGeneral |
|
2729 return KErrGeneral; |
|
2730 } |
|
2731 |
|
2732 |
|
2733 // ----------------------------------------------------------------------------- |
|
2734 // Cisolationserver::Login with correct data |
|
2735 // Example test method function. |
|
2736 // (other items were commented in a header). |
|
2737 // ----------------------------------------------------------------------------- |
|
2738 // |
|
2739 TInt Cisolationserver::LoginWithMissingSettings( CStifItemParser& aItem ) |
|
2740 { |
|
2741 |
|
2742 |
|
2743 ConnectData *connect_data = NULL; |
|
2744 char smsg[MAX_MSG_SIZE]; |
|
2745 char rmsg[MAX_MSG_SIZE]; |
|
2746 int index=0; |
|
2747 |
|
2748 |
|
2749 int timeout = 100; |
|
2750 int nBytes; |
|
2751 |
|
2752 int result = 0; |
|
2753 int err = 0; |
|
2754 int status = 0; |
|
2755 FILE *fp; |
|
2756 message_hdr_req *msgHdr = NULL; |
|
2757 message_hdr_resp* msg_struct = NULL; |
|
2758 TInt return_value = 0; |
|
2759 // Read data from the CFG file |
|
2760 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
2761 { |
|
2762 iLog->Log ( _L ( "read_data failed" ) ); |
|
2763 free_data ( connect_data ); |
|
2764 return_value = KErrGeneral; |
|
2765 goto return_code; |
|
2766 } |
|
2767 //request formation |
|
2768 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2769 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2770 |
|
2771 //message header use |
|
2772 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
2773 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2774 |
|
2775 msgHdr->message_type = ELogin_Request; |
|
2776 |
|
2777 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2778 index += sizeof( message_hdr_req ); |
|
2779 |
|
2780 int len = strlen(connect_data->username); |
|
2781 strcpy( smsg + index, connect_data->username ); |
|
2782 index += len + 1; |
|
2783 |
|
2784 //appending password |
|
2785 |
|
2786 len = strlen(connect_data->password ); |
|
2787 strcpy( smsg + index, connect_data->password ); |
|
2788 index += len + 1; |
|
2789 |
|
2790 //appending server name |
|
2791 |
|
2792 len = strlen(connect_data->server ); |
|
2793 strcpy( smsg + index, connect_data->server ); |
|
2794 index += len + 1; |
|
2795 |
|
2796 //appending resource |
|
2797 len = strlen(connect_data->resource ); |
|
2798 strcpy( smsg + index, connect_data->resource ); |
|
2799 index += len + 1; |
|
2800 |
|
2801 // ssl is missing here |
|
2802 |
|
2803 //appending server port |
|
2804 len = strlen(connect_data->port ); |
|
2805 strcpy( smsg + index, connect_data->port ); |
|
2806 index += len + 1; |
|
2807 |
|
2808 // appending IAP id |
|
2809 |
|
2810 smsg[index++]= '1'; |
|
2811 smsg[index++]= '\0'; |
|
2812 |
|
2813 //appending connmgr_bus |
|
2814 len = strlen(connect_data->connmgr_bus ); |
|
2815 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
2816 index += len + 1; |
|
2817 |
|
2818 //appending connmgr_path |
|
2819 len = strlen(connect_data->connmgr_path ); |
|
2820 strcpy( smsg + index, connect_data->connmgr_path ); |
|
2821 index += len + 1; |
|
2822 |
|
2823 //appending protocol |
|
2824 len = strlen(connect_data->protocol ); |
|
2825 strcpy( smsg + index, connect_data->protocol ); |
|
2826 index += len + 1; |
|
2827 |
|
2828 #ifdef __WINSCW__ |
|
2829 //proxy server |
|
2830 len = strlen(connect_data->proxy_data->proxy_server ); |
|
2831 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
2832 index += len + 1; |
|
2833 |
|
2834 //proxy port |
|
2835 len = strlen(connect_data->proxy_data->proxy_port ); |
|
2836 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
2837 index += len + 1; |
|
2838 |
|
2839 #endif |
|
2840 //running isoserver |
|
2841 run_isoserver(); |
|
2842 //create message queue for send request |
|
2843 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2844 //create message queue for response request |
|
2845 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2846 |
|
2847 |
|
2848 /* Send Message to queueOne */ |
|
2849 |
|
2850 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2851 |
|
2852 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
2853 |
|
2854 if (status < 0) |
|
2855 { |
|
2856 return_value = KErrGeneral; |
|
2857 goto return_code; |
|
2858 } |
|
2859 |
|
2860 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
2861 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
2862 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
2863 |
|
2864 if( msg_struct->response != 0) |
|
2865 { |
|
2866 return_value = KErrGeneral; |
|
2867 goto return_code; |
|
2868 } |
|
2869 //killing isoserver |
|
2870 return_code: |
|
2871 index=0; |
|
2872 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2873 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2874 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2875 msgHdr->message_type = EKill_Process; |
|
2876 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2877 index += sizeof( message_hdr_req ); |
|
2878 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
2879 free( msg_struct ); |
|
2880 return return_value; |
|
2881 } |
|
2882 |
|
2883 // ----------------------------------------------------------------------------- |
|
2884 // Cisolationserver::LoginWhenTGAndDDAreNotRunning |
|
2885 // Example test method function. |
|
2886 // (other items were commented in a header). |
|
2887 // ----------------------------------------------------------------------------- |
|
2888 // |
|
2889 TInt Cisolationserver::LoginWhenTGAndDDAreNotRunning( CStifItemParser& aItem ) |
|
2890 { |
|
2891 /* |
|
2892 |
|
2893 ConnectData *connect_data = NULL; |
|
2894 char smsg[MAX_MSG_SIZE]; |
|
2895 char rmsg[MAX_MSG_SIZE]; |
|
2896 int index=0; |
|
2897 |
|
2898 |
|
2899 int timeout = 100; |
|
2900 int nBytes; |
|
2901 |
|
2902 int result = 0; |
|
2903 int err = 0; |
|
2904 int status = 0; |
|
2905 FILE *fp; |
|
2906 message_hdr_req *msgHdr = NULL; |
|
2907 message_hdr_resp* msg_struct = NULL; |
|
2908 TInt return_value = 0; |
|
2909 // Read data from the CFG file |
|
2910 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
2911 { |
|
2912 iLog->Log ( _L ( "read_data failed" ) ); |
|
2913 free_data ( connect_data ); |
|
2914 return_value = KErrGeneral; |
|
2915 goto return_code; |
|
2916 } |
|
2917 //request formation |
|
2918 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
2919 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
2920 |
|
2921 //message header use |
|
2922 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
2923 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
2924 |
|
2925 msgHdr->message_type = ELogin_Request; |
|
2926 |
|
2927 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
2928 index += sizeof( message_hdr_req ); |
|
2929 |
|
2930 int len = strlen(connect_data->username); |
|
2931 strcpy( smsg + index, connect_data->username ); |
|
2932 index += len + 1; |
|
2933 |
|
2934 //appending password |
|
2935 |
|
2936 len = strlen(connect_data->password ); |
|
2937 strcpy( smsg + index, connect_data->password ); |
|
2938 index += len + 1; |
|
2939 |
|
2940 //appending server name |
|
2941 |
|
2942 len = strlen(connect_data->server ); |
|
2943 strcpy( smsg + index, connect_data->server ); |
|
2944 index += len + 1; |
|
2945 |
|
2946 //appending resource |
|
2947 len = strlen(connect_data->resource ); |
|
2948 strcpy( smsg + index, connect_data->resource ); |
|
2949 index += len + 1; |
|
2950 |
|
2951 //appending ssl |
|
2952 smsg[index++]= '1'; |
|
2953 smsg[index++]= '\0'; |
|
2954 |
|
2955 //appending server port |
|
2956 len = strlen(connect_data->port ); |
|
2957 strcpy( smsg + index, connect_data->port ); |
|
2958 index += len + 1; |
|
2959 |
|
2960 // appending IAP id |
|
2961 |
|
2962 smsg[index++]= '1'; |
|
2963 smsg[index++]= '\0'; |
|
2964 |
|
2965 //appending connmgr_bus |
|
2966 len = strlen(connect_data->connmgr_bus ); |
|
2967 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
2968 index += len + 1; |
|
2969 |
|
2970 //appending connmgr_path |
|
2971 len = strlen(connect_data->connmgr_path ); |
|
2972 strcpy( smsg + index, connect_data->connmgr_path ); |
|
2973 index += len + 1; |
|
2974 |
|
2975 //appending protocol |
|
2976 len = strlen(connect_data->protocol ); |
|
2977 strcpy( smsg + index, connect_data->protocol ); |
|
2978 index += len + 1; |
|
2979 |
|
2980 #ifdef __WINSCW__ |
|
2981 //proxy server |
|
2982 len = strlen(connect_data->proxy_data->proxy_server ); |
|
2983 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
2984 index += len + 1; |
|
2985 |
|
2986 //proxy port |
|
2987 len = strlen(connect_data->proxy_data->proxy_port ); |
|
2988 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
2989 index += len + 1; |
|
2990 |
|
2991 #endif |
|
2992 //running isoserver |
|
2993 run_isoserver(); |
|
2994 //create message queue for send request |
|
2995 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2996 //create message queue for response request |
|
2997 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
2998 |
|
2999 |
|
3000 // Send Message to queueOne |
|
3001 |
|
3002 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3003 |
|
3004 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
3005 |
|
3006 if (status < 0) |
|
3007 { |
|
3008 return_value = KErrGeneral; |
|
3009 goto return_code; |
|
3010 } |
|
3011 |
|
3012 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
3013 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
3014 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3015 |
|
3016 if( msg_struct->response != 0) |
|
3017 { |
|
3018 return_value = KErrGeneral; |
|
3019 goto return_code; |
|
3020 } |
|
3021 //killing isoserver |
|
3022 return_code: |
|
3023 index=0; |
|
3024 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3025 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3026 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3027 msgHdr->message_type = EKill_Process; |
|
3028 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3029 index += sizeof( message_hdr_req ); |
|
3030 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3031 free( msg_struct ); |
|
3032 return return_value; */ |
|
3033 return KErrNone; |
|
3034 } |
|
3035 |
|
3036 |
|
3037 // ----------------------------------------------------------------------------- |
|
3038 // Cisolationserver::Login with correct data |
|
3039 // Example test method function. |
|
3040 // (other items were commented in a header). |
|
3041 // ----------------------------------------------------------------------------- |
|
3042 // |
|
3043 TInt Cisolationserver::LoginWithCoreectUserIDWithSpace( CStifItemParser& aItem ) |
|
3044 { |
|
3045 ConnectData *connect_data = NULL; |
|
3046 char smsg[MAX_MSG_SIZE]; |
|
3047 char rmsg[MAX_MSG_SIZE]; |
|
3048 int index=0; |
|
3049 int timeout = 100; |
|
3050 int nBytes; |
|
3051 int result = 0; |
|
3052 int err = 0; |
|
3053 int status = 0; |
|
3054 message_hdr_req *msgHdr = NULL; |
|
3055 message_hdr_resp* msg_struct = NULL; |
|
3056 TInt return_value = 0; |
|
3057 // Read data from the CFG file |
|
3058 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
3059 { |
|
3060 iLog->Log ( _L ( "read_data failed" ) ); |
|
3061 free_data ( connect_data ); |
|
3062 return_value = KErrGeneral; |
|
3063 goto return_code; |
|
3064 } |
|
3065 //request formation |
|
3066 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3067 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3068 //message header use |
|
3069 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
3070 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3071 msgHdr->message_type = ELogin_Request; |
|
3072 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3073 index += sizeof( message_hdr_req ); |
|
3074 int len = strlen(connect_data->username); |
|
3075 strcpy( smsg + index, connect_data->username ); |
|
3076 index += len + 1; |
|
3077 smsg[index++]='\0'; |
|
3078 //appending password |
|
3079 len = strlen(connect_data->password ); |
|
3080 strcpy( smsg + index, connect_data->password ); |
|
3081 index += len + 1; |
|
3082 //appending server name |
|
3083 |
|
3084 len = strlen(connect_data->server ); |
|
3085 strcpy( smsg + index, connect_data->server ); |
|
3086 index += len + 1; |
|
3087 |
|
3088 //appending resource |
|
3089 len = strlen(connect_data->resource ); |
|
3090 strcpy( smsg + index, connect_data->resource ); |
|
3091 index += len + 1; |
|
3092 |
|
3093 //appending ssl |
|
3094 smsg[index++]= '1'; |
|
3095 smsg[index++]= '\0'; |
|
3096 |
|
3097 //appending server port |
|
3098 len = strlen(connect_data->port ); |
|
3099 strcpy( smsg + index, connect_data->port ); |
|
3100 index += len + 1; |
|
3101 |
|
3102 // appending IAP id |
|
3103 |
|
3104 smsg[index++]= '1'; |
|
3105 smsg[index++]= '\0'; |
|
3106 |
|
3107 //appending connmgr_bus |
|
3108 len = strlen(connect_data->connmgr_bus ); |
|
3109 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
3110 index += len + 1; |
|
3111 |
|
3112 //appending connmgr_path |
|
3113 len = strlen(connect_data->connmgr_path ); |
|
3114 strcpy( smsg + index, connect_data->connmgr_path ); |
|
3115 index += len + 1; |
|
3116 |
|
3117 //appending protocol |
|
3118 len = strlen(connect_data->protocol ); |
|
3119 strcpy( smsg + index, connect_data->protocol ); |
|
3120 index += len + 1; |
|
3121 |
|
3122 #ifdef __WINSCW__ |
|
3123 //proxy server |
|
3124 len = strlen(connect_data->proxy_data->proxy_server ); |
|
3125 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
3126 index += len + 1; |
|
3127 |
|
3128 //proxy port |
|
3129 len = strlen(connect_data->proxy_data->proxy_port ); |
|
3130 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
3131 index += len + 1; |
|
3132 |
|
3133 #endif |
|
3134 //running isoserver |
|
3135 run_isoserver(); |
|
3136 //create message queue for send request |
|
3137 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3138 //create message queue for response request |
|
3139 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3140 |
|
3141 |
|
3142 /* Send Message to queueOne */ |
|
3143 |
|
3144 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3145 |
|
3146 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
3147 |
|
3148 if (status < 0) |
|
3149 { |
|
3150 return_value = KErrGeneral; |
|
3151 goto return_code; |
|
3152 } |
|
3153 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
3154 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
3155 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3156 |
|
3157 if( msg_struct->error_type >0) |
|
3158 { |
|
3159 return_value = KErrGeneral; |
|
3160 goto return_code; |
|
3161 } |
|
3162 return_value = KErrNone; |
|
3163 //killing isoserver |
|
3164 return_code: |
|
3165 index=0; |
|
3166 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3167 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3168 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3169 msgHdr->message_type = EKill_Process; |
|
3170 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3171 index += sizeof( message_hdr_req ); |
|
3172 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3173 free( msg_struct ); |
|
3174 return return_value; |
|
3175 } |
|
3176 |
|
3177 // ----------------------------------------------------------------------------- |
|
3178 // Cisolationserver::Send message |
|
3179 // Example test method function. |
|
3180 // (other items were commented in a header). |
|
3181 // ----------------------------------------------------------------------------- |
|
3182 // |
|
3183 TInt Cisolationserver::SendMessageToCorrectUserID( CStifItemParser& aItem ) |
|
3184 { |
|
3185 |
|
3186 |
|
3187 ConnectData *connect_data = NULL; |
|
3188 char smsg[MAX_MSG_SIZE]; |
|
3189 char rmsg[MAX_MSG_SIZE]; |
|
3190 int index=0; |
|
3191 FILE *fp; |
|
3192 |
|
3193 int timeout = 200; |
|
3194 int nBytes; |
|
3195 |
|
3196 int result = 0; |
|
3197 int err = 0; |
|
3198 int status = 0; |
|
3199 message_hdr_req *msgHdr = NULL; |
|
3200 message_hdr_resp* msg_struct = NULL; |
|
3201 TInt return_value = 0; |
|
3202 // Read data from the CFG file |
|
3203 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
3204 { |
|
3205 iLog->Log ( _L ( "read_data failed" ) ); |
|
3206 free_data ( connect_data ); |
|
3207 return_value = KErrGeneral; |
|
3208 goto return_code; |
|
3209 } |
|
3210 //request formation |
|
3211 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3212 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3213 |
|
3214 //message header use |
|
3215 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
3216 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3217 |
|
3218 msgHdr->message_type = ELogin_Request; |
|
3219 |
|
3220 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3221 index += sizeof( message_hdr_req ); |
|
3222 |
|
3223 int len = strlen(connect_data->username); |
|
3224 strcpy( smsg + index, connect_data->username ); |
|
3225 index += len + 1; |
|
3226 |
|
3227 //appending password |
|
3228 |
|
3229 len = strlen(connect_data->password ); |
|
3230 strcpy( smsg + index, connect_data->password ); |
|
3231 index += len + 1; |
|
3232 |
|
3233 //appending server name |
|
3234 |
|
3235 len = strlen(connect_data->server ); |
|
3236 strcpy( smsg + index, connect_data->server ); |
|
3237 index += len + 1; |
|
3238 |
|
3239 //appending resource |
|
3240 len = strlen(connect_data->resource ); |
|
3241 strcpy( smsg + index, connect_data->resource ); |
|
3242 index += len + 1; |
|
3243 |
|
3244 //appending ssl |
|
3245 smsg[index++]= '1'; |
|
3246 smsg[index++]= '\0'; |
|
3247 |
|
3248 //appending server port |
|
3249 len = strlen(connect_data->port ); |
|
3250 strcpy( smsg + index, connect_data->port ); |
|
3251 index += len + 1; |
|
3252 |
|
3253 // appending IAP id |
|
3254 |
|
3255 smsg[index++]= '1'; |
|
3256 smsg[index++]= '\0'; |
|
3257 |
|
3258 //appending connmgr_bus |
|
3259 len = strlen(connect_data->connmgr_bus ); |
|
3260 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
3261 index += len + 1; |
|
3262 |
|
3263 //appending connmgr_path |
|
3264 len = strlen(connect_data->connmgr_path ); |
|
3265 strcpy( smsg + index, connect_data->connmgr_path ); |
|
3266 index += len + 1; |
|
3267 |
|
3268 //appending protocol |
|
3269 len = strlen(connect_data->protocol ); |
|
3270 strcpy( smsg + index, connect_data->protocol ); |
|
3271 index += len + 1; |
|
3272 |
|
3273 #ifdef __WINSCW__ |
|
3274 //proxy server |
|
3275 len = strlen(connect_data->proxy_data->proxy_server ); |
|
3276 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
3277 index += len + 1; |
|
3278 |
|
3279 //proxy port |
|
3280 len = strlen(connect_data->proxy_data->proxy_port ); |
|
3281 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
3282 index += len + 1; |
|
3283 |
|
3284 #endif |
|
3285 //running isoserver |
|
3286 run_isoserver(); |
|
3287 //create message queue for send request |
|
3288 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3289 //create message queue for response request |
|
3290 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3291 |
|
3292 |
|
3293 /* Send Message to queueOne */ |
|
3294 |
|
3295 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3296 |
|
3297 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
3298 |
|
3299 if (status < 0) |
|
3300 { |
|
3301 return_value = KErrGeneral; |
|
3302 goto return_code; |
|
3303 } |
|
3304 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
3305 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
3306 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3307 |
|
3308 if( msg_struct->response != 1) |
|
3309 { |
|
3310 return_value = KErrGeneral; |
|
3311 goto return_code; |
|
3312 } |
|
3313 |
|
3314 |
|
3315 // login end |
|
3316 //fetch req.. |
|
3317 for (int i= 0 ;i<3 ;i++) |
|
3318 { |
|
3319 |
|
3320 fp = fopen("c:\\fetch_contact.txt","a"); |
|
3321 do { |
|
3322 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3323 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3324 fwrite(rmsg,1,status,fp); |
|
3325 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3326 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
3327 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
3328 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
3329 fclose(fp); |
|
3330 |
|
3331 } |
|
3332 |
|
3333 //fetch end |
|
3334 |
|
3335 //send messge-------------------------------------------- |
|
3336 |
|
3337 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3338 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3339 index=0; |
|
3340 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3341 msgHdr->message_type = ESend_Request; |
|
3342 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3343 index += sizeof( message_hdr_req ); |
|
3344 |
|
3345 |
|
3346 // adding recipient |
|
3347 len = strlen(connect_data->msg_data->recipient ); |
|
3348 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
3349 index += len + 1; |
|
3350 |
|
3351 // adding recipient |
|
3352 /*len = strlen(connect_data->msg_data->recipient ); |
|
3353 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
3354 index += len + 1;*/ |
|
3355 |
|
3356 smsg[index++] = '\0'; |
|
3357 |
|
3358 // adding message part |
|
3359 |
|
3360 len = strlen(connect_data->msg_data->message ); |
|
3361 strcpy( smsg + index, connect_data->msg_data->message ); |
|
3362 index += len + 1; |
|
3363 |
|
3364 |
|
3365 |
|
3366 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3367 do { |
|
3368 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3369 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3370 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3371 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
3372 |
|
3373 if ( msg_struct->response != 1) |
|
3374 { |
|
3375 return_value = KErrGeneral; |
|
3376 goto return_code; |
|
3377 } |
|
3378 |
|
3379 |
|
3380 |
|
3381 //send message end--------------------------------------- |
|
3382 |
|
3383 |
|
3384 // logout test code from server |
|
3385 index=0; |
|
3386 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3387 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3388 |
|
3389 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3390 |
|
3391 msgHdr->message_type = ELogout_Request; |
|
3392 |
|
3393 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3394 index += sizeof( message_hdr_req ); |
|
3395 |
|
3396 |
|
3397 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3398 do { |
|
3399 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3400 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3401 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3402 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
3403 |
|
3404 if ( msg_struct->response != 1) |
|
3405 { |
|
3406 return_value = KErrGeneral; |
|
3407 goto return_code; |
|
3408 } |
|
3409 //killing isoserver |
|
3410 return_code: |
|
3411 index=0; |
|
3412 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3413 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3414 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3415 msgHdr->message_type = EKill_Process; |
|
3416 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3417 index += sizeof( message_hdr_req ); |
|
3418 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3419 free( msg_struct ); |
|
3420 return return_value; |
|
3421 } |
|
3422 |
|
3423 // ----------------------------------------------------------------------------- |
|
3424 // Cisolationserver::Send message with max len |
|
3425 // Example test method function. |
|
3426 // (other items were commented in a header). |
|
3427 // ----------------------------------------------------------------------------- |
|
3428 // |
|
3429 TInt Cisolationserver::SendMaxLenMessageToCorrectUserID( CStifItemParser& aItem ) |
|
3430 { |
|
3431 |
|
3432 |
|
3433 ConnectData *connect_data = NULL; |
|
3434 char smsg[MAX_MSG_SIZE]; |
|
3435 char rmsg[MAX_MSG_SIZE]; |
|
3436 int index=0; |
|
3437 FILE *fp; |
|
3438 |
|
3439 int timeout = 200; |
|
3440 int nBytes; |
|
3441 |
|
3442 int result = 0; |
|
3443 int err = 0; |
|
3444 int status = 0; |
|
3445 message_hdr_req *msgHdr = NULL; |
|
3446 message_hdr_resp* msg_struct = NULL; |
|
3447 TInt return_value = 0; |
|
3448 // Read data from the CFG file |
|
3449 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
3450 { |
|
3451 iLog->Log ( _L ( "read_data failed" ) ); |
|
3452 free_data ( connect_data ); |
|
3453 return_value = KErrGeneral; |
|
3454 goto return_code; |
|
3455 } |
|
3456 //request formation |
|
3457 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3458 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3459 |
|
3460 //message header use |
|
3461 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
3462 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3463 |
|
3464 msgHdr->message_type = ELogin_Request; |
|
3465 |
|
3466 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3467 index += sizeof( message_hdr_req ); |
|
3468 |
|
3469 int len = strlen(connect_data->username); |
|
3470 strcpy( smsg + index, connect_data->username ); |
|
3471 index += len + 1; |
|
3472 |
|
3473 //appending password |
|
3474 |
|
3475 len = strlen(connect_data->password ); |
|
3476 strcpy( smsg + index, connect_data->password ); |
|
3477 index += len + 1; |
|
3478 |
|
3479 //appending server name |
|
3480 |
|
3481 len = strlen(connect_data->server ); |
|
3482 strcpy( smsg + index, connect_data->server ); |
|
3483 index += len + 1; |
|
3484 |
|
3485 //appending resource |
|
3486 len = strlen(connect_data->resource ); |
|
3487 strcpy( smsg + index, connect_data->resource ); |
|
3488 index += len + 1; |
|
3489 |
|
3490 //appending ssl |
|
3491 smsg[index++]= '1'; |
|
3492 smsg[index++]= '\0'; |
|
3493 |
|
3494 //appending server port |
|
3495 len = strlen(connect_data->port ); |
|
3496 strcpy( smsg + index, connect_data->port ); |
|
3497 index += len + 1; |
|
3498 |
|
3499 // appending IAP id |
|
3500 |
|
3501 smsg[index++]= '1'; |
|
3502 smsg[index++]= '\0'; |
|
3503 |
|
3504 //appending connmgr_bus |
|
3505 len = strlen(connect_data->connmgr_bus ); |
|
3506 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
3507 index += len + 1; |
|
3508 |
|
3509 //appending connmgr_path |
|
3510 len = strlen(connect_data->connmgr_path ); |
|
3511 strcpy( smsg + index, connect_data->connmgr_path ); |
|
3512 index += len + 1; |
|
3513 |
|
3514 //appending protocol |
|
3515 len = strlen(connect_data->protocol ); |
|
3516 strcpy( smsg + index, connect_data->protocol ); |
|
3517 index += len + 1; |
|
3518 |
|
3519 #ifdef __WINSCW__ |
|
3520 //proxy server |
|
3521 len = strlen(connect_data->proxy_data->proxy_server ); |
|
3522 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
3523 index += len + 1; |
|
3524 |
|
3525 //proxy port |
|
3526 len = strlen(connect_data->proxy_data->proxy_port ); |
|
3527 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
3528 index += len + 1; |
|
3529 |
|
3530 #endif |
|
3531 |
|
3532 run_isoserver(); |
|
3533 |
|
3534 |
|
3535 //create message queue for send request |
|
3536 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3537 //create message queue for response request |
|
3538 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3539 |
|
3540 |
|
3541 /* Send Message to queueOne */ |
|
3542 |
|
3543 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3544 |
|
3545 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
3546 |
|
3547 if (status < 0) |
|
3548 { |
|
3549 return_value = KErrGeneral; |
|
3550 goto return_code; |
|
3551 } |
|
3552 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
3553 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
3554 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3555 |
|
3556 if( msg_struct->response != 1) |
|
3557 { |
|
3558 return_value = KErrGeneral; |
|
3559 goto return_code; |
|
3560 } |
|
3561 |
|
3562 |
|
3563 // login end |
|
3564 //fetch req.. |
|
3565 for (int i= 0 ;i<3 ;i++) |
|
3566 { |
|
3567 |
|
3568 fp = fopen("c:\\fetch_contact.txt","a"); |
|
3569 do { |
|
3570 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3571 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3572 fwrite(rmsg,1,status,fp); |
|
3573 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3574 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
3575 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
3576 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
3577 fclose(fp); |
|
3578 |
|
3579 } |
|
3580 |
|
3581 //fetch end |
|
3582 |
|
3583 //send messge-------------------------------------------- |
|
3584 |
|
3585 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3586 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3587 index=0; |
|
3588 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3589 msgHdr->message_type = ESend_Request; |
|
3590 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3591 index += sizeof( message_hdr_req ); |
|
3592 |
|
3593 |
|
3594 // adding recipient |
|
3595 len = strlen(connect_data->msg_data->recipient ); |
|
3596 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
3597 index += len + 1; |
|
3598 |
|
3599 // adding recipient |
|
3600 /*len = strlen(connect_data->msg_data->recipient ); |
|
3601 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
3602 index += len + 1;*/ |
|
3603 |
|
3604 smsg[index++] = '\0'; |
|
3605 |
|
3606 // adding message part |
|
3607 |
|
3608 len = strlen(connect_data->msg_data->message ); |
|
3609 strcpy( smsg + index, connect_data->msg_data->message ); |
|
3610 index += len + 1; |
|
3611 |
|
3612 |
|
3613 |
|
3614 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3615 do { |
|
3616 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3617 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3618 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3619 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
3620 |
|
3621 if ( msg_struct->response != 1) |
|
3622 { |
|
3623 return_value = KErrGeneral; |
|
3624 goto return_code; |
|
3625 } |
|
3626 |
|
3627 |
|
3628 //send message end--------------------------------------- |
|
3629 |
|
3630 |
|
3631 // logout test code from server |
|
3632 index=0; |
|
3633 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3634 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3635 |
|
3636 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3637 |
|
3638 msgHdr->message_type = ELogout_Request; |
|
3639 |
|
3640 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3641 index += sizeof( message_hdr_req ); |
|
3642 |
|
3643 |
|
3644 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3645 do { |
|
3646 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3647 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3648 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3649 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
3650 |
|
3651 if ( msg_struct->response != 1) |
|
3652 { |
|
3653 return_value = KErrGeneral; |
|
3654 goto return_code; |
|
3655 } |
|
3656 |
|
3657 //killing isoserver |
|
3658 return_code: |
|
3659 index=0; |
|
3660 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3661 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3662 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3663 msgHdr->message_type = EKill_Process; |
|
3664 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3665 index += sizeof( message_hdr_req ); |
|
3666 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3667 free( msg_struct ); |
|
3668 return return_value; |
|
3669 } |
|
3670 |
|
3671 // ----------------------------------------------------------------------------- |
|
3672 // Cisolationserver::Send message to unexist user id |
|
3673 // Example test method function. |
|
3674 // (other items were commented in a header). |
|
3675 // ----------------------------------------------------------------------------- |
|
3676 // |
|
3677 TInt Cisolationserver::SendTextMessageUnExistUserID( CStifItemParser& aItem ) |
|
3678 { |
|
3679 |
|
3680 |
|
3681 ConnectData *connect_data = NULL; |
|
3682 char smsg[MAX_MSG_SIZE]; |
|
3683 char rmsg[MAX_MSG_SIZE]; |
|
3684 int index=0; |
|
3685 FILE *fp; |
|
3686 |
|
3687 int timeout = 200; |
|
3688 int nBytes; |
|
3689 |
|
3690 int result = 0; |
|
3691 int err = 0; |
|
3692 int status = 0; |
|
3693 message_hdr_req *msgHdr = NULL; |
|
3694 message_hdr_resp* msg_struct = NULL; |
|
3695 TInt return_value = 0; |
|
3696 // Read data from the CFG file |
|
3697 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
3698 { |
|
3699 iLog->Log ( _L ( "read_data failed" ) ); |
|
3700 free_data ( connect_data ); |
|
3701 return_value = KErrGeneral; |
|
3702 goto return_code; |
|
3703 } |
|
3704 //request formation |
|
3705 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3706 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3707 |
|
3708 //message header use |
|
3709 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
3710 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3711 |
|
3712 msgHdr->message_type = ELogin_Request; |
|
3713 |
|
3714 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3715 index += sizeof( message_hdr_req ); |
|
3716 |
|
3717 int len = strlen(connect_data->username); |
|
3718 strcpy( smsg + index, connect_data->username ); |
|
3719 index += len + 1; |
|
3720 |
|
3721 //appending password |
|
3722 |
|
3723 len = strlen(connect_data->password ); |
|
3724 strcpy( smsg + index, connect_data->password ); |
|
3725 index += len + 1; |
|
3726 |
|
3727 //appending server name |
|
3728 |
|
3729 len = strlen(connect_data->server ); |
|
3730 strcpy( smsg + index, connect_data->server ); |
|
3731 index += len + 1; |
|
3732 |
|
3733 //appending resource |
|
3734 len = strlen(connect_data->resource ); |
|
3735 strcpy( smsg + index, connect_data->resource ); |
|
3736 index += len + 1; |
|
3737 |
|
3738 //appending ssl |
|
3739 smsg[index++]= '1'; |
|
3740 smsg[index++]= '\0'; |
|
3741 |
|
3742 //appending server port |
|
3743 len = strlen(connect_data->port ); |
|
3744 strcpy( smsg + index, connect_data->port ); |
|
3745 index += len + 1; |
|
3746 |
|
3747 // appending IAP id |
|
3748 |
|
3749 smsg[index++]= '1'; |
|
3750 smsg[index++]= '\0'; |
|
3751 |
|
3752 //appending connmgr_bus |
|
3753 len = strlen(connect_data->connmgr_bus ); |
|
3754 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
3755 index += len + 1; |
|
3756 |
|
3757 //appending connmgr_path |
|
3758 len = strlen(connect_data->connmgr_path ); |
|
3759 strcpy( smsg + index, connect_data->connmgr_path ); |
|
3760 index += len + 1; |
|
3761 |
|
3762 //appending protocol |
|
3763 len = strlen(connect_data->protocol ); |
|
3764 strcpy( smsg + index, connect_data->protocol ); |
|
3765 index += len + 1; |
|
3766 |
|
3767 #ifdef __WINSCW__ |
|
3768 //proxy server |
|
3769 len = strlen(connect_data->proxy_data->proxy_server ); |
|
3770 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
3771 index += len + 1; |
|
3772 |
|
3773 //proxy port |
|
3774 len = strlen(connect_data->proxy_data->proxy_port ); |
|
3775 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
3776 index += len + 1; |
|
3777 |
|
3778 #endif |
|
3779 //running isoserver |
|
3780 run_isoserver(); |
|
3781 |
|
3782 |
|
3783 |
|
3784 //create message queue for send request |
|
3785 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3786 //create message queue for response request |
|
3787 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
3788 |
|
3789 |
|
3790 /* Send Message to queueOne */ |
|
3791 |
|
3792 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3793 |
|
3794 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
3795 |
|
3796 if (status < 0) |
|
3797 { |
|
3798 return_value = KErrGeneral; |
|
3799 goto return_code; |
|
3800 } |
|
3801 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
3802 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
3803 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3804 |
|
3805 if( msg_struct->response != 1) |
|
3806 { |
|
3807 return_value = KErrGeneral; |
|
3808 goto return_code; |
|
3809 } |
|
3810 |
|
3811 |
|
3812 // login end |
|
3813 //fetch req.. |
|
3814 for (int i= 0 ;i<3 ;i++) |
|
3815 { |
|
3816 |
|
3817 fp = fopen("c:\\fetch_contact.txt","a"); |
|
3818 do { |
|
3819 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3820 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3821 fwrite(rmsg,1,status,fp); |
|
3822 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3823 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
3824 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
3825 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
3826 fclose(fp); |
|
3827 |
|
3828 } |
|
3829 |
|
3830 //fetch end |
|
3831 |
|
3832 //send messge-------------------------------------------- |
|
3833 |
|
3834 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3835 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3836 index=0; |
|
3837 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3838 msgHdr->message_type = ESend_Request; |
|
3839 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3840 index += sizeof( message_hdr_req ); |
|
3841 |
|
3842 |
|
3843 // adding recipient |
|
3844 len = strlen(connect_data->msg_data->recipient ); |
|
3845 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
3846 index += len + 1; |
|
3847 |
|
3848 // adding recipient |
|
3849 /*len = strlen(connect_data->msg_data->recipient ); |
|
3850 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
3851 index += len + 1;*/ |
|
3852 |
|
3853 smsg[index++] = '\0'; |
|
3854 |
|
3855 // adding message part |
|
3856 |
|
3857 len = strlen(connect_data->msg_data->message ); |
|
3858 strcpy( smsg + index, connect_data->msg_data->message ); |
|
3859 index += len + 1; |
|
3860 |
|
3861 |
|
3862 |
|
3863 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3864 do { |
|
3865 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3866 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3867 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3868 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
3869 |
|
3870 /* if ( msg_struct->response != 1) |
|
3871 { |
|
3872 return_value = KErrGeneral; |
|
3873 goto return_code; |
|
3874 }*/ |
|
3875 |
|
3876 //send message end--------------------------------------- |
|
3877 |
|
3878 |
|
3879 // logout test code from server |
|
3880 index=0; |
|
3881 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3882 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3883 |
|
3884 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3885 |
|
3886 msgHdr->message_type = ELogout_Request; |
|
3887 |
|
3888 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3889 index += sizeof( message_hdr_req ); |
|
3890 |
|
3891 |
|
3892 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3893 do { |
|
3894 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
3895 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
3896 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3897 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
3898 |
|
3899 if ( msg_struct->response != 1) |
|
3900 { |
|
3901 return_value = KErrGeneral; |
|
3902 goto return_code; |
|
3903 } |
|
3904 //killing isoserver |
|
3905 return_code: |
|
3906 index=0; |
|
3907 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3908 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3909 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3910 msgHdr->message_type = EKill_Process; |
|
3911 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3912 index += sizeof( message_hdr_req ); |
|
3913 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
3914 free( msg_struct ); |
|
3915 return return_value; |
|
3916 } |
|
3917 |
|
3918 // ----------------------------------------------------------------------------- |
|
3919 // Cisolationserver::Send message to unexist user id |
|
3920 // Example test method function. |
|
3921 // (other items were commented in a header). |
|
3922 // ----------------------------------------------------------------------------- |
|
3923 // |
|
3924 TInt Cisolationserver::SendTextMessageWithSpecialCharacter( CStifItemParser& aItem ) |
|
3925 { |
|
3926 |
|
3927 |
|
3928 ConnectData *connect_data = NULL; |
|
3929 char smsg[MAX_MSG_SIZE]; |
|
3930 char rmsg[MAX_MSG_SIZE]; |
|
3931 int index=0; |
|
3932 FILE *fp; |
|
3933 |
|
3934 int timeout = 200; |
|
3935 int nBytes; |
|
3936 |
|
3937 int result = 0; |
|
3938 int err = 0; |
|
3939 int status = 0; |
|
3940 message_hdr_req *msgHdr = NULL; |
|
3941 message_hdr_resp* msg_struct = NULL; |
|
3942 TInt return_value = 0; |
|
3943 // Read data from the CFG file |
|
3944 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
3945 { |
|
3946 iLog->Log ( _L ( "read_data failed" ) ); |
|
3947 free_data ( connect_data ); |
|
3948 return_value = KErrGeneral; |
|
3949 goto return_code; |
|
3950 } |
|
3951 //request formation |
|
3952 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
3953 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
3954 |
|
3955 //message header use |
|
3956 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
3957 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
3958 |
|
3959 msgHdr->message_type = ELogin_Request; |
|
3960 |
|
3961 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
3962 index += sizeof( message_hdr_req ); |
|
3963 |
|
3964 int len = strlen(connect_data->username); |
|
3965 strcpy( smsg + index, connect_data->username ); |
|
3966 index += len + 1; |
|
3967 |
|
3968 //appending password |
|
3969 |
|
3970 len = strlen(connect_data->password ); |
|
3971 strcpy( smsg + index, connect_data->password ); |
|
3972 index += len + 1; |
|
3973 |
|
3974 //appending server name |
|
3975 |
|
3976 len = strlen(connect_data->server ); |
|
3977 strcpy( smsg + index, connect_data->server ); |
|
3978 index += len + 1; |
|
3979 |
|
3980 //appending resource |
|
3981 len = strlen(connect_data->resource ); |
|
3982 strcpy( smsg + index, connect_data->resource ); |
|
3983 index += len + 1; |
|
3984 |
|
3985 //appending ssl |
|
3986 smsg[index++]= '1'; |
|
3987 smsg[index++]= '\0'; |
|
3988 |
|
3989 //appending server port |
|
3990 len = strlen(connect_data->port ); |
|
3991 strcpy( smsg + index, connect_data->port ); |
|
3992 index += len + 1; |
|
3993 |
|
3994 // appending IAP id |
|
3995 |
|
3996 smsg[index++]= '1'; |
|
3997 smsg[index++]= '\0'; |
|
3998 |
|
3999 //appending connmgr_bus |
|
4000 len = strlen(connect_data->connmgr_bus ); |
|
4001 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
4002 index += len + 1; |
|
4003 |
|
4004 //appending connmgr_path |
|
4005 len = strlen(connect_data->connmgr_path ); |
|
4006 strcpy( smsg + index, connect_data->connmgr_path ); |
|
4007 index += len + 1; |
|
4008 |
|
4009 //appending protocol |
|
4010 len = strlen(connect_data->protocol ); |
|
4011 strcpy( smsg + index, connect_data->protocol ); |
|
4012 index += len + 1; |
|
4013 |
|
4014 #ifdef __WINSCW__ |
|
4015 //proxy server |
|
4016 len = strlen(connect_data->proxy_data->proxy_server ); |
|
4017 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
4018 index += len + 1; |
|
4019 |
|
4020 //proxy port |
|
4021 len = strlen(connect_data->proxy_data->proxy_port ); |
|
4022 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
4023 index += len + 1; |
|
4024 |
|
4025 #endif |
|
4026 //running isoserver |
|
4027 run_isoserver(); |
|
4028 |
|
4029 //create message queue for send request |
|
4030 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4031 //create message queue for response request |
|
4032 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4033 |
|
4034 |
|
4035 /* Send Message to queueOne */ |
|
4036 |
|
4037 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4038 |
|
4039 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
4040 |
|
4041 if (status < 0) |
|
4042 { |
|
4043 return_value = KErrGeneral; |
|
4044 goto return_code; |
|
4045 } |
|
4046 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
4047 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
4048 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4049 |
|
4050 if( msg_struct->response != 1) |
|
4051 { |
|
4052 return_value = KErrGeneral; |
|
4053 goto return_code; |
|
4054 } |
|
4055 |
|
4056 |
|
4057 // login end |
|
4058 |
|
4059 //fetch req.. |
|
4060 for (int i= 0 ;i<3 ;i++) |
|
4061 { |
|
4062 |
|
4063 fp = fopen("c:\\fetch_contact.txt","a"); |
|
4064 do { |
|
4065 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4066 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4067 fwrite(rmsg,1,status,fp); |
|
4068 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4069 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
4070 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
4071 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
4072 fclose(fp); |
|
4073 |
|
4074 } |
|
4075 |
|
4076 //fetch end |
|
4077 //send messge-------------------------------------------- |
|
4078 |
|
4079 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4080 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4081 index=0; |
|
4082 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4083 msgHdr->message_type = ESend_Request; |
|
4084 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4085 index += sizeof( message_hdr_req ); |
|
4086 |
|
4087 |
|
4088 // adding recipient |
|
4089 len = strlen(connect_data->msg_data->recipient ); |
|
4090 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4091 index += len + 1; |
|
4092 |
|
4093 // adding recipient |
|
4094 /*len = strlen(connect_data->msg_data->recipient ); |
|
4095 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4096 index += len + 1;*/ |
|
4097 |
|
4098 smsg[index++] = '\0'; |
|
4099 |
|
4100 // adding message part |
|
4101 |
|
4102 len = strlen(connect_data->msg_data->message ); |
|
4103 strcpy( smsg + index, connect_data->msg_data->message ); |
|
4104 index += len + 1; |
|
4105 |
|
4106 |
|
4107 |
|
4108 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4109 do { |
|
4110 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4111 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4112 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4113 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
4114 |
|
4115 if ( msg_struct->response != 1) |
|
4116 { |
|
4117 return_value = KErrGeneral; |
|
4118 goto return_code; |
|
4119 } |
|
4120 //send message end--------------------------------------- |
|
4121 |
|
4122 |
|
4123 // logout test code from server |
|
4124 index=0; |
|
4125 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4126 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4127 |
|
4128 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4129 |
|
4130 msgHdr->message_type = ELogout_Request; |
|
4131 |
|
4132 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4133 index += sizeof( message_hdr_req ); |
|
4134 |
|
4135 |
|
4136 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4137 do { |
|
4138 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4139 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4140 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4141 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
4142 |
|
4143 if ( msg_struct->response != 1) |
|
4144 { |
|
4145 return_value = KErrGeneral; |
|
4146 goto return_code; |
|
4147 } |
|
4148 //killing isoserver |
|
4149 return_code: |
|
4150 index=0; |
|
4151 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4152 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4153 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4154 msgHdr->message_type = EKill_Process; |
|
4155 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4156 index += sizeof( message_hdr_req ); |
|
4157 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4158 free( msg_struct ); |
|
4159 return return_value; |
|
4160 } |
|
4161 |
|
4162 // ----------------------------------------------------------------------------- |
|
4163 // Cisolationserver::Send message to blank user id |
|
4164 // Example test method function. |
|
4165 // (other items were commented in a header). |
|
4166 // ----------------------------------------------------------------------------- |
|
4167 // |
|
4168 TInt Cisolationserver::SendMessageWithBlankUserID( CStifItemParser& aItem ) |
|
4169 { |
|
4170 |
|
4171 |
|
4172 ConnectData *connect_data = NULL; |
|
4173 char smsg[MAX_MSG_SIZE]; |
|
4174 char rmsg[MAX_MSG_SIZE]; |
|
4175 int index=0; |
|
4176 FILE *fp; |
|
4177 |
|
4178 int timeout = 200; |
|
4179 int nBytes; |
|
4180 |
|
4181 int result = 0; |
|
4182 int err = 0; |
|
4183 int status = 0; |
|
4184 message_hdr_req *msgHdr = NULL; |
|
4185 message_hdr_resp* msg_struct = NULL; |
|
4186 TInt return_value = 0; |
|
4187 // Read data from the CFG file |
|
4188 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
4189 { |
|
4190 iLog->Log ( _L ( "read_data failed" ) ); |
|
4191 free_data ( connect_data ); |
|
4192 return_value = KErrGeneral; |
|
4193 goto return_code; |
|
4194 } |
|
4195 //request formation |
|
4196 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4197 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4198 |
|
4199 //message header use |
|
4200 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
4201 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4202 |
|
4203 msgHdr->message_type = ELogin_Request; |
|
4204 |
|
4205 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4206 index += sizeof( message_hdr_req ); |
|
4207 |
|
4208 int len = strlen(connect_data->username); |
|
4209 strcpy( smsg + index, connect_data->username ); |
|
4210 index += len + 1; |
|
4211 |
|
4212 //appending password |
|
4213 |
|
4214 len = strlen(connect_data->password ); |
|
4215 strcpy( smsg + index, connect_data->password ); |
|
4216 index += len + 1; |
|
4217 |
|
4218 //appending server name |
|
4219 |
|
4220 len = strlen(connect_data->server ); |
|
4221 strcpy( smsg + index, connect_data->server ); |
|
4222 index += len + 1; |
|
4223 |
|
4224 //appending resource |
|
4225 len = strlen(connect_data->resource ); |
|
4226 strcpy( smsg + index, connect_data->resource ); |
|
4227 index += len + 1; |
|
4228 |
|
4229 //appending ssl |
|
4230 smsg[index++]= '1'; |
|
4231 smsg[index++]= '\0'; |
|
4232 |
|
4233 //appending server port |
|
4234 len = strlen(connect_data->port ); |
|
4235 strcpy( smsg + index, connect_data->port ); |
|
4236 index += len + 1; |
|
4237 |
|
4238 // appending IAP id |
|
4239 |
|
4240 smsg[index++]= '1'; |
|
4241 smsg[index++]= '\0'; |
|
4242 |
|
4243 //appending connmgr_bus |
|
4244 len = strlen(connect_data->connmgr_bus ); |
|
4245 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
4246 index += len + 1; |
|
4247 |
|
4248 //appending connmgr_path |
|
4249 len = strlen(connect_data->connmgr_path ); |
|
4250 strcpy( smsg + index, connect_data->connmgr_path ); |
|
4251 index += len + 1; |
|
4252 |
|
4253 //appending protocol |
|
4254 len = strlen(connect_data->protocol ); |
|
4255 strcpy( smsg + index, connect_data->protocol ); |
|
4256 index += len + 1; |
|
4257 |
|
4258 #ifdef __WINSCW__ |
|
4259 //proxy server |
|
4260 len = strlen(connect_data->proxy_data->proxy_server ); |
|
4261 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
4262 index += len + 1; |
|
4263 |
|
4264 //proxy port |
|
4265 len = strlen(connect_data->proxy_data->proxy_port ); |
|
4266 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
4267 index += len + 1; |
|
4268 |
|
4269 #endif |
|
4270 |
|
4271 //running isoserver |
|
4272 run_isoserver(); |
|
4273 |
|
4274 |
|
4275 //create message queue for send request |
|
4276 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4277 //create message queue for response request |
|
4278 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4279 |
|
4280 |
|
4281 /* Send Message to queueOne */ |
|
4282 |
|
4283 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4284 |
|
4285 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
4286 |
|
4287 if (status < 0) |
|
4288 { |
|
4289 return_value = KErrGeneral; |
|
4290 goto return_code; |
|
4291 } |
|
4292 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
4293 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
4294 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4295 |
|
4296 if( msg_struct->response != 1) |
|
4297 { |
|
4298 return_value = KErrGeneral; |
|
4299 goto return_code; |
|
4300 } |
|
4301 |
|
4302 |
|
4303 // login end |
|
4304 //fetch req.. |
|
4305 for (int i= 0 ;i<3 ;i++) |
|
4306 { |
|
4307 |
|
4308 fp = fopen("c:\\fetch_contact.txt","a"); |
|
4309 do { |
|
4310 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4311 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4312 fwrite(rmsg,1,status,fp); |
|
4313 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4314 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
4315 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
4316 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
4317 fclose(fp); |
|
4318 |
|
4319 } |
|
4320 |
|
4321 //fetch end |
|
4322 |
|
4323 //send messge-------------------------------------------- |
|
4324 |
|
4325 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4326 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4327 index=0; |
|
4328 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4329 msgHdr->message_type = ESend_Request; |
|
4330 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4331 index += sizeof( message_hdr_req ); |
|
4332 |
|
4333 |
|
4334 // adding recipient |
|
4335 smsg[index++] = '\0'; |
|
4336 |
|
4337 // adding recipient |
|
4338 /*len = strlen(connect_data->msg_data->recipient ); |
|
4339 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4340 index += len + 1;*/ |
|
4341 |
|
4342 smsg[index++] = '\0'; |
|
4343 |
|
4344 // adding message part |
|
4345 |
|
4346 len = strlen(connect_data->msg_data->message ); |
|
4347 strcpy( smsg + index, connect_data->msg_data->message ); |
|
4348 index += len + 1; |
|
4349 |
|
4350 |
|
4351 |
|
4352 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4353 do { |
|
4354 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4355 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4356 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4357 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
4358 |
|
4359 if ( msg_struct->response != 0) |
|
4360 { |
|
4361 return_value = KErrGeneral; |
|
4362 goto return_code; |
|
4363 } |
|
4364 |
|
4365 //send message end--------------------------------------- |
|
4366 |
|
4367 |
|
4368 // logout test code from server |
|
4369 index=0; |
|
4370 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4371 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4372 |
|
4373 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4374 |
|
4375 msgHdr->message_type = ELogout_Request; |
|
4376 |
|
4377 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4378 index += sizeof( message_hdr_req ); |
|
4379 |
|
4380 |
|
4381 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4382 do { |
|
4383 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4384 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4385 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4386 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
4387 |
|
4388 if ( msg_struct->response != 1) |
|
4389 { |
|
4390 return_value = KErrGeneral; |
|
4391 goto return_code; |
|
4392 } |
|
4393 //killing isoserver |
|
4394 return_code: |
|
4395 index=0; |
|
4396 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4397 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4398 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4399 msgHdr->message_type = EKill_Process; |
|
4400 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4401 index += sizeof( message_hdr_req ); |
|
4402 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4403 free( msg_struct ); |
|
4404 return return_value; |
|
4405 } |
|
4406 |
|
4407 // ----------------------------------------------------------------------------- |
|
4408 // Cisolationserver::Send blank message to user id |
|
4409 // Example test method function. |
|
4410 // (other items were commented in a header). |
|
4411 // ----------------------------------------------------------------------------- |
|
4412 // |
|
4413 TInt Cisolationserver::SendBlankMessageToUserID( CStifItemParser& aItem ) |
|
4414 { |
|
4415 ConnectData *connect_data = NULL; |
|
4416 char smsg[MAX_MSG_SIZE]; |
|
4417 char rmsg[MAX_MSG_SIZE]; |
|
4418 int index=0; |
|
4419 FILE *fp; |
|
4420 int timeout = 200; |
|
4421 int nBytes; |
|
4422 |
|
4423 int result = 0; |
|
4424 int err = 0; |
|
4425 int status = 0; |
|
4426 message_hdr_req *msgHdr = NULL; |
|
4427 message_hdr_resp* msg_struct = NULL; |
|
4428 TInt return_value = 0; |
|
4429 // Read data from the CFG file |
|
4430 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
4431 { |
|
4432 iLog->Log ( _L ( "read_data failed" ) ); |
|
4433 free_data ( connect_data ); |
|
4434 return_value = KErrGeneral; |
|
4435 goto return_code; |
|
4436 } |
|
4437 //request formation |
|
4438 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4439 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4440 |
|
4441 //message header use |
|
4442 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
4443 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4444 |
|
4445 msgHdr->message_type = ELogin_Request; |
|
4446 |
|
4447 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4448 index += sizeof( message_hdr_req ); |
|
4449 |
|
4450 int len = strlen(connect_data->username); |
|
4451 strcpy( smsg + index, connect_data->username ); |
|
4452 index += len + 1; |
|
4453 |
|
4454 //appending password |
|
4455 |
|
4456 len = strlen(connect_data->password ); |
|
4457 strcpy( smsg + index, connect_data->password ); |
|
4458 index += len + 1; |
|
4459 |
|
4460 //appending server name |
|
4461 |
|
4462 len = strlen(connect_data->server ); |
|
4463 strcpy( smsg + index, connect_data->server ); |
|
4464 index += len + 1; |
|
4465 |
|
4466 //appending resource |
|
4467 len = strlen(connect_data->resource ); |
|
4468 strcpy( smsg + index, connect_data->resource ); |
|
4469 index += len + 1; |
|
4470 |
|
4471 //appending ssl |
|
4472 smsg[index++]= '1'; |
|
4473 smsg[index++]= '\0'; |
|
4474 |
|
4475 //appending server port |
|
4476 len = strlen(connect_data->port ); |
|
4477 strcpy( smsg + index, connect_data->port ); |
|
4478 index += len + 1; |
|
4479 |
|
4480 // appending IAP id |
|
4481 |
|
4482 smsg[index++]= '1'; |
|
4483 smsg[index++]= '\0'; |
|
4484 |
|
4485 |
|
4486 |
|
4487 //appending connmgr_bus |
|
4488 len = strlen(connect_data->connmgr_bus ); |
|
4489 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
4490 index += len + 1; |
|
4491 |
|
4492 //appending connmgr_path |
|
4493 len = strlen(connect_data->connmgr_path ); |
|
4494 strcpy( smsg + index, connect_data->connmgr_path ); |
|
4495 index += len + 1; |
|
4496 |
|
4497 //appending protocol |
|
4498 len = strlen(connect_data->protocol ); |
|
4499 strcpy( smsg + index, connect_data->protocol ); |
|
4500 index += len + 1; |
|
4501 |
|
4502 #ifdef __WINSCW__ |
|
4503 //proxy server |
|
4504 len = strlen(connect_data->proxy_data->proxy_server ); |
|
4505 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
4506 index += len + 1; |
|
4507 |
|
4508 //proxy port |
|
4509 len = strlen(connect_data->proxy_data->proxy_port ); |
|
4510 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
4511 index += len + 1; |
|
4512 |
|
4513 #endif |
|
4514 //running isoserver |
|
4515 run_isoserver(); |
|
4516 //create message queue for send request |
|
4517 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4518 //create message queue for response request |
|
4519 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4520 |
|
4521 |
|
4522 /* Send Message to queueOne */ |
|
4523 |
|
4524 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4525 |
|
4526 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
4527 |
|
4528 if (status < 0) |
|
4529 { |
|
4530 return_value = KErrGeneral; |
|
4531 goto return_code; |
|
4532 } |
|
4533 |
|
4534 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
4535 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
4536 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4537 |
|
4538 if( msg_struct->response != 1) |
|
4539 { |
|
4540 return_value = KErrGeneral; |
|
4541 goto return_code; |
|
4542 } |
|
4543 |
|
4544 |
|
4545 // login end |
|
4546 //fetch req.. |
|
4547 for (int i= 0 ;i<3 ;i++) |
|
4548 { |
|
4549 |
|
4550 fp = fopen("c:\\fetch_contact.txt","a"); |
|
4551 do { |
|
4552 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4553 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4554 fwrite(rmsg,1,status,fp); |
|
4555 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4556 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
4557 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
4558 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
4559 fclose(fp); |
|
4560 |
|
4561 } |
|
4562 |
|
4563 //fetch end |
|
4564 |
|
4565 |
|
4566 //send messge-------------------------------------------- |
|
4567 |
|
4568 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4569 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4570 index=0; |
|
4571 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4572 msgHdr->message_type = ESend_Request; |
|
4573 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4574 index += sizeof( message_hdr_req ); |
|
4575 |
|
4576 |
|
4577 // adding recipient |
|
4578 len = strlen(connect_data->msg_data->recipient ); |
|
4579 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4580 index += len + 1; |
|
4581 |
|
4582 // adding recipient |
|
4583 /*len = strlen(connect_data->msg_data->recipient ); |
|
4584 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4585 index += len + 1;*/ |
|
4586 |
|
4587 smsg[index++] = '\0'; |
|
4588 |
|
4589 // adding message part |
|
4590 |
|
4591 smsg[index++]=' '; |
|
4592 smsg[index++]='\0'; |
|
4593 |
|
4594 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4595 do { |
|
4596 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4597 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4598 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4599 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
4600 |
|
4601 if ( msg_struct->response != 1) |
|
4602 { |
|
4603 return_value = KErrGeneral; |
|
4604 goto return_code; |
|
4605 } |
|
4606 |
|
4607 |
|
4608 //send message end--------------------------------------- |
|
4609 |
|
4610 |
|
4611 // logout test code from server |
|
4612 index=0; |
|
4613 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4614 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4615 |
|
4616 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4617 |
|
4618 msgHdr->message_type = ELogout_Request; |
|
4619 |
|
4620 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4621 index += sizeof( message_hdr_req ); |
|
4622 |
|
4623 |
|
4624 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4625 do { |
|
4626 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4627 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4628 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4629 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
4630 |
|
4631 if ( msg_struct->response != 1) |
|
4632 { |
|
4633 return_value = KErrGeneral; |
|
4634 goto return_code; |
|
4635 } |
|
4636 return_value = KErrNone; |
|
4637 goto return_code; |
|
4638 //killing isoserver |
|
4639 return_code: |
|
4640 index=0; |
|
4641 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4642 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4643 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4644 msgHdr->message_type = EKill_Process; |
|
4645 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4646 index += sizeof( message_hdr_req ); |
|
4647 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4648 free( msg_struct ); |
|
4649 return return_value; |
|
4650 } |
|
4651 |
|
4652 // ----------------------------------------------------------------------------- |
|
4653 // Cisolationserver::Send blank message to user id |
|
4654 // Example test method function. |
|
4655 // (other items were commented in a header). |
|
4656 // ----------------------------------------------------------------------------- |
|
4657 // |
|
4658 TInt Cisolationserver::SendSmilyToCorrectUserID( CStifItemParser& aItem ) |
|
4659 { |
|
4660 |
|
4661 |
|
4662 ConnectData *connect_data = NULL; |
|
4663 char smsg[MAX_MSG_SIZE]; |
|
4664 char rmsg[MAX_MSG_SIZE]; |
|
4665 int index=0; |
|
4666 FILE *fp; |
|
4667 |
|
4668 int timeout = 200; |
|
4669 int nBytes; |
|
4670 |
|
4671 int result = 0; |
|
4672 int err = 0; |
|
4673 int status = 0; |
|
4674 message_hdr_req *msgHdr = NULL; |
|
4675 message_hdr_resp* msg_struct = NULL; |
|
4676 TInt return_value = 0; |
|
4677 // Read data from the CFG file |
|
4678 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
4679 { |
|
4680 iLog->Log ( _L ( "read_data failed" ) ); |
|
4681 free_data ( connect_data ); |
|
4682 return_value = KErrGeneral; |
|
4683 goto return_code; |
|
4684 } |
|
4685 //request formation |
|
4686 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4687 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4688 |
|
4689 //message header use |
|
4690 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
4691 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4692 |
|
4693 msgHdr->message_type = ELogin_Request; |
|
4694 |
|
4695 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4696 index += sizeof( message_hdr_req ); |
|
4697 |
|
4698 int len = strlen(connect_data->username); |
|
4699 strcpy( smsg + index, connect_data->username ); |
|
4700 index += len + 1; |
|
4701 |
|
4702 //appending password |
|
4703 |
|
4704 len = strlen(connect_data->password ); |
|
4705 strcpy( smsg + index, connect_data->password ); |
|
4706 index += len + 1; |
|
4707 |
|
4708 //appending server name |
|
4709 |
|
4710 len = strlen(connect_data->server ); |
|
4711 strcpy( smsg + index, connect_data->server ); |
|
4712 index += len + 1; |
|
4713 |
|
4714 //appending resource |
|
4715 len = strlen(connect_data->resource ); |
|
4716 strcpy( smsg + index, connect_data->resource ); |
|
4717 index += len + 1; |
|
4718 |
|
4719 //appending ssl |
|
4720 smsg[index++]= '1'; |
|
4721 smsg[index++]= '\0'; |
|
4722 |
|
4723 //appending server port |
|
4724 len = strlen(connect_data->port ); |
|
4725 strcpy( smsg + index, connect_data->port ); |
|
4726 index += len + 1; |
|
4727 |
|
4728 // appending IAP id |
|
4729 |
|
4730 smsg[index++]= '1'; |
|
4731 smsg[index++]= '\0'; |
|
4732 |
|
4733 //appending connmgr_bus |
|
4734 len = strlen(connect_data->connmgr_bus ); |
|
4735 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
4736 index += len + 1; |
|
4737 |
|
4738 //appending connmgr_path |
|
4739 len = strlen(connect_data->connmgr_path ); |
|
4740 strcpy( smsg + index, connect_data->connmgr_path ); |
|
4741 index += len + 1; |
|
4742 |
|
4743 //appending protocol |
|
4744 len = strlen(connect_data->protocol ); |
|
4745 strcpy( smsg + index, connect_data->protocol ); |
|
4746 index += len + 1; |
|
4747 |
|
4748 #ifdef __WINSCW__ |
|
4749 //proxy server |
|
4750 len = strlen(connect_data->proxy_data->proxy_server ); |
|
4751 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
4752 index += len + 1; |
|
4753 |
|
4754 //proxy port |
|
4755 len = strlen(connect_data->proxy_data->proxy_port ); |
|
4756 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
4757 index += len + 1; |
|
4758 |
|
4759 #endif |
|
4760 //running isoserver |
|
4761 run_isoserver(); |
|
4762 |
|
4763 |
|
4764 |
|
4765 //create message queue for send request |
|
4766 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4767 //create message queue for response request |
|
4768 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
4769 |
|
4770 |
|
4771 /* Send Message to queueOne */ |
|
4772 |
|
4773 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4774 |
|
4775 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
4776 |
|
4777 if (status < 0) |
|
4778 { |
|
4779 return_value = KErrGeneral; |
|
4780 goto return_code; |
|
4781 } |
|
4782 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
4783 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
4784 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4785 |
|
4786 if( msg_struct->response != 1) |
|
4787 { |
|
4788 return_value = KErrGeneral; |
|
4789 goto return_code; |
|
4790 } |
|
4791 |
|
4792 |
|
4793 // login end |
|
4794 //fetch req.. |
|
4795 for (int i= 0 ;i<3 ;i++) |
|
4796 { |
|
4797 |
|
4798 fp = fopen("c:\\fetch_contact.txt","a"); |
|
4799 do { |
|
4800 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4801 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4802 fwrite(rmsg,1,status,fp); |
|
4803 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4804 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
4805 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
4806 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
4807 fclose(fp); |
|
4808 |
|
4809 } |
|
4810 |
|
4811 //fetch end |
|
4812 |
|
4813 //send messge-------------------------------------------- |
|
4814 |
|
4815 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4816 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4817 index=0; |
|
4818 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4819 msgHdr->message_type = ESend_Request; |
|
4820 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4821 index += sizeof( message_hdr_req ); |
|
4822 |
|
4823 |
|
4824 // adding recipient |
|
4825 len = strlen(connect_data->msg_data->recipient ); |
|
4826 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4827 index += len + 1; |
|
4828 |
|
4829 // adding recipient |
|
4830 /*len = strlen(connect_data->msg_data->recipient ); |
|
4831 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
4832 index += len + 1;*/ |
|
4833 |
|
4834 smsg[index++] = '\0'; |
|
4835 |
|
4836 // adding message part |
|
4837 |
|
4838 len = strlen(connect_data->msg_data->message ); |
|
4839 strncpy( smsg + index, connect_data->msg_data->message, strlen( connect_data->msg_data->message ) ); |
|
4840 index += len; |
|
4841 smsg[index++] = ' '; |
|
4842 smsg[index++]=':'; |
|
4843 smsg[index++]='-'; |
|
4844 smsg[index++]=')'; |
|
4845 smsg[index++] = '\0'; |
|
4846 |
|
4847 |
|
4848 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4849 do { |
|
4850 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4851 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4852 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4853 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
4854 |
|
4855 if ( msg_struct->response != 1) |
|
4856 { |
|
4857 return_value = KErrGeneral; |
|
4858 goto return_code; |
|
4859 } |
|
4860 |
|
4861 |
|
4862 //send message end--------------------------------------- |
|
4863 |
|
4864 |
|
4865 // logout test code from server |
|
4866 index=0; |
|
4867 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4868 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4869 |
|
4870 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4871 |
|
4872 msgHdr->message_type = ELogout_Request; |
|
4873 |
|
4874 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4875 index += sizeof( message_hdr_req ); |
|
4876 |
|
4877 |
|
4878 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4879 do { |
|
4880 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
4881 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
4882 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4883 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
4884 |
|
4885 if ( msg_struct->response != 1) |
|
4886 { |
|
4887 return_value = KErrGeneral; |
|
4888 goto return_code; |
|
4889 } |
|
4890 //killing isoserver |
|
4891 return_code: |
|
4892 index=0; |
|
4893 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4894 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4895 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4896 msgHdr->message_type = EKill_Process; |
|
4897 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4898 index += sizeof( message_hdr_req ); |
|
4899 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
4900 free( msg_struct ); |
|
4901 return return_value; |
|
4902 } |
|
4903 |
|
4904 // ----------------------------------------------------------------------------- |
|
4905 // Cisolationserver::Send message |
|
4906 // Example test method function. |
|
4907 // (other items were commented in a header). |
|
4908 // ----------------------------------------------------------------------------- |
|
4909 // |
|
4910 TInt Cisolationserver::SendMessageToOfflineContact( CStifItemParser& aItem ) |
|
4911 { |
|
4912 |
|
4913 |
|
4914 ConnectData *connect_data = NULL; |
|
4915 char smsg[MAX_MSG_SIZE]; |
|
4916 char rmsg[MAX_MSG_SIZE]; |
|
4917 int index=0; |
|
4918 FILE *fp; |
|
4919 |
|
4920 int timeout = 200; |
|
4921 int nBytes; |
|
4922 |
|
4923 int result = 0; |
|
4924 int err = 0; |
|
4925 int status = 0; |
|
4926 message_hdr_req *msgHdr = NULL; |
|
4927 message_hdr_resp* msg_struct = NULL; |
|
4928 TInt return_value = 0; |
|
4929 // Read data from the CFG file |
|
4930 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
4931 { |
|
4932 iLog->Log ( _L ( "read_data failed" ) ); |
|
4933 free_data ( connect_data ); |
|
4934 return_value = KErrGeneral; |
|
4935 goto return_code; |
|
4936 } |
|
4937 //request formation |
|
4938 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
4939 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
4940 |
|
4941 //message header use |
|
4942 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
4943 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
4944 |
|
4945 msgHdr->message_type = ELogin_Request; |
|
4946 |
|
4947 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
4948 index += sizeof( message_hdr_req ); |
|
4949 |
|
4950 int len = strlen(connect_data->username); |
|
4951 strcpy( smsg + index, connect_data->username ); |
|
4952 index += len + 1; |
|
4953 |
|
4954 //appending password |
|
4955 |
|
4956 len = strlen(connect_data->password ); |
|
4957 strcpy( smsg + index, connect_data->password ); |
|
4958 index += len + 1; |
|
4959 |
|
4960 //appending server name |
|
4961 |
|
4962 len = strlen(connect_data->server ); |
|
4963 strcpy( smsg + index, connect_data->server ); |
|
4964 index += len + 1; |
|
4965 |
|
4966 //appending resource |
|
4967 len = strlen(connect_data->resource ); |
|
4968 strcpy( smsg + index, connect_data->resource ); |
|
4969 index += len + 1; |
|
4970 |
|
4971 //appending ssl |
|
4972 smsg[index++]= '1'; |
|
4973 smsg[index++]= '\0'; |
|
4974 |
|
4975 //appending server port |
|
4976 len = strlen(connect_data->port ); |
|
4977 strcpy( smsg + index, connect_data->port ); |
|
4978 index += len + 1; |
|
4979 |
|
4980 // appending IAP id |
|
4981 |
|
4982 smsg[index++]= '1'; |
|
4983 smsg[index++]= '\0'; |
|
4984 |
|
4985 //appending connmgr_bus |
|
4986 len = strlen(connect_data->connmgr_bus ); |
|
4987 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
4988 index += len + 1; |
|
4989 |
|
4990 //appending connmgr_path |
|
4991 len = strlen(connect_data->connmgr_path ); |
|
4992 strcpy( smsg + index, connect_data->connmgr_path ); |
|
4993 index += len + 1; |
|
4994 |
|
4995 //appending protocol |
|
4996 len = strlen(connect_data->protocol ); |
|
4997 strcpy( smsg + index, connect_data->protocol ); |
|
4998 index += len + 1; |
|
4999 |
|
5000 #ifdef __WINSCW__ |
|
5001 //proxy server |
|
5002 len = strlen(connect_data->proxy_data->proxy_server ); |
|
5003 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
5004 index += len + 1; |
|
5005 |
|
5006 //proxy port |
|
5007 len = strlen(connect_data->proxy_data->proxy_port ); |
|
5008 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
5009 index += len + 1; |
|
5010 |
|
5011 #endif |
|
5012 //running isoserver |
|
5013 run_isoserver(); |
|
5014 |
|
5015 |
|
5016 |
|
5017 //create message queue for send request |
|
5018 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5019 //create message queue for response request |
|
5020 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5021 |
|
5022 |
|
5023 /* Send Message to queueOne */ |
|
5024 |
|
5025 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5026 |
|
5027 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
5028 |
|
5029 if (status < 0) |
|
5030 { |
|
5031 return_value = KErrGeneral; |
|
5032 goto return_code; |
|
5033 } |
|
5034 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
5035 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
5036 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5037 |
|
5038 if( msg_struct->response != 1) |
|
5039 { |
|
5040 return_value = KErrGeneral; |
|
5041 goto return_code; |
|
5042 } |
|
5043 |
|
5044 //fetch req.. |
|
5045 for (int i= 0 ;i<3 ;i++) |
|
5046 { |
|
5047 |
|
5048 fp = fopen("c:\\fetch_contact.txt","a"); |
|
5049 do { |
|
5050 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5051 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5052 fwrite(rmsg,1,status,fp); |
|
5053 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5054 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
5055 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
5056 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
5057 fclose(fp); |
|
5058 |
|
5059 } |
|
5060 |
|
5061 //fetch end |
|
5062 //send messge-------------------------------------------- |
|
5063 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5064 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5065 index=0; |
|
5066 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5067 msgHdr->message_type = ESend_Request; |
|
5068 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5069 index += sizeof( message_hdr_req ); |
|
5070 |
|
5071 |
|
5072 // adding recipient |
|
5073 len = strlen(connect_data->msg_data->recipient ); |
|
5074 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5075 index += len + 1; |
|
5076 |
|
5077 // adding recipient |
|
5078 /*len = strlen(connect_data->msg_data->recipient ); |
|
5079 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5080 index += len + 1;*/ |
|
5081 |
|
5082 smsg[index++] = '\0'; |
|
5083 |
|
5084 // adding message part |
|
5085 |
|
5086 len = strlen(connect_data->msg_data->message ); |
|
5087 strcpy( smsg + index, connect_data->msg_data->message ); |
|
5088 index += len + 1; |
|
5089 |
|
5090 |
|
5091 |
|
5092 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5093 do { |
|
5094 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5095 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5096 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5097 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
5098 |
|
5099 if ( msg_struct->response != 1) |
|
5100 { |
|
5101 return_value = KErrGeneral; |
|
5102 goto return_code; |
|
5103 } |
|
5104 |
|
5105 //send message end--------------------------------------- |
|
5106 |
|
5107 // logout test code from server |
|
5108 index=0; |
|
5109 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5110 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5111 |
|
5112 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5113 |
|
5114 msgHdr->message_type = ELogout_Request; |
|
5115 |
|
5116 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5117 index += sizeof( message_hdr_req ); |
|
5118 |
|
5119 |
|
5120 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5121 do { |
|
5122 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5123 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5124 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5125 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
5126 |
|
5127 if ( msg_struct->response != 1) |
|
5128 { |
|
5129 return_value = KErrGeneral; |
|
5130 goto return_code; |
|
5131 } |
|
5132 |
|
5133 //killing isoserver |
|
5134 return_code: |
|
5135 index=0; |
|
5136 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5137 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5138 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5139 msgHdr->message_type = EKill_Process; |
|
5140 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5141 index += sizeof( message_hdr_req ); |
|
5142 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5143 free( msg_struct ); |
|
5144 return return_value; |
|
5145 } |
|
5146 |
|
5147 |
|
5148 // ----------------------------------------------------------------------------- |
|
5149 // Cisolationserver::Send message |
|
5150 // Example test method function. |
|
5151 // (other items were commented in a header). |
|
5152 // ----------------------------------------------------------------------------- |
|
5153 // |
|
5154 TInt Cisolationserver::SendContinuousltReapitiveMessage( CStifItemParser& aItem ) |
|
5155 { |
|
5156 |
|
5157 |
|
5158 ConnectData *connect_data = NULL; |
|
5159 char smsg[MAX_MSG_SIZE]; |
|
5160 char rmsg[MAX_MSG_SIZE]; |
|
5161 int index=0; |
|
5162 FILE *fp; |
|
5163 |
|
5164 int timeout = 200; |
|
5165 int nBytes; |
|
5166 |
|
5167 int result = 0; |
|
5168 int err = 0; |
|
5169 int status = 0; |
|
5170 message_hdr_req *msgHdr = NULL; |
|
5171 message_hdr_resp* msg_struct = NULL; |
|
5172 TInt return_value = 0; |
|
5173 // Read data from the CFG file |
|
5174 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
5175 { |
|
5176 iLog->Log ( _L ( "read_data failed" ) ); |
|
5177 free_data ( connect_data ); |
|
5178 return_value = KErrGeneral; |
|
5179 goto return_code; |
|
5180 } |
|
5181 //request formation |
|
5182 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5183 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5184 |
|
5185 //message header use |
|
5186 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
5187 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5188 |
|
5189 msgHdr->message_type = ELogin_Request; |
|
5190 |
|
5191 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5192 index += sizeof( message_hdr_req ); |
|
5193 |
|
5194 int len = strlen(connect_data->username); |
|
5195 strcpy( smsg + index, connect_data->username ); |
|
5196 index += len + 1; |
|
5197 |
|
5198 //appending password |
|
5199 |
|
5200 len = strlen(connect_data->password ); |
|
5201 strcpy( smsg + index, connect_data->password ); |
|
5202 index += len + 1; |
|
5203 |
|
5204 //appending server name |
|
5205 |
|
5206 len = strlen(connect_data->server ); |
|
5207 strcpy( smsg + index, connect_data->server ); |
|
5208 index += len + 1; |
|
5209 |
|
5210 //appending resource |
|
5211 len = strlen(connect_data->resource ); |
|
5212 strcpy( smsg + index, connect_data->resource ); |
|
5213 index += len + 1; |
|
5214 |
|
5215 //appending ssl |
|
5216 smsg[index++]= '1'; |
|
5217 smsg[index++]= '\0'; |
|
5218 |
|
5219 //appending server port |
|
5220 len = strlen(connect_data->port ); |
|
5221 strcpy( smsg + index, connect_data->port ); |
|
5222 index += len + 1; |
|
5223 |
|
5224 // appending IAP id |
|
5225 |
|
5226 smsg[index++]= '1'; |
|
5227 smsg[index++]= '\0'; |
|
5228 |
|
5229 //appending connmgr_bus |
|
5230 len = strlen(connect_data->connmgr_bus ); |
|
5231 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
5232 index += len + 1; |
|
5233 |
|
5234 //appending connmgr_path |
|
5235 len = strlen(connect_data->connmgr_path ); |
|
5236 strcpy( smsg + index, connect_data->connmgr_path ); |
|
5237 index += len + 1; |
|
5238 |
|
5239 //appending protocol |
|
5240 len = strlen(connect_data->protocol ); |
|
5241 strcpy( smsg + index, connect_data->protocol ); |
|
5242 index += len + 1; |
|
5243 |
|
5244 #ifdef __WINSCW__ |
|
5245 //proxy server |
|
5246 len = strlen(connect_data->proxy_data->proxy_server ); |
|
5247 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
5248 index += len + 1; |
|
5249 |
|
5250 //proxy port |
|
5251 len = strlen(connect_data->proxy_data->proxy_port ); |
|
5252 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
5253 index += len + 1; |
|
5254 |
|
5255 #endif |
|
5256 //running isoserver |
|
5257 run_isoserver(); |
|
5258 |
|
5259 |
|
5260 |
|
5261 //create message queue for send request |
|
5262 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5263 //create message queue for response request |
|
5264 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5265 |
|
5266 |
|
5267 /* Send Message to queueOne */ |
|
5268 |
|
5269 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5270 |
|
5271 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
5272 |
|
5273 if (status < 0) |
|
5274 { |
|
5275 return_value = KErrGeneral; |
|
5276 goto return_code; |
|
5277 } |
|
5278 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
5279 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
5280 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5281 |
|
5282 if( msg_struct->response != 1) |
|
5283 { |
|
5284 return_value = KErrGeneral; |
|
5285 goto return_code; |
|
5286 } |
|
5287 |
|
5288 |
|
5289 // login end |
|
5290 //fetch req.. |
|
5291 for (int i= 0 ;i<3 ;i++) |
|
5292 { |
|
5293 |
|
5294 fp = fopen("c:\\fetch_contact.txt","a"); |
|
5295 do { |
|
5296 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5297 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5298 fwrite(rmsg,1,status,fp); |
|
5299 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5300 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
5301 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
5302 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
5303 fclose(fp); |
|
5304 |
|
5305 } |
|
5306 |
|
5307 //fetch end |
|
5308 |
|
5309 //send messge 1 -------------------------------------------- |
|
5310 |
|
5311 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5312 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5313 index=0; |
|
5314 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5315 msgHdr->message_type = ESend_Request; |
|
5316 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5317 index += sizeof( message_hdr_req ); |
|
5318 |
|
5319 |
|
5320 // adding recipient |
|
5321 len = strlen(connect_data->msg_data->recipient ); |
|
5322 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5323 index += len + 1; |
|
5324 |
|
5325 // adding recipient |
|
5326 /*len = strlen(connect_data->msg_data->recipient ); |
|
5327 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5328 index += len + 1;*/ |
|
5329 |
|
5330 smsg[index++] = '\0'; |
|
5331 |
|
5332 // adding message part |
|
5333 |
|
5334 len = strlen(connect_data->msg_data->message ); |
|
5335 strcpy( smsg + index, connect_data->msg_data->message ); |
|
5336 index += len + 1; |
|
5337 |
|
5338 |
|
5339 |
|
5340 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5341 do { |
|
5342 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5343 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5344 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5345 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
5346 |
|
5347 if ( msg_struct->response != 1) |
|
5348 { |
|
5349 return_value = KErrGeneral; |
|
5350 goto return_code; |
|
5351 } |
|
5352 |
|
5353 //send message end--------------------------------------- |
|
5354 |
|
5355 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5356 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5357 index=0; |
|
5358 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5359 msgHdr->message_type = ESend_Request; |
|
5360 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5361 index += sizeof( message_hdr_req ); |
|
5362 |
|
5363 |
|
5364 // adding recipient |
|
5365 len = strlen(connect_data->msg_data->recipient ); |
|
5366 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5367 index += len + 1; |
|
5368 |
|
5369 // adding recipient |
|
5370 /*len = strlen(connect_data->msg_data->recipient ); |
|
5371 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5372 index += len + 1;*/ |
|
5373 |
|
5374 smsg[index++] = '\0'; |
|
5375 |
|
5376 // adding message part |
|
5377 |
|
5378 len = strlen(connect_data->msg_data->message ); |
|
5379 strcpy( smsg + index, connect_data->msg_data->message ); |
|
5380 index += len + 1; |
|
5381 |
|
5382 |
|
5383 |
|
5384 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5385 do { |
|
5386 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5387 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5388 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5389 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
5390 |
|
5391 if ( msg_struct->response != 1) |
|
5392 { |
|
5393 return_value = KErrGeneral; |
|
5394 goto return_code; |
|
5395 } |
|
5396 |
|
5397 |
|
5398 // logout test code from server |
|
5399 index=0; |
|
5400 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5401 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5402 |
|
5403 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5404 |
|
5405 msgHdr->message_type = ELogout_Request; |
|
5406 |
|
5407 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5408 index += sizeof( message_hdr_req ); |
|
5409 |
|
5410 |
|
5411 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5412 do { |
|
5413 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5414 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5415 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5416 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
5417 |
|
5418 if ( msg_struct->response != 1) |
|
5419 { |
|
5420 return_value = KErrGeneral; |
|
5421 goto return_code; |
|
5422 } |
|
5423 |
|
5424 //killing isoserver |
|
5425 return_code: |
|
5426 index=0; |
|
5427 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5428 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5429 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5430 msgHdr->message_type = EKill_Process; |
|
5431 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5432 index += sizeof( message_hdr_req ); |
|
5433 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5434 free( msg_struct ); |
|
5435 return return_value; |
|
5436 } |
|
5437 |
|
5438 |
|
5439 // ----------------------------------------------------------------------------- |
|
5440 // Cisolationserver::Send message |
|
5441 // Example test method function. |
|
5442 // (other items were commented in a header). |
|
5443 // ----------------------------------------------------------------------------- |
|
5444 // |
|
5445 TInt Cisolationserver::SendTextMessageToBlockedUser( CStifItemParser& aItem ) |
|
5446 { |
|
5447 |
|
5448 |
|
5449 ConnectData *connect_data = NULL; |
|
5450 char smsg[MAX_MSG_SIZE]; |
|
5451 char rmsg[MAX_MSG_SIZE]; |
|
5452 int index=0; |
|
5453 FILE *fp; |
|
5454 |
|
5455 int timeout = 200; |
|
5456 int nBytes; |
|
5457 |
|
5458 int result = 0; |
|
5459 int err = 0; |
|
5460 int status = 0; |
|
5461 message_hdr_req *msgHdr = NULL; |
|
5462 message_hdr_resp* msg_struct = NULL; |
|
5463 TInt return_value = 0; |
|
5464 // Read data from the CFG file |
|
5465 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
5466 { |
|
5467 iLog->Log ( _L ( "read_data failed" ) ); |
|
5468 free_data ( connect_data ); |
|
5469 return_value = KErrGeneral; |
|
5470 goto return_code; |
|
5471 } |
|
5472 //request formation |
|
5473 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5474 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5475 |
|
5476 //message header use |
|
5477 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
5478 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5479 |
|
5480 msgHdr->message_type = ELogin_Request; |
|
5481 |
|
5482 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5483 index += sizeof( message_hdr_req ); |
|
5484 |
|
5485 int len = strlen(connect_data->username); |
|
5486 strcpy( smsg + index, connect_data->username ); |
|
5487 index += len + 1; |
|
5488 |
|
5489 //appending password |
|
5490 |
|
5491 len = strlen(connect_data->password ); |
|
5492 strcpy( smsg + index, connect_data->password ); |
|
5493 index += len + 1; |
|
5494 |
|
5495 //appending server name |
|
5496 |
|
5497 len = strlen(connect_data->server ); |
|
5498 strcpy( smsg + index, connect_data->server ); |
|
5499 index += len + 1; |
|
5500 |
|
5501 //appending resource |
|
5502 len = strlen(connect_data->resource ); |
|
5503 strcpy( smsg + index, connect_data->resource ); |
|
5504 index += len + 1; |
|
5505 |
|
5506 //appending ssl |
|
5507 smsg[index++]= '1'; |
|
5508 smsg[index++]= '\0'; |
|
5509 |
|
5510 //appending server port |
|
5511 len = strlen(connect_data->port ); |
|
5512 strcpy( smsg + index, connect_data->port ); |
|
5513 index += len + 1; |
|
5514 |
|
5515 // appending IAP id |
|
5516 |
|
5517 smsg[index++]= '1'; |
|
5518 smsg[index++]= '\0'; |
|
5519 |
|
5520 //appending connmgr_bus |
|
5521 len = strlen(connect_data->connmgr_bus ); |
|
5522 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
5523 index += len + 1; |
|
5524 |
|
5525 //appending connmgr_path |
|
5526 len = strlen(connect_data->connmgr_path ); |
|
5527 strcpy( smsg + index, connect_data->connmgr_path ); |
|
5528 index += len + 1; |
|
5529 |
|
5530 //appending protocol |
|
5531 len = strlen(connect_data->protocol ); |
|
5532 strcpy( smsg + index, connect_data->protocol ); |
|
5533 index += len + 1; |
|
5534 |
|
5535 #ifdef __WINSCW__ |
|
5536 //proxy server |
|
5537 len = strlen(connect_data->proxy_data->proxy_server ); |
|
5538 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
5539 index += len + 1; |
|
5540 |
|
5541 //proxy port |
|
5542 len = strlen(connect_data->proxy_data->proxy_port ); |
|
5543 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
5544 index += len + 1; |
|
5545 |
|
5546 #endif |
|
5547 //running isoserver |
|
5548 run_isoserver(); |
|
5549 |
|
5550 |
|
5551 |
|
5552 //create message queue for send request |
|
5553 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5554 //create message queue for response request |
|
5555 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5556 |
|
5557 |
|
5558 /* Send Message to queueOne */ |
|
5559 |
|
5560 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5561 |
|
5562 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
5563 |
|
5564 if (status < 0) |
|
5565 { |
|
5566 return_value = KErrGeneral; |
|
5567 goto return_code; |
|
5568 } |
|
5569 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
5570 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
5571 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5572 |
|
5573 if( msg_struct->response != 1) |
|
5574 { |
|
5575 return_value = KErrGeneral; |
|
5576 goto return_code; |
|
5577 } |
|
5578 |
|
5579 |
|
5580 // login end |
|
5581 |
|
5582 //fetch req.. |
|
5583 for (int i= 0 ;i<3 ;i++) |
|
5584 { |
|
5585 |
|
5586 fp = fopen("c:\\fetch_contact.txt","a"); |
|
5587 do { |
|
5588 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5589 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5590 fwrite(rmsg,1,status,fp); |
|
5591 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5592 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
5593 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
5594 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
5595 fclose(fp); |
|
5596 |
|
5597 } |
|
5598 |
|
5599 //fetch end |
|
5600 //send messge-------------------------------------------- |
|
5601 |
|
5602 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5603 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5604 index=0; |
|
5605 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5606 msgHdr->message_type = ESend_Request; |
|
5607 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5608 index += sizeof( message_hdr_req ); |
|
5609 |
|
5610 |
|
5611 // adding recipient |
|
5612 len = strlen(connect_data->msg_data->recipient ); |
|
5613 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5614 index += len + 1; |
|
5615 |
|
5616 // adding recipient |
|
5617 /*len = strlen(connect_data->msg_data->recipient ); |
|
5618 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5619 index += len + 1;*/ |
|
5620 |
|
5621 smsg[index++] = '\0'; |
|
5622 |
|
5623 // adding message part |
|
5624 |
|
5625 len = strlen(connect_data->msg_data->message ); |
|
5626 strcpy( smsg + index, connect_data->msg_data->message ); |
|
5627 index += len + 1; |
|
5628 |
|
5629 |
|
5630 |
|
5631 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5632 do { |
|
5633 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5634 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5635 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5636 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
5637 |
|
5638 if ( msg_struct->response != 1) |
|
5639 { |
|
5640 return_value = KErrGeneral; |
|
5641 goto return_code; |
|
5642 } |
|
5643 |
|
5644 |
|
5645 //send message end--------------------------------------- |
|
5646 |
|
5647 |
|
5648 // logout test code from server |
|
5649 index=0; |
|
5650 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5651 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5652 |
|
5653 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5654 |
|
5655 msgHdr->message_type = ELogout_Request; |
|
5656 |
|
5657 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5658 index += sizeof( message_hdr_req ); |
|
5659 |
|
5660 |
|
5661 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5662 do { |
|
5663 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5664 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5665 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5666 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
5667 |
|
5668 if ( msg_struct->response != 1) |
|
5669 { |
|
5670 return_value = KErrGeneral; |
|
5671 goto return_code; |
|
5672 } |
|
5673 //killing isoserver |
|
5674 return_code: |
|
5675 index=0; |
|
5676 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5677 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5678 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5679 msgHdr->message_type = EKill_Process; |
|
5680 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5681 index += sizeof( message_hdr_req ); |
|
5682 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5683 free( msg_struct ); |
|
5684 return return_value; |
|
5685 } |
|
5686 |
|
5687 // ----------------------------------------------------------------------------- |
|
5688 // Cisolationserver::Send message |
|
5689 // Example test method function. |
|
5690 // (other items were commented in a header). |
|
5691 // ----------------------------------------------------------------------------- |
|
5692 // |
|
5693 TInt Cisolationserver::SendTextMessageToUserIdWhoIsBlockedSender( CStifItemParser& aItem ) |
|
5694 { |
|
5695 |
|
5696 |
|
5697 ConnectData *connect_data = NULL; |
|
5698 char smsg[MAX_MSG_SIZE]; |
|
5699 char rmsg[MAX_MSG_SIZE]; |
|
5700 int index=0; |
|
5701 FILE *fp; |
|
5702 |
|
5703 int timeout = 200; |
|
5704 int nBytes; |
|
5705 |
|
5706 int result = 0; |
|
5707 int err = 0; |
|
5708 int status = 0; |
|
5709 message_hdr_req *msgHdr = NULL; |
|
5710 message_hdr_resp* msg_struct = NULL; |
|
5711 TInt return_value = 0; |
|
5712 // Read data from the CFG file |
|
5713 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
5714 { |
|
5715 iLog->Log ( _L ( "read_data failed" ) ); |
|
5716 free_data ( connect_data ); |
|
5717 return_value = KErrGeneral; |
|
5718 goto return_code; |
|
5719 } |
|
5720 //request formation |
|
5721 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5722 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5723 |
|
5724 //message header use |
|
5725 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
5726 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5727 |
|
5728 msgHdr->message_type = ELogin_Request; |
|
5729 |
|
5730 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5731 index += sizeof( message_hdr_req ); |
|
5732 |
|
5733 int len = strlen(connect_data->username); |
|
5734 strcpy( smsg + index, connect_data->username ); |
|
5735 index += len + 1; |
|
5736 |
|
5737 //appending password |
|
5738 |
|
5739 len = strlen(connect_data->password ); |
|
5740 strcpy( smsg + index, connect_data->password ); |
|
5741 index += len + 1; |
|
5742 |
|
5743 //appending server name |
|
5744 |
|
5745 len = strlen(connect_data->server ); |
|
5746 strcpy( smsg + index, connect_data->server ); |
|
5747 index += len + 1; |
|
5748 |
|
5749 //appending resource |
|
5750 len = strlen(connect_data->resource ); |
|
5751 strcpy( smsg + index, connect_data->resource ); |
|
5752 index += len + 1; |
|
5753 |
|
5754 //appending ssl |
|
5755 smsg[index++]= '1'; |
|
5756 smsg[index++]= '\0'; |
|
5757 |
|
5758 //appending server port |
|
5759 len = strlen(connect_data->port ); |
|
5760 strcpy( smsg + index, connect_data->port ); |
|
5761 index += len + 1; |
|
5762 |
|
5763 // appending IAP id |
|
5764 |
|
5765 smsg[index++]= '1'; |
|
5766 smsg[index++]= '\0'; |
|
5767 |
|
5768 //appending connmgr_bus |
|
5769 len = strlen(connect_data->connmgr_bus ); |
|
5770 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
5771 index += len + 1; |
|
5772 |
|
5773 //appending connmgr_path |
|
5774 len = strlen(connect_data->connmgr_path ); |
|
5775 strcpy( smsg + index, connect_data->connmgr_path ); |
|
5776 index += len + 1; |
|
5777 |
|
5778 //appending protocol |
|
5779 len = strlen(connect_data->protocol ); |
|
5780 strcpy( smsg + index, connect_data->protocol ); |
|
5781 index += len + 1; |
|
5782 |
|
5783 #ifdef __WINSCW__ |
|
5784 //proxy server |
|
5785 len = strlen(connect_data->proxy_data->proxy_server ); |
|
5786 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
5787 index += len + 1; |
|
5788 |
|
5789 //proxy port |
|
5790 len = strlen(connect_data->proxy_data->proxy_port ); |
|
5791 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
5792 index += len + 1; |
|
5793 |
|
5794 #endif |
|
5795 //running isoserver |
|
5796 run_isoserver(); |
|
5797 |
|
5798 |
|
5799 |
|
5800 //create message queue for send request |
|
5801 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5802 //create message queue for response request |
|
5803 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
5804 |
|
5805 |
|
5806 /* Send Message to queueOne */ |
|
5807 |
|
5808 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5809 |
|
5810 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
5811 |
|
5812 if (status < 0) |
|
5813 { |
|
5814 return_value = KErrGeneral; |
|
5815 goto return_code; |
|
5816 } |
|
5817 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
5818 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
5819 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5820 |
|
5821 if( msg_struct->response != 1) |
|
5822 { |
|
5823 return_value = KErrGeneral; |
|
5824 goto return_code; |
|
5825 } |
|
5826 |
|
5827 |
|
5828 // login end |
|
5829 |
|
5830 //fetch req.. |
|
5831 for (int i= 0 ;i<3 ;i++) |
|
5832 { |
|
5833 |
|
5834 fp = fopen("c:\\fetch_contact.txt","a"); |
|
5835 do { |
|
5836 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5837 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5838 fwrite(rmsg,1,status,fp); |
|
5839 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5840 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
5841 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
5842 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
5843 fclose(fp); |
|
5844 |
|
5845 } |
|
5846 |
|
5847 //fetch end |
|
5848 //send messge-------------------------------------------- |
|
5849 |
|
5850 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5851 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5852 index=0; |
|
5853 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5854 msgHdr->message_type = ESend_Request; |
|
5855 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5856 index += sizeof( message_hdr_req ); |
|
5857 |
|
5858 |
|
5859 // adding recipient |
|
5860 len = strlen(connect_data->msg_data->recipient ); |
|
5861 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5862 index += len + 1; |
|
5863 |
|
5864 // adding recipient |
|
5865 /*len = strlen(connect_data->msg_data->recipient ); |
|
5866 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
5867 index += len + 1;*/ |
|
5868 |
|
5869 smsg[index++] = '\0'; |
|
5870 |
|
5871 // adding message part |
|
5872 |
|
5873 len = strlen(connect_data->msg_data->message ); |
|
5874 strcpy( smsg + index, connect_data->msg_data->message ); |
|
5875 index += len + 1; |
|
5876 |
|
5877 |
|
5878 |
|
5879 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5880 do { |
|
5881 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5882 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5883 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5884 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
5885 |
|
5886 if ( msg_struct->response != 1) |
|
5887 { |
|
5888 return_value = KErrGeneral; |
|
5889 goto return_code; |
|
5890 } |
|
5891 |
|
5892 |
|
5893 //send message end--------------------------------------- |
|
5894 |
|
5895 |
|
5896 // logout test code from server |
|
5897 index=0; |
|
5898 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5899 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5900 |
|
5901 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5902 |
|
5903 msgHdr->message_type = ELogout_Request; |
|
5904 |
|
5905 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5906 index += sizeof( message_hdr_req ); |
|
5907 |
|
5908 |
|
5909 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5910 do { |
|
5911 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
5912 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
5913 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5914 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
5915 |
|
5916 if ( msg_struct->response != 1) |
|
5917 { |
|
5918 return_value = KErrGeneral; |
|
5919 goto return_code; |
|
5920 } |
|
5921 //killing isoserver |
|
5922 return_code: |
|
5923 index=0; |
|
5924 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5925 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5926 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5927 msgHdr->message_type = EKill_Process; |
|
5928 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5929 index += sizeof( message_hdr_req ); |
|
5930 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
5931 free( msg_struct ); |
|
5932 return return_value; |
|
5933 } |
|
5934 |
|
5935 // ----------------------------------------------------------------------------- |
|
5936 // Cisolationserver::Send message |
|
5937 // Example test method function. |
|
5938 // (other items were commented in a header). |
|
5939 // ----------------------------------------------------------------------------- |
|
5940 // |
|
5941 TInt Cisolationserver::SendLongTextMessageToUserId( CStifItemParser& aItem ) |
|
5942 { |
|
5943 |
|
5944 |
|
5945 ConnectData *connect_data = NULL; |
|
5946 char smsg[MAX_MSG_SIZE]; |
|
5947 char rmsg[MAX_MSG_SIZE]; |
|
5948 int index=0; |
|
5949 FILE *fp; |
|
5950 |
|
5951 int timeout = 200; |
|
5952 int nBytes; |
|
5953 |
|
5954 int result = 0; |
|
5955 int err = 0; |
|
5956 int status = 0; |
|
5957 message_hdr_req *msgHdr = NULL; |
|
5958 message_hdr_resp* msg_struct = NULL; |
|
5959 TInt return_value = 0; |
|
5960 // Read data from the CFG file |
|
5961 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
5962 { |
|
5963 iLog->Log ( _L ( "read_data failed" ) ); |
|
5964 free_data ( connect_data ); |
|
5965 return_value = KErrGeneral; |
|
5966 goto return_code; |
|
5967 } |
|
5968 //request formation |
|
5969 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
5970 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
5971 |
|
5972 //message header use |
|
5973 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
5974 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
5975 |
|
5976 msgHdr->message_type = ELogin_Request; |
|
5977 |
|
5978 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
5979 index += sizeof( message_hdr_req ); |
|
5980 |
|
5981 int len = strlen(connect_data->username); |
|
5982 strcpy( smsg + index, connect_data->username ); |
|
5983 index += len + 1; |
|
5984 |
|
5985 //appending password |
|
5986 |
|
5987 len = strlen(connect_data->password ); |
|
5988 strcpy( smsg + index, connect_data->password ); |
|
5989 index += len + 1; |
|
5990 |
|
5991 //appending server name |
|
5992 |
|
5993 len = strlen(connect_data->server ); |
|
5994 strcpy( smsg + index, connect_data->server ); |
|
5995 index += len + 1; |
|
5996 |
|
5997 //appending resource |
|
5998 len = strlen(connect_data->resource ); |
|
5999 strcpy( smsg + index, connect_data->resource ); |
|
6000 index += len + 1; |
|
6001 |
|
6002 //appending ssl |
|
6003 smsg[index++]= '1'; |
|
6004 smsg[index++]= '\0'; |
|
6005 |
|
6006 //appending server port |
|
6007 len = strlen(connect_data->port ); |
|
6008 strcpy( smsg + index, connect_data->port ); |
|
6009 index += len + 1; |
|
6010 |
|
6011 // appending IAP id |
|
6012 |
|
6013 smsg[index++]= '1'; |
|
6014 smsg[index++]= '\0'; |
|
6015 |
|
6016 //appending connmgr_bus |
|
6017 len = strlen(connect_data->connmgr_bus ); |
|
6018 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
6019 index += len + 1; |
|
6020 |
|
6021 //appending connmgr_path |
|
6022 len = strlen(connect_data->connmgr_path ); |
|
6023 strcpy( smsg + index, connect_data->connmgr_path ); |
|
6024 index += len + 1; |
|
6025 |
|
6026 //appending protocol |
|
6027 len = strlen(connect_data->protocol ); |
|
6028 strcpy( smsg + index, connect_data->protocol ); |
|
6029 index += len + 1; |
|
6030 |
|
6031 #ifdef __WINSCW__ |
|
6032 //proxy server |
|
6033 len = strlen(connect_data->proxy_data->proxy_server ); |
|
6034 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
6035 index += len + 1; |
|
6036 |
|
6037 //proxy port |
|
6038 len = strlen(connect_data->proxy_data->proxy_port ); |
|
6039 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
6040 index += len + 1; |
|
6041 |
|
6042 #endif |
|
6043 |
|
6044 run_isoserver(); |
|
6045 |
|
6046 |
|
6047 //create message queue for send request |
|
6048 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6049 //create message queue for response request |
|
6050 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6051 |
|
6052 |
|
6053 /* Send Message to queueOne */ |
|
6054 |
|
6055 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6056 |
|
6057 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
6058 |
|
6059 if (status < 0) |
|
6060 { |
|
6061 return_value = KErrGeneral; |
|
6062 goto return_code; |
|
6063 } |
|
6064 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
6065 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
6066 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6067 |
|
6068 if( msg_struct->response != 1) |
|
6069 { |
|
6070 return_value = KErrGeneral; |
|
6071 goto return_code; |
|
6072 } |
|
6073 |
|
6074 |
|
6075 // login end |
|
6076 //fetch req.. |
|
6077 for (int i= 0 ;i<3 ;i++) |
|
6078 { |
|
6079 |
|
6080 fp = fopen("c:\\fetch_contact.txt","a"); |
|
6081 do { |
|
6082 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6083 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6084 fwrite(rmsg,1,status,fp); |
|
6085 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6086 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
6087 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
6088 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
6089 fclose(fp); |
|
6090 |
|
6091 } |
|
6092 |
|
6093 //fetch end |
|
6094 |
|
6095 //send messge-------------------------------------------- |
|
6096 |
|
6097 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6098 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6099 index=0; |
|
6100 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6101 msgHdr->message_type = ESend_Request; |
|
6102 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6103 index += sizeof( message_hdr_req ); |
|
6104 |
|
6105 |
|
6106 // adding recipient |
|
6107 len = strlen(connect_data->msg_data->recipient ); |
|
6108 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
6109 index += len + 1; |
|
6110 |
|
6111 // adding recipient |
|
6112 /*len = strlen(connect_data->msg_data->recipient ); |
|
6113 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
6114 index += len + 1;*/ |
|
6115 |
|
6116 smsg[index++] = '\0'; |
|
6117 |
|
6118 // adding message part |
|
6119 |
|
6120 len = strlen(connect_data->msg_data->message ); |
|
6121 strcpy( smsg + index, connect_data->msg_data->message ); |
|
6122 index += len + 1; |
|
6123 |
|
6124 |
|
6125 |
|
6126 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6127 do { |
|
6128 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6129 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6130 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6131 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
6132 |
|
6133 if ( msg_struct->response != 1) |
|
6134 { |
|
6135 return_value = KErrGeneral; |
|
6136 goto return_code; |
|
6137 } |
|
6138 |
|
6139 |
|
6140 //send message end--------------------------------------- |
|
6141 |
|
6142 |
|
6143 // logout test code from server |
|
6144 index=0; |
|
6145 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6146 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6147 |
|
6148 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6149 |
|
6150 msgHdr->message_type = ELogout_Request; |
|
6151 |
|
6152 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6153 index += sizeof( message_hdr_req ); |
|
6154 |
|
6155 |
|
6156 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6157 do { |
|
6158 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6159 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6160 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6161 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
6162 |
|
6163 if ( msg_struct->response != 1) |
|
6164 { |
|
6165 return_value = KErrGeneral; |
|
6166 goto return_code; |
|
6167 } |
|
6168 |
|
6169 //killing isoserver |
|
6170 return_code: |
|
6171 index=0; |
|
6172 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6173 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6174 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6175 msgHdr->message_type = EKill_Process; |
|
6176 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6177 index += sizeof( message_hdr_req ); |
|
6178 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6179 free( msg_struct ); |
|
6180 return return_value; |
|
6181 } |
|
6182 |
|
6183 // ----------------------------------------------------------------------------- |
|
6184 // Cisolationserver::Send message |
|
6185 // Example test method function. |
|
6186 // (other items were commented in a header). |
|
6187 // ----------------------------------------------------------------------------- |
|
6188 // |
|
6189 TInt Cisolationserver::SendTextMessageUserWhoIsNotAddedInContactList( CStifItemParser& aItem ) |
|
6190 { |
|
6191 |
|
6192 |
|
6193 ConnectData *connect_data = NULL; |
|
6194 char smsg[MAX_MSG_SIZE]; |
|
6195 char rmsg[MAX_MSG_SIZE]; |
|
6196 int index=0; |
|
6197 FILE *fp; |
|
6198 |
|
6199 int timeout = 200; |
|
6200 int nBytes; |
|
6201 |
|
6202 int result = 0; |
|
6203 int err = 0; |
|
6204 int status = 0; |
|
6205 message_hdr_req *msgHdr = NULL; |
|
6206 message_hdr_resp* msg_struct = NULL; |
|
6207 TInt return_value = 0; |
|
6208 // Read data from the CFG file |
|
6209 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
6210 { |
|
6211 iLog->Log ( _L ( "read_data failed" ) ); |
|
6212 free_data ( connect_data ); |
|
6213 return_value = KErrGeneral; |
|
6214 goto return_code; |
|
6215 } |
|
6216 //request formation |
|
6217 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6218 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6219 |
|
6220 //message header use |
|
6221 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
6222 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6223 |
|
6224 msgHdr->message_type = ELogin_Request; |
|
6225 |
|
6226 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6227 index += sizeof( message_hdr_req ); |
|
6228 |
|
6229 int len = strlen(connect_data->username); |
|
6230 strcpy( smsg + index, connect_data->username ); |
|
6231 index += len + 1; |
|
6232 |
|
6233 //appending password |
|
6234 |
|
6235 len = strlen(connect_data->password ); |
|
6236 strcpy( smsg + index, connect_data->password ); |
|
6237 index += len + 1; |
|
6238 |
|
6239 //appending server name |
|
6240 |
|
6241 len = strlen(connect_data->server ); |
|
6242 strcpy( smsg + index, connect_data->server ); |
|
6243 index += len + 1; |
|
6244 |
|
6245 //appending resource |
|
6246 len = strlen(connect_data->resource ); |
|
6247 strcpy( smsg + index, connect_data->resource ); |
|
6248 index += len + 1; |
|
6249 |
|
6250 //appending ssl |
|
6251 smsg[index++]= '1'; |
|
6252 smsg[index++]= '\0'; |
|
6253 |
|
6254 //appending server port |
|
6255 len = strlen(connect_data->port ); |
|
6256 strcpy( smsg + index, connect_data->port ); |
|
6257 index += len + 1; |
|
6258 |
|
6259 // appending IAP id |
|
6260 |
|
6261 smsg[index++]= '1'; |
|
6262 smsg[index++]= '\0'; |
|
6263 |
|
6264 //appending connmgr_bus |
|
6265 len = strlen(connect_data->connmgr_bus ); |
|
6266 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
6267 index += len + 1; |
|
6268 |
|
6269 //appending connmgr_path |
|
6270 len = strlen(connect_data->connmgr_path ); |
|
6271 strcpy( smsg + index, connect_data->connmgr_path ); |
|
6272 index += len + 1; |
|
6273 |
|
6274 //appending protocol |
|
6275 len = strlen(connect_data->protocol ); |
|
6276 strcpy( smsg + index, connect_data->protocol ); |
|
6277 index += len + 1; |
|
6278 |
|
6279 #ifdef __WINSCW__ |
|
6280 //proxy server |
|
6281 len = strlen(connect_data->proxy_data->proxy_server ); |
|
6282 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
6283 index += len + 1; |
|
6284 |
|
6285 //proxy port |
|
6286 len = strlen(connect_data->proxy_data->proxy_port ); |
|
6287 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
6288 index += len + 1; |
|
6289 |
|
6290 #endif |
|
6291 //running isoserver |
|
6292 run_isoserver(); |
|
6293 |
|
6294 |
|
6295 |
|
6296 //create message queue for send request |
|
6297 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6298 //create message queue for response request |
|
6299 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6300 |
|
6301 |
|
6302 /* Send Message to queueOne */ |
|
6303 |
|
6304 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6305 |
|
6306 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
6307 |
|
6308 if (status < 0) |
|
6309 { |
|
6310 return_value = KErrGeneral; |
|
6311 goto return_code; |
|
6312 } |
|
6313 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
6314 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
6315 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6316 |
|
6317 if( msg_struct->response != 1) |
|
6318 { |
|
6319 return_value = KErrGeneral; |
|
6320 goto return_code; |
|
6321 } |
|
6322 |
|
6323 |
|
6324 // login end |
|
6325 |
|
6326 //fetch req.. |
|
6327 for (int i= 0 ;i<3 ;i++) |
|
6328 { |
|
6329 |
|
6330 fp = fopen("c:\\fetch_contact.txt","a"); |
|
6331 do { |
|
6332 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6333 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6334 fwrite(rmsg,1,status,fp); |
|
6335 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6336 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
6337 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
6338 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
6339 fclose(fp); |
|
6340 |
|
6341 } |
|
6342 |
|
6343 //fetch end |
|
6344 //send messge-------------------------------------------- |
|
6345 |
|
6346 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6347 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6348 index=0; |
|
6349 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6350 msgHdr->message_type = ESend_Request; |
|
6351 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6352 index += sizeof( message_hdr_req ); |
|
6353 |
|
6354 |
|
6355 // adding recipient |
|
6356 len = strlen(connect_data->msg_data->recipient ); |
|
6357 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
6358 index += len + 1; |
|
6359 |
|
6360 // adding recipient |
|
6361 /*len = strlen(connect_data->msg_data->recipient ); |
|
6362 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
6363 index += len + 1;*/ |
|
6364 |
|
6365 smsg[index++] = '\0'; |
|
6366 |
|
6367 // adding message part |
|
6368 |
|
6369 len = strlen(connect_data->msg_data->message ); |
|
6370 strcpy( smsg + index, connect_data->msg_data->message ); |
|
6371 index += len + 1; |
|
6372 |
|
6373 |
|
6374 |
|
6375 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6376 do { |
|
6377 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6378 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6379 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6380 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
6381 |
|
6382 if ( msg_struct->response != 1) |
|
6383 { |
|
6384 return_value = KErrGeneral; |
|
6385 goto return_code; |
|
6386 } |
|
6387 |
|
6388 |
|
6389 //send message end--------------------------------------- |
|
6390 |
|
6391 |
|
6392 // logout test code from server |
|
6393 index=0; |
|
6394 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6395 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6396 |
|
6397 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6398 |
|
6399 msgHdr->message_type = ELogout_Request; |
|
6400 |
|
6401 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6402 index += sizeof( message_hdr_req ); |
|
6403 |
|
6404 |
|
6405 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6406 do { |
|
6407 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6408 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6409 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6410 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
6411 |
|
6412 if ( msg_struct->response != 1) |
|
6413 { |
|
6414 return_value = KErrGeneral; |
|
6415 goto return_code; |
|
6416 } |
|
6417 |
|
6418 //killing isoserver |
|
6419 return_code: |
|
6420 index=0; |
|
6421 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6422 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6423 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6424 msgHdr->message_type = EKill_Process; |
|
6425 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6426 index += sizeof( message_hdr_req ); |
|
6427 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6428 free( msg_struct ); |
|
6429 return return_value; |
|
6430 } |
|
6431 |
|
6432 |
|
6433 |
|
6434 // ----------------------------------------------------------------------------- |
|
6435 // Cisolationserver::Login with correct data |
|
6436 // Example test method function. |
|
6437 // (other items were commented in a header). |
|
6438 // ----------------------------------------------------------------------------- |
|
6439 // |
|
6440 TInt Cisolationserver::MessageReceiveFromUser( CStifItemParser& aItem ) |
|
6441 { |
|
6442 |
|
6443 |
|
6444 ConnectData *connect_data = NULL; |
|
6445 char smsg[MAX_MSG_SIZE]; |
|
6446 char rmsg[MAX_MSG_SIZE]; |
|
6447 int index=0; |
|
6448 int i=0; |
|
6449 int msglen=0; |
|
6450 int timeout = 100; |
|
6451 int nBytes; |
|
6452 |
|
6453 int result = 0; |
|
6454 int err = 0; |
|
6455 int status = 0; |
|
6456 FILE *fp ; |
|
6457 message_hdr_req *msgHdr = NULL; |
|
6458 message_hdr_resp* msg_struct = NULL; |
|
6459 fp = fopen("c:\\receive_message_logs.txt","a");TInt return_value = 0; |
|
6460 // Read data from the CFG file |
|
6461 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
6462 { |
|
6463 iLog->Log ( _L ( "read_data failed" ) ); |
|
6464 free_data ( connect_data ); |
|
6465 return_value = KErrGeneral; |
|
6466 goto return_code; |
|
6467 } |
|
6468 //request formation |
|
6469 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6470 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6471 |
|
6472 //message header use |
|
6473 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
6474 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6475 |
|
6476 msgHdr->message_type = ELogin_Request; |
|
6477 |
|
6478 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6479 index += sizeof( message_hdr_req ); |
|
6480 |
|
6481 int len = strlen(connect_data->username); |
|
6482 strcpy( smsg + index, connect_data->username ); |
|
6483 index += len + 1; |
|
6484 |
|
6485 //appending password |
|
6486 |
|
6487 len = strlen(connect_data->password ); |
|
6488 strcpy( smsg + index, connect_data->password ); |
|
6489 index += len + 1; |
|
6490 |
|
6491 //appending server name |
|
6492 |
|
6493 len = strlen(connect_data->server ); |
|
6494 strcpy( smsg + index, connect_data->server ); |
|
6495 index += len + 1; |
|
6496 |
|
6497 //appending resource |
|
6498 len = strlen(connect_data->resource ); |
|
6499 strcpy( smsg + index, connect_data->resource ); |
|
6500 index += len + 1; |
|
6501 |
|
6502 //appending ssl |
|
6503 smsg[index++]= '1'; |
|
6504 smsg[index++]= '\0'; |
|
6505 |
|
6506 //appending server port |
|
6507 len = strlen(connect_data->port ); |
|
6508 strcpy( smsg + index, connect_data->port ); |
|
6509 index += len + 1; |
|
6510 |
|
6511 // appending IAP id |
|
6512 |
|
6513 smsg[index++]= '1'; |
|
6514 smsg[index++]= '\0'; |
|
6515 |
|
6516 //appending connmgr_bus |
|
6517 len = strlen(connect_data->connmgr_bus ); |
|
6518 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
6519 index += len + 1; |
|
6520 |
|
6521 //appending connmgr_path |
|
6522 len = strlen(connect_data->connmgr_path ); |
|
6523 strcpy( smsg + index, connect_data->connmgr_path ); |
|
6524 index += len + 1; |
|
6525 |
|
6526 //appending protocol |
|
6527 len = strlen(connect_data->protocol ); |
|
6528 strcpy( smsg + index, connect_data->protocol ); |
|
6529 index += len + 1; |
|
6530 |
|
6531 #ifdef __WINSCW__ |
|
6532 //proxy server |
|
6533 len = strlen(connect_data->proxy_data->proxy_server ); |
|
6534 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
6535 index += len + 1; |
|
6536 |
|
6537 //proxy port |
|
6538 len = strlen(connect_data->proxy_data->proxy_port ); |
|
6539 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
6540 index += len + 1; |
|
6541 |
|
6542 #endif |
|
6543 // running isoserver |
|
6544 run_isoserver(); |
|
6545 |
|
6546 |
|
6547 //create message queue for send request |
|
6548 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6549 //create message queue for response request |
|
6550 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6551 |
|
6552 |
|
6553 /* Send Message to queueOne */ |
|
6554 |
|
6555 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6556 |
|
6557 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
6558 |
|
6559 if (status < 0) |
|
6560 { |
|
6561 return_value = KErrGeneral; |
|
6562 goto return_code; |
|
6563 } |
|
6564 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
6565 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
6566 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6567 |
|
6568 if( msg_struct->response != 1) |
|
6569 { |
|
6570 return_value = KErrGeneral; |
|
6571 goto return_code; |
|
6572 } |
|
6573 |
|
6574 //fetch req.. |
|
6575 for (int i= 0 ;i<3 ;i++) |
|
6576 { |
|
6577 |
|
6578 fp = fopen("c:\\fetch_contact.txt","a"); |
|
6579 do { |
|
6580 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6581 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6582 fwrite(rmsg,1,status,fp); |
|
6583 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6584 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
6585 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
6586 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
6587 fclose(fp); |
|
6588 |
|
6589 } |
|
6590 |
|
6591 //fetch end |
|
6592 |
|
6593 |
|
6594 //send messge to our self-------------------------------------------- |
|
6595 |
|
6596 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6597 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6598 index=0; |
|
6599 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6600 msgHdr->message_type = ESend_Request; |
|
6601 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6602 index += sizeof( message_hdr_req ); |
|
6603 TBool ESend = EFalse , EReceive = EFalse; |
|
6604 |
|
6605 // adding recipient |
|
6606 len = strlen(connect_data->msg_data->recipient ); |
|
6607 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
6608 index += len + 1; |
|
6609 |
|
6610 // adding recipient |
|
6611 /*len = strlen(connect_data->msg_data->recipient ); |
|
6612 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
6613 index += len + 1;*/ |
|
6614 |
|
6615 smsg[index++] = '\0'; |
|
6616 |
|
6617 // adding message part |
|
6618 |
|
6619 len = strlen(connect_data->msg_data->message ); |
|
6620 strcpy( smsg + index, connect_data->msg_data->message ); |
|
6621 index += len + 1; |
|
6622 |
|
6623 |
|
6624 |
|
6625 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6626 do { |
|
6627 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6628 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6629 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6630 if(msg_struct->hdr_req.message_type==ESend_Request) |
|
6631 ESend=ETrue; |
|
6632 if(msg_struct->hdr_req.message_type==EText_Message_Receive) |
|
6633 ESend=ETrue; |
|
6634 } while (ESend/* == ETrue */&& EReceive/* ==ETrue*/) ;//(msg_struct->hdr_req.message_type!=ESend_Request); |
|
6635 |
|
6636 /* if ( msg_struct->response != 1) |
|
6637 { |
|
6638 return_value = KErrGeneral; |
|
6639 goto return_code; |
|
6640 } |
|
6641 |
|
6642 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6643 //wait for message receive |
|
6644 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
6645 if (status < 0) |
|
6646 { |
|
6647 return_value = KErrGeneral; |
|
6648 goto return_code; |
|
6649 } |
|
6650 fprintf( fp, "receive message %s\n", rmsg+24 ); |
|
6651 |
|
6652 for ( i=24 ; i <rmsg[i]!='\0';i++) |
|
6653 msglen++; |
|
6654 fprintf( fp, "receive message %s\n", rmsg+24+msglen+1 ); |
|
6655 */ |
|
6656 |
|
6657 // login end |
|
6658 // logout test code from server |
|
6659 index=0; |
|
6660 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6661 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6662 |
|
6663 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6664 |
|
6665 msgHdr->message_type = ELogout_Request; |
|
6666 |
|
6667 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6668 index += sizeof( message_hdr_req ); |
|
6669 |
|
6670 |
|
6671 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6672 do { |
|
6673 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6674 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6675 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6676 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
6677 |
|
6678 if ( msg_struct->response != 1) |
|
6679 { |
|
6680 return_value = KErrGeneral; |
|
6681 goto return_code; |
|
6682 } |
|
6683 |
|
6684 //killing isoserver |
|
6685 return_code: |
|
6686 index=0; |
|
6687 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6688 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6689 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6690 msgHdr->message_type = EKill_Process; |
|
6691 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6692 index += sizeof( message_hdr_req ); |
|
6693 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6694 free( msg_struct ); |
|
6695 return return_value; |
|
6696 |
|
6697 } |
|
6698 |
|
6699 |
|
6700 // ----------------------------------------------------------------------------- |
|
6701 // Cisolationserver::add member message |
|
6702 // Example test method function. |
|
6703 // (other items were commented in a header). |
|
6704 // ----------------------------------------------------------------------------- |
|
6705 // |
|
6706 TInt Cisolationserver::AddExistingContact( CStifItemParser& aItem ) |
|
6707 { |
|
6708 |
|
6709 |
|
6710 ConnectData *connect_data = NULL; |
|
6711 char smsg[MAX_MSG_SIZE]; |
|
6712 char rmsg[MAX_MSG_SIZE]; |
|
6713 int index=0; |
|
6714 FILE *fp; |
|
6715 |
|
6716 int timeout = 200; |
|
6717 int nBytes; |
|
6718 |
|
6719 int result = 0; |
|
6720 int err = 0; |
|
6721 int status = 0; |
|
6722 message_hdr_req *msgHdr = NULL; |
|
6723 message_hdr_resp* msg_struct = NULL; |
|
6724 TInt return_value = 0; |
|
6725 // Read data from the CFG file |
|
6726 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
6727 { |
|
6728 iLog->Log ( _L ( "read_data failed" ) ); |
|
6729 free_data ( connect_data ); |
|
6730 return_value = KErrGeneral; |
|
6731 goto return_code; |
|
6732 } |
|
6733 //request formation |
|
6734 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6735 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6736 |
|
6737 //message header use |
|
6738 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
6739 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6740 |
|
6741 msgHdr->message_type = ELogin_Request; |
|
6742 |
|
6743 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6744 index += sizeof( message_hdr_req ); |
|
6745 |
|
6746 int len = strlen(connect_data->username); |
|
6747 strcpy( smsg + index, connect_data->username ); |
|
6748 index += len + 1; |
|
6749 |
|
6750 //appending password |
|
6751 |
|
6752 len = strlen(connect_data->password ); |
|
6753 strcpy( smsg + index, connect_data->password ); |
|
6754 index += len + 1; |
|
6755 |
|
6756 //appending server name |
|
6757 |
|
6758 len = strlen(connect_data->server ); |
|
6759 strcpy( smsg + index, connect_data->server ); |
|
6760 index += len + 1; |
|
6761 |
|
6762 //appending resource |
|
6763 len = strlen(connect_data->resource ); |
|
6764 strcpy( smsg + index, connect_data->resource ); |
|
6765 index += len + 1; |
|
6766 |
|
6767 //appending ssl |
|
6768 smsg[index++]= '1'; |
|
6769 smsg[index++]= '\0'; |
|
6770 |
|
6771 //appending server port |
|
6772 len = strlen(connect_data->port ); |
|
6773 strcpy( smsg + index, connect_data->port ); |
|
6774 index += len + 1; |
|
6775 |
|
6776 // appending IAP id |
|
6777 |
|
6778 smsg[index++]= '1'; |
|
6779 smsg[index++]= '\0'; |
|
6780 |
|
6781 //appending connmgr_bus |
|
6782 len = strlen(connect_data->connmgr_bus ); |
|
6783 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
6784 index += len + 1; |
|
6785 |
|
6786 //appending connmgr_path |
|
6787 len = strlen(connect_data->connmgr_path ); |
|
6788 strcpy( smsg + index, connect_data->connmgr_path ); |
|
6789 index += len + 1; |
|
6790 |
|
6791 //appending protocol |
|
6792 len = strlen(connect_data->protocol ); |
|
6793 strcpy( smsg + index, connect_data->protocol ); |
|
6794 index += len + 1; |
|
6795 |
|
6796 #ifdef __WINSCW__ |
|
6797 //proxy server |
|
6798 len = strlen(connect_data->proxy_data->proxy_server ); |
|
6799 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
6800 index += len + 1; |
|
6801 |
|
6802 //proxy port |
|
6803 len = strlen(connect_data->proxy_data->proxy_port ); |
|
6804 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
6805 index += len + 1; |
|
6806 |
|
6807 #endif |
|
6808 |
|
6809 //running isoserver |
|
6810 run_isoserver(); |
|
6811 |
|
6812 |
|
6813 //create message queue for send request |
|
6814 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6815 //create message queue for response request |
|
6816 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
6817 |
|
6818 |
|
6819 /* Send Message to queueOne */ |
|
6820 |
|
6821 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6822 |
|
6823 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
6824 |
|
6825 if (status < 0) |
|
6826 { |
|
6827 return_value = KErrGeneral; |
|
6828 goto return_code; |
|
6829 } |
|
6830 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
6831 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
6832 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6833 |
|
6834 if( msg_struct->response != 1) |
|
6835 { |
|
6836 return_value = KErrGeneral; |
|
6837 goto return_code; |
|
6838 } |
|
6839 |
|
6840 |
|
6841 // login end |
|
6842 |
|
6843 //fetch req.. |
|
6844 for (int i= 0 ;i<3 ;i++) |
|
6845 { |
|
6846 |
|
6847 fp = fopen("c:\\fetch_contact.txt","a"); |
|
6848 do { |
|
6849 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6850 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6851 fwrite(rmsg,1,status,fp); |
|
6852 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6853 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
6854 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
6855 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
6856 fclose(fp); |
|
6857 |
|
6858 } |
|
6859 |
|
6860 //fetch end |
|
6861 |
|
6862 |
|
6863 //adding contact -------------------------------------------- |
|
6864 |
|
6865 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6866 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6867 index=0; |
|
6868 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6869 msgHdr->message_type = EAdd_Contact_Request; |
|
6870 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6871 index += sizeof( message_hdr_req ); |
|
6872 // adding add contact |
|
6873 len = strlen(connect_data->contact ); |
|
6874 strcpy( smsg + index, connect_data->contact ); |
|
6875 index += len + 1; |
|
6876 smsg[index++]='\0'; |
|
6877 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6878 do { |
|
6879 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6880 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6881 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6882 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
6883 |
|
6884 if ( msg_struct->response != 1) |
|
6885 { |
|
6886 return_value = KErrGeneral; |
|
6887 goto return_code; |
|
6888 } |
|
6889 |
|
6890 //add contact end--------------------------------------- |
|
6891 |
|
6892 |
|
6893 // logout test code from server |
|
6894 index=0; |
|
6895 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6896 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6897 |
|
6898 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6899 |
|
6900 msgHdr->message_type = ELogout_Request; |
|
6901 |
|
6902 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6903 index += sizeof( message_hdr_req ); |
|
6904 |
|
6905 |
|
6906 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6907 do { |
|
6908 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
6909 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
6910 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6911 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
6912 |
|
6913 if ( msg_struct->response != 1) |
|
6914 { |
|
6915 return_value = KErrGeneral; |
|
6916 goto return_code; |
|
6917 } |
|
6918 //killing isoserver |
|
6919 return_code: |
|
6920 index=0; |
|
6921 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6922 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6923 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6924 msgHdr->message_type = EKill_Process; |
|
6925 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6926 index += sizeof( message_hdr_req ); |
|
6927 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
6928 free( msg_struct ); |
|
6929 return return_value; |
|
6930 } |
|
6931 |
|
6932 // ----------------------------------------------------------------------------- |
|
6933 // Cisolationserver::add member message |
|
6934 // Example test method function. |
|
6935 // (other items were commented in a header). |
|
6936 // ----------------------------------------------------------------------------- |
|
6937 // |
|
6938 TInt Cisolationserver::AddUnexistingUserID( CStifItemParser& aItem ) |
|
6939 { |
|
6940 |
|
6941 |
|
6942 ConnectData *connect_data = NULL; |
|
6943 char smsg[MAX_MSG_SIZE]; |
|
6944 char rmsg[MAX_MSG_SIZE]; |
|
6945 int index=0; |
|
6946 FILE *fp; |
|
6947 |
|
6948 int timeout = 200; |
|
6949 int nBytes; |
|
6950 |
|
6951 int result = 0; |
|
6952 int err = 0; |
|
6953 int status = 0; |
|
6954 message_hdr_req *msgHdr = NULL; |
|
6955 message_hdr_resp* msg_struct = NULL; |
|
6956 TInt return_value = 0; |
|
6957 // Read data from the CFG file |
|
6958 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
6959 { |
|
6960 iLog->Log ( _L ( "read_data failed" ) ); |
|
6961 free_data ( connect_data ); |
|
6962 return_value = KErrGeneral; |
|
6963 goto return_code; |
|
6964 } |
|
6965 //request formation |
|
6966 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
6967 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
6968 |
|
6969 //message header use |
|
6970 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
6971 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
6972 |
|
6973 msgHdr->message_type = ELogin_Request; |
|
6974 |
|
6975 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
6976 index += sizeof( message_hdr_req ); |
|
6977 |
|
6978 int len = strlen(connect_data->username); |
|
6979 strcpy( smsg + index, connect_data->username ); |
|
6980 index += len + 1; |
|
6981 |
|
6982 //appending password |
|
6983 |
|
6984 len = strlen(connect_data->password ); |
|
6985 strcpy( smsg + index, connect_data->password ); |
|
6986 index += len + 1; |
|
6987 |
|
6988 //appending server name |
|
6989 |
|
6990 len = strlen(connect_data->server ); |
|
6991 strcpy( smsg + index, connect_data->server ); |
|
6992 index += len + 1; |
|
6993 |
|
6994 //appending resource |
|
6995 len = strlen(connect_data->resource ); |
|
6996 strcpy( smsg + index, connect_data->resource ); |
|
6997 index += len + 1; |
|
6998 |
|
6999 //appending ssl |
|
7000 smsg[index++]= '1'; |
|
7001 smsg[index++]= '\0'; |
|
7002 |
|
7003 //appending server port |
|
7004 len = strlen(connect_data->port ); |
|
7005 strcpy( smsg + index, connect_data->port ); |
|
7006 index += len + 1; |
|
7007 |
|
7008 // appending IAP id |
|
7009 |
|
7010 smsg[index++]= '1'; |
|
7011 smsg[index++]= '\0'; |
|
7012 |
|
7013 //appending connmgr_bus |
|
7014 len = strlen(connect_data->connmgr_bus ); |
|
7015 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
7016 index += len + 1; |
|
7017 |
|
7018 //appending connmgr_path |
|
7019 len = strlen(connect_data->connmgr_path ); |
|
7020 strcpy( smsg + index, connect_data->connmgr_path ); |
|
7021 index += len + 1; |
|
7022 |
|
7023 //appending protocol |
|
7024 len = strlen(connect_data->protocol ); |
|
7025 strcpy( smsg + index, connect_data->protocol ); |
|
7026 index += len + 1; |
|
7027 |
|
7028 #ifdef __WINSCW__ |
|
7029 //proxy server |
|
7030 len = strlen(connect_data->proxy_data->proxy_server ); |
|
7031 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
7032 index += len + 1; |
|
7033 |
|
7034 //proxy port |
|
7035 len = strlen(connect_data->proxy_data->proxy_port ); |
|
7036 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
7037 index += len + 1; |
|
7038 |
|
7039 #endif |
|
7040 |
|
7041 //running isoserver |
|
7042 run_isoserver(); |
|
7043 |
|
7044 |
|
7045 //create message queue for send request |
|
7046 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7047 //create message queue for response request |
|
7048 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7049 |
|
7050 |
|
7051 /* Send Message to queueOne */ |
|
7052 |
|
7053 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7054 |
|
7055 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
7056 |
|
7057 if (status < 0) |
|
7058 { |
|
7059 return_value = KErrGeneral; |
|
7060 goto return_code; |
|
7061 } |
|
7062 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
7063 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
7064 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7065 |
|
7066 if( msg_struct->response != 1) |
|
7067 { |
|
7068 return_value = KErrGeneral; |
|
7069 goto return_code; |
|
7070 } |
|
7071 |
|
7072 |
|
7073 // login end |
|
7074 //fetch req.. |
|
7075 for (int i= 0 ;i<3 ;i++) |
|
7076 { |
|
7077 |
|
7078 fp = fopen("c:\\fetch_contact.txt","a"); |
|
7079 do { |
|
7080 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7081 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7082 fwrite(rmsg,1,status,fp); |
|
7083 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7084 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
7085 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
7086 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
7087 fclose(fp); |
|
7088 |
|
7089 } |
|
7090 |
|
7091 //fetch end |
|
7092 //add contact -------------------------------------------- |
|
7093 |
|
7094 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7095 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7096 index=0; |
|
7097 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7098 msgHdr->message_type = EAdd_Contact_Request; |
|
7099 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7100 index += sizeof( message_hdr_req ); |
|
7101 // adding add contact |
|
7102 len = strlen(connect_data->contact ); |
|
7103 strcpy( smsg + index, connect_data->contact ); |
|
7104 index += len + 1; |
|
7105 smsg[index++] = '\0'; |
|
7106 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7107 do { |
|
7108 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7109 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7110 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7111 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
7112 |
|
7113 if ( msg_struct->response != 1) |
|
7114 { |
|
7115 return_value = KErrGeneral; |
|
7116 goto return_code; |
|
7117 } |
|
7118 |
|
7119 //add contact end--------------------------------------- |
|
7120 |
|
7121 |
|
7122 // logout test code from server |
|
7123 index=0; |
|
7124 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7125 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7126 |
|
7127 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7128 |
|
7129 msgHdr->message_type = ELogout_Request; |
|
7130 |
|
7131 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7132 index += sizeof( message_hdr_req ); |
|
7133 |
|
7134 |
|
7135 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7136 do { |
|
7137 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7138 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7139 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7140 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
7141 |
|
7142 if ( msg_struct->response != 1) |
|
7143 { |
|
7144 return_value = KErrGeneral; |
|
7145 goto return_code; |
|
7146 } |
|
7147 //killing isoserver |
|
7148 return_code: |
|
7149 index=0; |
|
7150 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7151 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7152 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7153 msgHdr->message_type = EKill_Process; |
|
7154 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7155 index += sizeof( message_hdr_req ); |
|
7156 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7157 free( msg_struct ); |
|
7158 return return_value; |
|
7159 } |
|
7160 |
|
7161 // ----------------------------------------------------------------------------- |
|
7162 // Cisolationserver::add member message |
|
7163 // Example test method function. |
|
7164 // (other items were commented in a header). |
|
7165 // ----------------------------------------------------------------------------- |
|
7166 // |
|
7167 TInt Cisolationserver::AddContactWhichIsAlreadyAdded( CStifItemParser& aItem ) |
|
7168 { |
|
7169 |
|
7170 |
|
7171 ConnectData *connect_data = NULL; |
|
7172 char smsg[MAX_MSG_SIZE]; |
|
7173 char rmsg[MAX_MSG_SIZE]; |
|
7174 int index=0; |
|
7175 FILE *fp; |
|
7176 |
|
7177 int timeout = 200; |
|
7178 int nBytes; |
|
7179 |
|
7180 int result = 0; |
|
7181 int err = 0; |
|
7182 int status = 0; |
|
7183 message_hdr_req *msgHdr = NULL; |
|
7184 message_hdr_resp* msg_struct = NULL; |
|
7185 TInt return_value = 0; |
|
7186 // Read data from the CFG file |
|
7187 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
7188 { |
|
7189 iLog->Log ( _L ( "read_data failed" ) ); |
|
7190 free_data ( connect_data ); |
|
7191 return_value = KErrGeneral; |
|
7192 goto return_code; |
|
7193 } |
|
7194 //request formation |
|
7195 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7196 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7197 |
|
7198 //message header use |
|
7199 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
7200 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7201 |
|
7202 msgHdr->message_type = ELogin_Request; |
|
7203 |
|
7204 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7205 index += sizeof( message_hdr_req ); |
|
7206 |
|
7207 int len = strlen(connect_data->username); |
|
7208 strcpy( smsg + index, connect_data->username ); |
|
7209 index += len + 1; |
|
7210 |
|
7211 //appending password |
|
7212 |
|
7213 len = strlen(connect_data->password ); |
|
7214 strcpy( smsg + index, connect_data->password ); |
|
7215 index += len + 1; |
|
7216 |
|
7217 //appending server name |
|
7218 |
|
7219 len = strlen(connect_data->server ); |
|
7220 strcpy( smsg + index, connect_data->server ); |
|
7221 index += len + 1; |
|
7222 |
|
7223 //appending resource |
|
7224 len = strlen(connect_data->resource ); |
|
7225 strcpy( smsg + index, connect_data->resource ); |
|
7226 index += len + 1; |
|
7227 |
|
7228 //appending ssl |
|
7229 smsg[index++]= '1'; |
|
7230 smsg[index++]= '\0'; |
|
7231 |
|
7232 //appending server port |
|
7233 len = strlen(connect_data->port ); |
|
7234 strcpy( smsg + index, connect_data->port ); |
|
7235 index += len + 1; |
|
7236 |
|
7237 // appending IAP id |
|
7238 |
|
7239 smsg[index++]= '1'; |
|
7240 smsg[index++]= '\0'; |
|
7241 |
|
7242 //appending connmgr_bus |
|
7243 len = strlen(connect_data->connmgr_bus ); |
|
7244 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
7245 index += len + 1; |
|
7246 |
|
7247 //appending connmgr_path |
|
7248 len = strlen(connect_data->connmgr_path ); |
|
7249 strcpy( smsg + index, connect_data->connmgr_path ); |
|
7250 index += len + 1; |
|
7251 |
|
7252 //appending protocol |
|
7253 len = strlen(connect_data->protocol ); |
|
7254 strcpy( smsg + index, connect_data->protocol ); |
|
7255 index += len + 1; |
|
7256 |
|
7257 #ifdef __WINSCW__ |
|
7258 //proxy server |
|
7259 len = strlen(connect_data->proxy_data->proxy_server ); |
|
7260 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
7261 index += len + 1; |
|
7262 |
|
7263 //proxy port |
|
7264 len = strlen(connect_data->proxy_data->proxy_port ); |
|
7265 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
7266 index += len + 1; |
|
7267 |
|
7268 #endif |
|
7269 |
|
7270 //running isoserver |
|
7271 run_isoserver(); |
|
7272 |
|
7273 |
|
7274 //create message queue for send request |
|
7275 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7276 //create message queue for response request |
|
7277 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7278 |
|
7279 |
|
7280 /* Send Message to queueOne */ |
|
7281 |
|
7282 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7283 |
|
7284 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
7285 |
|
7286 if (status < 0) |
|
7287 { |
|
7288 return_value = KErrGeneral; |
|
7289 goto return_code; |
|
7290 } |
|
7291 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
7292 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
7293 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7294 |
|
7295 if( msg_struct->response != 1) |
|
7296 { |
|
7297 return_value = KErrGeneral; |
|
7298 goto return_code; |
|
7299 } |
|
7300 |
|
7301 |
|
7302 // login end |
|
7303 //fetch req.. |
|
7304 for (int i= 0 ;i<3 ;i++) |
|
7305 { |
|
7306 |
|
7307 fp = fopen("c:\\fetch_contact.txt","a"); |
|
7308 do { |
|
7309 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7310 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7311 fwrite(rmsg,1,status,fp); |
|
7312 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7313 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
7314 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
7315 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
7316 fclose(fp); |
|
7317 |
|
7318 } |
|
7319 |
|
7320 //fetch end |
|
7321 //add member 1 st time-------------------------------------------- |
|
7322 |
|
7323 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7324 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7325 index=0; |
|
7326 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7327 msgHdr->message_type = EAdd_Contact_Request; |
|
7328 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7329 index += sizeof( message_hdr_req ); |
|
7330 |
|
7331 |
|
7332 // adding add contact |
|
7333 len = strlen(connect_data->contact ); |
|
7334 strcpy( smsg + index, connect_data->contact ); |
|
7335 index += len + 1; |
|
7336 |
|
7337 |
|
7338 |
|
7339 |
|
7340 |
|
7341 |
|
7342 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7343 do { |
|
7344 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7345 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7346 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7347 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
7348 |
|
7349 if ( msg_struct->response != 1) |
|
7350 { |
|
7351 return_value = KErrGeneral; |
|
7352 goto return_code; |
|
7353 } |
|
7354 |
|
7355 //add contact end--------------------------------------- |
|
7356 |
|
7357 //add member 2 nd time-------------------------------------------- |
|
7358 |
|
7359 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7360 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7361 index=0; |
|
7362 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7363 msgHdr->message_type = EAdd_Contact_Request; |
|
7364 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7365 index += sizeof( message_hdr_req ); |
|
7366 |
|
7367 |
|
7368 // adding add contact |
|
7369 len = strlen(connect_data->contact ); |
|
7370 strcpy( smsg + index, connect_data->contact ); |
|
7371 index += len + 1; |
|
7372 |
|
7373 |
|
7374 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7375 do { |
|
7376 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7377 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7378 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7379 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
7380 |
|
7381 if ( msg_struct->response != 1) |
|
7382 { |
|
7383 return_value = KErrGeneral; |
|
7384 goto return_code; |
|
7385 } |
|
7386 |
|
7387 //add contact end--------------------------------------- |
|
7388 |
|
7389 |
|
7390 // logout test code from server |
|
7391 index=0; |
|
7392 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7393 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7394 |
|
7395 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7396 |
|
7397 msgHdr->message_type = ELogout_Request; |
|
7398 |
|
7399 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7400 index += sizeof( message_hdr_req ); |
|
7401 |
|
7402 |
|
7403 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7404 do { |
|
7405 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7406 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7407 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7408 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
7409 |
|
7410 if ( msg_struct->response != 1) |
|
7411 { |
|
7412 return_value = KErrGeneral; |
|
7413 goto return_code; |
|
7414 } |
|
7415 //killing isoserver |
|
7416 return_code: |
|
7417 index=0; |
|
7418 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7419 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7420 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7421 msgHdr->message_type = EKill_Process; |
|
7422 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7423 index += sizeof( message_hdr_req ); |
|
7424 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7425 free( msg_struct ); |
|
7426 return return_value; |
|
7427 } |
|
7428 |
|
7429 |
|
7430 // ----------------------------------------------------------------------------- |
|
7431 // Cisolationserver::add member message |
|
7432 // Example test method function. |
|
7433 // (other items were commented in a header). |
|
7434 // ----------------------------------------------------------------------------- |
|
7435 // |
|
7436 TInt Cisolationserver::ClientSendBlankUserIdForADD( CStifItemParser& aItem ) |
|
7437 { |
|
7438 |
|
7439 |
|
7440 ConnectData *connect_data = NULL; |
|
7441 char smsg[MAX_MSG_SIZE]; |
|
7442 char rmsg[MAX_MSG_SIZE]; |
|
7443 int index=0; |
|
7444 FILE *fp; |
|
7445 |
|
7446 int timeout = 200; |
|
7447 int nBytes; |
|
7448 |
|
7449 int result = 0; |
|
7450 int err = 0; |
|
7451 int status = 0; |
|
7452 message_hdr_req *msgHdr = NULL; |
|
7453 message_hdr_resp* msg_struct = NULL; |
|
7454 TInt return_value = 0; |
|
7455 // Read data from the CFG file |
|
7456 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
7457 { |
|
7458 iLog->Log ( _L ( "read_data failed" ) ); |
|
7459 free_data ( connect_data ); |
|
7460 return_value = KErrGeneral; |
|
7461 goto return_code; |
|
7462 } |
|
7463 //request formation |
|
7464 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7465 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7466 |
|
7467 //message header use |
|
7468 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
7469 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7470 |
|
7471 msgHdr->message_type = ELogin_Request; |
|
7472 |
|
7473 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7474 index += sizeof( message_hdr_req ); |
|
7475 |
|
7476 int len = strlen(connect_data->username); |
|
7477 strcpy( smsg + index, connect_data->username ); |
|
7478 index += len + 1; |
|
7479 |
|
7480 //appending password |
|
7481 |
|
7482 len = strlen(connect_data->password ); |
|
7483 strcpy( smsg + index, connect_data->password ); |
|
7484 index += len + 1; |
|
7485 |
|
7486 //appending server name |
|
7487 |
|
7488 len = strlen(connect_data->server ); |
|
7489 strcpy( smsg + index, connect_data->server ); |
|
7490 index += len + 1; |
|
7491 |
|
7492 //appending resource |
|
7493 len = strlen(connect_data->resource ); |
|
7494 strcpy( smsg + index, connect_data->resource ); |
|
7495 index += len + 1; |
|
7496 |
|
7497 //appending ssl |
|
7498 smsg[index++]= '1'; |
|
7499 smsg[index++]= '\0'; |
|
7500 |
|
7501 //appending server port |
|
7502 len = strlen(connect_data->port ); |
|
7503 strcpy( smsg + index, connect_data->port ); |
|
7504 index += len + 1; |
|
7505 |
|
7506 // appending IAP id |
|
7507 |
|
7508 smsg[index++]= '1'; |
|
7509 smsg[index++]= '\0'; |
|
7510 |
|
7511 //appending connmgr_bus |
|
7512 len = strlen(connect_data->connmgr_bus ); |
|
7513 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
7514 index += len + 1; |
|
7515 |
|
7516 //appending connmgr_path |
|
7517 len = strlen(connect_data->connmgr_path ); |
|
7518 strcpy( smsg + index, connect_data->connmgr_path ); |
|
7519 index += len + 1; |
|
7520 |
|
7521 //appending protocol |
|
7522 len = strlen(connect_data->protocol ); |
|
7523 strcpy( smsg + index, connect_data->protocol ); |
|
7524 index += len + 1; |
|
7525 |
|
7526 #ifdef __WINSCW__ |
|
7527 //proxy server |
|
7528 len = strlen(connect_data->proxy_data->proxy_server ); |
|
7529 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
7530 index += len + 1; |
|
7531 |
|
7532 //proxy port |
|
7533 len = strlen(connect_data->proxy_data->proxy_port ); |
|
7534 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
7535 index += len + 1; |
|
7536 |
|
7537 #endif |
|
7538 //running isoserver |
|
7539 run_isoserver(); |
|
7540 |
|
7541 |
|
7542 |
|
7543 //create message queue for send request |
|
7544 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7545 //create message queue for response request |
|
7546 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7547 |
|
7548 |
|
7549 /* Send Message to queueOne */ |
|
7550 |
|
7551 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7552 |
|
7553 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
7554 |
|
7555 if (status < 0) |
|
7556 { |
|
7557 return_value = KErrGeneral; |
|
7558 goto return_code; |
|
7559 } |
|
7560 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
7561 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
7562 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7563 |
|
7564 if( msg_struct->response != 1) |
|
7565 { |
|
7566 return_value = KErrGeneral; |
|
7567 goto return_code; |
|
7568 } |
|
7569 |
|
7570 |
|
7571 // login end |
|
7572 |
|
7573 //fetch req.. |
|
7574 for (int i= 0 ;i<3 ;i++) |
|
7575 { |
|
7576 |
|
7577 fp = fopen("c:\\fetch_contact.txt","a"); |
|
7578 do { |
|
7579 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7580 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7581 fwrite(rmsg,1,status,fp); |
|
7582 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7583 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
7584 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
7585 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
7586 fclose(fp); |
|
7587 |
|
7588 } |
|
7589 |
|
7590 //fetch end |
|
7591 //add contact -------------------------------------------- |
|
7592 |
|
7593 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7594 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7595 index=0; |
|
7596 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7597 msgHdr->message_type = EAdd_Contact_Request; |
|
7598 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7599 index += sizeof( message_hdr_req ); |
|
7600 |
|
7601 |
|
7602 smsg[index++]='\0'; |
|
7603 //client is sending blank user id |
|
7604 smsg[index++]='\0'; |
|
7605 |
|
7606 |
|
7607 |
|
7608 |
|
7609 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7610 do { |
|
7611 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7612 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7613 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7614 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
7615 |
|
7616 if( msg_struct->error_type >0) |
|
7617 { |
|
7618 return_value = KErrGeneral; |
|
7619 goto return_code; |
|
7620 } |
|
7621 |
|
7622 //add contact end--------------------------------------- |
|
7623 |
|
7624 |
|
7625 // logout test code from server |
|
7626 index=0; |
|
7627 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7628 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7629 |
|
7630 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7631 |
|
7632 msgHdr->message_type = ELogout_Request; |
|
7633 |
|
7634 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7635 index += sizeof( message_hdr_req ); |
|
7636 |
|
7637 |
|
7638 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7639 do { |
|
7640 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7641 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7642 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7643 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
7644 |
|
7645 if( msg_struct->response != 1) |
|
7646 { |
|
7647 return_value = KErrGeneral; |
|
7648 goto return_code; |
|
7649 } |
|
7650 //killing isoserver |
|
7651 return_code: |
|
7652 index=0; |
|
7653 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7654 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7655 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7656 msgHdr->message_type = EKill_Process; |
|
7657 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7658 index += sizeof( message_hdr_req ); |
|
7659 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7660 free( msg_struct ); |
|
7661 return return_value; |
|
7662 } |
|
7663 |
|
7664 // ----------------------------------------------------------------------------- |
|
7665 // Cisolationserver::add member message |
|
7666 // Example test method function. |
|
7667 // (other items were commented in a header). |
|
7668 // ----------------------------------------------------------------------------- |
|
7669 // |
|
7670 TInt Cisolationserver::AddExistingContactWIthSpace( CStifItemParser& aItem ) |
|
7671 { |
|
7672 |
|
7673 |
|
7674 ConnectData *connect_data = NULL; |
|
7675 char smsg[MAX_MSG_SIZE]; |
|
7676 char rmsg[MAX_MSG_SIZE]; |
|
7677 int index=0; |
|
7678 FILE *fp; |
|
7679 |
|
7680 int timeout = 200; |
|
7681 int nBytes; |
|
7682 |
|
7683 int result = 0; |
|
7684 int err = 0; |
|
7685 int status = 0; |
|
7686 message_hdr_req *msgHdr = NULL; |
|
7687 message_hdr_resp* msg_struct = NULL; |
|
7688 TInt return_value = 0; |
|
7689 // Read data from the CFG file |
|
7690 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
7691 { |
|
7692 iLog->Log ( _L ( "read_data failed" ) ); |
|
7693 free_data ( connect_data ); |
|
7694 return_value = KErrGeneral; |
|
7695 goto return_code; |
|
7696 } |
|
7697 //request formation |
|
7698 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7699 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7700 |
|
7701 //message header use |
|
7702 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
7703 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7704 |
|
7705 msgHdr->message_type = ELogin_Request; |
|
7706 |
|
7707 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7708 index += sizeof( message_hdr_req ); |
|
7709 |
|
7710 int len = strlen(connect_data->username); |
|
7711 strcpy( smsg + index, connect_data->username ); |
|
7712 index += len + 1; |
|
7713 |
|
7714 //appending password |
|
7715 |
|
7716 len = strlen(connect_data->password ); |
|
7717 strcpy( smsg + index, connect_data->password ); |
|
7718 index += len + 1; |
|
7719 |
|
7720 //appending server name |
|
7721 |
|
7722 len = strlen(connect_data->server ); |
|
7723 strcpy( smsg + index, connect_data->server ); |
|
7724 index += len + 1; |
|
7725 |
|
7726 //appending resource |
|
7727 len = strlen(connect_data->resource ); |
|
7728 strcpy( smsg + index, connect_data->resource ); |
|
7729 index += len + 1; |
|
7730 |
|
7731 //appending ssl |
|
7732 smsg[index++]= '1'; |
|
7733 smsg[index++]= '\0'; |
|
7734 |
|
7735 //appending server port |
|
7736 len = strlen(connect_data->port ); |
|
7737 strcpy( smsg + index, connect_data->port ); |
|
7738 index += len + 1; |
|
7739 |
|
7740 // appending IAP id |
|
7741 |
|
7742 smsg[index++]= '1'; |
|
7743 smsg[index++]= '\0'; |
|
7744 |
|
7745 //appending connmgr_bus |
|
7746 len = strlen(connect_data->connmgr_bus ); |
|
7747 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
7748 index += len + 1; |
|
7749 |
|
7750 //appending connmgr_path |
|
7751 len = strlen(connect_data->connmgr_path ); |
|
7752 strcpy( smsg + index, connect_data->connmgr_path ); |
|
7753 index += len + 1; |
|
7754 |
|
7755 //appending protocol |
|
7756 len = strlen(connect_data->protocol ); |
|
7757 strcpy( smsg + index, connect_data->protocol ); |
|
7758 index += len + 1; |
|
7759 |
|
7760 #ifdef __WINSCW__ |
|
7761 //proxy server |
|
7762 len = strlen(connect_data->proxy_data->proxy_server ); |
|
7763 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
7764 index += len + 1; |
|
7765 |
|
7766 //proxy port |
|
7767 len = strlen(connect_data->proxy_data->proxy_port ); |
|
7768 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
7769 index += len + 1; |
|
7770 |
|
7771 #endif |
|
7772 |
|
7773 //running isoserver |
|
7774 run_isoserver(); |
|
7775 |
|
7776 |
|
7777 //create message queue for send request |
|
7778 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7779 //create message queue for response request |
|
7780 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
7781 |
|
7782 |
|
7783 /* Send Message to queueOne */ |
|
7784 |
|
7785 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7786 |
|
7787 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
7788 |
|
7789 if (status < 0) |
|
7790 { |
|
7791 return_value = KErrGeneral; |
|
7792 goto return_code; |
|
7793 } |
|
7794 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
7795 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
7796 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7797 |
|
7798 if( msg_struct->response != 1) |
|
7799 { |
|
7800 return_value = KErrGeneral; |
|
7801 goto return_code; |
|
7802 } |
|
7803 |
|
7804 |
|
7805 // login end |
|
7806 |
|
7807 //fetch req.. |
|
7808 for (int i= 0 ;i<3 ;i++) |
|
7809 { |
|
7810 |
|
7811 fp = fopen("c:\\fetch_contact.txt","a"); |
|
7812 do { |
|
7813 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7814 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7815 fwrite(rmsg,1,status,fp); |
|
7816 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7817 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
7818 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
7819 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
7820 fclose(fp); |
|
7821 |
|
7822 } |
|
7823 |
|
7824 //fetch end |
|
7825 |
|
7826 //send messge-------------------------------------------- |
|
7827 |
|
7828 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7829 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7830 index=0; |
|
7831 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7832 msgHdr->message_type = EAdd_Contact_Request; |
|
7833 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7834 index += sizeof( message_hdr_req ); |
|
7835 |
|
7836 |
|
7837 // adding add contact |
|
7838 len = strlen(connect_data->contact ); |
|
7839 strcpy( smsg + index, connect_data->contact ); |
|
7840 index += len + 1; |
|
7841 smsg[index++]=' '; |
|
7842 |
|
7843 smsg[index++]= '\0'; |
|
7844 |
|
7845 |
|
7846 |
|
7847 |
|
7848 |
|
7849 |
|
7850 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7851 do { |
|
7852 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7853 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7854 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7855 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
7856 |
|
7857 if( msg_struct->response != 0) |
|
7858 { |
|
7859 return_value = KErrGeneral; |
|
7860 goto return_code; |
|
7861 } |
|
7862 //add contact end--------------------------------------- |
|
7863 |
|
7864 |
|
7865 // logout test code from server |
|
7866 index=0; |
|
7867 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7868 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7869 |
|
7870 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7871 |
|
7872 msgHdr->message_type = ELogout_Request; |
|
7873 |
|
7874 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7875 index += sizeof( message_hdr_req ); |
|
7876 |
|
7877 |
|
7878 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7879 do { |
|
7880 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
7881 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
7882 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7883 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
7884 |
|
7885 if ( msg_struct->response != 1) |
|
7886 { |
|
7887 return_value = KErrGeneral; |
|
7888 goto return_code; |
|
7889 } |
|
7890 //killing isoserver |
|
7891 return_code: |
|
7892 index=0; |
|
7893 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7894 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7895 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7896 msgHdr->message_type = EKill_Process; |
|
7897 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7898 index += sizeof( message_hdr_req ); |
|
7899 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
7900 free( msg_struct ); |
|
7901 return return_value; |
|
7902 } |
|
7903 |
|
7904 // ----------------------------------------------------------------------------- |
|
7905 // Cisolationserver::add member message |
|
7906 // Example test method function. |
|
7907 // (other items were commented in a header). |
|
7908 // ----------------------------------------------------------------------------- |
|
7909 // |
|
7910 TInt Cisolationserver::AddExistingContactWIthMixedLetter( CStifItemParser& aItem ) |
|
7911 { |
|
7912 |
|
7913 |
|
7914 ConnectData *connect_data = NULL; |
|
7915 char smsg[MAX_MSG_SIZE]; |
|
7916 char rmsg[MAX_MSG_SIZE]; |
|
7917 int index=0; |
|
7918 FILE *fp; |
|
7919 |
|
7920 int timeout = 200; |
|
7921 int nBytes; |
|
7922 |
|
7923 int result = 0; |
|
7924 int err = 0; |
|
7925 int status = 0; |
|
7926 message_hdr_req *msgHdr = NULL; |
|
7927 message_hdr_resp* msg_struct = NULL; |
|
7928 TInt return_value = 0; |
|
7929 // Read data from the CFG file |
|
7930 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
7931 { |
|
7932 iLog->Log ( _L ( "read_data failed" ) ); |
|
7933 free_data ( connect_data ); |
|
7934 return_value = KErrGeneral; |
|
7935 goto return_code; |
|
7936 } |
|
7937 //request formation |
|
7938 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
7939 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
7940 |
|
7941 //message header use |
|
7942 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
7943 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
7944 |
|
7945 msgHdr->message_type = ELogin_Request; |
|
7946 |
|
7947 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
7948 index += sizeof( message_hdr_req ); |
|
7949 |
|
7950 int len = strlen(connect_data->username); |
|
7951 strcpy( smsg + index, connect_data->username ); |
|
7952 index += len + 1; |
|
7953 |
|
7954 //appending password |
|
7955 |
|
7956 len = strlen(connect_data->password ); |
|
7957 strcpy( smsg + index, connect_data->password ); |
|
7958 index += len + 1; |
|
7959 |
|
7960 //appending server name |
|
7961 |
|
7962 len = strlen(connect_data->server ); |
|
7963 strcpy( smsg + index, connect_data->server ); |
|
7964 index += len + 1; |
|
7965 |
|
7966 //appending resource |
|
7967 len = strlen(connect_data->resource ); |
|
7968 strcpy( smsg + index, connect_data->resource ); |
|
7969 index += len + 1; |
|
7970 |
|
7971 //appending ssl |
|
7972 smsg[index++]= '1'; |
|
7973 smsg[index++]= '\0'; |
|
7974 |
|
7975 //appending server port |
|
7976 len = strlen(connect_data->port ); |
|
7977 strcpy( smsg + index, connect_data->port ); |
|
7978 index += len + 1; |
|
7979 |
|
7980 // appending IAP id |
|
7981 |
|
7982 smsg[index++]= '1'; |
|
7983 smsg[index++]= '\0'; |
|
7984 |
|
7985 //appending connmgr_bus |
|
7986 len = strlen(connect_data->connmgr_bus ); |
|
7987 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
7988 index += len + 1; |
|
7989 |
|
7990 //appending connmgr_path |
|
7991 len = strlen(connect_data->connmgr_path ); |
|
7992 strcpy( smsg + index, connect_data->connmgr_path ); |
|
7993 index += len + 1; |
|
7994 |
|
7995 //appending protocol |
|
7996 len = strlen(connect_data->protocol ); |
|
7997 strcpy( smsg + index, connect_data->protocol ); |
|
7998 index += len + 1; |
|
7999 |
|
8000 #ifdef __WINSCW__ |
|
8001 //proxy server |
|
8002 len = strlen(connect_data->proxy_data->proxy_server ); |
|
8003 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
8004 index += len + 1; |
|
8005 |
|
8006 //proxy port |
|
8007 len = strlen(connect_data->proxy_data->proxy_port ); |
|
8008 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
8009 index += len + 1; |
|
8010 |
|
8011 #endif |
|
8012 |
|
8013 //running isoserver |
|
8014 run_isoserver(); |
|
8015 |
|
8016 |
|
8017 //create message queue for send request |
|
8018 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8019 //create message queue for response request |
|
8020 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8021 |
|
8022 |
|
8023 /* Send Message to queueOne */ |
|
8024 |
|
8025 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8026 |
|
8027 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
8028 |
|
8029 if (status < 0) |
|
8030 { |
|
8031 return_value = KErrGeneral; |
|
8032 goto return_code; |
|
8033 } |
|
8034 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
8035 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
8036 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8037 |
|
8038 if( msg_struct->response != 1) |
|
8039 { |
|
8040 return_value = KErrGeneral; |
|
8041 goto return_code; |
|
8042 } |
|
8043 |
|
8044 |
|
8045 // login end |
|
8046 //fetch req.. |
|
8047 for (int i= 0 ;i<3 ;i++) |
|
8048 { |
|
8049 |
|
8050 fp = fopen("c:\\fetch_contact.txt","a"); |
|
8051 do { |
|
8052 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8053 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8054 fwrite(rmsg,1,status,fp); |
|
8055 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8056 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
8057 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
8058 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
8059 fclose(fp); |
|
8060 |
|
8061 } |
|
8062 |
|
8063 //fetch end |
|
8064 |
|
8065 //send messge-------------------------------------------- |
|
8066 |
|
8067 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8068 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8069 index=0; |
|
8070 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8071 msgHdr->message_type = EAdd_Contact_Request; |
|
8072 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8073 index += sizeof( message_hdr_req ); |
|
8074 |
|
8075 |
|
8076 // adding add contact |
|
8077 len = strlen(connect_data->contact ); |
|
8078 strcpy( smsg + index, connect_data->contact ); |
|
8079 index += len + 1; |
|
8080 smsg[index++]='\0'; |
|
8081 |
|
8082 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8083 do { |
|
8084 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8085 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8086 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8087 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
8088 |
|
8089 if ( msg_struct->response != 1) |
|
8090 { |
|
8091 return_value = KErrGeneral; |
|
8092 goto return_code; |
|
8093 } |
|
8094 |
|
8095 //add contact end--------------------------------------- |
|
8096 |
|
8097 |
|
8098 // logout test code from server |
|
8099 index=0; |
|
8100 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8101 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8102 |
|
8103 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8104 |
|
8105 msgHdr->message_type = ELogout_Request; |
|
8106 |
|
8107 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8108 index += sizeof( message_hdr_req ); |
|
8109 |
|
8110 |
|
8111 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8112 do { |
|
8113 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8114 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8115 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8116 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
8117 |
|
8118 if ( msg_struct->response != 1) |
|
8119 { |
|
8120 return_value = KErrGeneral; |
|
8121 goto return_code; |
|
8122 } |
|
8123 //killing isoserver |
|
8124 return_code: |
|
8125 index=0; |
|
8126 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8127 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8128 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8129 msgHdr->message_type = EKill_Process; |
|
8130 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8131 index += sizeof( message_hdr_req ); |
|
8132 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8133 free( msg_struct ); |
|
8134 return return_value; |
|
8135 } |
|
8136 |
|
8137 // ----------------------------------------------------------------------------- |
|
8138 // Cisolationserver::add member message |
|
8139 // Example test method function. |
|
8140 // (other items were commented in a header). |
|
8141 // ----------------------------------------------------------------------------- |
|
8142 // |
|
8143 TInt Cisolationserver::AddInvalidContactWIthSpecialLetter( CStifItemParser& aItem ) |
|
8144 { |
|
8145 |
|
8146 |
|
8147 ConnectData *connect_data = NULL; |
|
8148 char smsg[MAX_MSG_SIZE]; |
|
8149 char rmsg[MAX_MSG_SIZE]; |
|
8150 int index=0; |
|
8151 FILE *fp; |
|
8152 |
|
8153 int timeout = 200; |
|
8154 int nBytes; |
|
8155 |
|
8156 int result = 0; |
|
8157 int err = 0; |
|
8158 int status = 0; |
|
8159 message_hdr_req *msgHdr = NULL; |
|
8160 message_hdr_resp* msg_struct = NULL; |
|
8161 TInt return_value = 0; |
|
8162 // Read data from the CFG file |
|
8163 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
8164 { |
|
8165 iLog->Log ( _L ( "read_data failed" ) ); |
|
8166 free_data ( connect_data ); |
|
8167 return_value = KErrGeneral; |
|
8168 goto return_code; |
|
8169 } |
|
8170 //request formation |
|
8171 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8172 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8173 |
|
8174 //message header use |
|
8175 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
8176 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8177 |
|
8178 msgHdr->message_type = ELogin_Request; |
|
8179 |
|
8180 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8181 index += sizeof( message_hdr_req ); |
|
8182 |
|
8183 int len = strlen(connect_data->username); |
|
8184 strcpy( smsg + index, connect_data->username ); |
|
8185 index += len + 1; |
|
8186 |
|
8187 //appending password |
|
8188 |
|
8189 len = strlen(connect_data->password ); |
|
8190 strcpy( smsg + index, connect_data->password ); |
|
8191 index += len + 1; |
|
8192 |
|
8193 //appending server name |
|
8194 |
|
8195 len = strlen(connect_data->server ); |
|
8196 strcpy( smsg + index, connect_data->server ); |
|
8197 index += len + 1; |
|
8198 |
|
8199 //appending resource |
|
8200 len = strlen(connect_data->resource ); |
|
8201 strcpy( smsg + index, connect_data->resource ); |
|
8202 index += len + 1; |
|
8203 |
|
8204 //appending ssl |
|
8205 smsg[index++]= '1'; |
|
8206 smsg[index++]= '\0'; |
|
8207 |
|
8208 //appending server port |
|
8209 len = strlen(connect_data->port ); |
|
8210 strcpy( smsg + index, connect_data->port ); |
|
8211 index += len + 1; |
|
8212 |
|
8213 // appending IAP id |
|
8214 |
|
8215 smsg[index++]= '1'; |
|
8216 smsg[index++]= '\0'; |
|
8217 |
|
8218 //appending connmgr_bus |
|
8219 len = strlen(connect_data->connmgr_bus ); |
|
8220 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
8221 index += len + 1; |
|
8222 |
|
8223 //appending connmgr_path |
|
8224 len = strlen(connect_data->connmgr_path ); |
|
8225 strcpy( smsg + index, connect_data->connmgr_path ); |
|
8226 index += len + 1; |
|
8227 |
|
8228 //appending protocol |
|
8229 len = strlen(connect_data->protocol ); |
|
8230 strcpy( smsg + index, connect_data->protocol ); |
|
8231 index += len + 1; |
|
8232 |
|
8233 #ifdef __WINSCW__ |
|
8234 //proxy server |
|
8235 len = strlen(connect_data->proxy_data->proxy_server ); |
|
8236 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
8237 index += len + 1; |
|
8238 |
|
8239 //proxy port |
|
8240 len = strlen(connect_data->proxy_data->proxy_port ); |
|
8241 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
8242 index += len + 1; |
|
8243 |
|
8244 #endif |
|
8245 |
|
8246 //running isoserver |
|
8247 run_isoserver(); |
|
8248 |
|
8249 |
|
8250 //create message queue for send request |
|
8251 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8252 //create message queue for response request |
|
8253 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8254 |
|
8255 |
|
8256 /* Send Message to queueOne */ |
|
8257 |
|
8258 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8259 |
|
8260 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
8261 |
|
8262 if (status < 0) |
|
8263 { |
|
8264 return_value = KErrGeneral; |
|
8265 goto return_code; |
|
8266 } |
|
8267 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
8268 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
8269 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8270 |
|
8271 if( msg_struct->response != 1) |
|
8272 { |
|
8273 return_value = KErrGeneral; |
|
8274 goto return_code; |
|
8275 } |
|
8276 |
|
8277 |
|
8278 // login end |
|
8279 |
|
8280 //fetch req.. |
|
8281 for (int i= 0 ;i<3 ;i++) |
|
8282 { |
|
8283 |
|
8284 fp = fopen("c:\\fetch_contact.txt","a"); |
|
8285 do { |
|
8286 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8287 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8288 fwrite(rmsg,1,status,fp); |
|
8289 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8290 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
8291 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
8292 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
8293 fclose(fp); |
|
8294 |
|
8295 } |
|
8296 |
|
8297 //fetch end |
|
8298 //send messge-------------------------------------------- |
|
8299 |
|
8300 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8301 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8302 index=0; |
|
8303 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8304 msgHdr->message_type = EAdd_Contact_Request; |
|
8305 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8306 index += sizeof( message_hdr_req ); |
|
8307 |
|
8308 |
|
8309 // adding add contact |
|
8310 len = strlen(connect_data->contact ); |
|
8311 strcpy( smsg + index, connect_data->contact ); |
|
8312 index += len + 1; |
|
8313 |
|
8314 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8315 do { |
|
8316 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8317 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8318 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8319 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
8320 |
|
8321 if ( msg_struct->response != 1) |
|
8322 { |
|
8323 return_value = KErrGeneral; |
|
8324 goto return_code; |
|
8325 } |
|
8326 |
|
8327 //add contact end--------------------------------------- |
|
8328 |
|
8329 |
|
8330 // logout test code from server |
|
8331 index=0; |
|
8332 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8333 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8334 |
|
8335 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8336 |
|
8337 msgHdr->message_type = ELogout_Request; |
|
8338 |
|
8339 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8340 index += sizeof( message_hdr_req ); |
|
8341 |
|
8342 |
|
8343 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8344 do { |
|
8345 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8346 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8347 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8348 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
8349 |
|
8350 if ( msg_struct->response != 1) |
|
8351 { |
|
8352 return_value = KErrGeneral; |
|
8353 goto return_code; |
|
8354 } |
|
8355 //killing isoserver |
|
8356 return_code: |
|
8357 index=0; |
|
8358 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8359 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8360 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8361 msgHdr->message_type = EKill_Process; |
|
8362 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8363 index += sizeof( message_hdr_req ); |
|
8364 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8365 free( msg_struct ); |
|
8366 return return_value; |
|
8367 } |
|
8368 |
|
8369 |
|
8370 // ----------------------------------------------------------------------------- |
|
8371 // Cisolationserver::add member message |
|
8372 // Example test method function. |
|
8373 // (other items were commented in a header). |
|
8374 // ----------------------------------------------------------------------------- |
|
8375 // |
|
8376 TInt Cisolationserver::DeleteExistingContact( CStifItemParser& aItem ) |
|
8377 { |
|
8378 |
|
8379 |
|
8380 ConnectData *connect_data = NULL; |
|
8381 char smsg[MAX_MSG_SIZE]; |
|
8382 char rmsg[MAX_MSG_SIZE]; |
|
8383 int index=0; |
|
8384 FILE *fp; |
|
8385 |
|
8386 int timeout = 200; |
|
8387 int nBytes; |
|
8388 |
|
8389 int result = 0; |
|
8390 int err = 0; |
|
8391 int status = 0; |
|
8392 message_hdr_req *msgHdr = NULL; |
|
8393 message_hdr_resp* msg_struct = NULL; |
|
8394 TInt return_value = 0; |
|
8395 // Read data from the CFG file |
|
8396 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
8397 { |
|
8398 iLog->Log ( _L ( "read_data failed" ) ); |
|
8399 free_data ( connect_data ); |
|
8400 return_value = KErrGeneral; |
|
8401 goto return_code; |
|
8402 } |
|
8403 //request formation |
|
8404 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8405 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8406 |
|
8407 //message header use |
|
8408 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
8409 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8410 |
|
8411 msgHdr->message_type = ELogin_Request; |
|
8412 |
|
8413 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8414 index += sizeof( message_hdr_req ); |
|
8415 |
|
8416 int len = strlen(connect_data->username); |
|
8417 strcpy( smsg + index, connect_data->username ); |
|
8418 index += len + 1; |
|
8419 |
|
8420 //appending password |
|
8421 |
|
8422 len = strlen(connect_data->password ); |
|
8423 strcpy( smsg + index, connect_data->password ); |
|
8424 index += len + 1; |
|
8425 |
|
8426 //appending server name |
|
8427 |
|
8428 len = strlen(connect_data->server ); |
|
8429 strcpy( smsg + index, connect_data->server ); |
|
8430 index += len + 1; |
|
8431 |
|
8432 //appending resource |
|
8433 len = strlen(connect_data->resource ); |
|
8434 strcpy( smsg + index, connect_data->resource ); |
|
8435 index += len + 1; |
|
8436 |
|
8437 //appending ssl |
|
8438 smsg[index++]= '1'; |
|
8439 smsg[index++]= '\0'; |
|
8440 |
|
8441 //appending server port |
|
8442 len = strlen(connect_data->port ); |
|
8443 strcpy( smsg + index, connect_data->port ); |
|
8444 index += len + 1; |
|
8445 |
|
8446 // appending IAP id |
|
8447 |
|
8448 smsg[index++]= '1'; |
|
8449 smsg[index++]= '\0'; |
|
8450 |
|
8451 //appending connmgr_bus |
|
8452 len = strlen(connect_data->connmgr_bus ); |
|
8453 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
8454 index += len + 1; |
|
8455 |
|
8456 //appending connmgr_path |
|
8457 len = strlen(connect_data->connmgr_path ); |
|
8458 strcpy( smsg + index, connect_data->connmgr_path ); |
|
8459 index += len + 1; |
|
8460 |
|
8461 //appending protocol |
|
8462 len = strlen(connect_data->protocol ); |
|
8463 strcpy( smsg + index, connect_data->protocol ); |
|
8464 index += len + 1; |
|
8465 |
|
8466 #ifdef __WINSCW__ |
|
8467 //proxy server |
|
8468 len = strlen(connect_data->proxy_data->proxy_server ); |
|
8469 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
8470 index += len + 1; |
|
8471 |
|
8472 //proxy port |
|
8473 len = strlen(connect_data->proxy_data->proxy_port ); |
|
8474 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
8475 index += len + 1; |
|
8476 |
|
8477 #endif |
|
8478 //running isoserver |
|
8479 run_isoserver(); |
|
8480 |
|
8481 //create message queue for send request |
|
8482 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8483 //create message queue for response request |
|
8484 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8485 |
|
8486 |
|
8487 /* Send Message to queueOne */ |
|
8488 |
|
8489 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8490 |
|
8491 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
8492 |
|
8493 if (status < 0) |
|
8494 { |
|
8495 return_value = KErrGeneral; |
|
8496 goto return_code; |
|
8497 } |
|
8498 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
8499 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
8500 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8501 |
|
8502 if( msg_struct->response != 1) |
|
8503 { |
|
8504 return_value = KErrGeneral; |
|
8505 goto return_code; |
|
8506 } |
|
8507 |
|
8508 |
|
8509 // login end |
|
8510 //fetch req.. |
|
8511 for (int i= 0 ;i<3 ;i++) |
|
8512 { |
|
8513 |
|
8514 fp = fopen("c:\\fetch_contact.txt","a"); |
|
8515 do { |
|
8516 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8517 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8518 fwrite(rmsg,1,status,fp); |
|
8519 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8520 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
8521 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
8522 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
8523 fclose(fp); |
|
8524 |
|
8525 } |
|
8526 |
|
8527 //fetch end |
|
8528 |
|
8529 //delete contact-------------------------------------------- |
|
8530 |
|
8531 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8532 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8533 index=0; |
|
8534 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8535 msgHdr->message_type = EDelete_Contact_Request; |
|
8536 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8537 index += sizeof( message_hdr_req ); |
|
8538 |
|
8539 |
|
8540 // adding add contact |
|
8541 len = strlen(connect_data->contact ); |
|
8542 strcpy( smsg + index, connect_data->contact ); |
|
8543 index += len + 1; |
|
8544 smsg[index++] = '\0'; |
|
8545 |
|
8546 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8547 do { |
|
8548 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8549 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8550 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8551 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
8552 |
|
8553 if ( msg_struct->response != 1) |
|
8554 { |
|
8555 return_value = KErrGeneral; |
|
8556 goto return_code; |
|
8557 } |
|
8558 |
|
8559 //add contact end--------------------------------------- |
|
8560 |
|
8561 |
|
8562 // logout test code from server |
|
8563 // logout test code from server |
|
8564 index=0; |
|
8565 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8566 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8567 |
|
8568 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8569 |
|
8570 msgHdr->message_type = ELogout_Request; |
|
8571 |
|
8572 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8573 index += sizeof( message_hdr_req ); |
|
8574 |
|
8575 |
|
8576 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8577 do { |
|
8578 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8579 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8580 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8581 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
8582 |
|
8583 if ( msg_struct->response != 1) |
|
8584 { |
|
8585 return_value = KErrGeneral; |
|
8586 goto return_code; |
|
8587 } |
|
8588 return_code: |
|
8589 index=0; |
|
8590 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8591 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8592 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8593 msgHdr->message_type = EKill_Process; |
|
8594 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8595 index += sizeof( message_hdr_req ); |
|
8596 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8597 free( msg_struct ); |
|
8598 return return_value; |
|
8599 } |
|
8600 |
|
8601 // ----------------------------------------------------------------------------- |
|
8602 // Cisolationserver::add member message |
|
8603 // Example test method function. |
|
8604 // (other items were commented in a header). |
|
8605 // ----------------------------------------------------------------------------- |
|
8606 // |
|
8607 TInt Cisolationserver::DeleteUnexistingUserID( CStifItemParser& aItem ) |
|
8608 { |
|
8609 |
|
8610 |
|
8611 ConnectData *connect_data = NULL; |
|
8612 char smsg[MAX_MSG_SIZE]; |
|
8613 char rmsg[MAX_MSG_SIZE]; |
|
8614 int index=0; |
|
8615 FILE *fp; |
|
8616 |
|
8617 int timeout = 200; |
|
8618 int nBytes; |
|
8619 |
|
8620 int result = 0; |
|
8621 int err = 0; |
|
8622 int status = 0; |
|
8623 message_hdr_req *msgHdr = NULL; |
|
8624 message_hdr_resp* msg_struct = NULL; |
|
8625 TInt return_value = 0; |
|
8626 // Read data from the CFG file |
|
8627 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
8628 { |
|
8629 iLog->Log ( _L ( "read_data failed" ) ); |
|
8630 free_data ( connect_data ); |
|
8631 return_value = KErrGeneral; |
|
8632 goto return_code; |
|
8633 } |
|
8634 //request formation |
|
8635 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8636 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8637 |
|
8638 //message header use |
|
8639 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
8640 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8641 |
|
8642 msgHdr->message_type = ELogin_Request; |
|
8643 |
|
8644 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8645 index += sizeof( message_hdr_req ); |
|
8646 |
|
8647 int len = strlen(connect_data->username); |
|
8648 strcpy( smsg + index, connect_data->username ); |
|
8649 index += len + 1; |
|
8650 |
|
8651 //appending password |
|
8652 |
|
8653 len = strlen(connect_data->password ); |
|
8654 strcpy( smsg + index, connect_data->password ); |
|
8655 index += len + 1; |
|
8656 |
|
8657 //appending server name |
|
8658 |
|
8659 len = strlen(connect_data->server ); |
|
8660 strcpy( smsg + index, connect_data->server ); |
|
8661 index += len + 1; |
|
8662 |
|
8663 //appending resource |
|
8664 len = strlen(connect_data->resource ); |
|
8665 strcpy( smsg + index, connect_data->resource ); |
|
8666 index += len + 1; |
|
8667 |
|
8668 //appending ssl |
|
8669 smsg[index++]= '1'; |
|
8670 smsg[index++]= '\0'; |
|
8671 |
|
8672 //appending server port |
|
8673 len = strlen(connect_data->port ); |
|
8674 strcpy( smsg + index, connect_data->port ); |
|
8675 index += len + 1; |
|
8676 |
|
8677 // appending IAP id |
|
8678 |
|
8679 smsg[index++]= '1'; |
|
8680 smsg[index++]= '\0'; |
|
8681 |
|
8682 //appending connmgr_bus |
|
8683 len = strlen(connect_data->connmgr_bus ); |
|
8684 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
8685 index += len + 1; |
|
8686 |
|
8687 //appending connmgr_path |
|
8688 len = strlen(connect_data->connmgr_path ); |
|
8689 strcpy( smsg + index, connect_data->connmgr_path ); |
|
8690 index += len + 1; |
|
8691 |
|
8692 //appending protocol |
|
8693 len = strlen(connect_data->protocol ); |
|
8694 strcpy( smsg + index, connect_data->protocol ); |
|
8695 index += len + 1; |
|
8696 |
|
8697 #ifdef __WINSCW__ |
|
8698 //proxy server |
|
8699 len = strlen(connect_data->proxy_data->proxy_server ); |
|
8700 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
8701 index += len + 1; |
|
8702 |
|
8703 //proxy port |
|
8704 len = strlen(connect_data->proxy_data->proxy_port ); |
|
8705 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
8706 index += len + 1; |
|
8707 |
|
8708 #endif |
|
8709 //running isoserver |
|
8710 run_isoserver(); |
|
8711 //create message queue for send request |
|
8712 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8713 //create message queue for response request |
|
8714 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8715 |
|
8716 |
|
8717 /* Send Message to queueOne */ |
|
8718 |
|
8719 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8720 |
|
8721 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
8722 |
|
8723 if (status < 0) |
|
8724 { |
|
8725 return_value = KErrGeneral; |
|
8726 goto return_code; |
|
8727 } |
|
8728 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
8729 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
8730 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8731 |
|
8732 if( msg_struct->response != 1) |
|
8733 { |
|
8734 return_value = KErrGeneral; |
|
8735 goto return_code; |
|
8736 } |
|
8737 |
|
8738 |
|
8739 // login end |
|
8740 //fetch req.. |
|
8741 for (int i= 0 ;i<3 ;i++) |
|
8742 { |
|
8743 |
|
8744 fp = fopen("c:\\fetch_contact.txt","a"); |
|
8745 do { |
|
8746 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8747 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8748 fwrite(rmsg,1,status,fp); |
|
8749 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8750 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
8751 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
8752 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
8753 fclose(fp); |
|
8754 |
|
8755 } |
|
8756 |
|
8757 //fetch end |
|
8758 //delete contact-------------------------------------------- |
|
8759 |
|
8760 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8761 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8762 index=0; |
|
8763 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8764 msgHdr->message_type = EDelete_Contact_Request; |
|
8765 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8766 index += sizeof( message_hdr_req ); |
|
8767 |
|
8768 |
|
8769 // adding add contact |
|
8770 len = strlen(connect_data->contact ); |
|
8771 strcpy( smsg + index, connect_data->contact ); |
|
8772 index += len + 1; |
|
8773 |
|
8774 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8775 do { |
|
8776 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8777 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8778 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8779 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
8780 |
|
8781 if ( msg_struct->response != 1) |
|
8782 { |
|
8783 return_value = KErrGeneral; |
|
8784 goto return_code; |
|
8785 } |
|
8786 |
|
8787 //add contact end--------------------------------------- |
|
8788 |
|
8789 |
|
8790 // logout test code from server |
|
8791 index=0; |
|
8792 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8793 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8794 |
|
8795 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8796 |
|
8797 msgHdr->message_type = ELogout_Request; |
|
8798 |
|
8799 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8800 index += sizeof( message_hdr_req ); |
|
8801 |
|
8802 |
|
8803 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8804 do { |
|
8805 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8806 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8807 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8808 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
8809 |
|
8810 if ( msg_struct->response != 1) |
|
8811 { |
|
8812 return_value = KErrGeneral; |
|
8813 goto return_code; |
|
8814 } |
|
8815 //killing isoserver |
|
8816 return_code: |
|
8817 index=0; |
|
8818 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8819 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8820 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8821 msgHdr->message_type = EKill_Process; |
|
8822 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8823 index += sizeof( message_hdr_req ); |
|
8824 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8825 free( msg_struct ); |
|
8826 return return_value; |
|
8827 } |
|
8828 |
|
8829 // ----------------------------------------------------------------------------- |
|
8830 // Cisolationserver::add member message |
|
8831 // Example test method function. |
|
8832 // (other items were commented in a header). |
|
8833 // ----------------------------------------------------------------------------- |
|
8834 // |
|
8835 TInt Cisolationserver::DeleteContactWhichIsAlreadyDeleted( CStifItemParser& aItem ) |
|
8836 { |
|
8837 |
|
8838 |
|
8839 ConnectData *connect_data = NULL; |
|
8840 char smsg[MAX_MSG_SIZE]; |
|
8841 char rmsg[MAX_MSG_SIZE]; |
|
8842 int index=0; |
|
8843 FILE *fp; |
|
8844 |
|
8845 int timeout = 200; |
|
8846 int nBytes; |
|
8847 |
|
8848 int result = 0; |
|
8849 int err = 0; |
|
8850 int status = 0; |
|
8851 message_hdr_req *msgHdr = NULL; |
|
8852 message_hdr_resp* msg_struct = NULL; |
|
8853 TInt return_value = 0; |
|
8854 // Read data from the CFG file |
|
8855 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
8856 { |
|
8857 iLog->Log ( _L ( "read_data failed" ) ); |
|
8858 free_data ( connect_data ); |
|
8859 return_value = KErrGeneral; |
|
8860 goto return_code; |
|
8861 } |
|
8862 //request formation |
|
8863 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8864 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8865 |
|
8866 //message header use |
|
8867 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
8868 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8869 |
|
8870 msgHdr->message_type = ELogin_Request; |
|
8871 |
|
8872 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8873 index += sizeof( message_hdr_req ); |
|
8874 |
|
8875 int len = strlen(connect_data->username); |
|
8876 strcpy( smsg + index, connect_data->username ); |
|
8877 index += len + 1; |
|
8878 |
|
8879 //appending password |
|
8880 |
|
8881 len = strlen(connect_data->password ); |
|
8882 strcpy( smsg + index, connect_data->password ); |
|
8883 index += len + 1; |
|
8884 |
|
8885 //appending server name |
|
8886 |
|
8887 len = strlen(connect_data->server ); |
|
8888 strcpy( smsg + index, connect_data->server ); |
|
8889 index += len + 1; |
|
8890 |
|
8891 //appending resource |
|
8892 len = strlen(connect_data->resource ); |
|
8893 strcpy( smsg + index, connect_data->resource ); |
|
8894 index += len + 1; |
|
8895 |
|
8896 //appending ssl |
|
8897 smsg[index++]= '1'; |
|
8898 smsg[index++]= '\0'; |
|
8899 |
|
8900 //appending server port |
|
8901 len = strlen(connect_data->port ); |
|
8902 strcpy( smsg + index, connect_data->port ); |
|
8903 index += len + 1; |
|
8904 |
|
8905 // appending IAP id |
|
8906 |
|
8907 smsg[index++]= '1'; |
|
8908 smsg[index++]= '\0'; |
|
8909 |
|
8910 //appending connmgr_bus |
|
8911 len = strlen(connect_data->connmgr_bus ); |
|
8912 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
8913 index += len + 1; |
|
8914 |
|
8915 //appending connmgr_path |
|
8916 len = strlen(connect_data->connmgr_path ); |
|
8917 strcpy( smsg + index, connect_data->connmgr_path ); |
|
8918 index += len + 1; |
|
8919 |
|
8920 //appending protocol |
|
8921 len = strlen(connect_data->protocol ); |
|
8922 strcpy( smsg + index, connect_data->protocol ); |
|
8923 index += len + 1; |
|
8924 |
|
8925 #ifdef __WINSCW__ |
|
8926 //proxy server |
|
8927 len = strlen(connect_data->proxy_data->proxy_server ); |
|
8928 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
8929 index += len + 1; |
|
8930 |
|
8931 //proxy port |
|
8932 len = strlen(connect_data->proxy_data->proxy_port ); |
|
8933 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
8934 index += len + 1; |
|
8935 |
|
8936 #endif |
|
8937 |
|
8938 //running isoserver |
|
8939 run_isoserver(); |
|
8940 |
|
8941 |
|
8942 //create message queue for send request |
|
8943 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8944 //create message queue for response request |
|
8945 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
8946 |
|
8947 |
|
8948 /* Send Message to queueOne */ |
|
8949 |
|
8950 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
8951 |
|
8952 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
8953 |
|
8954 if (status < 0) |
|
8955 { |
|
8956 return_value = KErrGeneral; |
|
8957 goto return_code; |
|
8958 } |
|
8959 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
8960 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
8961 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8962 |
|
8963 if( msg_struct->response != 1) |
|
8964 { |
|
8965 return_value = KErrGeneral; |
|
8966 goto return_code; |
|
8967 } |
|
8968 |
|
8969 |
|
8970 // login end |
|
8971 //fetch req.. |
|
8972 for (int i= 0 ;i<3 ;i++) |
|
8973 { |
|
8974 |
|
8975 fp = fopen("c:\\fetch_contact.txt","a"); |
|
8976 do { |
|
8977 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
8978 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
8979 fwrite(rmsg,1,status,fp); |
|
8980 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8981 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
8982 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
8983 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
8984 fclose(fp); |
|
8985 |
|
8986 } |
|
8987 |
|
8988 //fetch end |
|
8989 |
|
8990 |
|
8991 //add member 1 st time-------------------------------------------- |
|
8992 |
|
8993 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
8994 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
8995 index=0; |
|
8996 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
8997 msgHdr->message_type = EAdd_Contact_Request; |
|
8998 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
8999 index += sizeof( message_hdr_req ); |
|
9000 |
|
9001 // addiing in q for deleting contact |
|
9002 len = strlen(connect_data->contact ); |
|
9003 strcpy( smsg + index, connect_data->contact ); |
|
9004 index += len + 1; |
|
9005 |
|
9006 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9007 do { |
|
9008 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9009 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9010 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9011 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
9012 |
|
9013 if ( msg_struct->response != 1) |
|
9014 { |
|
9015 return_value = KErrGeneral; |
|
9016 goto return_code; |
|
9017 } |
|
9018 |
|
9019 //add contact end 1--------------------------------------- |
|
9020 |
|
9021 //delete member 1 st time-------------------------------------------- |
|
9022 |
|
9023 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9024 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9025 index=0; |
|
9026 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9027 msgHdr->message_type = EDelete_Contact_Request; |
|
9028 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9029 index += sizeof( message_hdr_req ); |
|
9030 |
|
9031 |
|
9032 // addiing in q for deleting contact |
|
9033 len = strlen(connect_data->contact ); |
|
9034 strcpy( smsg + index, connect_data->contact ); |
|
9035 index += len + 1; |
|
9036 |
|
9037 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9038 do { |
|
9039 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9040 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9041 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9042 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
9043 |
|
9044 if ( msg_struct->response != 1) |
|
9045 { |
|
9046 return_value = KErrGeneral; |
|
9047 goto return_code; |
|
9048 } |
|
9049 //delete contact end 1--------------------------------------- |
|
9050 |
|
9051 //delete contact 2 nd time-------------------------------------------- |
|
9052 |
|
9053 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9054 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9055 index=0; |
|
9056 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9057 msgHdr->message_type = EDelete_Contact_Request; |
|
9058 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9059 index += sizeof( message_hdr_req ); |
|
9060 |
|
9061 |
|
9062 // delete contact |
|
9063 len = strlen(connect_data->contact ); |
|
9064 strcpy( smsg + index, connect_data->contact ); |
|
9065 index += len + 1; |
|
9066 |
|
9067 |
|
9068 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9069 do { |
|
9070 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9071 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9072 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9073 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
9074 |
|
9075 if ( msg_struct->response != 1) |
|
9076 { |
|
9077 return_value = KErrGeneral; |
|
9078 goto return_code; |
|
9079 } |
|
9080 |
|
9081 //delete contact end--------------------------------------- |
|
9082 |
|
9083 |
|
9084 // logout test code from server |
|
9085 index=0; |
|
9086 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9087 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9088 |
|
9089 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9090 |
|
9091 msgHdr->message_type = ELogout_Request; |
|
9092 |
|
9093 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9094 index += sizeof( message_hdr_req ); |
|
9095 |
|
9096 |
|
9097 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9098 do { |
|
9099 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9100 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9101 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9102 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
9103 |
|
9104 if ( msg_struct->response != 1) |
|
9105 { |
|
9106 return_value = KErrGeneral; |
|
9107 goto return_code; |
|
9108 } |
|
9109 //killing isoserver |
|
9110 return_code: |
|
9111 index=0; |
|
9112 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9113 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9114 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9115 msgHdr->message_type = EKill_Process; |
|
9116 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9117 index += sizeof( message_hdr_req ); |
|
9118 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9119 free( msg_struct ); |
|
9120 return return_value; |
|
9121 } |
|
9122 |
|
9123 |
|
9124 // ----------------------------------------------------------------------------- |
|
9125 // Cisolationserver::add member message |
|
9126 // Example test method function. |
|
9127 // (other items were commented in a header). |
|
9128 // ----------------------------------------------------------------------------- |
|
9129 // |
|
9130 TInt Cisolationserver::ClientSendBlankUserIdForDELETE( CStifItemParser& aItem ) |
|
9131 { |
|
9132 |
|
9133 |
|
9134 ConnectData *connect_data = NULL; |
|
9135 char smsg[MAX_MSG_SIZE]; |
|
9136 char rmsg[MAX_MSG_SIZE]; |
|
9137 int index=0; |
|
9138 FILE *fp; |
|
9139 |
|
9140 int timeout = 200; |
|
9141 int nBytes; |
|
9142 |
|
9143 int result = 0; |
|
9144 int err = 0; |
|
9145 int status = 0; |
|
9146 message_hdr_req *msgHdr = NULL; |
|
9147 message_hdr_resp* msg_struct = NULL; |
|
9148 TInt return_value = 0; |
|
9149 // Read data from the CFG file |
|
9150 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
9151 { |
|
9152 iLog->Log ( _L ( "read_data failed" ) ); |
|
9153 free_data ( connect_data ); |
|
9154 return_value = KErrGeneral; |
|
9155 goto return_code; |
|
9156 } |
|
9157 //request formation |
|
9158 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9159 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9160 |
|
9161 //message header use |
|
9162 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
9163 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9164 |
|
9165 msgHdr->message_type = ELogin_Request; |
|
9166 |
|
9167 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9168 index += sizeof( message_hdr_req ); |
|
9169 |
|
9170 int len = strlen(connect_data->username); |
|
9171 strcpy( smsg + index, connect_data->username ); |
|
9172 index += len + 1; |
|
9173 |
|
9174 //appending password |
|
9175 |
|
9176 len = strlen(connect_data->password ); |
|
9177 strcpy( smsg + index, connect_data->password ); |
|
9178 index += len + 1; |
|
9179 |
|
9180 //appending server name |
|
9181 |
|
9182 len = strlen(connect_data->server ); |
|
9183 strcpy( smsg + index, connect_data->server ); |
|
9184 index += len + 1; |
|
9185 |
|
9186 //appending resource |
|
9187 len = strlen(connect_data->resource ); |
|
9188 strcpy( smsg + index, connect_data->resource ); |
|
9189 index += len + 1; |
|
9190 |
|
9191 //appending ssl |
|
9192 smsg[index++]= '1'; |
|
9193 smsg[index++]= '\0'; |
|
9194 |
|
9195 //appending server port |
|
9196 len = strlen(connect_data->port ); |
|
9197 strcpy( smsg + index, connect_data->port ); |
|
9198 index += len + 1; |
|
9199 |
|
9200 // appending IAP id |
|
9201 |
|
9202 smsg[index++]= '1'; |
|
9203 smsg[index++]= '\0'; |
|
9204 |
|
9205 //appending connmgr_bus |
|
9206 len = strlen(connect_data->connmgr_bus ); |
|
9207 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
9208 index += len + 1; |
|
9209 |
|
9210 //appending connmgr_path |
|
9211 len = strlen(connect_data->connmgr_path ); |
|
9212 strcpy( smsg + index, connect_data->connmgr_path ); |
|
9213 index += len + 1; |
|
9214 |
|
9215 //appending protocol |
|
9216 len = strlen(connect_data->protocol ); |
|
9217 strcpy( smsg + index, connect_data->protocol ); |
|
9218 index += len + 1; |
|
9219 |
|
9220 #ifdef __WINSCW__ |
|
9221 //proxy server |
|
9222 len = strlen(connect_data->proxy_data->proxy_server ); |
|
9223 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
9224 index += len + 1; |
|
9225 |
|
9226 //proxy port |
|
9227 len = strlen(connect_data->proxy_data->proxy_port ); |
|
9228 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
9229 index += len + 1; |
|
9230 |
|
9231 #endif |
|
9232 //running isoserver |
|
9233 run_isoserver(); |
|
9234 |
|
9235 |
|
9236 |
|
9237 //create message queue for send request |
|
9238 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9239 //create message queue for response request |
|
9240 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9241 |
|
9242 |
|
9243 /* Send Message to queueOne */ |
|
9244 |
|
9245 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9246 |
|
9247 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
9248 |
|
9249 if (status < 0) |
|
9250 { |
|
9251 return_value = KErrGeneral; |
|
9252 goto return_code; |
|
9253 } |
|
9254 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
9255 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
9256 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9257 |
|
9258 if( msg_struct->response != 1) |
|
9259 { |
|
9260 return_value = KErrGeneral; |
|
9261 goto return_code; |
|
9262 } |
|
9263 |
|
9264 |
|
9265 // login end |
|
9266 //fetch req.. |
|
9267 for (int i= 0 ;i<3 ;i++) |
|
9268 { |
|
9269 |
|
9270 fp = fopen("c:\\fetch_contact.txt","a"); |
|
9271 do { |
|
9272 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9273 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9274 fwrite(rmsg,1,status,fp); |
|
9275 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9276 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
9277 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
9278 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
9279 fclose(fp); |
|
9280 |
|
9281 } |
|
9282 |
|
9283 //fetch end |
|
9284 |
|
9285 //delete contact -------------------------------------------- |
|
9286 |
|
9287 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9288 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9289 index=0; |
|
9290 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9291 msgHdr->message_type = EDelete_Contact_Request; |
|
9292 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9293 index += sizeof( message_hdr_req ); |
|
9294 |
|
9295 |
|
9296 smsg[index++]='\0'; |
|
9297 //client is sending blank user id |
|
9298 smsg[index++]='\0'; |
|
9299 |
|
9300 |
|
9301 |
|
9302 |
|
9303 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9304 do { |
|
9305 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9306 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9307 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9308 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
9309 |
|
9310 if( msg_struct->error_type >0) |
|
9311 { |
|
9312 return_value = KErrGeneral; |
|
9313 goto return_code; |
|
9314 } |
|
9315 |
|
9316 //delete contact end--------------------------------------- |
|
9317 |
|
9318 |
|
9319 // logout test code from server |
|
9320 index=0; |
|
9321 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9322 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9323 |
|
9324 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9325 |
|
9326 msgHdr->message_type = ELogout_Request; |
|
9327 |
|
9328 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9329 index += sizeof( message_hdr_req ); |
|
9330 |
|
9331 |
|
9332 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9333 do { |
|
9334 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9335 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9336 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9337 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
9338 |
|
9339 if ( msg_struct->response != 1) |
|
9340 { |
|
9341 return_value = KErrGeneral; |
|
9342 goto return_code; |
|
9343 } |
|
9344 //killing isoserver |
|
9345 return_code: |
|
9346 index=0; |
|
9347 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9348 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9349 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9350 msgHdr->message_type = EKill_Process; |
|
9351 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9352 index += sizeof( message_hdr_req ); |
|
9353 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9354 free( msg_struct ); |
|
9355 return return_value; |
|
9356 } |
|
9357 |
|
9358 // ----------------------------------------------------------------------------- |
|
9359 // Cisolationserver::add member message |
|
9360 // Example test method function. |
|
9361 // (other items were commented in a header). |
|
9362 // ----------------------------------------------------------------------------- |
|
9363 // |
|
9364 TInt Cisolationserver::DeleteExistingContactWIthSpace( CStifItemParser& aItem ) |
|
9365 { |
|
9366 |
|
9367 |
|
9368 ConnectData *connect_data = NULL; |
|
9369 char smsg[MAX_MSG_SIZE]; |
|
9370 char rmsg[MAX_MSG_SIZE]; |
|
9371 int index=0; |
|
9372 FILE *fp; |
|
9373 |
|
9374 int timeout = 200; |
|
9375 int nBytes; |
|
9376 |
|
9377 int result = 0; |
|
9378 int err = 0; |
|
9379 int status = 0; |
|
9380 message_hdr_req *msgHdr = NULL; |
|
9381 message_hdr_resp* msg_struct = NULL; |
|
9382 TInt return_value = 0; |
|
9383 // Read data from the CFG file |
|
9384 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
9385 { |
|
9386 iLog->Log ( _L ( "read_data failed" ) ); |
|
9387 free_data ( connect_data ); |
|
9388 return_value = KErrGeneral; |
|
9389 goto return_code; |
|
9390 } |
|
9391 //request formation |
|
9392 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9393 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9394 |
|
9395 //message header use |
|
9396 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
9397 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9398 |
|
9399 msgHdr->message_type = ELogin_Request; |
|
9400 |
|
9401 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9402 index += sizeof( message_hdr_req ); |
|
9403 |
|
9404 int len = strlen(connect_data->username); |
|
9405 strcpy( smsg + index, connect_data->username ); |
|
9406 index += len + 1; |
|
9407 |
|
9408 //appending password |
|
9409 |
|
9410 len = strlen(connect_data->password ); |
|
9411 strcpy( smsg + index, connect_data->password ); |
|
9412 index += len + 1; |
|
9413 |
|
9414 //appending server name |
|
9415 |
|
9416 len = strlen(connect_data->server ); |
|
9417 strcpy( smsg + index, connect_data->server ); |
|
9418 index += len + 1; |
|
9419 |
|
9420 //appending resource |
|
9421 len = strlen(connect_data->resource ); |
|
9422 strcpy( smsg + index, connect_data->resource ); |
|
9423 index += len + 1; |
|
9424 |
|
9425 //appending ssl |
|
9426 smsg[index++]= '1'; |
|
9427 smsg[index++]= '\0'; |
|
9428 |
|
9429 //appending server port |
|
9430 len = strlen(connect_data->port ); |
|
9431 strcpy( smsg + index, connect_data->port ); |
|
9432 index += len + 1; |
|
9433 |
|
9434 // appending IAP id |
|
9435 |
|
9436 smsg[index++]= '1'; |
|
9437 smsg[index++]= '\0'; |
|
9438 |
|
9439 //appending connmgr_bus |
|
9440 len = strlen(connect_data->connmgr_bus ); |
|
9441 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
9442 index += len + 1; |
|
9443 |
|
9444 //appending connmgr_path |
|
9445 len = strlen(connect_data->connmgr_path ); |
|
9446 strcpy( smsg + index, connect_data->connmgr_path ); |
|
9447 index += len + 1; |
|
9448 |
|
9449 //appending protocol |
|
9450 len = strlen(connect_data->protocol ); |
|
9451 strcpy( smsg + index, connect_data->protocol ); |
|
9452 index += len + 1; |
|
9453 |
|
9454 #ifdef __WINSCW__ |
|
9455 //proxy server |
|
9456 len = strlen(connect_data->proxy_data->proxy_server ); |
|
9457 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
9458 index += len + 1; |
|
9459 |
|
9460 //proxy port |
|
9461 len = strlen(connect_data->proxy_data->proxy_port ); |
|
9462 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
9463 index += len + 1; |
|
9464 |
|
9465 #endif |
|
9466 //running isoserver |
|
9467 run_isoserver(); |
|
9468 //create message queue for send request |
|
9469 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9470 //create message queue for response request |
|
9471 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9472 |
|
9473 |
|
9474 /* Send Message to queueOne */ |
|
9475 |
|
9476 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9477 |
|
9478 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
9479 |
|
9480 if (status < 0) |
|
9481 { |
|
9482 return_value = KErrGeneral; |
|
9483 goto return_code; |
|
9484 } |
|
9485 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
9486 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
9487 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9488 |
|
9489 if( msg_struct->response != 1) |
|
9490 { |
|
9491 return_value = KErrGeneral; |
|
9492 goto return_code; |
|
9493 } |
|
9494 |
|
9495 |
|
9496 // login end |
|
9497 |
|
9498 //fetch req.. |
|
9499 for (int i= 0 ;i<3 ;i++) |
|
9500 { |
|
9501 |
|
9502 fp = fopen("c:\\fetch_contact.txt","a"); |
|
9503 do { |
|
9504 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9505 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9506 fwrite(rmsg,1,status,fp); |
|
9507 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9508 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
9509 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
9510 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
9511 fclose(fp); |
|
9512 |
|
9513 } |
|
9514 |
|
9515 //fetch end |
|
9516 |
|
9517 //delete contact-------------------------------------------- |
|
9518 |
|
9519 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9520 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9521 index=0; |
|
9522 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9523 msgHdr->message_type = EDelete_Contact_Request; |
|
9524 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9525 index += sizeof( message_hdr_req ); |
|
9526 |
|
9527 |
|
9528 // adding delete contact in queue |
|
9529 len = strlen(connect_data->contact ); |
|
9530 strcpy( smsg + index, connect_data->contact ); |
|
9531 index += len + 1; |
|
9532 smsg[index++]='\0'; |
|
9533 |
|
9534 |
|
9535 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9536 do { |
|
9537 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9538 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9539 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9540 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
9541 |
|
9542 if( msg_struct->response != 0) |
|
9543 { |
|
9544 return_value = KErrGeneral; |
|
9545 goto return_code; |
|
9546 } |
|
9547 //delete contact end--------------------------------------- |
|
9548 |
|
9549 |
|
9550 // logout test code from server |
|
9551 index=0; |
|
9552 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9553 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9554 |
|
9555 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9556 |
|
9557 msgHdr->message_type = ELogout_Request; |
|
9558 |
|
9559 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9560 index += sizeof( message_hdr_req ); |
|
9561 |
|
9562 |
|
9563 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9564 do { |
|
9565 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9566 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9567 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9568 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
9569 |
|
9570 if ( msg_struct->response != 1) |
|
9571 { |
|
9572 return_value = KErrGeneral; |
|
9573 goto return_code; |
|
9574 } |
|
9575 //killing isoserver |
|
9576 return_code: |
|
9577 index=0; |
|
9578 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9579 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9580 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9581 msgHdr->message_type = EKill_Process; |
|
9582 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9583 index += sizeof( message_hdr_req ); |
|
9584 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9585 free( msg_struct ); |
|
9586 return return_value; |
|
9587 } |
|
9588 |
|
9589 // ----------------------------------------------------------------------------- |
|
9590 // Cisolationserver::add member message |
|
9591 // Example test method function. |
|
9592 // (other items were commented in a header). |
|
9593 // ----------------------------------------------------------------------------- |
|
9594 // |
|
9595 TInt Cisolationserver::DeleteExistingContactWIthMixedLetter( CStifItemParser& aItem ) |
|
9596 { |
|
9597 |
|
9598 |
|
9599 ConnectData *connect_data = NULL; |
|
9600 char smsg[MAX_MSG_SIZE]; |
|
9601 char rmsg[MAX_MSG_SIZE]; |
|
9602 int index=0; |
|
9603 FILE *fp; |
|
9604 |
|
9605 int timeout = 200; |
|
9606 int nBytes; |
|
9607 |
|
9608 int result = 0; |
|
9609 int err = 0; |
|
9610 int status = 0; |
|
9611 message_hdr_req *msgHdr = NULL; |
|
9612 message_hdr_resp* msg_struct = NULL; |
|
9613 TInt return_value = 0; |
|
9614 // Read data from the CFG file |
|
9615 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
9616 { |
|
9617 iLog->Log ( _L ( "read_data failed" ) ); |
|
9618 free_data ( connect_data ); |
|
9619 return_value = KErrGeneral; |
|
9620 goto return_code; |
|
9621 } |
|
9622 //request formation |
|
9623 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9624 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9625 |
|
9626 //message header use |
|
9627 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
9628 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9629 |
|
9630 msgHdr->message_type = ELogin_Request; |
|
9631 |
|
9632 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9633 index += sizeof( message_hdr_req ); |
|
9634 |
|
9635 int len = strlen(connect_data->username); |
|
9636 strcpy( smsg + index, connect_data->username ); |
|
9637 index += len + 1; |
|
9638 |
|
9639 //appending password |
|
9640 |
|
9641 len = strlen(connect_data->password ); |
|
9642 strcpy( smsg + index, connect_data->password ); |
|
9643 index += len + 1; |
|
9644 |
|
9645 //appending server name |
|
9646 |
|
9647 len = strlen(connect_data->server ); |
|
9648 strcpy( smsg + index, connect_data->server ); |
|
9649 index += len + 1; |
|
9650 |
|
9651 //appending resource |
|
9652 len = strlen(connect_data->resource ); |
|
9653 strcpy( smsg + index, connect_data->resource ); |
|
9654 index += len + 1; |
|
9655 |
|
9656 //appending ssl |
|
9657 smsg[index++]= '1'; |
|
9658 smsg[index++]= '\0'; |
|
9659 |
|
9660 //appending server port |
|
9661 len = strlen(connect_data->port ); |
|
9662 strcpy( smsg + index, connect_data->port ); |
|
9663 index += len + 1; |
|
9664 |
|
9665 // appending IAP id |
|
9666 |
|
9667 smsg[index++]= '1'; |
|
9668 smsg[index++]= '\0'; |
|
9669 |
|
9670 //appending connmgr_bus |
|
9671 len = strlen(connect_data->connmgr_bus ); |
|
9672 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
9673 index += len + 1; |
|
9674 |
|
9675 //appending connmgr_path |
|
9676 len = strlen(connect_data->connmgr_path ); |
|
9677 strcpy( smsg + index, connect_data->connmgr_path ); |
|
9678 index += len + 1; |
|
9679 |
|
9680 //appending protocol |
|
9681 len = strlen(connect_data->protocol ); |
|
9682 strcpy( smsg + index, connect_data->protocol ); |
|
9683 index += len + 1; |
|
9684 |
|
9685 #ifdef __WINSCW__ |
|
9686 //proxy server |
|
9687 len = strlen(connect_data->proxy_data->proxy_server ); |
|
9688 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
9689 index += len + 1; |
|
9690 |
|
9691 //proxy port |
|
9692 len = strlen(connect_data->proxy_data->proxy_port ); |
|
9693 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
9694 index += len + 1; |
|
9695 |
|
9696 #endif |
|
9697 |
|
9698 //running isoserver |
|
9699 run_isoserver(); |
|
9700 //create message queue for send request |
|
9701 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9702 //create message queue for response request |
|
9703 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9704 /* Send Message to queueOne */ |
|
9705 |
|
9706 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9707 |
|
9708 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
9709 |
|
9710 if (status < 0) |
|
9711 { |
|
9712 return_value = KErrGeneral; |
|
9713 goto return_code; |
|
9714 } |
|
9715 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
9716 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
9717 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9718 |
|
9719 if( msg_struct->response != 1) |
|
9720 { |
|
9721 return_value = KErrGeneral; |
|
9722 goto return_code; |
|
9723 } |
|
9724 |
|
9725 |
|
9726 // login end |
|
9727 |
|
9728 //fetch req.. |
|
9729 for (int i= 0 ;i<3 ;i++) |
|
9730 { |
|
9731 |
|
9732 fp = fopen("c:\\fetch_contact.txt","a"); |
|
9733 do { |
|
9734 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9735 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9736 fwrite(rmsg,1,status,fp); |
|
9737 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9738 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
9739 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
9740 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
9741 fclose(fp); |
|
9742 |
|
9743 } |
|
9744 |
|
9745 //fetch end |
|
9746 |
|
9747 //delete contact-------------------------------------------- |
|
9748 |
|
9749 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9750 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9751 index=0; |
|
9752 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9753 msgHdr->message_type = EDelete_Contact_Request; |
|
9754 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9755 index += sizeof( message_hdr_req ); |
|
9756 |
|
9757 |
|
9758 // adding delete contact id |
|
9759 len = strlen(connect_data->contact ); |
|
9760 strcpy( smsg + index, connect_data->contact ); |
|
9761 index += len + 1; |
|
9762 |
|
9763 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9764 do { |
|
9765 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9766 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9767 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9768 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
9769 |
|
9770 |
|
9771 //delete contact end--------------------------------------- |
|
9772 |
|
9773 |
|
9774 // logout test code from server |
|
9775 index=0; |
|
9776 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9777 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9778 |
|
9779 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9780 |
|
9781 msgHdr->message_type = ELogout_Request; |
|
9782 |
|
9783 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9784 index += sizeof( message_hdr_req ); |
|
9785 |
|
9786 |
|
9787 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9788 do { |
|
9789 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9790 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9791 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9792 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
9793 |
|
9794 if ( msg_struct->response != 1) |
|
9795 { |
|
9796 return_value = KErrGeneral; |
|
9797 goto return_code; |
|
9798 } |
|
9799 //killing isoserver |
|
9800 return_code: |
|
9801 index=0; |
|
9802 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9803 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9804 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9805 msgHdr->message_type = EKill_Process; |
|
9806 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9807 index += sizeof( message_hdr_req ); |
|
9808 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9809 free( msg_struct ); |
|
9810 return return_value; |
|
9811 } |
|
9812 |
|
9813 // ----------------------------------------------------------------------------- |
|
9814 // Cisolationserver::add member message |
|
9815 // Example test method function. |
|
9816 // (other items were commented in a header). |
|
9817 // ----------------------------------------------------------------------------- |
|
9818 // |
|
9819 TInt Cisolationserver::DeleteInvalidContactWIthSpecialLetter( CStifItemParser& aItem ) |
|
9820 { |
|
9821 |
|
9822 |
|
9823 ConnectData *connect_data = NULL; |
|
9824 char smsg[MAX_MSG_SIZE]; |
|
9825 char rmsg[MAX_MSG_SIZE]; |
|
9826 int index=0; |
|
9827 FILE *fp; |
|
9828 |
|
9829 int timeout = 200; |
|
9830 int nBytes; |
|
9831 |
|
9832 int result = 0; |
|
9833 int err = 0; |
|
9834 int status = 0; |
|
9835 message_hdr_req *msgHdr = NULL; |
|
9836 message_hdr_resp* msg_struct = NULL; |
|
9837 TInt return_value = 0; |
|
9838 // Read data from the CFG file |
|
9839 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
9840 { |
|
9841 iLog->Log ( _L ( "read_data failed" ) ); |
|
9842 free_data ( connect_data ); |
|
9843 return_value = KErrGeneral; |
|
9844 goto return_code; |
|
9845 } |
|
9846 //request formation |
|
9847 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9848 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9849 |
|
9850 //message header use |
|
9851 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
9852 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9853 |
|
9854 msgHdr->message_type = ELogin_Request; |
|
9855 |
|
9856 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9857 index += sizeof( message_hdr_req ); |
|
9858 |
|
9859 int len = strlen(connect_data->username); |
|
9860 strcpy( smsg + index, connect_data->username ); |
|
9861 index += len + 1; |
|
9862 |
|
9863 //appending password |
|
9864 |
|
9865 len = strlen(connect_data->password ); |
|
9866 strcpy( smsg + index, connect_data->password ); |
|
9867 index += len + 1; |
|
9868 |
|
9869 //appending server name |
|
9870 |
|
9871 len = strlen(connect_data->server ); |
|
9872 strcpy( smsg + index, connect_data->server ); |
|
9873 index += len + 1; |
|
9874 |
|
9875 //appending resource |
|
9876 len = strlen(connect_data->resource ); |
|
9877 strcpy( smsg + index, connect_data->resource ); |
|
9878 index += len + 1; |
|
9879 |
|
9880 //appending ssl |
|
9881 smsg[index++]= '1'; |
|
9882 smsg[index++]= '\0'; |
|
9883 |
|
9884 //appending server port |
|
9885 len = strlen(connect_data->port ); |
|
9886 strcpy( smsg + index, connect_data->port ); |
|
9887 index += len + 1; |
|
9888 |
|
9889 // appending IAP id |
|
9890 |
|
9891 smsg[index++]= '1'; |
|
9892 smsg[index++]= '\0'; |
|
9893 |
|
9894 //appending connmgr_bus |
|
9895 len = strlen(connect_data->connmgr_bus ); |
|
9896 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
9897 index += len + 1; |
|
9898 |
|
9899 //appending connmgr_path |
|
9900 len = strlen(connect_data->connmgr_path ); |
|
9901 strcpy( smsg + index, connect_data->connmgr_path ); |
|
9902 index += len + 1; |
|
9903 |
|
9904 //appending protocol |
|
9905 len = strlen(connect_data->protocol ); |
|
9906 strcpy( smsg + index, connect_data->protocol ); |
|
9907 index += len + 1; |
|
9908 |
|
9909 #ifdef __WINSCW__ |
|
9910 //proxy server |
|
9911 len = strlen(connect_data->proxy_data->proxy_server ); |
|
9912 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
9913 index += len + 1; |
|
9914 |
|
9915 //proxy port |
|
9916 len = strlen(connect_data->proxy_data->proxy_port ); |
|
9917 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
9918 index += len + 1; |
|
9919 |
|
9920 #endif |
|
9921 //running isoserver |
|
9922 run_isoserver(); |
|
9923 //create message queue for send request |
|
9924 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9925 //create message queue for response request |
|
9926 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
9927 |
|
9928 |
|
9929 /* Send Message to queueOne */ |
|
9930 |
|
9931 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9932 |
|
9933 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
9934 |
|
9935 if (status < 0) |
|
9936 { |
|
9937 return_value = KErrGeneral; |
|
9938 goto return_code; |
|
9939 } |
|
9940 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
9941 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
9942 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9943 |
|
9944 if( msg_struct->response != 1) |
|
9945 { |
|
9946 return_value = KErrGeneral; |
|
9947 goto return_code; |
|
9948 } |
|
9949 |
|
9950 |
|
9951 // login end |
|
9952 |
|
9953 //fetch req.. |
|
9954 for (int i= 0 ;i<3 ;i++) |
|
9955 { |
|
9956 |
|
9957 fp = fopen("c:\\fetch_contact.txt","a"); |
|
9958 do { |
|
9959 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9960 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9961 fwrite(rmsg,1,status,fp); |
|
9962 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9963 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
9964 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
9965 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
9966 fclose(fp); |
|
9967 |
|
9968 } |
|
9969 |
|
9970 //fetch end |
|
9971 |
|
9972 //delete contact-------------------------------------------- |
|
9973 |
|
9974 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
9975 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9976 index=0; |
|
9977 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
9978 msgHdr->message_type = EDelete_Contact_Request; |
|
9979 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
9980 index += sizeof( message_hdr_req ); |
|
9981 |
|
9982 |
|
9983 // adding delete contact |
|
9984 len = strlen(connect_data->contact ); |
|
9985 strcpy( smsg + index, connect_data->contact ); |
|
9986 index += len + 1; |
|
9987 |
|
9988 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
9989 do { |
|
9990 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
9991 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
9992 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
9993 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
9994 |
|
9995 if ( msg_struct->response != 1) |
|
9996 { |
|
9997 return_value = KErrGeneral; |
|
9998 goto return_code; |
|
9999 } |
|
10000 |
|
10001 //delete contact end--------------------------------------- |
|
10002 |
|
10003 |
|
10004 // logout test code from server |
|
10005 index=0; |
|
10006 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10007 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10008 |
|
10009 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10010 |
|
10011 msgHdr->message_type = ELogout_Request; |
|
10012 |
|
10013 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10014 index += sizeof( message_hdr_req ); |
|
10015 |
|
10016 |
|
10017 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10018 do { |
|
10019 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10020 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10021 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10022 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
10023 |
|
10024 if ( msg_struct->response != 1) |
|
10025 { |
|
10026 return_value = KErrGeneral; |
|
10027 goto return_code; |
|
10028 } |
|
10029 //killing isoserver |
|
10030 return_code: |
|
10031 index=0; |
|
10032 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10033 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10034 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10035 msgHdr->message_type = EKill_Process; |
|
10036 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10037 index += sizeof( message_hdr_req ); |
|
10038 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10039 free( msg_struct ); |
|
10040 return return_value; |
|
10041 } |
|
10042 |
|
10043 // ----------------------------------------------------------------------------- |
|
10044 // Cisolationserver::Login with correct data |
|
10045 // Example test method function. |
|
10046 // (other items were commented in a header). |
|
10047 // ----------------------------------------------------------------------------- |
|
10048 // |
|
10049 TInt Cisolationserver::FetchContatcs( CStifItemParser& aItem ) |
|
10050 { |
|
10051 |
|
10052 |
|
10053 ConnectData *connect_data = NULL; |
|
10054 char smsg[MAX_MSG_SIZE]; |
|
10055 char rmsg[MAX_MSG_SIZE]; |
|
10056 int index=0; |
|
10057 FILE *fp; |
|
10058 |
|
10059 int timeout = 100; |
|
10060 int nBytes; |
|
10061 |
|
10062 int result = 0; |
|
10063 int err = 0; |
|
10064 int status = 0; |
|
10065 message_hdr_req *msgHdr = NULL; |
|
10066 message_hdr_resp* msg_struct = NULL; |
|
10067 TInt return_value = 0; |
|
10068 // Read data from the CFG file |
|
10069 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
10070 { |
|
10071 iLog->Log ( _L ( "read_data failed" ) ); |
|
10072 free_data ( connect_data ); |
|
10073 return_value = KErrGeneral; |
|
10074 goto return_code; |
|
10075 } |
|
10076 //request formation |
|
10077 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10078 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10079 |
|
10080 //message header use |
|
10081 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
10082 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10083 |
|
10084 msgHdr->message_type = ELogin_Request; |
|
10085 |
|
10086 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10087 index += sizeof( message_hdr_req ); |
|
10088 |
|
10089 int len = strlen(connect_data->username); |
|
10090 strcpy( smsg + index, connect_data->username ); |
|
10091 index += len + 1; |
|
10092 |
|
10093 //appending password |
|
10094 |
|
10095 len = strlen(connect_data->password ); |
|
10096 strcpy( smsg + index, connect_data->password ); |
|
10097 index += len + 1; |
|
10098 |
|
10099 //appending server name |
|
10100 |
|
10101 len = strlen(connect_data->server ); |
|
10102 strcpy( smsg + index, connect_data->server ); |
|
10103 index += len + 1; |
|
10104 |
|
10105 //appending resource |
|
10106 len = strlen(connect_data->resource ); |
|
10107 strcpy( smsg + index, connect_data->resource ); |
|
10108 index += len + 1; |
|
10109 |
|
10110 //appending ssl |
|
10111 smsg[index++]= '1'; |
|
10112 smsg[index++]= '\0'; |
|
10113 |
|
10114 //appending server port |
|
10115 len = strlen(connect_data->port ); |
|
10116 strcpy( smsg + index, connect_data->port ); |
|
10117 index += len + 1; |
|
10118 |
|
10119 // appending IAP id |
|
10120 |
|
10121 smsg[index++]= '1'; |
|
10122 smsg[index++]= '\0'; |
|
10123 |
|
10124 |
|
10125 //appending connmgr_bus |
|
10126 len = strlen(connect_data->connmgr_bus ); |
|
10127 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
10128 index += len + 1; |
|
10129 |
|
10130 //appending connmgr_path |
|
10131 len = strlen(connect_data->connmgr_path ); |
|
10132 strcpy( smsg + index, connect_data->connmgr_path ); |
|
10133 index += len + 1; |
|
10134 |
|
10135 //appending protocol |
|
10136 len = strlen(connect_data->protocol ); |
|
10137 strcpy( smsg + index, connect_data->protocol ); |
|
10138 index += len + 1; |
|
10139 |
|
10140 #ifdef __WINSCW__ |
|
10141 //proxy server |
|
10142 len = strlen(connect_data->proxy_data->proxy_server ); |
|
10143 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
10144 index += len + 1; |
|
10145 |
|
10146 //proxy port |
|
10147 len = strlen(connect_data->proxy_data->proxy_port ); |
|
10148 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
10149 index += len + 1; |
|
10150 |
|
10151 #endif |
|
10152 //running isoserver |
|
10153 run_isoserver(); |
|
10154 //create message queue for send request |
|
10155 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
10156 //create message queue for response request |
|
10157 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
10158 |
|
10159 |
|
10160 /* Send Message to queueOne */ |
|
10161 |
|
10162 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10163 |
|
10164 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
10165 |
|
10166 if (status < 0) |
|
10167 { |
|
10168 return_value = KErrGeneral; |
|
10169 goto return_code; |
|
10170 } |
|
10171 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
10172 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
10173 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10174 |
|
10175 if( msg_struct->response != 1) |
|
10176 { |
|
10177 return_value = KErrGeneral; |
|
10178 goto return_code; |
|
10179 } |
|
10180 |
|
10181 |
|
10182 // login end |
|
10183 //fetch req.. |
|
10184 for (int i= 0 ;i<3 ;i++) |
|
10185 { |
|
10186 |
|
10187 fp = fopen("c:\\fetch_contact.txt","a"); |
|
10188 do { |
|
10189 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10190 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10191 fwrite(rmsg,1,status,fp); |
|
10192 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10193 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
10194 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
10195 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
10196 fclose(fp); |
|
10197 |
|
10198 } |
|
10199 |
|
10200 //fetch end |
|
10201 // logout test code from server |
|
10202 // logout test code from server |
|
10203 index=0; |
|
10204 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10205 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10206 |
|
10207 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10208 |
|
10209 msgHdr->message_type = ELogout_Request; |
|
10210 |
|
10211 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10212 index += sizeof( message_hdr_req ); |
|
10213 |
|
10214 |
|
10215 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10216 do { |
|
10217 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10218 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10219 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10220 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
10221 |
|
10222 if ( msg_struct->response != 1) |
|
10223 { |
|
10224 return_value = KErrGeneral; |
|
10225 goto return_code; |
|
10226 } |
|
10227 //killing isoserver |
|
10228 return_code: |
|
10229 index=0; |
|
10230 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10231 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10232 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10233 msgHdr->message_type = EKill_Process; |
|
10234 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10235 index += sizeof( message_hdr_req ); |
|
10236 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10237 free( msg_struct ); |
|
10238 return return_value; |
|
10239 } |
|
10240 |
|
10241 |
|
10242 TInt Cisolationserver::AddContatcs( CStifItemParser& aItem ) |
|
10243 { |
|
10244 ConnectData *connect_data = NULL; |
|
10245 char smsg[MAX_MSG_SIZE]; |
|
10246 char rmsg[MAX_MSG_SIZE]; |
|
10247 int index=0; |
|
10248 FILE *fp; |
|
10249 |
|
10250 int timeout = 200; |
|
10251 int nBytes; |
|
10252 |
|
10253 int result = 0; |
|
10254 int err = 0; |
|
10255 int status = 0; |
|
10256 message_hdr_req *msgHdr = NULL; |
|
10257 message_hdr_resp* msg_struct = NULL; |
|
10258 TInt return_value = 0; |
|
10259 // Read data from the CFG file |
|
10260 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
10261 { |
|
10262 iLog->Log ( _L ( "read_data failed" ) ); |
|
10263 free_data ( connect_data ); |
|
10264 return_value = KErrGeneral; |
|
10265 goto return_code; |
|
10266 } |
|
10267 //request formation |
|
10268 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10269 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10270 |
|
10271 //message header use |
|
10272 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
10273 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10274 |
|
10275 msgHdr->message_type = ELogin_Request; |
|
10276 |
|
10277 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10278 index += sizeof( message_hdr_req ); |
|
10279 |
|
10280 int len = strlen(connect_data->username); |
|
10281 strcpy( smsg + index, connect_data->username ); |
|
10282 index += len + 1; |
|
10283 |
|
10284 //appending password |
|
10285 |
|
10286 len = strlen(connect_data->password ); |
|
10287 strcpy( smsg + index, connect_data->password ); |
|
10288 index += len + 1; |
|
10289 |
|
10290 //appending server name |
|
10291 |
|
10292 len = strlen(connect_data->server ); |
|
10293 strcpy( smsg + index, connect_data->server ); |
|
10294 index += len + 1; |
|
10295 |
|
10296 //appending resource |
|
10297 len = strlen(connect_data->resource ); |
|
10298 strcpy( smsg + index, connect_data->resource ); |
|
10299 index += len + 1; |
|
10300 |
|
10301 //appending ssl |
|
10302 smsg[index++]= '1'; |
|
10303 smsg[index++]= '\0'; |
|
10304 |
|
10305 //appending server port |
|
10306 len = strlen(connect_data->port ); |
|
10307 strcpy( smsg + index, connect_data->port ); |
|
10308 index += len + 1; |
|
10309 |
|
10310 // appending IAP id |
|
10311 |
|
10312 smsg[index++]= '1'; |
|
10313 smsg[index++]= '\0'; |
|
10314 |
|
10315 //appending connmgr_bus |
|
10316 len = strlen(connect_data->connmgr_bus ); |
|
10317 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
10318 index += len + 1; |
|
10319 |
|
10320 //appending connmgr_path |
|
10321 len = strlen(connect_data->connmgr_path ); |
|
10322 strcpy( smsg + index, connect_data->connmgr_path ); |
|
10323 index += len + 1; |
|
10324 |
|
10325 //appending protocol |
|
10326 len = strlen(connect_data->protocol ); |
|
10327 strcpy( smsg + index, connect_data->protocol ); |
|
10328 index += len + 1; |
|
10329 |
|
10330 #ifdef __WINSCW__ |
|
10331 //proxy server |
|
10332 len = strlen(connect_data->proxy_data->proxy_server ); |
|
10333 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
10334 index += len + 1; |
|
10335 |
|
10336 //proxy port |
|
10337 len = strlen(connect_data->proxy_data->proxy_port ); |
|
10338 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
10339 index += len + 1; |
|
10340 |
|
10341 #endif |
|
10342 |
|
10343 |
|
10344 //running isoserver |
|
10345 run_isoserver(); |
|
10346 |
|
10347 //create message queue for send request |
|
10348 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
10349 //create message queue for response request |
|
10350 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
10351 |
|
10352 |
|
10353 /* Send Message to queueOne */ |
|
10354 |
|
10355 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10356 |
|
10357 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
10358 |
|
10359 if (status < 0) |
|
10360 { |
|
10361 return_value = KErrGeneral; |
|
10362 goto return_code; |
|
10363 } |
|
10364 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
10365 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
10366 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10367 |
|
10368 if( msg_struct->response != 1) |
|
10369 { |
|
10370 return_value = KErrGeneral; |
|
10371 goto return_code; |
|
10372 } |
|
10373 |
|
10374 |
|
10375 // login end |
|
10376 //fetch req.. |
|
10377 for (int i= 0 ;i<3 ;i++) |
|
10378 { |
|
10379 |
|
10380 fp = fopen("c:\\fetch_contact.txt","a"); |
|
10381 do { |
|
10382 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10383 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10384 fwrite(rmsg,1,status,fp); |
|
10385 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10386 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
10387 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
10388 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
10389 fclose(fp); |
|
10390 |
|
10391 } |
|
10392 |
|
10393 //fetch end |
|
10394 //send msg copy |
|
10395 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10396 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10397 index=0; |
|
10398 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10399 msgHdr->message_type = ESend_Request; |
|
10400 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10401 index += sizeof( message_hdr_req ); |
|
10402 |
|
10403 //------------------------1 |
|
10404 // adding recipient |
|
10405 len = strlen( "santhosh09431243.ic@gmail.com" ); |
|
10406 strcpy( smsg + index, "santhosh09431243.ic@gmail.com" ); |
|
10407 index += len + 1; |
|
10408 |
|
10409 smsg[index++] = '\0'; |
|
10410 |
|
10411 // adding message part |
|
10412 |
|
10413 len = strlen(connect_data->msg_data->message ); |
|
10414 strcpy( smsg + index, connect_data->msg_data->message ); |
|
10415 index += len + 1; |
|
10416 |
|
10417 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10418 |
|
10419 do { |
|
10420 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10421 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10422 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10423 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
10424 |
|
10425 if ( msg_struct->response != 1) |
|
10426 { |
|
10427 return_value = KErrGeneral; |
|
10428 goto return_code; |
|
10429 } |
|
10430 //send msg copy end |
|
10431 |
|
10432 |
|
10433 |
|
10434 //EAdd_Contact_Request messge-------------------------------------------- |
|
10435 |
|
10436 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10437 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10438 index=0; |
|
10439 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10440 msgHdr->message_type = EAdd_Contact_Request; |
|
10441 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10442 index += sizeof( message_hdr_req ); |
|
10443 |
|
10444 |
|
10445 // adding recipient |
|
10446 //len = strlen( "tele1236@gmail.com" ); |
|
10447 //strcpy( smsg + index, "tele1236@gmail.com" ); |
|
10448 //index += len + 1; |
|
10449 |
|
10450 strcpy( smsg + index, "testlm123@gmail.com" ); |
|
10451 index += strlen( "testlm123@gmail.com" ) + 1; |
|
10452 |
|
10453 smsg[index++] = '\0'; |
|
10454 |
|
10455 // adding message part |
|
10456 |
|
10457 len = strlen(connect_data->msg_data->message ); |
|
10458 strcpy( smsg + index, connect_data->msg_data->message ); |
|
10459 index += len + 1; |
|
10460 |
|
10461 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10462 |
|
10463 do { |
|
10464 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10465 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10466 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10467 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
10468 |
|
10469 if ( msg_struct->response != 1) |
|
10470 { |
|
10471 return_value = KErrGeneral; |
|
10472 goto return_code; |
|
10473 } |
|
10474 |
|
10475 |
|
10476 // sleep( 50 ); |
|
10477 //EAdd_Contact_Request message end--------------------------------------- |
|
10478 |
|
10479 /* sleep( 100 ); |
|
10480 //--------------------------------Trying to add client notification---------------------- |
|
10481 |
|
10482 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
10483 |
|
10484 if ( status < 0 ) |
|
10485 { |
|
10486 return_value = KErrGeneral; |
|
10487 goto return_code; |
|
10488 } |
|
10489 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
10490 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
10491 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10492 if ( msg_struct->response != 1) |
|
10493 { |
|
10494 return_value = KErrGeneral; |
|
10495 goto return_code; |
|
10496 } |
|
10497 */ |
|
10498 //--------------------------------Trying to add client end---------------------- |
|
10499 |
|
10500 |
|
10501 |
|
10502 |
|
10503 //EAdd_Contact_Request messge-------------------------------------------- |
|
10504 |
|
10505 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10506 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10507 index=0; |
|
10508 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10509 msgHdr->message_type = EAdd_Contact_Request; |
|
10510 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10511 index += sizeof( message_hdr_req ); |
|
10512 |
|
10513 |
|
10514 // adding recipient |
|
10515 len = strlen(connect_data->msg_data->recipient ); |
|
10516 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10517 index += len + 1; |
|
10518 |
|
10519 strcpy( smsg + index, "tele1236@gmail.com" ); |
|
10520 index += strlen( "tele1236@gmail.com" ) + 1; |
|
10521 |
|
10522 // adding recipient |
|
10523 //len = strlen(connect_data->msg_data->recipient ); |
|
10524 //strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10525 //index += len + 1; |
|
10526 |
|
10527 smsg[index++] = '\0'; |
|
10528 |
|
10529 // adding message part |
|
10530 |
|
10531 len = strlen(connect_data->msg_data->message ); |
|
10532 strcpy( smsg + index, connect_data->msg_data->message ); |
|
10533 index += len + 1; |
|
10534 |
|
10535 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10536 |
|
10537 do { |
|
10538 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10539 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10540 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10541 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
10542 |
|
10543 if ( msg_struct->response != 1) |
|
10544 { |
|
10545 return_value = KErrGeneral; |
|
10546 goto return_code; |
|
10547 } |
|
10548 |
|
10549 //EAdd_Contact_Request message end--------------------------------------- |
|
10550 |
|
10551 |
|
10552 |
|
10553 //EAdd_Contact_Request -ve messge-------------------------------------------- |
|
10554 |
|
10555 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10556 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10557 index=0; |
|
10558 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10559 msgHdr->message_type = EAdd_Contact_Request; |
|
10560 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10561 index += sizeof( message_hdr_req ); |
|
10562 |
|
10563 //-----------------1 |
|
10564 // adding recipient |
|
10565 len = strlen(connect_data->msg_data->recipient ); |
|
10566 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10567 index += len + 1; |
|
10568 |
|
10569 strcpy( smsg + index, "tele1236@gmail.com" ); |
|
10570 index += strlen( "tele1236@gmail.com" ) + 1; |
|
10571 |
|
10572 smsg[index++] = '\0'; |
|
10573 |
|
10574 // adding message part |
|
10575 |
|
10576 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10577 |
|
10578 do { |
|
10579 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10580 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10581 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10582 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
10583 |
|
10584 if ( msg_struct->response != 1) |
|
10585 { |
|
10586 return_value = KErrGeneral; |
|
10587 goto return_code; |
|
10588 } |
|
10589 |
|
10590 //-----------------2 -ve |
|
10591 index = 0; |
|
10592 index += sizeof( message_hdr_req ); |
|
10593 // adding recipient |
|
10594 len = strlen(connect_data->msg_data->recipient ); |
|
10595 memcpy( smsg + index, connect_data->msg_data->recipient, len ); |
|
10596 index += len; |
|
10597 |
|
10598 // adding message part |
|
10599 |
|
10600 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10601 |
|
10602 do { |
|
10603 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10604 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10605 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10606 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
10607 |
|
10608 if ( msg_struct->response != 1) |
|
10609 { |
|
10610 return_value = KErrGeneral; |
|
10611 goto return_code; |
|
10612 } |
|
10613 //----------------- |
|
10614 |
|
10615 |
|
10616 //EAdd_Contact_Request -ve message end--------------------------------------- |
|
10617 |
|
10618 //send messge-------------------------------------------- |
|
10619 |
|
10620 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10621 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10622 index=0; |
|
10623 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10624 msgHdr->message_type = ESend_Request; |
|
10625 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10626 index += sizeof( message_hdr_req ); |
|
10627 |
|
10628 //------------------------1 |
|
10629 // adding recipient |
|
10630 len = strlen( "santhosh.ic@gmail.com" ); |
|
10631 strcpy( smsg + index, "santhosh.ic@gmail.com" ); |
|
10632 index += len + 1; |
|
10633 |
|
10634 // adding recipient |
|
10635 len = strlen(connect_data->msg_data->recipient ); |
|
10636 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10637 index += len + 1; |
|
10638 |
|
10639 smsg[index++] = '\0'; |
|
10640 |
|
10641 // adding message part |
|
10642 |
|
10643 len = strlen(connect_data->msg_data->message ); |
|
10644 strcpy( smsg + index, connect_data->msg_data->message ); |
|
10645 index += len + 1; |
|
10646 |
|
10647 |
|
10648 |
|
10649 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10650 |
|
10651 do { |
|
10652 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10653 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10654 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10655 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
10656 |
|
10657 if ( msg_struct->response != 1) |
|
10658 { |
|
10659 return_value = KErrGeneral; |
|
10660 goto return_code; |
|
10661 } |
|
10662 //-----------------------------------2 -ve |
|
10663 index = 0; |
|
10664 index += sizeof( message_hdr_req ); |
|
10665 // adding recipient |
|
10666 for ( int i = 0; i <= 11; i++ ) |
|
10667 { |
|
10668 len = strlen( "santhosh.ic@gmail.com" ); |
|
10669 strcpy( smsg + index, "santhosh.ic@gmail.com" ); |
|
10670 index += len + 1; |
|
10671 } |
|
10672 smsg[index++] = '\0'; |
|
10673 // adding message part |
|
10674 |
|
10675 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10676 |
|
10677 do { |
|
10678 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10679 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10680 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10681 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
10682 |
|
10683 if ( msg_struct->response != 0) |
|
10684 { |
|
10685 return_value = KErrGeneral; |
|
10686 goto return_code; |
|
10687 } |
|
10688 |
|
10689 |
|
10690 //-----------------------------------3 -ve |
|
10691 index = 0; |
|
10692 index += sizeof( message_hdr_req ); |
|
10693 // adding recipient |
|
10694 len = strlen(connect_data->msg_data->recipient ); |
|
10695 memcpy( smsg + index, connect_data->msg_data->recipient, len ); |
|
10696 index += len; |
|
10697 |
|
10698 // adding message part |
|
10699 |
|
10700 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10701 |
|
10702 do { |
|
10703 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10704 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10705 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10706 } while (msg_struct->hdr_req.message_type!=ESend_Request); |
|
10707 |
|
10708 if ( msg_struct->response != 0) |
|
10709 { |
|
10710 return_value = KErrGeneral; |
|
10711 goto return_code; |
|
10712 } |
|
10713 |
|
10714 //send message end--------------------------------------- |
|
10715 |
|
10716 //EDelete_Contact_Request messge-------------------------------------------- |
|
10717 |
|
10718 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10719 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10720 index=0; |
|
10721 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10722 msgHdr->message_type = EDelete_Contact_Request; |
|
10723 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10724 index += sizeof( message_hdr_req ); |
|
10725 |
|
10726 |
|
10727 // adding recipient |
|
10728 len = strlen(connect_data->msg_data->recipient ); |
|
10729 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10730 index += len + 1; |
|
10731 |
|
10732 strcpy( smsg + index, "tele1236@gmail.com" ); |
|
10733 index += strlen( "tele1236@gmail.com" ) + 1; |
|
10734 |
|
10735 // adding recipient |
|
10736 //len = strlen(connect_data->msg_data->recipient ); |
|
10737 //strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10738 //index += len + 1; |
|
10739 |
|
10740 smsg[index++] = '\0'; |
|
10741 |
|
10742 // adding message part |
|
10743 |
|
10744 len = strlen(connect_data->msg_data->message ); |
|
10745 strcpy( smsg + index, connect_data->msg_data->message ); |
|
10746 index += len + 1; |
|
10747 |
|
10748 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10749 |
|
10750 do { |
|
10751 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10752 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10753 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10754 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
10755 |
|
10756 if ( msg_struct->response != 0) |
|
10757 { |
|
10758 return_value = KErrGeneral; |
|
10759 goto return_code; |
|
10760 } |
|
10761 //--------------------delete---------------------- |
|
10762 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10763 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10764 index=0; |
|
10765 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10766 msgHdr->message_type = EDelete_Contact_Request; |
|
10767 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10768 index += sizeof( message_hdr_req ); |
|
10769 |
|
10770 |
|
10771 // adding recipient |
|
10772 len = strlen(connect_data->msg_data->recipient ); |
|
10773 strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10774 index += len + 1; |
|
10775 |
|
10776 strcpy( smsg + index, "rakesh.harsh@gmail.com" ); |
|
10777 index += strlen( "rakesh.harsh@gmail.com" ) + 1; |
|
10778 |
|
10779 // adding recipient |
|
10780 //len = strlen(connect_data->msg_data->recipient ); |
|
10781 //strcpy( smsg + index, connect_data->msg_data->recipient ); |
|
10782 //index += len + 1; |
|
10783 |
|
10784 smsg[index++] = '\0'; |
|
10785 |
|
10786 // adding message part |
|
10787 |
|
10788 len = strlen(connect_data->msg_data->message ); |
|
10789 strcpy( smsg + index, connect_data->msg_data->message ); |
|
10790 index += len + 1; |
|
10791 |
|
10792 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10793 |
|
10794 do { |
|
10795 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10796 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10797 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10798 } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request); |
|
10799 |
|
10800 |
|
10801 |
|
10802 //EDelete_Contact_Request message end--------------------------------------- |
|
10803 |
|
10804 //--------------Recieve message----------------------------------- |
|
10805 /* do { |
|
10806 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10807 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10808 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10809 } while (msg_struct->hdr_req.message_type!=EText_Message_Receive); |
|
10810 |
|
10811 if ( msg_struct->response != 1) |
|
10812 { |
|
10813 return_value = KErrGeneral; |
|
10814 goto return_code; |
|
10815 } |
|
10816 do { |
|
10817 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10818 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10819 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10820 } while (msg_struct->hdr_req.message_type!=EText_Message_Receive); |
|
10821 |
|
10822 if ( msg_struct->response != 1) |
|
10823 { |
|
10824 return_value = KErrGeneral; |
|
10825 goto return_code; |
|
10826 } */ //------------------------Recieve message end--------------------- |
|
10827 |
|
10828 //-------------update presence with available--------------- |
|
10829 |
|
10830 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10831 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10832 index=0; |
|
10833 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10834 msgHdr->message_type = EUpdateOwnPresence; |
|
10835 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10836 index += sizeof( message_hdr_req ); |
|
10837 |
|
10838 |
|
10839 // updating availability |
|
10840 char *availability = "available"; |
|
10841 memcpy( smsg + index, availability, strlen( availability ) ); |
|
10842 index += strlen( availability ); |
|
10843 |
|
10844 smsg[index++]='\0'; |
|
10845 |
|
10846 //updating status text |
|
10847 char *statustext = "i m busy"; |
|
10848 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
10849 index += strlen( statustext ); |
|
10850 |
|
10851 |
|
10852 |
|
10853 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10854 |
|
10855 do { |
|
10856 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10857 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10858 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10859 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
10860 |
|
10861 if ( msg_struct->response != 1) |
|
10862 { |
|
10863 return_value = KErrGeneral; |
|
10864 goto return_code; |
|
10865 } |
|
10866 // ------------------------------------------------------------------ |
|
10867 |
|
10868 //-------------update presence with available--------------- |
|
10869 |
|
10870 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10871 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10872 index=0; |
|
10873 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10874 msgHdr->message_type = EUpdateOwnPresence; |
|
10875 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10876 index += sizeof( message_hdr_req ); |
|
10877 |
|
10878 |
|
10879 // updating availability |
|
10880 char *availability1 = "dnd"; |
|
10881 memcpy( smsg + index, availability1, strlen( availability1 ) ); |
|
10882 index += strlen( availability1 ); |
|
10883 |
|
10884 smsg[index++]='\0'; |
|
10885 |
|
10886 //updating status text |
|
10887 char *statustext1 = "i m busy"; |
|
10888 memcpy( smsg + index, statustext1, strlen( statustext1 ) ); |
|
10889 index += strlen( statustext1 ); |
|
10890 |
|
10891 |
|
10892 |
|
10893 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10894 |
|
10895 do { |
|
10896 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10897 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10898 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10899 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
10900 |
|
10901 if ( msg_struct->response != 1) |
|
10902 { |
|
10903 return_value = KErrGeneral; |
|
10904 goto return_code; |
|
10905 } |
|
10906 // ------------------------------------------------------------------ |
|
10907 |
|
10908 //-------------update presence with available--------------- |
|
10909 |
|
10910 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10911 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10912 index=0; |
|
10913 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10914 msgHdr->message_type = EUpdateOwnPresence; |
|
10915 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10916 index += sizeof( message_hdr_req ); |
|
10917 |
|
10918 |
|
10919 // updating availability |
|
10920 char *availability2 = "away"; |
|
10921 memcpy( smsg + index, availability2, strlen( availability2 ) ); |
|
10922 index += strlen( availability2 ); |
|
10923 |
|
10924 smsg[index++]='\0'; |
|
10925 |
|
10926 //updating status text |
|
10927 char *statustext2 = "i m busy"; |
|
10928 memcpy( smsg + index, statustext2, strlen( statustext2 ) ); |
|
10929 index += strlen( statustext2 ); |
|
10930 |
|
10931 |
|
10932 |
|
10933 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10934 |
|
10935 do { |
|
10936 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10937 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10938 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10939 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
10940 |
|
10941 if ( msg_struct->response != 1) |
|
10942 { |
|
10943 return_value = KErrGeneral; |
|
10944 goto return_code; |
|
10945 } |
|
10946 // ------------------------------------------------------------------ |
|
10947 |
|
10948 //----------------------------presence negative case------------------ |
|
10949 |
|
10950 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10951 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10952 index=0; |
|
10953 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10954 msgHdr->message_type = EUpdateOwnPresence; |
|
10955 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10956 index += sizeof( message_hdr_req ); |
|
10957 |
|
10958 |
|
10959 // updating availability with blank |
|
10960 smsg[index++]='\0'; |
|
10961 smsg[index++]='\0'; |
|
10962 //smsg[index++]='\0'; |
|
10963 |
|
10964 //updating status text |
|
10965 char *statustext4 = "i m not on desk"; |
|
10966 memcpy( smsg + index, statustext4, strlen( statustext4 ) ); |
|
10967 index += strlen( statustext4 ); |
|
10968 |
|
10969 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
10970 |
|
10971 do { |
|
10972 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
10973 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
10974 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10975 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
10976 |
|
10977 if ( msg_struct->error_type > 0) |
|
10978 { |
|
10979 return_value = KErrGeneral; |
|
10980 goto return_code; |
|
10981 } |
|
10982 |
|
10983 //-------------------------1 end |
|
10984 |
|
10985 // update 2 negative |
|
10986 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
10987 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
10988 index=0; |
|
10989 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
10990 msgHdr->message_type = EUpdateOwnPresence; |
|
10991 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
10992 index += sizeof( message_hdr_req ); |
|
10993 |
|
10994 |
|
10995 // updating availability |
|
10996 char *availability4 = "available"; |
|
10997 memcpy( smsg + index, availability, strlen( availability4 ) ); |
|
10998 index += strlen( availability4 ); |
|
10999 |
|
11000 |
|
11001 |
|
11002 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11003 |
|
11004 do { |
|
11005 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11006 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11007 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11008 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
11009 |
|
11010 if ( msg_struct->response != 1) |
|
11011 { |
|
11012 return_value = KErrGeneral; |
|
11013 goto return_code; |
|
11014 } |
|
11015 //---- |
|
11016 // logout test code from server |
|
11017 index=0; |
|
11018 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11019 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11020 |
|
11021 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11022 |
|
11023 msgHdr->message_type = ELogout_Request; |
|
11024 |
|
11025 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11026 index += sizeof( message_hdr_req ); |
|
11027 |
|
11028 |
|
11029 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11030 |
|
11031 do { |
|
11032 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11033 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11034 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11035 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
11036 |
|
11037 if ( msg_struct->response != 1) |
|
11038 { |
|
11039 return_value = KErrGeneral; |
|
11040 goto return_code; |
|
11041 } |
|
11042 //killing isoserver |
|
11043 return_code: |
|
11044 index=0; |
|
11045 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11046 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11047 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11048 msgHdr->message_type = EKill_Process; |
|
11049 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11050 index += sizeof( message_hdr_req ); |
|
11051 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11052 free( msg_struct ); |
|
11053 return return_value; |
|
11054 } |
|
11055 |
|
11056 // ----------------------------------------------------------------------------- |
|
11057 // Cisolationserver::UpdatePresenceWithAway |
|
11058 // Example test method function. |
|
11059 // (other items were commented in a header). |
|
11060 // ----------------------------------------------------------------------------- |
|
11061 // |
|
11062 TInt Cisolationserver::UpdatePresenceWithAway( CStifItemParser& aItem ) |
|
11063 { |
|
11064 |
|
11065 |
|
11066 ConnectData *connect_data = NULL; |
|
11067 char smsg[MAX_MSG_SIZE]; |
|
11068 char rmsg[MAX_MSG_SIZE]; |
|
11069 int index=0; |
|
11070 |
|
11071 |
|
11072 int timeout = 100; |
|
11073 int nBytes; |
|
11074 |
|
11075 int result = 0; |
|
11076 int err = 0; |
|
11077 int status = 0; |
|
11078 FILE *fp; |
|
11079 message_hdr_req *msgHdr = NULL; |
|
11080 message_hdr_resp* msg_struct = NULL; |
|
11081 TInt return_value = 0; |
|
11082 // Read data from the CFG file |
|
11083 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
11084 { |
|
11085 iLog->Log ( _L ( "read_data failed" ) ); |
|
11086 free_data ( connect_data ); |
|
11087 return_value = KErrGeneral; |
|
11088 goto return_code; |
|
11089 } |
|
11090 //request formation |
|
11091 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11092 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11093 |
|
11094 //message header use |
|
11095 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
11096 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11097 |
|
11098 msgHdr->message_type = ELogin_Request; |
|
11099 |
|
11100 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11101 index += sizeof( message_hdr_req ); |
|
11102 |
|
11103 int len = strlen(connect_data->username); |
|
11104 strcpy( smsg + index, connect_data->username ); |
|
11105 index += len + 1; |
|
11106 |
|
11107 //appending password |
|
11108 |
|
11109 len = strlen(connect_data->password ); |
|
11110 strcpy( smsg + index, connect_data->password ); |
|
11111 index += len + 1; |
|
11112 |
|
11113 //appending server name |
|
11114 |
|
11115 len = strlen(connect_data->server ); |
|
11116 strcpy( smsg + index, connect_data->server ); |
|
11117 index += len + 1; |
|
11118 |
|
11119 //appending resource |
|
11120 len = strlen(connect_data->resource ); |
|
11121 strcpy( smsg + index, connect_data->resource ); |
|
11122 index += len + 1; |
|
11123 |
|
11124 //appending ssl |
|
11125 smsg[index++]= '1'; |
|
11126 smsg[index++]= '\0'; |
|
11127 |
|
11128 //appending server port |
|
11129 len = strlen(connect_data->port ); |
|
11130 strcpy( smsg + index, connect_data->port ); |
|
11131 index += len + 1; |
|
11132 |
|
11133 // appending IAP id |
|
11134 |
|
11135 smsg[index++]= '1'; |
|
11136 smsg[index++]= '\0'; |
|
11137 |
|
11138 //appending connmgr_bus |
|
11139 len = strlen(connect_data->connmgr_bus ); |
|
11140 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
11141 index += len + 1; |
|
11142 |
|
11143 //appending connmgr_path |
|
11144 len = strlen(connect_data->connmgr_path ); |
|
11145 strcpy( smsg + index, connect_data->connmgr_path ); |
|
11146 index += len + 1; |
|
11147 |
|
11148 //appending protocol |
|
11149 len = strlen(connect_data->protocol ); |
|
11150 strcpy( smsg + index, connect_data->protocol ); |
|
11151 index += len + 1; |
|
11152 |
|
11153 #ifdef __WINSCW__ |
|
11154 //proxy server |
|
11155 len = strlen(connect_data->proxy_data->proxy_server ); |
|
11156 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
11157 index += len + 1; |
|
11158 |
|
11159 //proxy port |
|
11160 len = strlen(connect_data->proxy_data->proxy_port ); |
|
11161 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
11162 index += len + 1; |
|
11163 |
|
11164 #endif |
|
11165 //running isoserver |
|
11166 run_isoserver(); |
|
11167 //create message queue for send request |
|
11168 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11169 //create message queue for response request |
|
11170 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11171 |
|
11172 |
|
11173 /* Send Message to queueOne */ |
|
11174 |
|
11175 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11176 |
|
11177 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
11178 |
|
11179 if (status < 0) |
|
11180 { |
|
11181 return_value = KErrGeneral; |
|
11182 goto return_code; |
|
11183 } |
|
11184 |
|
11185 |
|
11186 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
11187 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
11188 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11189 |
|
11190 if( msg_struct->response != 1) |
|
11191 { |
|
11192 return_value = KErrGeneral; |
|
11193 goto return_code; |
|
11194 } |
|
11195 |
|
11196 |
|
11197 // login end |
|
11198 //fetch req.. |
|
11199 for (int i= 0 ;i<3 ;i++) |
|
11200 { |
|
11201 |
|
11202 fp = fopen("c:\\fetch_contact.txt","a"); |
|
11203 do { |
|
11204 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11205 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11206 fwrite(rmsg,1,status,fp); |
|
11207 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11208 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
11209 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
11210 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
11211 fclose(fp); |
|
11212 |
|
11213 } |
|
11214 |
|
11215 //fetch end |
|
11216 //fetch end |
|
11217 |
|
11218 //-------------update presence--------------- |
|
11219 |
|
11220 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11221 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11222 index=0; |
|
11223 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11224 msgHdr->message_type = EUpdateOwnPresence; |
|
11225 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11226 index += sizeof( message_hdr_req ); |
|
11227 |
|
11228 |
|
11229 // updating availability |
|
11230 char *availability = "away"; |
|
11231 memcpy( smsg + index, availability, strlen( availability ) ); |
|
11232 index += strlen( availability ); |
|
11233 |
|
11234 smsg[index++]='\0'; |
|
11235 |
|
11236 //updating status text |
|
11237 char *statustext = "i m busy"; |
|
11238 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
11239 index += strlen( statustext ); |
|
11240 |
|
11241 |
|
11242 |
|
11243 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11244 |
|
11245 do { |
|
11246 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11247 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11248 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11249 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
11250 |
|
11251 if ( msg_struct->response != 1) |
|
11252 { |
|
11253 return_value = KErrGeneral; |
|
11254 goto return_code; |
|
11255 } |
|
11256 |
|
11257 // logout test code from server |
|
11258 index=0; |
|
11259 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11260 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11261 |
|
11262 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11263 |
|
11264 msgHdr->message_type = ELogout_Request; |
|
11265 |
|
11266 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11267 index += sizeof( message_hdr_req ); |
|
11268 |
|
11269 |
|
11270 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11271 |
|
11272 do { |
|
11273 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11274 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11275 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11276 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
11277 |
|
11278 if ( msg_struct->response != 1) |
|
11279 { |
|
11280 return_value = KErrGeneral; |
|
11281 goto return_code; |
|
11282 } |
|
11283 //killing isoserver |
|
11284 return_code: |
|
11285 index=0; |
|
11286 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11287 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11288 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11289 msgHdr->message_type = EKill_Process; |
|
11290 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11291 index += sizeof( message_hdr_req ); |
|
11292 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11293 free( msg_struct ); |
|
11294 return return_value; |
|
11295 } |
|
11296 |
|
11297 // ----------------------------------------------------------------------------- |
|
11298 // Cisolationserver::UpdatePresenceWithAway |
|
11299 // Example test method function. |
|
11300 // (other items were commented in a header). |
|
11301 // ----------------------------------------------------------------------------- |
|
11302 // |
|
11303 TInt Cisolationserver::UpdatePresenceWithAvailable( CStifItemParser& aItem ) |
|
11304 { |
|
11305 |
|
11306 |
|
11307 ConnectData *connect_data = NULL; |
|
11308 char smsg[MAX_MSG_SIZE]; |
|
11309 char rmsg[MAX_MSG_SIZE]; |
|
11310 int index=0; |
|
11311 |
|
11312 |
|
11313 int timeout = 100; |
|
11314 int nBytes; |
|
11315 |
|
11316 int result = 0; |
|
11317 int err = 0; |
|
11318 int status = 0; |
|
11319 FILE *fp; |
|
11320 message_hdr_req *msgHdr = NULL; |
|
11321 message_hdr_resp* msg_struct = NULL; |
|
11322 TInt return_value = 0; |
|
11323 // Read data from the CFG file |
|
11324 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
11325 { |
|
11326 iLog->Log ( _L ( "read_data failed" ) ); |
|
11327 free_data ( connect_data ); |
|
11328 return_value = KErrGeneral; |
|
11329 goto return_code; |
|
11330 } |
|
11331 //request formation |
|
11332 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11333 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11334 |
|
11335 //message header use |
|
11336 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
11337 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11338 |
|
11339 msgHdr->message_type = ELogin_Request; |
|
11340 |
|
11341 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11342 index += sizeof( message_hdr_req ); |
|
11343 |
|
11344 int len = strlen(connect_data->username); |
|
11345 strcpy( smsg + index, connect_data->username ); |
|
11346 index += len + 1; |
|
11347 |
|
11348 //appending password |
|
11349 |
|
11350 len = strlen(connect_data->password ); |
|
11351 strcpy( smsg + index, connect_data->password ); |
|
11352 index += len + 1; |
|
11353 |
|
11354 //appending server name |
|
11355 |
|
11356 len = strlen(connect_data->server ); |
|
11357 strcpy( smsg + index, connect_data->server ); |
|
11358 index += len + 1; |
|
11359 |
|
11360 //appending resource |
|
11361 len = strlen(connect_data->resource ); |
|
11362 strcpy( smsg + index, connect_data->resource ); |
|
11363 index += len + 1; |
|
11364 |
|
11365 //appending ssl |
|
11366 smsg[index++]= '1'; |
|
11367 smsg[index++]= '\0'; |
|
11368 |
|
11369 //appending server port |
|
11370 len = strlen(connect_data->port ); |
|
11371 strcpy( smsg + index, connect_data->port ); |
|
11372 index += len + 1; |
|
11373 |
|
11374 // appending IAP id |
|
11375 |
|
11376 smsg[index++]= '1'; |
|
11377 smsg[index++]= '\0'; |
|
11378 |
|
11379 //appending connmgr_bus |
|
11380 len = strlen(connect_data->connmgr_bus ); |
|
11381 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
11382 index += len + 1; |
|
11383 |
|
11384 //appending connmgr_path |
|
11385 len = strlen(connect_data->connmgr_path ); |
|
11386 strcpy( smsg + index, connect_data->connmgr_path ); |
|
11387 index += len + 1; |
|
11388 |
|
11389 //appending protocol |
|
11390 len = strlen(connect_data->protocol ); |
|
11391 strcpy( smsg + index, connect_data->protocol ); |
|
11392 index += len + 1; |
|
11393 |
|
11394 #ifdef __WINSCW__ |
|
11395 //proxy server |
|
11396 len = strlen(connect_data->proxy_data->proxy_server ); |
|
11397 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
11398 index += len + 1; |
|
11399 |
|
11400 //proxy port |
|
11401 len = strlen(connect_data->proxy_data->proxy_port ); |
|
11402 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
11403 index += len + 1; |
|
11404 |
|
11405 #endif |
|
11406 //running isoserver |
|
11407 run_isoserver(); |
|
11408 //create message queue for send request |
|
11409 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11410 //create message queue for response request |
|
11411 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11412 |
|
11413 |
|
11414 /* Send Message to queueOne */ |
|
11415 |
|
11416 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11417 |
|
11418 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
11419 |
|
11420 if (status < 0) |
|
11421 { |
|
11422 return_value = KErrGeneral; |
|
11423 goto return_code; |
|
11424 } |
|
11425 |
|
11426 |
|
11427 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
11428 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
11429 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11430 |
|
11431 if( msg_struct->response != 1) |
|
11432 { |
|
11433 return_value = KErrGeneral; |
|
11434 goto return_code; |
|
11435 } |
|
11436 |
|
11437 |
|
11438 // login end |
|
11439 //fetch req.. |
|
11440 for (int i= 0 ;i<3 ;i++) |
|
11441 { |
|
11442 |
|
11443 fp = fopen("c:\\fetch_contact.txt","a"); |
|
11444 do { |
|
11445 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11446 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11447 fwrite(rmsg,1,status,fp); |
|
11448 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11449 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
11450 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
11451 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
11452 fclose(fp); |
|
11453 |
|
11454 } |
|
11455 |
|
11456 //fetch end |
|
11457 //fetch end |
|
11458 |
|
11459 //-------------update presence--------------- |
|
11460 |
|
11461 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11462 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11463 index=0; |
|
11464 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11465 msgHdr->message_type = EUpdateOwnPresence; |
|
11466 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11467 index += sizeof( message_hdr_req ); |
|
11468 |
|
11469 |
|
11470 // updating availability |
|
11471 char *availability = "available"; |
|
11472 memcpy( smsg + index, availability, strlen( availability ) ); |
|
11473 index += strlen( availability ); |
|
11474 smsg[index++]='\0'; |
|
11475 |
|
11476 //updating status text |
|
11477 char *statustext = "there is difference between thought and execution"; |
|
11478 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
11479 index += strlen( statustext ); |
|
11480 |
|
11481 |
|
11482 |
|
11483 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11484 |
|
11485 do { |
|
11486 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11487 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11488 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11489 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
11490 |
|
11491 if ( msg_struct->response != 1) |
|
11492 { |
|
11493 return_value = KErrGeneral; |
|
11494 goto return_code; |
|
11495 } |
|
11496 // logout test code from server |
|
11497 index=0; |
|
11498 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11499 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11500 |
|
11501 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11502 |
|
11503 msgHdr->message_type = ELogout_Request; |
|
11504 |
|
11505 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11506 index += sizeof( message_hdr_req ); |
|
11507 |
|
11508 |
|
11509 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11510 do { |
|
11511 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11512 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11513 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11514 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
11515 |
|
11516 if ( msg_struct->response != 1) |
|
11517 { |
|
11518 return_value = KErrGeneral; |
|
11519 goto return_code; |
|
11520 } |
|
11521 //killing isoserver |
|
11522 return_code: |
|
11523 index=0; |
|
11524 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11525 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11526 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11527 msgHdr->message_type = EKill_Process; |
|
11528 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11529 index += sizeof( message_hdr_req ); |
|
11530 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11531 free( msg_struct ); |
|
11532 return return_value; |
|
11533 } |
|
11534 |
|
11535 // ----------------------------------------------------------------------------- |
|
11536 // Cisolationserver::UpdatePresenceWithDnd |
|
11537 // Example test method function. |
|
11538 // (other items were commented in a header). |
|
11539 // ----------------------------------------------------------------------------- |
|
11540 // |
|
11541 TInt Cisolationserver::UpdatePresenceWithDnd( CStifItemParser& aItem ) |
|
11542 { |
|
11543 |
|
11544 |
|
11545 ConnectData *connect_data = NULL; |
|
11546 char smsg[MAX_MSG_SIZE]; |
|
11547 char rmsg[MAX_MSG_SIZE]; |
|
11548 int index=0; |
|
11549 |
|
11550 |
|
11551 int timeout = 100; |
|
11552 int nBytes; |
|
11553 |
|
11554 int result = 0; |
|
11555 int err = 0; |
|
11556 int status = 0; |
|
11557 FILE *fp; |
|
11558 message_hdr_req *msgHdr = NULL; |
|
11559 message_hdr_resp* msg_struct = NULL; |
|
11560 TInt return_value = 0; |
|
11561 // Read data from the CFG file |
|
11562 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
11563 { |
|
11564 iLog->Log ( _L ( "read_data failed" ) ); |
|
11565 free_data ( connect_data ); |
|
11566 return_value = KErrGeneral; |
|
11567 goto return_code; |
|
11568 } |
|
11569 //request formation |
|
11570 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11571 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11572 |
|
11573 //message header use |
|
11574 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
11575 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11576 |
|
11577 msgHdr->message_type = ELogin_Request; |
|
11578 |
|
11579 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11580 index += sizeof( message_hdr_req ); |
|
11581 |
|
11582 int len = strlen(connect_data->username); |
|
11583 strcpy( smsg + index, connect_data->username ); |
|
11584 index += len + 1; |
|
11585 |
|
11586 //appending password |
|
11587 |
|
11588 len = strlen(connect_data->password ); |
|
11589 strcpy( smsg + index, connect_data->password ); |
|
11590 index += len + 1; |
|
11591 |
|
11592 //appending server name |
|
11593 |
|
11594 len = strlen(connect_data->server ); |
|
11595 strcpy( smsg + index, connect_data->server ); |
|
11596 index += len + 1; |
|
11597 |
|
11598 //appending resource |
|
11599 len = strlen(connect_data->resource ); |
|
11600 strcpy( smsg + index, connect_data->resource ); |
|
11601 index += len + 1; |
|
11602 |
|
11603 //appending ssl |
|
11604 smsg[index++]= '1'; |
|
11605 smsg[index++]= '\0'; |
|
11606 |
|
11607 //appending server port |
|
11608 len = strlen(connect_data->port ); |
|
11609 strcpy( smsg + index, connect_data->port ); |
|
11610 index += len + 1; |
|
11611 |
|
11612 // appending IAP id |
|
11613 |
|
11614 smsg[index++]= '1'; |
|
11615 smsg[index++]= '\0'; |
|
11616 |
|
11617 //appending connmgr_bus |
|
11618 len = strlen(connect_data->connmgr_bus ); |
|
11619 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
11620 index += len + 1; |
|
11621 |
|
11622 //appending connmgr_path |
|
11623 len = strlen(connect_data->connmgr_path ); |
|
11624 strcpy( smsg + index, connect_data->connmgr_path ); |
|
11625 index += len + 1; |
|
11626 |
|
11627 //appending protocol |
|
11628 len = strlen(connect_data->protocol ); |
|
11629 strcpy( smsg + index, connect_data->protocol ); |
|
11630 index += len + 1; |
|
11631 |
|
11632 #ifdef __WINSCW__ |
|
11633 //proxy server |
|
11634 len = strlen(connect_data->proxy_data->proxy_server ); |
|
11635 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
11636 index += len + 1; |
|
11637 |
|
11638 //proxy port |
|
11639 len = strlen(connect_data->proxy_data->proxy_port ); |
|
11640 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
11641 index += len + 1; |
|
11642 |
|
11643 #endif |
|
11644 //running isoserver |
|
11645 run_isoserver(); |
|
11646 //create message queue for send request |
|
11647 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11648 //create message queue for response request |
|
11649 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11650 |
|
11651 |
|
11652 /* Send Message to queueOne */ |
|
11653 |
|
11654 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11655 |
|
11656 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
11657 |
|
11658 if (status < 0) |
|
11659 { |
|
11660 return_value = KErrGeneral; |
|
11661 goto return_code; |
|
11662 } |
|
11663 |
|
11664 |
|
11665 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
11666 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
11667 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11668 |
|
11669 if( msg_struct->response != 1) |
|
11670 { |
|
11671 return_value = KErrGeneral; |
|
11672 goto return_code; |
|
11673 } |
|
11674 |
|
11675 |
|
11676 // login end |
|
11677 //fetch req.. |
|
11678 for (int i= 0 ;i<3 ;i++) |
|
11679 { |
|
11680 |
|
11681 fp = fopen("c:\\fetch_contact.txt","a"); |
|
11682 do { |
|
11683 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11684 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11685 fwrite(rmsg,1,status,fp); |
|
11686 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11687 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
11688 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
11689 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
11690 fclose(fp); |
|
11691 |
|
11692 } |
|
11693 |
|
11694 //fetch end |
|
11695 //fetch end |
|
11696 |
|
11697 //-------------update presence--------------- |
|
11698 |
|
11699 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11700 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11701 index=0; |
|
11702 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11703 msgHdr->message_type = EUpdateOwnPresence; |
|
11704 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11705 index += sizeof( message_hdr_req ); |
|
11706 |
|
11707 |
|
11708 // updating availability |
|
11709 char *availability = "dnd"; |
|
11710 memcpy( smsg + index, availability, strlen( availability ) ); |
|
11711 index += strlen( availability ); |
|
11712 smsg[index++]='\0'; |
|
11713 |
|
11714 //updating status text |
|
11715 char *statustext = "i m busy"; |
|
11716 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
11717 index += strlen( statustext ); |
|
11718 |
|
11719 |
|
11720 |
|
11721 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11722 |
|
11723 do { |
|
11724 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11725 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11726 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11727 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
11728 |
|
11729 if ( msg_struct->response != 1) |
|
11730 { |
|
11731 return_value = KErrGeneral; |
|
11732 goto return_code; |
|
11733 } |
|
11734 |
|
11735 // logout test code from server |
|
11736 index=0; |
|
11737 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11738 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11739 |
|
11740 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11741 |
|
11742 msgHdr->message_type = ELogout_Request; |
|
11743 |
|
11744 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11745 index += sizeof( message_hdr_req ); |
|
11746 |
|
11747 |
|
11748 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11749 do { |
|
11750 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11751 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11752 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11753 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
11754 |
|
11755 if ( msg_struct->response != 1) |
|
11756 { |
|
11757 return_value = KErrGeneral; |
|
11758 goto return_code; |
|
11759 } |
|
11760 |
|
11761 //killing isoserver |
|
11762 return_code: |
|
11763 index=0; |
|
11764 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11765 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11766 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11767 msgHdr->message_type = EKill_Process; |
|
11768 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11769 index += sizeof( message_hdr_req ); |
|
11770 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11771 free( msg_struct ); |
|
11772 return return_value; |
|
11773 } |
|
11774 |
|
11775 // ----------------------------------------------------------------------------- |
|
11776 // Cisolationserver::UpdatePresenceWithDnd |
|
11777 // Example test method function. |
|
11778 // (other items were commented in a header). |
|
11779 // ----------------------------------------------------------------------------- |
|
11780 // |
|
11781 TInt Cisolationserver::UpdatePresenceMultipleTimeInSameSession( CStifItemParser& aItem ) |
|
11782 { |
|
11783 |
|
11784 |
|
11785 ConnectData *connect_data = NULL; |
|
11786 char smsg[MAX_MSG_SIZE]; |
|
11787 char rmsg[MAX_MSG_SIZE]; |
|
11788 int index=0; |
|
11789 |
|
11790 |
|
11791 int timeout = 100; |
|
11792 int nBytes; |
|
11793 |
|
11794 int result = 0; |
|
11795 int err = 0; |
|
11796 int status = 0; |
|
11797 FILE *fp; |
|
11798 message_hdr_req *msgHdr = NULL; |
|
11799 message_hdr_resp* msg_struct = NULL; |
|
11800 TInt return_value = 0; |
|
11801 // Read data from the CFG file |
|
11802 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
11803 { |
|
11804 iLog->Log ( _L ( "read_data failed" ) ); |
|
11805 free_data ( connect_data ); |
|
11806 return_value = KErrGeneral; |
|
11807 goto return_code; |
|
11808 } |
|
11809 //request formation |
|
11810 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11811 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11812 |
|
11813 //message header use |
|
11814 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
11815 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11816 |
|
11817 msgHdr->message_type = ELogin_Request; |
|
11818 |
|
11819 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11820 index += sizeof( message_hdr_req ); |
|
11821 |
|
11822 int len = strlen(connect_data->username); |
|
11823 strcpy( smsg + index, connect_data->username ); |
|
11824 index += len + 1; |
|
11825 |
|
11826 //appending password |
|
11827 |
|
11828 len = strlen(connect_data->password ); |
|
11829 strcpy( smsg + index, connect_data->password ); |
|
11830 index += len + 1; |
|
11831 |
|
11832 //appending server name |
|
11833 |
|
11834 len = strlen(connect_data->server ); |
|
11835 strcpy( smsg + index, connect_data->server ); |
|
11836 index += len + 1; |
|
11837 |
|
11838 //appending resource |
|
11839 len = strlen(connect_data->resource ); |
|
11840 strcpy( smsg + index, connect_data->resource ); |
|
11841 index += len + 1; |
|
11842 |
|
11843 //appending ssl |
|
11844 smsg[index++]= '1'; |
|
11845 smsg[index++]= '\0'; |
|
11846 |
|
11847 //appending server port |
|
11848 len = strlen(connect_data->port ); |
|
11849 strcpy( smsg + index, connect_data->port ); |
|
11850 index += len + 1; |
|
11851 |
|
11852 // appending IAP id |
|
11853 |
|
11854 smsg[index++]= '1'; |
|
11855 smsg[index++]= '\0'; |
|
11856 |
|
11857 //appending connmgr_bus |
|
11858 len = strlen(connect_data->connmgr_bus ); |
|
11859 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
11860 index += len + 1; |
|
11861 |
|
11862 //appending connmgr_path |
|
11863 len = strlen(connect_data->connmgr_path ); |
|
11864 strcpy( smsg + index, connect_data->connmgr_path ); |
|
11865 index += len + 1; |
|
11866 |
|
11867 //appending protocol |
|
11868 len = strlen(connect_data->protocol ); |
|
11869 strcpy( smsg + index, connect_data->protocol ); |
|
11870 index += len + 1; |
|
11871 |
|
11872 #ifdef __WINSCW__ |
|
11873 //proxy server |
|
11874 len = strlen(connect_data->proxy_data->proxy_server ); |
|
11875 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
11876 index += len + 1; |
|
11877 |
|
11878 //proxy port |
|
11879 len = strlen(connect_data->proxy_data->proxy_port ); |
|
11880 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
11881 index += len + 1; |
|
11882 |
|
11883 #endif |
|
11884 //running isoserver |
|
11885 run_isoserver(); |
|
11886 //create message queue for send request |
|
11887 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11888 //create message queue for response request |
|
11889 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
11890 |
|
11891 |
|
11892 /* Send Message to queueOne */ |
|
11893 |
|
11894 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11895 |
|
11896 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
11897 |
|
11898 if (status < 0) |
|
11899 { |
|
11900 return_value = KErrGeneral; |
|
11901 goto return_code; |
|
11902 } |
|
11903 |
|
11904 |
|
11905 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
11906 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
11907 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11908 |
|
11909 if( msg_struct->response != 1) |
|
11910 { |
|
11911 return_value = KErrGeneral; |
|
11912 goto return_code; |
|
11913 } |
|
11914 |
|
11915 |
|
11916 // login end |
|
11917 //fetch req.. |
|
11918 for (int i= 0 ;i<3 ;i++) |
|
11919 { |
|
11920 |
|
11921 fp = fopen("c:\\fetch_contact.txt","a"); |
|
11922 do { |
|
11923 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11924 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11925 fwrite(rmsg,1,status,fp); |
|
11926 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11927 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
11928 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
11929 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
11930 fclose(fp); |
|
11931 |
|
11932 } |
|
11933 |
|
11934 //fetch end |
|
11935 //fetch end |
|
11936 |
|
11937 //-------------update presence--------------- |
|
11938 |
|
11939 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11940 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11941 index=0; |
|
11942 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11943 msgHdr->message_type = EUpdateOwnPresence; |
|
11944 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11945 index += sizeof( message_hdr_req ); |
|
11946 |
|
11947 |
|
11948 // updating availability |
|
11949 char *availability = "dnd"; |
|
11950 memcpy( smsg + index, availability, strlen( availability ) ); |
|
11951 index += strlen( availability ); |
|
11952 smsg[index++]='\0'; |
|
11953 |
|
11954 //updating status text |
|
11955 char *statustext = "i m busy"; |
|
11956 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
11957 index += strlen( statustext ); |
|
11958 |
|
11959 |
|
11960 |
|
11961 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11962 |
|
11963 do { |
|
11964 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
11965 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
11966 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11967 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
11968 |
|
11969 if ( msg_struct->response != 1) |
|
11970 { |
|
11971 return_value = KErrGeneral; |
|
11972 goto return_code; |
|
11973 } |
|
11974 //-------------update presence 2nd time--------------- |
|
11975 |
|
11976 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
11977 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
11978 index=0; |
|
11979 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
11980 msgHdr->message_type = EUpdateOwnPresence; |
|
11981 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
11982 index += sizeof( message_hdr_req ); |
|
11983 |
|
11984 |
|
11985 // updating availability |
|
11986 char *availability1 = "away"; |
|
11987 memcpy( smsg + index, availability1, strlen( availability1 ) ); |
|
11988 index += strlen( availability1 ); |
|
11989 smsg[index++]='\0'; |
|
11990 |
|
11991 //updating status text |
|
11992 char *statustext1 = "i m not on desk"; |
|
11993 memcpy( smsg + index, statustext1, strlen( statustext1 ) ); |
|
11994 index += strlen( statustext1 ); |
|
11995 |
|
11996 |
|
11997 |
|
11998 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
11999 |
|
12000 do { |
|
12001 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12002 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12003 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12004 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
12005 |
|
12006 if ( msg_struct->response != 1) |
|
12007 { |
|
12008 return_value = KErrGeneral; |
|
12009 goto return_code; |
|
12010 } |
|
12011 |
|
12012 |
|
12013 // logout test code from server |
|
12014 index=0; |
|
12015 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12016 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12017 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12018 msgHdr->message_type = ELogout_Request; |
|
12019 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12020 index += sizeof( message_hdr_req ); |
|
12021 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12022 do { |
|
12023 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12024 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12025 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12026 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
12027 |
|
12028 if ( msg_struct->response != 1) |
|
12029 { |
|
12030 return_value = KErrGeneral; |
|
12031 goto return_code; |
|
12032 } |
|
12033 //killing isoserver |
|
12034 return_code: |
|
12035 index=0; |
|
12036 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12037 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12038 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12039 msgHdr->message_type = EKill_Process; |
|
12040 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12041 index += sizeof( message_hdr_req ); |
|
12042 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12043 free( msg_struct ); |
|
12044 return return_value; |
|
12045 } |
|
12046 // ----------------------------------------------------------------------------- |
|
12047 // Cisolationserver::UpdatePresenceWithDnd |
|
12048 // Example test method function. |
|
12049 // (other items were commented in a header). |
|
12050 // ----------------------------------------------------------------------------- |
|
12051 // |
|
12052 TInt Cisolationserver::UpdateOnlyStatusText( CStifItemParser& aItem ) |
|
12053 { |
|
12054 |
|
12055 |
|
12056 ConnectData *connect_data = NULL; |
|
12057 char smsg[MAX_MSG_SIZE]; |
|
12058 char rmsg[MAX_MSG_SIZE]; |
|
12059 int index=0; |
|
12060 |
|
12061 |
|
12062 int timeout = 100; |
|
12063 int nBytes; |
|
12064 |
|
12065 int result = 0; |
|
12066 int err = 0; |
|
12067 int status = 0; |
|
12068 FILE *fp; |
|
12069 message_hdr_req *msgHdr = NULL; |
|
12070 message_hdr_resp* msg_struct = NULL; |
|
12071 TInt return_value = 0; |
|
12072 // Read data from the CFG file |
|
12073 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
12074 { |
|
12075 iLog->Log ( _L ( "read_data failed" ) ); |
|
12076 free_data ( connect_data ); |
|
12077 return_value = KErrGeneral; |
|
12078 goto return_code; |
|
12079 } |
|
12080 //request formation |
|
12081 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12082 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12083 |
|
12084 //message header use |
|
12085 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
12086 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12087 |
|
12088 msgHdr->message_type = ELogin_Request; |
|
12089 |
|
12090 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12091 index += sizeof( message_hdr_req ); |
|
12092 |
|
12093 int len = strlen(connect_data->username); |
|
12094 strcpy( smsg + index, connect_data->username ); |
|
12095 index += len + 1; |
|
12096 |
|
12097 //appending password |
|
12098 |
|
12099 len = strlen(connect_data->password ); |
|
12100 strcpy( smsg + index, connect_data->password ); |
|
12101 index += len + 1; |
|
12102 |
|
12103 //appending server name |
|
12104 |
|
12105 len = strlen(connect_data->server ); |
|
12106 strcpy( smsg + index, connect_data->server ); |
|
12107 index += len + 1; |
|
12108 |
|
12109 //appending resource |
|
12110 len = strlen(connect_data->resource ); |
|
12111 strcpy( smsg + index, connect_data->resource ); |
|
12112 index += len + 1; |
|
12113 |
|
12114 //appending ssl |
|
12115 smsg[index++]= '1'; |
|
12116 smsg[index++]= '\0'; |
|
12117 |
|
12118 //appending server port |
|
12119 len = strlen(connect_data->port ); |
|
12120 strcpy( smsg + index, connect_data->port ); |
|
12121 index += len + 1; |
|
12122 |
|
12123 // appending IAP id |
|
12124 |
|
12125 smsg[index++]= '1'; |
|
12126 smsg[index++]= '\0'; |
|
12127 |
|
12128 //appending connmgr_bus |
|
12129 len = strlen(connect_data->connmgr_bus ); |
|
12130 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
12131 index += len + 1; |
|
12132 |
|
12133 //appending connmgr_path |
|
12134 len = strlen(connect_data->connmgr_path ); |
|
12135 strcpy( smsg + index, connect_data->connmgr_path ); |
|
12136 index += len + 1; |
|
12137 |
|
12138 //appending protocol |
|
12139 len = strlen(connect_data->protocol ); |
|
12140 strcpy( smsg + index, connect_data->protocol ); |
|
12141 index += len + 1; |
|
12142 |
|
12143 #ifdef __WINSCW__ |
|
12144 //proxy server |
|
12145 len = strlen(connect_data->proxy_data->proxy_server ); |
|
12146 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
12147 index += len + 1; |
|
12148 |
|
12149 //proxy port |
|
12150 len = strlen(connect_data->proxy_data->proxy_port ); |
|
12151 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
12152 index += len + 1; |
|
12153 |
|
12154 #endif |
|
12155 //running isoserver |
|
12156 run_isoserver(); |
|
12157 //create message queue for send request |
|
12158 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12159 //create message queue for response request |
|
12160 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12161 |
|
12162 |
|
12163 /* Send Message to queueOne */ |
|
12164 |
|
12165 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12166 |
|
12167 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
12168 |
|
12169 if (status < 0) |
|
12170 { |
|
12171 return_value = KErrGeneral; |
|
12172 goto return_code; |
|
12173 } |
|
12174 |
|
12175 |
|
12176 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
12177 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
12178 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12179 |
|
12180 if( msg_struct->response != 1) |
|
12181 { |
|
12182 return_value = KErrGeneral; |
|
12183 goto return_code; |
|
12184 } |
|
12185 |
|
12186 |
|
12187 // login end |
|
12188 //fetch req.. |
|
12189 for (int i= 0 ;i<3 ;i++) |
|
12190 { |
|
12191 |
|
12192 fp = fopen("c:\\fetch_contact.txt","a"); |
|
12193 do { |
|
12194 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12195 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12196 fwrite(rmsg,1,status,fp); |
|
12197 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12198 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
12199 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
12200 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
12201 fclose(fp); |
|
12202 |
|
12203 } |
|
12204 |
|
12205 //fetch end |
|
12206 |
|
12207 //-------------update presence--------------- |
|
12208 |
|
12209 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12210 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12211 index=0; |
|
12212 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12213 msgHdr->message_type = EUpdateOwnPresence; |
|
12214 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12215 index += sizeof( message_hdr_req ); |
|
12216 |
|
12217 |
|
12218 // updating availability with blank |
|
12219 smsg[index++]='\0'; |
|
12220 smsg[index++]='\0'; |
|
12221 //smsg[index++]='\0'; |
|
12222 |
|
12223 //updating status text |
|
12224 char *statustext = "i m not on desk"; |
|
12225 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
12226 index += strlen( statustext ); |
|
12227 |
|
12228 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12229 |
|
12230 do { |
|
12231 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12232 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12233 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12234 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
12235 |
|
12236 if ( msg_struct->error_type > 0) |
|
12237 { |
|
12238 return_value = KErrGeneral; |
|
12239 goto return_code; |
|
12240 } |
|
12241 |
|
12242 // logout test code from server |
|
12243 index=0; |
|
12244 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12245 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12246 |
|
12247 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12248 |
|
12249 msgHdr->message_type = ELogout_Request; |
|
12250 |
|
12251 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12252 index += sizeof( message_hdr_req ); |
|
12253 |
|
12254 |
|
12255 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12256 do { |
|
12257 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12258 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12259 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12260 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
12261 |
|
12262 if ( msg_struct->response != 1) |
|
12263 { |
|
12264 return_value = KErrGeneral; |
|
12265 goto return_code; |
|
12266 } |
|
12267 //killing isoserver |
|
12268 return_code: |
|
12269 index=0; |
|
12270 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12271 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12272 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12273 msgHdr->message_type = EKill_Process; |
|
12274 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12275 index += sizeof( message_hdr_req ); |
|
12276 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12277 free( msg_struct ); |
|
12278 return return_value; |
|
12279 } |
|
12280 |
|
12281 // ----------------------------------------------------------------------------- |
|
12282 // Cisolationserver::UpdatePresenceWithAway |
|
12283 // Example test method function. |
|
12284 // (other items were commented in a header). |
|
12285 // ----------------------------------------------------------------------------- |
|
12286 // |
|
12287 TInt Cisolationserver::UpdateOnlyUserAvailability( CStifItemParser& aItem ) |
|
12288 { |
|
12289 |
|
12290 |
|
12291 ConnectData *connect_data = NULL; |
|
12292 char smsg[MAX_MSG_SIZE]; |
|
12293 char rmsg[MAX_MSG_SIZE]; |
|
12294 int index=0; |
|
12295 |
|
12296 |
|
12297 int timeout = 100; |
|
12298 int nBytes; |
|
12299 |
|
12300 int result = 0; |
|
12301 int err = 0; |
|
12302 int status = 0; |
|
12303 FILE *fp; |
|
12304 message_hdr_req *msgHdr = NULL; |
|
12305 message_hdr_resp* msg_struct = NULL; |
|
12306 TInt return_value = 0; |
|
12307 // Read data from the CFG file |
|
12308 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
12309 { |
|
12310 iLog->Log ( _L ( "read_data failed" ) ); |
|
12311 free_data ( connect_data ); |
|
12312 return_value = KErrGeneral; |
|
12313 goto return_code; |
|
12314 } |
|
12315 //request formation |
|
12316 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12317 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12318 |
|
12319 //message header use |
|
12320 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
12321 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12322 |
|
12323 msgHdr->message_type = ELogin_Request; |
|
12324 |
|
12325 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12326 index += sizeof( message_hdr_req ); |
|
12327 |
|
12328 int len = strlen(connect_data->username); |
|
12329 strcpy( smsg + index, connect_data->username ); |
|
12330 index += len + 1; |
|
12331 |
|
12332 //appending password |
|
12333 |
|
12334 len = strlen(connect_data->password ); |
|
12335 strcpy( smsg + index, connect_data->password ); |
|
12336 index += len + 1; |
|
12337 |
|
12338 //appending server name |
|
12339 |
|
12340 len = strlen(connect_data->server ); |
|
12341 strcpy( smsg + index, connect_data->server ); |
|
12342 index += len + 1; |
|
12343 |
|
12344 //appending resource |
|
12345 len = strlen(connect_data->resource ); |
|
12346 strcpy( smsg + index, connect_data->resource ); |
|
12347 index += len + 1; |
|
12348 |
|
12349 //appending ssl |
|
12350 smsg[index++]= '1'; |
|
12351 smsg[index++]= '\0'; |
|
12352 |
|
12353 //appending server port |
|
12354 len = strlen(connect_data->port ); |
|
12355 strcpy( smsg + index, connect_data->port ); |
|
12356 index += len + 1; |
|
12357 |
|
12358 // appending IAP id |
|
12359 |
|
12360 smsg[index++]= '1'; |
|
12361 smsg[index++]= '\0'; |
|
12362 |
|
12363 //appending connmgr_bus |
|
12364 len = strlen(connect_data->connmgr_bus ); |
|
12365 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
12366 index += len + 1; |
|
12367 |
|
12368 //appending connmgr_path |
|
12369 len = strlen(connect_data->connmgr_path ); |
|
12370 strcpy( smsg + index, connect_data->connmgr_path ); |
|
12371 index += len + 1; |
|
12372 |
|
12373 //appending protocol |
|
12374 len = strlen(connect_data->protocol ); |
|
12375 strcpy( smsg + index, connect_data->protocol ); |
|
12376 index += len + 1; |
|
12377 |
|
12378 #ifdef __WINSCW__ |
|
12379 //proxy server |
|
12380 len = strlen(connect_data->proxy_data->proxy_server ); |
|
12381 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
12382 index += len + 1; |
|
12383 |
|
12384 //proxy port |
|
12385 len = strlen(connect_data->proxy_data->proxy_port ); |
|
12386 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
12387 index += len + 1; |
|
12388 |
|
12389 #endif |
|
12390 //running isoserver |
|
12391 run_isoserver(); |
|
12392 |
|
12393 |
|
12394 |
|
12395 //create message queue for send request |
|
12396 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12397 //create message queue for response request |
|
12398 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12399 |
|
12400 |
|
12401 /* Send Message to queueOne */ |
|
12402 |
|
12403 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12404 |
|
12405 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
12406 |
|
12407 if (status < 0) |
|
12408 { |
|
12409 return_value = KErrGeneral; |
|
12410 goto return_code; |
|
12411 } |
|
12412 |
|
12413 |
|
12414 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
12415 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
12416 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12417 |
|
12418 if( msg_struct->response != 1) |
|
12419 { |
|
12420 return_value = KErrGeneral; |
|
12421 goto return_code; |
|
12422 } |
|
12423 |
|
12424 |
|
12425 // login end |
|
12426 //fetch req.. |
|
12427 for (int i= 0 ;i<3 ;i++) |
|
12428 { |
|
12429 |
|
12430 fp = fopen("c:\\fetch_contact.txt","a"); |
|
12431 do { |
|
12432 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12433 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12434 fwrite(rmsg,1,status,fp); |
|
12435 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12436 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
12437 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
12438 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
12439 fclose(fp); |
|
12440 |
|
12441 } |
|
12442 |
|
12443 //fetch end |
|
12444 |
|
12445 //-------------update presence--------------- |
|
12446 |
|
12447 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12448 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12449 index=0; |
|
12450 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12451 msgHdr->message_type = EUpdateOwnPresence; |
|
12452 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12453 index += sizeof( message_hdr_req ); |
|
12454 |
|
12455 |
|
12456 // updating availability |
|
12457 char *availability = "available"; |
|
12458 memcpy( smsg + index, availability, strlen( availability ) ); |
|
12459 index += strlen( availability ); |
|
12460 |
|
12461 |
|
12462 |
|
12463 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12464 |
|
12465 do { |
|
12466 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12467 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12468 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12469 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
12470 |
|
12471 if ( msg_struct->response != 1) |
|
12472 { |
|
12473 return_value = KErrGeneral; |
|
12474 goto return_code; |
|
12475 } |
|
12476 |
|
12477 // logout test code from server |
|
12478 index=0; |
|
12479 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12480 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12481 |
|
12482 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12483 |
|
12484 msgHdr->message_type = ELogout_Request; |
|
12485 |
|
12486 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12487 index += sizeof( message_hdr_req ); |
|
12488 |
|
12489 |
|
12490 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12491 do { |
|
12492 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12493 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12494 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12495 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
12496 |
|
12497 if ( msg_struct->response != 1) |
|
12498 { |
|
12499 return_value = KErrGeneral; |
|
12500 goto return_code; |
|
12501 } |
|
12502 |
|
12503 //killing isoserver |
|
12504 return_code: |
|
12505 index=0; |
|
12506 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12507 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12508 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12509 msgHdr->message_type = EKill_Process; |
|
12510 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12511 index += sizeof( message_hdr_req ); |
|
12512 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12513 free( msg_struct ); |
|
12514 return return_value; |
|
12515 } |
|
12516 |
|
12517 // ----------------------------------------------------------------------------- |
|
12518 // Cisolationserver::UpdatePresenceWithAway |
|
12519 // Example test method function. |
|
12520 // (other items were commented in a header). |
|
12521 // ----------------------------------------------------------------------------- |
|
12522 // |
|
12523 TInt Cisolationserver::UpdateOwnPresenceWithBlankData( CStifItemParser& aItem ) |
|
12524 { |
|
12525 |
|
12526 |
|
12527 ConnectData *connect_data = NULL; |
|
12528 char smsg[MAX_MSG_SIZE]; |
|
12529 char rmsg[MAX_MSG_SIZE]; |
|
12530 int index=0; |
|
12531 |
|
12532 |
|
12533 int timeout = 100; |
|
12534 int nBytes; |
|
12535 |
|
12536 int result = 0; |
|
12537 int err = 0; |
|
12538 int status = 0; |
|
12539 FILE *fp; |
|
12540 message_hdr_req *msgHdr = NULL; |
|
12541 message_hdr_resp* msg_struct = NULL; |
|
12542 TInt return_value = 0; |
|
12543 // Read data from the CFG file |
|
12544 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
12545 { |
|
12546 iLog->Log ( _L ( "read_data failed" ) ); |
|
12547 free_data ( connect_data ); |
|
12548 return_value = KErrGeneral; |
|
12549 goto return_code; |
|
12550 } |
|
12551 //request formation |
|
12552 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12553 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12554 |
|
12555 //message header use |
|
12556 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
12557 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12558 |
|
12559 msgHdr->message_type = ELogin_Request; |
|
12560 |
|
12561 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12562 index += sizeof( message_hdr_req ); |
|
12563 |
|
12564 int len = strlen(connect_data->username); |
|
12565 strcpy( smsg + index, connect_data->username ); |
|
12566 index += len + 1; |
|
12567 |
|
12568 //appending password |
|
12569 |
|
12570 len = strlen(connect_data->password ); |
|
12571 strcpy( smsg + index, connect_data->password ); |
|
12572 index += len + 1; |
|
12573 |
|
12574 //appending server name |
|
12575 |
|
12576 len = strlen(connect_data->server ); |
|
12577 strcpy( smsg + index, connect_data->server ); |
|
12578 index += len + 1; |
|
12579 |
|
12580 //appending resource |
|
12581 len = strlen(connect_data->resource ); |
|
12582 strcpy( smsg + index, connect_data->resource ); |
|
12583 index += len + 1; |
|
12584 |
|
12585 //appending ssl |
|
12586 smsg[index++]= '1'; |
|
12587 smsg[index++]= '\0'; |
|
12588 |
|
12589 //appending server port |
|
12590 len = strlen(connect_data->port ); |
|
12591 strcpy( smsg + index, connect_data->port ); |
|
12592 index += len + 1; |
|
12593 |
|
12594 // appending IAP id |
|
12595 |
|
12596 smsg[index++]= '1'; |
|
12597 smsg[index++]= '\0'; |
|
12598 |
|
12599 //appending connmgr_bus |
|
12600 len = strlen(connect_data->connmgr_bus ); |
|
12601 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
12602 index += len + 1; |
|
12603 |
|
12604 //appending connmgr_path |
|
12605 len = strlen(connect_data->connmgr_path ); |
|
12606 strcpy( smsg + index, connect_data->connmgr_path ); |
|
12607 index += len + 1; |
|
12608 |
|
12609 //appending protocol |
|
12610 len = strlen(connect_data->protocol ); |
|
12611 strcpy( smsg + index, connect_data->protocol ); |
|
12612 index += len + 1; |
|
12613 |
|
12614 #ifdef __WINSCW__ |
|
12615 //proxy server |
|
12616 len = strlen(connect_data->proxy_data->proxy_server ); |
|
12617 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
12618 index += len + 1; |
|
12619 |
|
12620 //proxy port |
|
12621 len = strlen(connect_data->proxy_data->proxy_port ); |
|
12622 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
12623 index += len + 1; |
|
12624 |
|
12625 #endif |
|
12626 //running isoserver |
|
12627 run_isoserver(); |
|
12628 |
|
12629 |
|
12630 |
|
12631 //create message queue for send request |
|
12632 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12633 //create message queue for response request |
|
12634 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12635 |
|
12636 |
|
12637 /* Send Message to queueOne */ |
|
12638 |
|
12639 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12640 |
|
12641 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
12642 |
|
12643 if (status < 0) |
|
12644 { |
|
12645 return_value = KErrGeneral; |
|
12646 goto return_code; |
|
12647 } |
|
12648 |
|
12649 |
|
12650 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
12651 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
12652 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12653 |
|
12654 if( msg_struct->response != 1) |
|
12655 { |
|
12656 return_value = KErrGeneral; |
|
12657 goto return_code; |
|
12658 } |
|
12659 |
|
12660 |
|
12661 // login end |
|
12662 //fetch req.. |
|
12663 for (int i= 0 ;i<3 ;i++) |
|
12664 { |
|
12665 |
|
12666 fp = fopen("c:\\fetch_contact.txt","a"); |
|
12667 do { |
|
12668 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12669 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12670 fwrite(rmsg,1,status,fp); |
|
12671 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12672 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
12673 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
12674 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
12675 fclose(fp); |
|
12676 |
|
12677 } |
|
12678 |
|
12679 //fetch end |
|
12680 |
|
12681 //-------------update presence--------------- |
|
12682 |
|
12683 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12684 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12685 index=0; |
|
12686 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12687 msgHdr->message_type = EUpdateOwnPresence; |
|
12688 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12689 index += sizeof( message_hdr_req ); |
|
12690 |
|
12691 |
|
12692 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12693 |
|
12694 do { |
|
12695 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12696 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12697 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12698 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
12699 |
|
12700 if ( msg_struct->error_type > 0) |
|
12701 { |
|
12702 return_value = KErrGeneral; |
|
12703 goto return_code; |
|
12704 } |
|
12705 // logout test code from server |
|
12706 index=0; |
|
12707 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12708 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12709 |
|
12710 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12711 |
|
12712 msgHdr->message_type = ELogout_Request; |
|
12713 |
|
12714 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12715 index += sizeof( message_hdr_req ); |
|
12716 |
|
12717 |
|
12718 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12719 do { |
|
12720 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12721 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12722 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12723 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
12724 |
|
12725 if ( msg_struct->response != 1) |
|
12726 { |
|
12727 return_value = KErrGeneral; |
|
12728 goto return_code; |
|
12729 } |
|
12730 //killing isoserver |
|
12731 return_code: |
|
12732 index=0; |
|
12733 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12734 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12735 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12736 msgHdr->message_type = EKill_Process; |
|
12737 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12738 index += sizeof( message_hdr_req ); |
|
12739 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12740 free( msg_struct ); |
|
12741 return return_value; |
|
12742 } |
|
12743 // ----------------------------------------------------------------------------- |
|
12744 // Cisolationserver::UpdatePresenceWithDnd |
|
12745 // Example test method function. |
|
12746 // (other items were commented in a header). |
|
12747 // ----------------------------------------------------------------------------- |
|
12748 // |
|
12749 TInt Cisolationserver::UpdateStatusTextWithSpecialCharacter( CStifItemParser& aItem ) |
|
12750 { |
|
12751 |
|
12752 |
|
12753 ConnectData *connect_data = NULL; |
|
12754 char smsg[MAX_MSG_SIZE]; |
|
12755 char rmsg[MAX_MSG_SIZE]; |
|
12756 int index=0; |
|
12757 |
|
12758 |
|
12759 int timeout = 100; |
|
12760 int nBytes; |
|
12761 |
|
12762 int result = 0; |
|
12763 int err = 0; |
|
12764 int status = 0; |
|
12765 FILE *fp; |
|
12766 message_hdr_req *msgHdr = NULL; |
|
12767 message_hdr_resp* msg_struct = NULL; |
|
12768 TInt return_value = 0; |
|
12769 // Read data from the CFG file |
|
12770 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
12771 { |
|
12772 iLog->Log ( _L ( "read_data failed" ) ); |
|
12773 free_data ( connect_data ); |
|
12774 return_value = KErrGeneral; |
|
12775 goto return_code; |
|
12776 } |
|
12777 //request formation |
|
12778 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12779 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12780 |
|
12781 //message header use |
|
12782 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
12783 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12784 |
|
12785 msgHdr->message_type = ELogin_Request; |
|
12786 |
|
12787 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12788 index += sizeof( message_hdr_req ); |
|
12789 |
|
12790 int len = strlen(connect_data->username); |
|
12791 strcpy( smsg + index, connect_data->username ); |
|
12792 index += len + 1; |
|
12793 |
|
12794 //appending password |
|
12795 |
|
12796 len = strlen(connect_data->password ); |
|
12797 strcpy( smsg + index, connect_data->password ); |
|
12798 index += len + 1; |
|
12799 |
|
12800 //appending server name |
|
12801 |
|
12802 len = strlen(connect_data->server ); |
|
12803 strcpy( smsg + index, connect_data->server ); |
|
12804 index += len + 1; |
|
12805 |
|
12806 //appending resource |
|
12807 len = strlen(connect_data->resource ); |
|
12808 strcpy( smsg + index, connect_data->resource ); |
|
12809 index += len + 1; |
|
12810 |
|
12811 //appending ssl |
|
12812 smsg[index++]= '1'; |
|
12813 smsg[index++]= '\0'; |
|
12814 |
|
12815 //appending server port |
|
12816 len = strlen(connect_data->port ); |
|
12817 strcpy( smsg + index, connect_data->port ); |
|
12818 index += len + 1; |
|
12819 |
|
12820 // appending IAP id |
|
12821 |
|
12822 smsg[index++]= '1'; |
|
12823 smsg[index++]= '\0'; |
|
12824 |
|
12825 //appending connmgr_bus |
|
12826 len = strlen(connect_data->connmgr_bus ); |
|
12827 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
12828 index += len + 1; |
|
12829 |
|
12830 //appending connmgr_path |
|
12831 len = strlen(connect_data->connmgr_path ); |
|
12832 strcpy( smsg + index, connect_data->connmgr_path ); |
|
12833 index += len + 1; |
|
12834 |
|
12835 //appending protocol |
|
12836 len = strlen(connect_data->protocol ); |
|
12837 strcpy( smsg + index, connect_data->protocol ); |
|
12838 index += len + 1; |
|
12839 |
|
12840 #ifdef __WINSCW__ |
|
12841 //proxy server |
|
12842 len = strlen(connect_data->proxy_data->proxy_server ); |
|
12843 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
12844 index += len + 1; |
|
12845 |
|
12846 //proxy port |
|
12847 len = strlen(connect_data->proxy_data->proxy_port ); |
|
12848 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
12849 index += len + 1; |
|
12850 |
|
12851 #endif |
|
12852 //running isoserver |
|
12853 run_isoserver(); |
|
12854 //create message queue for send request |
|
12855 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12856 //create message queue for response request |
|
12857 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
12858 |
|
12859 |
|
12860 /* Send Message to queueOne */ |
|
12861 |
|
12862 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12863 |
|
12864 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
12865 |
|
12866 if (status < 0) |
|
12867 { |
|
12868 return_value = KErrGeneral; |
|
12869 goto return_code; |
|
12870 } |
|
12871 |
|
12872 |
|
12873 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
12874 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
12875 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12876 |
|
12877 if( msg_struct->response != 1) |
|
12878 { |
|
12879 return_value = KErrGeneral; |
|
12880 goto return_code; |
|
12881 } |
|
12882 |
|
12883 |
|
12884 // login end |
|
12885 //fetch req.. |
|
12886 for (int i= 0 ;i<3 ;i++) |
|
12887 { |
|
12888 |
|
12889 fp = fopen("c:\\fetch_contact.txt","a"); |
|
12890 do { |
|
12891 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12892 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12893 fwrite(rmsg,1,status,fp); |
|
12894 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12895 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
12896 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
12897 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
12898 fclose(fp); |
|
12899 |
|
12900 } |
|
12901 |
|
12902 //fetch end |
|
12903 |
|
12904 //-------------update presence--------------- |
|
12905 |
|
12906 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12907 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12908 index=0; |
|
12909 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12910 msgHdr->message_type = EUpdateOwnPresence; |
|
12911 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12912 index += sizeof( message_hdr_req ); |
|
12913 |
|
12914 |
|
12915 // updating availability |
|
12916 char *availability = "dnd"; |
|
12917 memcpy( smsg + index, availability, strlen( availability ) ); |
|
12918 index += strlen( availability ); |
|
12919 smsg[index++]='\0'; |
|
12920 |
|
12921 //updating status text |
|
12922 char *statustext = "hi i m_ fine here @@@@@ ********* &&&&&&&&&&&&"; |
|
12923 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
12924 index += strlen( statustext ); |
|
12925 |
|
12926 |
|
12927 |
|
12928 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12929 |
|
12930 do { |
|
12931 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12932 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12933 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12934 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
12935 |
|
12936 if ( msg_struct->response != 1) |
|
12937 { |
|
12938 return_value = KErrGeneral; |
|
12939 goto return_code; |
|
12940 } |
|
12941 // logout test code from server |
|
12942 index=0; |
|
12943 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12944 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12945 |
|
12946 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12947 |
|
12948 msgHdr->message_type = ELogout_Request; |
|
12949 |
|
12950 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12951 index += sizeof( message_hdr_req ); |
|
12952 |
|
12953 |
|
12954 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12955 do { |
|
12956 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
12957 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
12958 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12959 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
12960 |
|
12961 if ( msg_struct->response != 1) |
|
12962 { |
|
12963 return_value = KErrGeneral; |
|
12964 goto return_code; |
|
12965 } |
|
12966 //killing isoserver |
|
12967 return_code: |
|
12968 index=0; |
|
12969 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
12970 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
12971 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
12972 msgHdr->message_type = EKill_Process; |
|
12973 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
12974 index += sizeof( message_hdr_req ); |
|
12975 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
12976 free( msg_struct ); |
|
12977 return return_value; |
|
12978 } |
|
12979 |
|
12980 // ----------------------------------------------------------------------------- |
|
12981 // Cisolationserver::UpdatePresenceWithDnd |
|
12982 // Example test method function. |
|
12983 // (other items were commented in a header). |
|
12984 // ----------------------------------------------------------------------------- |
|
12985 // |
|
12986 TInt Cisolationserver::UpdateStatusTextWithMaxLen( CStifItemParser& aItem ) |
|
12987 { |
|
12988 |
|
12989 |
|
12990 ConnectData *connect_data = NULL; |
|
12991 char smsg[MAX_MSG_SIZE]; |
|
12992 char rmsg[MAX_MSG_SIZE]; |
|
12993 int index=0; |
|
12994 |
|
12995 |
|
12996 int timeout = 100; |
|
12997 int nBytes; |
|
12998 |
|
12999 int result = 0; |
|
13000 int err = 0; |
|
13001 int status = 0; |
|
13002 FILE *fp; |
|
13003 message_hdr_req *msgHdr = NULL; |
|
13004 message_hdr_resp* msg_struct = NULL; |
|
13005 TInt return_value = 0; |
|
13006 // Read data from the CFG file |
|
13007 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
13008 { |
|
13009 iLog->Log ( _L ( "read_data failed" ) ); |
|
13010 free_data ( connect_data ); |
|
13011 return_value = KErrGeneral; |
|
13012 goto return_code; |
|
13013 } |
|
13014 //request formation |
|
13015 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13016 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13017 |
|
13018 //message header use |
|
13019 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
13020 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13021 |
|
13022 msgHdr->message_type = ELogin_Request; |
|
13023 |
|
13024 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13025 index += sizeof( message_hdr_req ); |
|
13026 |
|
13027 int len = strlen(connect_data->username); |
|
13028 strcpy( smsg + index, connect_data->username ); |
|
13029 index += len + 1; |
|
13030 |
|
13031 //appending password |
|
13032 |
|
13033 len = strlen(connect_data->password ); |
|
13034 strcpy( smsg + index, connect_data->password ); |
|
13035 index += len + 1; |
|
13036 |
|
13037 //appending server name |
|
13038 |
|
13039 len = strlen(connect_data->server ); |
|
13040 strcpy( smsg + index, connect_data->server ); |
|
13041 index += len + 1; |
|
13042 |
|
13043 //appending resource |
|
13044 len = strlen(connect_data->resource ); |
|
13045 strcpy( smsg + index, connect_data->resource ); |
|
13046 index += len + 1; |
|
13047 |
|
13048 //appending ssl |
|
13049 smsg[index++]= '1'; |
|
13050 smsg[index++]= '\0'; |
|
13051 |
|
13052 //appending server port |
|
13053 len = strlen(connect_data->port ); |
|
13054 strcpy( smsg + index, connect_data->port ); |
|
13055 index += len + 1; |
|
13056 |
|
13057 // appending IAP id |
|
13058 |
|
13059 smsg[index++]= '1'; |
|
13060 smsg[index++]= '\0'; |
|
13061 |
|
13062 //appending connmgr_bus |
|
13063 len = strlen(connect_data->connmgr_bus ); |
|
13064 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
13065 index += len + 1; |
|
13066 |
|
13067 //appending connmgr_path |
|
13068 len = strlen(connect_data->connmgr_path ); |
|
13069 strcpy( smsg + index, connect_data->connmgr_path ); |
|
13070 index += len + 1; |
|
13071 |
|
13072 //appending protocol |
|
13073 len = strlen(connect_data->protocol ); |
|
13074 strcpy( smsg + index, connect_data->protocol ); |
|
13075 index += len + 1; |
|
13076 |
|
13077 #ifdef __WINSCW__ |
|
13078 //proxy server |
|
13079 len = strlen(connect_data->proxy_data->proxy_server ); |
|
13080 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
13081 index += len + 1; |
|
13082 |
|
13083 //proxy port |
|
13084 len = strlen(connect_data->proxy_data->proxy_port ); |
|
13085 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
13086 index += len + 1; |
|
13087 |
|
13088 #endif |
|
13089 //running isoserver |
|
13090 run_isoserver(); |
|
13091 //create message queue for send request |
|
13092 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13093 //create message queue for response request |
|
13094 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13095 |
|
13096 |
|
13097 /* Send Message to queueOne */ |
|
13098 |
|
13099 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13100 |
|
13101 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13102 |
|
13103 if (status < 0) |
|
13104 { |
|
13105 return_value = KErrGeneral; |
|
13106 goto return_code; |
|
13107 } |
|
13108 |
|
13109 |
|
13110 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
13111 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
13112 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13113 |
|
13114 if( msg_struct->response != 1) |
|
13115 { |
|
13116 return_value = KErrGeneral; |
|
13117 goto return_code; |
|
13118 } |
|
13119 |
|
13120 |
|
13121 // login end |
|
13122 //fetch req.. |
|
13123 for (int i= 0 ;i<3 ;i++) |
|
13124 { |
|
13125 |
|
13126 fp = fopen("c:\\fetch_contact.txt","a"); |
|
13127 do { |
|
13128 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13129 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13130 fwrite(rmsg,1,status,fp); |
|
13131 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13132 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
13133 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
13134 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
13135 fclose(fp); |
|
13136 |
|
13137 } |
|
13138 |
|
13139 //fetch end |
|
13140 |
|
13141 //-------------update presence--------------- |
|
13142 |
|
13143 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13144 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13145 index=0; |
|
13146 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13147 msgHdr->message_type = EUpdateOwnPresence; |
|
13148 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13149 index += sizeof( message_hdr_req ); |
|
13150 |
|
13151 |
|
13152 // updating availability |
|
13153 char *availability = "dnd"; |
|
13154 memcpy( smsg + index, availability, strlen( availability ) ); |
|
13155 index += strlen( availability ); |
|
13156 smsg[index++]='\0'; |
|
13157 |
|
13158 //updating status text |
|
13159 char *statustext = "thesr is difference between thoughts and execution "; |
|
13160 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
13161 index += strlen( statustext ); |
|
13162 |
|
13163 |
|
13164 |
|
13165 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13166 |
|
13167 do { |
|
13168 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13169 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13170 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13171 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
13172 |
|
13173 if ( msg_struct->response != 1) |
|
13174 { |
|
13175 return_value = KErrGeneral; |
|
13176 goto return_code; |
|
13177 } |
|
13178 |
|
13179 // logout test code from server |
|
13180 index=0; |
|
13181 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13182 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13183 |
|
13184 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13185 |
|
13186 msgHdr->message_type = ELogout_Request; |
|
13187 |
|
13188 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13189 index += sizeof( message_hdr_req ); |
|
13190 |
|
13191 |
|
13192 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13193 do { |
|
13194 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13195 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13196 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13197 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
13198 |
|
13199 if ( msg_struct->response != 1) |
|
13200 { |
|
13201 return_value = KErrGeneral; |
|
13202 goto return_code; |
|
13203 } |
|
13204 |
|
13205 //killing isoserver |
|
13206 return_code: |
|
13207 index=0; |
|
13208 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13209 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13210 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13211 msgHdr->message_type = EKill_Process; |
|
13212 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13213 index += sizeof( message_hdr_req ); |
|
13214 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13215 free( msg_struct ); |
|
13216 return return_value; |
|
13217 } |
|
13218 |
|
13219 // ----------------------------------------------------------------------------- |
|
13220 // Cisolationserver::UpdatePresenceWithDnd |
|
13221 // Example test method function. |
|
13222 // (other items were commented in a header). |
|
13223 // ----------------------------------------------------------------------------- |
|
13224 // |
|
13225 TInt Cisolationserver::HandelingPresenceNotification( CStifItemParser& aItem ) |
|
13226 { |
|
13227 |
|
13228 /* |
|
13229 ConnectData *connect_data = NULL; |
|
13230 char smsg[MAX_MSG_SIZE]; |
|
13231 char rmsg[MAX_MSG_SIZE]; |
|
13232 int index=0; |
|
13233 |
|
13234 |
|
13235 int timeout = 100; |
|
13236 int nBytes; |
|
13237 |
|
13238 int result = 0; |
|
13239 int err = 0; |
|
13240 int status = 0; |
|
13241 FILE *fp; |
|
13242 message_hdr_req *msgHdr = NULL; |
|
13243 message_hdr_resp* msg_struct = NULL; |
|
13244 TInt return_value = 0; |
|
13245 // Read data from the CFG file |
|
13246 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
13247 { |
|
13248 iLog->Log ( _L ( "read_data failed" ) ); |
|
13249 free_data ( connect_data ); |
|
13250 return_value = KErrGeneral; |
|
13251 goto return_code; |
|
13252 } |
|
13253 //request formation |
|
13254 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13255 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13256 |
|
13257 //message header use |
|
13258 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
13259 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13260 |
|
13261 msgHdr->message_type = ELogin_Request; |
|
13262 |
|
13263 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13264 index += sizeof( message_hdr_req ); |
|
13265 |
|
13266 int len = strlen(connect_data->username); |
|
13267 strcpy( smsg + index, connect_data->username ); |
|
13268 index += len + 1; |
|
13269 |
|
13270 //appending password |
|
13271 |
|
13272 len = strlen(connect_data->password ); |
|
13273 strcpy( smsg + index, connect_data->password ); |
|
13274 index += len + 1; |
|
13275 |
|
13276 //appending server name |
|
13277 |
|
13278 len = strlen(connect_data->server ); |
|
13279 strcpy( smsg + index, connect_data->server ); |
|
13280 index += len + 1; |
|
13281 |
|
13282 //appending resource |
|
13283 len = strlen(connect_data->resource ); |
|
13284 strcpy( smsg + index, connect_data->resource ); |
|
13285 index += len + 1; |
|
13286 |
|
13287 //appending ssl |
|
13288 smsg[index++]= '1'; |
|
13289 smsg[index++]= '\0'; |
|
13290 |
|
13291 //appending server port |
|
13292 len = strlen(connect_data->port ); |
|
13293 strcpy( smsg + index, connect_data->port ); |
|
13294 index += len + 1; |
|
13295 |
|
13296 // appending IAP id |
|
13297 |
|
13298 smsg[index++]= '1'; |
|
13299 smsg[index++]= '\0'; |
|
13300 |
|
13301 //appending connmgr_bus |
|
13302 len = strlen(connect_data->connmgr_bus ); |
|
13303 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
13304 index += len + 1; |
|
13305 |
|
13306 //appending connmgr_path |
|
13307 len = strlen(connect_data->connmgr_path ); |
|
13308 strcpy( smsg + index, connect_data->connmgr_path ); |
|
13309 index += len + 1; |
|
13310 |
|
13311 //appending protocol |
|
13312 len = strlen(connect_data->protocol ); |
|
13313 strcpy( smsg + index, connect_data->protocol ); |
|
13314 index += len + 1; |
|
13315 |
|
13316 #ifdef __WINSCW__ |
|
13317 //proxy server |
|
13318 len = strlen(connect_data->proxy_data->proxy_server ); |
|
13319 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
13320 index += len + 1; |
|
13321 |
|
13322 //proxy port |
|
13323 len = strlen(connect_data->proxy_data->proxy_port ); |
|
13324 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
13325 index += len + 1; |
|
13326 |
|
13327 #endif |
|
13328 //running isoserver |
|
13329 run_isoserver(); |
|
13330 //create message queue for send request |
|
13331 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13332 //create message queue for response request |
|
13333 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13334 |
|
13335 |
|
13336 // Send Message to queueOne |
|
13337 |
|
13338 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13339 |
|
13340 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13341 |
|
13342 if (status < 0) |
|
13343 { |
|
13344 return_value = KErrGeneral; |
|
13345 goto return_code; |
|
13346 } |
|
13347 |
|
13348 |
|
13349 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
13350 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
13351 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13352 |
|
13353 if( msg_struct->response != 1) |
|
13354 { |
|
13355 return_value = KErrGeneral; |
|
13356 goto return_code; |
|
13357 } |
|
13358 |
|
13359 |
|
13360 // login end |
|
13361 //fetch req.. |
|
13362 for (int i= 0 ;i<3 ;i++) |
|
13363 { |
|
13364 |
|
13365 fp = fopen("c:\\fetch_contact.txt","a"); |
|
13366 do { |
|
13367 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13368 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13369 fwrite(rmsg,1,status,fp); |
|
13370 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13371 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
13372 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
13373 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
13374 fclose(fp); |
|
13375 |
|
13376 } |
|
13377 |
|
13378 //fetch end |
|
13379 |
|
13380 //-------------update presence--------------- |
|
13381 |
|
13382 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13383 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13384 index=0; |
|
13385 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13386 msgHdr->message_type = EUpdateOwnPresence; |
|
13387 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13388 index += sizeof( message_hdr_req ); |
|
13389 |
|
13390 |
|
13391 // updating availability |
|
13392 char *availability = "dnd"; |
|
13393 memcpy( smsg + index, availability, strlen( availability ) ); |
|
13394 index += strlen( availability ); |
|
13395 smsg[index++]='\0'; |
|
13396 |
|
13397 //updating status text |
|
13398 char *statustext = "i m busy"; |
|
13399 memcpy( smsg + index, statustext, strlen( statustext ) ); |
|
13400 index += strlen( statustext ); |
|
13401 |
|
13402 |
|
13403 |
|
13404 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13405 |
|
13406 do { |
|
13407 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13408 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13409 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13410 } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence); |
|
13411 |
|
13412 if ( msg_struct->response != 1) |
|
13413 { |
|
13414 return_value = KErrGeneral; |
|
13415 goto return_code; |
|
13416 } |
|
13417 |
|
13418 // waiting for second change |
|
13419 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13420 //wait for message receive |
|
13421 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13422 if (status < 0) |
|
13423 { |
|
13424 return_value = KErrGeneral; |
|
13425 goto return_code; |
|
13426 } |
|
13427 // waiting for first change |
|
13428 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13429 //wait for message receive |
|
13430 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13431 if (status < 0) |
|
13432 { |
|
13433 return_value = KErrGeneral; |
|
13434 goto return_code; |
|
13435 } |
|
13436 |
|
13437 // waiting for first change |
|
13438 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13439 //wait for message receive |
|
13440 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13441 if (status < 0) |
|
13442 { |
|
13443 return_value = KErrGeneral; |
|
13444 goto return_code; |
|
13445 } |
|
13446 |
|
13447 |
|
13448 // waiting for first change |
|
13449 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13450 //wait for message receive |
|
13451 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13452 if (status < 0) |
|
13453 { |
|
13454 return_value = KErrGeneral; |
|
13455 goto return_code; |
|
13456 } |
|
13457 |
|
13458 |
|
13459 // waiting for first change |
|
13460 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13461 //wait for message receive |
|
13462 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13463 if (status < 0) |
|
13464 { |
|
13465 return_value = KErrGeneral; |
|
13466 goto return_code; |
|
13467 } |
|
13468 // logout test code from server |
|
13469 index=0; |
|
13470 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13471 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13472 |
|
13473 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13474 |
|
13475 msgHdr->message_type = ELogout_Request; |
|
13476 |
|
13477 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13478 index += sizeof( message_hdr_req ); |
|
13479 |
|
13480 |
|
13481 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13482 do { |
|
13483 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13484 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13485 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13486 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
13487 |
|
13488 if ( msg_struct->response != 1) |
|
13489 { |
|
13490 return_value = KErrGeneral; |
|
13491 goto return_code; |
|
13492 } |
|
13493 //killing isoserver |
|
13494 return_code: |
|
13495 index=0; |
|
13496 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13497 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13498 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13499 msgHdr->message_type = EKill_Process; |
|
13500 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13501 index += sizeof( message_hdr_req ); |
|
13502 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13503 free( msg_struct ); |
|
13504 return return_value; */ |
|
13505 return KErrNone; |
|
13506 } |
|
13507 |
|
13508 |
|
13509 Cisolationserver::SearchKeyValue( CStifItemParser& aItem ) |
|
13510 { |
|
13511 ConnectData *connect_data = NULL; |
|
13512 char smsg[MAX_MSG_SIZE]; |
|
13513 char rmsg[MAX_MSG_SIZE]; |
|
13514 int index=0; |
|
13515 FILE *fp; |
|
13516 |
|
13517 int timeout = 200; |
|
13518 int nBytes; |
|
13519 |
|
13520 int result = 0; |
|
13521 int err = 0; |
|
13522 int status = 0; |
|
13523 TInt return_value = 0; |
|
13524 message_hdr_req *msgHdr = NULL; |
|
13525 message_hdr_resp* msg_struct = NULL; |
|
13526 |
|
13527 // Read data from the CFG file |
|
13528 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
13529 { |
|
13530 iLog->Log ( _L ( "read_data failed" ) ); |
|
13531 free_data ( connect_data ); |
|
13532 return KErrGeneral; |
|
13533 } |
|
13534 //request formation |
|
13535 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13536 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13537 |
|
13538 //message header use |
|
13539 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
13540 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13541 |
|
13542 msgHdr->message_type = ELogin_Request; |
|
13543 |
|
13544 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13545 index += sizeof( message_hdr_req ); |
|
13546 |
|
13547 int len = strlen(connect_data->username); |
|
13548 strcpy( smsg + index, connect_data->username ); |
|
13549 index += len + 1; |
|
13550 |
|
13551 //appending password |
|
13552 |
|
13553 len = strlen(connect_data->password ); |
|
13554 strcpy( smsg + index, connect_data->password ); |
|
13555 index += len + 1; |
|
13556 |
|
13557 //appending server name |
|
13558 |
|
13559 len = strlen(connect_data->server ); |
|
13560 strcpy( smsg + index, connect_data->server ); |
|
13561 index += len + 1; |
|
13562 |
|
13563 //appending resource |
|
13564 len = strlen(connect_data->resource ); |
|
13565 strcpy( smsg + index, connect_data->resource ); |
|
13566 index += len + 1; |
|
13567 |
|
13568 //appending ssl |
|
13569 smsg[index++]= '0'; |
|
13570 smsg[index++]= '\0'; |
|
13571 |
|
13572 //appending server port |
|
13573 len = strlen(connect_data->port ); |
|
13574 strcpy( smsg + index, connect_data->port ); |
|
13575 index += len + 1; |
|
13576 |
|
13577 // appending IAP id |
|
13578 |
|
13579 smsg[index++]= '1'; |
|
13580 smsg[index++]= '\0'; |
|
13581 |
|
13582 //appending connmgr_bus |
|
13583 len = strlen(connect_data->connmgr_bus ); |
|
13584 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
13585 index += len + 1; |
|
13586 |
|
13587 //appending connmgr_path |
|
13588 len = strlen(connect_data->connmgr_path ); |
|
13589 strcpy( smsg + index, connect_data->connmgr_path ); |
|
13590 index += len + 1; |
|
13591 |
|
13592 //appending protocol |
|
13593 len = strlen(connect_data->protocol ); |
|
13594 strcpy( smsg + index, connect_data->protocol ); |
|
13595 index += len + 1; |
|
13596 |
|
13597 #ifdef __WINSCW__ |
|
13598 //proxy server |
|
13599 len = strlen(connect_data->proxy_data->proxy_server ); |
|
13600 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
13601 index += len + 1; |
|
13602 |
|
13603 //proxy port |
|
13604 len = strlen(connect_data->proxy_data->proxy_port ); |
|
13605 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
13606 index += len + 1; |
|
13607 |
|
13608 #endif |
|
13609 run_isoserver(); |
|
13610 |
|
13611 |
|
13612 |
|
13613 //create message queue for send request |
|
13614 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13615 //create message queue for response request |
|
13616 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13617 |
|
13618 |
|
13619 /* Send Message to queueOne */ |
|
13620 |
|
13621 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13622 |
|
13623 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13624 |
|
13625 if (status < 0) |
|
13626 { |
|
13627 return_value = KErrGeneral; |
|
13628 goto return_code; |
|
13629 } |
|
13630 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
13631 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
13632 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13633 |
|
13634 if( msg_struct->response != 1) |
|
13635 { |
|
13636 return_value = KErrGeneral; |
|
13637 goto return_code; |
|
13638 } |
|
13639 |
|
13640 |
|
13641 // login end |
|
13642 //fetch req.. |
|
13643 for (int i= 0 ;i<3 ;i++) |
|
13644 { |
|
13645 |
|
13646 fp = fopen("c:\\fetch_contact.txt","a"); |
|
13647 do { |
|
13648 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13649 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13650 fwrite(rmsg,1,status,fp); |
|
13651 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13652 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
13653 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
13654 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
13655 fclose(fp); |
|
13656 |
|
13657 } |
|
13658 |
|
13659 //fetch end |
|
13660 |
|
13661 //search messge-------------------------------------------- |
|
13662 |
|
13663 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13664 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13665 index=0; |
|
13666 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13667 msgHdr->message_type = ESearch; |
|
13668 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13669 index += sizeof( message_hdr_req ); |
|
13670 |
|
13671 |
|
13672 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
13673 // adding key |
|
13674 len = strlen(search_label); |
|
13675 strcpy( smsg + index, search_label ); |
|
13676 index += len + 1; |
|
13677 |
|
13678 |
|
13679 |
|
13680 // adding value |
|
13681 |
|
13682 len = strlen("santhosh" ); |
|
13683 strcpy( smsg + index, "santhosh" ); |
|
13684 index += len + 1; |
|
13685 |
|
13686 |
|
13687 smsg[index++] = '\0'; |
|
13688 |
|
13689 |
|
13690 |
|
13691 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13692 do { |
|
13693 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13694 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13695 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13696 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
13697 |
|
13698 if ( msg_struct->response != 1) |
|
13699 { |
|
13700 return_value = KErrGeneral; |
|
13701 goto return_code; |
|
13702 } |
|
13703 ///------------------------------------------------------------- |
|
13704 |
|
13705 |
|
13706 //search message end--------------------------------------- |
|
13707 |
|
13708 |
|
13709 // logout test code from server |
|
13710 index=0; |
|
13711 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13712 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13713 |
|
13714 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13715 |
|
13716 msgHdr->message_type = ELogout_Request; |
|
13717 |
|
13718 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13719 index += sizeof( message_hdr_req ); |
|
13720 |
|
13721 |
|
13722 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13723 do { |
|
13724 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13725 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13726 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13727 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
13728 |
|
13729 if ( msg_struct->response != 1) |
|
13730 { |
|
13731 return_value = KErrGeneral; |
|
13732 goto return_code; |
|
13733 } |
|
13734 |
|
13735 |
|
13736 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
13737 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
13738 return_value = KErrNone; |
|
13739 goto return_code; |
|
13740 //killing isoserver |
|
13741 return_code: |
|
13742 index=0; |
|
13743 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13744 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13745 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13746 msgHdr->message_type = EKill_Process; |
|
13747 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13748 index += sizeof( message_hdr_req ); |
|
13749 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13750 free( msg_struct ); |
|
13751 return return_value; |
|
13752 } |
|
13753 |
|
13754 Cisolationserver::SearchKeyValueWithResult( CStifItemParser& aItem ) |
|
13755 { |
|
13756 ConnectData *connect_data = NULL; |
|
13757 char smsg[MAX_MSG_SIZE]; |
|
13758 char rmsg[MAX_MSG_SIZE]; |
|
13759 int index=0; |
|
13760 FILE *fp; |
|
13761 |
|
13762 int timeout = 200; |
|
13763 int nBytes; |
|
13764 TInt return_value = 0; |
|
13765 int result = 0; |
|
13766 int err = 0; |
|
13767 int status = 0; |
|
13768 message_hdr_req *msgHdr = NULL; |
|
13769 message_hdr_resp* msg_struct = NULL; |
|
13770 |
|
13771 // Read data from the CFG file |
|
13772 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
13773 { |
|
13774 iLog->Log ( _L ( "read_data failed" ) ); |
|
13775 free_data ( connect_data ); |
|
13776 return_value = KErrGeneral; |
|
13777 goto return_code; |
|
13778 } |
|
13779 //request formation |
|
13780 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13781 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13782 |
|
13783 //message header use |
|
13784 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
13785 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13786 |
|
13787 msgHdr->message_type = ELogin_Request; |
|
13788 |
|
13789 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13790 index += sizeof( message_hdr_req ); |
|
13791 |
|
13792 int len = strlen(connect_data->username); |
|
13793 strcpy( smsg + index, connect_data->username ); |
|
13794 index += len + 1; |
|
13795 |
|
13796 //appending password |
|
13797 |
|
13798 len = strlen(connect_data->password ); |
|
13799 strcpy( smsg + index, connect_data->password ); |
|
13800 index += len + 1; |
|
13801 |
|
13802 //appending server name |
|
13803 |
|
13804 len = strlen(connect_data->server ); |
|
13805 strcpy( smsg + index, connect_data->server ); |
|
13806 index += len + 1; |
|
13807 |
|
13808 //appending resource |
|
13809 len = strlen(connect_data->resource ); |
|
13810 strcpy( smsg + index, connect_data->resource ); |
|
13811 index += len + 1; |
|
13812 |
|
13813 //appending ssl |
|
13814 smsg[index++]= '0'; |
|
13815 smsg[index++]= '\0'; |
|
13816 |
|
13817 //appending server port |
|
13818 len = strlen(connect_data->port ); |
|
13819 strcpy( smsg + index, connect_data->port ); |
|
13820 index += len + 1; |
|
13821 |
|
13822 // appending IAP id |
|
13823 |
|
13824 smsg[index++]= '1'; |
|
13825 smsg[index++]= '\0'; |
|
13826 |
|
13827 //appending connmgr_bus |
|
13828 len = strlen(connect_data->connmgr_bus ); |
|
13829 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
13830 index += len + 1; |
|
13831 |
|
13832 //appending connmgr_path |
|
13833 len = strlen(connect_data->connmgr_path ); |
|
13834 strcpy( smsg + index, connect_data->connmgr_path ); |
|
13835 index += len + 1; |
|
13836 |
|
13837 //appending protocol |
|
13838 len = strlen(connect_data->protocol ); |
|
13839 strcpy( smsg + index, connect_data->protocol ); |
|
13840 index += len + 1; |
|
13841 |
|
13842 #ifdef __WINSCW__ |
|
13843 //proxy server |
|
13844 len = strlen(connect_data->proxy_data->proxy_server ); |
|
13845 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
13846 index += len + 1; |
|
13847 |
|
13848 //proxy port |
|
13849 len = strlen(connect_data->proxy_data->proxy_port ); |
|
13850 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
13851 index += len + 1; |
|
13852 |
|
13853 #endif |
|
13854 run_isoserver(); |
|
13855 |
|
13856 |
|
13857 |
|
13858 //create message queue for send request |
|
13859 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13860 //create message queue for response request |
|
13861 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
13862 |
|
13863 |
|
13864 /* Send Message to queueOne */ |
|
13865 |
|
13866 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13867 |
|
13868 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
13869 |
|
13870 if (status < 0) |
|
13871 { |
|
13872 return_value = KErrGeneral; |
|
13873 goto return_code; |
|
13874 } |
|
13875 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
13876 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
13877 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13878 |
|
13879 if( msg_struct->response != 1) |
|
13880 { |
|
13881 return_value = KErrGeneral; |
|
13882 goto return_code; |
|
13883 } |
|
13884 |
|
13885 |
|
13886 // login end |
|
13887 //fetch req.. |
|
13888 for (int i= 0 ;i<3 ;i++) |
|
13889 { |
|
13890 |
|
13891 fp = fopen("c:\\fetch_contact.txt","a"); |
|
13892 do { |
|
13893 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13894 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13895 fwrite(rmsg,1,status,fp); |
|
13896 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13897 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
13898 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
13899 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
13900 fclose(fp); |
|
13901 |
|
13902 } |
|
13903 |
|
13904 //fetch end |
|
13905 |
|
13906 //search messge-------------------------------------------- |
|
13907 |
|
13908 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13909 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13910 index=0; |
|
13911 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13912 msgHdr->message_type = ESearch; |
|
13913 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13914 index += sizeof( message_hdr_req ); |
|
13915 |
|
13916 |
|
13917 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
13918 // adding key |
|
13919 len = strlen(search_label); |
|
13920 strcpy( smsg + index, search_label ); |
|
13921 index += len + 1; |
|
13922 |
|
13923 // adding value |
|
13924 |
|
13925 len = strlen("rakesh" ); |
|
13926 strcpy( smsg + index, "rakesh" ); |
|
13927 index += len + 1; |
|
13928 |
|
13929 smsg[index++] = '\0'; |
|
13930 |
|
13931 |
|
13932 |
|
13933 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13934 do { |
|
13935 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13936 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13937 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13938 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
13939 |
|
13940 if ( msg_struct->response != 1) |
|
13941 { |
|
13942 return_value = KErrGeneral; |
|
13943 goto return_code; |
|
13944 } |
|
13945 |
|
13946 |
|
13947 |
|
13948 //search message end--------------------------------------- |
|
13949 |
|
13950 |
|
13951 // logout test code from server |
|
13952 index=0; |
|
13953 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13954 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13955 |
|
13956 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13957 |
|
13958 msgHdr->message_type = ELogout_Request; |
|
13959 |
|
13960 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13961 index += sizeof( message_hdr_req ); |
|
13962 |
|
13963 |
|
13964 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13965 do { |
|
13966 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
13967 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
13968 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13969 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
13970 |
|
13971 if ( msg_struct->response != 1) |
|
13972 { |
|
13973 return_value = KErrGeneral; |
|
13974 goto return_code; |
|
13975 } |
|
13976 |
|
13977 |
|
13978 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
13979 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
13980 return_value = KErrNone; |
|
13981 goto return_code; |
|
13982 //killing isoserver |
|
13983 return_code: |
|
13984 index=0; |
|
13985 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
13986 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
13987 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
13988 msgHdr->message_type = EKill_Process; |
|
13989 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
13990 index += sizeof( message_hdr_req ); |
|
13991 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
13992 free( msg_struct ); |
|
13993 return return_value; |
|
13994 } |
|
13995 |
|
13996 |
|
13997 |
|
13998 Cisolationserver::SearchKeyValueInvalidParam( CStifItemParser& aItem ) |
|
13999 { |
|
14000 ConnectData *connect_data = NULL; |
|
14001 char smsg[MAX_MSG_SIZE]; |
|
14002 char rmsg[MAX_MSG_SIZE]; |
|
14003 int index=0; |
|
14004 FILE *fp; |
|
14005 |
|
14006 int timeout = 200; |
|
14007 int nBytes; |
|
14008 TInt return_value = 0; |
|
14009 int result = 0; |
|
14010 int err = 0; |
|
14011 int status = 0; |
|
14012 message_hdr_req *msgHdr = NULL; |
|
14013 message_hdr_resp* msg_struct = NULL; |
|
14014 |
|
14015 // Read data from the CFG file |
|
14016 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
14017 { |
|
14018 iLog->Log ( _L ( "read_data failed" ) ); |
|
14019 free_data ( connect_data ); |
|
14020 return_value = KErrGeneral; |
|
14021 goto return_code; |
|
14022 } |
|
14023 //request formation |
|
14024 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14025 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14026 |
|
14027 //message header use |
|
14028 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
14029 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14030 |
|
14031 msgHdr->message_type = ELogin_Request; |
|
14032 |
|
14033 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14034 index += sizeof( message_hdr_req ); |
|
14035 |
|
14036 int len = strlen(connect_data->username); |
|
14037 strcpy( smsg + index, connect_data->username ); |
|
14038 index += len + 1; |
|
14039 |
|
14040 //appending password |
|
14041 |
|
14042 len = strlen(connect_data->password ); |
|
14043 strcpy( smsg + index, connect_data->password ); |
|
14044 index += len + 1; |
|
14045 |
|
14046 //appending server name |
|
14047 |
|
14048 len = strlen(connect_data->server ); |
|
14049 strcpy( smsg + index, connect_data->server ); |
|
14050 index += len + 1; |
|
14051 |
|
14052 //appending resource |
|
14053 len = strlen(connect_data->resource ); |
|
14054 strcpy( smsg + index, connect_data->resource ); |
|
14055 index += len + 1; |
|
14056 |
|
14057 //appending ssl |
|
14058 smsg[index++]= '0'; |
|
14059 smsg[index++]= '\0'; |
|
14060 |
|
14061 //appending server port |
|
14062 len = strlen(connect_data->port ); |
|
14063 strcpy( smsg + index, connect_data->port ); |
|
14064 index += len + 1; |
|
14065 |
|
14066 // appending IAP id |
|
14067 |
|
14068 smsg[index++]= '1'; |
|
14069 smsg[index++]= '\0'; |
|
14070 |
|
14071 //appending connmgr_bus |
|
14072 len = strlen(connect_data->connmgr_bus ); |
|
14073 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
14074 index += len + 1; |
|
14075 |
|
14076 //appending connmgr_path |
|
14077 len = strlen(connect_data->connmgr_path ); |
|
14078 strcpy( smsg + index, connect_data->connmgr_path ); |
|
14079 index += len + 1; |
|
14080 |
|
14081 //appending protocol |
|
14082 len = strlen(connect_data->protocol ); |
|
14083 strcpy( smsg + index, connect_data->protocol ); |
|
14084 index += len + 1; |
|
14085 |
|
14086 #ifdef __WINSCW__ |
|
14087 //proxy server |
|
14088 len = strlen(connect_data->proxy_data->proxy_server ); |
|
14089 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
14090 index += len + 1; |
|
14091 |
|
14092 //proxy port |
|
14093 len = strlen(connect_data->proxy_data->proxy_port ); |
|
14094 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
14095 index += len + 1; |
|
14096 |
|
14097 #endif |
|
14098 run_isoserver(); |
|
14099 |
|
14100 //create message queue for send request |
|
14101 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14102 //create message queue for response request |
|
14103 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14104 |
|
14105 |
|
14106 /* Send Message to queueOne */ |
|
14107 |
|
14108 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14109 |
|
14110 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
14111 |
|
14112 if (status < 0) |
|
14113 { |
|
14114 return_value = KErrGeneral; |
|
14115 goto return_code; |
|
14116 } |
|
14117 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
14118 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
14119 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14120 |
|
14121 if( msg_struct->response != 1) |
|
14122 { |
|
14123 return_value = KErrGeneral; |
|
14124 goto return_code; |
|
14125 } |
|
14126 |
|
14127 |
|
14128 // login end |
|
14129 //fetch req.. |
|
14130 for (int i= 0 ;i<3 ;i++) |
|
14131 { |
|
14132 |
|
14133 fp = fopen("c:\\fetch_contact.txt","a"); |
|
14134 do { |
|
14135 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14136 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14137 fwrite(rmsg,1,status,fp); |
|
14138 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14139 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
14140 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
14141 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
14142 fclose(fp); |
|
14143 |
|
14144 } |
|
14145 |
|
14146 //fetch end |
|
14147 |
|
14148 //search messge-------------------------------------------- |
|
14149 |
|
14150 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14151 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14152 index=0; |
|
14153 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14154 msgHdr->message_type = ESearch; |
|
14155 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14156 index += sizeof( message_hdr_req ); |
|
14157 |
|
14158 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
14159 // adding key |
|
14160 len = strlen(search_label); |
|
14161 strcpy( smsg + index, search_label ); |
|
14162 index += len + 1; |
|
14163 |
|
14164 smsg[index++] = '\0'; |
|
14165 |
|
14166 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14167 do { |
|
14168 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14169 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14170 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14171 } while (msg_struct->hdr_req.message_type!= ESearch ); |
|
14172 |
|
14173 if ( msg_struct->response != 0) |
|
14174 { |
|
14175 return_value = KErrGeneral; |
|
14176 goto return_code; |
|
14177 } |
|
14178 |
|
14179 |
|
14180 |
|
14181 //search message end--------------------------------------- |
|
14182 |
|
14183 |
|
14184 // logout test code from server |
|
14185 index=0; |
|
14186 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14187 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14188 |
|
14189 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14190 |
|
14191 msgHdr->message_type = ELogout_Request; |
|
14192 |
|
14193 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14194 index += sizeof( message_hdr_req ); |
|
14195 |
|
14196 |
|
14197 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14198 do { |
|
14199 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14200 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14201 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14202 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
14203 |
|
14204 if ( msg_struct->response != 1) |
|
14205 { |
|
14206 return_value = KErrGeneral; |
|
14207 goto return_code; |
|
14208 } |
|
14209 |
|
14210 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
14211 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
14212 return_value = KErrNone; |
|
14213 goto return_code; |
|
14214 //killing isoserver |
|
14215 return_code: |
|
14216 index=0; |
|
14217 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14218 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14219 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14220 msgHdr->message_type = EKill_Process; |
|
14221 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14222 index += sizeof( message_hdr_req ); |
|
14223 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14224 free( msg_struct ); |
|
14225 return return_value; |
|
14226 |
|
14227 } |
|
14228 |
|
14229 |
|
14230 Cisolationserver::SearchForLargeNoOfResult( CStifItemParser& aItem ) |
|
14231 { |
|
14232 ConnectData *connect_data = NULL; |
|
14233 char smsg[MAX_MSG_SIZE]; |
|
14234 char rmsg[MAX_MSG_SIZE]; |
|
14235 int index=0; |
|
14236 FILE *fp; |
|
14237 |
|
14238 int timeout = 200; |
|
14239 int nBytes; |
|
14240 TInt return_value = 0; |
|
14241 int result = 0; |
|
14242 int err = 0; |
|
14243 int status = 0; |
|
14244 message_hdr_req *msgHdr = NULL; |
|
14245 message_hdr_resp* msg_struct = NULL; |
|
14246 |
|
14247 // Read data from the CFG file |
|
14248 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
14249 { |
|
14250 iLog->Log ( _L ( "read_data failed" ) ); |
|
14251 free_data ( connect_data ); |
|
14252 return_value = KErrGeneral; |
|
14253 goto return_code; |
|
14254 } |
|
14255 //request formation |
|
14256 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14257 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14258 |
|
14259 //message header use |
|
14260 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
14261 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14262 |
|
14263 msgHdr->message_type = ELogin_Request; |
|
14264 |
|
14265 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14266 index += sizeof( message_hdr_req ); |
|
14267 |
|
14268 int len = strlen(connect_data->username); |
|
14269 strcpy( smsg + index, connect_data->username ); |
|
14270 index += len + 1; |
|
14271 |
|
14272 //appending password |
|
14273 |
|
14274 len = strlen(connect_data->password ); |
|
14275 strcpy( smsg + index, connect_data->password ); |
|
14276 index += len + 1; |
|
14277 |
|
14278 //appending server name |
|
14279 |
|
14280 len = strlen(connect_data->server ); |
|
14281 strcpy( smsg + index, connect_data->server ); |
|
14282 index += len + 1; |
|
14283 |
|
14284 //appending resource |
|
14285 len = strlen(connect_data->resource ); |
|
14286 strcpy( smsg + index, connect_data->resource ); |
|
14287 index += len + 1; |
|
14288 |
|
14289 //appending ssl |
|
14290 smsg[index++]= '0'; |
|
14291 smsg[index++]= '\0'; |
|
14292 |
|
14293 //appending server port |
|
14294 len = strlen(connect_data->port ); |
|
14295 strcpy( smsg + index, connect_data->port ); |
|
14296 index += len + 1; |
|
14297 |
|
14298 // appending IAP id |
|
14299 |
|
14300 smsg[index++]= '1'; |
|
14301 smsg[index++]= '\0'; |
|
14302 |
|
14303 //appending connmgr_bus |
|
14304 len = strlen(connect_data->connmgr_bus ); |
|
14305 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
14306 index += len + 1; |
|
14307 |
|
14308 //appending connmgr_path |
|
14309 len = strlen(connect_data->connmgr_path ); |
|
14310 strcpy( smsg + index, connect_data->connmgr_path ); |
|
14311 index += len + 1; |
|
14312 |
|
14313 //appending protocol |
|
14314 len = strlen(connect_data->protocol ); |
|
14315 strcpy( smsg + index, connect_data->protocol ); |
|
14316 index += len + 1; |
|
14317 |
|
14318 #ifdef __WINSCW__ |
|
14319 //proxy server |
|
14320 len = strlen(connect_data->proxy_data->proxy_server ); |
|
14321 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
14322 index += len + 1; |
|
14323 |
|
14324 //proxy port |
|
14325 len = strlen(connect_data->proxy_data->proxy_port ); |
|
14326 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
14327 index += len + 1; |
|
14328 |
|
14329 #endif |
|
14330 run_isoserver(); |
|
14331 |
|
14332 |
|
14333 |
|
14334 //create message queue for send request |
|
14335 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14336 //create message queue for response request |
|
14337 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14338 |
|
14339 |
|
14340 /* Send Message to queueOne */ |
|
14341 |
|
14342 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14343 |
|
14344 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
14345 |
|
14346 if (status < 0) |
|
14347 { |
|
14348 return_value = KErrGeneral; |
|
14349 goto return_code; |
|
14350 } |
|
14351 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
14352 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
14353 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14354 |
|
14355 if( msg_struct->response != 1) |
|
14356 { |
|
14357 return_value = KErrGeneral; |
|
14358 goto return_code; |
|
14359 } |
|
14360 |
|
14361 |
|
14362 // login end |
|
14363 //fetch req.. |
|
14364 for (int i= 0 ;i<3 ;i++) |
|
14365 { |
|
14366 |
|
14367 fp = fopen("c:\\fetch_contact.txt","a"); |
|
14368 do { |
|
14369 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14370 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14371 fwrite(rmsg,1,status,fp); |
|
14372 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14373 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
14374 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
14375 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
14376 fclose(fp); |
|
14377 |
|
14378 } |
|
14379 |
|
14380 //fetch end |
|
14381 |
|
14382 //search messge-------------------------------------------- |
|
14383 |
|
14384 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14385 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14386 index=0; |
|
14387 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14388 msgHdr->message_type = ESearch; |
|
14389 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14390 index += sizeof( message_hdr_req ); |
|
14391 |
|
14392 |
|
14393 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
14394 // adding key |
|
14395 len = strlen(search_label); |
|
14396 strcpy( smsg + index, search_label ); |
|
14397 index += len + 1; |
|
14398 |
|
14399 |
|
14400 |
|
14401 // adding value |
|
14402 |
|
14403 len = strlen("a*" ); |
|
14404 strcpy( smsg + index, "a*" ); |
|
14405 index += len + 1; |
|
14406 |
|
14407 smsg[index++] = '\0'; |
|
14408 |
|
14409 |
|
14410 |
|
14411 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14412 do { |
|
14413 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14414 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14415 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14416 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
14417 |
|
14418 if ( msg_struct->response != 1) |
|
14419 { |
|
14420 return_value = KErrGeneral; |
|
14421 goto return_code; |
|
14422 } |
|
14423 |
|
14424 |
|
14425 |
|
14426 //search message end--------------------------------------- |
|
14427 |
|
14428 |
|
14429 // logout test code from server |
|
14430 index=0; |
|
14431 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14432 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14433 |
|
14434 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14435 |
|
14436 msgHdr->message_type = ELogout_Request; |
|
14437 |
|
14438 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14439 index += sizeof( message_hdr_req ); |
|
14440 |
|
14441 |
|
14442 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14443 do { |
|
14444 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14445 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14446 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14447 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
14448 |
|
14449 if ( msg_struct->response != 1) |
|
14450 { |
|
14451 return_value = KErrGeneral; |
|
14452 goto return_code; |
|
14453 } |
|
14454 |
|
14455 |
|
14456 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
14457 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
14458 return_value = KErrNone; |
|
14459 goto return_code; |
|
14460 |
|
14461 //killing isoserver |
|
14462 return_code: |
|
14463 index=0; |
|
14464 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14465 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14466 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14467 msgHdr->message_type = EKill_Process; |
|
14468 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14469 index += sizeof( message_hdr_req ); |
|
14470 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14471 free( msg_struct ); |
|
14472 return return_value; |
|
14473 } |
|
14474 |
|
14475 Cisolationserver::SearchKeyValueInvalidParam2( CStifItemParser& aItem ) |
|
14476 { |
|
14477 ConnectData *connect_data = NULL; |
|
14478 char smsg[MAX_MSG_SIZE]; |
|
14479 char rmsg[MAX_MSG_SIZE]; |
|
14480 int index=0; |
|
14481 FILE *fp; |
|
14482 |
|
14483 int timeout = 200; |
|
14484 int nBytes; |
|
14485 TInt return_value = 0; |
|
14486 int result = 0; |
|
14487 int err = 0; |
|
14488 int status = 0; |
|
14489 message_hdr_req *msgHdr = NULL; |
|
14490 message_hdr_resp* msg_struct = NULL; |
|
14491 |
|
14492 // Read data from the CFG file |
|
14493 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
14494 { |
|
14495 iLog->Log ( _L ( "read_data failed" ) ); |
|
14496 free_data ( connect_data ); |
|
14497 return_value = KErrGeneral; |
|
14498 goto return_code; |
|
14499 } |
|
14500 //request formation |
|
14501 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14502 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14503 |
|
14504 //message header use |
|
14505 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
14506 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14507 |
|
14508 msgHdr->message_type = ELogin_Request; |
|
14509 |
|
14510 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14511 index += sizeof( message_hdr_req ); |
|
14512 |
|
14513 int len = strlen(connect_data->username); |
|
14514 strcpy( smsg + index, connect_data->username ); |
|
14515 index += len + 1; |
|
14516 |
|
14517 //appending password |
|
14518 |
|
14519 len = strlen(connect_data->password ); |
|
14520 strcpy( smsg + index, connect_data->password ); |
|
14521 index += len + 1; |
|
14522 |
|
14523 //appending server name |
|
14524 |
|
14525 len = strlen(connect_data->server ); |
|
14526 strcpy( smsg + index, connect_data->server ); |
|
14527 index += len + 1; |
|
14528 |
|
14529 //appending resource |
|
14530 len = strlen(connect_data->resource ); |
|
14531 strcpy( smsg + index, connect_data->resource ); |
|
14532 index += len + 1; |
|
14533 |
|
14534 //appending ssl |
|
14535 smsg[index++]= '0'; |
|
14536 smsg[index++]= '\0'; |
|
14537 |
|
14538 //appending server port |
|
14539 len = strlen(connect_data->port ); |
|
14540 strcpy( smsg + index, connect_data->port ); |
|
14541 index += len + 1; |
|
14542 |
|
14543 // appending IAP id |
|
14544 |
|
14545 smsg[index++]= '1'; |
|
14546 smsg[index++]= '\0'; |
|
14547 |
|
14548 //appending connmgr_bus |
|
14549 len = strlen(connect_data->connmgr_bus ); |
|
14550 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
14551 index += len + 1; |
|
14552 |
|
14553 //appending connmgr_path |
|
14554 len = strlen(connect_data->connmgr_path ); |
|
14555 strcpy( smsg + index, connect_data->connmgr_path ); |
|
14556 index += len + 1; |
|
14557 |
|
14558 //appending protocol |
|
14559 len = strlen(connect_data->protocol ); |
|
14560 strcpy( smsg + index, connect_data->protocol ); |
|
14561 index += len + 1; |
|
14562 |
|
14563 #ifdef __WINSCW__ |
|
14564 //proxy server |
|
14565 len = strlen(connect_data->proxy_data->proxy_server ); |
|
14566 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
14567 index += len + 1; |
|
14568 |
|
14569 //proxy port |
|
14570 len = strlen(connect_data->proxy_data->proxy_port ); |
|
14571 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
14572 index += len + 1; |
|
14573 |
|
14574 #endif |
|
14575 run_isoserver(); |
|
14576 |
|
14577 //create message queue for send request |
|
14578 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14579 //create message queue for response request |
|
14580 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14581 |
|
14582 |
|
14583 /* Send Message to queueOne */ |
|
14584 |
|
14585 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14586 |
|
14587 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
14588 |
|
14589 if (status < 0) |
|
14590 { |
|
14591 return_value = KErrGeneral; |
|
14592 goto return_code; |
|
14593 } |
|
14594 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
14595 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
14596 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14597 |
|
14598 if( msg_struct->response != 1) |
|
14599 { |
|
14600 return_value = KErrGeneral; |
|
14601 goto return_code; |
|
14602 } |
|
14603 |
|
14604 |
|
14605 // login end |
|
14606 //fetch req.. |
|
14607 for (int i= 0 ;i<3 ;i++) |
|
14608 { |
|
14609 |
|
14610 fp = fopen("c:\\fetch_contact.txt","a"); |
|
14611 do { |
|
14612 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14613 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14614 fwrite(rmsg,1,status,fp); |
|
14615 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14616 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
14617 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
14618 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
14619 fclose(fp); |
|
14620 |
|
14621 } |
|
14622 |
|
14623 //fetch end |
|
14624 |
|
14625 //search messge-------------------------------------------- |
|
14626 |
|
14627 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14628 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14629 index=0; |
|
14630 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14631 msgHdr->message_type = ESearch; |
|
14632 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14633 index += sizeof( message_hdr_req ); |
|
14634 |
|
14635 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14636 do { |
|
14637 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14638 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14639 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14640 } while (msg_struct->hdr_req.message_type!= ESearch ); |
|
14641 |
|
14642 if ( msg_struct->response != 0 ) |
|
14643 { |
|
14644 return_value = KErrGeneral; |
|
14645 goto return_code; |
|
14646 } |
|
14647 |
|
14648 |
|
14649 |
|
14650 //search message end--------------------------------------- |
|
14651 |
|
14652 |
|
14653 // logout test code from server |
|
14654 index=0; |
|
14655 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14656 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14657 |
|
14658 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14659 |
|
14660 msgHdr->message_type = ELogout_Request; |
|
14661 |
|
14662 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14663 index += sizeof( message_hdr_req ); |
|
14664 |
|
14665 |
|
14666 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14667 do { |
|
14668 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14669 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14670 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14671 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
14672 |
|
14673 if ( msg_struct->response != 1) |
|
14674 { |
|
14675 return_value = KErrGeneral; |
|
14676 goto return_code; |
|
14677 } |
|
14678 |
|
14679 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
14680 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
14681 return_value = KErrNone; |
|
14682 goto return_code; |
|
14683 //killing isoserver |
|
14684 return_code: |
|
14685 index=0; |
|
14686 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14687 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14688 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14689 msgHdr->message_type = EKill_Process; |
|
14690 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14691 index += sizeof( message_hdr_req ); |
|
14692 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14693 free( msg_struct ); |
|
14694 return return_value; |
|
14695 |
|
14696 } |
|
14697 Cisolationserver::SearchKeyValueInvalidHashValues( CStifItemParser& aItem ) |
|
14698 { |
|
14699 ConnectData *connect_data = NULL; |
|
14700 char smsg[MAX_MSG_SIZE]; |
|
14701 char rmsg[MAX_MSG_SIZE]; |
|
14702 int index=0; |
|
14703 FILE *fp; |
|
14704 |
|
14705 int timeout = 200; |
|
14706 int nBytes; |
|
14707 TInt return_value = 0; |
|
14708 int result = 0; |
|
14709 int err = 0; |
|
14710 int status = 0; |
|
14711 message_hdr_req *msgHdr = NULL; |
|
14712 message_hdr_resp* msg_struct = NULL; |
|
14713 |
|
14714 // Read data from the CFG file |
|
14715 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
14716 { |
|
14717 iLog->Log ( _L ( "read_data failed" ) ); |
|
14718 free_data ( connect_data ); |
|
14719 return_value = KErrGeneral; |
|
14720 goto return_code; |
|
14721 } |
|
14722 //request formation |
|
14723 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14724 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14725 |
|
14726 //message header use |
|
14727 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
14728 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14729 |
|
14730 msgHdr->message_type = ELogin_Request; |
|
14731 |
|
14732 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14733 index += sizeof( message_hdr_req ); |
|
14734 |
|
14735 int len = strlen(connect_data->username); |
|
14736 strcpy( smsg + index, connect_data->username ); |
|
14737 index += len + 1; |
|
14738 |
|
14739 //appending password |
|
14740 |
|
14741 len = strlen(connect_data->password ); |
|
14742 strcpy( smsg + index, connect_data->password ); |
|
14743 index += len + 1; |
|
14744 |
|
14745 //appending server name |
|
14746 |
|
14747 len = strlen(connect_data->server ); |
|
14748 strcpy( smsg + index, connect_data->server ); |
|
14749 index += len + 1; |
|
14750 |
|
14751 //appending resource |
|
14752 len = strlen(connect_data->resource ); |
|
14753 strcpy( smsg + index, connect_data->resource ); |
|
14754 index += len + 1; |
|
14755 |
|
14756 //appending ssl |
|
14757 smsg[index++]= '0'; |
|
14758 smsg[index++]= '\0'; |
|
14759 |
|
14760 //appending server port |
|
14761 len = strlen(connect_data->port ); |
|
14762 strcpy( smsg + index, connect_data->port ); |
|
14763 index += len + 1; |
|
14764 |
|
14765 // appending IAP id |
|
14766 |
|
14767 smsg[index++]= '1'; |
|
14768 smsg[index++]= '\0'; |
|
14769 |
|
14770 //appending connmgr_bus |
|
14771 len = strlen(connect_data->connmgr_bus ); |
|
14772 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
14773 index += len + 1; |
|
14774 |
|
14775 //appending connmgr_path |
|
14776 len = strlen(connect_data->connmgr_path ); |
|
14777 strcpy( smsg + index, connect_data->connmgr_path ); |
|
14778 index += len + 1; |
|
14779 |
|
14780 //appending protocol |
|
14781 len = strlen(connect_data->protocol ); |
|
14782 strcpy( smsg + index, connect_data->protocol ); |
|
14783 index += len + 1; |
|
14784 |
|
14785 #ifdef __WINSCW__ |
|
14786 //proxy server |
|
14787 len = strlen(connect_data->proxy_data->proxy_server ); |
|
14788 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
14789 index += len + 1; |
|
14790 |
|
14791 //proxy port |
|
14792 len = strlen(connect_data->proxy_data->proxy_port ); |
|
14793 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
14794 index += len + 1; |
|
14795 |
|
14796 #endif |
|
14797 run_isoserver(); |
|
14798 |
|
14799 //create message queue for send request |
|
14800 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14801 //create message queue for response request |
|
14802 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
14803 |
|
14804 |
|
14805 /* Send Message to queueOne */ |
|
14806 |
|
14807 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14808 |
|
14809 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
14810 |
|
14811 if (status < 0) |
|
14812 { |
|
14813 return_value = KErrGeneral; |
|
14814 goto return_code; |
|
14815 } |
|
14816 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
14817 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
14818 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14819 |
|
14820 if( msg_struct->response != 1) |
|
14821 { |
|
14822 return_value = KErrGeneral; |
|
14823 goto return_code; |
|
14824 } |
|
14825 |
|
14826 |
|
14827 // login end |
|
14828 //fetch req.. |
|
14829 for (int i= 0 ;i<3 ;i++) |
|
14830 { |
|
14831 |
|
14832 fp = fopen("c:\\fetch_contact.txt","a"); |
|
14833 do { |
|
14834 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14835 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14836 fwrite(rmsg,1,status,fp); |
|
14837 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14838 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
14839 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
14840 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
14841 fclose(fp); |
|
14842 |
|
14843 } |
|
14844 |
|
14845 //fetch end |
|
14846 |
|
14847 //search messge-------------------------------------------- |
|
14848 |
|
14849 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14850 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14851 index=0; |
|
14852 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14853 msgHdr->message_type = ESearch; |
|
14854 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14855 index += sizeof( message_hdr_req ); |
|
14856 |
|
14857 |
|
14858 // adding key |
|
14859 len = strlen( "firstGname" ); |
|
14860 strcpy( smsg + index, "firstGname" ); |
|
14861 index += len + 1; |
|
14862 |
|
14863 // adding value |
|
14864 len = strlen("I" ); |
|
14865 strcpy( smsg + index, "I" ); |
|
14866 index += len + 1; |
|
14867 |
|
14868 smsg[index++] = '\0'; |
|
14869 |
|
14870 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14871 do { |
|
14872 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14873 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14874 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14875 } while (msg_struct->hdr_req.message_type!= ESearch ); |
|
14876 |
|
14877 if ( msg_struct->response != 0) |
|
14878 { |
|
14879 return_value = KErrGeneral; |
|
14880 goto return_code; |
|
14881 } |
|
14882 |
|
14883 |
|
14884 |
|
14885 //search message end--------------------------------------- |
|
14886 |
|
14887 |
|
14888 // logout test code from server |
|
14889 index=0; |
|
14890 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14891 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14892 |
|
14893 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14894 |
|
14895 msgHdr->message_type = ELogout_Request; |
|
14896 |
|
14897 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14898 index += sizeof( message_hdr_req ); |
|
14899 |
|
14900 |
|
14901 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14902 do { |
|
14903 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
14904 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
14905 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14906 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
14907 |
|
14908 if ( msg_struct->response != 1) |
|
14909 { |
|
14910 return_value = KErrGeneral; |
|
14911 goto return_code; |
|
14912 } |
|
14913 |
|
14914 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
14915 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
14916 return_value = KErrNone; |
|
14917 goto return_code; |
|
14918 |
|
14919 //killing isoserver |
|
14920 return_code: |
|
14921 index=0; |
|
14922 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14923 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14924 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14925 msgHdr->message_type = EKill_Process; |
|
14926 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14927 index += sizeof( message_hdr_req ); |
|
14928 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
14929 free( msg_struct ); |
|
14930 return return_value; |
|
14931 } |
|
14932 |
|
14933 Cisolationserver::SearchKeyValueBlank( CStifItemParser& aItem ) |
|
14934 { |
|
14935 ConnectData *connect_data = NULL; |
|
14936 char smsg[MAX_MSG_SIZE]; |
|
14937 char rmsg[MAX_MSG_SIZE]; |
|
14938 int index=0; |
|
14939 FILE *fp; |
|
14940 |
|
14941 int timeout = 200; |
|
14942 int nBytes; |
|
14943 TInt return_value = 0; |
|
14944 int result = 0; |
|
14945 int err = 0; |
|
14946 int status = 0; |
|
14947 message_hdr_req *msgHdr = NULL; |
|
14948 message_hdr_resp* msg_struct = NULL; |
|
14949 |
|
14950 // Read data from the CFG file |
|
14951 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
14952 { |
|
14953 iLog->Log ( _L ( "read_data failed" ) ); |
|
14954 free_data ( connect_data ); |
|
14955 return_value = KErrGeneral; |
|
14956 goto return_code; |
|
14957 } |
|
14958 //request formation |
|
14959 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
14960 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
14961 |
|
14962 //message header use |
|
14963 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
14964 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
14965 |
|
14966 msgHdr->message_type = ELogin_Request; |
|
14967 |
|
14968 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
14969 index += sizeof( message_hdr_req ); |
|
14970 |
|
14971 int len = strlen(connect_data->username); |
|
14972 strcpy( smsg + index, connect_data->username ); |
|
14973 index += len + 1; |
|
14974 |
|
14975 //appending password |
|
14976 |
|
14977 len = strlen(connect_data->password ); |
|
14978 strcpy( smsg + index, connect_data->password ); |
|
14979 index += len + 1; |
|
14980 |
|
14981 //appending server name |
|
14982 |
|
14983 len = strlen(connect_data->server ); |
|
14984 strcpy( smsg + index, connect_data->server ); |
|
14985 index += len + 1; |
|
14986 |
|
14987 //appending resource |
|
14988 len = strlen(connect_data->resource ); |
|
14989 strcpy( smsg + index, connect_data->resource ); |
|
14990 index += len + 1; |
|
14991 |
|
14992 //appending ssl |
|
14993 smsg[index++]= '0'; |
|
14994 smsg[index++]= '\0'; |
|
14995 |
|
14996 //appending server port |
|
14997 len = strlen(connect_data->port ); |
|
14998 strcpy( smsg + index, connect_data->port ); |
|
14999 index += len + 1; |
|
15000 |
|
15001 // appending IAP id |
|
15002 |
|
15003 smsg[index++]= '1'; |
|
15004 smsg[index++]= '\0'; |
|
15005 |
|
15006 //appending connmgr_bus |
|
15007 len = strlen(connect_data->connmgr_bus ); |
|
15008 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
15009 index += len + 1; |
|
15010 |
|
15011 //appending connmgr_path |
|
15012 len = strlen(connect_data->connmgr_path ); |
|
15013 strcpy( smsg + index, connect_data->connmgr_path ); |
|
15014 index += len + 1; |
|
15015 |
|
15016 //appending protocol |
|
15017 len = strlen(connect_data->protocol ); |
|
15018 strcpy( smsg + index, connect_data->protocol ); |
|
15019 index += len + 1; |
|
15020 |
|
15021 #ifdef __WINSCW__ |
|
15022 //proxy server |
|
15023 len = strlen(connect_data->proxy_data->proxy_server ); |
|
15024 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
15025 index += len + 1; |
|
15026 |
|
15027 //proxy port |
|
15028 len = strlen(connect_data->proxy_data->proxy_port ); |
|
15029 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
15030 index += len + 1; |
|
15031 |
|
15032 #endif |
|
15033 run_isoserver(); |
|
15034 |
|
15035 //create message queue for send request |
|
15036 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15037 //create message queue for response request |
|
15038 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15039 |
|
15040 |
|
15041 /* Send Message to queueOne */ |
|
15042 |
|
15043 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15044 |
|
15045 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
15046 |
|
15047 if (status < 0) |
|
15048 { |
|
15049 return_value = KErrGeneral; |
|
15050 goto return_code; |
|
15051 } |
|
15052 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
15053 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
15054 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15055 |
|
15056 if( msg_struct->response != 1) |
|
15057 { |
|
15058 return_value = KErrGeneral; |
|
15059 goto return_code; |
|
15060 } |
|
15061 |
|
15062 |
|
15063 // login end |
|
15064 //fetch req.. |
|
15065 for (int i= 0 ;i<3 ;i++) |
|
15066 { |
|
15067 |
|
15068 fp = fopen("c:\\fetch_contact.txt","a"); |
|
15069 do { |
|
15070 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15071 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15072 fwrite(rmsg,1,status,fp); |
|
15073 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15074 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
15075 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
15076 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
15077 fclose(fp); |
|
15078 |
|
15079 } |
|
15080 |
|
15081 //fetch end |
|
15082 |
|
15083 //search messge-------------------------------------------- |
|
15084 |
|
15085 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15086 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15087 index=0; |
|
15088 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15089 msgHdr->message_type = ESearch; |
|
15090 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15091 index += sizeof( message_hdr_req ); |
|
15092 |
|
15093 |
|
15094 // adding key |
|
15095 len = strlen( connect_data->key_jid ); |
|
15096 strcpy( smsg + index, connect_data->key_jid ); |
|
15097 index += len + 1; |
|
15098 |
|
15099 // adding value |
|
15100 len = strlen("" ); |
|
15101 strcpy( smsg + index, "" ); |
|
15102 index += len + 1; |
|
15103 |
|
15104 smsg[index++] = '\0'; |
|
15105 |
|
15106 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15107 do { |
|
15108 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15109 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15110 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15111 } while (msg_struct->hdr_req.message_type!= ESearch ); |
|
15112 |
|
15113 |
|
15114 if( msg_struct->error_type != INVALID_PARAMETERES ) |
|
15115 { |
|
15116 return_value = KErrGeneral; |
|
15117 goto return_code; |
|
15118 } |
|
15119 |
|
15120 |
|
15121 |
|
15122 |
|
15123 //search message end--------------------------------------- |
|
15124 |
|
15125 |
|
15126 // logout test code from server |
|
15127 index=0; |
|
15128 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15129 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15130 |
|
15131 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15132 |
|
15133 msgHdr->message_type = ELogout_Request; |
|
15134 |
|
15135 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15136 index += sizeof( message_hdr_req ); |
|
15137 |
|
15138 |
|
15139 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15140 do { |
|
15141 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15142 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15143 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15144 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
15145 |
|
15146 if ( msg_struct->response != 1) |
|
15147 { |
|
15148 return_value = KErrGeneral; |
|
15149 goto return_code; |
|
15150 } |
|
15151 |
|
15152 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
15153 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
15154 return_value = KErrNone; |
|
15155 goto return_code; |
|
15156 |
|
15157 //killing isoserver |
|
15158 return_code: |
|
15159 index=0; |
|
15160 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15161 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15162 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15163 msgHdr->message_type = EKill_Process; |
|
15164 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15165 index += sizeof( message_hdr_req ); |
|
15166 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15167 free( msg_struct ); |
|
15168 return return_value; |
|
15169 } |
|
15170 |
|
15171 Cisolationserver::SearchKeyValueLargeString( CStifItemParser& aItem ) |
|
15172 { |
|
15173 ConnectData *connect_data = NULL; |
|
15174 char smsg[MAX_MSG_SIZE]; |
|
15175 char rmsg[MAX_MSG_SIZE]; |
|
15176 int index=0; |
|
15177 FILE *fp; |
|
15178 |
|
15179 int timeout = 200; |
|
15180 int nBytes; |
|
15181 TInt return_value = 0; |
|
15182 int result = 0; |
|
15183 int err = 0; |
|
15184 int status = 0; |
|
15185 message_hdr_req *msgHdr = NULL; |
|
15186 message_hdr_resp* msg_struct = NULL; |
|
15187 |
|
15188 // Read data from the CFG file |
|
15189 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
15190 { |
|
15191 iLog->Log ( _L ( "read_data failed" ) ); |
|
15192 free_data ( connect_data ); |
|
15193 return_value = KErrGeneral; |
|
15194 goto return_code; |
|
15195 } |
|
15196 //request formation |
|
15197 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15198 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15199 |
|
15200 //message header use |
|
15201 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
15202 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15203 |
|
15204 msgHdr->message_type = ELogin_Request; |
|
15205 |
|
15206 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15207 index += sizeof( message_hdr_req ); |
|
15208 |
|
15209 int len = strlen(connect_data->username); |
|
15210 strcpy( smsg + index, connect_data->username ); |
|
15211 index += len + 1; |
|
15212 |
|
15213 //appending password |
|
15214 |
|
15215 len = strlen(connect_data->password ); |
|
15216 strcpy( smsg + index, connect_data->password ); |
|
15217 index += len + 1; |
|
15218 |
|
15219 //appending server name |
|
15220 |
|
15221 len = strlen(connect_data->server ); |
|
15222 strcpy( smsg + index, connect_data->server ); |
|
15223 index += len + 1; |
|
15224 |
|
15225 //appending resource |
|
15226 len = strlen(connect_data->resource ); |
|
15227 strcpy( smsg + index, connect_data->resource ); |
|
15228 index += len + 1; |
|
15229 |
|
15230 //appending ssl |
|
15231 smsg[index++]= '0'; |
|
15232 smsg[index++]= '\0'; |
|
15233 |
|
15234 //appending server port |
|
15235 len = strlen(connect_data->port ); |
|
15236 strcpy( smsg + index, connect_data->port ); |
|
15237 index += len + 1; |
|
15238 |
|
15239 // appending IAP id |
|
15240 |
|
15241 smsg[index++]= '1'; |
|
15242 smsg[index++]= '\0'; |
|
15243 |
|
15244 //appending connmgr_bus |
|
15245 len = strlen(connect_data->connmgr_bus ); |
|
15246 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
15247 index += len + 1; |
|
15248 |
|
15249 //appending connmgr_path |
|
15250 len = strlen(connect_data->connmgr_path ); |
|
15251 strcpy( smsg + index, connect_data->connmgr_path ); |
|
15252 index += len + 1; |
|
15253 |
|
15254 //appending protocol |
|
15255 len = strlen(connect_data->protocol ); |
|
15256 strcpy( smsg + index, connect_data->protocol ); |
|
15257 index += len + 1; |
|
15258 |
|
15259 #ifdef __WINSCW__ |
|
15260 //proxy server |
|
15261 len = strlen(connect_data->proxy_data->proxy_server ); |
|
15262 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
15263 index += len + 1; |
|
15264 |
|
15265 //proxy port |
|
15266 len = strlen(connect_data->proxy_data->proxy_port ); |
|
15267 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
15268 index += len + 1; |
|
15269 |
|
15270 #endif |
|
15271 run_isoserver(); |
|
15272 |
|
15273 //create message queue for send request |
|
15274 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15275 //create message queue for response request |
|
15276 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15277 |
|
15278 |
|
15279 /* Send Message to queueOne */ |
|
15280 |
|
15281 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15282 |
|
15283 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
15284 |
|
15285 if (status < 0) |
|
15286 { |
|
15287 return_value = KErrGeneral; |
|
15288 goto return_code; |
|
15289 } |
|
15290 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
15291 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
15292 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15293 |
|
15294 if( msg_struct->response != 1) |
|
15295 { |
|
15296 return_value = KErrGeneral; |
|
15297 goto return_code; |
|
15298 } |
|
15299 |
|
15300 |
|
15301 // login end |
|
15302 //fetch req.. |
|
15303 for (int i= 0 ;i<3 ;i++) |
|
15304 { |
|
15305 |
|
15306 fp = fopen("c:\\fetch_contact.txt","a"); |
|
15307 do { |
|
15308 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15309 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15310 fwrite(rmsg,1,status,fp); |
|
15311 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15312 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
15313 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
15314 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
15315 fclose(fp); |
|
15316 |
|
15317 } |
|
15318 |
|
15319 //fetch end |
|
15320 |
|
15321 //search messge-------------------------------------------- |
|
15322 |
|
15323 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15324 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15325 index=0; |
|
15326 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15327 msgHdr->message_type = ESearch; |
|
15328 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15329 index += sizeof( message_hdr_req ); |
|
15330 |
|
15331 |
|
15332 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
15333 // adding key |
|
15334 len = strlen(search_label); |
|
15335 strcpy( smsg + index, search_label ); |
|
15336 index += len + 1; |
|
15337 |
|
15338 // adding value |
|
15339 len = strlen( "Gmail is a new kind of webmail built on \ |
|
15340 the idea that email can be more intuitive efficient and useful" ); |
|
15341 |
|
15342 strcpy( smsg + index, "Gmail is a new kind of webmail built on \ |
|
15343 the idea that email can be more intuitive efficient and useful" ); |
|
15344 index += len + 1; |
|
15345 |
|
15346 smsg[index++] = '\0'; |
|
15347 |
|
15348 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15349 do { |
|
15350 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15351 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15352 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15353 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
15354 |
|
15355 if ( msg_struct->response != 1) |
|
15356 { |
|
15357 return_value = KErrGeneral; |
|
15358 goto return_code; |
|
15359 } |
|
15360 |
|
15361 |
|
15362 |
|
15363 //search message end--------------------------------------- |
|
15364 |
|
15365 |
|
15366 // logout test code from server |
|
15367 index=0; |
|
15368 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15369 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15370 |
|
15371 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15372 |
|
15373 msgHdr->message_type = ELogout_Request; |
|
15374 |
|
15375 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15376 index += sizeof( message_hdr_req ); |
|
15377 |
|
15378 |
|
15379 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15380 do { |
|
15381 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15382 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15383 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15384 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
15385 |
|
15386 if ( msg_struct->response != 1) |
|
15387 { |
|
15388 return_value = KErrGeneral; |
|
15389 goto return_code; |
|
15390 } |
|
15391 |
|
15392 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
15393 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
15394 return_value = KErrNone; |
|
15395 goto return_code; |
|
15396 |
|
15397 //killing isoserver |
|
15398 return_code: |
|
15399 index=0; |
|
15400 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15401 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15402 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15403 msgHdr->message_type = EKill_Process; |
|
15404 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15405 index += sizeof( message_hdr_req ); |
|
15406 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15407 free( msg_struct ); |
|
15408 return return_value; |
|
15409 } |
|
15410 |
|
15411 Cisolationserver::SearchKeyValueSpecialChar( CStifItemParser& aItem ) |
|
15412 { |
|
15413 ConnectData *connect_data = NULL; |
|
15414 char smsg[MAX_MSG_SIZE]; |
|
15415 char rmsg[MAX_MSG_SIZE]; |
|
15416 int index=0; |
|
15417 FILE *fp; |
|
15418 |
|
15419 int timeout = 200; |
|
15420 int nBytes; |
|
15421 TInt return_value = 0; |
|
15422 int result = 0; |
|
15423 int err = 0; |
|
15424 int status = 0; |
|
15425 message_hdr_req *msgHdr = NULL; |
|
15426 message_hdr_resp* msg_struct = NULL; |
|
15427 |
|
15428 // Read data from the CFG file |
|
15429 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
15430 { |
|
15431 iLog->Log ( _L ( "read_data failed" ) ); |
|
15432 free_data ( connect_data ); |
|
15433 return_value = KErrGeneral; |
|
15434 goto return_code; |
|
15435 } |
|
15436 //request formation |
|
15437 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15438 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15439 |
|
15440 //message header use |
|
15441 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
15442 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15443 |
|
15444 msgHdr->message_type = ELogin_Request; |
|
15445 |
|
15446 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15447 index += sizeof( message_hdr_req ); |
|
15448 |
|
15449 int len = strlen(connect_data->username); |
|
15450 strcpy( smsg + index, connect_data->username ); |
|
15451 index += len + 1; |
|
15452 |
|
15453 //appending password |
|
15454 |
|
15455 len = strlen(connect_data->password ); |
|
15456 strcpy( smsg + index, connect_data->password ); |
|
15457 index += len + 1; |
|
15458 |
|
15459 //appending server name |
|
15460 |
|
15461 len = strlen(connect_data->server ); |
|
15462 strcpy( smsg + index, connect_data->server ); |
|
15463 index += len + 1; |
|
15464 |
|
15465 //appending resource |
|
15466 len = strlen(connect_data->resource ); |
|
15467 strcpy( smsg + index, connect_data->resource ); |
|
15468 index += len + 1; |
|
15469 |
|
15470 //appending ssl |
|
15471 smsg[index++]= '0'; |
|
15472 smsg[index++]= '\0'; |
|
15473 |
|
15474 //appending server port |
|
15475 len = strlen(connect_data->port ); |
|
15476 strcpy( smsg + index, connect_data->port ); |
|
15477 index += len + 1; |
|
15478 |
|
15479 // appending IAP id |
|
15480 |
|
15481 smsg[index++]= '1'; |
|
15482 smsg[index++]= '\0'; |
|
15483 |
|
15484 //appending connmgr_bus |
|
15485 len = strlen(connect_data->connmgr_bus ); |
|
15486 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
15487 index += len + 1; |
|
15488 |
|
15489 //appending connmgr_path |
|
15490 len = strlen(connect_data->connmgr_path ); |
|
15491 strcpy( smsg + index, connect_data->connmgr_path ); |
|
15492 index += len + 1; |
|
15493 |
|
15494 //appending protocol |
|
15495 len = strlen(connect_data->protocol ); |
|
15496 strcpy( smsg + index, connect_data->protocol ); |
|
15497 index += len + 1; |
|
15498 |
|
15499 #ifdef __WINSCW__ |
|
15500 //proxy server |
|
15501 len = strlen(connect_data->proxy_data->proxy_server ); |
|
15502 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
15503 index += len + 1; |
|
15504 |
|
15505 //proxy port |
|
15506 len = strlen(connect_data->proxy_data->proxy_port ); |
|
15507 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
15508 index += len + 1; |
|
15509 |
|
15510 #endif |
|
15511 run_isoserver(); |
|
15512 |
|
15513 //create message queue for send request |
|
15514 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15515 //create message queue for response request |
|
15516 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15517 |
|
15518 |
|
15519 /* Send Message to queueOne */ |
|
15520 |
|
15521 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15522 |
|
15523 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
15524 |
|
15525 if (status < 0) |
|
15526 { |
|
15527 return_value = KErrGeneral; |
|
15528 goto return_code; |
|
15529 } |
|
15530 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
15531 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
15532 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15533 |
|
15534 if( msg_struct->response != 1) |
|
15535 { |
|
15536 return_value = KErrGeneral; |
|
15537 goto return_code; |
|
15538 } |
|
15539 |
|
15540 |
|
15541 // login end |
|
15542 //fetch req.. |
|
15543 for (int i= 0 ;i<3 ;i++) |
|
15544 { |
|
15545 |
|
15546 fp = fopen("c:\\fetch_contact.txt","a"); |
|
15547 do { |
|
15548 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15549 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15550 fwrite(rmsg,1,status,fp); |
|
15551 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15552 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
15553 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
15554 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
15555 fclose(fp); |
|
15556 |
|
15557 } |
|
15558 |
|
15559 //fetch end |
|
15560 |
|
15561 //search messge-------------------------------------------- |
|
15562 |
|
15563 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15564 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15565 index=0; |
|
15566 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15567 msgHdr->message_type = ESearch; |
|
15568 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15569 index += sizeof( message_hdr_req ); |
|
15570 |
|
15571 |
|
15572 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
15573 // adding key |
|
15574 len = strlen(search_label); |
|
15575 strcpy( smsg + index, search_label ); |
|
15576 index += len + 1; |
|
15577 |
|
15578 // adding value |
|
15579 len = strlen("happy_123@chat.gizmoproject.com" ); |
|
15580 strcpy( smsg + index, "happy_123@chat.gizmoproject.com" ); |
|
15581 index += len + 1; |
|
15582 |
|
15583 smsg[index++] = '\0'; |
|
15584 |
|
15585 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15586 do { |
|
15587 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15588 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15589 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15590 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
15591 |
|
15592 if ( msg_struct->response != 1) |
|
15593 { |
|
15594 return_value = KErrGeneral; |
|
15595 goto return_code; |
|
15596 } |
|
15597 |
|
15598 |
|
15599 |
|
15600 //search message end--------------------------------------- |
|
15601 |
|
15602 |
|
15603 // logout test code from server |
|
15604 index=0; |
|
15605 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15606 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15607 |
|
15608 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15609 |
|
15610 msgHdr->message_type = ELogout_Request; |
|
15611 |
|
15612 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15613 index += sizeof( message_hdr_req ); |
|
15614 |
|
15615 |
|
15616 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15617 do { |
|
15618 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15619 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15620 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15621 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
15622 |
|
15623 if ( msg_struct->response != 1) |
|
15624 { |
|
15625 return_value = KErrGeneral; |
|
15626 goto return_code; |
|
15627 } |
|
15628 |
|
15629 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
15630 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
15631 return_value = KErrNone; |
|
15632 goto return_code; |
|
15633 |
|
15634 //killing isoserver |
|
15635 return_code: |
|
15636 index=0; |
|
15637 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15638 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15639 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15640 msgHdr->message_type = EKill_Process; |
|
15641 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15642 index += sizeof( message_hdr_req ); |
|
15643 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15644 free( msg_struct ); |
|
15645 return return_value; |
|
15646 } |
|
15647 |
|
15648 // ----------------------------------------------------------------------------- |
|
15649 // Cisolationserver::RejectAddRequestFromUser |
|
15650 // Example test method function. |
|
15651 // (other items were commented in a header). |
|
15652 // ----------------------------------------------------------------------------- |
|
15653 //RejectAddRequestFromUser |
|
15654 TInt Cisolationserver::RejectAddRequestFromUser( CStifItemParser& aItem ) |
|
15655 { |
|
15656 |
|
15657 |
|
15658 ConnectData *connect_data = NULL; |
|
15659 char smsg[MAX_MSG_SIZE]; |
|
15660 char rmsg[MAX_MSG_SIZE]; |
|
15661 int index=0; |
|
15662 |
|
15663 |
|
15664 int timeout = 100; |
|
15665 int nBytes; |
|
15666 |
|
15667 int result = 0; |
|
15668 int err = 0; |
|
15669 int status = 0; |
|
15670 FILE *fp; |
|
15671 message_hdr_req *msgHdr = NULL; |
|
15672 message_hdr_resp* msg_struct = NULL; |
|
15673 TInt return_value = 0; |
|
15674 // Read data from the CFG file |
|
15675 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
15676 { |
|
15677 iLog->Log ( _L ( "read_data failed" ) ); |
|
15678 free_data ( connect_data ); |
|
15679 return_value = KErrGeneral; |
|
15680 goto return_code; |
|
15681 } |
|
15682 //request formation |
|
15683 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15684 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15685 |
|
15686 //message header use |
|
15687 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
15688 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15689 |
|
15690 msgHdr->message_type = ELogin_Request; |
|
15691 |
|
15692 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15693 index += sizeof( message_hdr_req ); |
|
15694 |
|
15695 int len = strlen(connect_data->username); |
|
15696 strcpy( smsg + index, connect_data->username ); |
|
15697 index += len + 1; |
|
15698 |
|
15699 //appending password |
|
15700 |
|
15701 len = strlen(connect_data->password ); |
|
15702 strcpy( smsg + index, connect_data->password ); |
|
15703 index += len + 1; |
|
15704 |
|
15705 //appending server name |
|
15706 |
|
15707 len = strlen(connect_data->server ); |
|
15708 strcpy( smsg + index, connect_data->server ); |
|
15709 index += len + 1; |
|
15710 |
|
15711 //appending resource |
|
15712 len = strlen(connect_data->resource ); |
|
15713 strcpy( smsg + index, connect_data->resource ); |
|
15714 index += len + 1; |
|
15715 |
|
15716 //appending ssl |
|
15717 smsg[index++]= '1'; |
|
15718 smsg[index++]= '\0'; |
|
15719 |
|
15720 //appending server port |
|
15721 len = strlen(connect_data->port ); |
|
15722 strcpy( smsg + index, connect_data->port ); |
|
15723 index += len + 1; |
|
15724 |
|
15725 // appending IAP id |
|
15726 |
|
15727 smsg[index++]= '1'; |
|
15728 smsg[index++]= '\0'; |
|
15729 |
|
15730 //appending connmgr_bus |
|
15731 len = strlen(connect_data->connmgr_bus ); |
|
15732 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
15733 index += len + 1; |
|
15734 |
|
15735 //appending connmgr_path |
|
15736 len = strlen(connect_data->connmgr_path ); |
|
15737 strcpy( smsg + index, connect_data->connmgr_path ); |
|
15738 index += len + 1; |
|
15739 |
|
15740 //appending protocol |
|
15741 len = strlen(connect_data->protocol ); |
|
15742 strcpy( smsg + index, connect_data->protocol ); |
|
15743 index += len + 1; |
|
15744 |
|
15745 #ifdef __WINSCW__ |
|
15746 //proxy server |
|
15747 len = strlen(connect_data->proxy_data->proxy_server ); |
|
15748 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
15749 index += len + 1; |
|
15750 |
|
15751 //proxy port |
|
15752 len = strlen(connect_data->proxy_data->proxy_port ); |
|
15753 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
15754 index += len + 1; |
|
15755 |
|
15756 #endif |
|
15757 //running isoserver |
|
15758 run_isoserver(); |
|
15759 //create message queue for send request |
|
15760 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15761 //create message queue for response request |
|
15762 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
15763 |
|
15764 |
|
15765 /* Send Message to queueOne */ |
|
15766 |
|
15767 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15768 |
|
15769 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
15770 |
|
15771 if (status < 0) |
|
15772 { |
|
15773 return_value = KErrGeneral; |
|
15774 goto return_code; |
|
15775 } |
|
15776 |
|
15777 |
|
15778 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
15779 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
15780 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15781 |
|
15782 if( msg_struct->response != 1) |
|
15783 { |
|
15784 return_value = KErrGeneral; |
|
15785 goto return_code; |
|
15786 } |
|
15787 |
|
15788 |
|
15789 // login end |
|
15790 //fetch req.. |
|
15791 for (int i= 0 ;i<3 ;i++) |
|
15792 { |
|
15793 |
|
15794 fp = fopen("c:\\fetch_contact.txt","a"); |
|
15795 do { |
|
15796 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15797 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15798 fwrite(rmsg,1,status,fp); |
|
15799 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15800 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
15801 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
15802 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
15803 fclose(fp); |
|
15804 |
|
15805 } |
|
15806 |
|
15807 //fetch end |
|
15808 //fetch end |
|
15809 // getting add notification from user |
|
15810 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15811 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15812 index=0; |
|
15813 |
|
15814 do { |
|
15815 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15816 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15817 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15818 // memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15819 } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish); |
|
15820 |
|
15821 if ( msg_struct->response != 1) |
|
15822 { |
|
15823 return_value = KErrGeneral; |
|
15824 goto return_code; |
|
15825 } |
|
15826 char *userid = (char *)malloc(100); |
|
15827 len=0; |
|
15828 len+=sizeof(message_hdr_resp); |
|
15829 strcpy(userid,rmsg+len); |
|
15830 |
|
15831 |
|
15832 |
|
15833 |
|
15834 // rejecting add request from user |
|
15835 |
|
15836 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15837 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15838 index=0; |
|
15839 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15840 msgHdr->message_type = EReject_Contact_Request; |
|
15841 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15842 index += sizeof( message_hdr_req ); |
|
15843 len=0; |
|
15844 len+=strlen(userid); |
|
15845 strcpy( smsg + index ,userid ); |
|
15846 index += len + 1; |
|
15847 |
|
15848 |
|
15849 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15850 |
|
15851 do { |
|
15852 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15853 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15854 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15855 } while (msg_struct->hdr_req.message_type!=EReject_Contact_Request); |
|
15856 |
|
15857 if ( msg_struct->response != 1) |
|
15858 { |
|
15859 return_value = KErrGeneral; |
|
15860 goto return_code; |
|
15861 } |
|
15862 |
|
15863 // logout test code from server |
|
15864 index=0; |
|
15865 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15866 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15867 |
|
15868 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15869 |
|
15870 msgHdr->message_type = ELogout_Request; |
|
15871 |
|
15872 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15873 index += sizeof( message_hdr_req ); |
|
15874 |
|
15875 |
|
15876 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15877 |
|
15878 do { |
|
15879 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
15880 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
15881 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15882 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
15883 |
|
15884 if ( msg_struct->response != 1) |
|
15885 { |
|
15886 return_value = KErrGeneral; |
|
15887 goto return_code; |
|
15888 } |
|
15889 //killing isoserver |
|
15890 return_code: |
|
15891 index=0; |
|
15892 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15893 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15894 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15895 msgHdr->message_type = EKill_Process; |
|
15896 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15897 index += sizeof( message_hdr_req ); |
|
15898 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
15899 free( msg_struct ); |
|
15900 return return_value; |
|
15901 } |
|
15902 |
|
15903 // ----------------------------------------------------------------------------- |
|
15904 // Cisolationserver::AcceptAddRequestFromUser |
|
15905 // Example test method function. |
|
15906 // (other items were commented in a header). |
|
15907 // ----------------------------------------------------------------------------- |
|
15908 // |
|
15909 Cisolationserver::SearchAndAddContact( CStifItemParser& aItem ) |
|
15910 { |
|
15911 |
|
15912 ConnectData *connect_data = NULL; |
|
15913 char smsg[MAX_MSG_SIZE]; |
|
15914 char rmsg[MAX_MSG_SIZE]; |
|
15915 int index=0; |
|
15916 FILE *fp; |
|
15917 |
|
15918 int timeout = 200; |
|
15919 int nBytes; |
|
15920 TInt return_value = 0; |
|
15921 int result = 0; |
|
15922 int err = 0; |
|
15923 int status = 0; |
|
15924 message_hdr_req *msgHdr = NULL; |
|
15925 message_hdr_resp* msg_struct = NULL; |
|
15926 |
|
15927 // Read data from the CFG file |
|
15928 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
15929 { |
|
15930 iLog->Log ( _L ( "read_data failed" ) ); |
|
15931 free_data ( connect_data ); |
|
15932 return_value = KErrGeneral; |
|
15933 goto return_code; |
|
15934 } |
|
15935 //request formation |
|
15936 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
15937 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
15938 |
|
15939 //message header use |
|
15940 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
15941 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
15942 |
|
15943 msgHdr->message_type = ELogin_Request; |
|
15944 |
|
15945 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
15946 index += sizeof( message_hdr_req ); |
|
15947 |
|
15948 int len = strlen(connect_data->username); |
|
15949 strcpy( smsg + index, connect_data->username ); |
|
15950 index += len + 1; |
|
15951 |
|
15952 //appending password |
|
15953 |
|
15954 len = strlen(connect_data->password ); |
|
15955 strcpy( smsg + index, connect_data->password ); |
|
15956 index += len + 1; |
|
15957 |
|
15958 //appending server name |
|
15959 |
|
15960 len = strlen(connect_data->server ); |
|
15961 strcpy( smsg + index, connect_data->server ); |
|
15962 index += len + 1; |
|
15963 |
|
15964 //appending resource |
|
15965 len = strlen(connect_data->resource ); |
|
15966 strcpy( smsg + index, connect_data->resource ); |
|
15967 index += len + 1; |
|
15968 |
|
15969 //appending ssl |
|
15970 smsg[index++]= '0'; |
|
15971 smsg[index++]= '\0'; |
|
15972 |
|
15973 //appending server port |
|
15974 len = strlen(connect_data->port ); |
|
15975 strcpy( smsg + index, connect_data->port ); |
|
15976 index += len + 1; |
|
15977 |
|
15978 // appending IAP id |
|
15979 |
|
15980 smsg[index++]= '1'; |
|
15981 smsg[index++]= '\0'; |
|
15982 |
|
15983 //appending connmgr_bus |
|
15984 len = strlen(connect_data->connmgr_bus ); |
|
15985 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
15986 index += len + 1; |
|
15987 |
|
15988 //appending connmgr_path |
|
15989 len = strlen(connect_data->connmgr_path ); |
|
15990 strcpy( smsg + index, connect_data->connmgr_path ); |
|
15991 index += len + 1; |
|
15992 |
|
15993 //appending protocol |
|
15994 len = strlen(connect_data->protocol ); |
|
15995 strcpy( smsg + index, connect_data->protocol ); |
|
15996 index += len + 1; |
|
15997 |
|
15998 #ifdef __WINSCW__ |
|
15999 //proxy server |
|
16000 len = strlen(connect_data->proxy_data->proxy_server ); |
|
16001 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
16002 index += len + 1; |
|
16003 |
|
16004 //proxy port |
|
16005 len = strlen(connect_data->proxy_data->proxy_port ); |
|
16006 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
16007 index += len + 1; |
|
16008 |
|
16009 #endif |
|
16010 run_isoserver(); |
|
16011 |
|
16012 //create message queue for send request |
|
16013 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16014 //create message queue for response request |
|
16015 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16016 |
|
16017 |
|
16018 /* Send Message to queueOne */ |
|
16019 |
|
16020 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16021 |
|
16022 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
16023 |
|
16024 if (status < 0) |
|
16025 { |
|
16026 return_value = KErrGeneral; |
|
16027 goto return_code; |
|
16028 } |
|
16029 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
16030 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
16031 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16032 |
|
16033 if( msg_struct->response != 1) |
|
16034 { |
|
16035 return_value = KErrGeneral; |
|
16036 goto return_code; |
|
16037 } |
|
16038 |
|
16039 |
|
16040 // login end |
|
16041 //fetch req.. |
|
16042 for (int i= 0 ;i<3 ;i++) |
|
16043 { |
|
16044 |
|
16045 fp = fopen("c:\\fetch_contact.txt","a"); |
|
16046 do { |
|
16047 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16048 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16049 fwrite(rmsg,1,status,fp); |
|
16050 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16051 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
16052 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
16053 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
16054 fclose(fp); |
|
16055 |
|
16056 } |
|
16057 |
|
16058 //fetch end |
|
16059 |
|
16060 //search messge-------------------------------------------- |
|
16061 |
|
16062 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16063 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16064 index=0; |
|
16065 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16066 msgHdr->message_type = ESearch; |
|
16067 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16068 index += sizeof( message_hdr_req ); |
|
16069 |
|
16070 |
|
16071 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
16072 // adding key |
|
16073 len = strlen(search_label); |
|
16074 strcpy( smsg + index, search_label ); |
|
16075 index += len + 1; |
|
16076 |
|
16077 // adding value |
|
16078 len = strlen("rakesh" ); |
|
16079 strcpy( smsg + index, "rakesh" ); |
|
16080 index += len + 1; |
|
16081 |
|
16082 smsg[index++] = '\0'; |
|
16083 |
|
16084 gint temp = 0; |
|
16085 gchar* add_contact = NULL; |
|
16086 |
|
16087 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16088 do |
|
16089 { |
|
16090 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16091 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16092 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16093 //To add contact only once for the first time |
|
16094 if ( 0 == temp && ESearch == msg_struct->hdr_req.message_type ) |
|
16095 { |
|
16096 // length will point to the start of the contact to be added |
|
16097 int length = 0; |
|
16098 length += sizeof( message_hdr_resp ); |
|
16099 |
|
16100 while ( 0 != strcmp( "jid", rmsg + length ) |
|
16101 && '\0' != *( rmsg + length + 1) ) |
|
16102 { |
|
16103 length += strlen( rmsg + length ) + 1; |
|
16104 gchar* add_contact = rmsg + length; |
|
16105 } |
|
16106 length += strlen( rmsg + length ) + 1; |
|
16107 |
|
16108 add_contact = strdup( rmsg + length ); |
|
16109 //add contact end--------------------------------------- |
|
16110 temp++; |
|
16111 } |
|
16112 |
|
16113 |
|
16114 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
16115 |
|
16116 if ( msg_struct->response != 1 ) |
|
16117 { |
|
16118 return_value = KErrGeneral; |
|
16119 goto return_code; |
|
16120 } |
|
16121 |
|
16122 //search message end--------------------------------------- |
|
16123 |
|
16124 //adding contact -------------------------------------------- |
|
16125 |
|
16126 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16127 index=0; |
|
16128 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16129 msgHdr->message_type = EAdd_Contact_Request; |
|
16130 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16131 index += sizeof( message_hdr_req ); |
|
16132 // adding add contact |
|
16133 len = strlen( add_contact ); |
|
16134 strcpy( smsg + index, add_contact ); |
|
16135 index += len + 1; |
|
16136 smsg[index++]='\0'; |
|
16137 |
|
16138 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16139 do { |
|
16140 |
|
16141 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16142 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16143 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16144 |
|
16145 } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request); |
|
16146 |
|
16147 if ( msg_struct->response != 1 ) |
|
16148 { |
|
16149 return_value = KErrGeneral; |
|
16150 goto return_code; |
|
16151 } |
|
16152 |
|
16153 |
|
16154 // logout test code from server |
|
16155 index=0; |
|
16156 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16157 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16158 |
|
16159 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16160 |
|
16161 msgHdr->message_type = ELogout_Request; |
|
16162 |
|
16163 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16164 index += sizeof( message_hdr_req ); |
|
16165 |
|
16166 |
|
16167 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16168 do { |
|
16169 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16170 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16171 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16172 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
16173 |
|
16174 if ( msg_struct->response != 1) |
|
16175 { |
|
16176 return_value = KErrGeneral; |
|
16177 goto return_code; |
|
16178 } |
|
16179 |
|
16180 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
16181 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
16182 return_value = KErrNone; |
|
16183 goto return_code; |
|
16184 |
|
16185 //killing isoserver |
|
16186 return_code: |
|
16187 index=0; |
|
16188 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16189 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16190 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16191 msgHdr->message_type = EKill_Process; |
|
16192 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16193 index += sizeof( message_hdr_req ); |
|
16194 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16195 free( msg_struct ); |
|
16196 return return_value; |
|
16197 } |
|
16198 |
|
16199 // ----------------------------------------------------------------------------- |
|
16200 // Cisolationserver::AcceptAddRequestFromUser |
|
16201 // Example test method function. |
|
16202 // (other items were commented in a header). |
|
16203 // ----------------------------------------------------------------------------- |
|
16204 // |
|
16205 Cisolationserver::SecondSearch( CStifItemParser& aItem ) |
|
16206 { |
|
16207 |
|
16208 ConnectData *connect_data = NULL; |
|
16209 char smsg[MAX_MSG_SIZE]; |
|
16210 char rmsg[MAX_MSG_SIZE]; |
|
16211 int index=0; |
|
16212 FILE *fp; |
|
16213 |
|
16214 int timeout = 200; |
|
16215 int nBytes; |
|
16216 TInt return_value = 0; |
|
16217 int result = 0; |
|
16218 int err = 0; |
|
16219 int status = 0; |
|
16220 message_hdr_req *msgHdr = NULL; |
|
16221 message_hdr_resp* msg_struct = NULL; |
|
16222 |
|
16223 // Read data from the CFG file |
|
16224 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
16225 { |
|
16226 iLog->Log ( _L ( "read_data failed" ) ); |
|
16227 free_data ( connect_data ); |
|
16228 return_value = KErrGeneral; |
|
16229 goto return_code; |
|
16230 } |
|
16231 //request formation |
|
16232 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16233 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16234 |
|
16235 //message header use |
|
16236 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
16237 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16238 |
|
16239 msgHdr->message_type = ELogin_Request; |
|
16240 |
|
16241 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16242 index += sizeof( message_hdr_req ); |
|
16243 |
|
16244 int len = strlen(connect_data->username); |
|
16245 strcpy( smsg + index, connect_data->username ); |
|
16246 index += len + 1; |
|
16247 |
|
16248 //appending password |
|
16249 |
|
16250 len = strlen(connect_data->password ); |
|
16251 strcpy( smsg + index, connect_data->password ); |
|
16252 index += len + 1; |
|
16253 |
|
16254 //appending server name |
|
16255 |
|
16256 len = strlen(connect_data->server ); |
|
16257 strcpy( smsg + index, connect_data->server ); |
|
16258 index += len + 1; |
|
16259 |
|
16260 //appending resource |
|
16261 len = strlen(connect_data->resource ); |
|
16262 strcpy( smsg + index, connect_data->resource ); |
|
16263 index += len + 1; |
|
16264 |
|
16265 //appending ssl |
|
16266 smsg[index++]= '0'; |
|
16267 smsg[index++]= '\0'; |
|
16268 |
|
16269 //appending server port |
|
16270 len = strlen(connect_data->port ); |
|
16271 strcpy( smsg + index, connect_data->port ); |
|
16272 index += len + 1; |
|
16273 |
|
16274 // appending IAP id |
|
16275 |
|
16276 smsg[index++]= '1'; |
|
16277 smsg[index++]= '\0'; |
|
16278 |
|
16279 //appending connmgr_bus |
|
16280 len = strlen(connect_data->connmgr_bus ); |
|
16281 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
16282 index += len + 1; |
|
16283 |
|
16284 //appending connmgr_path |
|
16285 len = strlen(connect_data->connmgr_path ); |
|
16286 strcpy( smsg + index, connect_data->connmgr_path ); |
|
16287 index += len + 1; |
|
16288 |
|
16289 //appending protocol |
|
16290 len = strlen(connect_data->protocol ); |
|
16291 strcpy( smsg + index, connect_data->protocol ); |
|
16292 index += len + 1; |
|
16293 |
|
16294 #ifdef __WINSCW__ |
|
16295 //proxy server |
|
16296 len = strlen(connect_data->proxy_data->proxy_server ); |
|
16297 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
16298 index += len + 1; |
|
16299 |
|
16300 //proxy port |
|
16301 len = strlen(connect_data->proxy_data->proxy_port ); |
|
16302 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
16303 index += len + 1; |
|
16304 |
|
16305 #endif |
|
16306 run_isoserver(); |
|
16307 |
|
16308 //create message queue for send request |
|
16309 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16310 //create message queue for response request |
|
16311 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16312 |
|
16313 |
|
16314 /* Send Message to queueOne */ |
|
16315 |
|
16316 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16317 |
|
16318 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
16319 |
|
16320 if (status < 0) |
|
16321 { |
|
16322 return_value = KErrGeneral; |
|
16323 goto return_code; |
|
16324 } |
|
16325 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
16326 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
16327 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16328 |
|
16329 if( msg_struct->response != 1) |
|
16330 { |
|
16331 return_value = KErrGeneral; |
|
16332 goto return_code; |
|
16333 } |
|
16334 |
|
16335 |
|
16336 // login end |
|
16337 //fetch req.. |
|
16338 for (int i= 0 ;i<3 ;i++) |
|
16339 { |
|
16340 |
|
16341 fp = fopen("c:\\fetch_contact.txt","a"); |
|
16342 do { |
|
16343 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16344 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16345 fwrite(rmsg,1,status,fp); |
|
16346 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16347 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
16348 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
16349 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
16350 fclose(fp); |
|
16351 |
|
16352 } |
|
16353 |
|
16354 //fetch end |
|
16355 |
|
16356 //search messge-------------------------------------------- |
|
16357 |
|
16358 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16359 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16360 index=0; |
|
16361 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16362 msgHdr->message_type = ESearch; |
|
16363 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16364 index += sizeof( message_hdr_req ); |
|
16365 |
|
16366 const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name); |
|
16367 // adding key |
|
16368 len = strlen(search_label); |
|
16369 strcpy( smsg + index, search_label ); |
|
16370 index += len + 1; |
|
16371 |
|
16372 // adding value |
|
16373 len = strlen("sharath" ); |
|
16374 strcpy( smsg + index, "sharath" ); |
|
16375 index += len + 1; |
|
16376 |
|
16377 smsg[index++] = '\0'; |
|
16378 |
|
16379 gint temp = 0; |
|
16380 gchar* add_contact = NULL; |
|
16381 |
|
16382 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16383 do |
|
16384 { |
|
16385 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16386 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16387 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16388 |
|
16389 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
16390 |
|
16391 if ( msg_struct->response != 1 ) |
|
16392 { |
|
16393 return_value = KErrGeneral; |
|
16394 goto return_code; |
|
16395 } |
|
16396 |
|
16397 //search message end--------------------------------------- |
|
16398 |
|
16399 |
|
16400 //second search messge-------------------------------------------- |
|
16401 |
|
16402 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16403 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16404 index=0; |
|
16405 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16406 msgHdr->message_type = ESearch; |
|
16407 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16408 index += sizeof( message_hdr_req ); |
|
16409 |
|
16410 |
|
16411 |
|
16412 |
|
16413 const gchar* search_label1 = GetSearchLabelL(connect_data->server,connect_data->key_middle_name); |
|
16414 // adding key |
|
16415 len = strlen(search_label1); |
|
16416 strcpy( smsg + index, search_label1 ); |
|
16417 index += len + 1; |
|
16418 |
|
16419 // adding value |
|
16420 len = strlen("Jeppu" ); |
|
16421 strcpy( smsg + index, "Jeppu" ); |
|
16422 index += len + 1; |
|
16423 |
|
16424 smsg[index++] = '\0'; |
|
16425 |
|
16426 |
|
16427 |
|
16428 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16429 do |
|
16430 { |
|
16431 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16432 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16433 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16434 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
16435 |
|
16436 if ( msg_struct->response != 1 ) |
|
16437 { |
|
16438 return_value = KErrGeneral; |
|
16439 goto return_code; |
|
16440 } |
|
16441 |
|
16442 //search message end--------------------------------------- |
|
16443 |
|
16444 |
|
16445 |
|
16446 // logout test code from server |
|
16447 index=0; |
|
16448 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16449 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16450 |
|
16451 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16452 |
|
16453 msgHdr->message_type = ELogout_Request; |
|
16454 |
|
16455 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16456 index += sizeof( message_hdr_req ); |
|
16457 |
|
16458 |
|
16459 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16460 do { |
|
16461 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16462 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16463 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16464 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
16465 |
|
16466 if ( msg_struct->response != 1) |
|
16467 { |
|
16468 return_value = KErrGeneral; |
|
16469 goto return_code; |
|
16470 } |
|
16471 |
|
16472 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
16473 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
16474 return_value = KErrNone; |
|
16475 goto return_code; |
|
16476 |
|
16477 //killing isoserver |
|
16478 return_code: |
|
16479 index=0; |
|
16480 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16481 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16482 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16483 msgHdr->message_type = EKill_Process; |
|
16484 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16485 index += sizeof( message_hdr_req ); |
|
16486 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16487 free( msg_struct ); |
|
16488 return return_value; |
|
16489 } |
|
16490 |
|
16491 |
|
16492 TInt Cisolationserver::AcceptAddRequestFromUser( CStifItemParser& aItem ) |
|
16493 { |
|
16494 |
|
16495 |
|
16496 ConnectData *connect_data = NULL; |
|
16497 char smsg[MAX_MSG_SIZE]; |
|
16498 char rmsg[MAX_MSG_SIZE]; |
|
16499 int index=0; |
|
16500 |
|
16501 |
|
16502 int timeout = 100; |
|
16503 int nBytes; |
|
16504 |
|
16505 int result = 0; |
|
16506 int err = 0; |
|
16507 int status = 0; |
|
16508 FILE *fp; |
|
16509 message_hdr_req *msgHdr = NULL; |
|
16510 message_hdr_resp* msg_struct = NULL; |
|
16511 TInt return_value = 0; |
|
16512 // Read data from the CFG file |
|
16513 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
16514 { |
|
16515 iLog->Log ( _L ( "read_data failed" ) ); |
|
16516 free_data ( connect_data ); |
|
16517 return_value = KErrGeneral; |
|
16518 goto return_code; |
|
16519 } |
|
16520 //request formation |
|
16521 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16522 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16523 |
|
16524 //message header use |
|
16525 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
16526 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16527 |
|
16528 msgHdr->message_type = ELogin_Request; |
|
16529 |
|
16530 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16531 index += sizeof( message_hdr_req ); |
|
16532 |
|
16533 int len = strlen(connect_data->username); |
|
16534 strcpy( smsg + index, connect_data->username ); |
|
16535 index += len + 1; |
|
16536 |
|
16537 //appending password |
|
16538 |
|
16539 len = strlen(connect_data->password ); |
|
16540 strcpy( smsg + index, connect_data->password ); |
|
16541 index += len + 1; |
|
16542 |
|
16543 //appending server name |
|
16544 |
|
16545 len = strlen(connect_data->server ); |
|
16546 strcpy( smsg + index, connect_data->server ); |
|
16547 index += len + 1; |
|
16548 |
|
16549 //appending resource |
|
16550 len = strlen(connect_data->resource ); |
|
16551 strcpy( smsg + index, connect_data->resource ); |
|
16552 index += len + 1; |
|
16553 |
|
16554 //appending ssl |
|
16555 smsg[index++]= '1'; |
|
16556 smsg[index++]= '\0'; |
|
16557 |
|
16558 //appending server port |
|
16559 len = strlen(connect_data->port ); |
|
16560 strcpy( smsg + index, connect_data->port ); |
|
16561 index += len + 1; |
|
16562 |
|
16563 // appending IAP id |
|
16564 |
|
16565 smsg[index++]= '1'; |
|
16566 smsg[index++]= '\0'; |
|
16567 |
|
16568 //appending connmgr_bus |
|
16569 len = strlen(connect_data->connmgr_bus ); |
|
16570 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
16571 index += len + 1; |
|
16572 |
|
16573 //appending connmgr_path |
|
16574 len = strlen(connect_data->connmgr_path ); |
|
16575 strcpy( smsg + index, connect_data->connmgr_path ); |
|
16576 index += len + 1; |
|
16577 |
|
16578 //appending protocol |
|
16579 len = strlen(connect_data->protocol ); |
|
16580 strcpy( smsg + index, connect_data->protocol ); |
|
16581 index += len + 1; |
|
16582 |
|
16583 #ifdef __WINSCW__ |
|
16584 //proxy server |
|
16585 len = strlen(connect_data->proxy_data->proxy_server ); |
|
16586 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
16587 index += len + 1; |
|
16588 |
|
16589 //proxy port |
|
16590 len = strlen(connect_data->proxy_data->proxy_port ); |
|
16591 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
16592 index += len + 1; |
|
16593 |
|
16594 #endif |
|
16595 //running isoserver |
|
16596 run_isoserver(); |
|
16597 //create message queue for send request |
|
16598 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16599 //create message queue for response request |
|
16600 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16601 |
|
16602 |
|
16603 /* Send Message to queueOne */ |
|
16604 |
|
16605 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16606 |
|
16607 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
16608 |
|
16609 if (status < 0) |
|
16610 { |
|
16611 return_value = KErrGeneral; |
|
16612 goto return_code; |
|
16613 } |
|
16614 |
|
16615 |
|
16616 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
16617 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
16618 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16619 |
|
16620 if( msg_struct->response != 1) |
|
16621 { |
|
16622 return_value = KErrGeneral; |
|
16623 goto return_code; |
|
16624 } |
|
16625 |
|
16626 |
|
16627 // login end |
|
16628 //fetch req.. |
|
16629 for (int i= 0 ;i<3 ;i++) |
|
16630 { |
|
16631 |
|
16632 fp = fopen("c:\\fetch_contact.txt","a"); |
|
16633 do { |
|
16634 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16635 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16636 fwrite(rmsg,1,status,fp); |
|
16637 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16638 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
16639 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
16640 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
16641 fclose(fp); |
|
16642 |
|
16643 } |
|
16644 |
|
16645 //fetch end |
|
16646 //fetch end |
|
16647 // getting add notification from user |
|
16648 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16649 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16650 index=0; |
|
16651 |
|
16652 do { |
|
16653 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16654 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16655 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16656 // memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16657 } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish); |
|
16658 |
|
16659 if ( msg_struct->response != 1) |
|
16660 { |
|
16661 return_value = KErrGeneral; |
|
16662 goto return_code; |
|
16663 } |
|
16664 char *userid = (char *)malloc(100); |
|
16665 len=0; |
|
16666 len+=sizeof(message_hdr_resp); |
|
16667 strcpy(userid,rmsg+len); |
|
16668 // accepting add request from user |
|
16669 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16670 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16671 index=0; |
|
16672 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16673 msgHdr->message_type = EReject_Contact_Request; |
|
16674 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16675 index += sizeof( message_hdr_req ); |
|
16676 len=0; |
|
16677 len+=strlen(userid); |
|
16678 strcpy( smsg + index ,userid ); |
|
16679 index += len + 1; |
|
16680 |
|
16681 |
|
16682 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16683 |
|
16684 do { |
|
16685 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16686 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16687 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16688 } while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request); |
|
16689 |
|
16690 if ( msg_struct->response != 1) |
|
16691 { |
|
16692 return_value = KErrGeneral; |
|
16693 goto return_code; |
|
16694 } |
|
16695 |
|
16696 // logout test code from server |
|
16697 index=0; |
|
16698 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16699 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16700 |
|
16701 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16702 |
|
16703 msgHdr->message_type = ELogout_Request; |
|
16704 |
|
16705 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16706 index += sizeof( message_hdr_req ); |
|
16707 |
|
16708 |
|
16709 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16710 |
|
16711 do { |
|
16712 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16713 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16714 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16715 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
16716 |
|
16717 if ( msg_struct->response != 1) |
|
16718 { |
|
16719 return_value = KErrGeneral; |
|
16720 goto return_code; |
|
16721 } |
|
16722 //killing isoserver |
|
16723 return_code: |
|
16724 index=0; |
|
16725 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16726 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16727 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16728 msgHdr->message_type = EKill_Process; |
|
16729 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16730 index += sizeof( message_hdr_req ); |
|
16731 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16732 free( msg_struct ); |
|
16733 return return_value; |
|
16734 } |
|
16735 |
|
16736 |
|
16737 // ----------------------------------------------------------------------------- |
|
16738 // Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest |
|
16739 // Example test method function. |
|
16740 // (other items were commented in a header). |
|
16741 // ----------------------------------------------------------------------------- |
|
16742 // |
|
16743 TInt Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest( CStifItemParser& aItem ) |
|
16744 { |
|
16745 |
|
16746 |
|
16747 ConnectData *connect_data = NULL; |
|
16748 char smsg[MAX_MSG_SIZE]; |
|
16749 char rmsg[MAX_MSG_SIZE]; |
|
16750 int index=0; |
|
16751 FILE *fp; |
|
16752 |
|
16753 int timeout = 200; |
|
16754 int nBytes; |
|
16755 |
|
16756 int result = 0; |
|
16757 int err = 0; |
|
16758 int status = 0; |
|
16759 message_hdr_req *msgHdr = NULL; |
|
16760 message_hdr_resp* msg_struct = NULL; |
|
16761 TInt return_value = 0; |
|
16762 // Read data from the CFG file |
|
16763 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
16764 { |
|
16765 iLog->Log ( _L ( "read_data failed" ) ); |
|
16766 free_data ( connect_data ); |
|
16767 return_value = KErrGeneral; |
|
16768 goto return_code; |
|
16769 } |
|
16770 //request formation |
|
16771 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16772 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16773 |
|
16774 //message header use |
|
16775 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
16776 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16777 |
|
16778 msgHdr->message_type = ELogin_Request; |
|
16779 |
|
16780 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16781 index += sizeof( message_hdr_req ); |
|
16782 |
|
16783 int len = strlen(connect_data->username); |
|
16784 strcpy( smsg + index, connect_data->username ); |
|
16785 index += len + 1; |
|
16786 |
|
16787 //appending password |
|
16788 |
|
16789 len = strlen(connect_data->password ); |
|
16790 strcpy( smsg + index, connect_data->password ); |
|
16791 index += len + 1; |
|
16792 |
|
16793 //appending server name |
|
16794 |
|
16795 len = strlen(connect_data->server ); |
|
16796 strcpy( smsg + index, connect_data->server ); |
|
16797 index += len + 1; |
|
16798 |
|
16799 //appending resource |
|
16800 len = strlen(connect_data->resource ); |
|
16801 strcpy( smsg + index, connect_data->resource ); |
|
16802 index += len + 1; |
|
16803 |
|
16804 //appending ssl |
|
16805 smsg[index++]= '1'; |
|
16806 smsg[index++]= '\0'; |
|
16807 |
|
16808 //appending server port |
|
16809 len = strlen(connect_data->port ); |
|
16810 strcpy( smsg + index, connect_data->port ); |
|
16811 index += len + 1; |
|
16812 |
|
16813 // appending IAP id |
|
16814 |
|
16815 smsg[index++]= '1'; |
|
16816 smsg[index++]= '\0'; |
|
16817 |
|
16818 //appending connmgr_bus |
|
16819 len = strlen(connect_data->connmgr_bus ); |
|
16820 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
16821 index += len + 1; |
|
16822 |
|
16823 //appending connmgr_path |
|
16824 len = strlen(connect_data->connmgr_path ); |
|
16825 strcpy( smsg + index, connect_data->connmgr_path ); |
|
16826 index += len + 1; |
|
16827 |
|
16828 //appending protocol |
|
16829 len = strlen(connect_data->protocol ); |
|
16830 strcpy( smsg + index, connect_data->protocol ); |
|
16831 index += len + 1; |
|
16832 |
|
16833 #ifdef __WINSCW__ |
|
16834 //proxy server |
|
16835 len = strlen(connect_data->proxy_data->proxy_server ); |
|
16836 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
16837 index += len + 1; |
|
16838 |
|
16839 //proxy port |
|
16840 len = strlen(connect_data->proxy_data->proxy_port ); |
|
16841 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
16842 index += len + 1; |
|
16843 |
|
16844 #endif |
|
16845 |
|
16846 //running isoserver |
|
16847 run_isoserver(); |
|
16848 |
|
16849 |
|
16850 //create message queue for send request |
|
16851 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16852 //create message queue for response request |
|
16853 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
16854 |
|
16855 |
|
16856 /* Send Message to queueOne */ |
|
16857 |
|
16858 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16859 |
|
16860 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
16861 |
|
16862 if (status < 0) |
|
16863 { |
|
16864 return_value = KErrGeneral; |
|
16865 goto return_code; |
|
16866 } |
|
16867 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
16868 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
16869 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16870 |
|
16871 if( msg_struct->response != 1) |
|
16872 { |
|
16873 return_value = KErrGeneral; |
|
16874 goto return_code; |
|
16875 } |
|
16876 |
|
16877 |
|
16878 // login end |
|
16879 //fetch req.. |
|
16880 for (int i= 0 ;i<3 ;i++) |
|
16881 { |
|
16882 |
|
16883 fp = fopen("c:\\fetch_contact.txt","a"); |
|
16884 do { |
|
16885 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16886 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16887 fwrite(rmsg,1,status,fp); |
|
16888 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16889 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
16890 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
16891 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
16892 fclose(fp); |
|
16893 |
|
16894 } |
|
16895 |
|
16896 //fetch end |
|
16897 //Accepting Add request from contact without ne add notification -------------------------------------------- |
|
16898 |
|
16899 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16900 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16901 index=0; |
|
16902 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16903 msgHdr->message_type = EAccept_Contact_Request; |
|
16904 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16905 index += sizeof( message_hdr_req ); |
|
16906 // adding add contact |
|
16907 len = strlen(connect_data->contact ); |
|
16908 strcpy( smsg + index, connect_data->contact ); |
|
16909 index += len + 1; |
|
16910 smsg[index++] = '\0'; |
|
16911 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16912 do { |
|
16913 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16914 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16915 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16916 } while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request); |
|
16917 |
|
16918 if ( msg_struct->response != 0) |
|
16919 { |
|
16920 return_value = KErrGeneral; |
|
16921 goto return_code; |
|
16922 } |
|
16923 |
|
16924 //add contact end--------------------------------------- |
|
16925 |
|
16926 |
|
16927 // logout test code from server |
|
16928 index=0; |
|
16929 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16930 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16931 |
|
16932 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16933 |
|
16934 msgHdr->message_type = ELogout_Request; |
|
16935 |
|
16936 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16937 index += sizeof( message_hdr_req ); |
|
16938 |
|
16939 |
|
16940 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16941 do { |
|
16942 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
16943 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
16944 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16945 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
16946 |
|
16947 if ( msg_struct->response != 1) |
|
16948 { |
|
16949 return_value = KErrGeneral; |
|
16950 goto return_code; |
|
16951 } |
|
16952 //killing isoserver |
|
16953 return_code: |
|
16954 index=0; |
|
16955 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
16956 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
16957 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
16958 msgHdr->message_type = EKill_Process; |
|
16959 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
16960 index += sizeof( message_hdr_req ); |
|
16961 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
16962 free( msg_struct ); |
|
16963 return return_value; |
|
16964 } |
|
16965 |
|
16966 // ----------------------------------------------------------------------------- |
|
16967 // Cisolationserver::SendRejectRequestWithoutReceivingAddrequest |
|
16968 // Example test method function. |
|
16969 // (other items were commented in a header). |
|
16970 // ----------------------------------------------------------------------------- |
|
16971 // |
|
16972 TInt Cisolationserver::SendRejectRequestWithoutReceivingAddrequest( CStifItemParser& aItem ) |
|
16973 { |
|
16974 |
|
16975 |
|
16976 ConnectData *connect_data = NULL; |
|
16977 char smsg[MAX_MSG_SIZE]; |
|
16978 char rmsg[MAX_MSG_SIZE]; |
|
16979 int index=0; |
|
16980 FILE *fp; |
|
16981 |
|
16982 int timeout = 200; |
|
16983 int nBytes; |
|
16984 |
|
16985 int result = 0; |
|
16986 int err = 0; |
|
16987 int status = 0; |
|
16988 message_hdr_req *msgHdr = NULL; |
|
16989 message_hdr_resp* msg_struct = NULL; |
|
16990 TInt return_value = 0; |
|
16991 // Read data from the CFG file |
|
16992 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
16993 { |
|
16994 iLog->Log ( _L ( "read_data failed" ) ); |
|
16995 free_data ( connect_data ); |
|
16996 return_value = KErrGeneral; |
|
16997 goto return_code; |
|
16998 } |
|
16999 //request formation |
|
17000 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17001 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17002 |
|
17003 //message header use |
|
17004 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
17005 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17006 |
|
17007 msgHdr->message_type = ELogin_Request; |
|
17008 |
|
17009 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17010 index += sizeof( message_hdr_req ); |
|
17011 |
|
17012 int len = strlen(connect_data->username); |
|
17013 strcpy( smsg + index, connect_data->username ); |
|
17014 index += len + 1; |
|
17015 |
|
17016 //appending password |
|
17017 |
|
17018 len = strlen(connect_data->password ); |
|
17019 strcpy( smsg + index, connect_data->password ); |
|
17020 index += len + 1; |
|
17021 |
|
17022 //appending server name |
|
17023 |
|
17024 len = strlen(connect_data->server ); |
|
17025 strcpy( smsg + index, connect_data->server ); |
|
17026 index += len + 1; |
|
17027 |
|
17028 //appending resource |
|
17029 len = strlen(connect_data->resource ); |
|
17030 strcpy( smsg + index, connect_data->resource ); |
|
17031 index += len + 1; |
|
17032 |
|
17033 //appending ssl |
|
17034 smsg[index++]= '1'; |
|
17035 smsg[index++]= '\0'; |
|
17036 |
|
17037 //appending server port |
|
17038 len = strlen(connect_data->port ); |
|
17039 strcpy( smsg + index, connect_data->port ); |
|
17040 index += len + 1; |
|
17041 |
|
17042 // appending IAP id |
|
17043 |
|
17044 smsg[index++]= '1'; |
|
17045 smsg[index++]= '\0'; |
|
17046 |
|
17047 //appending connmgr_bus |
|
17048 len = strlen(connect_data->connmgr_bus ); |
|
17049 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
17050 index += len + 1; |
|
17051 |
|
17052 //appending connmgr_path |
|
17053 len = strlen(connect_data->connmgr_path ); |
|
17054 strcpy( smsg + index, connect_data->connmgr_path ); |
|
17055 index += len + 1; |
|
17056 |
|
17057 //appending protocol |
|
17058 len = strlen(connect_data->protocol ); |
|
17059 strcpy( smsg + index, connect_data->protocol ); |
|
17060 index += len + 1; |
|
17061 |
|
17062 #ifdef __WINSCW__ |
|
17063 //proxy server |
|
17064 len = strlen(connect_data->proxy_data->proxy_server ); |
|
17065 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
17066 index += len + 1; |
|
17067 |
|
17068 //proxy port |
|
17069 len = strlen(connect_data->proxy_data->proxy_port ); |
|
17070 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
17071 index += len + 1; |
|
17072 |
|
17073 #endif |
|
17074 |
|
17075 //running isoserver |
|
17076 run_isoserver(); |
|
17077 |
|
17078 |
|
17079 //create message queue for send request |
|
17080 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17081 //create message queue for response request |
|
17082 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17083 |
|
17084 |
|
17085 /* Send Message to queueOne */ |
|
17086 |
|
17087 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17088 |
|
17089 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
17090 |
|
17091 if (status < 0) |
|
17092 { |
|
17093 return_value = KErrGeneral; |
|
17094 goto return_code; |
|
17095 } |
|
17096 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
17097 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
17098 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17099 |
|
17100 if( msg_struct->response != 0) |
|
17101 { |
|
17102 return_value = KErrGeneral; |
|
17103 goto return_code; |
|
17104 } |
|
17105 |
|
17106 |
|
17107 // login end |
|
17108 //fetch req.. |
|
17109 for (int i= 0 ;i<3 ;i++) |
|
17110 { |
|
17111 |
|
17112 fp = fopen("c:\\fetch_contact.txt","a"); |
|
17113 do { |
|
17114 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17115 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17116 fwrite(rmsg,1,status,fp); |
|
17117 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17118 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
17119 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
17120 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
17121 fclose(fp); |
|
17122 |
|
17123 } |
|
17124 |
|
17125 //fetch end |
|
17126 //Accepting Add request from contact without ne add notification -------------------------------------------- |
|
17127 |
|
17128 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17129 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17130 index=0; |
|
17131 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17132 msgHdr->message_type = EReject_Contact_Request; |
|
17133 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17134 index += sizeof( message_hdr_req ); |
|
17135 // adding add contact |
|
17136 len = strlen(connect_data->contact ); |
|
17137 strcpy( smsg + index, connect_data->contact ); |
|
17138 index += len + 1; |
|
17139 smsg[index++] = '\0'; |
|
17140 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17141 do { |
|
17142 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17143 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17144 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17145 } while (msg_struct->hdr_req.message_type!=EReject_Contact_Request); |
|
17146 |
|
17147 if ( msg_struct->response != 1) |
|
17148 { |
|
17149 return_value = KErrGeneral; |
|
17150 goto return_code; |
|
17151 } |
|
17152 |
|
17153 //add contact end--------------------------------------- |
|
17154 |
|
17155 |
|
17156 // logout test code from server |
|
17157 index=0; |
|
17158 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17159 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17160 |
|
17161 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17162 |
|
17163 msgHdr->message_type = ELogout_Request; |
|
17164 |
|
17165 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17166 index += sizeof( message_hdr_req ); |
|
17167 |
|
17168 |
|
17169 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17170 do { |
|
17171 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17172 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17173 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17174 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
17175 |
|
17176 if ( msg_struct->response != 1) |
|
17177 { |
|
17178 return_value = KErrGeneral; |
|
17179 goto return_code; |
|
17180 } |
|
17181 //killing isoserver |
|
17182 return_code: |
|
17183 index=0; |
|
17184 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17185 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17186 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17187 msgHdr->message_type = EKill_Process; |
|
17188 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17189 index += sizeof( message_hdr_req ); |
|
17190 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17191 free( msg_struct ); |
|
17192 return return_value; |
|
17193 } |
|
17194 |
|
17195 |
|
17196 // ----------------------------------------------------------------------------- |
|
17197 // Cisolationserver::SendAcceptRequestWithoutAnyUserID |
|
17198 // Example test method function. |
|
17199 // (other items were commented in a header). |
|
17200 // ----------------------------------------------------------------------------- |
|
17201 // |
|
17202 TInt Cisolationserver::SendAcceptRequestWithoutAnyUserID( CStifItemParser& aItem ) |
|
17203 { |
|
17204 |
|
17205 |
|
17206 ConnectData *connect_data = NULL; |
|
17207 char smsg[MAX_MSG_SIZE]; |
|
17208 char rmsg[MAX_MSG_SIZE]; |
|
17209 int index=0; |
|
17210 |
|
17211 |
|
17212 int timeout = 100; |
|
17213 int nBytes; |
|
17214 |
|
17215 int result = 0; |
|
17216 int err = 0; |
|
17217 int status = 0; |
|
17218 FILE *fp; |
|
17219 message_hdr_req *msgHdr = NULL; |
|
17220 message_hdr_resp* msg_struct = NULL; |
|
17221 TInt return_value = 0; |
|
17222 // Read data from the CFG file |
|
17223 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
17224 { |
|
17225 iLog->Log ( _L ( "read_data failed" ) ); |
|
17226 free_data ( connect_data ); |
|
17227 return_value = KErrGeneral; |
|
17228 goto return_code; |
|
17229 } |
|
17230 //request formation |
|
17231 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17232 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17233 |
|
17234 //message header use |
|
17235 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
17236 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17237 |
|
17238 msgHdr->message_type = ELogin_Request; |
|
17239 |
|
17240 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17241 index += sizeof( message_hdr_req ); |
|
17242 |
|
17243 int len = strlen(connect_data->username); |
|
17244 strcpy( smsg + index, connect_data->username ); |
|
17245 index += len + 1; |
|
17246 |
|
17247 //appending password |
|
17248 |
|
17249 len = strlen(connect_data->password ); |
|
17250 strcpy( smsg + index, connect_data->password ); |
|
17251 index += len + 1; |
|
17252 |
|
17253 //appending server name |
|
17254 |
|
17255 len = strlen(connect_data->server ); |
|
17256 strcpy( smsg + index, connect_data->server ); |
|
17257 index += len + 1; |
|
17258 |
|
17259 //appending resource |
|
17260 len = strlen(connect_data->resource ); |
|
17261 strcpy( smsg + index, connect_data->resource ); |
|
17262 index += len + 1; |
|
17263 |
|
17264 //appending ssl |
|
17265 smsg[index++]= '1'; |
|
17266 smsg[index++]= '\0'; |
|
17267 |
|
17268 //appending server port |
|
17269 len = strlen(connect_data->port ); |
|
17270 strcpy( smsg + index, connect_data->port ); |
|
17271 index += len + 1; |
|
17272 |
|
17273 // appending IAP id |
|
17274 |
|
17275 smsg[index++]= '1'; |
|
17276 smsg[index++]= '\0'; |
|
17277 |
|
17278 //appending connmgr_bus |
|
17279 len = strlen(connect_data->connmgr_bus ); |
|
17280 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
17281 index += len + 1; |
|
17282 |
|
17283 //appending connmgr_path |
|
17284 len = strlen(connect_data->connmgr_path ); |
|
17285 strcpy( smsg + index, connect_data->connmgr_path ); |
|
17286 index += len + 1; |
|
17287 |
|
17288 //appending protocol |
|
17289 len = strlen(connect_data->protocol ); |
|
17290 strcpy( smsg + index, connect_data->protocol ); |
|
17291 index += len + 1; |
|
17292 |
|
17293 #ifdef __WINSCW__ |
|
17294 //proxy server |
|
17295 len = strlen(connect_data->proxy_data->proxy_server ); |
|
17296 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
17297 index += len + 1; |
|
17298 |
|
17299 //proxy port |
|
17300 len = strlen(connect_data->proxy_data->proxy_port ); |
|
17301 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
17302 index += len + 1; |
|
17303 |
|
17304 #endif |
|
17305 //running isoserver |
|
17306 run_isoserver(); |
|
17307 //create message queue for send request |
|
17308 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17309 //create message queue for response request |
|
17310 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17311 |
|
17312 |
|
17313 /* Send Message to queueOne */ |
|
17314 |
|
17315 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17316 |
|
17317 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
17318 |
|
17319 if (status < 0) |
|
17320 { |
|
17321 return_value = KErrGeneral; |
|
17322 goto return_code; |
|
17323 } |
|
17324 |
|
17325 |
|
17326 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
17327 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
17328 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17329 |
|
17330 if( msg_struct->response != 1) |
|
17331 { |
|
17332 return_value = KErrGeneral; |
|
17333 goto return_code; |
|
17334 } |
|
17335 |
|
17336 |
|
17337 // login end |
|
17338 //fetch req.. |
|
17339 for (int i= 0 ;i<3 ;i++) |
|
17340 { |
|
17341 |
|
17342 fp = fopen("c:\\fetch_contact.txt","a"); |
|
17343 do { |
|
17344 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17345 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17346 fwrite(rmsg,1,status,fp); |
|
17347 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17348 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
17349 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
17350 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
17351 fclose(fp); |
|
17352 |
|
17353 } |
|
17354 |
|
17355 //fetch end |
|
17356 //fetch end |
|
17357 // getting add notification from user |
|
17358 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17359 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17360 index=0; |
|
17361 |
|
17362 do { |
|
17363 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17364 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17365 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17366 // memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17367 } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish); |
|
17368 |
|
17369 if ( msg_struct->response != 1) |
|
17370 { |
|
17371 return_value = KErrGeneral; |
|
17372 goto return_code; |
|
17373 } |
|
17374 char *userid = (char *)malloc(100); |
|
17375 len=0; |
|
17376 len+=sizeof(message_hdr_resp); |
|
17377 strcpy(userid,rmsg+len); |
|
17378 // accepting add request from user |
|
17379 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17380 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17381 index=0; |
|
17382 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17383 msgHdr->message_type = EReject_Contact_Request; |
|
17384 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17385 index += sizeof( message_hdr_req ); |
|
17386 |
|
17387 //no need to send user id with this message |
|
17388 //len=0; |
|
17389 //len+=strlen(userid); |
|
17390 //strcpy( smsg + index ,userid ); |
|
17391 //index += len + 1; |
|
17392 |
|
17393 |
|
17394 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17395 |
|
17396 do { |
|
17397 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17398 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17399 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17400 } while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request); |
|
17401 // need to check response |
|
17402 if ( msg_struct->response != 0) |
|
17403 { |
|
17404 return_value = KErrGeneral; |
|
17405 goto return_code; |
|
17406 } |
|
17407 |
|
17408 // logout test code from server |
|
17409 index=0; |
|
17410 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17411 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17412 |
|
17413 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17414 |
|
17415 msgHdr->message_type = ELogout_Request; |
|
17416 |
|
17417 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17418 index += sizeof( message_hdr_req ); |
|
17419 |
|
17420 |
|
17421 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17422 |
|
17423 do { |
|
17424 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17425 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17426 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17427 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
17428 |
|
17429 if ( msg_struct->response != 1) |
|
17430 { |
|
17431 return_value = KErrGeneral; |
|
17432 goto return_code; |
|
17433 } |
|
17434 //killing isoserver |
|
17435 return_code: |
|
17436 index=0; |
|
17437 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17438 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17439 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17440 msgHdr->message_type = EKill_Process; |
|
17441 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17442 index += sizeof( message_hdr_req ); |
|
17443 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17444 free( msg_struct ); |
|
17445 return return_value; |
|
17446 } |
|
17447 |
|
17448 // ----------------------------------------------------------------------------- |
|
17449 // Cisolationserver::SendRejectRequestWithoutAnyUserID |
|
17450 // Example test method function. |
|
17451 // (other items were commented in a header). |
|
17452 // ----------------------------------------------------------------------------- |
|
17453 //RejectAddRequestFromUser |
|
17454 TInt Cisolationserver::SendRejectRequestWithoutAnyUserID( CStifItemParser& aItem ) |
|
17455 { |
|
17456 |
|
17457 |
|
17458 ConnectData *connect_data = NULL; |
|
17459 char smsg[MAX_MSG_SIZE]; |
|
17460 char rmsg[MAX_MSG_SIZE]; |
|
17461 int index=0; |
|
17462 |
|
17463 |
|
17464 int timeout = 100; |
|
17465 int nBytes; |
|
17466 |
|
17467 int result = 0; |
|
17468 int err = 0; |
|
17469 int status = 0; |
|
17470 FILE *fp; |
|
17471 message_hdr_req *msgHdr = NULL; |
|
17472 message_hdr_resp* msg_struct = NULL; |
|
17473 TInt return_value = 0; |
|
17474 // Read data from the CFG file |
|
17475 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
17476 { |
|
17477 iLog->Log ( _L ( "read_data failed" ) ); |
|
17478 free_data ( connect_data ); |
|
17479 return_value = KErrGeneral; |
|
17480 goto return_code; |
|
17481 } |
|
17482 //request formation |
|
17483 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17484 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17485 |
|
17486 //message header use |
|
17487 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
17488 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17489 |
|
17490 msgHdr->message_type = ELogin_Request; |
|
17491 |
|
17492 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17493 index += sizeof( message_hdr_req ); |
|
17494 |
|
17495 int len = strlen(connect_data->username); |
|
17496 strcpy( smsg + index, connect_data->username ); |
|
17497 index += len + 1; |
|
17498 |
|
17499 //appending password |
|
17500 |
|
17501 len = strlen(connect_data->password ); |
|
17502 strcpy( smsg + index, connect_data->password ); |
|
17503 index += len + 1; |
|
17504 |
|
17505 //appending server name |
|
17506 |
|
17507 len = strlen(connect_data->server ); |
|
17508 strcpy( smsg + index, connect_data->server ); |
|
17509 index += len + 1; |
|
17510 |
|
17511 //appending resource |
|
17512 len = strlen(connect_data->resource ); |
|
17513 strcpy( smsg + index, connect_data->resource ); |
|
17514 index += len + 1; |
|
17515 |
|
17516 //appending ssl |
|
17517 smsg[index++]= '1'; |
|
17518 smsg[index++]= '\0'; |
|
17519 |
|
17520 //appending server port |
|
17521 len = strlen(connect_data->port ); |
|
17522 strcpy( smsg + index, connect_data->port ); |
|
17523 index += len + 1; |
|
17524 |
|
17525 // appending IAP id |
|
17526 |
|
17527 smsg[index++]= '1'; |
|
17528 smsg[index++]= '\0'; |
|
17529 |
|
17530 //appending connmgr_bus |
|
17531 len = strlen(connect_data->connmgr_bus ); |
|
17532 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
17533 index += len + 1; |
|
17534 |
|
17535 //appending connmgr_path |
|
17536 len = strlen(connect_data->connmgr_path ); |
|
17537 strcpy( smsg + index, connect_data->connmgr_path ); |
|
17538 index += len + 1; |
|
17539 |
|
17540 //appending protocol |
|
17541 len = strlen(connect_data->protocol ); |
|
17542 strcpy( smsg + index, connect_data->protocol ); |
|
17543 index += len + 1; |
|
17544 |
|
17545 #ifdef __WINSCW__ |
|
17546 //proxy server |
|
17547 len = strlen(connect_data->proxy_data->proxy_server ); |
|
17548 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
17549 index += len + 1; |
|
17550 |
|
17551 //proxy port |
|
17552 len = strlen(connect_data->proxy_data->proxy_port ); |
|
17553 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
17554 index += len + 1; |
|
17555 |
|
17556 #endif |
|
17557 //running isoserver |
|
17558 run_isoserver(); |
|
17559 //create message queue for send request |
|
17560 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17561 //create message queue for response request |
|
17562 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17563 |
|
17564 |
|
17565 /* Send Message to queueOne */ |
|
17566 |
|
17567 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17568 |
|
17569 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
17570 |
|
17571 if (status < 0) |
|
17572 { |
|
17573 return_value = KErrGeneral; |
|
17574 goto return_code; |
|
17575 } |
|
17576 |
|
17577 |
|
17578 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
17579 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
17580 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17581 |
|
17582 if( msg_struct->response != 1) |
|
17583 { |
|
17584 return_value = KErrGeneral; |
|
17585 goto return_code; |
|
17586 } |
|
17587 |
|
17588 |
|
17589 // login end |
|
17590 //fetch req.. |
|
17591 for (int i= 0 ;i<3 ;i++) |
|
17592 { |
|
17593 |
|
17594 fp = fopen("c:\\fetch_contact.txt","a"); |
|
17595 do { |
|
17596 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17597 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17598 fwrite(rmsg,1,status,fp); |
|
17599 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17600 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
17601 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
17602 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
17603 fclose(fp); |
|
17604 |
|
17605 } |
|
17606 |
|
17607 //fetch end |
|
17608 //fetch end |
|
17609 // getting add notification from user |
|
17610 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17611 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17612 index=0; |
|
17613 |
|
17614 do { |
|
17615 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17616 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17617 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17618 // memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17619 } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish); |
|
17620 |
|
17621 if ( msg_struct->response != 1) |
|
17622 { |
|
17623 return_value = KErrGeneral; |
|
17624 goto return_code; |
|
17625 } |
|
17626 char *userid = (char *)malloc(100); |
|
17627 len=0; |
|
17628 len+=sizeof(message_hdr_resp); |
|
17629 strcpy(userid,rmsg+len); |
|
17630 |
|
17631 |
|
17632 |
|
17633 |
|
17634 // rejecting add request from user |
|
17635 |
|
17636 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17637 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17638 index=0; |
|
17639 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17640 msgHdr->message_type = EReject_Contact_Request; |
|
17641 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17642 index += sizeof( message_hdr_req ); |
|
17643 //len=0; |
|
17644 //len+=strlen(userid); |
|
17645 //strcpy( smsg + index ,userid ); |
|
17646 //index += len + 1; |
|
17647 |
|
17648 |
|
17649 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17650 |
|
17651 do { |
|
17652 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17653 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17654 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17655 } while (msg_struct->hdr_req.message_type!=EReject_Contact_Request); |
|
17656 |
|
17657 if ( msg_struct->response != 0) |
|
17658 { |
|
17659 return_value = KErrGeneral; |
|
17660 goto return_code; |
|
17661 } |
|
17662 |
|
17663 // logout test code from server |
|
17664 index=0; |
|
17665 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17666 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17667 |
|
17668 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17669 |
|
17670 msgHdr->message_type = ELogout_Request; |
|
17671 |
|
17672 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17673 index += sizeof( message_hdr_req ); |
|
17674 |
|
17675 |
|
17676 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17677 |
|
17678 do { |
|
17679 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17680 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17681 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17682 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
17683 |
|
17684 if ( msg_struct->response != 1) |
|
17685 { |
|
17686 return_value = KErrGeneral; |
|
17687 goto return_code; |
|
17688 } |
|
17689 //killing isoserver |
|
17690 return_code: |
|
17691 index=0; |
|
17692 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17693 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17694 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17695 msgHdr->message_type = EKill_Process; |
|
17696 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17697 index += sizeof( message_hdr_req ); |
|
17698 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17699 free( msg_struct ); |
|
17700 return return_value; |
|
17701 } |
|
17702 |
|
17703 // ----------------------------------------------------------------------------- |
|
17704 // Cisolationserver::Login with correct data |
|
17705 // Example test method function. |
|
17706 // (other items were commented in a header). |
|
17707 // ----------------------------------------------------------------------------- |
|
17708 // |
|
17709 TInt Cisolationserver::LogoutWhileUserIsNotLoggedIn( CStifItemParser& aItem ) |
|
17710 { |
|
17711 |
|
17712 ConnectData *connect_data = NULL; |
|
17713 char smsg[MAX_MSG_SIZE]; |
|
17714 char rmsg[MAX_MSG_SIZE]; |
|
17715 int index=0; |
|
17716 |
|
17717 FILE *fp; |
|
17718 int timeout = 100; |
|
17719 int nBytes; |
|
17720 int result = 0; |
|
17721 int err = 0; |
|
17722 int status = 0; |
|
17723 message_hdr_req *msgHdr = NULL; |
|
17724 message_hdr_resp* msg_struct = NULL; |
|
17725 TInt return_value = 0; |
|
17726 // Read data from the CFG file |
|
17727 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
17728 { |
|
17729 iLog->Log ( _L ( "read_data failed" ) ); |
|
17730 free_data ( connect_data ); |
|
17731 return_value = KErrGeneral; |
|
17732 goto return_code; |
|
17733 } |
|
17734 //request formation |
|
17735 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17736 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17737 //message header use |
|
17738 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
17739 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17740 msgHdr->message_type = ELogin_Request; |
|
17741 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17742 index += sizeof( message_hdr_req ); |
|
17743 int len = strlen(connect_data->username); |
|
17744 strcpy( smsg + index, connect_data->username ); |
|
17745 index += len + 1; |
|
17746 //appending password |
|
17747 len = strlen(connect_data->password ); |
|
17748 strcpy( smsg + index, connect_data->password ); |
|
17749 index += len + 1; |
|
17750 //appending server name |
|
17751 len = strlen(connect_data->server ); |
|
17752 strcpy( smsg + index, connect_data->server ); |
|
17753 index += len + 1; |
|
17754 //appending resource |
|
17755 len = strlen(connect_data->resource ); |
|
17756 strcpy( smsg + index, connect_data->resource ); |
|
17757 index += len + 1; |
|
17758 //appending ssl |
|
17759 smsg[index++]= '1'; |
|
17760 smsg[index++]= '\0'; |
|
17761 //appending server port |
|
17762 len = strlen(connect_data->port ); |
|
17763 strcpy( smsg + index, connect_data->port ); |
|
17764 index += len + 1; |
|
17765 // appending IAP id |
|
17766 smsg[index++]= '1'; |
|
17767 smsg[index++]= '\0'; |
|
17768 //appending connmgr_bus |
|
17769 len = strlen(connect_data->connmgr_bus ); |
|
17770 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
17771 index += len + 1; |
|
17772 //appending connmgr_path |
|
17773 len = strlen(connect_data->connmgr_path ); |
|
17774 strcpy( smsg + index, connect_data->connmgr_path ); |
|
17775 index += len + 1; |
|
17776 //appending protocol |
|
17777 len = strlen(connect_data->protocol ); |
|
17778 strcpy( smsg + index, connect_data->protocol ); |
|
17779 index += len + 1; |
|
17780 #ifdef __WINSCW__ |
|
17781 //proxy server |
|
17782 len = strlen(connect_data->proxy_data->proxy_server ); |
|
17783 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
17784 index += len + 1; |
|
17785 //proxy port |
|
17786 len = strlen(connect_data->proxy_data->proxy_port ); |
|
17787 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
17788 index += len + 1; |
|
17789 #endif |
|
17790 //running isoserver |
|
17791 run_isoserver(); |
|
17792 //create message queue for send request |
|
17793 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17794 //create message queue for response request |
|
17795 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
17796 |
|
17797 //fetch end |
|
17798 |
|
17799 // logout test code from server |
|
17800 index=0; |
|
17801 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17802 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17803 |
|
17804 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17805 |
|
17806 msgHdr->message_type = ELogout_Request; |
|
17807 |
|
17808 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17809 index += sizeof( message_hdr_req ); |
|
17810 |
|
17811 |
|
17812 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17813 |
|
17814 do { |
|
17815 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
17816 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
17817 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17818 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
17819 |
|
17820 if ( msg_struct->response != 1) |
|
17821 { |
|
17822 return_value = KErrGeneral; |
|
17823 goto return_code; |
|
17824 } |
|
17825 return_value = KErrNone; |
|
17826 goto return_code; |
|
17827 //killing isoserver |
|
17828 return_code: |
|
17829 index=0; |
|
17830 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
17831 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
17832 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
17833 msgHdr->message_type = EKill_Process; |
|
17834 |
|
17835 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
17836 index += sizeof( message_hdr_req ); |
|
17837 |
|
17838 |
|
17839 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
17840 free( msg_struct ); |
|
17841 return return_value; |
|
17842 |
|
17843 } |
|
17844 |
|
17845 |
|
17846 // ----------------------------------------------------------------------------- |
|
17847 // Cisolationserver::GetSearchLabelForYukonL |
|
17848 // ----------------------------------------------------------------------------- |
|
17849 const gchar* Cisolationserver::GetSearchLabelForYukonL(gchar *search_key) |
|
17850 { |
|
17851 if(strcmp(search_key,"user") == 0) |
|
17852 { |
|
17853 gchar* label= "User"; |
|
17854 return label; |
|
17855 } |
|
17856 else if(strcmp(search_key,"fn") == 0) |
|
17857 { |
|
17858 gchar* label= "Full Name"; |
|
17859 return label; |
|
17860 } |
|
17861 else if(strcmp(search_key,"first") == 0) |
|
17862 { |
|
17863 gchar* label= "Name"; |
|
17864 return label; |
|
17865 } |
|
17866 else if(strcmp(search_key,"middle") == 0) |
|
17867 { |
|
17868 gchar* label= "Middle Name"; |
|
17869 return label; |
|
17870 } |
|
17871 else if(strcmp(search_key,"last") == 0) |
|
17872 { |
|
17873 gchar* label= "Family Name"; |
|
17874 return label; |
|
17875 } |
|
17876 else if(strcmp(search_key,"nick") == 0) |
|
17877 { |
|
17878 gchar* label= "Nickname"; |
|
17879 return label; |
|
17880 } |
|
17881 else if(strcmp(search_key,"email") == 0) |
|
17882 { |
|
17883 gchar* label= "Email"; |
|
17884 return label; |
|
17885 } |
|
17886 else if(strcmp(search_key,"bday") == 0) |
|
17887 { |
|
17888 gchar* label= "Birthday"; |
|
17889 return label; |
|
17890 } |
|
17891 else if(strcmp(search_key,"ctry") == 0) |
|
17892 { |
|
17893 gchar* label= "Country"; |
|
17894 return label; |
|
17895 } |
|
17896 else if(strcmp(search_key,"orgname") == 0) |
|
17897 { |
|
17898 gchar* label= "Organization Name"; |
|
17899 return label; |
|
17900 } |
|
17901 else if(strcmp(search_key,"locality") == 0) |
|
17902 { |
|
17903 gchar* label= "City"; |
|
17904 return label; |
|
17905 } |
|
17906 else if(strcmp(search_key,"orgunit") == 0) |
|
17907 { |
|
17908 gchar* label= "Organization Unit"; |
|
17909 return label; |
|
17910 } |
|
17911 } |
|
17912 |
|
17913 |
|
17914 // ----------------------------------------------------------------------------- |
|
17915 // Cisolationserver::GetSearchLabelForGizmoL |
|
17916 // ----------------------------------------------------------------------------- |
|
17917 const gchar* Cisolationserver::GetSearchLabelForGizmoL(gchar *search_key) |
|
17918 { |
|
17919 if(strcmp(search_key,"xmpp_user") == 0) |
|
17920 { |
|
17921 gchar* label= "Account Name"; |
|
17922 return label; |
|
17923 } |
|
17924 else if(strcmp(search_key,"email_address") == 0) |
|
17925 { |
|
17926 gchar* label= "Email Address"; |
|
17927 return label; |
|
17928 } |
|
17929 else if(strcmp(search_key,"first_name") == 0) |
|
17930 { |
|
17931 gchar* label= "First Name"; |
|
17932 return label; |
|
17933 } |
|
17934 else if(strcmp(search_key,"last_name") == 0) |
|
17935 { |
|
17936 gchar* label= "Family Name"; |
|
17937 return label; |
|
17938 } |
|
17939 else if(strcmp(search_key,"country") == 0) |
|
17940 { |
|
17941 gchar* label= "Country"; |
|
17942 return label; |
|
17943 } |
|
17944 else if(strcmp(search_key,"state") == 0) |
|
17945 { |
|
17946 gchar* label= "State/Province"; |
|
17947 return label; |
|
17948 } |
|
17949 else if(strcmp(search_key,"city") == 0) |
|
17950 { |
|
17951 gchar* label= "City"; |
|
17952 return label; |
|
17953 } |
|
17954 else if(strcmp(search_key,"max_results") == 0) |
|
17955 { |
|
17956 gchar* label= "Maximum # of Results"; |
|
17957 return label; |
|
17958 } |
|
17959 } |
|
17960 |
|
17961 // ----------------------------------------------------------------------------- |
|
17962 // Cisolationserver::GetSearchLabelL |
|
17963 // ----------------------------------------------------------------------------- |
|
17964 const gchar* Cisolationserver::GetSearchLabelL(gchar* aService,gchar* aSearchKey) |
|
17965 { |
|
17966 if(strcmp(aService,"chat.gizmoproject.com") == 0) |
|
17967 { |
|
17968 GetSearchLabelForGizmoL(aSearchKey); |
|
17969 } |
|
17970 else if(strcmp(aService,"chat.ovi.com") == 0 ) |
|
17971 { |
|
17972 GetSearchLabelForYukonL(aSearchKey); |
|
17973 } |
|
17974 } |
|
17975 |
|
17976 |
|
17977 // ----------------------------------------------------------------------------- |
|
17978 // Cisolationserver::?member_function |
|
17979 // ?implementation_description |
|
17980 // (other items were commented in a header). |
|
17981 |
|
17982 // ----------------------------------------------------------------------------- |
|
17983 // Cisolationserver::AcceptAddRequestFromUser |
|
17984 // Example test method function. |
|
17985 // (other items were commented in a header). |
|
17986 // ----------------------------------------------------------------------------- |
|
17987 // |
|
17988 Cisolationserver::GetKeysAndSearch( CStifItemParser& aItem ) |
|
17989 { |
|
17990 |
|
17991 ConnectData *connect_data = NULL; |
|
17992 char smsg[MAX_MSG_SIZE]; |
|
17993 char rmsg[MAX_MSG_SIZE]; |
|
17994 int index=0; |
|
17995 FILE *fp; |
|
17996 |
|
17997 int timeout = 200; |
|
17998 int nBytes; |
|
17999 TInt return_value = 0; |
|
18000 int result = 0; |
|
18001 int err = 0; |
|
18002 int status = 0; |
|
18003 message_hdr_req *msgHdr = NULL; |
|
18004 message_hdr_resp* msg_struct = NULL; |
|
18005 |
|
18006 // Read data from the CFG file |
|
18007 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
18008 { |
|
18009 iLog->Log ( _L ( "read_data failed" ) ); |
|
18010 free_data ( connect_data ); |
|
18011 return_value = KErrGeneral; |
|
18012 goto return_code; |
|
18013 } |
|
18014 //request formation |
|
18015 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18016 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18017 |
|
18018 //message header use |
|
18019 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
18020 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18021 |
|
18022 msgHdr->message_type = ELogin_Request; |
|
18023 |
|
18024 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18025 index += sizeof( message_hdr_req ); |
|
18026 |
|
18027 int len = strlen(connect_data->username); |
|
18028 strcpy( smsg + index, connect_data->username ); |
|
18029 index += len + 1; |
|
18030 |
|
18031 //appending password |
|
18032 |
|
18033 len = strlen(connect_data->password ); |
|
18034 strcpy( smsg + index, connect_data->password ); |
|
18035 index += len + 1; |
|
18036 |
|
18037 //appending server name |
|
18038 |
|
18039 len = strlen(connect_data->server ); |
|
18040 strcpy( smsg + index, connect_data->server ); |
|
18041 index += len + 1; |
|
18042 |
|
18043 //appending resource |
|
18044 len = strlen(connect_data->resource ); |
|
18045 strcpy( smsg + index, connect_data->resource ); |
|
18046 index += len + 1; |
|
18047 |
|
18048 //appending ssl |
|
18049 smsg[index++]= '0'; |
|
18050 smsg[index++]= '\0'; |
|
18051 |
|
18052 //appending server port |
|
18053 len = strlen(connect_data->port ); |
|
18054 strcpy( smsg + index, connect_data->port ); |
|
18055 index += len + 1; |
|
18056 |
|
18057 // appending IAP id |
|
18058 |
|
18059 smsg[index++]= '1'; |
|
18060 smsg[index++]= '\0'; |
|
18061 |
|
18062 //appending connmgr_bus |
|
18063 len = strlen(connect_data->connmgr_bus ); |
|
18064 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
18065 index += len + 1; |
|
18066 |
|
18067 //appending connmgr_path |
|
18068 len = strlen(connect_data->connmgr_path ); |
|
18069 strcpy( smsg + index, connect_data->connmgr_path ); |
|
18070 index += len + 1; |
|
18071 |
|
18072 //appending protocol |
|
18073 len = strlen(connect_data->protocol ); |
|
18074 strcpy( smsg + index, connect_data->protocol ); |
|
18075 index += len + 1; |
|
18076 |
|
18077 #ifdef __WINSCW__ |
|
18078 //proxy server |
|
18079 len = strlen(connect_data->proxy_data->proxy_server ); |
|
18080 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
18081 index += len + 1; |
|
18082 |
|
18083 //proxy port |
|
18084 len = strlen(connect_data->proxy_data->proxy_port ); |
|
18085 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
18086 index += len + 1; |
|
18087 |
|
18088 #endif |
|
18089 run_isoserver(); |
|
18090 |
|
18091 //create message queue for send request |
|
18092 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18093 //create message queue for response request |
|
18094 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18095 |
|
18096 |
|
18097 /* Send Message to queueOne */ |
|
18098 |
|
18099 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18100 |
|
18101 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
18102 |
|
18103 if (status < 0) |
|
18104 { |
|
18105 return_value = KErrGeneral; |
|
18106 goto return_code; |
|
18107 } |
|
18108 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
18109 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
18110 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18111 |
|
18112 if( msg_struct->response != 1) |
|
18113 { |
|
18114 return_value = KErrGeneral; |
|
18115 goto return_code; |
|
18116 } |
|
18117 |
|
18118 |
|
18119 // login end |
|
18120 //fetch req.. |
|
18121 for (int i= 0 ;i<3 ;i++) |
|
18122 { |
|
18123 |
|
18124 fp = fopen("c:\\fetch_contact.txt","a"); |
|
18125 do { |
|
18126 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18127 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18128 fwrite(rmsg,1,status,fp); |
|
18129 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18130 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
18131 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
18132 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
18133 fclose(fp); |
|
18134 |
|
18135 } |
|
18136 |
|
18137 //fetch end |
|
18138 |
|
18139 |
|
18140 |
|
18141 // get search keys test code from server |
|
18142 index=0; |
|
18143 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18144 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18145 |
|
18146 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18147 |
|
18148 msgHdr->message_type = ESearch_Get_Keys; |
|
18149 |
|
18150 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18151 index += sizeof( message_hdr_req ); |
|
18152 |
|
18153 |
|
18154 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18155 do { |
|
18156 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18157 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18158 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18159 |
|
18160 } while (msg_struct->hdr_req.message_type!= ESearch_Get_Keys ); |
|
18161 |
|
18162 if ( msg_struct->response != 1) |
|
18163 { |
|
18164 return_value = KErrGeneral; |
|
18165 goto return_code; |
|
18166 } |
|
18167 |
|
18168 int length = sizeof( message_hdr_resp ); |
|
18169 char* search_value = NULL; |
|
18170 do { |
|
18171 search_value = strdup ( rmsg + length ); |
|
18172 |
|
18173 if ( !search_value ) |
|
18174 { |
|
18175 return_value = KErrGeneral; |
|
18176 goto return_code; |
|
18177 } |
|
18178 length += strlen( search_value ) + 1; |
|
18179 } while ( ( 0 != strcmp( "First Name", search_value ) ) |
|
18180 && length < status &&( free ( search_value ), search_value = NULL, 1 ) ); |
|
18181 |
|
18182 |
|
18183 |
|
18184 |
|
18185 //search messge-------------------------------------------- |
|
18186 |
|
18187 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18188 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18189 index=0; |
|
18190 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18191 msgHdr->message_type = ESearch; |
|
18192 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18193 index += sizeof( message_hdr_req ); |
|
18194 |
|
18195 |
|
18196 // adding key |
|
18197 len = strlen( search_value ); |
|
18198 strcpy( smsg + index, search_value ); |
|
18199 index += len + 1; |
|
18200 |
|
18201 // adding value |
|
18202 len = strlen( "santhosh" ); |
|
18203 strcpy( smsg + index, "santhosh" ); |
|
18204 index += len + 1; |
|
18205 |
|
18206 smsg[index++] = '\0'; |
|
18207 |
|
18208 gint temp = 0; |
|
18209 gchar* add_contact = NULL; |
|
18210 |
|
18211 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18212 do |
|
18213 { |
|
18214 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18215 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18216 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18217 |
|
18218 } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished ); |
|
18219 |
|
18220 if ( msg_struct->response != 1 ) |
|
18221 { |
|
18222 return_value = KErrGeneral; |
|
18223 goto return_code; |
|
18224 } |
|
18225 |
|
18226 //search message end--------------------------------------- |
|
18227 |
|
18228 |
|
18229 // logout test code from server |
|
18230 index=0; |
|
18231 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18232 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18233 |
|
18234 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18235 |
|
18236 msgHdr->message_type = ELogout_Request; |
|
18237 |
|
18238 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18239 index += sizeof( message_hdr_req ); |
|
18240 |
|
18241 |
|
18242 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18243 do { |
|
18244 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18245 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18246 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18247 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
18248 |
|
18249 if ( msg_struct->response != 1) |
|
18250 { |
|
18251 return_value = KErrGeneral; |
|
18252 goto return_code; |
|
18253 } |
|
18254 |
|
18255 // result = MsgQDelete(REQUEST_QUEUE, &err); |
|
18256 // result = MsgQDelete(RESPONSE_QUEUE, &err); |
|
18257 return_value = KErrNone; |
|
18258 goto return_code; |
|
18259 |
|
18260 //killing isoserver |
|
18261 return_code: |
|
18262 index=0; |
|
18263 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18264 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18265 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18266 msgHdr->message_type = EKill_Process; |
|
18267 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18268 index += sizeof( message_hdr_req ); |
|
18269 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18270 free( msg_struct ); |
|
18271 return return_value; |
|
18272 } |
|
18273 |
|
18274 // ----------------------------------------------------------------------------- |
|
18275 // Cisolationserver::set avatar |
|
18276 // Example test method function. |
|
18277 // (other items were commented in a header). |
|
18278 // ----------------------------------------------------------------------------- |
|
18279 // |
|
18280 TInt Cisolationserver::SetOwnAvatar( CStifItemParser& aItem ) |
|
18281 { |
|
18282 |
|
18283 |
|
18284 ConnectData *connect_data = NULL; |
|
18285 char smsg[MAX_MSG_SIZE]; |
|
18286 char rmsg[MAX_MSG_SIZE]; |
|
18287 int index=0; |
|
18288 FILE *fp; |
|
18289 |
|
18290 int timeout = 200; |
|
18291 int nBytes; |
|
18292 |
|
18293 int result = 0; |
|
18294 int err = 0; |
|
18295 int status = 0; |
|
18296 message_hdr_req *msgHdr = NULL; |
|
18297 message_hdr_resp* msg_struct = NULL; |
|
18298 TInt return_value = 0; |
|
18299 // Read data from the CFG file |
|
18300 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
18301 { |
|
18302 iLog->Log ( _L ( "read_data failed" ) ); |
|
18303 free_data ( connect_data ); |
|
18304 return_value = KErrGeneral; |
|
18305 goto return_code; |
|
18306 } |
|
18307 //request formation |
|
18308 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18309 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18310 |
|
18311 //message header use |
|
18312 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
18313 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18314 |
|
18315 msgHdr->message_type = ELogin_Request; |
|
18316 |
|
18317 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18318 index += sizeof( message_hdr_req ); |
|
18319 |
|
18320 int len = strlen(connect_data->username); |
|
18321 strcpy( smsg + index, connect_data->username ); |
|
18322 index += len + 1; |
|
18323 |
|
18324 //appending password |
|
18325 |
|
18326 len = strlen(connect_data->password ); |
|
18327 strcpy( smsg + index, connect_data->password ); |
|
18328 index += len + 1; |
|
18329 |
|
18330 //appending server name |
|
18331 |
|
18332 len = strlen(connect_data->server ); |
|
18333 strcpy( smsg + index, connect_data->server ); |
|
18334 index += len + 1; |
|
18335 |
|
18336 //appending resource |
|
18337 len = strlen(connect_data->resource ); |
|
18338 strcpy( smsg + index, connect_data->resource ); |
|
18339 index += len + 1; |
|
18340 |
|
18341 //appending ssl |
|
18342 smsg[index++]= '1'; |
|
18343 smsg[index++]= '\0'; |
|
18344 |
|
18345 //appending server port |
|
18346 len = strlen(connect_data->port ); |
|
18347 strcpy( smsg + index, connect_data->port ); |
|
18348 index += len + 1; |
|
18349 |
|
18350 // appending IAP id |
|
18351 |
|
18352 smsg[index++]= '1'; |
|
18353 smsg[index++]= '\0'; |
|
18354 |
|
18355 //appending connmgr_bus |
|
18356 len = strlen(connect_data->connmgr_bus ); |
|
18357 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
18358 index += len + 1; |
|
18359 |
|
18360 //appending connmgr_path |
|
18361 len = strlen(connect_data->connmgr_path ); |
|
18362 strcpy( smsg + index, connect_data->connmgr_path ); |
|
18363 index += len + 1; |
|
18364 |
|
18365 //appending protocol |
|
18366 len = strlen(connect_data->protocol ); |
|
18367 strcpy( smsg + index, connect_data->protocol ); |
|
18368 index += len + 1; |
|
18369 |
|
18370 #ifdef __WINSCW__ |
|
18371 //proxy server |
|
18372 len = strlen(connect_data->proxy_data->proxy_server ); |
|
18373 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
18374 index += len + 1; |
|
18375 |
|
18376 //proxy port |
|
18377 len = strlen(connect_data->proxy_data->proxy_port ); |
|
18378 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
18379 index += len + 1; |
|
18380 |
|
18381 #endif |
|
18382 |
|
18383 //running isoserver |
|
18384 run_isoserver(); |
|
18385 |
|
18386 |
|
18387 //create message queue for send request |
|
18388 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18389 //create message queue for response request |
|
18390 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18391 |
|
18392 |
|
18393 /* Send Message to queueOne */ |
|
18394 |
|
18395 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18396 |
|
18397 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
18398 |
|
18399 if (status < 0) |
|
18400 { |
|
18401 return_value = KErrGeneral; |
|
18402 goto return_code; |
|
18403 } |
|
18404 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
18405 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
18406 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18407 |
|
18408 if( msg_struct->response != 1) |
|
18409 { |
|
18410 return_value = KErrGeneral; |
|
18411 goto return_code; |
|
18412 } |
|
18413 |
|
18414 |
|
18415 // login end |
|
18416 |
|
18417 //fetch req.. |
|
18418 for (int i= 0 ;i<3 ;i++) |
|
18419 { |
|
18420 |
|
18421 fp = fopen("c:\\fetch_contact.txt","a"); |
|
18422 do { |
|
18423 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18424 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18425 fwrite(rmsg,1,status,fp); |
|
18426 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18427 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
18428 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
18429 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
18430 fclose(fp); |
|
18431 |
|
18432 } |
|
18433 |
|
18434 //fetch end |
|
18435 //set avatar |
|
18436 TPtrC filename; |
|
18437 TPtrC mimetype; |
|
18438 gchar *file_name; |
|
18439 gchar *mime_type; |
|
18440 gchar *filecontent; |
|
18441 int n; |
|
18442 TBuf8<KMaxFileName> temp; |
|
18443 |
|
18444 index = 0; |
|
18445 index += sizeof( message_hdr_req ); |
|
18446 // setting avatar |
|
18447 FILE *file; |
|
18448 char *buffer; |
|
18449 unsigned long fileLen; |
|
18450 |
|
18451 //Open file |
|
18452 file = fopen(connect_data->image_file_name, "rb"); |
|
18453 if (!file) |
|
18454 { |
|
18455 fprintf(stderr, "Unable to open file %s", file_name); |
|
18456 return; |
|
18457 } |
|
18458 |
|
18459 //Get file length |
|
18460 fseek(file, 0, SEEK_END); |
|
18461 fileLen=ftell(file); |
|
18462 fseek(file, 0, SEEK_SET); |
|
18463 |
|
18464 |
|
18465 //strcpy(mime_type,"image\jpeg"); |
|
18466 len = fileLen + strlen(connect_data->mimetype) + 1; |
|
18467 buffer=(char *)malloc(len); |
|
18468 if (!buffer) |
|
18469 { |
|
18470 fprintf(stderr, "Memory error!"); |
|
18471 fclose(file); |
|
18472 return; |
|
18473 } |
|
18474 memset( buffer, '\0', len ); |
|
18475 memcpy( buffer, connect_data->mimetype, strlen(connect_data->mimetype) ); |
|
18476 //Read file contents into buffer |
|
18477 |
|
18478 fread(buffer + strlen(connect_data->mimetype) + 1, fileLen, 1, file); |
|
18479 fclose(file); |
|
18480 |
|
18481 //Do what ever with buffer |
|
18482 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18483 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18484 index=0; |
|
18485 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18486 msgHdr->message_type = EUpdateOwnAvtar; |
|
18487 // memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18488 /* Send Message to queueOne */ |
|
18489 TInt header_size = sizeof( message_hdr_req ); |
|
18490 //crashes for perticuler image.Need to fix |
|
18491 char* one_pdu = ( char* ) malloc( ONE_K_OPENC_FIX ); |
|
18492 //run a loop for rest of the data and keep track of the case of nBytes being |
|
18493 //multiple of 1020 - sizeof(msghdr) and it being not |
|
18494 //Amount of payload that can be sent |
|
18495 TInt single_read = ONE_K_OPENC_FIX - header_size; |
|
18496 //Data recieved from PublishOwnPresenceL has message header at begining |
|
18497 TInt actual_data = fileLen; |
|
18498 //No of packets needed to send the image data |
|
18499 TInt total_packets = (TInt)ceil( ( double ) ( actual_data ) / single_read ); |
|
18500 //This offset moves thru the msg pointer |
|
18501 TInt navigate_offset = 0; |
|
18502 for ( TInt i = 0; i < total_packets; i++ ) |
|
18503 { |
|
18504 //till the last packet size_tobe_sent will be ONE_K_OPENC_FIX |
|
18505 //last packet data is actual_data % single_read if less than single_read else ONE_K_OPENC_FIX |
|
18506 TInt size_tobe_sent = ( i < total_packets - 1 ) ? ONE_K_OPENC_FIX : |
|
18507 ( actual_data % single_read ? |
|
18508 actual_data % single_read + header_size : ONE_K_OPENC_FIX ); |
|
18509 |
|
18510 if ( i < total_packets - 1 ) |
|
18511 { |
|
18512 msgHdr->continue_flag = 1; |
|
18513 } |
|
18514 else |
|
18515 { |
|
18516 msgHdr->continue_flag = 0; |
|
18517 } |
|
18518 |
|
18519 //memcpy ( msg + header_size , msg + navigate_offset, size_tobe_sent - header_size ); |
|
18520 memcpy( one_pdu , msgHdr, header_size ); |
|
18521 memcpy( one_pdu + header_size, buffer + navigate_offset, size_tobe_sent - header_size ); |
|
18522 result = MsgQSend ( REQUEST_QUEUE, one_pdu, size_tobe_sent, |
|
18523 MSG_PRI_NORMAL, timeout, &err ); |
|
18524 User::LeaveIfError ( result ); |
|
18525 navigate_offset += single_read; |
|
18526 } |
|
18527 free(one_pdu); |
|
18528 free(buffer); |
|
18529 do { |
|
18530 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18531 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18532 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18533 } while (msg_struct->hdr_req.message_type!=EUpdateOwnAvtar); |
|
18534 |
|
18535 if ( msg_struct->response != 1) |
|
18536 { |
|
18537 return_value = KErrGeneral; |
|
18538 goto return_code; |
|
18539 } |
|
18540 |
|
18541 //set avatar end |
|
18542 // logout test code from server |
|
18543 index=0; |
|
18544 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18545 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18546 |
|
18547 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18548 |
|
18549 msgHdr->message_type = ELogout_Request; |
|
18550 |
|
18551 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18552 index += sizeof( message_hdr_req ); |
|
18553 |
|
18554 |
|
18555 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18556 do { |
|
18557 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18558 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18559 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18560 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
18561 |
|
18562 if ( msg_struct->response != 1) |
|
18563 { |
|
18564 return_value = KErrGeneral; |
|
18565 goto return_code; |
|
18566 } |
|
18567 //killing isoserver |
|
18568 return_code: |
|
18569 index=0; |
|
18570 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18571 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18572 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18573 msgHdr->message_type = EKill_Process; |
|
18574 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18575 index += sizeof( message_hdr_req ); |
|
18576 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18577 free( msg_struct ); |
|
18578 return return_value; |
|
18579 } |
|
18580 |
|
18581 // ----------------------------------------------------------------------------- |
|
18582 // Cisolationserver::clear avatar |
|
18583 // Example test method function. |
|
18584 // (other items were commented in a header). |
|
18585 // ----------------------------------------------------------------------------- |
|
18586 // |
|
18587 TInt Cisolationserver::ClearOwnAvatar( CStifItemParser& aItem ) |
|
18588 { |
|
18589 |
|
18590 |
|
18591 ConnectData *connect_data = NULL; |
|
18592 char smsg[MAX_MSG_SIZE]; |
|
18593 char rmsg[MAX_MSG_SIZE]; |
|
18594 int index=0; |
|
18595 FILE *fp; |
|
18596 |
|
18597 int timeout = 200; |
|
18598 int nBytes; |
|
18599 |
|
18600 int result = 0; |
|
18601 int err = 0; |
|
18602 int status = 0; |
|
18603 message_hdr_req *msgHdr = NULL; |
|
18604 message_hdr_resp* msg_struct = NULL; |
|
18605 TInt return_value = 0; |
|
18606 // Read data from the CFG file |
|
18607 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
18608 { |
|
18609 iLog->Log ( _L ( "read_data failed" ) ); |
|
18610 free_data ( connect_data ); |
|
18611 return_value = KErrGeneral; |
|
18612 goto return_code; |
|
18613 } |
|
18614 //request formation |
|
18615 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18616 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18617 |
|
18618 //message header use |
|
18619 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
18620 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18621 |
|
18622 msgHdr->message_type = ELogin_Request; |
|
18623 |
|
18624 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18625 index += sizeof( message_hdr_req ); |
|
18626 |
|
18627 int len = strlen(connect_data->username); |
|
18628 strcpy( smsg + index, connect_data->username ); |
|
18629 index += len + 1; |
|
18630 |
|
18631 //appending password |
|
18632 |
|
18633 len = strlen(connect_data->password ); |
|
18634 strcpy( smsg + index, connect_data->password ); |
|
18635 index += len + 1; |
|
18636 |
|
18637 //appending server name |
|
18638 |
|
18639 len = strlen(connect_data->server ); |
|
18640 strcpy( smsg + index, connect_data->server ); |
|
18641 index += len + 1; |
|
18642 |
|
18643 //appending resource |
|
18644 len = strlen(connect_data->resource ); |
|
18645 strcpy( smsg + index, connect_data->resource ); |
|
18646 index += len + 1; |
|
18647 |
|
18648 //appending ssl |
|
18649 smsg[index++]= '1'; |
|
18650 smsg[index++]= '\0'; |
|
18651 |
|
18652 //appending server port |
|
18653 len = strlen(connect_data->port ); |
|
18654 strcpy( smsg + index, connect_data->port ); |
|
18655 index += len + 1; |
|
18656 |
|
18657 // appending IAP id |
|
18658 |
|
18659 smsg[index++]= '1'; |
|
18660 smsg[index++]= '\0'; |
|
18661 |
|
18662 //appending connmgr_bus |
|
18663 len = strlen(connect_data->connmgr_bus ); |
|
18664 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
18665 index += len + 1; |
|
18666 |
|
18667 //appending connmgr_path |
|
18668 len = strlen(connect_data->connmgr_path ); |
|
18669 strcpy( smsg + index, connect_data->connmgr_path ); |
|
18670 index += len + 1; |
|
18671 |
|
18672 //appending protocol |
|
18673 len = strlen(connect_data->protocol ); |
|
18674 strcpy( smsg + index, connect_data->protocol ); |
|
18675 index += len + 1; |
|
18676 |
|
18677 #ifdef __WINSCW__ |
|
18678 //proxy server |
|
18679 len = strlen(connect_data->proxy_data->proxy_server ); |
|
18680 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
18681 index += len + 1; |
|
18682 |
|
18683 //proxy port |
|
18684 len = strlen(connect_data->proxy_data->proxy_port ); |
|
18685 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
18686 index += len + 1; |
|
18687 |
|
18688 #endif |
|
18689 |
|
18690 //running isoserver |
|
18691 run_isoserver(); |
|
18692 |
|
18693 |
|
18694 //create message queue for send request |
|
18695 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18696 //create message queue for response request |
|
18697 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18698 |
|
18699 |
|
18700 /* Send Message to queueOne */ |
|
18701 |
|
18702 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18703 |
|
18704 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
18705 |
|
18706 if (status < 0) |
|
18707 { |
|
18708 return_value = KErrGeneral; |
|
18709 goto return_code; |
|
18710 } |
|
18711 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
18712 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
18713 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18714 |
|
18715 if( msg_struct->response != 1) |
|
18716 { |
|
18717 return_value = KErrGeneral; |
|
18718 goto return_code; |
|
18719 } |
|
18720 |
|
18721 |
|
18722 // login end |
|
18723 |
|
18724 //fetch req.. |
|
18725 for (int i= 0 ;i<3 ;i++) |
|
18726 { |
|
18727 |
|
18728 fp = fopen("c:\\fetch_contact.txt","a"); |
|
18729 do { |
|
18730 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18731 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18732 fwrite(rmsg,1,status,fp); |
|
18733 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18734 } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
18735 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
18736 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag); |
|
18737 fclose(fp); |
|
18738 |
|
18739 } |
|
18740 |
|
18741 //fetch end |
|
18742 |
|
18743 //clear avatar |
|
18744 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18745 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18746 index=0; |
|
18747 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18748 msgHdr->message_type = EClearOwnAvatar; |
|
18749 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18750 index += sizeof( message_hdr_req ); |
|
18751 smsg[index++]='\0'; |
|
18752 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18753 do { |
|
18754 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18755 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18756 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18757 } while (msg_struct->hdr_req.message_type!=EClearOwnAvatar); |
|
18758 |
|
18759 if ( msg_struct->response != 1) |
|
18760 { |
|
18761 return_value = KErrGeneral; |
|
18762 goto return_code; |
|
18763 } |
|
18764 //clear avatar end |
|
18765 // logout test code from server |
|
18766 index=0; |
|
18767 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18768 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18769 |
|
18770 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18771 |
|
18772 msgHdr->message_type = ELogout_Request; |
|
18773 |
|
18774 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18775 index += sizeof( message_hdr_req ); |
|
18776 |
|
18777 |
|
18778 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18779 do { |
|
18780 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18781 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18782 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18783 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
18784 |
|
18785 if ( msg_struct->response != 1) |
|
18786 { |
|
18787 return_value = KErrGeneral; |
|
18788 goto return_code; |
|
18789 } |
|
18790 //killing isoserver |
|
18791 return_code: |
|
18792 index=0; |
|
18793 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18794 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18795 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18796 msgHdr->message_type = EKill_Process; |
|
18797 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18798 index += sizeof( message_hdr_req ); |
|
18799 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18800 free( msg_struct ); |
|
18801 return return_value; |
|
18802 } |
|
18803 |
|
18804 |
|
18805 // ----------------------------------------------------------------------------- |
|
18806 // Cisolationserver::clear avatar |
|
18807 // Example test method function. |
|
18808 // (other items were commented in a header). |
|
18809 // ----------------------------------------------------------------------------- |
|
18810 // |
|
18811 TInt Cisolationserver::FetchCachedContacts( CStifItemParser& aItem ) |
|
18812 { |
|
18813 |
|
18814 |
|
18815 ConnectData *connect_data = NULL; |
|
18816 char smsg[MAX_MSG_SIZE]; |
|
18817 char rmsg[MAX_MSG_SIZE]; |
|
18818 int index=0; |
|
18819 FILE *fp; |
|
18820 |
|
18821 int timeout = 200; |
|
18822 int nBytes; |
|
18823 |
|
18824 int result = 0; |
|
18825 int err = 0; |
|
18826 int status = 0; |
|
18827 message_hdr_req *msgHdr = NULL; |
|
18828 message_hdr_resp* msg_struct = NULL; |
|
18829 TInt return_value = 0; |
|
18830 // Read data from the CFG file |
|
18831 if ( read_data ( connect_data, aItem ) != RC_OK ) |
|
18832 { |
|
18833 iLog->Log ( _L ( "read_data failed" ) ); |
|
18834 free_data ( connect_data ); |
|
18835 return_value = KErrGeneral; |
|
18836 goto return_code; |
|
18837 } |
|
18838 //request formation |
|
18839 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18840 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18841 |
|
18842 //message header use |
|
18843 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
18844 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18845 |
|
18846 msgHdr->message_type = ELogin_Request; |
|
18847 |
|
18848 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18849 index += sizeof( message_hdr_req ); |
|
18850 |
|
18851 int len = strlen(connect_data->username); |
|
18852 strcpy( smsg + index, connect_data->username ); |
|
18853 index += len + 1; |
|
18854 |
|
18855 //appending password |
|
18856 |
|
18857 len = strlen(connect_data->password ); |
|
18858 strcpy( smsg + index, connect_data->password ); |
|
18859 index += len + 1; |
|
18860 |
|
18861 //appending server name |
|
18862 |
|
18863 len = strlen(connect_data->server ); |
|
18864 strcpy( smsg + index, connect_data->server ); |
|
18865 index += len + 1; |
|
18866 |
|
18867 //appending resource |
|
18868 len = strlen(connect_data->resource ); |
|
18869 strcpy( smsg + index, connect_data->resource ); |
|
18870 index += len + 1; |
|
18871 |
|
18872 //appending ssl |
|
18873 smsg[index++]= '1'; |
|
18874 smsg[index++]= '\0'; |
|
18875 |
|
18876 //appending server port |
|
18877 len = strlen(connect_data->port ); |
|
18878 strcpy( smsg + index, connect_data->port ); |
|
18879 index += len + 1; |
|
18880 |
|
18881 // appending IAP id |
|
18882 |
|
18883 smsg[index++]= '1'; |
|
18884 smsg[index++]= '\0'; |
|
18885 |
|
18886 //appending connmgr_bus |
|
18887 len = strlen(connect_data->connmgr_bus ); |
|
18888 strcpy( smsg + index, connect_data->connmgr_bus ); |
|
18889 index += len + 1; |
|
18890 |
|
18891 //appending connmgr_path |
|
18892 len = strlen(connect_data->connmgr_path ); |
|
18893 strcpy( smsg + index, connect_data->connmgr_path ); |
|
18894 index += len + 1; |
|
18895 |
|
18896 //appending protocol |
|
18897 len = strlen(connect_data->protocol ); |
|
18898 strcpy( smsg + index, connect_data->protocol ); |
|
18899 index += len + 1; |
|
18900 |
|
18901 #ifdef __WINSCW__ |
|
18902 //proxy server |
|
18903 len = strlen(connect_data->proxy_data->proxy_server ); |
|
18904 strcpy( smsg + index, connect_data->proxy_data->proxy_server ); |
|
18905 index += len + 1; |
|
18906 |
|
18907 //proxy port |
|
18908 len = strlen(connect_data->proxy_data->proxy_port ); |
|
18909 strcpy( smsg + index, connect_data->proxy_data->proxy_port ); |
|
18910 index += len + 1; |
|
18911 |
|
18912 #endif |
|
18913 |
|
18914 //running isoserver |
|
18915 run_isoserver(); |
|
18916 |
|
18917 |
|
18918 //create message queue for send request |
|
18919 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18920 //create message queue for response request |
|
18921 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
18922 |
|
18923 |
|
18924 /* Send Message to queueOne */ |
|
18925 |
|
18926 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18927 |
|
18928 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
18929 |
|
18930 if (status < 0) |
|
18931 { |
|
18932 return_value = KErrGeneral; |
|
18933 goto return_code; |
|
18934 } |
|
18935 msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) ); |
|
18936 memset( msg_struct, '\0', sizeof( message_hdr_resp ) ); |
|
18937 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18938 |
|
18939 if( msg_struct->response != 1) |
|
18940 { |
|
18941 return_value = KErrGeneral; |
|
18942 goto return_code; |
|
18943 } |
|
18944 |
|
18945 |
|
18946 // login end |
|
18947 |
|
18948 //fetch req.. |
|
18949 TInt count = 0; |
|
18950 |
|
18951 fp = fopen("c:\\fetch_contact.txt","a"); |
|
18952 do { |
|
18953 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18954 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18955 fwrite(rmsg,1,status,fp); |
|
18956 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18957 |
|
18958 if ( (msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
18959 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
18960 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts) && 0 == msg_struct->continue_flag ) |
|
18961 { |
|
18962 count++; |
|
18963 } |
|
18964 |
|
18965 |
|
18966 } while (count < 3 ); |
|
18967 fclose(fp); |
|
18968 |
|
18969 |
|
18970 |
|
18971 |
|
18972 //fetch end |
|
18973 FILE* fop = NULL; |
|
18974 //clear avatar |
|
18975 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
18976 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18977 index=0; |
|
18978 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
18979 msgHdr->message_type = EFetchCachedContacts; |
|
18980 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
18981 index += sizeof( message_hdr_req ); |
|
18982 smsg[index++]='\0'; |
|
18983 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
18984 fop = fopen("c:\\santhosh.txt","a"); |
|
18985 count = 0; |
|
18986 do { |
|
18987 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
18988 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
18989 fwrite(rmsg,1,status,fop); |
|
18990 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
18991 |
|
18992 if ( ((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) |
|
18993 ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) |
|
18994 ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts)) && 0 == msg_struct->continue_flag ) |
|
18995 { |
|
18996 count++; |
|
18997 } |
|
18998 |
|
18999 |
|
19000 } while (count < 3 ); |
|
19001 fclose(fop); |
|
19002 |
|
19003 //clear avatar end |
|
19004 // logout test code from server |
|
19005 index=0; |
|
19006 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
19007 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
19008 |
|
19009 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
19010 |
|
19011 msgHdr->message_type = ELogout_Request; |
|
19012 |
|
19013 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
19014 index += sizeof( message_hdr_req ); |
|
19015 |
|
19016 |
|
19017 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
19018 do { |
|
19019 status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); |
|
19020 memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); |
|
19021 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
19022 } while (msg_struct->hdr_req.message_type!=ELogout_Request); |
|
19023 |
|
19024 if ( msg_struct->response != 1) |
|
19025 { |
|
19026 return_value = KErrGeneral; |
|
19027 goto return_code; |
|
19028 } |
|
19029 //killing isoserver |
|
19030 return_code: |
|
19031 index=0; |
|
19032 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
19033 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
19034 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
19035 msgHdr->message_type = EKill_Process; |
|
19036 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
19037 index += sizeof( message_hdr_req ); |
|
19038 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
19039 free( msg_struct ); |
|
19040 return return_value; |
|
19041 } |
|
19042 |
|
19043 // ----------------------------------------------------------------------------- |
|
19044 // Cisolationserver::?member_function |
|
19045 // ?implementation_description |
|
19046 // (other items were commented in a header). |
|
19047 // ----------------------------------------------------------------------------- |
|
19048 // |
|
19049 /* |
|
19050 TInt Cisolationserver::?member_function( |
|
19051 CItemParser& aItem ) |
|
19052 { |
|
19053 |
|
19054 ?code |
|
19055 |
|
19056 } |
|
19057 */ |
|
19058 |
|
19059 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
19060 // None |
|
19061 |
|
19062 // [End of File] - Do not remove |