isolationserver/tsrc/src/isolationserverBlocks.cpp
branchRCL_3
changeset 11 3404599e4dda
parent 9 46cc8e302e43
equal deleted inserted replaced
9:46cc8e302e43 11:3404599e4dda
     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 the License "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 
       
    21 // [INCLUDE FILES] - do not remove
       
    22 #include <e32svr.h>
       
    23 #include <StifParser.h>
       
    24 #include <StifTestInterface.h>
       
    25 #include "isolationserver.h"
       
    26 #include  <e32const.h>
       
    27 
       
    28 #include <glib.h>
       
    29 #include <glib/gprintf.h>           // for g_stpcpy
       
    30 #include <string.h>
       
    31 #include <stdlib.h>
       
    32 
       
    33 #include <glowmem.h>
       
    34 #include "msgliterals.h"
       
    35 #include "msg_enums.h"
       
    36 #include <math.h>
       
    37 #define ONE_K_OPENC_FIX 1020
       
    38 
       
    39 typedef enum
       
    40 {
       
    41 	RC_OK,
       
    42 	RC_ERROR
       
    43 } RC_Code_t;
       
    44 
       
    45 
       
    46 typedef struct
       
    47 {
       
    48 	gchar *recipient;
       
    49 	gchar *message;
       
    50 } MessageData;
       
    51 
       
    52 typedef struct
       
    53 {
       
    54 	gchar      *proxy_server;
       
    55 	gchar      *proxy_port;	
       
    56 }ProxyData;
       
    57 
       
    58 typedef struct
       
    59 {
       
    60 	gchar       *server;
       
    61 	gchar       *username;
       
    62 	gchar       *password;		
       
    63 	gchar       *resource;
       
    64 	MessageData *msg_data;
       
    65 	gchar       *port;	
       
    66 
       
    67     ProxyData   *proxy_data;
       
    68     gchar       *contact;
       
    69     gchar		*connmgr_bus;
       
    70     gchar		*connmgr_path;
       
    71     gchar		*protocol; 
       
    72     gchar		*key_given_name;
       
    73     gchar		*key_middle_name;
       
    74     gchar		*key_jid;
       
    75     gchar		*key_full_name;
       
    76     gchar       *mimetype;
       
    77     gchar       *image_file_name; 
       
    78 
       
    79 } ConnectData;
       
    80 
       
    81 
       
    82 // Function to read data from the cfg file
       
    83 static RC_Code_t read_data ( ConnectData*& connect_data, 
       
    84                              CStifItemParser& aItem );
       
    85                              
       
    86 // Function to free the allocated resources
       
    87 static void free_data ( ConnectData*& connect_data );                             
       
    88 
       
    89 // EXTERNAL DATA STRUCTURES
       
    90 //extern  ?external_data;
       
    91 
       
    92 // EXTERNAL FUNCTION PROTOTYPES  
       
    93 //extern ?external_function( ?arg_type,?arg_type );
       
    94 
       
    95 // CONSTANTS
       
    96 //const ?type ?constant_var = ?constant;
       
    97 
       
    98 // MACROS
       
    99 //#define ?macro ?macro_def
       
   100 
       
   101 // LOCAL CONSTANTS AND MACROS
       
   102 //const ?type ?constant_var = ?constant;
       
   103 //#define ?macro_name ?macro_def
       
   104 
       
   105 // MODULE DATA STRUCTURES
       
   106 //enum ?declaration
       
   107 //typedef ?declaration
       
   108 
       
   109 // LOCAL FUNCTION PROTOTYPES
       
   110 //?type ?function_name( ?arg_type, ?arg_type );
       
   111 
       
   112 // FORWARD DECLARATIONS
       
   113 //class ?FORWARD_CLASSNAME;
       
   114 
       
   115 // ============================= LOCAL FUNCTIONS ===============================
       
   116 
       
   117 
       
   118 
       
   119 //-----------------------------------------------------------------------------
       
   120 // function_name	: read_data
       
   121 // description     	: Reads data from the CFG file
       
   122 // Returns          : None
       
   123 //-----------------------------------------------------------------------------
       
   124 //
       
   125 static RC_Code_t
       
   126 read_data ( ConnectData*& connect_data, CStifItemParser& aItem )
       
   127     {
       
   128 	TPtrC               string;
       
   129 	TBuf8<KMaxFileName> temp;
       
   130 	MessageData         *msg_data   = NULL;
       
   131 	
       
   132 
       
   133 	ProxyData           *proxy_data = NULL;
       
   134 //	TInt                proxy_port;
       
   135 
       
   136 
       
   137 	
       
   138 	connect_data = g_new0 ( ConnectData, 1 );
       
   139 	if ( !connect_data )
       
   140 	    {
       
   141 		return RC_ERROR;
       
   142 	    }
       
   143 	    
       
   144 	msg_data = g_new0 ( MessageData, 1 );
       
   145 	if ( !msg_data )
       
   146 	    {
       
   147 		free_data ( connect_data );
       
   148 		return RC_ERROR;
       
   149 	    }
       
   150 	
       
   151 	connect_data->msg_data = msg_data;
       
   152 	
       
   153 
       
   154     proxy_data = g_new0 ( ProxyData, 1 );
       
   155     if ( !proxy_data ) 
       
   156     	{
       
   157     	free_data ( connect_data );
       
   158     	return RC_ERROR;
       
   159     	}
       
   160 	connect_data->proxy_data = proxy_data;
       
   161 
       
   162 
       
   163 	// Read server name
       
   164 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   165 	    {
       
   166 		temp.Copy ( string );
       
   167 		temp.Append ( '\0' );
       
   168 		connect_data->server = g_new0 ( gchar, temp.Length() );
       
   169 		if ( !connect_data->server )
       
   170 		    {			
       
   171 			free_data ( connect_data );
       
   172 			return RC_ERROR;
       
   173 		    }
       
   174 		g_stpcpy ( connect_data->server, ( gchar * ) temp.Ptr() ); 
       
   175 	    }
       
   176 	    
       
   177 	// Read Username
       
   178 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   179 	    {
       
   180 	    temp.Copy ( string );
       
   181 	    temp.Append ( '\0' );
       
   182 	    connect_data->username = g_new0 ( gchar, temp.Length() );
       
   183 	    if ( !connect_data->username )
       
   184 	        {	    	
       
   185 	    	free_data ( connect_data );
       
   186 	    	return RC_ERROR;
       
   187 	        }
       
   188 	    g_stpcpy ( connect_data->username, ( gchar * ) temp.Ptr() );		    
       
   189 	    }
       
   190 	
       
   191 	// Read Password corresponding to Username
       
   192 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   193 	    {
       
   194 	    temp.Copy ( string );
       
   195 	    temp.Append ( '\0' );
       
   196 	    connect_data->password = g_new0 ( gchar, temp.Length () );		    
       
   197 	    if ( !connect_data->password )
       
   198 	        {	    	
       
   199 	    	free_data ( connect_data );
       
   200 	    	return RC_ERROR;
       
   201 	        }
       
   202 	    g_stpcpy ( connect_data->password, ( gchar *) temp.Ptr() );
       
   203 	    }
       
   204 	
       
   205 	// Read recipient
       
   206 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   207 	    {
       
   208 	    temp.Copy ( string );
       
   209 	    temp.Append ( '\0' );
       
   210 	    msg_data->recipient = g_new0 ( gchar, temp.Length() );
       
   211 	    if ( !msg_data->recipient )
       
   212 	        {
       
   213 	    	free_data ( connect_data );
       
   214 	    	return RC_ERROR;
       
   215 	        }
       
   216 	    g_stpcpy ( msg_data->recipient, ( gchar * ) temp.Ptr() );
       
   217 	    }
       
   218 	
       
   219 	// Read Message
       
   220 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   221 	    {
       
   222 	    temp.Copy ( string );
       
   223 	    temp.Append ( '\0' );	    
       
   224 	    msg_data->message = g_new0 ( gchar, temp.Length() );
       
   225 	    if ( !msg_data->message )
       
   226 	        {
       
   227 	    	free_data ( connect_data );
       
   228 	    	return RC_ERROR;
       
   229 	        }
       
   230 	    g_stpcpy ( msg_data->message, ( gchar * ) temp.Ptr() );
       
   231 	    }
       
   232 	
       
   233 	// Read resource identifier
       
   234 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   235 	    {
       
   236 	    temp.Copy ( string );
       
   237 	    temp.Append ( '\0' );
       
   238 	    connect_data->resource = g_new0 ( gchar, temp.Length() );
       
   239 	    if ( !connect_data->resource )
       
   240 	        {
       
   241 	    	free_data ( connect_data );
       
   242 	    	return RC_ERROR;
       
   243 	        }
       
   244 	    g_stpcpy ( connect_data->resource, ( gchar * ) temp.Ptr() );		    
       
   245 	    }
       
   246 	 
       
   247 
       
   248 	// Read proxy server and proxy port
       
   249     if ( aItem.GetNextString ( string ) == KErrNone )
       
   250     	{
       
   251     	temp.Copy ( string );
       
   252     	temp.Append ( '\0' );
       
   253     	proxy_data->proxy_server = g_new0 ( gchar, temp.Length() );
       
   254     	if ( !proxy_data->proxy_server )
       
   255     		{
       
   256     		free_data ( connect_data );
       
   257     		return RC_ERROR;
       
   258     		}
       
   259     	g_stpcpy ( proxy_data->proxy_server, ( gchar * ) temp.Ptr() );
       
   260     	}
       
   261     	
       
   262     	if ( aItem.GetNextString ( string ) == KErrNone )
       
   263     	{
       
   264     	temp.Copy ( string );
       
   265     	temp.Append ( '\0' );
       
   266     	proxy_data->proxy_port = g_new0 ( gchar, temp.Length() );
       
   267     	if ( !proxy_data->proxy_port )
       
   268     		{
       
   269     		free_data ( connect_data );
       
   270     		return RC_ERROR;
       
   271     		}
       
   272     	g_stpcpy ( proxy_data->proxy_port, ( gchar * ) temp.Ptr() );
       
   273     	}
       
   274     	
       
   275     	
       
   276     	
       
   277     /*	if ( aItem.GetNextString ( proxy_port ) == KErrNone )
       
   278     		{
       
   279     		proxy_data->proxy_port = proxy_port;
       
   280     		}  */  	
       
   281  
       
   282 
       
   283 	// Read POrt address
       
   284 	if ( aItem.GetNextString ( string ) == KErrNone )
       
   285 	    {
       
   286 	    temp.Copy ( string );
       
   287 	    temp.Append ( '\0' );
       
   288 	    connect_data->port = g_new0 ( gchar, temp.Length() );
       
   289 	    if ( !connect_data->port )
       
   290 	        {
       
   291 	    	free_data ( connect_data );
       
   292 	    	return RC_ERROR;
       
   293 	        }
       
   294 	    g_stpcpy ( connect_data->port, ( gchar * ) temp.Ptr() );		    
       
   295 	    }
       
   296   
       
   297   // read Add member
       
   298        if ( aItem.GetNextString ( string ) == KErrNone )
       
   299 	    {
       
   300 		temp.Copy ( string );
       
   301 		temp.Append ( '\0' );
       
   302 		connect_data->contact = g_new0 ( gchar, temp.Length() );
       
   303 		if ( !connect_data->contact )
       
   304 		    {			
       
   305 			free_data ( connect_data );
       
   306 			return RC_ERROR;
       
   307 		    }
       
   308 		g_stpcpy ( connect_data->contact, ( gchar * ) temp.Ptr() ); 
       
   309 	    }
       
   310   
       
   311    	// read CONNMGR_BUS
       
   312        if ( aItem.GetNextString ( string ) == KErrNone )
       
   313 	    {
       
   314 		temp.Copy ( string );
       
   315 		temp.Append ( '\0' );
       
   316 		connect_data->connmgr_bus = g_new0 ( gchar, temp.Length() );
       
   317 		if ( !connect_data->connmgr_bus )
       
   318 		    {			
       
   319 			free_data ( connect_data );
       
   320 			return RC_ERROR;
       
   321 		    }
       
   322 		g_stpcpy ( connect_data->connmgr_bus, ( gchar * ) temp.Ptr() ); 
       
   323 	    }
       
   324 	
       
   325 	// read CONNMGR_PATH
       
   326        if ( aItem.GetNextString ( string ) == KErrNone )
       
   327 	    {
       
   328 		temp.Copy ( string );
       
   329 		temp.Append ( '\0' );
       
   330 		connect_data->connmgr_path = g_new0 ( gchar, temp.Length() );
       
   331 		if ( !connect_data->connmgr_path )
       
   332 		    {			
       
   333 			free_data ( connect_data );
       
   334 			return RC_ERROR;
       
   335 		    }
       
   336 		g_stpcpy ( connect_data->connmgr_path, ( gchar * ) temp.Ptr() ); 
       
   337 	    }
       
   338 	    
       
   339 	// read PROTOCOL
       
   340        if ( aItem.GetNextString ( string ) == KErrNone )
       
   341 	    {
       
   342 		temp.Copy ( string );
       
   343 		temp.Append ( '\0' );
       
   344 		connect_data->protocol = g_new0 ( gchar, temp.Length() );
       
   345 		if ( !connect_data->protocol )
       
   346 		    {			
       
   347 			free_data ( connect_data );
       
   348 			return RC_ERROR;
       
   349 		    }
       
   350 		g_stpcpy ( connect_data->protocol, ( gchar * ) temp.Ptr() ); 
       
   351 	    }	 
       
   352 	        
       
   353     
       
   354 	    // read given Name
       
   355        if ( aItem.GetNextString ( string ) == KErrNone )
       
   356 	    {
       
   357 		temp.Copy ( string );
       
   358 		temp.Append ( '\0' );
       
   359 		connect_data->key_given_name = g_new0 ( gchar, temp.Length() );
       
   360 		if ( !connect_data->key_given_name )
       
   361 		    {			
       
   362 			free_data ( connect_data );
       
   363 			return RC_ERROR;
       
   364 		    }
       
   365 		g_stpcpy ( connect_data->key_given_name, ( gchar * ) temp.Ptr() ); 
       
   366 	    }	 
       
   367 	    
       
   368 	    // read middle Name
       
   369        if ( aItem.GetNextString ( string ) == KErrNone )
       
   370 	    {
       
   371 		temp.Copy ( string );
       
   372 		temp.Append ( '\0' );
       
   373 		connect_data->key_middle_name = g_new0 ( gchar, temp.Length() );
       
   374 		if ( !connect_data->key_middle_name )
       
   375 		    {			
       
   376 			free_data ( connect_data );
       
   377 			return RC_ERROR;
       
   378 		    }
       
   379 		g_stpcpy ( connect_data->key_middle_name, ( gchar * ) temp.Ptr() ); 
       
   380 	    }	 
       
   381 	    
       
   382 	    // read email Name
       
   383        if ( aItem.GetNextString ( string ) == KErrNone )
       
   384 	    {
       
   385 		temp.Copy ( string );
       
   386 		temp.Append ( '\0' );
       
   387 		connect_data->key_jid = g_new0 ( gchar, temp.Length() );
       
   388 		if ( !connect_data->key_jid )
       
   389 		    {			
       
   390 			free_data ( connect_data );
       
   391 			return RC_ERROR;
       
   392 		    }
       
   393 		g_stpcpy ( connect_data->key_jid, ( gchar * ) temp.Ptr() ); 
       
   394 	    }	 
       
   395 	    
       
   396 	    // read full Name
       
   397        if ( aItem.GetNextString ( string ) == KErrNone )
       
   398 	    {
       
   399 		temp.Copy ( string );
       
   400 		temp.Append ( '\0' );
       
   401 		connect_data->key_full_name = g_new0 ( gchar, temp.Length() );
       
   402 		if ( !connect_data->key_full_name )
       
   403 		    {			
       
   404 			free_data ( connect_data );
       
   405 			return RC_ERROR;
       
   406 		    }
       
   407 		g_stpcpy ( connect_data->key_full_name, ( gchar * ) temp.Ptr() ); 
       
   408 	    }	 
       
   409        // read mimetype
       
   410        if ( aItem.GetNextString ( string ) == KErrNone )
       
   411            {
       
   412            temp.Copy ( string );
       
   413            temp.Append ( '\0' );
       
   414            connect_data->mimetype = g_new0 ( gchar, temp.Length() );
       
   415            if ( !connect_data->mimetype )
       
   416                {           
       
   417                free_data ( connect_data );
       
   418                return RC_ERROR;
       
   419                }
       
   420            g_stpcpy ( connect_data->mimetype, ( gchar * ) temp.Ptr() ); 
       
   421            }    
       
   422        // read image filename
       
   423        if ( aItem.GetNextString ( string ) == KErrNone )
       
   424            {
       
   425            temp.Copy ( string );
       
   426            temp.Append ( '\0' );
       
   427            connect_data->image_file_name = g_new0 ( gchar, temp.Length() );
       
   428            if ( !connect_data->image_file_name )
       
   429                {           
       
   430                free_data ( connect_data );
       
   431                return RC_ERROR;
       
   432                }
       
   433            g_stpcpy ( connect_data->image_file_name, ( gchar * ) temp.Ptr() ); 
       
   434            }          
       
   435 	return RC_OK;
       
   436     }
       
   437 
       
   438 
       
   439 //-----------------------------------------------------------------------------
       
   440 // function_name	: free_data
       
   441 // description     	: Deallocates all the data
       
   442 // Returns          : None
       
   443 //-----------------------------------------------------------------------------
       
   444 //
       
   445 static void
       
   446 free_data ( ConnectData*& connect_data )
       
   447     {
       
   448 	if ( connect_data )
       
   449 	    {
       
   450 		if ( connect_data->server )
       
   451 		    {
       
   452 			g_free ( connect_data->server );
       
   453 			connect_data->server = NULL;
       
   454 		    }
       
   455 		
       
   456 		if ( connect_data->username )
       
   457 		    {
       
   458 			g_free ( connect_data->username );
       
   459 			connect_data->username = NULL;
       
   460 		    }
       
   461 		
       
   462 		if ( connect_data->password )
       
   463 		    {
       
   464 			g_free ( connect_data->password );
       
   465 			connect_data->password = NULL;
       
   466 		    }
       
   467 		
       
   468 		if ( connect_data->msg_data )
       
   469 		    {
       
   470 			if ( connect_data->msg_data->recipient )
       
   471 			    {
       
   472 				g_free ( connect_data->msg_data->recipient );
       
   473 				connect_data->msg_data->recipient = NULL;
       
   474 			    }
       
   475 			if ( connect_data->msg_data->message )
       
   476 			    {
       
   477 				g_free ( connect_data->msg_data->message );
       
   478 				connect_data->msg_data->message = NULL;
       
   479 			    }
       
   480 			g_free ( connect_data->msg_data );
       
   481 			connect_data->msg_data = NULL;
       
   482 		    }		
       
   483 		
       
   484 		if ( connect_data->resource )
       
   485 		    {
       
   486 			g_free ( connect_data->resource );
       
   487 			connect_data->resource = NULL;
       
   488 		    }
       
   489 		    
       
   490 
       
   491 	    if ( connect_data->proxy_data )
       
   492 	    	{
       
   493 	    	if ( connect_data->proxy_data->proxy_server )
       
   494 	    		{
       
   495 	    		g_free ( connect_data->proxy_data->proxy_server );
       
   496 	    		connect_data->proxy_data->proxy_server = NULL;
       
   497 	    		}
       
   498 	    	g_free ( connect_data->proxy_data );
       
   499 	    	connect_data->proxy_data = NULL;	
       
   500 	    	}
       
   501 	  
       
   502 	    if ( connect_data->port )
       
   503 		    {
       
   504 			g_free ( connect_data->port );
       
   505 			connect_data->port = NULL;
       
   506 		    }  
       
   507 		    
       
   508 		    
       
   509 		if ( connect_data->contact )
       
   510 		    {
       
   511 			g_free ( connect_data->contact );
       
   512 			connect_data->contact = NULL;
       
   513 		    }
       
   514 		    
       
   515 		if ( connect_data->key_given_name )
       
   516 		    {
       
   517 			g_free ( connect_data->key_given_name );
       
   518 			connect_data->key_given_name = NULL;
       
   519 		    }
       
   520 		    
       
   521 		if ( connect_data->key_middle_name )
       
   522 		    {
       
   523 			g_free ( connect_data->key_middle_name );
       
   524 			connect_data->key_middle_name = NULL;
       
   525 		    }
       
   526 		    
       
   527 		if ( connect_data->key_jid )
       
   528 		    {
       
   529 			g_free ( connect_data->key_jid );
       
   530 			connect_data->key_jid = NULL;
       
   531 		    }
       
   532 		    
       
   533 		if ( connect_data->key_full_name )
       
   534 		    {
       
   535 			g_free ( connect_data->key_full_name );
       
   536 			connect_data->key_full_name = NULL;
       
   537 		    }  
       
   538 		          
       
   539 		g_free ( connect_data );
       
   540 		connect_data = NULL;    
       
   541 	    }
       
   542     }
       
   543     
       
   544     //-----------------------------------------------------------------------------
       
   545 // function_name	: running isolation server exe
       
   546 // description     	: Deallocates all the data
       
   547 // Returns          : None
       
   548 //-----------------------------------------------------------------------------
       
   549   int  run_isoserver()
       
   550   {
       
   551   	// running isoserver 
       
   552     RProcess isosrv_launcher;
       
   553     TInt lunch_err = 0;
       
   554     _LIT(KProcess, "isoserver.exe");
       
   555     lunch_err = isosrv_launcher.Create( KProcess, KNullDesC );
       
   556      if ( KErrNone != lunch_err ) 
       
   557 	    {
       
   558 		return KErrGeneral;
       
   559 	    	
       
   560 	    }
       
   561 	isosrv_launcher.Resume();
       
   562 	return KErrNone;
       
   563   }
       
   564 
       
   565 // -----------------------------------------------------------------------------
       
   566 // ?function_name ?description.
       
   567 // ?description
       
   568 // Returns: ?value_1: ?description
       
   569 //          ?value_n: ?description_line1
       
   570 //                    ?description_line2
       
   571 // -----------------------------------------------------------------------------
       
   572 //
       
   573 /*
       
   574 ?type ?function_name(
       
   575     ?arg_type arg,  // ?description
       
   576     ?arg_type arg)  // ?description
       
   577     {
       
   578 
       
   579     ?code  // ?comment
       
   580 
       
   581     // ?comment
       
   582     ?code
       
   583     }
       
   584 */
       
   585 
       
   586 // ============================ MEMBER FUNCTIONS ===============================
       
   587 
       
   588 // -----------------------------------------------------------------------------
       
   589 // Cisolationserver::Delete
       
   590 // Delete here all resources allocated and opened from test methods. 
       
   591 // Called from destructor. 
       
   592 // -----------------------------------------------------------------------------
       
   593 //
       
   594 void Cisolationserver::Delete() 
       
   595     {
       
   596 
       
   597     }
       
   598 
       
   599 // -----------------------------------------------------------------------------
       
   600 // Cisolationserver::RunMethodL
       
   601 // Run specified method. Contains also table of test mothods and their names.
       
   602 // -----------------------------------------------------------------------------
       
   603 //
       
   604 TInt Cisolationserver::RunMethodL( 
       
   605     CStifItemParser& aItem ) 
       
   606     {
       
   607 
       
   608     static TStifFunctionInfo const KFunctions[] =
       
   609         {  
       
   610         
       
   611         ENTRY( "SecondSearch", Cisolationserver::SecondSearch), 
       
   612         ENTRY( "SearchAndAddContact", Cisolationserver::SearchAndAddContact ),
       
   613         ENTRY( "LoginWithCorrectData", Cisolationserver::LoginWithCorrectdata ),
       
   614         ENTRY( "LoginWithWrongPassword", Cisolationserver::LoginWithWrongPassword ),
       
   615         ENTRY( "LoginWithUnexistUserId", Cisolationserver::LoginWithUnexistUserId),
       
   616         ENTRY( "LoginWithUnexistServer", Cisolationserver::LoginWithUnexistServer),
       
   617         ENTRY( "LoginWithMixedLetterUserId", Cisolationserver::LoginWithMixedletterUserId),
       
   618         ENTRY( "LoginWithMaximumLenghtUserId", Cisolationserver::LoginWithMaximumLengthUserId),
       
   619         ENTRY( "LoginWithMinimumLenghtUserId", Cisolationserver::LoginWithMinimumLengthUserId),
       
   620         ENTRY( "LogoutFromServer", Cisolationserver::LogoutFromServer),
       
   621         ENTRY( "LoginWithBlankUserId", Cisolationserver::LoginWithBlankUserId),
       
   622         ENTRY( "LoginLogOutWithReapitiveSession", Cisolationserver::LoginLogOutWithReapitiveSession),
       
   623         ENTRY( "LoginWithCoreectUserIDWithSpace", Cisolationserver::LoginWithCoreectUserIDWithSpace),
       
   624         ENTRY( "LoginWithInvalidPortAddress", Cisolationserver::LoginWithInvalidPortAddress),
       
   625         ENTRY( "LoginWithMissingSettings", Cisolationserver::LoginWithMissingSettings),
       
   626         ENTRY( "LoginWhenTGAndDDAreNotRunning", Cisolationserver::LoginWhenTGAndDDAreNotRunning),
       
   627         ENTRY( "SendMessageToCorrectUserID", Cisolationserver::SendMessageToCorrectUserID),
       
   628         ENTRY( "SendMaxLenMessageToCorrectUserID", Cisolationserver::SendMaxLenMessageToCorrectUserID),
       
   629         ENTRY( "SendTextMessageUnExistUserID", Cisolationserver::SendTextMessageUnExistUserID),
       
   630         ENTRY( "SendTextMessageWithSpecialCharacter", Cisolationserver::SendTextMessageWithSpecialCharacter),
       
   631         ENTRY( "SendMessageWithBlankUserID", Cisolationserver::SendMessageWithBlankUserID),
       
   632         ENTRY( "SendSmilyToCorrectUserID", Cisolationserver::SendSmilyToCorrectUserID),
       
   633         ENTRY( "SendBlankMessageToUserID", Cisolationserver::SendBlankMessageToUserID),
       
   634         ENTRY( "SendMessageToOfflineContact", Cisolationserver::SendMessageToOfflineContact),
       
   635         ENTRY( "SendContinuousltReapitiveMessage", Cisolationserver::SendContinuousltReapitiveMessage),
       
   636         ENTRY( "SendTextMessageToBlockedUser", Cisolationserver::SendTextMessageToBlockedUser),
       
   637         ENTRY( "SendTextMessageToUserIdWhoIsBlockedSender", Cisolationserver::SendTextMessageToUserIdWhoIsBlockedSender),
       
   638         ENTRY( "SendLongTextMessageToUserId", Cisolationserver::SendLongTextMessageToUserId),
       
   639         ENTRY( "SendTextMessageUserWhoIsNotAddedInContactList", Cisolationserver::SendTextMessageUserWhoIsNotAddedInContactList),
       
   640         ENTRY( "MessageReceiveFromUser", Cisolationserver::MessageReceiveFromUser),
       
   641         ENTRY( "AddExistingContact", Cisolationserver::AddExistingContact),
       
   642         ENTRY( "ClientSendBlankUserIdForADD", Cisolationserver::ClientSendBlankUserIdForADD),
       
   643         ENTRY( "AddContactWhichIsAlreadyAdded", Cisolationserver::AddContactWhichIsAlreadyAdded),
       
   644         ENTRY( "AddExistingContactWIthSpace", Cisolationserver::AddExistingContactWIthSpace),
       
   645         ENTRY( "AddUnexistingUserID", Cisolationserver::AddUnexistingUserID),
       
   646         ENTRY( "AddExistingContactWIthMixedLetter", Cisolationserver::AddExistingContactWIthMixedLetter),
       
   647         ENTRY( "AddInvalidContactWIthSpecialLetter", Cisolationserver::AddInvalidContactWIthSpecialLetter),
       
   648         ENTRY( "DeleteExistingContact", Cisolationserver::DeleteExistingContact),
       
   649         ENTRY( "ClientSendBlankUserIdForDELETE", Cisolationserver::ClientSendBlankUserIdForDELETE),
       
   650         ENTRY( "DeleteContactWhichIsAlreadyDeleted", Cisolationserver::DeleteContactWhichIsAlreadyDeleted),
       
   651         ENTRY( "DeleteExistingContactWIthSpace", Cisolationserver::DeleteExistingContactWIthSpace),
       
   652         ENTRY( "DeleteUnexistingUserID", Cisolationserver::DeleteUnexistingUserID),
       
   653         ENTRY( "DeleteExistingContactWIthMixedLetter", Cisolationserver::DeleteExistingContactWIthMixedLetter),
       
   654         ENTRY( "DeleteInvalidContactWIthSpecialLetter", Cisolationserver::DeleteInvalidContactWIthSpecialLetter),
       
   655         ENTRY( "FetchContatcs", Cisolationserver::FetchContatcs),
       
   656         ENTRY( "AddContatcs", Cisolationserver::AddContatcs),
       
   657         ENTRY( "UpdatePresenceWithAway", Cisolationserver::UpdatePresenceWithAway),
       
   658         ENTRY( "UpdatePresenceWithDnd", Cisolationserver::UpdatePresenceWithDnd),
       
   659         ENTRY( "UpdatePresenceWithAvailable", Cisolationserver::UpdatePresenceWithAvailable),
       
   660         ENTRY( "UpdatePresenceMultipleTimeInSameSession", Cisolationserver::UpdatePresenceMultipleTimeInSameSession),
       
   661         ENTRY( "UpdateOnlyStatusText", Cisolationserver::UpdateOnlyStatusText),
       
   662         ENTRY( "UpdateOnlyUserAvailability", Cisolationserver::UpdateOnlyUserAvailability),
       
   663         ENTRY( "UpdateOwnPresenceWithBlankData", Cisolationserver::UpdateOwnPresenceWithBlankData),
       
   664         ENTRY( "UpdateStatusTextWithMaxLen", Cisolationserver::UpdateStatusTextWithMaxLen),
       
   665         ENTRY( "UpdateStatusTextWithSpecialCharacter", Cisolationserver::UpdateStatusTextWithSpecialCharacter),
       
   666         ENTRY( "HandelingPresenceNotification", Cisolationserver::HandelingPresenceNotification),
       
   667         ENTRY( "SearchKeyValue", Cisolationserver::SearchKeyValue),
       
   668         ENTRY( "SearchKeyValueWithResult", Cisolationserver::SearchKeyValueWithResult ),
       
   669         ENTRY( "SearchKeyValueInvalidParam", Cisolationserver::SearchKeyValueInvalidParam ),
       
   670         ENTRY( "SearchForLargeNoOfResult", Cisolationserver::SearchForLargeNoOfResult ),
       
   671         ENTRY( "SearchKeyValueInvalidParam2", Cisolationserver::SearchKeyValueInvalidParam2 ),
       
   672         ENTRY( "SearchKeyValueInvalidHashValues", Cisolationserver::SearchKeyValueInvalidHashValues ),
       
   673         ENTRY( "SearchKeyValueBlank", Cisolationserver::SearchKeyValueBlank ),
       
   674         ENTRY( "SearchKeyValueSpecialChar", Cisolationserver::SearchKeyValueSpecialChar ),
       
   675         ENTRY( "SearchKeyValueLargeString", Cisolationserver::SearchKeyValueLargeString ),
       
   676         ENTRY( "AcceptAddRequestFromUser", Cisolationserver::AcceptAddRequestFromUser ),
       
   677         ENTRY( "RejectAddRequestFromUser", Cisolationserver::RejectAddRequestFromUser ),
       
   678         ENTRY( "SendAcceptRequestWithoutReceivingAddrequest", Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest ),
       
   679         ENTRY( "SendRejectRequestWithoutReceivingAddrequest", Cisolationserver::SendRejectRequestWithoutReceivingAddrequest ),
       
   680         ENTRY( "SendAcceptRequestWithoutAnyUserID", Cisolationserver::SendAcceptRequestWithoutAnyUserID ),
       
   681         ENTRY( "SendRejectRequestWithoutAnyUserID", Cisolationserver::SendRejectRequestWithoutAnyUserID ),
       
   682         ENTRY( "LogoutWhileUserIsNotLoggedIn", Cisolationserver::LogoutWhileUserIsNotLoggedIn),
       
   683         ENTRY( "GetKeysAndSearch", Cisolationserver::GetKeysAndSearch),
       
   684         ENTRY( "SetOwnAvatar", Cisolationserver::SetOwnAvatar),
       
   685         ENTRY( "ClearOwnAvatar", Cisolationserver::ClearOwnAvatar),
       
   686         ENTRY( "FetchCachedContacts", Cisolationserver::FetchCachedContacts),
       
   687         //ADD NEW ENTRY HERE
       
   688         // [test cases entries] - Do not remove
       
   689 
       
   690         };
       
   691 
       
   692     const TInt count = sizeof( KFunctions ) / 
       
   693                         sizeof( TStifFunctionInfo );
       
   694 
       
   695     return RunInternalL( KFunctions, count, aItem );
       
   696 
       
   697     }
       
   698     
       
   699    // -----------------------------------------------------------------------------
       
   700 // Cisolationserver::Login with correct data
       
   701 // Example test method function.
       
   702 // (other items were commented in a header).
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 TInt Cisolationserver::LoginWithCorrectdata( CStifItemParser& aItem )
       
   706     {
       
   707   	
       
   708     ConnectData  *connect_data = NULL;
       
   709     char smsg[MAX_MSG_SIZE];
       
   710     char rmsg[MAX_MSG_SIZE];
       
   711     int index=0;
       
   712 
       
   713 	FILE *fp;	
       
   714 	int timeout = 100;
       
   715 	int nBytes;
       
   716     int result = 0;
       
   717     int err = 0;
       
   718     int status = 0;
       
   719     message_hdr_req *msgHdr = NULL;  
       
   720     message_hdr_resp* msg_struct = NULL;
       
   721     TInt return_value = 0;
       
   722         	// Read data from the CFG file
       
   723 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
   724 		{
       
   725 		iLog->Log ( _L ( "read_data failed" ) );
       
   726 		free_data ( connect_data );
       
   727 		return_value = KErrGeneral;
       
   728 		goto return_code;
       
   729 		}
       
   730 	//request formation	
       
   731 	memset( smsg, '\0', MAX_MSG_SIZE );
       
   732 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
   733 	//message header use
       
   734 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
   735     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
   736     msgHdr->message_type = ELogin_Request;
       
   737     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
   738     index += sizeof( message_hdr_req );
       
   739     int len = strlen(connect_data->username);
       
   740     strcpy( smsg + index, connect_data->username );
       
   741     index += len + 1;
       
   742     //appending password
       
   743     len = strlen(connect_data->password );
       
   744     strcpy( smsg + index, connect_data->password );
       
   745     index += len + 1;
       
   746     //appending server name
       
   747     len = strlen(connect_data->server );
       
   748     strcpy( smsg + index, connect_data->server );
       
   749     index += len + 1;
       
   750     //appending resource
       
   751     len = strlen(connect_data->resource );
       
   752     strcpy( smsg + index, connect_data->resource );
       
   753     index += len + 1;
       
   754     //appending ssl
       
   755     smsg[index++]= '1';
       
   756     smsg[index++]= '\0';
       
   757     //appending server port
       
   758     len = strlen(connect_data->port );
       
   759     strcpy( smsg + index, connect_data->port );
       
   760     index += len + 1;
       
   761     // appending IAP id
       
   762     smsg[index++]= '1';
       
   763     smsg[index++]= '\0';
       
   764     //appending connmgr_bus
       
   765     len = strlen(connect_data->connmgr_bus );
       
   766     strcpy( smsg + index, connect_data->connmgr_bus );
       
   767     index += len + 1;
       
   768     //appending connmgr_path
       
   769     len = strlen(connect_data->connmgr_path );
       
   770     strcpy( smsg + index, connect_data->connmgr_path );
       
   771     index += len + 1;
       
   772     //appending protocol
       
   773     len = strlen(connect_data->protocol );
       
   774     strcpy( smsg + index, connect_data->protocol );
       
   775     index += len + 1;
       
   776     #ifdef __WINSCW__
       
   777     //proxy server
       
   778     len = strlen(connect_data->proxy_data->proxy_server );
       
   779     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
   780     index += len + 1;
       
   781     //proxy port
       
   782     len = strlen(connect_data->proxy_data->proxy_port );
       
   783     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
   784     index += len + 1;
       
   785     #endif
       
   786      //running isoserver   
       
   787     run_isoserver(); 
       
   788     //create message queue for send request
       
   789     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
   790     //create message queue for response request
       
   791     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
   792     /* Send Message to queueOne */
       
   793 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
   794     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
   795     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
   796 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
   797 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
   798     if (status < 0)
       
   799     {
       
   800     return_value = KErrGeneral;
       
   801 	goto return_code;	
       
   802     }
       
   803    	if( msg_struct->response != 1)
       
   804     {
       
   805     return_value = KErrGeneral;
       
   806 	goto return_code;
       
   807     }
       
   808      // login end
       
   809     //fetch req..
       
   810     for (int i= 0 ;i<3 ;i++)
       
   811     {
       
   812         
       
   813     fp = fopen("c:\\fetch_contact.txt","a");
       
   814 	do  {
       
   815 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
   816 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
   817 		fwrite(rmsg,1,status,fp);
       
   818 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
   819 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
   820 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
   821 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
   822 	fclose(fp);	
       
   823 	
       
   824     }
       
   825 
       
   826 	//fetch end
       
   827     
       
   828     // logout test code from server
       
   829     index=0;
       
   830     memset( smsg, '\0', MAX_MSG_SIZE );
       
   831 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
   832 	
       
   833 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
   834     
       
   835     msgHdr->message_type = ELogout_Request;
       
   836  
       
   837     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
   838     index += sizeof( message_hdr_req );
       
   839 
       
   840 	
       
   841 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
   842     
       
   843     do  {
       
   844 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
   845 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
   846 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
   847 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
   848    
       
   849     if ( msg_struct->response != 1)
       
   850     {
       
   851     return_value = KErrGeneral;
       
   852 	goto return_code;
       
   853     }
       
   854     return_value = KErrNone;
       
   855 	goto return_code;
       
   856     //killing isoserver
       
   857     return_code:
       
   858     index=0;
       
   859     memset( smsg, '\0', MAX_MSG_SIZE );
       
   860 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
   861 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
   862     msgHdr->message_type = EKill_Process;
       
   863  
       
   864     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
   865     index += sizeof( message_hdr_req );
       
   866 
       
   867 	
       
   868 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
   869     free( msg_struct );
       
   870     return return_value;
       
   871 
       
   872     }
       
   873 
       
   874 
       
   875   // -----------------------------------------------------------------------------
       
   876 // Cisolationserver::Logout from server
       
   877 // Example test method function.
       
   878 // (other items were commented in a header).
       
   879 // -----------------------------------------------------------------------------
       
   880 //
       
   881 TInt Cisolationserver::LogoutFromServer( CStifItemParser& aItem )
       
   882     {
       
   883   	ConnectData  *connect_data = NULL;
       
   884     char smsg[MAX_MSG_SIZE];
       
   885     char rmsg[MAX_MSG_SIZE];
       
   886     int index=0;
       
   887 
       
   888 	FILE *fp;	
       
   889 	int timeout = 100;
       
   890 	int nBytes;
       
   891     int result = 0;
       
   892     int err = 0;
       
   893     int status = 0;
       
   894     message_hdr_req *msgHdr = NULL;  
       
   895     message_hdr_resp* msg_struct = NULL;
       
   896     TInt return_value = 0;
       
   897         	// Read data from the CFG file
       
   898 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
   899 		{
       
   900 		iLog->Log ( _L ( "read_data failed" ) );
       
   901 		free_data ( connect_data );
       
   902 		return_value = KErrGeneral;
       
   903 		goto return_code;
       
   904 		}
       
   905 	//request formation	
       
   906 	memset( smsg, '\0', MAX_MSG_SIZE );
       
   907 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
   908 	//message header use
       
   909 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
   910     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
   911     msgHdr->message_type = ELogin_Request;
       
   912     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
   913     index += sizeof( message_hdr_req );
       
   914     int len = strlen(connect_data->username);
       
   915     strcpy( smsg + index, connect_data->username );
       
   916     index += len + 1;
       
   917     //appending password
       
   918     len = strlen(connect_data->password );
       
   919     strcpy( smsg + index, connect_data->password );
       
   920     index += len + 1;
       
   921     //appending server name
       
   922     len = strlen(connect_data->server );
       
   923     strcpy( smsg + index, connect_data->server );
       
   924     index += len + 1;
       
   925     //appending resource
       
   926     len = strlen(connect_data->resource );
       
   927     strcpy( smsg + index, connect_data->resource );
       
   928     index += len + 1;
       
   929     //appending ssl
       
   930     smsg[index++]= '1';
       
   931     smsg[index++]= '\0';
       
   932     //appending server port
       
   933     len = strlen(connect_data->port );
       
   934     strcpy( smsg + index, connect_data->port );
       
   935     index += len + 1;
       
   936     // appending IAP id
       
   937     smsg[index++]= '1';
       
   938     smsg[index++]= '\0';
       
   939     //appending connmgr_bus
       
   940     len = strlen(connect_data->connmgr_bus );
       
   941     strcpy( smsg + index, connect_data->connmgr_bus );
       
   942     index += len + 1;
       
   943     //appending connmgr_path
       
   944     len = strlen(connect_data->connmgr_path );
       
   945     strcpy( smsg + index, connect_data->connmgr_path );
       
   946     index += len + 1;
       
   947     //appending protocol
       
   948     len = strlen(connect_data->protocol );
       
   949     strcpy( smsg + index, connect_data->protocol );
       
   950     index += len + 1;
       
   951     #ifdef __WINSCW__
       
   952     //proxy server
       
   953     len = strlen(connect_data->proxy_data->proxy_server );
       
   954     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
   955     index += len + 1;
       
   956     //proxy port
       
   957     len = strlen(connect_data->proxy_data->proxy_port );
       
   958     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
   959     index += len + 1;
       
   960     #endif
       
   961      //running isoserver   
       
   962     run_isoserver(); 
       
   963     //create message queue for send request
       
   964     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
   965     //create message queue for response request
       
   966     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
   967     /* Send Message to queueOne */
       
   968 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
   969     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
   970     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
   971 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
   972 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
   973     if (status < 0)
       
   974     {
       
   975     return_value = KErrGeneral;
       
   976 	goto return_code;	
       
   977     }
       
   978    	if( msg_struct->response != 1)
       
   979     {
       
   980     return_value = KErrGeneral;
       
   981 	goto return_code;
       
   982     }
       
   983      // login end
       
   984     //fetch req..
       
   985     for (int i= 0 ;i<3 ;i++)
       
   986     {
       
   987         
       
   988     fp = fopen("c:\\fetch_contact.txt","a");
       
   989 	do  {
       
   990 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
   991 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
   992 		fwrite(rmsg,1,status,fp);
       
   993 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
   994 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
   995 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
   996 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
   997 	fclose(fp);	
       
   998 	
       
   999     }
       
  1000 
       
  1001 	//fetch end
       
  1002     
       
  1003     // logout test code from server
       
  1004     index=0;
       
  1005     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1006 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1007 	
       
  1008 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1009     
       
  1010     msgHdr->message_type = ELogout_Request;
       
  1011  
       
  1012     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1013     index += sizeof( message_hdr_req );
       
  1014 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1015     
       
  1016     do  {
       
  1017 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  1018 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1019 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1020 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  1021    
       
  1022     if ( msg_struct->response != 1)
       
  1023     {
       
  1024     return_value = KErrGeneral;
       
  1025 	goto return_code;
       
  1026     }
       
  1027     return_value = KErrNone;
       
  1028 	goto return_code;
       
  1029     //killing isoserver
       
  1030     return_code:
       
  1031     index=0;
       
  1032     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1033 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1034 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1035     msgHdr->message_type = EKill_Process;
       
  1036     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1037     index += sizeof( message_hdr_req );
       
  1038 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  1039     free( msg_struct );
       
  1040     return return_value;
       
  1041 
       
  1042     }
       
  1043 
       
  1044   // -----------------------------------------------------------------------------
       
  1045 // Cisolationserver::Login with mixed letter user
       
  1046 // Example test method function.
       
  1047 // (other items were commented in a header).
       
  1048 // -----------------------------------------------------------------------------
       
  1049 //
       
  1050 TInt Cisolationserver::LoginWithMixedletterUserId( CStifItemParser& aItem )
       
  1051     {
       
  1052   	
       
  1053     ConnectData  *connect_data = NULL;
       
  1054     char smsg[MAX_MSG_SIZE];
       
  1055     char rmsg[MAX_MSG_SIZE];
       
  1056     int index=0;
       
  1057 
       
  1058 	FILE *fp;	
       
  1059 	int timeout = 100;
       
  1060 	int nBytes;
       
  1061     int result = 0;
       
  1062     int err = 0;
       
  1063     int status = 0;
       
  1064     message_hdr_req *msgHdr = NULL;  
       
  1065     message_hdr_resp* msg_struct = NULL;
       
  1066     TInt return_value = 0;
       
  1067         	// Read data from the CFG file
       
  1068 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  1069 		{
       
  1070 		iLog->Log ( _L ( "read_data failed" ) );
       
  1071 		free_data ( connect_data );
       
  1072 		return_value = KErrGeneral;
       
  1073 		goto return_code;
       
  1074 		}
       
  1075 	//request formation	
       
  1076 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  1077 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1078 	//message header use
       
  1079 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  1080     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1081     msgHdr->message_type = ELogin_Request;
       
  1082     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1083     index += sizeof( message_hdr_req );
       
  1084     int len = strlen(connect_data->username);
       
  1085     strcpy( smsg + index, connect_data->username );
       
  1086     index += len + 1;
       
  1087     //appending password
       
  1088     len = strlen(connect_data->password );
       
  1089     strcpy( smsg + index, connect_data->password );
       
  1090     index += len + 1;
       
  1091     //appending server name
       
  1092     len = strlen(connect_data->server );
       
  1093     strcpy( smsg + index, connect_data->server );
       
  1094     index += len + 1;
       
  1095     //appending resource
       
  1096     len = strlen(connect_data->resource );
       
  1097     strcpy( smsg + index, connect_data->resource );
       
  1098     index += len + 1;
       
  1099     //appending ssl
       
  1100     smsg[index++]= '1';
       
  1101     smsg[index++]= '\0';
       
  1102     //appending server port
       
  1103     len = strlen(connect_data->port );
       
  1104     strcpy( smsg + index, connect_data->port );
       
  1105     index += len + 1;
       
  1106     // appending IAP id
       
  1107     smsg[index++]= '1';
       
  1108     smsg[index++]= '\0';
       
  1109     //appending connmgr_bus
       
  1110     len = strlen(connect_data->connmgr_bus );
       
  1111     strcpy( smsg + index, connect_data->connmgr_bus );
       
  1112     index += len + 1;
       
  1113     //appending connmgr_path
       
  1114     len = strlen(connect_data->connmgr_path );
       
  1115     strcpy( smsg + index, connect_data->connmgr_path );
       
  1116     index += len + 1;
       
  1117     //appending protocol
       
  1118     len = strlen(connect_data->protocol );
       
  1119     strcpy( smsg + index, connect_data->protocol );
       
  1120     index += len + 1;
       
  1121     #ifdef __WINSCW__
       
  1122     //proxy server
       
  1123     len = strlen(connect_data->proxy_data->proxy_server );
       
  1124     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  1125     index += len + 1;
       
  1126     //proxy port
       
  1127     len = strlen(connect_data->proxy_data->proxy_port );
       
  1128     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  1129     index += len + 1;
       
  1130     #endif
       
  1131      //running isoserver   
       
  1132     run_isoserver(); 
       
  1133     //create message queue for send request
       
  1134     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1135     //create message queue for response request
       
  1136     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1137     /* Send Message to queueOne */
       
  1138 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1139     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1140     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1141 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1142 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1143     if (status < 0)
       
  1144     {
       
  1145     return_value = KErrGeneral;
       
  1146 	goto return_code;	
       
  1147     }
       
  1148    	if( msg_struct->response != 1)
       
  1149     {
       
  1150     return_value = KErrGeneral;
       
  1151 	goto return_code;
       
  1152     }
       
  1153      // login end
       
  1154     //fetch req..
       
  1155     for (int i= 0 ;i<3 ;i++)
       
  1156     {
       
  1157         
       
  1158     fp = fopen("c:\\fetch_contact.txt","a");
       
  1159 	do  {
       
  1160 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  1161 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1162 		fwrite(rmsg,1,status,fp);
       
  1163 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1164 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  1165 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  1166 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  1167 	fclose(fp);	
       
  1168 	
       
  1169     }
       
  1170 
       
  1171 	//fetch end
       
  1172     
       
  1173     // logout test code from server
       
  1174     index=0;
       
  1175     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1176 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1177 	
       
  1178 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1179     
       
  1180     msgHdr->message_type = ELogout_Request;
       
  1181  
       
  1182     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1183     index += sizeof( message_hdr_req );
       
  1184 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1185     
       
  1186     do  {
       
  1187 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  1188 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1189 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1190 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  1191    
       
  1192     if ( msg_struct->response != 1)
       
  1193     {
       
  1194     return_value = KErrGeneral;
       
  1195 	goto return_code;
       
  1196     }
       
  1197     return_value = KErrNone;
       
  1198 	goto return_code;
       
  1199     //killing isoserver
       
  1200     return_code:
       
  1201     index=0;
       
  1202     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1203 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1204 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1205     msgHdr->message_type = EKill_Process;
       
  1206     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1207     index += sizeof( message_hdr_req );
       
  1208 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  1209     free( msg_struct );
       
  1210     return return_value;
       
  1211 
       
  1212     }
       
  1213     
       
  1214     // -----------------------------------------------------------------------------
       
  1215 // Cisolationserver::Login with mixed letter user
       
  1216 // Example test method function.
       
  1217 // (other items were commented in a header).
       
  1218 // -----------------------------------------------------------------------------
       
  1219 //
       
  1220 TInt Cisolationserver::LoginWithMinimumLengthUserId( CStifItemParser& aItem )
       
  1221     {
       
  1222   	
       
  1223     ConnectData  *connect_data = NULL;
       
  1224     char smsg[MAX_MSG_SIZE];
       
  1225     char rmsg[MAX_MSG_SIZE];
       
  1226     int index=0;
       
  1227 
       
  1228 	FILE *fp;	
       
  1229 	int timeout = 100;
       
  1230 	int nBytes;
       
  1231     int result = 0;
       
  1232     int err = 0;
       
  1233     int status = 0;
       
  1234     message_hdr_req *msgHdr = NULL;  
       
  1235     message_hdr_resp* msg_struct = NULL;
       
  1236     TInt return_value = 0;
       
  1237         	// Read data from the CFG file
       
  1238 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  1239 		{
       
  1240 		iLog->Log ( _L ( "read_data failed" ) );
       
  1241 		free_data ( connect_data );
       
  1242 		return_value = KErrGeneral;
       
  1243 		goto return_code;
       
  1244 		}
       
  1245 	//request formation	
       
  1246 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  1247 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1248 	//message header use
       
  1249 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  1250     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1251     msgHdr->message_type = ELogin_Request;
       
  1252     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1253     index += sizeof( message_hdr_req );
       
  1254     int len = strlen(connect_data->username);
       
  1255     strcpy( smsg + index, connect_data->username );
       
  1256     index += len + 1;
       
  1257     //appending password
       
  1258     len = strlen(connect_data->password );
       
  1259     strcpy( smsg + index, connect_data->password );
       
  1260     index += len + 1;
       
  1261     //appending server name
       
  1262     len = strlen(connect_data->server );
       
  1263     strcpy( smsg + index, connect_data->server );
       
  1264     index += len + 1;
       
  1265     //appending resource
       
  1266     len = strlen(connect_data->resource );
       
  1267     strcpy( smsg + index, connect_data->resource );
       
  1268     index += len + 1;
       
  1269     //appending ssl
       
  1270     smsg[index++]= '1';
       
  1271     smsg[index++]= '\0';
       
  1272     //appending server port
       
  1273     len = strlen(connect_data->port );
       
  1274     strcpy( smsg + index, connect_data->port );
       
  1275     index += len + 1;
       
  1276     // appending IAP id
       
  1277     smsg[index++]= '1';
       
  1278     smsg[index++]= '\0';
       
  1279     //appending connmgr_bus
       
  1280     len = strlen(connect_data->connmgr_bus );
       
  1281     strcpy( smsg + index, connect_data->connmgr_bus );
       
  1282     index += len + 1;
       
  1283     //appending connmgr_path
       
  1284     len = strlen(connect_data->connmgr_path );
       
  1285     strcpy( smsg + index, connect_data->connmgr_path );
       
  1286     index += len + 1;
       
  1287     //appending protocol
       
  1288     len = strlen(connect_data->protocol );
       
  1289     strcpy( smsg + index, connect_data->protocol );
       
  1290     index += len + 1;
       
  1291     #ifdef __WINSCW__
       
  1292     //proxy server
       
  1293     len = strlen(connect_data->proxy_data->proxy_server );
       
  1294     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  1295     index += len + 1;
       
  1296     //proxy port
       
  1297     len = strlen(connect_data->proxy_data->proxy_port );
       
  1298     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  1299     index += len + 1;
       
  1300     #endif
       
  1301      //running isoserver   
       
  1302     run_isoserver(); 
       
  1303     //create message queue for send request
       
  1304     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1305     //create message queue for response request
       
  1306     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1307     /* Send Message to queueOne */
       
  1308 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1309     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1310     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1311 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1312 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1313     if (status < 0)
       
  1314     {
       
  1315     return_value = KErrGeneral;
       
  1316 	goto return_code;	
       
  1317     }
       
  1318    	if( msg_struct->response != 1)
       
  1319     {
       
  1320     return_value = KErrGeneral;
       
  1321 	goto return_code;
       
  1322     }
       
  1323      // login end
       
  1324     //fetch req..
       
  1325     for (int i= 0 ;i<3 ;i++)
       
  1326     {
       
  1327         
       
  1328     fp = fopen("c:\\fetch_contact.txt","a");
       
  1329 	do  {
       
  1330 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  1331 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1332 		fwrite(rmsg,1,status,fp);
       
  1333 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1334 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  1335 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  1336 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  1337 	fclose(fp);	
       
  1338 	
       
  1339     }
       
  1340 
       
  1341 	//fetch end
       
  1342     
       
  1343     // logout test code from server
       
  1344     index=0;
       
  1345     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1346 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1347 	
       
  1348 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1349     
       
  1350     msgHdr->message_type = ELogout_Request;
       
  1351  
       
  1352     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1353     index += sizeof( message_hdr_req );
       
  1354 
       
  1355 	
       
  1356 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1357     
       
  1358     do  {
       
  1359 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  1360 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1361 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1362 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  1363    
       
  1364     if ( msg_struct->response != 1)
       
  1365     {
       
  1366     return_value = KErrGeneral;
       
  1367 	goto return_code;
       
  1368     }
       
  1369     return_value = KErrNone;
       
  1370 	goto return_code;
       
  1371     //killing isoserver
       
  1372     return_code:
       
  1373     index=0;
       
  1374     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1375 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1376 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1377     msgHdr->message_type = EKill_Process;
       
  1378  
       
  1379     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1380     index += sizeof( message_hdr_req );
       
  1381 
       
  1382 	
       
  1383 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  1384     free( msg_struct );
       
  1385     return return_value;
       
  1386 
       
  1387     }
       
  1388     
       
  1389      // -----------------------------------------------------------------------------
       
  1390 // Cisolationserver::Login with mixed letter user
       
  1391 // Example test method function.
       
  1392 // (other items were commented in a header).
       
  1393 // -----------------------------------------------------------------------------
       
  1394 //
       
  1395 TInt Cisolationserver::LoginWithMaximumLengthUserId( CStifItemParser& aItem )
       
  1396     {
       
  1397   	
       
  1398     ConnectData  *connect_data = NULL;
       
  1399     char smsg[MAX_MSG_SIZE];
       
  1400     char rmsg[MAX_MSG_SIZE];
       
  1401     int index=0;
       
  1402 
       
  1403 	FILE *fp;	
       
  1404 	int timeout = 100;
       
  1405 	int nBytes;
       
  1406     int result = 0;
       
  1407     int err = 0;
       
  1408     int status = 0;
       
  1409     message_hdr_req *msgHdr = NULL;  
       
  1410     message_hdr_resp* msg_struct = NULL;
       
  1411     TInt return_value = 0;
       
  1412         	// Read data from the CFG file
       
  1413 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  1414 		{
       
  1415 		iLog->Log ( _L ( "read_data failed" ) );
       
  1416 		free_data ( connect_data );
       
  1417 		return_value = KErrGeneral;
       
  1418 		goto return_code;
       
  1419 		}
       
  1420 	//request formation	
       
  1421 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  1422 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1423 	//message header use
       
  1424 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  1425     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1426     msgHdr->message_type = ELogin_Request;
       
  1427     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1428     index += sizeof( message_hdr_req );
       
  1429     int len = strlen(connect_data->username);
       
  1430     strcpy( smsg + index, connect_data->username );
       
  1431     index += len + 1;
       
  1432     //appending password
       
  1433     len = strlen(connect_data->password );
       
  1434     strcpy( smsg + index, connect_data->password );
       
  1435     index += len + 1;
       
  1436     //appending server name
       
  1437     len = strlen(connect_data->server );
       
  1438     strcpy( smsg + index, connect_data->server );
       
  1439     index += len + 1;
       
  1440     //appending resource
       
  1441     len = strlen(connect_data->resource );
       
  1442     strcpy( smsg + index, connect_data->resource );
       
  1443     index += len + 1;
       
  1444     //appending ssl
       
  1445     smsg[index++]= '1';
       
  1446     smsg[index++]= '\0';
       
  1447     //appending server port
       
  1448     len = strlen(connect_data->port );
       
  1449     strcpy( smsg + index, connect_data->port );
       
  1450     index += len + 1;
       
  1451     // appending IAP id
       
  1452     smsg[index++]= '1';
       
  1453     smsg[index++]= '\0';
       
  1454     //appending connmgr_bus
       
  1455     len = strlen(connect_data->connmgr_bus );
       
  1456     strcpy( smsg + index, connect_data->connmgr_bus );
       
  1457     index += len + 1;
       
  1458     //appending connmgr_path
       
  1459     len = strlen(connect_data->connmgr_path );
       
  1460     strcpy( smsg + index, connect_data->connmgr_path );
       
  1461     index += len + 1;
       
  1462     //appending protocol
       
  1463     len = strlen(connect_data->protocol );
       
  1464     strcpy( smsg + index, connect_data->protocol );
       
  1465     index += len + 1;
       
  1466     #ifdef __WINSCW__
       
  1467     //proxy server
       
  1468     len = strlen(connect_data->proxy_data->proxy_server );
       
  1469     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  1470     index += len + 1;
       
  1471     //proxy port
       
  1472     len = strlen(connect_data->proxy_data->proxy_port );
       
  1473     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  1474     index += len + 1;
       
  1475     #endif
       
  1476      //running isoserver   
       
  1477     run_isoserver(); 
       
  1478     //create message queue for send request
       
  1479     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1480     //create message queue for response request
       
  1481     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1482     /* Send Message to queueOne */
       
  1483 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1484     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1485     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1486 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1487 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1488     if (status < 0)
       
  1489     {
       
  1490     return_value = KErrGeneral;
       
  1491 	goto return_code;	
       
  1492     }
       
  1493    	if( msg_struct->response != 1)
       
  1494     {
       
  1495     return_value = KErrGeneral;
       
  1496 	goto return_code;
       
  1497     }
       
  1498      // login end
       
  1499     //fetch req..
       
  1500     for (int i= 0 ;i<3 ;i++)
       
  1501     {
       
  1502         
       
  1503     fp = fopen("c:\\fetch_contact.txt","a");
       
  1504 	do  {
       
  1505 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  1506 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1507 		fwrite(rmsg,1,status,fp);
       
  1508 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1509 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  1510 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  1511 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  1512 	fclose(fp);	
       
  1513 	
       
  1514     }
       
  1515 
       
  1516 	//fetch end
       
  1517     
       
  1518     // logout test code from server
       
  1519     index=0;
       
  1520     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1521 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1522 	
       
  1523 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1524     
       
  1525     msgHdr->message_type = ELogout_Request;
       
  1526  
       
  1527     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1528     index += sizeof( message_hdr_req );
       
  1529 
       
  1530 	
       
  1531 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1532     
       
  1533     do  {
       
  1534 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  1535 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  1536 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1537 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  1538    
       
  1539     if ( msg_struct->response != 1)
       
  1540     {
       
  1541     return_value = KErrGeneral;
       
  1542 	goto return_code;
       
  1543     }
       
  1544     return_value = KErrNone;
       
  1545 	goto return_code;
       
  1546     //killing isoserver
       
  1547     return_code:
       
  1548     index=0;
       
  1549     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1550 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1551 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1552     msgHdr->message_type = EKill_Process;
       
  1553  
       
  1554     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1555     index += sizeof( message_hdr_req );
       
  1556 
       
  1557 	
       
  1558 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  1559     free( msg_struct );
       
  1560     return return_value;
       
  1561 
       
  1562     } 
       
  1563 // -----------------------------------------------------------------------------
       
  1564 // Cisolationserver::Login with bad password
       
  1565 // Example test method function.
       
  1566 // (other items were commented in a header).
       
  1567 // -----------------------------------------------------------------------------
       
  1568 //
       
  1569 TInt Cisolationserver::LoginWithWrongPassword( CStifItemParser& aItem )
       
  1570     {
       
  1571     ConnectData  *connect_data = NULL;
       
  1572     char smsg[MAX_MSG_SIZE];
       
  1573     char rmsg[MAX_MSG_SIZE];
       
  1574     int index=0;
       
  1575     int timeout = 100;
       
  1576 	int nBytes;
       
  1577     int result = 0;
       
  1578     int err = 0;
       
  1579     int status = 0;
       
  1580     message_hdr_req *msgHdr = NULL;  
       
  1581     message_hdr_resp* msg_struct = NULL;
       
  1582     TInt return_value = 0;
       
  1583         	// Read data from the CFG file
       
  1584 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  1585 		{
       
  1586 		iLog->Log ( _L ( "read_data failed" ) );
       
  1587 		free_data ( connect_data );
       
  1588 		return_value = KErrGeneral;
       
  1589 		goto return_code;
       
  1590 		}
       
  1591 	//request formation	
       
  1592 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  1593 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1594 	
       
  1595 	//message header use
       
  1596 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  1597     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1598     
       
  1599     msgHdr->message_type = ELogin_Request;
       
  1600  
       
  1601     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1602     index += sizeof( message_hdr_req );
       
  1603     
       
  1604     int len = strlen(connect_data->username);
       
  1605     strcpy( smsg + index, connect_data->username );
       
  1606     index += len + 1;
       
  1607     
       
  1608     //appending password
       
  1609     
       
  1610     len = strlen(connect_data->password );
       
  1611     strcpy( smsg + index, connect_data->password );
       
  1612     index += len + 1;
       
  1613     
       
  1614     //appending server name
       
  1615     
       
  1616     len = strlen(connect_data->server );
       
  1617     strcpy( smsg + index, connect_data->server );
       
  1618     index += len + 1;
       
  1619     
       
  1620     //appending resource
       
  1621     len = strlen(connect_data->resource );
       
  1622     strcpy( smsg + index, connect_data->resource );
       
  1623     index += len + 1;
       
  1624     
       
  1625     //appending ssl
       
  1626     smsg[index++]= '1';
       
  1627     smsg[index++]= '\0';
       
  1628     
       
  1629     //appending server port
       
  1630     len = strlen(connect_data->port );
       
  1631     strcpy( smsg + index, connect_data->port );
       
  1632     index += len + 1;
       
  1633     
       
  1634     // appending IAP id
       
  1635     
       
  1636     smsg[index++]= '1';
       
  1637     smsg[index++]= '\0';
       
  1638     
       
  1639     //appending connmgr_bus
       
  1640     len = strlen(connect_data->connmgr_bus );
       
  1641     strcpy( smsg + index, connect_data->connmgr_bus );
       
  1642     index += len + 1;
       
  1643     
       
  1644     //appending connmgr_path
       
  1645     len = strlen(connect_data->connmgr_path );
       
  1646     strcpy( smsg + index, connect_data->connmgr_path );
       
  1647     index += len + 1;
       
  1648     
       
  1649     //appending protocol
       
  1650     len = strlen(connect_data->protocol );
       
  1651     strcpy( smsg + index, connect_data->protocol );
       
  1652     index += len + 1;
       
  1653     
       
  1654     #ifdef __WINSCW__
       
  1655     //proxy server
       
  1656     len = strlen(connect_data->proxy_data->proxy_server );
       
  1657     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  1658     index += len + 1;
       
  1659     
       
  1660     //proxy port
       
  1661     len = strlen(connect_data->proxy_data->proxy_port );
       
  1662     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  1663     index += len + 1;
       
  1664     
       
  1665     #endif
       
  1666     //running isoserver   
       
  1667     run_isoserver(); 
       
  1668      //create message queue for send request
       
  1669     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1670     //create message queue for response request
       
  1671     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1672 	/* Send Message to queueOne */
       
  1673 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1674     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1675     if (status < 0)
       
  1676     {
       
  1677     return_value = KErrGeneral;
       
  1678 	goto return_code;
       
  1679     }
       
  1680     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1681 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1682 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1683 	if( msg_struct->response != 0)
       
  1684     {
       
  1685     return_value = KErrGeneral;
       
  1686 	goto return_code;
       
  1687     }
       
  1688     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1689     if (status < 0)
       
  1690     {
       
  1691     return_value = KErrGeneral;
       
  1692 	goto return_code;
       
  1693     }
       
  1694     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1695 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1696 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1697 	if( msg_struct->response != 0)
       
  1698     {
       
  1699     return_value = KErrGeneral;
       
  1700 	goto return_code;
       
  1701     }
       
  1702     goto return_code;
       
  1703      //killing isoserver
       
  1704     return_code:
       
  1705     index=0;
       
  1706     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1707 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1708 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1709     msgHdr->message_type = EKill_Process;
       
  1710     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1711     index += sizeof( message_hdr_req );
       
  1712 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  1713     free( msg_struct );
       
  1714     return return_value;
       
  1715     }
       
  1716 
       
  1717 // -----------------------------------------------------------------------------
       
  1718 // Cisolationserver::Login with unexist user id
       
  1719 // Example test method function.
       
  1720 // (other items were commented in a header).
       
  1721 // -----------------------------------------------------------------------------
       
  1722 //
       
  1723 TInt Cisolationserver::LoginWithUnexistUserId( CStifItemParser& aItem )
       
  1724     {
       
  1725 
       
  1726     	
       
  1727     ConnectData  *connect_data = NULL;
       
  1728     char smsg[MAX_MSG_SIZE];
       
  1729     char rmsg[MAX_MSG_SIZE];
       
  1730     int index=0;
       
  1731     
       
  1732 		
       
  1733 	int timeout = 100;
       
  1734 	int nBytes;
       
  1735 
       
  1736     int result = 0;
       
  1737     int err = 0;
       
  1738     int status = 0;
       
  1739     message_hdr_req *msgHdr = NULL;  
       
  1740     message_hdr_resp* msg_struct = NULL;
       
  1741     TInt return_value = 0;
       
  1742         	// Read data from the CFG file
       
  1743 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  1744 		{
       
  1745 		iLog->Log ( _L ( "read_data failed" ) );
       
  1746 		free_data ( connect_data );
       
  1747 		return_value = KErrGeneral;
       
  1748 		goto return_code;
       
  1749 		}
       
  1750 	//request formation	
       
  1751 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  1752 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1753 	
       
  1754 	//message header use
       
  1755 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  1756     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1757     
       
  1758     msgHdr->message_type = ELogin_Request;
       
  1759  
       
  1760     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1761     index += sizeof( message_hdr_req );
       
  1762     
       
  1763     int len = strlen(connect_data->username);
       
  1764     strcpy( smsg + index, connect_data->username );
       
  1765     index += len + 1;
       
  1766     
       
  1767     //appending password
       
  1768     
       
  1769     len = strlen(connect_data->password );
       
  1770     strcpy( smsg + index, connect_data->password );
       
  1771     index += len + 1;
       
  1772     
       
  1773     //appending server name
       
  1774     
       
  1775     len = strlen(connect_data->server );
       
  1776     strcpy( smsg + index, connect_data->server );
       
  1777     index += len + 1;
       
  1778     
       
  1779     //appending resource
       
  1780     len = strlen(connect_data->resource );
       
  1781     strcpy( smsg + index, connect_data->resource );
       
  1782     index += len + 1;
       
  1783     
       
  1784     //appending ssl
       
  1785     smsg[index++]= '1';
       
  1786     smsg[index++]= '\0';
       
  1787     
       
  1788     //appending server port
       
  1789     len = strlen(connect_data->port );
       
  1790     strcpy( smsg + index, connect_data->port );
       
  1791     index += len + 1;
       
  1792     
       
  1793     // appending IAP id
       
  1794     
       
  1795     smsg[index++]= '1';
       
  1796     smsg[index++]= '\0';
       
  1797     
       
  1798     //appending connmgr_bus
       
  1799     len = strlen(connect_data->connmgr_bus );
       
  1800     strcpy( smsg + index, connect_data->connmgr_bus );
       
  1801     index += len + 1;
       
  1802     
       
  1803     //appending connmgr_path
       
  1804     len = strlen(connect_data->connmgr_path );
       
  1805     strcpy( smsg + index, connect_data->connmgr_path );
       
  1806     index += len + 1;
       
  1807     
       
  1808     //appending protocol
       
  1809     len = strlen(connect_data->protocol );
       
  1810     strcpy( smsg + index, connect_data->protocol );
       
  1811     index += len + 1;
       
  1812     
       
  1813     #ifdef __WINSCW__
       
  1814     //proxy server
       
  1815     len = strlen(connect_data->proxy_data->proxy_server );
       
  1816     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  1817     index += len + 1;
       
  1818     
       
  1819     //proxy port
       
  1820     len = strlen(connect_data->proxy_data->proxy_port );
       
  1821     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  1822     index += len + 1;
       
  1823     
       
  1824     #endif
       
  1825     //running isoserver   
       
  1826     run_isoserver(); 
       
  1827     //create message queue for send request
       
  1828     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1829     //create message queue for response request
       
  1830     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1831 		
       
  1832 	
       
  1833 	/* Send Message to queueOne */
       
  1834 	
       
  1835 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  1836     
       
  1837     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1838     
       
  1839     if (status < 0)
       
  1840     {
       
  1841     return_value = KErrGeneral;	
       
  1842     }
       
  1843     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1844 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1845 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1846 	if( msg_struct->response != 0 )
       
  1847     {
       
  1848       return_value = KErrGeneral;
       
  1849 	goto return_code;
       
  1850     }
       
  1851     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  1852     
       
  1853     if (status < 0)
       
  1854     {
       
  1855     return_value = KErrGeneral;
       
  1856 	goto return_code;	
       
  1857     }
       
  1858     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  1859 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  1860 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  1861 	
       
  1862 	if( msg_struct->response != 0)
       
  1863     {
       
  1864     	return_value = KErrGeneral;
       
  1865 	goto return_code;
       
  1866     } 
       
  1867     
       
  1868     //killing isoserver
       
  1869     return_code:
       
  1870     index=0;
       
  1871     memset( smsg, '\0', MAX_MSG_SIZE );
       
  1872 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1873 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1874     msgHdr->message_type = EKill_Process;
       
  1875     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1876     index += sizeof( message_hdr_req );
       
  1877 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  1878     free( msg_struct );
       
  1879     return return_value;
       
  1880     }
       
  1881     
       
  1882     
       
  1883   // -----------------------------------------------------------------------------
       
  1884 // Cisolationserver::connect with unexist server
       
  1885 // Example test method function.
       
  1886 // (other items were commented in a header).
       
  1887 // -----------------------------------------------------------------------------
       
  1888 //
       
  1889 TInt Cisolationserver::LoginWithUnexistServer( CStifItemParser& aItem )
       
  1890     {
       
  1891 
       
  1892     /*	
       
  1893     ConnectData  *connect_data = NULL;
       
  1894     char smsg[MAX_MSG_SIZE];
       
  1895     char rmsg[MAX_MSG_SIZE];
       
  1896     int index=0;
       
  1897     
       
  1898 		
       
  1899 	int timeout = 100;
       
  1900 	int nBytes;
       
  1901 
       
  1902     int result = 0;
       
  1903     int err = 0;
       
  1904     int status = 0;
       
  1905     message_hdr_req *msgHdr = NULL;  
       
  1906     message_hdr_resp* msg_struct = NULL;
       
  1907     TInt return_value = 0;
       
  1908         	// Read data from the CFG file
       
  1909 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  1910 		{
       
  1911 		iLog->Log ( _L ( "read_data failed" ) );
       
  1912 		free_data ( connect_data );
       
  1913 		return_value = KErrGeneral;
       
  1914 		goto return_code;
       
  1915 		}
       
  1916 	//request formation	
       
  1917 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  1918 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  1919 	
       
  1920 	//message header use
       
  1921 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  1922     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  1923     
       
  1924     msgHdr->message_type = ELogin_Request;
       
  1925  
       
  1926     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  1927     index += sizeof( message_hdr_req );
       
  1928     
       
  1929     int len = strlen(connect_data->username);
       
  1930     strcpy( smsg + index, connect_data->username );
       
  1931     index += len + 1;
       
  1932     
       
  1933     //appending password
       
  1934     
       
  1935     len = strlen(connect_data->password );
       
  1936     strcpy( smsg + index, connect_data->password );
       
  1937     index += len + 1;
       
  1938     
       
  1939     //appending server name
       
  1940     
       
  1941     len = strlen(connect_data->server );
       
  1942     strcpy( smsg + index, connect_data->server );
       
  1943     index += len + 1;
       
  1944     
       
  1945     //appending resource
       
  1946     len = strlen(connect_data->resource );
       
  1947     strcpy( smsg + index, connect_data->resource );
       
  1948     index += len + 1;
       
  1949     
       
  1950     //appending ssl
       
  1951     smsg[index++]= '1';
       
  1952     smsg[index++]= '\0';
       
  1953     
       
  1954     //appending server port
       
  1955     len = strlen(connect_data->port );
       
  1956     strcpy( smsg + index, connect_data->port );
       
  1957     index += len + 1;
       
  1958     
       
  1959     // appending IAP id
       
  1960     
       
  1961     smsg[index++]= '1';
       
  1962     smsg[index++]= '\0';
       
  1963     
       
  1964     //appending connmgr_bus
       
  1965     len = strlen(connect_data->connmgr_bus );
       
  1966     strcpy( smsg + index, connect_data->connmgr_bus );
       
  1967     index += len + 1;
       
  1968     
       
  1969     //appending connmgr_path
       
  1970     len = strlen(connect_data->connmgr_path );
       
  1971     strcpy( smsg + index, connect_data->connmgr_path );
       
  1972     index += len + 1;
       
  1973     
       
  1974     //appending protocol
       
  1975     len = strlen(connect_data->protocol );
       
  1976     strcpy( smsg + index, connect_data->protocol );
       
  1977     index += len + 1;
       
  1978     
       
  1979     #ifdef __WINSCW__
       
  1980     //proxy server
       
  1981     len = strlen(connect_data->proxy_data->proxy_server );
       
  1982     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  1983     index += len + 1;
       
  1984     
       
  1985     //proxy port
       
  1986     len = strlen(connect_data->proxy_data->proxy_port );
       
  1987     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  1988     index += len + 1;
       
  1989     
       
  1990     #endif
       
  1991     //running isoserver   
       
  1992     run_isoserver();     
       
  1993     //create message queue for send request
       
  1994     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1995     //create message queue for response request
       
  1996     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  1997 		
       
  1998 	
       
  1999 	//Send Message to queueOne 
       
  2000 	
       
  2001 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2002     
       
  2003     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2004     
       
  2005     if (status < 0)
       
  2006     {
       
  2007     return_value = KErrGeneral;
       
  2008 	goto return_code;	
       
  2009     }
       
  2010     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2011 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2012 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2013 	
       
  2014 	if( msg_struct->response != 0)
       
  2015     {
       
  2016     	return_value = KErrGeneral;
       
  2017 	goto return_code;
       
  2018     }
       
  2019     
       
  2020     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2021     
       
  2022     if (status < 0)
       
  2023     {
       
  2024     return_value = KErrGeneral;
       
  2025 	goto return_code;	
       
  2026     }
       
  2027     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2028 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2029 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2030 	
       
  2031 	if( msg_struct->response != 0)
       
  2032     {
       
  2033     	return_value = KErrGeneral;
       
  2034 	goto return_code;
       
  2035     }
       
  2036     // login end
       
  2037     //killing isoserver
       
  2038     return_code:
       
  2039     index=0;
       
  2040     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2041 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2042 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2043     msgHdr->message_type = EKill_Process;
       
  2044     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2045     index += sizeof( message_hdr_req );
       
  2046 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  2047     free( msg_struct );
       
  2048     return return_value;
       
  2049     */
       
  2050     //LM is not getting call back from server so we are just saying KerrGeneral
       
  2051     return KErrGeneral;
       
  2052     }
       
  2053     
       
  2054     
       
  2055     
       
  2056     // -----------------------------------------------------------------------------
       
  2057 // Cisolationserver::Login with correct data
       
  2058 // Example test method function.
       
  2059 // (other items were commented in a header).
       
  2060 // -----------------------------------------------------------------------------
       
  2061 //
       
  2062 TInt Cisolationserver::LoginWithBlankUserId( CStifItemParser& aItem )
       
  2063     {
       
  2064     ConnectData  *connect_data = NULL;
       
  2065     char smsg[MAX_MSG_SIZE];
       
  2066     char rmsg[MAX_MSG_SIZE];
       
  2067     int index=0;
       
  2068     int timeout = 100;
       
  2069 	int nBytes;
       
  2070     int result = 0;
       
  2071     int err = 0;
       
  2072     int status = 0;
       
  2073     message_hdr_req *msgHdr = NULL;  
       
  2074     message_hdr_resp* msg_struct = NULL;
       
  2075     TInt return_value = 0;
       
  2076         	// Read data from the CFG file
       
  2077 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  2078 		{
       
  2079 		iLog->Log ( _L ( "read_data failed" ) );
       
  2080 		free_data ( connect_data );
       
  2081 		return_value = KErrGeneral;
       
  2082 		goto return_code;
       
  2083 		}
       
  2084 
       
  2085 	//request formation	
       
  2086 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  2087 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2088 	
       
  2089 	//message header use
       
  2090 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  2091     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2092     
       
  2093     msgHdr->message_type = ELogin_Request;
       
  2094  
       
  2095     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2096     index += sizeof( message_hdr_req );
       
  2097     // blank user id
       
  2098     smsg[index++]='\0';    
       
  2099     smsg[index++]='\0';
       
  2100     
       
  2101     //appending password
       
  2102     
       
  2103    int len = strlen(connect_data->password );
       
  2104     strcpy( smsg + index, connect_data->password );
       
  2105     index += len + 1;
       
  2106     
       
  2107     //appending server name
       
  2108     
       
  2109     len = strlen(connect_data->server );
       
  2110     strcpy( smsg + index, connect_data->server );
       
  2111     index += len + 1;
       
  2112     
       
  2113     //appending resource
       
  2114     len = strlen(connect_data->resource );
       
  2115     strcpy( smsg + index, connect_data->resource );
       
  2116     index += len + 1;
       
  2117     
       
  2118     //appending ssl
       
  2119     smsg[index++]= '1';
       
  2120     smsg[index++]= '\0';
       
  2121     
       
  2122     //appending server port
       
  2123     len = strlen(connect_data->port );
       
  2124     strcpy( smsg + index, connect_data->port );
       
  2125     index += len + 1;
       
  2126     
       
  2127     // appending IAP id
       
  2128     
       
  2129     smsg[index++]= '1';
       
  2130     smsg[index++]= '\0';
       
  2131     
       
  2132     //appending connmgr_bus
       
  2133     len = strlen(connect_data->connmgr_bus );
       
  2134     strcpy( smsg + index, connect_data->connmgr_bus );
       
  2135     index += len + 1;
       
  2136     
       
  2137     //appending connmgr_path
       
  2138     len = strlen(connect_data->connmgr_path );
       
  2139     strcpy( smsg + index, connect_data->connmgr_path );
       
  2140     index += len + 1;
       
  2141     
       
  2142     //appending protocol
       
  2143     len = strlen(connect_data->protocol );
       
  2144     strcpy( smsg + index, connect_data->protocol );
       
  2145     index += len + 1;
       
  2146     
       
  2147     #ifdef __WINSCW__
       
  2148     //proxy server
       
  2149     len = strlen(connect_data->proxy_data->proxy_server );
       
  2150     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  2151     index += len + 1;
       
  2152     
       
  2153     //proxy port
       
  2154     len = strlen(connect_data->proxy_data->proxy_port );
       
  2155     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  2156     index += len + 1;
       
  2157     
       
  2158     #endif
       
  2159     //running isoserver   
       
  2160     run_isoserver(); 
       
  2161     //create message queue for send request
       
  2162     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2163     //create message queue for response request
       
  2164     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2165 		
       
  2166 	
       
  2167 	/* Send Message to queueOne */
       
  2168 	
       
  2169 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2170     
       
  2171     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2172     
       
  2173     if (status < 0)
       
  2174     {
       
  2175     return_value = KErrGeneral;
       
  2176 	goto return_code;	
       
  2177     }
       
  2178     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2179 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2180 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2181 	
       
  2182 	if( msg_struct->error_type > 0)
       
  2183     {
       
  2184     return_value = KErrGeneral;
       
  2185 	goto return_code;
       
  2186     }
       
  2187     goto return_code;
       
  2188     //killing isoserver
       
  2189     return_code:
       
  2190     index=0;
       
  2191     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2192 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2193 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2194     msgHdr->message_type = EKill_Process;
       
  2195     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2196     index += sizeof( message_hdr_req );
       
  2197 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  2198     free( msg_struct );
       
  2199     return return_value;
       
  2200     }
       
  2201 
       
  2202  // -----------------------------------------------------------------------------
       
  2203 // Cisolationserver::Logout from server
       
  2204 // Example test method function.
       
  2205 // (other items were commented in a header).
       
  2206 // -----------------------------------------------------------------------------
       
  2207 //
       
  2208 TInt Cisolationserver::LoginLogOutWithReapitiveSession( CStifItemParser& aItem )
       
  2209     {
       
  2210 
       
  2211     	
       
  2212     ConnectData  *connect_data = NULL;
       
  2213     char smsg[MAX_MSG_SIZE];
       
  2214     char rmsg[MAX_MSG_SIZE];
       
  2215     int index=0;
       
  2216     FILE *fp;
       
  2217 		
       
  2218 	int timeout = 100;
       
  2219 	int nBytes;
       
  2220 
       
  2221     int result = 0;
       
  2222     int err = 0;
       
  2223     int status = 0;
       
  2224     message_hdr_req *msgHdr = NULL;  
       
  2225     message_hdr_resp* msg_struct = NULL;
       
  2226     TInt return_value = 0;
       
  2227         	// Read data from the CFG file
       
  2228 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  2229 		{
       
  2230 		iLog->Log ( _L ( "read_data failed" ) );
       
  2231 		free_data ( connect_data );
       
  2232 		return_value = KErrGeneral;
       
  2233 		goto return_code;
       
  2234 		}
       
  2235 	//request formation	
       
  2236 	 index=0;
       
  2237 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  2238 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2239 	
       
  2240 	//message header use
       
  2241 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  2242     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2243     
       
  2244     msgHdr->message_type = ELogin_Request;
       
  2245  
       
  2246     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2247     index += sizeof( message_hdr_req );
       
  2248     
       
  2249     int len = strlen(connect_data->username);
       
  2250     strcpy( smsg + index, connect_data->username );
       
  2251     index += len + 1;
       
  2252     
       
  2253     //appending password
       
  2254     
       
  2255     len = strlen(connect_data->password );
       
  2256     strcpy( smsg + index, connect_data->password );
       
  2257     index += len + 1;
       
  2258     
       
  2259     //appending server name
       
  2260     
       
  2261     len = strlen(connect_data->server );
       
  2262     strcpy( smsg + index, connect_data->server );
       
  2263     index += len + 1;
       
  2264     
       
  2265     //appending resource
       
  2266     len = strlen(connect_data->resource );
       
  2267     strcpy( smsg + index, connect_data->resource );
       
  2268     index += len + 1;
       
  2269     
       
  2270     //appending ssl
       
  2271     smsg[index++]= '1';
       
  2272     smsg[index++]= '\0';
       
  2273     
       
  2274     //appending server port
       
  2275     len = strlen(connect_data->port );
       
  2276     strcpy( smsg + index, connect_data->port );
       
  2277     index += len + 1;
       
  2278     
       
  2279     // appending IAP id
       
  2280     
       
  2281     smsg[index++]= '1';
       
  2282     smsg[index++]= '\0';
       
  2283     
       
  2284     //appending connmgr_bus
       
  2285     len = strlen(connect_data->connmgr_bus );
       
  2286     strcpy( smsg + index, connect_data->connmgr_bus );
       
  2287     index += len + 1;
       
  2288     
       
  2289     //appending connmgr_path
       
  2290     len = strlen(connect_data->connmgr_path );
       
  2291     strcpy( smsg + index, connect_data->connmgr_path );
       
  2292     index += len + 1;
       
  2293     
       
  2294     //appending protocol
       
  2295     len = strlen(connect_data->protocol );
       
  2296     strcpy( smsg + index, connect_data->protocol );
       
  2297     index += len + 1;
       
  2298     
       
  2299     #ifdef __WINSCW__
       
  2300     //proxy server
       
  2301     len = strlen(connect_data->proxy_data->proxy_server );
       
  2302     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  2303     index += len + 1;
       
  2304     
       
  2305     //proxy port
       
  2306     len = strlen(connect_data->proxy_data->proxy_port );
       
  2307     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  2308     index += len + 1;
       
  2309     
       
  2310     #endif
       
  2311     //running isoserver   
       
  2312     run_isoserver(); 
       
  2313     
       
  2314     
       
  2315         
       
  2316     //create message queue for send request
       
  2317     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2318     //create message queue for response request
       
  2319     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2320 		
       
  2321 	
       
  2322 	/* Send Message to queueOne */
       
  2323 	
       
  2324 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2325     
       
  2326     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2327     
       
  2328     if (status < 0)
       
  2329     {
       
  2330     return_value = KErrGeneral;
       
  2331 	goto return_code;	
       
  2332     }
       
  2333     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2334 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2335 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2336 	
       
  2337 	if( msg_struct->response != 1)
       
  2338     {
       
  2339     return_value = KErrGeneral;
       
  2340 	goto return_code;
       
  2341     }
       
  2342     
       
  2343     
       
  2344     // login end
       
  2345     //fetch req..
       
  2346     for (int i= 0 ;i<3 ;i++)
       
  2347     {
       
  2348         
       
  2349     fp = fopen("c:\\fetch_contact.txt","a");
       
  2350 	do  {
       
  2351 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  2352 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  2353 		fwrite(rmsg,1,status,fp);
       
  2354 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2355 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  2356 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  2357 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  2358 	fclose(fp);	
       
  2359 	
       
  2360     }
       
  2361 
       
  2362 	//fetch end
       
  2363     // logout test code from server
       
  2364     index=0;
       
  2365     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2366 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2367 	
       
  2368 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2369     
       
  2370     msgHdr->message_type = ELogout_Request;
       
  2371  
       
  2372     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2373     index += sizeof( message_hdr_req );
       
  2374 
       
  2375 	
       
  2376 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2377     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2378     
       
  2379     if (status < 0)
       
  2380     {
       
  2381     return_value = KErrGeneral;
       
  2382 	goto return_code;	
       
  2383     }
       
  2384 	msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2385 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2386 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2387 	if ( msg_struct->response != 1)
       
  2388     {
       
  2389     	return_value = KErrGeneral;
       
  2390 	goto return_code;
       
  2391     }
       
  2392     //killing isolation server
       
  2393     index=0;
       
  2394     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2395 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2396 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2397     msgHdr->message_type = EKill_Process;
       
  2398     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2399     index += sizeof( message_hdr_req );
       
  2400 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  2401     	//request formation	
       
  2402 	 index=0;
       
  2403 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  2404 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2405 	
       
  2406 	//message header use
       
  2407 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  2408     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2409     
       
  2410     msgHdr->message_type = ELogin_Request;
       
  2411  
       
  2412     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2413     index += sizeof( message_hdr_req );
       
  2414     
       
  2415      len = strlen(connect_data->username);
       
  2416     strcpy( smsg + index, connect_data->username );
       
  2417     index += len + 1;
       
  2418     
       
  2419     //appending password
       
  2420     
       
  2421     len = strlen(connect_data->password );
       
  2422     strcpy( smsg + index, connect_data->password );
       
  2423     index += len + 1;
       
  2424     
       
  2425     //appending server name
       
  2426     
       
  2427     len = strlen(connect_data->server );
       
  2428     strcpy( smsg + index, connect_data->server );
       
  2429     index += len + 1;
       
  2430     
       
  2431     //appending resource
       
  2432     len = strlen(connect_data->resource );
       
  2433     strcpy( smsg + index, connect_data->resource );
       
  2434     index += len + 1;
       
  2435     
       
  2436     //appending ssl
       
  2437     smsg[index++]= '1';
       
  2438     smsg[index++]= '\0';
       
  2439     
       
  2440     //appending server port
       
  2441     len = strlen(connect_data->port );
       
  2442     strcpy( smsg + index, connect_data->port );
       
  2443     index += len + 1;
       
  2444     
       
  2445     // appending IAP id
       
  2446     
       
  2447     smsg[index++]= '1';
       
  2448     smsg[index++]= '\0';
       
  2449     
       
  2450     //appending connmgr_bus
       
  2451     len = strlen(connect_data->connmgr_bus );
       
  2452     strcpy( smsg + index, connect_data->connmgr_bus );
       
  2453     index += len + 1;
       
  2454     
       
  2455     //appending connmgr_path
       
  2456     len = strlen(connect_data->connmgr_path );
       
  2457     strcpy( smsg + index, connect_data->connmgr_path );
       
  2458     index += len + 1;
       
  2459     
       
  2460     //appending protocol
       
  2461     len = strlen(connect_data->protocol );
       
  2462     strcpy( smsg + index, connect_data->protocol );
       
  2463     index += len + 1;
       
  2464     
       
  2465     #ifdef __WINSCW__
       
  2466     //proxy server
       
  2467     len = strlen(connect_data->proxy_data->proxy_server );
       
  2468     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  2469     index += len + 1;
       
  2470     
       
  2471     //proxy port
       
  2472     len = strlen(connect_data->proxy_data->proxy_port );
       
  2473     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  2474     index += len + 1;
       
  2475     
       
  2476     #endif
       
  2477     
       
  2478     //running isoserver   
       
  2479     run_isoserver(); 
       
  2480     
       
  2481         
       
  2482     //create message queue for send request
       
  2483     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2484     //create message queue for response request
       
  2485     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2486 		
       
  2487 	
       
  2488 	/* Send Message to queueOne */
       
  2489 	
       
  2490 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2491     
       
  2492     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2493     
       
  2494     if (status < 0)
       
  2495     {
       
  2496     return_value = KErrGeneral;
       
  2497 	goto return_code;	
       
  2498     }
       
  2499     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2500 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2501 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2502 	
       
  2503 	if( msg_struct->response != 1)
       
  2504     {
       
  2505     	return_value = KErrGeneral;
       
  2506 	goto return_code;
       
  2507     }
       
  2508     
       
  2509     
       
  2510     // login end
       
  2511     //fetch req..
       
  2512     for (int i= 0 ;i<3 ;i++)
       
  2513     {
       
  2514         
       
  2515     fp = fopen("c:\\fetch_contact.txt","a");
       
  2516 	do  {
       
  2517 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  2518 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  2519 		fwrite(rmsg,1,status,fp);
       
  2520 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2521 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  2522 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  2523 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  2524 	fclose(fp);	
       
  2525 	
       
  2526     }
       
  2527 
       
  2528 	//fetch end
       
  2529 	
       
  2530     // logout test code from server
       
  2531     index=0;
       
  2532     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2533 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2534 	
       
  2535 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2536     
       
  2537     msgHdr->message_type = ELogout_Request;
       
  2538  
       
  2539     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2540     index += sizeof( message_hdr_req );
       
  2541 
       
  2542 	
       
  2543 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2544     
       
  2545     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2546     
       
  2547     if (status < 0)
       
  2548     {
       
  2549     return_value = KErrGeneral;
       
  2550 	goto return_code;	
       
  2551     }
       
  2552 	msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2553 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2554 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2555 	if ( msg_struct->response != 1)
       
  2556     {
       
  2557     return_value = KErrGeneral;
       
  2558 	goto return_code;
       
  2559     }
       
  2560     
       
  2561     
       
  2562      //killing isoserver
       
  2563     return_code:
       
  2564     index=0;
       
  2565     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2566 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2567 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2568     msgHdr->message_type = EKill_Process;
       
  2569     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2570     index += sizeof( message_hdr_req );
       
  2571 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  2572     free( msg_struct );
       
  2573     return return_value;
       
  2574     }
       
  2575     
       
  2576     // -----------------------------------------------------------------------------
       
  2577 // Cisolationserver::connect with invalid port
       
  2578 // Example test method function.
       
  2579 // (other items were commented in a header).
       
  2580 // -----------------------------------------------------------------------------
       
  2581 //
       
  2582 TInt Cisolationserver::LoginWithInvalidPortAddress( CStifItemParser& aItem )
       
  2583     {
       
  2584 
       
  2585     /*	
       
  2586     ConnectData  *connect_data = NULL;
       
  2587     char smsg[MAX_MSG_SIZE];
       
  2588     char rmsg[MAX_MSG_SIZE];
       
  2589     int index=0;
       
  2590     
       
  2591 		
       
  2592 	int timeout = 100;
       
  2593 	int nBytes;
       
  2594 
       
  2595     int result = 0;
       
  2596     int err = 0;
       
  2597     int status = 0;
       
  2598     message_hdr_req *msgHdr = NULL;  
       
  2599     message_hdr_resp* msg_struct = NULL;
       
  2600     TInt return_value = 0;
       
  2601         	// Read data from the CFG file
       
  2602 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  2603 		{
       
  2604 		iLog->Log ( _L ( "read_data failed" ) );
       
  2605 		free_data ( connect_data );
       
  2606 		return_value = KErrGeneral;
       
  2607 		goto return_code;
       
  2608 		}
       
  2609 	//request formation	
       
  2610 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  2611 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2612 	
       
  2613 	//message header use
       
  2614 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  2615     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2616     
       
  2617     msgHdr->message_type = ELogin_Request;
       
  2618  
       
  2619     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2620     index += sizeof( message_hdr_req );
       
  2621     
       
  2622     int len = strlen(connect_data->username);
       
  2623     strcpy( smsg + index, connect_data->username );
       
  2624     index += len + 1;
       
  2625     
       
  2626     //appending password
       
  2627     
       
  2628     len = strlen(connect_data->password );
       
  2629     strcpy( smsg + index, connect_data->password );
       
  2630     index += len + 1;
       
  2631     
       
  2632     //appending server name
       
  2633     
       
  2634     len = strlen(connect_data->server );
       
  2635     strcpy( smsg + index, connect_data->server );
       
  2636     index += len + 1;
       
  2637     
       
  2638     //appending resource
       
  2639     len = strlen(connect_data->resource );
       
  2640     strcpy( smsg + index, connect_data->resource );
       
  2641     index += len + 1;
       
  2642     
       
  2643     //appending ssl
       
  2644     smsg[index++]= '1';
       
  2645     smsg[index++]= '\0';
       
  2646     
       
  2647     //appending server port
       
  2648     
       
  2649     smsg[index++]='4';
       
  2650     smsg[index++]='4';
       
  2651     smsg[index++]='2';
       
  2652     
       
  2653     smsg[index++]='\0';
       
  2654     
       
  2655     // appending IAP id
       
  2656     
       
  2657     smsg[index++]= '1';
       
  2658     smsg[index++]= '\0';
       
  2659     
       
  2660     //appending connmgr_bus
       
  2661     len = strlen(connect_data->connmgr_bus );
       
  2662     strcpy( smsg + index, connect_data->connmgr_bus );
       
  2663     index += len + 1;
       
  2664     
       
  2665     //appending connmgr_path
       
  2666     len = strlen(connect_data->connmgr_path );
       
  2667     strcpy( smsg + index, connect_data->connmgr_path );
       
  2668     index += len + 1;
       
  2669     
       
  2670     //appending protocol
       
  2671     len = strlen(connect_data->protocol );
       
  2672     strcpy( smsg + index, connect_data->protocol );
       
  2673     index += len + 1;
       
  2674     
       
  2675     #ifdef __WINSCW__
       
  2676     //proxy server
       
  2677     len = strlen(connect_data->proxy_data->proxy_server );
       
  2678     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  2679     index += len + 1;
       
  2680     
       
  2681     //proxy port
       
  2682     len = strlen(connect_data->proxy_data->proxy_port );
       
  2683     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  2684     index += len + 1;
       
  2685     
       
  2686     #endif
       
  2687     //running isoserver   
       
  2688     run_isoserver(); 
       
  2689     //create message queue for send request
       
  2690     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2691     //create message queue for response request
       
  2692     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2693 		
       
  2694 	
       
  2695 	// Send Message to queueOne 
       
  2696 	
       
  2697 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2698     
       
  2699     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2700     
       
  2701     if (status < 0)
       
  2702     {
       
  2703     return_value = KErrGeneral;
       
  2704 	goto return_code;	
       
  2705     }
       
  2706     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2707 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2708 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2709 	
       
  2710 	if( msg_struct->response == 1)
       
  2711     {
       
  2712     	return_value = KErrGeneral;
       
  2713 	goto return_code;
       
  2714     }
       
  2715     
       
  2716     //killing isoserver
       
  2717     return_code:
       
  2718     index=0;
       
  2719     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2720 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2721 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2722     msgHdr->message_type = EKill_Process;
       
  2723     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2724     index += sizeof( message_hdr_req );
       
  2725 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  2726     free( msg_struct );
       
  2727     return return_value;
       
  2728     */
       
  2729     //LM is not getting call back from server so we are just saying KerrGeneral
       
  2730     return KErrGeneral;
       
  2731     }
       
  2732 
       
  2733    
       
  2734    // -----------------------------------------------------------------------------
       
  2735 // Cisolationserver::Login with correct data
       
  2736 // Example test method function.
       
  2737 // (other items were commented in a header).
       
  2738 // -----------------------------------------------------------------------------
       
  2739 //
       
  2740 TInt Cisolationserver::LoginWithMissingSettings( CStifItemParser& aItem )
       
  2741     {
       
  2742 
       
  2743     	
       
  2744     ConnectData  *connect_data = NULL;
       
  2745     char smsg[MAX_MSG_SIZE];
       
  2746     char rmsg[MAX_MSG_SIZE];
       
  2747     int index=0;
       
  2748     
       
  2749 		
       
  2750 	int timeout = 100;
       
  2751 	int nBytes;
       
  2752 
       
  2753     int result = 0;
       
  2754     int err = 0;
       
  2755     int status = 0;
       
  2756     FILE *fp;
       
  2757     message_hdr_req *msgHdr = NULL;  
       
  2758     message_hdr_resp* msg_struct = NULL;
       
  2759     TInt return_value = 0;
       
  2760         	// Read data from the CFG file
       
  2761 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  2762 		{
       
  2763 		iLog->Log ( _L ( "read_data failed" ) );
       
  2764 		free_data ( connect_data );
       
  2765 		return_value = KErrGeneral;
       
  2766 		goto return_code;
       
  2767 		}
       
  2768 	//request formation	
       
  2769 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  2770 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2771 	
       
  2772 	//message header use
       
  2773 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  2774     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2775     
       
  2776     msgHdr->message_type = ELogin_Request;
       
  2777  
       
  2778     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2779     index += sizeof( message_hdr_req );
       
  2780     
       
  2781     int len = strlen(connect_data->username);
       
  2782     strcpy( smsg + index, connect_data->username );
       
  2783     index += len + 1;
       
  2784     
       
  2785     //appending password
       
  2786     
       
  2787     len = strlen(connect_data->password );
       
  2788     strcpy( smsg + index, connect_data->password );
       
  2789     index += len + 1;
       
  2790    
       
  2791     //appending server name
       
  2792     
       
  2793     len = strlen(connect_data->server );
       
  2794     strcpy( smsg + index, connect_data->server );
       
  2795     index += len + 1;
       
  2796     
       
  2797     //appending resource
       
  2798     len = strlen(connect_data->resource );
       
  2799     strcpy( smsg + index, connect_data->resource );
       
  2800     index += len + 1;
       
  2801     
       
  2802     // ssl is missing here
       
  2803         
       
  2804     //appending server port
       
  2805     len = strlen(connect_data->port );
       
  2806     strcpy( smsg + index, connect_data->port );
       
  2807     index += len + 1;
       
  2808     
       
  2809     // appending IAP id
       
  2810     
       
  2811     smsg[index++]= '1';
       
  2812     smsg[index++]= '\0';
       
  2813     
       
  2814     //appending connmgr_bus
       
  2815     len = strlen(connect_data->connmgr_bus );
       
  2816     strcpy( smsg + index, connect_data->connmgr_bus );
       
  2817     index += len + 1;
       
  2818     
       
  2819     //appending connmgr_path
       
  2820     len = strlen(connect_data->connmgr_path );
       
  2821     strcpy( smsg + index, connect_data->connmgr_path );
       
  2822     index += len + 1;
       
  2823     
       
  2824     //appending protocol
       
  2825     len = strlen(connect_data->protocol );
       
  2826     strcpy( smsg + index, connect_data->protocol );
       
  2827     index += len + 1;
       
  2828     
       
  2829     #ifdef __WINSCW__
       
  2830     //proxy server
       
  2831     len = strlen(connect_data->proxy_data->proxy_server );
       
  2832     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  2833     index += len + 1;
       
  2834     
       
  2835     //proxy port
       
  2836     len = strlen(connect_data->proxy_data->proxy_port );
       
  2837     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  2838     index += len + 1;
       
  2839     
       
  2840     #endif
       
  2841     //running isoserver   
       
  2842     run_isoserver();    
       
  2843     //create message queue for send request
       
  2844     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2845     //create message queue for response request
       
  2846     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2847 	
       
  2848 	
       
  2849 	/* Send Message to queueOne */
       
  2850 	
       
  2851 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  2852     
       
  2853     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  2854     
       
  2855     if (status < 0)
       
  2856     {
       
  2857     return_value = KErrGeneral;
       
  2858 	goto return_code;	
       
  2859     }
       
  2860    
       
  2861     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  2862 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  2863 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  2864 	
       
  2865 	if( msg_struct->response != 0)
       
  2866     {
       
  2867     	return_value = KErrGeneral;
       
  2868 	goto return_code;
       
  2869     }
       
  2870     //killing isoserver
       
  2871     return_code:
       
  2872     index=0;
       
  2873     memset( smsg, '\0', MAX_MSG_SIZE );
       
  2874 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2875 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2876     msgHdr->message_type = EKill_Process;
       
  2877     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2878     index += sizeof( message_hdr_req );
       
  2879 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  2880     free( msg_struct );
       
  2881     return return_value;
       
  2882     }
       
  2883 
       
  2884    // -----------------------------------------------------------------------------
       
  2885 // Cisolationserver::LoginWhenTGAndDDAreNotRunning
       
  2886 // Example test method function.
       
  2887 // (other items were commented in a header).
       
  2888 // -----------------------------------------------------------------------------
       
  2889 //
       
  2890 TInt Cisolationserver::LoginWhenTGAndDDAreNotRunning( CStifItemParser& aItem )
       
  2891     {
       
  2892     /*
       
  2893     	
       
  2894     ConnectData  *connect_data = NULL;
       
  2895     char smsg[MAX_MSG_SIZE];
       
  2896     char rmsg[MAX_MSG_SIZE];
       
  2897     int index=0;
       
  2898     
       
  2899 		
       
  2900 	int timeout = 100;
       
  2901 	int nBytes;
       
  2902 
       
  2903     int result = 0;
       
  2904     int err = 0;
       
  2905     int status = 0;
       
  2906     FILE *fp;
       
  2907     message_hdr_req *msgHdr = NULL;  
       
  2908     message_hdr_resp* msg_struct = NULL;
       
  2909     TInt return_value = 0;
       
  2910         	// Read data from the CFG file
       
  2911 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  2912 		{
       
  2913 		iLog->Log ( _L ( "read_data failed" ) );
       
  2914 		free_data ( connect_data );
       
  2915 		return_value = KErrGeneral;
       
  2916 		goto return_code;
       
  2917 		}
       
  2918 	//request formation	
       
  2919 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  2920 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  2921 	
       
  2922 	//message header use
       
  2923 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  2924     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  2925     
       
  2926     msgHdr->message_type = ELogin_Request;
       
  2927  
       
  2928     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  2929     index += sizeof( message_hdr_req );
       
  2930     
       
  2931     int len = strlen(connect_data->username);
       
  2932     strcpy( smsg + index, connect_data->username );
       
  2933     index += len + 1;
       
  2934     
       
  2935     //appending password
       
  2936     
       
  2937     len = strlen(connect_data->password );
       
  2938     strcpy( smsg + index, connect_data->password );
       
  2939     index += len + 1;
       
  2940    
       
  2941     //appending server name
       
  2942     
       
  2943     len = strlen(connect_data->server );
       
  2944     strcpy( smsg + index, connect_data->server );
       
  2945     index += len + 1;
       
  2946     
       
  2947     //appending resource
       
  2948     len = strlen(connect_data->resource );
       
  2949     strcpy( smsg + index, connect_data->resource );
       
  2950     index += len + 1;
       
  2951     
       
  2952     //appending ssl
       
  2953     smsg[index++]= '1';
       
  2954     smsg[index++]= '\0';
       
  2955     
       
  2956     //appending server port
       
  2957     len = strlen(connect_data->port );
       
  2958     strcpy( smsg + index, connect_data->port );
       
  2959     index += len + 1;
       
  2960     
       
  2961     // appending IAP id
       
  2962     
       
  2963     smsg[index++]= '1';
       
  2964     smsg[index++]= '\0';
       
  2965     
       
  2966     //appending connmgr_bus
       
  2967     len = strlen(connect_data->connmgr_bus );
       
  2968     strcpy( smsg + index, connect_data->connmgr_bus );
       
  2969     index += len + 1;
       
  2970     
       
  2971     //appending connmgr_path
       
  2972     len = strlen(connect_data->connmgr_path );
       
  2973     strcpy( smsg + index, connect_data->connmgr_path );
       
  2974     index += len + 1;
       
  2975     
       
  2976     //appending protocol
       
  2977     len = strlen(connect_data->protocol );
       
  2978     strcpy( smsg + index, connect_data->protocol );
       
  2979     index += len + 1;
       
  2980     
       
  2981     #ifdef __WINSCW__
       
  2982     //proxy server
       
  2983     len = strlen(connect_data->proxy_data->proxy_server );
       
  2984     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  2985     index += len + 1;
       
  2986     
       
  2987     //proxy port
       
  2988     len = strlen(connect_data->proxy_data->proxy_port );
       
  2989     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  2990     index += len + 1;
       
  2991     
       
  2992     #endif
       
  2993     //running isoserver   
       
  2994     run_isoserver();     
       
  2995     //create message queue for send request
       
  2996     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2997     //create message queue for response request
       
  2998     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  2999 	
       
  3000 	
       
  3001 	// Send Message to queueOne 
       
  3002 	
       
  3003 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3004     
       
  3005     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  3006     
       
  3007     if (status < 0)
       
  3008     {
       
  3009     return_value = KErrGeneral;
       
  3010 	goto return_code;	
       
  3011     }
       
  3012    
       
  3013     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  3014 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  3015 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  3016 	
       
  3017 	if( msg_struct->response != 0)
       
  3018     {
       
  3019     	return_value = KErrGeneral;
       
  3020 	goto return_code;
       
  3021     }
       
  3022     //killing isoserver
       
  3023     return_code:
       
  3024     index=0;
       
  3025     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3026 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3027 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3028     msgHdr->message_type = EKill_Process;
       
  3029     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3030     index += sizeof( message_hdr_req );
       
  3031 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  3032     free( msg_struct );
       
  3033     return return_value; */
       
  3034     return KErrNone;
       
  3035     }
       
  3036 
       
  3037     
       
  3038     // -----------------------------------------------------------------------------
       
  3039 // Cisolationserver::Login with correct data
       
  3040 // Example test method function.
       
  3041 // (other items were commented in a header).
       
  3042 // -----------------------------------------------------------------------------
       
  3043 //
       
  3044 TInt Cisolationserver::LoginWithCoreectUserIDWithSpace( CStifItemParser& aItem )
       
  3045     {
       
  3046     ConnectData  *connect_data = NULL;
       
  3047     char smsg[MAX_MSG_SIZE];
       
  3048     char rmsg[MAX_MSG_SIZE];
       
  3049     int index=0;
       
  3050     int timeout = 100;
       
  3051 	int nBytes;
       
  3052     int result = 0;
       
  3053     int err = 0;
       
  3054     int status = 0;
       
  3055     message_hdr_req *msgHdr = NULL;  
       
  3056     message_hdr_resp* msg_struct = NULL;
       
  3057     TInt return_value = 0;
       
  3058         	// Read data from the CFG file
       
  3059 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  3060 		{
       
  3061 		iLog->Log ( _L ( "read_data failed" ) );
       
  3062 		free_data ( connect_data );
       
  3063 		return_value = KErrGeneral;
       
  3064 		goto return_code;
       
  3065 		}
       
  3066 	//request formation	
       
  3067 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  3068 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3069 	//message header use
       
  3070 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  3071     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3072     msgHdr->message_type = ELogin_Request;
       
  3073     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3074     index += sizeof( message_hdr_req );
       
  3075     int len = strlen(connect_data->username);
       
  3076     strcpy( smsg + index, connect_data->username );
       
  3077     index += len + 1;
       
  3078     smsg[index++]='\0';
       
  3079     //appending password
       
  3080     len = strlen(connect_data->password );
       
  3081     strcpy( smsg + index, connect_data->password );
       
  3082     index += len + 1;
       
  3083     //appending server name
       
  3084     
       
  3085     len = strlen(connect_data->server );
       
  3086     strcpy( smsg + index, connect_data->server );
       
  3087     index += len + 1;
       
  3088     
       
  3089     //appending resource
       
  3090     len = strlen(connect_data->resource );
       
  3091     strcpy( smsg + index, connect_data->resource );
       
  3092     index += len + 1;
       
  3093     
       
  3094     //appending ssl
       
  3095     smsg[index++]= '1';
       
  3096     smsg[index++]= '\0';
       
  3097     
       
  3098     //appending server port
       
  3099     len = strlen(connect_data->port );
       
  3100     strcpy( smsg + index, connect_data->port );
       
  3101     index += len + 1;
       
  3102     
       
  3103     // appending IAP id
       
  3104     
       
  3105     smsg[index++]= '1';
       
  3106     smsg[index++]= '\0';
       
  3107      
       
  3108     //appending connmgr_bus
       
  3109     len = strlen(connect_data->connmgr_bus );
       
  3110     strcpy( smsg + index, connect_data->connmgr_bus );
       
  3111     index += len + 1;
       
  3112     
       
  3113     //appending connmgr_path
       
  3114     len = strlen(connect_data->connmgr_path );
       
  3115     strcpy( smsg + index, connect_data->connmgr_path );
       
  3116     index += len + 1;
       
  3117     
       
  3118     //appending protocol
       
  3119     len = strlen(connect_data->protocol );
       
  3120     strcpy( smsg + index, connect_data->protocol );
       
  3121     index += len + 1;
       
  3122  
       
  3123     #ifdef __WINSCW__
       
  3124     //proxy server
       
  3125     len = strlen(connect_data->proxy_data->proxy_server );
       
  3126     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  3127     index += len + 1;
       
  3128     
       
  3129     //proxy port
       
  3130     len = strlen(connect_data->proxy_data->proxy_port );
       
  3131     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  3132     index += len + 1;
       
  3133     
       
  3134     #endif
       
  3135     //running isoserver   
       
  3136     run_isoserver(); 
       
  3137     //create message queue for send request
       
  3138     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3139     //create message queue for response request
       
  3140     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3141 		
       
  3142 	
       
  3143 	/* Send Message to queueOne */
       
  3144 	
       
  3145 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3146     
       
  3147     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  3148     
       
  3149     if (status < 0)
       
  3150     {
       
  3151     return_value = KErrGeneral;
       
  3152 	goto return_code;
       
  3153     }
       
  3154     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  3155 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  3156 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  3157 	
       
  3158 	if( msg_struct->error_type >0)
       
  3159     {
       
  3160     return_value = KErrGeneral;
       
  3161 	goto return_code;
       
  3162     }
       
  3163     return_value = KErrNone;
       
  3164     //killing isoserver
       
  3165     return_code:
       
  3166     index=0;
       
  3167     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3168 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3169 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3170     msgHdr->message_type = EKill_Process;
       
  3171     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3172     index += sizeof( message_hdr_req );
       
  3173 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  3174     free( msg_struct );
       
  3175     return return_value;
       
  3176     }
       
  3177 
       
  3178  // -----------------------------------------------------------------------------
       
  3179 // Cisolationserver::Send message
       
  3180 // Example test method function.
       
  3181 // (other items were commented in a header).
       
  3182 // -----------------------------------------------------------------------------
       
  3183 //
       
  3184 TInt Cisolationserver::SendMessageToCorrectUserID( CStifItemParser& aItem )
       
  3185     {
       
  3186 
       
  3187     	
       
  3188    ConnectData  *connect_data = NULL;
       
  3189     char smsg[MAX_MSG_SIZE];
       
  3190     char rmsg[MAX_MSG_SIZE];
       
  3191     int index=0;
       
  3192     FILE *fp;
       
  3193 		
       
  3194 	int timeout = 200;
       
  3195 	int nBytes;
       
  3196 
       
  3197     int result = 0;
       
  3198     int err = 0;
       
  3199     int status = 0;
       
  3200     message_hdr_req *msgHdr = NULL;  
       
  3201     message_hdr_resp* msg_struct = NULL;
       
  3202     TInt return_value = 0;
       
  3203         	// Read data from the CFG file
       
  3204 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  3205 		{
       
  3206 		iLog->Log ( _L ( "read_data failed" ) );
       
  3207 		free_data ( connect_data );
       
  3208 		return_value = KErrGeneral;
       
  3209 		goto return_code;
       
  3210 		}
       
  3211 	//request formation	
       
  3212 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  3213 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3214 	
       
  3215 	//message header use
       
  3216 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  3217     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3218     
       
  3219     msgHdr->message_type = ELogin_Request;
       
  3220  
       
  3221     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3222     index += sizeof( message_hdr_req );
       
  3223     
       
  3224     int len = strlen(connect_data->username);
       
  3225     strcpy( smsg + index, connect_data->username );
       
  3226     index += len + 1;
       
  3227     
       
  3228     //appending password
       
  3229     
       
  3230     len = strlen(connect_data->password );
       
  3231     strcpy( smsg + index, connect_data->password );
       
  3232     index += len + 1;
       
  3233     
       
  3234     //appending server name
       
  3235     
       
  3236     len = strlen(connect_data->server );
       
  3237     strcpy( smsg + index, connect_data->server );
       
  3238     index += len + 1;
       
  3239     
       
  3240     //appending resource
       
  3241     len = strlen(connect_data->resource );
       
  3242     strcpy( smsg + index, connect_data->resource );
       
  3243     index += len + 1;
       
  3244     
       
  3245     //appending ssl
       
  3246     smsg[index++]= '1';
       
  3247     smsg[index++]= '\0';
       
  3248     
       
  3249     //appending server port
       
  3250     len = strlen(connect_data->port );
       
  3251     strcpy( smsg + index, connect_data->port );
       
  3252     index += len + 1;
       
  3253     
       
  3254     // appending IAP id
       
  3255     
       
  3256     smsg[index++]= '1';
       
  3257     smsg[index++]= '\0';
       
  3258     
       
  3259     //appending connmgr_bus
       
  3260     len = strlen(connect_data->connmgr_bus );
       
  3261     strcpy( smsg + index, connect_data->connmgr_bus );
       
  3262     index += len + 1;
       
  3263     
       
  3264     //appending connmgr_path
       
  3265     len = strlen(connect_data->connmgr_path );
       
  3266     strcpy( smsg + index, connect_data->connmgr_path );
       
  3267     index += len + 1;
       
  3268     
       
  3269     //appending protocol
       
  3270     len = strlen(connect_data->protocol );
       
  3271     strcpy( smsg + index, connect_data->protocol );
       
  3272     index += len + 1;
       
  3273     
       
  3274     #ifdef __WINSCW__
       
  3275     //proxy server
       
  3276     len = strlen(connect_data->proxy_data->proxy_server );
       
  3277     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  3278     index += len + 1;
       
  3279     
       
  3280     //proxy port
       
  3281     len = strlen(connect_data->proxy_data->proxy_port );
       
  3282     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  3283     index += len + 1;
       
  3284     
       
  3285     #endif
       
  3286     //running isoserver   
       
  3287     run_isoserver(); 
       
  3288     //create message queue for send request
       
  3289     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3290     //create message queue for response request
       
  3291     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3292 		
       
  3293 	
       
  3294 	/* Send Message to queueOne */
       
  3295 	
       
  3296 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3297     
       
  3298     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  3299     
       
  3300     if (status < 0)
       
  3301     {
       
  3302     return_value = KErrGeneral;
       
  3303 	goto return_code;	
       
  3304     }
       
  3305     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  3306 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  3307 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  3308 	
       
  3309 	if( msg_struct->response != 1)
       
  3310     {
       
  3311     	return_value = KErrGeneral;
       
  3312 	goto return_code;
       
  3313     }
       
  3314     
       
  3315     
       
  3316     // login end
       
  3317     //fetch req..
       
  3318     for (int i= 0 ;i<3 ;i++)
       
  3319     {
       
  3320         
       
  3321     fp = fopen("c:\\fetch_contact.txt","a");
       
  3322 	do  {
       
  3323 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  3324 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3325 		fwrite(rmsg,1,status,fp);
       
  3326 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3327 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  3328 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  3329 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  3330 	fclose(fp);	
       
  3331 	
       
  3332     }
       
  3333 
       
  3334 	//fetch end
       
  3335      
       
  3336     //send messge--------------------------------------------
       
  3337    
       
  3338     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3339 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3340 	index=0;
       
  3341     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3342     msgHdr->message_type = ESend_Request;	
       
  3343     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3344 	index += sizeof( message_hdr_req );
       
  3345 	
       
  3346 	
       
  3347     // adding recipient
       
  3348     len = strlen(connect_data->msg_data->recipient );
       
  3349     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  3350     index += len + 1;
       
  3351     
       
  3352      // adding recipient
       
  3353     /*len = strlen(connect_data->msg_data->recipient );
       
  3354     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  3355     index += len + 1;*/
       
  3356     
       
  3357     smsg[index++] = '\0';
       
  3358     
       
  3359     // adding message part
       
  3360      
       
  3361     len = strlen(connect_data->msg_data->message );
       
  3362     strcpy( smsg + index, connect_data->msg_data->message );
       
  3363     index += len + 1;
       
  3364      
       
  3365     
       
  3366     
       
  3367      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3368      do  {
       
  3369 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  3370 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3371 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3372 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  3373    
       
  3374      if ( msg_struct->response != 1)
       
  3375     {
       
  3376     	return_value = KErrGeneral;
       
  3377 	goto return_code;
       
  3378     }    
       
  3379     
       
  3380     
       
  3381     
       
  3382     //send message end---------------------------------------
       
  3383     
       
  3384     
       
  3385     // logout test code from server
       
  3386     index=0;
       
  3387     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3388 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3389 	
       
  3390 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3391     
       
  3392     msgHdr->message_type = ELogout_Request;
       
  3393  
       
  3394     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3395     index += sizeof( message_hdr_req );
       
  3396 
       
  3397 	
       
  3398 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3399      do  {
       
  3400 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  3401 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3402 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3403 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  3404    
       
  3405      if ( msg_struct->response != 1)
       
  3406     {
       
  3407     	return_value = KErrGeneral;
       
  3408 	goto return_code;
       
  3409     }
       
  3410     //killing isoserver
       
  3411     return_code:
       
  3412     index=0;
       
  3413     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3414 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3415 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3416     msgHdr->message_type = EKill_Process;
       
  3417     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3418     index += sizeof( message_hdr_req );
       
  3419 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  3420     free( msg_struct );
       
  3421     return return_value;
       
  3422     }
       
  3423 
       
  3424 // -----------------------------------------------------------------------------
       
  3425 // Cisolationserver::Send message with max len
       
  3426 // Example test method function.
       
  3427 // (other items were commented in a header).
       
  3428 // -----------------------------------------------------------------------------
       
  3429 //
       
  3430 TInt Cisolationserver::SendMaxLenMessageToCorrectUserID( CStifItemParser& aItem )
       
  3431     {
       
  3432 
       
  3433     	
       
  3434     ConnectData  *connect_data = NULL;
       
  3435     char smsg[MAX_MSG_SIZE];
       
  3436     char rmsg[MAX_MSG_SIZE];
       
  3437     int index=0;
       
  3438     FILE *fp;
       
  3439 		
       
  3440 	int timeout = 200;
       
  3441 	int nBytes;
       
  3442 
       
  3443     int result = 0;
       
  3444     int err = 0;
       
  3445     int status = 0;
       
  3446     message_hdr_req *msgHdr = NULL;  
       
  3447     message_hdr_resp* msg_struct = NULL;
       
  3448     TInt return_value = 0;
       
  3449         	// Read data from the CFG file
       
  3450 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  3451 		{
       
  3452 		iLog->Log ( _L ( "read_data failed" ) );
       
  3453 		free_data ( connect_data );
       
  3454 		return_value = KErrGeneral;
       
  3455 		goto return_code;
       
  3456 		}
       
  3457 	//request formation	
       
  3458 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  3459 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3460 	
       
  3461 	//message header use
       
  3462 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  3463     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3464     
       
  3465     msgHdr->message_type = ELogin_Request;
       
  3466  
       
  3467     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3468     index += sizeof( message_hdr_req );
       
  3469     
       
  3470     int len = strlen(connect_data->username);
       
  3471     strcpy( smsg + index, connect_data->username );
       
  3472     index += len + 1;
       
  3473     
       
  3474     //appending password
       
  3475     
       
  3476     len = strlen(connect_data->password );
       
  3477     strcpy( smsg + index, connect_data->password );
       
  3478     index += len + 1;
       
  3479     
       
  3480     //appending server name
       
  3481     
       
  3482     len = strlen(connect_data->server );
       
  3483     strcpy( smsg + index, connect_data->server );
       
  3484     index += len + 1;
       
  3485     
       
  3486     //appending resource
       
  3487     len = strlen(connect_data->resource );
       
  3488     strcpy( smsg + index, connect_data->resource );
       
  3489     index += len + 1;
       
  3490     
       
  3491     //appending ssl
       
  3492     smsg[index++]= '1';
       
  3493     smsg[index++]= '\0';
       
  3494     
       
  3495     //appending server port
       
  3496     len = strlen(connect_data->port );
       
  3497     strcpy( smsg + index, connect_data->port );
       
  3498     index += len + 1;
       
  3499     
       
  3500     // appending IAP id
       
  3501     
       
  3502     smsg[index++]= '1';
       
  3503     smsg[index++]= '\0';
       
  3504     
       
  3505     //appending connmgr_bus
       
  3506     len = strlen(connect_data->connmgr_bus );
       
  3507     strcpy( smsg + index, connect_data->connmgr_bus );
       
  3508     index += len + 1;
       
  3509     
       
  3510     //appending connmgr_path
       
  3511     len = strlen(connect_data->connmgr_path );
       
  3512     strcpy( smsg + index, connect_data->connmgr_path );
       
  3513     index += len + 1;
       
  3514     
       
  3515     //appending protocol
       
  3516     len = strlen(connect_data->protocol );
       
  3517     strcpy( smsg + index, connect_data->protocol );
       
  3518     index += len + 1;
       
  3519     
       
  3520     #ifdef __WINSCW__
       
  3521     //proxy server
       
  3522     len = strlen(connect_data->proxy_data->proxy_server );
       
  3523     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  3524     index += len + 1;
       
  3525     
       
  3526     //proxy port
       
  3527     len = strlen(connect_data->proxy_data->proxy_port );
       
  3528     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  3529     index += len + 1;
       
  3530     
       
  3531     #endif
       
  3532     
       
  3533     run_isoserver();
       
  3534     
       
  3535         
       
  3536     //create message queue for send request
       
  3537     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3538     //create message queue for response request
       
  3539     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3540 		
       
  3541 	
       
  3542 	/* Send Message to queueOne */
       
  3543 	
       
  3544 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3545     
       
  3546     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  3547     
       
  3548     if (status < 0)
       
  3549     {
       
  3550     return_value = KErrGeneral;
       
  3551 	goto return_code;	
       
  3552     }
       
  3553     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  3554 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  3555 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  3556 	
       
  3557 	if( msg_struct->response != 1)
       
  3558     {
       
  3559     	return_value = KErrGeneral;
       
  3560 	goto return_code;
       
  3561     }
       
  3562     
       
  3563     
       
  3564     // login end
       
  3565    //fetch req..
       
  3566     for (int i= 0 ;i<3 ;i++)
       
  3567     {
       
  3568         
       
  3569     fp = fopen("c:\\fetch_contact.txt","a");
       
  3570 	do  {
       
  3571 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  3572 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3573 		fwrite(rmsg,1,status,fp);
       
  3574 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3575 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  3576 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  3577 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  3578 	fclose(fp);	
       
  3579 	
       
  3580     }
       
  3581 
       
  3582 	//fetch end
       
  3583      
       
  3584     //send messge--------------------------------------------
       
  3585    
       
  3586     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3587 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3588 	index=0;
       
  3589     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3590     msgHdr->message_type = ESend_Request;	
       
  3591     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3592 	index += sizeof( message_hdr_req );
       
  3593 	
       
  3594 	
       
  3595     // adding recipient
       
  3596     len = strlen(connect_data->msg_data->recipient );
       
  3597     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  3598     index += len + 1;
       
  3599     
       
  3600      // adding recipient
       
  3601     /*len = strlen(connect_data->msg_data->recipient );
       
  3602     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  3603     index += len + 1;*/
       
  3604     
       
  3605     smsg[index++] = '\0';
       
  3606     
       
  3607     // adding message part
       
  3608      
       
  3609     len = strlen(connect_data->msg_data->message );
       
  3610     strcpy( smsg + index, connect_data->msg_data->message );
       
  3611     index += len + 1;
       
  3612      
       
  3613        
       
  3614     
       
  3615     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3616      do  {
       
  3617 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  3618 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3619 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3620 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  3621    
       
  3622      if ( msg_struct->response != 1)
       
  3623     {
       
  3624     	return_value = KErrGeneral;
       
  3625 	goto return_code;
       
  3626     } 
       
  3627     
       
  3628     
       
  3629     //send message end---------------------------------------
       
  3630     
       
  3631     
       
  3632     // logout test code from server
       
  3633     index=0;
       
  3634     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3635 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3636 	
       
  3637 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3638     
       
  3639     msgHdr->message_type = ELogout_Request;
       
  3640  
       
  3641     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3642     index += sizeof( message_hdr_req );
       
  3643 
       
  3644 	
       
  3645 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3646      do  {
       
  3647 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  3648 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3649 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3650 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  3651    
       
  3652      if ( msg_struct->response != 1)
       
  3653     {
       
  3654     return_value = KErrGeneral;
       
  3655 	goto return_code;
       
  3656     }
       
  3657     
       
  3658      //killing isoserver
       
  3659     return_code:
       
  3660     index=0;
       
  3661     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3662 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3663 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3664     msgHdr->message_type = EKill_Process;
       
  3665     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3666     index += sizeof( message_hdr_req );
       
  3667 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  3668     free( msg_struct );
       
  3669     return return_value;
       
  3670     }
       
  3671 
       
  3672    // -----------------------------------------------------------------------------
       
  3673 // Cisolationserver::Send message to unexist user id
       
  3674 // Example test method function.
       
  3675 // (other items were commented in a header).
       
  3676 // -----------------------------------------------------------------------------
       
  3677 //
       
  3678 TInt Cisolationserver::SendTextMessageUnExistUserID( CStifItemParser& aItem )
       
  3679     {
       
  3680 
       
  3681     	
       
  3682    ConnectData  *connect_data = NULL;
       
  3683     char smsg[MAX_MSG_SIZE];
       
  3684     char rmsg[MAX_MSG_SIZE];
       
  3685     int index=0;
       
  3686     FILE *fp;
       
  3687 		
       
  3688 	int timeout = 200;
       
  3689 	int nBytes;
       
  3690 
       
  3691     int result = 0;
       
  3692     int err = 0;
       
  3693     int status = 0;
       
  3694     message_hdr_req *msgHdr = NULL;  
       
  3695     message_hdr_resp* msg_struct = NULL;
       
  3696     TInt return_value = 0;
       
  3697         	// Read data from the CFG file
       
  3698 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  3699 		{
       
  3700 		iLog->Log ( _L ( "read_data failed" ) );
       
  3701 		free_data ( connect_data );
       
  3702 		return_value = KErrGeneral;
       
  3703 		goto return_code;
       
  3704 		}
       
  3705 	//request formation	
       
  3706 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  3707 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3708 	
       
  3709 	//message header use
       
  3710 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  3711     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3712     
       
  3713     msgHdr->message_type = ELogin_Request;
       
  3714  
       
  3715     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3716     index += sizeof( message_hdr_req );
       
  3717     
       
  3718     int len = strlen(connect_data->username);
       
  3719     strcpy( smsg + index, connect_data->username );
       
  3720     index += len + 1;
       
  3721     
       
  3722     //appending password
       
  3723     
       
  3724     len = strlen(connect_data->password );
       
  3725     strcpy( smsg + index, connect_data->password );
       
  3726     index += len + 1;
       
  3727     
       
  3728     //appending server name
       
  3729     
       
  3730     len = strlen(connect_data->server );
       
  3731     strcpy( smsg + index, connect_data->server );
       
  3732     index += len + 1;
       
  3733     
       
  3734     //appending resource
       
  3735     len = strlen(connect_data->resource );
       
  3736     strcpy( smsg + index, connect_data->resource );
       
  3737     index += len + 1;
       
  3738     
       
  3739     //appending ssl
       
  3740     smsg[index++]= '1';
       
  3741     smsg[index++]= '\0';
       
  3742     
       
  3743     //appending server port
       
  3744     len = strlen(connect_data->port );
       
  3745     strcpy( smsg + index, connect_data->port );
       
  3746     index += len + 1;
       
  3747     
       
  3748     // appending IAP id
       
  3749     
       
  3750     smsg[index++]= '1';
       
  3751     smsg[index++]= '\0';
       
  3752     
       
  3753     //appending connmgr_bus
       
  3754     len = strlen(connect_data->connmgr_bus );
       
  3755     strcpy( smsg + index, connect_data->connmgr_bus );
       
  3756     index += len + 1;
       
  3757     
       
  3758     //appending connmgr_path
       
  3759     len = strlen(connect_data->connmgr_path );
       
  3760     strcpy( smsg + index, connect_data->connmgr_path );
       
  3761     index += len + 1;
       
  3762     
       
  3763     //appending protocol
       
  3764     len = strlen(connect_data->protocol );
       
  3765     strcpy( smsg + index, connect_data->protocol );
       
  3766     index += len + 1;
       
  3767     
       
  3768     #ifdef __WINSCW__
       
  3769     //proxy server
       
  3770     len = strlen(connect_data->proxy_data->proxy_server );
       
  3771     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  3772     index += len + 1;
       
  3773     
       
  3774     //proxy port
       
  3775     len = strlen(connect_data->proxy_data->proxy_port );
       
  3776     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  3777     index += len + 1;
       
  3778     
       
  3779     #endif
       
  3780     //running isoserver   
       
  3781     run_isoserver(); 
       
  3782     
       
  3783     
       
  3784         
       
  3785     //create message queue for send request
       
  3786     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3787     //create message queue for response request
       
  3788     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  3789 		
       
  3790 	
       
  3791 	/* Send Message to queueOne */
       
  3792 	
       
  3793 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3794     
       
  3795     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  3796     
       
  3797     if (status < 0)
       
  3798     {
       
  3799     return_value = KErrGeneral;
       
  3800 	goto return_code;	
       
  3801     }
       
  3802     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  3803 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  3804 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  3805 	
       
  3806 	if( msg_struct->response != 1)
       
  3807     {
       
  3808     	return_value = KErrGeneral;
       
  3809 	goto return_code;
       
  3810     }
       
  3811     
       
  3812     
       
  3813     // login end
       
  3814    //fetch req..
       
  3815     for (int i= 0 ;i<3 ;i++)
       
  3816     {
       
  3817         
       
  3818     fp = fopen("c:\\fetch_contact.txt","a");
       
  3819 	do  {
       
  3820 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  3821 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3822 		fwrite(rmsg,1,status,fp);
       
  3823 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3824 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  3825 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  3826 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  3827 	fclose(fp);	
       
  3828 	
       
  3829     }
       
  3830 
       
  3831 	//fetch end
       
  3832      
       
  3833     //send messge--------------------------------------------
       
  3834    
       
  3835     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3836 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3837 	index=0;
       
  3838     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3839     msgHdr->message_type = ESend_Request;	
       
  3840     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3841 	index += sizeof( message_hdr_req );
       
  3842 	
       
  3843 	
       
  3844     // adding recipient
       
  3845     len = strlen(connect_data->msg_data->recipient );
       
  3846     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  3847     index += len + 1;
       
  3848     
       
  3849      // adding recipient
       
  3850     /*len = strlen(connect_data->msg_data->recipient );
       
  3851     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  3852     index += len + 1;*/
       
  3853     
       
  3854     smsg[index++] = '\0';
       
  3855     
       
  3856     // adding message part
       
  3857      
       
  3858     len = strlen(connect_data->msg_data->message );
       
  3859     strcpy( smsg + index, connect_data->msg_data->message );
       
  3860     index += len + 1;
       
  3861      
       
  3862        
       
  3863     
       
  3864     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3865      do  {
       
  3866 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  3867 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3868 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3869 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  3870    
       
  3871     /* if ( msg_struct->response != 1)
       
  3872     {
       
  3873     return_value = KErrGeneral;
       
  3874 	goto return_code;
       
  3875     }*/
       
  3876     
       
  3877     //send message end---------------------------------------
       
  3878     
       
  3879     
       
  3880    // logout test code from server
       
  3881     index=0;
       
  3882     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3883 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3884 	
       
  3885 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3886     
       
  3887     msgHdr->message_type = ELogout_Request;
       
  3888  
       
  3889     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3890     index += sizeof( message_hdr_req );
       
  3891 
       
  3892 	
       
  3893 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  3894      do  {
       
  3895 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  3896 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  3897 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3898 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  3899    
       
  3900      if ( msg_struct->response != 1)
       
  3901     {
       
  3902     	return_value = KErrGeneral;
       
  3903 	goto return_code;
       
  3904     }
       
  3905     //killing isoserver
       
  3906     return_code:
       
  3907     index=0;
       
  3908     memset( smsg, '\0', MAX_MSG_SIZE );
       
  3909 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3910 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3911     msgHdr->message_type = EKill_Process;
       
  3912     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3913     index += sizeof( message_hdr_req );
       
  3914 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  3915     free( msg_struct );
       
  3916     return return_value;
       
  3917     }
       
  3918 
       
  3919     // -----------------------------------------------------------------------------
       
  3920 // Cisolationserver::Send message to unexist user id
       
  3921 // Example test method function.
       
  3922 // (other items were commented in a header).
       
  3923 // -----------------------------------------------------------------------------
       
  3924 //
       
  3925 TInt Cisolationserver::SendTextMessageWithSpecialCharacter( CStifItemParser& aItem )
       
  3926     {
       
  3927 
       
  3928     	
       
  3929    ConnectData  *connect_data = NULL;
       
  3930     char smsg[MAX_MSG_SIZE];
       
  3931     char rmsg[MAX_MSG_SIZE];
       
  3932     int index=0;
       
  3933     FILE *fp;
       
  3934 		
       
  3935 	int timeout = 200;
       
  3936 	int nBytes;
       
  3937 
       
  3938     int result = 0;
       
  3939     int err = 0;
       
  3940     int status = 0;
       
  3941     message_hdr_req *msgHdr = NULL;  
       
  3942     message_hdr_resp* msg_struct = NULL;
       
  3943     TInt return_value = 0;
       
  3944         	// Read data from the CFG file
       
  3945 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  3946 		{
       
  3947 		iLog->Log ( _L ( "read_data failed" ) );
       
  3948 		free_data ( connect_data );
       
  3949 		return_value = KErrGeneral;
       
  3950 		goto return_code;
       
  3951 		}
       
  3952 	//request formation	
       
  3953 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  3954 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  3955 	
       
  3956 	//message header use
       
  3957 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  3958     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  3959     
       
  3960     msgHdr->message_type = ELogin_Request;
       
  3961  
       
  3962     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  3963     index += sizeof( message_hdr_req );
       
  3964     
       
  3965     int len = strlen(connect_data->username);
       
  3966     strcpy( smsg + index, connect_data->username );
       
  3967     index += len + 1;
       
  3968     
       
  3969     //appending password
       
  3970     
       
  3971     len = strlen(connect_data->password );
       
  3972     strcpy( smsg + index, connect_data->password );
       
  3973     index += len + 1;
       
  3974     
       
  3975     //appending server name
       
  3976     
       
  3977     len = strlen(connect_data->server );
       
  3978     strcpy( smsg + index, connect_data->server );
       
  3979     index += len + 1;
       
  3980     
       
  3981     //appending resource
       
  3982     len = strlen(connect_data->resource );
       
  3983     strcpy( smsg + index, connect_data->resource );
       
  3984     index += len + 1;
       
  3985     
       
  3986     //appending ssl
       
  3987     smsg[index++]= '1';
       
  3988     smsg[index++]= '\0';
       
  3989     
       
  3990     //appending server port
       
  3991     len = strlen(connect_data->port );
       
  3992     strcpy( smsg + index, connect_data->port );
       
  3993     index += len + 1;
       
  3994     
       
  3995     // appending IAP id
       
  3996     
       
  3997     smsg[index++]= '1';
       
  3998     smsg[index++]= '\0';
       
  3999     
       
  4000     //appending connmgr_bus
       
  4001     len = strlen(connect_data->connmgr_bus );
       
  4002     strcpy( smsg + index, connect_data->connmgr_bus );
       
  4003     index += len + 1;
       
  4004     
       
  4005     //appending connmgr_path
       
  4006     len = strlen(connect_data->connmgr_path );
       
  4007     strcpy( smsg + index, connect_data->connmgr_path );
       
  4008     index += len + 1;
       
  4009     
       
  4010     //appending protocol
       
  4011     len = strlen(connect_data->protocol );
       
  4012     strcpy( smsg + index, connect_data->protocol );
       
  4013     index += len + 1;
       
  4014     
       
  4015     #ifdef __WINSCW__
       
  4016     //proxy server
       
  4017     len = strlen(connect_data->proxy_data->proxy_server );
       
  4018     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  4019     index += len + 1;
       
  4020     
       
  4021     //proxy port
       
  4022     len = strlen(connect_data->proxy_data->proxy_port );
       
  4023     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  4024     index += len + 1;
       
  4025     
       
  4026     #endif
       
  4027     //running isoserver   
       
  4028     run_isoserver(); 
       
  4029        
       
  4030     //create message queue for send request
       
  4031     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4032     //create message queue for response request
       
  4033     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4034 		
       
  4035 	
       
  4036 	/* Send Message to queueOne */
       
  4037 	
       
  4038 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4039     
       
  4040     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  4041     
       
  4042     if (status < 0)
       
  4043     {
       
  4044     return_value = KErrGeneral;
       
  4045 	goto return_code;	
       
  4046     }
       
  4047     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  4048 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  4049 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  4050 	
       
  4051 	if( msg_struct->response != 1)
       
  4052     {
       
  4053     	return_value = KErrGeneral;
       
  4054 	goto return_code;
       
  4055     }
       
  4056     
       
  4057     
       
  4058     // login end
       
  4059 
       
  4060     //fetch req..
       
  4061     for (int i= 0 ;i<3 ;i++)
       
  4062     {
       
  4063         
       
  4064     fp = fopen("c:\\fetch_contact.txt","a");
       
  4065 	do  {
       
  4066 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  4067 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4068 		fwrite(rmsg,1,status,fp);
       
  4069 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4070 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  4071 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  4072 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  4073 	fclose(fp);	
       
  4074 	
       
  4075     }
       
  4076 
       
  4077 	//fetch end     
       
  4078     //send messge--------------------------------------------
       
  4079    
       
  4080     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4081 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4082 	index=0;
       
  4083     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4084     msgHdr->message_type = ESend_Request;	
       
  4085     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4086 	index += sizeof( message_hdr_req );
       
  4087 	
       
  4088 	
       
  4089     // adding recipient
       
  4090     len = strlen(connect_data->msg_data->recipient );
       
  4091     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4092     index += len + 1;
       
  4093     
       
  4094      // adding recipient
       
  4095     /*len = strlen(connect_data->msg_data->recipient );
       
  4096     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4097     index += len + 1;*/
       
  4098     
       
  4099     smsg[index++] = '\0';
       
  4100     
       
  4101     // adding message part
       
  4102      
       
  4103     len = strlen(connect_data->msg_data->message );
       
  4104     strcpy( smsg + index, connect_data->msg_data->message );
       
  4105     index += len + 1;
       
  4106      
       
  4107        
       
  4108     
       
  4109     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4110      do  {
       
  4111 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4112 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4113 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4114 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  4115    
       
  4116      if ( msg_struct->response != 1)
       
  4117     {
       
  4118     	return_value = KErrGeneral;
       
  4119 	goto return_code;
       
  4120     }
       
  4121     //send message end---------------------------------------
       
  4122     
       
  4123     
       
  4124    // logout test code from server
       
  4125     index=0;
       
  4126     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4127 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4128 	
       
  4129 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4130     
       
  4131     msgHdr->message_type = ELogout_Request;
       
  4132  
       
  4133     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4134     index += sizeof( message_hdr_req );
       
  4135 
       
  4136 	
       
  4137 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4138      do  {
       
  4139 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4140 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4141 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4142 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  4143    
       
  4144      if ( msg_struct->response != 1)
       
  4145     {
       
  4146     	return_value = KErrGeneral;
       
  4147 	goto return_code;
       
  4148     }
       
  4149     //killing isoserver
       
  4150     return_code:
       
  4151     index=0;
       
  4152     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4153 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4154 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4155     msgHdr->message_type = EKill_Process;
       
  4156     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4157     index += sizeof( message_hdr_req );
       
  4158 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  4159     free( msg_struct );
       
  4160     return return_value;
       
  4161     }
       
  4162 
       
  4163    // -----------------------------------------------------------------------------
       
  4164 // Cisolationserver::Send message to blank user id
       
  4165 // Example test method function.
       
  4166 // (other items were commented in a header).
       
  4167 // -----------------------------------------------------------------------------
       
  4168 //
       
  4169 TInt Cisolationserver::SendMessageWithBlankUserID( CStifItemParser& aItem )
       
  4170     {
       
  4171 
       
  4172     	
       
  4173    ConnectData  *connect_data = NULL;
       
  4174     char smsg[MAX_MSG_SIZE];
       
  4175     char rmsg[MAX_MSG_SIZE];
       
  4176     int index=0;
       
  4177     FILE *fp;
       
  4178 		
       
  4179 	int timeout = 200;
       
  4180 	int nBytes;
       
  4181 
       
  4182     int result = 0;
       
  4183     int err = 0;
       
  4184     int status = 0;
       
  4185     message_hdr_req *msgHdr = NULL;  
       
  4186     message_hdr_resp* msg_struct = NULL;
       
  4187     TInt return_value = 0;
       
  4188         	// Read data from the CFG file
       
  4189 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  4190 		{
       
  4191 		iLog->Log ( _L ( "read_data failed" ) );
       
  4192 		free_data ( connect_data );
       
  4193 		return_value = KErrGeneral;
       
  4194 		goto return_code;
       
  4195 		}
       
  4196 	//request formation	
       
  4197 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  4198 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4199 	
       
  4200 	//message header use
       
  4201 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  4202     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4203     
       
  4204     msgHdr->message_type = ELogin_Request;
       
  4205  
       
  4206     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4207     index += sizeof( message_hdr_req );
       
  4208     
       
  4209     int len = strlen(connect_data->username);
       
  4210     strcpy( smsg + index, connect_data->username );
       
  4211     index += len + 1;
       
  4212     
       
  4213     //appending password
       
  4214     
       
  4215     len = strlen(connect_data->password );
       
  4216     strcpy( smsg + index, connect_data->password );
       
  4217     index += len + 1;
       
  4218     
       
  4219     //appending server name
       
  4220     
       
  4221     len = strlen(connect_data->server );
       
  4222     strcpy( smsg + index, connect_data->server );
       
  4223     index += len + 1;
       
  4224     
       
  4225     //appending resource
       
  4226     len = strlen(connect_data->resource );
       
  4227     strcpy( smsg + index, connect_data->resource );
       
  4228     index += len + 1;
       
  4229     
       
  4230     //appending ssl
       
  4231     smsg[index++]= '1';
       
  4232     smsg[index++]= '\0';
       
  4233     
       
  4234     //appending server port
       
  4235     len = strlen(connect_data->port );
       
  4236     strcpy( smsg + index, connect_data->port );
       
  4237     index += len + 1;
       
  4238     
       
  4239     // appending IAP id
       
  4240     
       
  4241     smsg[index++]= '1';
       
  4242     smsg[index++]= '\0';
       
  4243     
       
  4244     //appending connmgr_bus
       
  4245     len = strlen(connect_data->connmgr_bus );
       
  4246     strcpy( smsg + index, connect_data->connmgr_bus );
       
  4247     index += len + 1;
       
  4248     
       
  4249     //appending connmgr_path
       
  4250     len = strlen(connect_data->connmgr_path );
       
  4251     strcpy( smsg + index, connect_data->connmgr_path );
       
  4252     index += len + 1;
       
  4253     
       
  4254     //appending protocol
       
  4255     len = strlen(connect_data->protocol );
       
  4256     strcpy( smsg + index, connect_data->protocol );
       
  4257     index += len + 1;
       
  4258     
       
  4259     #ifdef __WINSCW__
       
  4260     //proxy server
       
  4261     len = strlen(connect_data->proxy_data->proxy_server );
       
  4262     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  4263     index += len + 1;
       
  4264     
       
  4265     //proxy port
       
  4266     len = strlen(connect_data->proxy_data->proxy_port );
       
  4267     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  4268     index += len + 1;
       
  4269     
       
  4270     #endif
       
  4271     
       
  4272     //running isoserver   
       
  4273     run_isoserver(); 
       
  4274     
       
  4275         
       
  4276     //create message queue for send request
       
  4277     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4278     //create message queue for response request
       
  4279     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4280 		
       
  4281 	
       
  4282 	/* Send Message to queueOne */
       
  4283 	
       
  4284 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4285     
       
  4286     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  4287     
       
  4288     if (status < 0)
       
  4289     {
       
  4290     return_value = KErrGeneral;
       
  4291 	goto return_code;	
       
  4292     }
       
  4293     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  4294 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  4295 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  4296 	
       
  4297 	if( msg_struct->response != 1)
       
  4298     {
       
  4299     	return_value = KErrGeneral;
       
  4300 	goto return_code;
       
  4301     }
       
  4302     
       
  4303     
       
  4304     // login end
       
  4305     //fetch req..
       
  4306     for (int i= 0 ;i<3 ;i++)
       
  4307     {
       
  4308         
       
  4309     fp = fopen("c:\\fetch_contact.txt","a");
       
  4310 	do  {
       
  4311 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  4312 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4313 		fwrite(rmsg,1,status,fp);
       
  4314 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4315 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  4316 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  4317 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  4318 	fclose(fp);	
       
  4319 	
       
  4320     }
       
  4321 
       
  4322 	//fetch end
       
  4323      
       
  4324     //send messge--------------------------------------------
       
  4325    
       
  4326     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4327 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4328 	index=0;
       
  4329     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4330     msgHdr->message_type = ESend_Request;	
       
  4331     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4332 	index += sizeof( message_hdr_req );
       
  4333 	
       
  4334 	
       
  4335     // adding recipient
       
  4336     smsg[index++] = '\0';
       
  4337     
       
  4338      // adding recipient
       
  4339     /*len = strlen(connect_data->msg_data->recipient );
       
  4340     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4341     index += len + 1;*/
       
  4342     
       
  4343     smsg[index++] = '\0';
       
  4344     
       
  4345     // adding message part
       
  4346      
       
  4347     len = strlen(connect_data->msg_data->message );
       
  4348     strcpy( smsg + index, connect_data->msg_data->message );
       
  4349     index += len + 1;
       
  4350      
       
  4351        
       
  4352     
       
  4353     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4354      do  {
       
  4355 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4356 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4357 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4358 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  4359    
       
  4360      if ( msg_struct->response != 0)
       
  4361     {
       
  4362     	return_value = KErrGeneral;
       
  4363 	goto return_code;
       
  4364     }
       
  4365     
       
  4366     //send message end---------------------------------------
       
  4367     
       
  4368     
       
  4369     // logout test code from server
       
  4370     index=0;
       
  4371     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4372 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4373 	
       
  4374 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4375     
       
  4376     msgHdr->message_type = ELogout_Request;
       
  4377  
       
  4378     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4379     index += sizeof( message_hdr_req );
       
  4380 
       
  4381 	
       
  4382 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4383      do  {
       
  4384 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4385 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4386 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4387 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  4388    
       
  4389      if ( msg_struct->response != 1)
       
  4390     {
       
  4391     	return_value = KErrGeneral;
       
  4392 	goto return_code;
       
  4393     }
       
  4394      //killing isoserver
       
  4395     return_code:
       
  4396     index=0;
       
  4397     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4398 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4399 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4400     msgHdr->message_type = EKill_Process;
       
  4401     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4402     index += sizeof( message_hdr_req );
       
  4403 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  4404     free( msg_struct );
       
  4405     return return_value;
       
  4406     }
       
  4407 
       
  4408   // -----------------------------------------------------------------------------
       
  4409 // Cisolationserver::Send blank message to user id
       
  4410 // Example test method function.
       
  4411 // (other items were commented in a header).
       
  4412 // -----------------------------------------------------------------------------
       
  4413 //
       
  4414 TInt Cisolationserver::SendBlankMessageToUserID( CStifItemParser& aItem )
       
  4415     {
       
  4416     ConnectData  *connect_data = NULL;
       
  4417     char smsg[MAX_MSG_SIZE];
       
  4418     char rmsg[MAX_MSG_SIZE];
       
  4419     int index=0;
       
  4420     FILE *fp;
       
  4421 	int timeout = 200;
       
  4422 	int nBytes;
       
  4423 
       
  4424     int result = 0;
       
  4425     int err = 0;
       
  4426     int status = 0;
       
  4427     message_hdr_req *msgHdr = NULL;  
       
  4428     message_hdr_resp* msg_struct = NULL;
       
  4429     TInt return_value = 0;
       
  4430         	// Read data from the CFG file
       
  4431 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  4432 		{
       
  4433 		iLog->Log ( _L ( "read_data failed" ) );
       
  4434 		free_data ( connect_data );
       
  4435 		return_value = KErrGeneral;
       
  4436 		goto return_code;
       
  4437 		}
       
  4438 	//request formation	
       
  4439 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  4440 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4441 	
       
  4442 	//message header use
       
  4443 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  4444     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4445     
       
  4446     msgHdr->message_type = ELogin_Request;
       
  4447  
       
  4448     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4449     index += sizeof( message_hdr_req );
       
  4450     
       
  4451     int len = strlen(connect_data->username);
       
  4452     strcpy( smsg + index, connect_data->username );
       
  4453     index += len + 1;
       
  4454     
       
  4455     //appending password
       
  4456     
       
  4457     len = strlen(connect_data->password );
       
  4458     strcpy( smsg + index, connect_data->password );
       
  4459     index += len + 1;
       
  4460     
       
  4461     //appending server name
       
  4462     
       
  4463     len = strlen(connect_data->server );
       
  4464     strcpy( smsg + index, connect_data->server );
       
  4465     index += len + 1;
       
  4466     
       
  4467     //appending resource
       
  4468     len = strlen(connect_data->resource );
       
  4469     strcpy( smsg + index, connect_data->resource );
       
  4470     index += len + 1;
       
  4471     
       
  4472     //appending ssl
       
  4473     smsg[index++]= '1';
       
  4474     smsg[index++]= '\0';
       
  4475     
       
  4476     //appending server port
       
  4477     len = strlen(connect_data->port );
       
  4478     strcpy( smsg + index, connect_data->port );
       
  4479     index += len + 1;
       
  4480     
       
  4481     // appending IAP id
       
  4482     
       
  4483     smsg[index++]= '1';
       
  4484     smsg[index++]= '\0';
       
  4485     
       
  4486     
       
  4487     
       
  4488     //appending connmgr_bus
       
  4489     len = strlen(connect_data->connmgr_bus );
       
  4490     strcpy( smsg + index, connect_data->connmgr_bus );
       
  4491     index += len + 1;
       
  4492     
       
  4493     //appending connmgr_path
       
  4494     len = strlen(connect_data->connmgr_path );
       
  4495     strcpy( smsg + index, connect_data->connmgr_path );
       
  4496     index += len + 1;
       
  4497     
       
  4498     //appending protocol
       
  4499     len = strlen(connect_data->protocol );
       
  4500     strcpy( smsg + index, connect_data->protocol );
       
  4501     index += len + 1;
       
  4502     
       
  4503     #ifdef __WINSCW__
       
  4504     //proxy server
       
  4505     len = strlen(connect_data->proxy_data->proxy_server );
       
  4506     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  4507     index += len + 1;
       
  4508     
       
  4509     //proxy port
       
  4510     len = strlen(connect_data->proxy_data->proxy_port );
       
  4511     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  4512     index += len + 1;
       
  4513     
       
  4514     #endif
       
  4515     //running isoserver   
       
  4516     run_isoserver(); 
       
  4517     //create message queue for send request
       
  4518     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4519     //create message queue for response request
       
  4520     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4521 		
       
  4522 	
       
  4523 	/* Send Message to queueOne */
       
  4524 	
       
  4525 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4526     
       
  4527     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  4528     
       
  4529     if (status < 0)
       
  4530     {
       
  4531     return_value = KErrGeneral;
       
  4532 	goto return_code;	
       
  4533     }
       
  4534     
       
  4535     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  4536 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  4537 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  4538 	
       
  4539 	if( msg_struct->response != 1)
       
  4540     {
       
  4541     return_value = KErrGeneral;
       
  4542 	goto return_code;
       
  4543     }
       
  4544     
       
  4545     
       
  4546     // login end
       
  4547     //fetch req..
       
  4548     for (int i= 0 ;i<3 ;i++)
       
  4549     {
       
  4550         
       
  4551     fp = fopen("c:\\fetch_contact.txt","a");
       
  4552 	do  {
       
  4553 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  4554 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4555 		fwrite(rmsg,1,status,fp);
       
  4556 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4557 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  4558 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  4559 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  4560 	fclose(fp);	
       
  4561 	
       
  4562     }
       
  4563 
       
  4564 	//fetch end
       
  4565 
       
  4566      
       
  4567     //send messge--------------------------------------------
       
  4568    
       
  4569     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4570 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4571 	index=0;
       
  4572     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4573     msgHdr->message_type = ESend_Request;	
       
  4574     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4575 	index += sizeof( message_hdr_req );
       
  4576 	
       
  4577 	
       
  4578     // adding recipient
       
  4579     len = strlen(connect_data->msg_data->recipient );
       
  4580     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4581     index += len + 1;
       
  4582     
       
  4583      // adding recipient
       
  4584     /*len = strlen(connect_data->msg_data->recipient );
       
  4585     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4586     index += len + 1;*/
       
  4587     
       
  4588     smsg[index++] = '\0';
       
  4589     
       
  4590     // adding message part
       
  4591      
       
  4592     smsg[index++]=' ';
       
  4593     smsg[index++]='\0';
       
  4594        
       
  4595     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4596      do  {
       
  4597 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4598 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4599 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4600 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  4601    
       
  4602      if ( msg_struct->response != 1)
       
  4603     {
       
  4604     return_value = KErrGeneral;
       
  4605 	goto return_code;
       
  4606     }
       
  4607     
       
  4608     
       
  4609     //send message end---------------------------------------
       
  4610     
       
  4611     
       
  4612     // logout test code from server
       
  4613     index=0;
       
  4614     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4615 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4616 	
       
  4617 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4618     
       
  4619     msgHdr->message_type = ELogout_Request;
       
  4620  
       
  4621     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4622     index += sizeof( message_hdr_req );
       
  4623 
       
  4624 	
       
  4625 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4626      do  {
       
  4627 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4628 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4629 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4630 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  4631    
       
  4632      if ( msg_struct->response != 1)
       
  4633     {
       
  4634     return_value = KErrGeneral;
       
  4635 	goto return_code;
       
  4636     }
       
  4637     return_value = KErrNone;
       
  4638 	goto return_code;
       
  4639      //killing isoserver
       
  4640     return_code:
       
  4641     index=0;
       
  4642     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4643 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4644 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4645     msgHdr->message_type = EKill_Process;
       
  4646     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4647     index += sizeof( message_hdr_req );
       
  4648 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  4649     free( msg_struct );
       
  4650     return return_value;
       
  4651     }
       
  4652     
       
  4653      // -----------------------------------------------------------------------------
       
  4654 // Cisolationserver::Send blank message to user id
       
  4655 // Example test method function.
       
  4656 // (other items were commented in a header).
       
  4657 // -----------------------------------------------------------------------------
       
  4658 //
       
  4659 TInt Cisolationserver::SendSmilyToCorrectUserID( CStifItemParser& aItem )
       
  4660     {
       
  4661 
       
  4662     	
       
  4663    ConnectData  *connect_data = NULL;
       
  4664     char smsg[MAX_MSG_SIZE];
       
  4665     char rmsg[MAX_MSG_SIZE];
       
  4666     int index=0;
       
  4667     FILE *fp;
       
  4668 		
       
  4669 	int timeout = 200;
       
  4670 	int nBytes;
       
  4671 
       
  4672     int result = 0;
       
  4673     int err = 0;
       
  4674     int status = 0;
       
  4675     message_hdr_req *msgHdr = NULL;  
       
  4676     message_hdr_resp* msg_struct = NULL;
       
  4677     TInt return_value = 0;
       
  4678         	// Read data from the CFG file
       
  4679 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  4680 		{
       
  4681 		iLog->Log ( _L ( "read_data failed" ) );
       
  4682 		free_data ( connect_data );
       
  4683 		return_value = KErrGeneral;
       
  4684 		goto return_code;
       
  4685 		}
       
  4686 	//request formation	
       
  4687 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  4688 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4689 	
       
  4690 	//message header use
       
  4691 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  4692     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4693     
       
  4694     msgHdr->message_type = ELogin_Request;
       
  4695  
       
  4696     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4697     index += sizeof( message_hdr_req );
       
  4698     
       
  4699     int len = strlen(connect_data->username);
       
  4700     strcpy( smsg + index, connect_data->username );
       
  4701     index += len + 1;
       
  4702     
       
  4703     //appending password
       
  4704     
       
  4705     len = strlen(connect_data->password );
       
  4706     strcpy( smsg + index, connect_data->password );
       
  4707     index += len + 1;
       
  4708     
       
  4709     //appending server name
       
  4710     
       
  4711     len = strlen(connect_data->server );
       
  4712     strcpy( smsg + index, connect_data->server );
       
  4713     index += len + 1;
       
  4714     
       
  4715     //appending resource
       
  4716     len = strlen(connect_data->resource );
       
  4717     strcpy( smsg + index, connect_data->resource );
       
  4718     index += len + 1;
       
  4719     
       
  4720     //appending ssl
       
  4721     smsg[index++]= '1';
       
  4722     smsg[index++]= '\0';
       
  4723     
       
  4724     //appending server port
       
  4725     len = strlen(connect_data->port );
       
  4726     strcpy( smsg + index, connect_data->port );
       
  4727     index += len + 1;
       
  4728     
       
  4729     // appending IAP id
       
  4730     
       
  4731     smsg[index++]= '1';
       
  4732     smsg[index++]= '\0';
       
  4733     
       
  4734     //appending connmgr_bus
       
  4735     len = strlen(connect_data->connmgr_bus );
       
  4736     strcpy( smsg + index, connect_data->connmgr_bus );
       
  4737     index += len + 1;
       
  4738     
       
  4739     //appending connmgr_path
       
  4740     len = strlen(connect_data->connmgr_path );
       
  4741     strcpy( smsg + index, connect_data->connmgr_path );
       
  4742     index += len + 1;
       
  4743     
       
  4744     //appending protocol
       
  4745     len = strlen(connect_data->protocol );
       
  4746     strcpy( smsg + index, connect_data->protocol );
       
  4747     index += len + 1;
       
  4748     
       
  4749     #ifdef __WINSCW__
       
  4750     //proxy server
       
  4751     len = strlen(connect_data->proxy_data->proxy_server );
       
  4752     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  4753     index += len + 1;
       
  4754     
       
  4755     //proxy port
       
  4756     len = strlen(connect_data->proxy_data->proxy_port );
       
  4757     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  4758     index += len + 1;
       
  4759     
       
  4760     #endif
       
  4761     //running isoserver   
       
  4762     run_isoserver(); 
       
  4763     
       
  4764     
       
  4765         
       
  4766     //create message queue for send request
       
  4767     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4768     //create message queue for response request
       
  4769     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  4770 		
       
  4771 	
       
  4772 	/* Send Message to queueOne */
       
  4773 	
       
  4774 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4775     
       
  4776     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  4777     
       
  4778     if (status < 0)
       
  4779     {
       
  4780     return_value = KErrGeneral;
       
  4781 	goto return_code;	
       
  4782     }
       
  4783     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  4784 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  4785 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  4786 	
       
  4787 	if( msg_struct->response != 1)
       
  4788     {
       
  4789     	return_value = KErrGeneral;
       
  4790 	goto return_code;
       
  4791     }
       
  4792     
       
  4793     
       
  4794     // login end
       
  4795     //fetch req..
       
  4796     for (int i= 0 ;i<3 ;i++)
       
  4797     {
       
  4798         
       
  4799     fp = fopen("c:\\fetch_contact.txt","a");
       
  4800 	do  {
       
  4801 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  4802 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4803 		fwrite(rmsg,1,status,fp);
       
  4804 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4805 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  4806 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  4807 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  4808 	fclose(fp);	
       
  4809 	
       
  4810     }
       
  4811 
       
  4812 	//fetch end
       
  4813      
       
  4814     //send messge--------------------------------------------
       
  4815    
       
  4816     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4817 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4818 	index=0;
       
  4819     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4820     msgHdr->message_type = ESend_Request;	
       
  4821     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4822 	index += sizeof( message_hdr_req );
       
  4823 	
       
  4824 	
       
  4825     // adding recipient
       
  4826     len = strlen(connect_data->msg_data->recipient );
       
  4827     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4828     index += len + 1;
       
  4829     
       
  4830      // adding recipient
       
  4831     /*len = strlen(connect_data->msg_data->recipient );
       
  4832     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  4833     index += len + 1;*/
       
  4834     
       
  4835     smsg[index++] = '\0';
       
  4836     
       
  4837     // adding message part
       
  4838      
       
  4839     len = strlen(connect_data->msg_data->message );
       
  4840     strncpy( smsg + index, connect_data->msg_data->message, strlen( connect_data->msg_data->message ) );
       
  4841     index += len;
       
  4842     smsg[index++] = ' ';
       
  4843     smsg[index++]=':';
       
  4844     smsg[index++]='-';
       
  4845     smsg[index++]=')';
       
  4846     smsg[index++] = '\0';
       
  4847        
       
  4848     
       
  4849     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4850      do  {
       
  4851 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4852 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4853 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4854 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  4855    
       
  4856      if ( msg_struct->response != 1)
       
  4857     {
       
  4858     	return_value = KErrGeneral;
       
  4859 	goto return_code;
       
  4860     }
       
  4861     
       
  4862     
       
  4863     //send message end---------------------------------------
       
  4864     
       
  4865     
       
  4866     // logout test code from server
       
  4867     index=0;
       
  4868     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4869 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4870 	
       
  4871 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4872     
       
  4873     msgHdr->message_type = ELogout_Request;
       
  4874  
       
  4875     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4876     index += sizeof( message_hdr_req );
       
  4877 
       
  4878 	
       
  4879 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  4880      do  {
       
  4881 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  4882 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  4883 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4884 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  4885    
       
  4886      if ( msg_struct->response != 1)
       
  4887     {
       
  4888     	return_value = KErrGeneral;
       
  4889 	goto return_code;
       
  4890     }
       
  4891     //killing isoserver
       
  4892     return_code:
       
  4893     index=0;
       
  4894     memset( smsg, '\0', MAX_MSG_SIZE );
       
  4895 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4896 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4897     msgHdr->message_type = EKill_Process;
       
  4898     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4899     index += sizeof( message_hdr_req );
       
  4900 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  4901     free( msg_struct );
       
  4902     return return_value;
       
  4903     }
       
  4904     
       
  4905     // -----------------------------------------------------------------------------
       
  4906 // Cisolationserver::Send message
       
  4907 // Example test method function.
       
  4908 // (other items were commented in a header).
       
  4909 // -----------------------------------------------------------------------------
       
  4910 //
       
  4911 TInt Cisolationserver::SendMessageToOfflineContact( CStifItemParser& aItem )
       
  4912     {
       
  4913 
       
  4914     	
       
  4915    ConnectData  *connect_data = NULL;
       
  4916     char smsg[MAX_MSG_SIZE];
       
  4917     char rmsg[MAX_MSG_SIZE];
       
  4918     int index=0;
       
  4919     FILE *fp;
       
  4920 		
       
  4921 	int timeout = 200;
       
  4922 	int nBytes;
       
  4923 
       
  4924     int result = 0;
       
  4925     int err = 0;
       
  4926     int status = 0;
       
  4927     message_hdr_req *msgHdr = NULL;  
       
  4928     message_hdr_resp* msg_struct = NULL;
       
  4929     TInt return_value = 0;
       
  4930         	// Read data from the CFG file
       
  4931 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  4932 		{
       
  4933 		iLog->Log ( _L ( "read_data failed" ) );
       
  4934 		free_data ( connect_data );
       
  4935 		return_value = KErrGeneral;
       
  4936 		goto return_code;
       
  4937 		}
       
  4938 	//request formation	
       
  4939 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  4940 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  4941 	
       
  4942 	//message header use
       
  4943 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  4944     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  4945     
       
  4946     msgHdr->message_type = ELogin_Request;
       
  4947  
       
  4948     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  4949     index += sizeof( message_hdr_req );
       
  4950     
       
  4951     int len = strlen(connect_data->username);
       
  4952     strcpy( smsg + index, connect_data->username );
       
  4953     index += len + 1;
       
  4954     
       
  4955     //appending password
       
  4956     
       
  4957     len = strlen(connect_data->password );
       
  4958     strcpy( smsg + index, connect_data->password );
       
  4959     index += len + 1;
       
  4960     
       
  4961     //appending server name
       
  4962     
       
  4963     len = strlen(connect_data->server );
       
  4964     strcpy( smsg + index, connect_data->server );
       
  4965     index += len + 1;
       
  4966     
       
  4967     //appending resource
       
  4968     len = strlen(connect_data->resource );
       
  4969     strcpy( smsg + index, connect_data->resource );
       
  4970     index += len + 1;
       
  4971     
       
  4972     //appending ssl
       
  4973     smsg[index++]= '1';
       
  4974     smsg[index++]= '\0';
       
  4975     
       
  4976     //appending server port
       
  4977     len = strlen(connect_data->port );
       
  4978     strcpy( smsg + index, connect_data->port );
       
  4979     index += len + 1;
       
  4980     
       
  4981     // appending IAP id
       
  4982     
       
  4983     smsg[index++]= '1';
       
  4984     smsg[index++]= '\0';
       
  4985     
       
  4986     //appending connmgr_bus
       
  4987     len = strlen(connect_data->connmgr_bus );
       
  4988     strcpy( smsg + index, connect_data->connmgr_bus );
       
  4989     index += len + 1;
       
  4990     
       
  4991     //appending connmgr_path
       
  4992     len = strlen(connect_data->connmgr_path );
       
  4993     strcpy( smsg + index, connect_data->connmgr_path );
       
  4994     index += len + 1;
       
  4995     
       
  4996     //appending protocol
       
  4997     len = strlen(connect_data->protocol );
       
  4998     strcpy( smsg + index, connect_data->protocol );
       
  4999     index += len + 1;
       
  5000     
       
  5001     #ifdef __WINSCW__
       
  5002     //proxy server
       
  5003     len = strlen(connect_data->proxy_data->proxy_server );
       
  5004     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  5005     index += len + 1;
       
  5006     
       
  5007     //proxy port
       
  5008     len = strlen(connect_data->proxy_data->proxy_port );
       
  5009     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  5010     index += len + 1;
       
  5011     
       
  5012     #endif
       
  5013     //running isoserver   
       
  5014     run_isoserver(); 
       
  5015     
       
  5016     
       
  5017         
       
  5018     //create message queue for send request
       
  5019     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5020     //create message queue for response request
       
  5021     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5022 		
       
  5023 	
       
  5024 	/* Send Message to queueOne */
       
  5025 	
       
  5026 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5027     
       
  5028     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  5029     
       
  5030     if (status < 0)
       
  5031     {
       
  5032     return_value = KErrGeneral;
       
  5033 	goto return_code;	
       
  5034     }
       
  5035     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  5036 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  5037 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  5038 	
       
  5039 	if( msg_struct->response != 1)
       
  5040     {
       
  5041     	return_value = KErrGeneral;
       
  5042 	goto return_code;
       
  5043     }   
       
  5044     
       
  5045     //fetch req..
       
  5046     for (int i= 0 ;i<3 ;i++)
       
  5047     {
       
  5048         
       
  5049     fp = fopen("c:\\fetch_contact.txt","a");
       
  5050 	do  {
       
  5051 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  5052 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5053 		fwrite(rmsg,1,status,fp);
       
  5054 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5055 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  5056 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  5057 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  5058 	fclose(fp);	
       
  5059 	
       
  5060     }
       
  5061 
       
  5062 	//fetch end
       
  5063     //send messge--------------------------------------------
       
  5064     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5065 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5066 	index=0;
       
  5067     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5068     msgHdr->message_type = ESend_Request;	
       
  5069     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5070 	index += sizeof( message_hdr_req );
       
  5071 	
       
  5072 	
       
  5073     // adding recipient
       
  5074     len = strlen(connect_data->msg_data->recipient );
       
  5075     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5076     index += len + 1;
       
  5077     
       
  5078      // adding recipient
       
  5079     /*len = strlen(connect_data->msg_data->recipient );
       
  5080     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5081     index += len + 1;*/
       
  5082     
       
  5083     smsg[index++] = '\0';
       
  5084     
       
  5085     // adding message part
       
  5086      
       
  5087     len = strlen(connect_data->msg_data->message );
       
  5088     strcpy( smsg + index, connect_data->msg_data->message );
       
  5089     index += len + 1;
       
  5090      
       
  5091        
       
  5092     
       
  5093     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5094      do  {
       
  5095 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5096 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5097 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5098 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  5099    
       
  5100      if ( msg_struct->response != 1)
       
  5101     {
       
  5102     	return_value = KErrGeneral;
       
  5103 	goto return_code;
       
  5104     }    
       
  5105     
       
  5106     //send message end---------------------------------------
       
  5107     
       
  5108    // logout test code from server
       
  5109     index=0;
       
  5110     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5111 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5112 	
       
  5113 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5114     
       
  5115     msgHdr->message_type = ELogout_Request;
       
  5116  
       
  5117     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5118     index += sizeof( message_hdr_req );
       
  5119 
       
  5120 	
       
  5121 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5122      do  {
       
  5123 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5124 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5125 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5126 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  5127    
       
  5128      if ( msg_struct->response != 1)
       
  5129     {
       
  5130     	return_value = KErrGeneral;
       
  5131 	goto return_code;
       
  5132     }
       
  5133     
       
  5134      //killing isoserver
       
  5135     return_code:
       
  5136     index=0;
       
  5137     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5138 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5139 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5140     msgHdr->message_type = EKill_Process;
       
  5141     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5142     index += sizeof( message_hdr_req );
       
  5143 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  5144     free( msg_struct );
       
  5145     return return_value;
       
  5146     }
       
  5147 
       
  5148 
       
  5149 // -----------------------------------------------------------------------------
       
  5150 // Cisolationserver::Send message
       
  5151 // Example test method function.
       
  5152 // (other items were commented in a header).
       
  5153 // -----------------------------------------------------------------------------
       
  5154 //
       
  5155 TInt Cisolationserver::SendContinuousltReapitiveMessage( CStifItemParser& aItem )
       
  5156     {
       
  5157 
       
  5158     	
       
  5159    ConnectData  *connect_data = NULL;
       
  5160     char smsg[MAX_MSG_SIZE];
       
  5161     char rmsg[MAX_MSG_SIZE];
       
  5162     int index=0;
       
  5163     FILE *fp;
       
  5164 		
       
  5165 	int timeout = 200;
       
  5166 	int nBytes;
       
  5167 
       
  5168     int result = 0;
       
  5169     int err = 0;
       
  5170     int status = 0;
       
  5171     message_hdr_req *msgHdr = NULL;  
       
  5172     message_hdr_resp* msg_struct = NULL;
       
  5173     TInt return_value = 0;
       
  5174         	// Read data from the CFG file
       
  5175 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  5176 		{
       
  5177 		iLog->Log ( _L ( "read_data failed" ) );
       
  5178 		free_data ( connect_data );
       
  5179 		return_value = KErrGeneral;
       
  5180 		goto return_code;
       
  5181 		}
       
  5182 	//request formation	
       
  5183 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  5184 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5185 	
       
  5186 	//message header use
       
  5187 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  5188     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5189     
       
  5190     msgHdr->message_type = ELogin_Request;
       
  5191  
       
  5192     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5193     index += sizeof( message_hdr_req );
       
  5194     
       
  5195     int len = strlen(connect_data->username);
       
  5196     strcpy( smsg + index, connect_data->username );
       
  5197     index += len + 1;
       
  5198     
       
  5199     //appending password
       
  5200     
       
  5201     len = strlen(connect_data->password );
       
  5202     strcpy( smsg + index, connect_data->password );
       
  5203     index += len + 1;
       
  5204     
       
  5205     //appending server name
       
  5206     
       
  5207     len = strlen(connect_data->server );
       
  5208     strcpy( smsg + index, connect_data->server );
       
  5209     index += len + 1;
       
  5210     
       
  5211     //appending resource
       
  5212     len = strlen(connect_data->resource );
       
  5213     strcpy( smsg + index, connect_data->resource );
       
  5214     index += len + 1;
       
  5215     
       
  5216     //appending ssl
       
  5217     smsg[index++]= '1';
       
  5218     smsg[index++]= '\0';
       
  5219     
       
  5220     //appending server port
       
  5221     len = strlen(connect_data->port );
       
  5222     strcpy( smsg + index, connect_data->port );
       
  5223     index += len + 1;
       
  5224     
       
  5225     // appending IAP id
       
  5226     
       
  5227     smsg[index++]= '1';
       
  5228     smsg[index++]= '\0';
       
  5229     
       
  5230     //appending connmgr_bus
       
  5231     len = strlen(connect_data->connmgr_bus );
       
  5232     strcpy( smsg + index, connect_data->connmgr_bus );
       
  5233     index += len + 1;
       
  5234     
       
  5235     //appending connmgr_path
       
  5236     len = strlen(connect_data->connmgr_path );
       
  5237     strcpy( smsg + index, connect_data->connmgr_path );
       
  5238     index += len + 1;
       
  5239     
       
  5240     //appending protocol
       
  5241     len = strlen(connect_data->protocol );
       
  5242     strcpy( smsg + index, connect_data->protocol );
       
  5243     index += len + 1;
       
  5244     
       
  5245     #ifdef __WINSCW__
       
  5246     //proxy server
       
  5247     len = strlen(connect_data->proxy_data->proxy_server );
       
  5248     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  5249     index += len + 1;
       
  5250     
       
  5251     //proxy port
       
  5252     len = strlen(connect_data->proxy_data->proxy_port );
       
  5253     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  5254     index += len + 1;
       
  5255     
       
  5256     #endif
       
  5257     //running isoserver   
       
  5258     run_isoserver(); 
       
  5259     
       
  5260     
       
  5261         
       
  5262     //create message queue for send request
       
  5263     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5264     //create message queue for response request
       
  5265     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5266 		
       
  5267 	
       
  5268 	/* Send Message to queueOne */
       
  5269 	
       
  5270 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5271     
       
  5272     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  5273     
       
  5274     if (status < 0)
       
  5275     {
       
  5276     return_value = KErrGeneral;
       
  5277 	goto return_code;	
       
  5278     }
       
  5279     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  5280 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  5281 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  5282 	
       
  5283 	if( msg_struct->response != 1)
       
  5284     {
       
  5285     	return_value = KErrGeneral;
       
  5286 	goto return_code;
       
  5287     }
       
  5288     
       
  5289     
       
  5290     // login end
       
  5291     //fetch req..
       
  5292     for (int i= 0 ;i<3 ;i++)
       
  5293     {
       
  5294         
       
  5295     fp = fopen("c:\\fetch_contact.txt","a");
       
  5296 	do  {
       
  5297 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  5298 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5299 		fwrite(rmsg,1,status,fp);
       
  5300 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5301 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  5302 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  5303 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  5304 	fclose(fp);	
       
  5305 	
       
  5306     }
       
  5307 
       
  5308 	//fetch end
       
  5309      
       
  5310     //send messge 1 --------------------------------------------
       
  5311    
       
  5312     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5313 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5314 	index=0;
       
  5315     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5316     msgHdr->message_type = ESend_Request;	
       
  5317     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5318 	index += sizeof( message_hdr_req );
       
  5319 	
       
  5320 	
       
  5321     // adding recipient
       
  5322     len = strlen(connect_data->msg_data->recipient );
       
  5323     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5324     index += len + 1;
       
  5325     
       
  5326      // adding recipient
       
  5327     /*len = strlen(connect_data->msg_data->recipient );
       
  5328     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5329     index += len + 1;*/
       
  5330     
       
  5331     smsg[index++] = '\0';
       
  5332     
       
  5333     // adding message part
       
  5334      
       
  5335     len = strlen(connect_data->msg_data->message );
       
  5336     strcpy( smsg + index, connect_data->msg_data->message );
       
  5337     index += len + 1;
       
  5338      
       
  5339        
       
  5340     
       
  5341     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5342      do  {
       
  5343 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5344 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5345 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5346 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  5347    
       
  5348      if ( msg_struct->response != 1)
       
  5349     {
       
  5350     	return_value = KErrGeneral;
       
  5351 	goto return_code;
       
  5352     }
       
  5353     
       
  5354     //send message end---------------------------------------
       
  5355     
       
  5356     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5357 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5358 	index=0;
       
  5359     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5360     msgHdr->message_type = ESend_Request;	
       
  5361     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5362 	index += sizeof( message_hdr_req );
       
  5363 	
       
  5364 	
       
  5365     // adding recipient
       
  5366     len = strlen(connect_data->msg_data->recipient );
       
  5367     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5368     index += len + 1;
       
  5369     
       
  5370      // adding recipient
       
  5371     /*len = strlen(connect_data->msg_data->recipient );
       
  5372     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5373     index += len + 1;*/
       
  5374     
       
  5375     smsg[index++] = '\0';
       
  5376     
       
  5377     // adding message part
       
  5378      
       
  5379     len = strlen(connect_data->msg_data->message );
       
  5380     strcpy( smsg + index, connect_data->msg_data->message );
       
  5381     index += len + 1;
       
  5382      
       
  5383        
       
  5384     
       
  5385     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5386      do  {
       
  5387 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5388 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5389 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5390 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  5391    
       
  5392      if ( msg_struct->response != 1)
       
  5393     {
       
  5394     	return_value = KErrGeneral;
       
  5395 	goto return_code;
       
  5396     }
       
  5397     
       
  5398 
       
  5399     // logout test code from server
       
  5400     index=0;
       
  5401     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5402 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5403 	
       
  5404 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5405     
       
  5406     msgHdr->message_type = ELogout_Request;
       
  5407  
       
  5408     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5409     index += sizeof( message_hdr_req );
       
  5410 
       
  5411 	
       
  5412 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5413      do  {
       
  5414 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5415 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5416 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5417 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  5418    
       
  5419      if ( msg_struct->response != 1)
       
  5420     {
       
  5421     	return_value = KErrGeneral;
       
  5422 	goto return_code;
       
  5423     }
       
  5424     
       
  5425      //killing isoserver
       
  5426     return_code:
       
  5427     index=0;
       
  5428     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5429 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5430 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5431     msgHdr->message_type = EKill_Process;
       
  5432     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5433     index += sizeof( message_hdr_req );
       
  5434 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  5435     free( msg_struct );
       
  5436     return return_value;
       
  5437     }
       
  5438 
       
  5439 
       
  5440 // -----------------------------------------------------------------------------
       
  5441 // Cisolationserver::Send message
       
  5442 // Example test method function.
       
  5443 // (other items were commented in a header).
       
  5444 // -----------------------------------------------------------------------------
       
  5445 //
       
  5446 TInt Cisolationserver::SendTextMessageToBlockedUser( CStifItemParser& aItem )
       
  5447     {
       
  5448 
       
  5449     	
       
  5450    ConnectData  *connect_data = NULL;
       
  5451     char smsg[MAX_MSG_SIZE];
       
  5452     char rmsg[MAX_MSG_SIZE];
       
  5453     int index=0;
       
  5454     FILE *fp;
       
  5455 		
       
  5456 	int timeout = 200;
       
  5457 	int nBytes;
       
  5458 
       
  5459     int result = 0;
       
  5460     int err = 0;
       
  5461     int status = 0;
       
  5462     message_hdr_req *msgHdr = NULL;  
       
  5463     message_hdr_resp* msg_struct = NULL;
       
  5464     TInt return_value = 0;
       
  5465         	// Read data from the CFG file
       
  5466 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  5467 		{
       
  5468 		iLog->Log ( _L ( "read_data failed" ) );
       
  5469 		free_data ( connect_data );
       
  5470 		return_value = KErrGeneral;
       
  5471 		goto return_code;
       
  5472 		}
       
  5473 	//request formation	
       
  5474 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  5475 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5476 	
       
  5477 	//message header use
       
  5478 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  5479     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5480     
       
  5481     msgHdr->message_type = ELogin_Request;
       
  5482  
       
  5483     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5484     index += sizeof( message_hdr_req );
       
  5485     
       
  5486     int len = strlen(connect_data->username);
       
  5487     strcpy( smsg + index, connect_data->username );
       
  5488     index += len + 1;
       
  5489     
       
  5490     //appending password
       
  5491     
       
  5492     len = strlen(connect_data->password );
       
  5493     strcpy( smsg + index, connect_data->password );
       
  5494     index += len + 1;
       
  5495     
       
  5496     //appending server name
       
  5497     
       
  5498     len = strlen(connect_data->server );
       
  5499     strcpy( smsg + index, connect_data->server );
       
  5500     index += len + 1;
       
  5501     
       
  5502     //appending resource
       
  5503     len = strlen(connect_data->resource );
       
  5504     strcpy( smsg + index, connect_data->resource );
       
  5505     index += len + 1;
       
  5506     
       
  5507     //appending ssl
       
  5508     smsg[index++]= '1';
       
  5509     smsg[index++]= '\0';
       
  5510     
       
  5511     //appending server port
       
  5512     len = strlen(connect_data->port );
       
  5513     strcpy( smsg + index, connect_data->port );
       
  5514     index += len + 1;
       
  5515     
       
  5516     // appending IAP id
       
  5517     
       
  5518     smsg[index++]= '1';
       
  5519     smsg[index++]= '\0';
       
  5520     
       
  5521     //appending connmgr_bus
       
  5522     len = strlen(connect_data->connmgr_bus );
       
  5523     strcpy( smsg + index, connect_data->connmgr_bus );
       
  5524     index += len + 1;
       
  5525     
       
  5526     //appending connmgr_path
       
  5527     len = strlen(connect_data->connmgr_path );
       
  5528     strcpy( smsg + index, connect_data->connmgr_path );
       
  5529     index += len + 1;
       
  5530     
       
  5531     //appending protocol
       
  5532     len = strlen(connect_data->protocol );
       
  5533     strcpy( smsg + index, connect_data->protocol );
       
  5534     index += len + 1;
       
  5535     
       
  5536     #ifdef __WINSCW__
       
  5537     //proxy server
       
  5538     len = strlen(connect_data->proxy_data->proxy_server );
       
  5539     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  5540     index += len + 1;
       
  5541     
       
  5542     //proxy port
       
  5543     len = strlen(connect_data->proxy_data->proxy_port );
       
  5544     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  5545     index += len + 1;
       
  5546     
       
  5547     #endif
       
  5548     //running isoserver   
       
  5549     run_isoserver(); 
       
  5550     
       
  5551     
       
  5552         
       
  5553     //create message queue for send request
       
  5554     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5555     //create message queue for response request
       
  5556     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5557 		
       
  5558 	
       
  5559 	/* Send Message to queueOne */
       
  5560 	
       
  5561 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5562     
       
  5563     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  5564     
       
  5565     if (status < 0)
       
  5566     {
       
  5567     return_value = KErrGeneral;
       
  5568 	goto return_code;	
       
  5569     }
       
  5570     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  5571 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  5572 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  5573 	
       
  5574 	if( msg_struct->response != 1)
       
  5575     {
       
  5576     	return_value = KErrGeneral;
       
  5577 	goto return_code;
       
  5578     }
       
  5579     
       
  5580     
       
  5581     // login end
       
  5582 
       
  5583      //fetch req..
       
  5584     for (int i= 0 ;i<3 ;i++)
       
  5585     {
       
  5586         
       
  5587     fp = fopen("c:\\fetch_contact.txt","a");
       
  5588 	do  {
       
  5589 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  5590 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5591 		fwrite(rmsg,1,status,fp);
       
  5592 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5593 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  5594 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  5595 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  5596 	fclose(fp);	
       
  5597 	
       
  5598     }
       
  5599 
       
  5600 	//fetch end
       
  5601     //send messge--------------------------------------------
       
  5602    
       
  5603     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5604 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5605 	index=0;
       
  5606     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5607     msgHdr->message_type = ESend_Request;	
       
  5608     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5609 	index += sizeof( message_hdr_req );
       
  5610 	
       
  5611 	
       
  5612     // adding recipient
       
  5613     len = strlen(connect_data->msg_data->recipient );
       
  5614     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5615     index += len + 1;
       
  5616     
       
  5617      // adding recipient
       
  5618     /*len = strlen(connect_data->msg_data->recipient );
       
  5619     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5620     index += len + 1;*/
       
  5621     
       
  5622     smsg[index++] = '\0';
       
  5623     
       
  5624     // adding message part
       
  5625      
       
  5626     len = strlen(connect_data->msg_data->message );
       
  5627     strcpy( smsg + index, connect_data->msg_data->message );
       
  5628     index += len + 1;
       
  5629      
       
  5630        
       
  5631     
       
  5632     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5633      do  {
       
  5634 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5635 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5636 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5637 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  5638    
       
  5639      if ( msg_struct->response != 1)
       
  5640     {
       
  5641     	return_value = KErrGeneral;
       
  5642 	goto return_code;
       
  5643     }
       
  5644     
       
  5645     
       
  5646     //send message end---------------------------------------
       
  5647     
       
  5648     
       
  5649     // logout test code from server
       
  5650     index=0;
       
  5651     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5652 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5653 	
       
  5654 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5655     
       
  5656     msgHdr->message_type = ELogout_Request;
       
  5657  
       
  5658     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5659     index += sizeof( message_hdr_req );
       
  5660 
       
  5661 	
       
  5662 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5663      do  {
       
  5664 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5665 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5666 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5667 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  5668    
       
  5669      if ( msg_struct->response != 1)
       
  5670     {
       
  5671     	return_value = KErrGeneral;
       
  5672 	goto return_code;
       
  5673     }
       
  5674      //killing isoserver
       
  5675     return_code:
       
  5676     index=0;
       
  5677     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5678 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5679 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5680     msgHdr->message_type = EKill_Process;
       
  5681     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5682     index += sizeof( message_hdr_req );
       
  5683 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  5684     free( msg_struct );
       
  5685     return return_value;
       
  5686     }
       
  5687 
       
  5688 // -----------------------------------------------------------------------------
       
  5689 // Cisolationserver::Send message
       
  5690 // Example test method function.
       
  5691 // (other items were commented in a header).
       
  5692 // -----------------------------------------------------------------------------
       
  5693 //
       
  5694 TInt Cisolationserver::SendTextMessageToUserIdWhoIsBlockedSender( CStifItemParser& aItem )
       
  5695     {
       
  5696 
       
  5697     	
       
  5698    ConnectData  *connect_data = NULL;
       
  5699     char smsg[MAX_MSG_SIZE];
       
  5700     char rmsg[MAX_MSG_SIZE];
       
  5701     int index=0;
       
  5702     FILE *fp;
       
  5703 		
       
  5704 	int timeout = 200;
       
  5705 	int nBytes;
       
  5706 
       
  5707     int result = 0;
       
  5708     int err = 0;
       
  5709     int status = 0;
       
  5710     message_hdr_req *msgHdr = NULL;  
       
  5711     message_hdr_resp* msg_struct = NULL;
       
  5712     TInt return_value = 0;
       
  5713         	// Read data from the CFG file
       
  5714 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  5715 		{
       
  5716 		iLog->Log ( _L ( "read_data failed" ) );
       
  5717 		free_data ( connect_data );
       
  5718 		return_value = KErrGeneral;
       
  5719 		goto return_code;
       
  5720 		}
       
  5721 	//request formation	
       
  5722 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  5723 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5724 	
       
  5725 	//message header use
       
  5726 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  5727     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5728     
       
  5729     msgHdr->message_type = ELogin_Request;
       
  5730  
       
  5731     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5732     index += sizeof( message_hdr_req );
       
  5733     
       
  5734     int len = strlen(connect_data->username);
       
  5735     strcpy( smsg + index, connect_data->username );
       
  5736     index += len + 1;
       
  5737     
       
  5738     //appending password
       
  5739     
       
  5740     len = strlen(connect_data->password );
       
  5741     strcpy( smsg + index, connect_data->password );
       
  5742     index += len + 1;
       
  5743     
       
  5744     //appending server name
       
  5745     
       
  5746     len = strlen(connect_data->server );
       
  5747     strcpy( smsg + index, connect_data->server );
       
  5748     index += len + 1;
       
  5749     
       
  5750     //appending resource
       
  5751     len = strlen(connect_data->resource );
       
  5752     strcpy( smsg + index, connect_data->resource );
       
  5753     index += len + 1;
       
  5754     
       
  5755     //appending ssl
       
  5756     smsg[index++]= '1';
       
  5757     smsg[index++]= '\0';
       
  5758     
       
  5759     //appending server port
       
  5760     len = strlen(connect_data->port );
       
  5761     strcpy( smsg + index, connect_data->port );
       
  5762     index += len + 1;
       
  5763     
       
  5764     // appending IAP id
       
  5765     
       
  5766     smsg[index++]= '1';
       
  5767     smsg[index++]= '\0';
       
  5768     
       
  5769     //appending connmgr_bus
       
  5770     len = strlen(connect_data->connmgr_bus );
       
  5771     strcpy( smsg + index, connect_data->connmgr_bus );
       
  5772     index += len + 1;
       
  5773     
       
  5774     //appending connmgr_path
       
  5775     len = strlen(connect_data->connmgr_path );
       
  5776     strcpy( smsg + index, connect_data->connmgr_path );
       
  5777     index += len + 1;
       
  5778     
       
  5779     //appending protocol
       
  5780     len = strlen(connect_data->protocol );
       
  5781     strcpy( smsg + index, connect_data->protocol );
       
  5782     index += len + 1;
       
  5783     
       
  5784     #ifdef __WINSCW__
       
  5785     //proxy server
       
  5786     len = strlen(connect_data->proxy_data->proxy_server );
       
  5787     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  5788     index += len + 1;
       
  5789     
       
  5790     //proxy port
       
  5791     len = strlen(connect_data->proxy_data->proxy_port );
       
  5792     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  5793     index += len + 1;
       
  5794     
       
  5795     #endif
       
  5796     //running isoserver   
       
  5797     run_isoserver(); 
       
  5798     
       
  5799     
       
  5800         
       
  5801     //create message queue for send request
       
  5802     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5803     //create message queue for response request
       
  5804     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  5805 		
       
  5806 	
       
  5807 	/* Send Message to queueOne */
       
  5808 	
       
  5809 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5810     
       
  5811     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  5812     
       
  5813     if (status < 0)
       
  5814     {
       
  5815     return_value = KErrGeneral;
       
  5816 	goto return_code;	
       
  5817     }
       
  5818     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  5819 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  5820 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  5821 	
       
  5822 	if( msg_struct->response != 1)
       
  5823     {
       
  5824     	return_value = KErrGeneral;
       
  5825 	goto return_code;
       
  5826     }
       
  5827     
       
  5828     
       
  5829     // login end
       
  5830 
       
  5831     //fetch req..
       
  5832     for (int i= 0 ;i<3 ;i++)
       
  5833     {
       
  5834         
       
  5835     fp = fopen("c:\\fetch_contact.txt","a");
       
  5836 	do  {
       
  5837 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  5838 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5839 		fwrite(rmsg,1,status,fp);
       
  5840 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5841 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  5842 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  5843 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  5844 	fclose(fp);	
       
  5845 	
       
  5846     }
       
  5847 
       
  5848 	//fetch end 
       
  5849     //send messge--------------------------------------------
       
  5850    
       
  5851     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5852 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5853 	index=0;
       
  5854     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5855     msgHdr->message_type = ESend_Request;	
       
  5856     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5857 	index += sizeof( message_hdr_req );
       
  5858 	
       
  5859 	
       
  5860     // adding recipient
       
  5861     len = strlen(connect_data->msg_data->recipient );
       
  5862     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5863     index += len + 1;
       
  5864     
       
  5865      // adding recipient
       
  5866     /*len = strlen(connect_data->msg_data->recipient );
       
  5867     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  5868     index += len + 1;*/
       
  5869     
       
  5870     smsg[index++] = '\0';
       
  5871     
       
  5872     // adding message part
       
  5873      
       
  5874     len = strlen(connect_data->msg_data->message );
       
  5875     strcpy( smsg + index, connect_data->msg_data->message );
       
  5876     index += len + 1;
       
  5877      
       
  5878        
       
  5879     
       
  5880     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5881      do  {
       
  5882 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5883 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5884 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5885 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  5886    
       
  5887      if ( msg_struct->response != 1)
       
  5888     {
       
  5889     	return_value = KErrGeneral;
       
  5890 	goto return_code;
       
  5891     }
       
  5892     
       
  5893     
       
  5894     //send message end---------------------------------------
       
  5895     
       
  5896     
       
  5897     // logout test code from server
       
  5898     index=0;
       
  5899     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5900 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5901 	
       
  5902 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5903     
       
  5904     msgHdr->message_type = ELogout_Request;
       
  5905  
       
  5906     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5907     index += sizeof( message_hdr_req );
       
  5908 
       
  5909 	
       
  5910 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  5911      do  {
       
  5912 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  5913 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  5914 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5915 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  5916    
       
  5917      if ( msg_struct->response != 1)
       
  5918     {
       
  5919     	return_value = KErrGeneral;
       
  5920 	goto return_code;
       
  5921     }
       
  5922      //killing isoserver
       
  5923     return_code:
       
  5924     index=0;
       
  5925     memset( smsg, '\0', MAX_MSG_SIZE );
       
  5926 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5927 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5928     msgHdr->message_type = EKill_Process;
       
  5929     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5930     index += sizeof( message_hdr_req );
       
  5931 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  5932     free( msg_struct );
       
  5933     return return_value;
       
  5934     }
       
  5935 
       
  5936 // -----------------------------------------------------------------------------
       
  5937 // Cisolationserver::Send message
       
  5938 // Example test method function.
       
  5939 // (other items were commented in a header).
       
  5940 // -----------------------------------------------------------------------------
       
  5941 //
       
  5942 TInt Cisolationserver::SendLongTextMessageToUserId( CStifItemParser& aItem )
       
  5943     {
       
  5944 
       
  5945     	
       
  5946     ConnectData  *connect_data = NULL;
       
  5947     char smsg[MAX_MSG_SIZE];
       
  5948     char rmsg[MAX_MSG_SIZE];
       
  5949     int index=0;
       
  5950     FILE *fp;
       
  5951 		
       
  5952 	int timeout = 200;
       
  5953 	int nBytes;
       
  5954 
       
  5955     int result = 0;
       
  5956     int err = 0;
       
  5957     int status = 0;
       
  5958     message_hdr_req *msgHdr = NULL;  
       
  5959     message_hdr_resp* msg_struct = NULL;
       
  5960     TInt return_value = 0;
       
  5961         	// Read data from the CFG file
       
  5962 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  5963 		{
       
  5964 		iLog->Log ( _L ( "read_data failed" ) );
       
  5965 		free_data ( connect_data );
       
  5966 		return_value = KErrGeneral;
       
  5967 		goto return_code;
       
  5968 		}
       
  5969 	//request formation	
       
  5970 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  5971 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  5972 	
       
  5973 	//message header use
       
  5974 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  5975     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  5976     
       
  5977     msgHdr->message_type = ELogin_Request;
       
  5978  
       
  5979     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  5980     index += sizeof( message_hdr_req );
       
  5981     
       
  5982     int len = strlen(connect_data->username);
       
  5983     strcpy( smsg + index, connect_data->username );
       
  5984     index += len + 1;
       
  5985     
       
  5986     //appending password
       
  5987     
       
  5988     len = strlen(connect_data->password );
       
  5989     strcpy( smsg + index, connect_data->password );
       
  5990     index += len + 1;
       
  5991     
       
  5992     //appending server name
       
  5993     
       
  5994     len = strlen(connect_data->server );
       
  5995     strcpy( smsg + index, connect_data->server );
       
  5996     index += len + 1;
       
  5997     
       
  5998     //appending resource
       
  5999     len = strlen(connect_data->resource );
       
  6000     strcpy( smsg + index, connect_data->resource );
       
  6001     index += len + 1;
       
  6002     
       
  6003     //appending ssl
       
  6004     smsg[index++]= '1';
       
  6005     smsg[index++]= '\0';
       
  6006     
       
  6007     //appending server port
       
  6008     len = strlen(connect_data->port );
       
  6009     strcpy( smsg + index, connect_data->port );
       
  6010     index += len + 1;
       
  6011     
       
  6012     // appending IAP id
       
  6013     
       
  6014     smsg[index++]= '1';
       
  6015     smsg[index++]= '\0';
       
  6016     
       
  6017     //appending connmgr_bus
       
  6018     len = strlen(connect_data->connmgr_bus );
       
  6019     strcpy( smsg + index, connect_data->connmgr_bus );
       
  6020     index += len + 1;
       
  6021     
       
  6022     //appending connmgr_path
       
  6023     len = strlen(connect_data->connmgr_path );
       
  6024     strcpy( smsg + index, connect_data->connmgr_path );
       
  6025     index += len + 1;
       
  6026     
       
  6027     //appending protocol
       
  6028     len = strlen(connect_data->protocol );
       
  6029     strcpy( smsg + index, connect_data->protocol );
       
  6030     index += len + 1;
       
  6031     
       
  6032     #ifdef __WINSCW__
       
  6033     //proxy server
       
  6034     len = strlen(connect_data->proxy_data->proxy_server );
       
  6035     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  6036     index += len + 1;
       
  6037     
       
  6038     //proxy port
       
  6039     len = strlen(connect_data->proxy_data->proxy_port );
       
  6040     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  6041     index += len + 1;
       
  6042     
       
  6043     #endif
       
  6044     
       
  6045     run_isoserver();
       
  6046     
       
  6047         
       
  6048     //create message queue for send request
       
  6049     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6050     //create message queue for response request
       
  6051     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6052 		
       
  6053 	
       
  6054 	/* Send Message to queueOne */
       
  6055 	
       
  6056 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6057     
       
  6058     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  6059     
       
  6060     if (status < 0)
       
  6061     {
       
  6062     return_value = KErrGeneral;
       
  6063 	goto return_code;	
       
  6064     }
       
  6065     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  6066 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  6067 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  6068 	
       
  6069 	if( msg_struct->response != 1)
       
  6070     {
       
  6071     	return_value = KErrGeneral;
       
  6072 	goto return_code;
       
  6073     }
       
  6074     
       
  6075     
       
  6076     // login end
       
  6077    //fetch req..
       
  6078     for (int i= 0 ;i<3 ;i++)
       
  6079     {
       
  6080         
       
  6081     fp = fopen("c:\\fetch_contact.txt","a");
       
  6082 	do  {
       
  6083 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  6084 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6085 		fwrite(rmsg,1,status,fp);
       
  6086 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6087 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  6088 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  6089 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  6090 	fclose(fp);	
       
  6091 	
       
  6092     }
       
  6093 
       
  6094 	//fetch end
       
  6095      
       
  6096     //send messge--------------------------------------------
       
  6097    
       
  6098     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6099 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6100 	index=0;
       
  6101     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6102     msgHdr->message_type = ESend_Request;	
       
  6103     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6104 	index += sizeof( message_hdr_req );
       
  6105 	
       
  6106 	
       
  6107     // adding recipient
       
  6108     len = strlen(connect_data->msg_data->recipient );
       
  6109     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  6110     index += len + 1;
       
  6111     
       
  6112      // adding recipient
       
  6113     /*len = strlen(connect_data->msg_data->recipient );
       
  6114     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  6115     index += len + 1;*/
       
  6116     
       
  6117     smsg[index++] = '\0';
       
  6118     
       
  6119     // adding message part
       
  6120      
       
  6121     len = strlen(connect_data->msg_data->message );
       
  6122     strcpy( smsg + index, connect_data->msg_data->message );
       
  6123     index += len + 1;
       
  6124      
       
  6125        
       
  6126     
       
  6127     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6128      do  {
       
  6129 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6130 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6131 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6132 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  6133    
       
  6134      if ( msg_struct->response != 1)
       
  6135     {
       
  6136     	return_value = KErrGeneral;
       
  6137 	goto return_code;
       
  6138     } 
       
  6139     
       
  6140     
       
  6141     //send message end---------------------------------------
       
  6142     
       
  6143     
       
  6144     // logout test code from server
       
  6145     index=0;
       
  6146     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6147 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6148 	
       
  6149 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6150     
       
  6151     msgHdr->message_type = ELogout_Request;
       
  6152  
       
  6153     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6154     index += sizeof( message_hdr_req );
       
  6155 
       
  6156 	
       
  6157 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6158      do  {
       
  6159 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6160 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6161 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6162 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  6163    
       
  6164      if ( msg_struct->response != 1)
       
  6165     {
       
  6166     	return_value = KErrGeneral;
       
  6167 	goto return_code;
       
  6168     }
       
  6169     
       
  6170      //killing isoserver
       
  6171     return_code:
       
  6172     index=0;
       
  6173     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6174 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6175 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6176     msgHdr->message_type = EKill_Process;
       
  6177     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6178     index += sizeof( message_hdr_req );
       
  6179 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  6180     free( msg_struct );
       
  6181     return return_value;
       
  6182     }
       
  6183 
       
  6184 // -----------------------------------------------------------------------------
       
  6185 // Cisolationserver::Send message
       
  6186 // Example test method function.
       
  6187 // (other items were commented in a header).
       
  6188 // -----------------------------------------------------------------------------
       
  6189 //
       
  6190 TInt Cisolationserver::SendTextMessageUserWhoIsNotAddedInContactList( CStifItemParser& aItem )
       
  6191     {
       
  6192 
       
  6193     	
       
  6194     ConnectData  *connect_data = NULL;
       
  6195     char smsg[MAX_MSG_SIZE];
       
  6196     char rmsg[MAX_MSG_SIZE];
       
  6197     int index=0;
       
  6198     FILE *fp;
       
  6199 		
       
  6200 	int timeout = 200;
       
  6201 	int nBytes;
       
  6202 
       
  6203     int result = 0;
       
  6204     int err = 0;
       
  6205     int status = 0;
       
  6206     message_hdr_req *msgHdr = NULL;  
       
  6207     message_hdr_resp* msg_struct = NULL;
       
  6208     TInt return_value = 0;
       
  6209         	// Read data from the CFG file
       
  6210 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  6211 		{
       
  6212 		iLog->Log ( _L ( "read_data failed" ) );
       
  6213 		free_data ( connect_data );
       
  6214 		return_value = KErrGeneral;
       
  6215 		goto return_code;
       
  6216 		}
       
  6217 	//request formation	
       
  6218 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  6219 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6220 	
       
  6221 	//message header use
       
  6222 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  6223     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6224     
       
  6225     msgHdr->message_type = ELogin_Request;
       
  6226  
       
  6227     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6228     index += sizeof( message_hdr_req );
       
  6229     
       
  6230     int len = strlen(connect_data->username);
       
  6231     strcpy( smsg + index, connect_data->username );
       
  6232     index += len + 1;
       
  6233     
       
  6234     //appending password
       
  6235     
       
  6236     len = strlen(connect_data->password );
       
  6237     strcpy( smsg + index, connect_data->password );
       
  6238     index += len + 1;
       
  6239     
       
  6240     //appending server name
       
  6241     
       
  6242     len = strlen(connect_data->server );
       
  6243     strcpy( smsg + index, connect_data->server );
       
  6244     index += len + 1;
       
  6245     
       
  6246     //appending resource
       
  6247     len = strlen(connect_data->resource );
       
  6248     strcpy( smsg + index, connect_data->resource );
       
  6249     index += len + 1;
       
  6250     
       
  6251     //appending ssl
       
  6252     smsg[index++]= '1';
       
  6253     smsg[index++]= '\0';
       
  6254     
       
  6255     //appending server port
       
  6256     len = strlen(connect_data->port );
       
  6257     strcpy( smsg + index, connect_data->port );
       
  6258     index += len + 1;
       
  6259     
       
  6260     // appending IAP id
       
  6261     
       
  6262     smsg[index++]= '1';
       
  6263     smsg[index++]= '\0';
       
  6264     
       
  6265     //appending connmgr_bus
       
  6266     len = strlen(connect_data->connmgr_bus );
       
  6267     strcpy( smsg + index, connect_data->connmgr_bus );
       
  6268     index += len + 1;
       
  6269     
       
  6270     //appending connmgr_path
       
  6271     len = strlen(connect_data->connmgr_path );
       
  6272     strcpy( smsg + index, connect_data->connmgr_path );
       
  6273     index += len + 1;
       
  6274     
       
  6275     //appending protocol
       
  6276     len = strlen(connect_data->protocol );
       
  6277     strcpy( smsg + index, connect_data->protocol );
       
  6278     index += len + 1;
       
  6279     
       
  6280     #ifdef __WINSCW__
       
  6281     //proxy server
       
  6282     len = strlen(connect_data->proxy_data->proxy_server );
       
  6283     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  6284     index += len + 1;
       
  6285     
       
  6286     //proxy port
       
  6287     len = strlen(connect_data->proxy_data->proxy_port );
       
  6288     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  6289     index += len + 1;
       
  6290     
       
  6291     #endif
       
  6292     //running isoserver   
       
  6293     run_isoserver(); 
       
  6294     
       
  6295     
       
  6296         
       
  6297     //create message queue for send request
       
  6298     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6299     //create message queue for response request
       
  6300     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6301 		
       
  6302 	
       
  6303 	/* Send Message to queueOne */
       
  6304 	
       
  6305 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6306     
       
  6307     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  6308     
       
  6309     if (status < 0)
       
  6310     {
       
  6311     return_value = KErrGeneral;
       
  6312 	goto return_code;	
       
  6313     }
       
  6314     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  6315 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  6316 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  6317 	
       
  6318 	if( msg_struct->response != 1)
       
  6319     {
       
  6320     	return_value = KErrGeneral;
       
  6321 	goto return_code;
       
  6322     }
       
  6323     
       
  6324     
       
  6325     // login end
       
  6326 
       
  6327     //fetch req..
       
  6328     for (int i= 0 ;i<3 ;i++)
       
  6329     {
       
  6330         
       
  6331     fp = fopen("c:\\fetch_contact.txt","a");
       
  6332 	do  {
       
  6333 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  6334 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6335 		fwrite(rmsg,1,status,fp);
       
  6336 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6337 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  6338 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  6339 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  6340 	fclose(fp);	
       
  6341 	
       
  6342     }
       
  6343 
       
  6344 	//fetch end
       
  6345     //send messge--------------------------------------------
       
  6346    
       
  6347     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6348 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6349 	index=0;
       
  6350     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6351     msgHdr->message_type = ESend_Request;	
       
  6352     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6353 	index += sizeof( message_hdr_req );
       
  6354 	
       
  6355 	
       
  6356     // adding recipient
       
  6357     len = strlen(connect_data->msg_data->recipient );
       
  6358     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  6359     index += len + 1;
       
  6360     
       
  6361      // adding recipient
       
  6362     /*len = strlen(connect_data->msg_data->recipient );
       
  6363     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  6364     index += len + 1;*/
       
  6365     
       
  6366     smsg[index++] = '\0';
       
  6367     
       
  6368     // adding message part
       
  6369      
       
  6370     len = strlen(connect_data->msg_data->message );
       
  6371     strcpy( smsg + index, connect_data->msg_data->message );
       
  6372     index += len + 1;
       
  6373      
       
  6374        
       
  6375     
       
  6376     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6377      do  {
       
  6378 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6379 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6380 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6381 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
  6382    
       
  6383      if ( msg_struct->response != 1)
       
  6384     {
       
  6385     	return_value = KErrGeneral;
       
  6386 	goto return_code;
       
  6387     }
       
  6388     
       
  6389     
       
  6390     //send message end---------------------------------------
       
  6391     
       
  6392     
       
  6393     // logout test code from server
       
  6394     index=0;
       
  6395     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6396 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6397 	
       
  6398 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6399     
       
  6400     msgHdr->message_type = ELogout_Request;
       
  6401  
       
  6402     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6403     index += sizeof( message_hdr_req );
       
  6404 
       
  6405 	
       
  6406 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6407      do  {
       
  6408 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6409 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6410 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6411 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  6412    
       
  6413      if ( msg_struct->response != 1)
       
  6414     {
       
  6415     	return_value = KErrGeneral;
       
  6416 	goto return_code;
       
  6417     }
       
  6418     
       
  6419      //killing isoserver
       
  6420     return_code:
       
  6421     index=0;
       
  6422     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6423 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6424 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6425     msgHdr->message_type = EKill_Process;
       
  6426     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6427     index += sizeof( message_hdr_req );
       
  6428 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  6429     free( msg_struct );
       
  6430     return return_value;
       
  6431     }
       
  6432 
       
  6433  
       
  6434 
       
  6435 // -----------------------------------------------------------------------------
       
  6436 // Cisolationserver::Login with correct data
       
  6437 // Example test method function.
       
  6438 // (other items were commented in a header).
       
  6439 // -----------------------------------------------------------------------------
       
  6440 //
       
  6441 TInt Cisolationserver::MessageReceiveFromUser( CStifItemParser& aItem )
       
  6442     {
       
  6443 
       
  6444     	
       
  6445     ConnectData  *connect_data = NULL;
       
  6446     char smsg[MAX_MSG_SIZE];
       
  6447     char rmsg[MAX_MSG_SIZE];
       
  6448     int index=0;
       
  6449     int i=0;
       
  6450 	int msglen=0;	
       
  6451 	int timeout = 100;
       
  6452 	int nBytes;
       
  6453 
       
  6454     int result = 0;
       
  6455     int err = 0;
       
  6456     int status = 0;
       
  6457     FILE *fp ;
       
  6458     message_hdr_req *msgHdr = NULL;  
       
  6459     message_hdr_resp* msg_struct = NULL;
       
  6460     fp = fopen("c:\\receive_message_logs.txt","a");TInt return_value = 0;
       
  6461         	// Read data from the CFG file
       
  6462 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  6463 		{
       
  6464 		iLog->Log ( _L ( "read_data failed" ) );
       
  6465 		free_data ( connect_data );
       
  6466 		return_value = KErrGeneral;
       
  6467 		goto return_code;
       
  6468 		}
       
  6469 	//request formation	
       
  6470 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  6471 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6472 	
       
  6473 	//message header use
       
  6474 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  6475     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6476     
       
  6477     msgHdr->message_type = ELogin_Request;
       
  6478  
       
  6479     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6480     index += sizeof( message_hdr_req );
       
  6481     
       
  6482     int len = strlen(connect_data->username);
       
  6483     strcpy( smsg + index, connect_data->username );
       
  6484     index += len + 1;
       
  6485     
       
  6486     //appending password
       
  6487     
       
  6488     len = strlen(connect_data->password );
       
  6489     strcpy( smsg + index, connect_data->password );
       
  6490     index += len + 1;
       
  6491     
       
  6492     //appending server name
       
  6493     
       
  6494     len = strlen(connect_data->server );
       
  6495     strcpy( smsg + index, connect_data->server );
       
  6496     index += len + 1;
       
  6497     
       
  6498     //appending resource
       
  6499     len = strlen(connect_data->resource );
       
  6500     strcpy( smsg + index, connect_data->resource );
       
  6501     index += len + 1;
       
  6502     
       
  6503     //appending ssl
       
  6504     smsg[index++]= '1';
       
  6505     smsg[index++]= '\0';
       
  6506     
       
  6507     //appending server port
       
  6508     len = strlen(connect_data->port );
       
  6509     strcpy( smsg + index, connect_data->port );
       
  6510     index += len + 1;
       
  6511     
       
  6512     // appending IAP id
       
  6513     
       
  6514     smsg[index++]= '1';
       
  6515     smsg[index++]= '\0';
       
  6516     
       
  6517     //appending connmgr_bus
       
  6518     len = strlen(connect_data->connmgr_bus );
       
  6519     strcpy( smsg + index, connect_data->connmgr_bus );
       
  6520     index += len + 1;
       
  6521     
       
  6522     //appending connmgr_path
       
  6523     len = strlen(connect_data->connmgr_path );
       
  6524     strcpy( smsg + index, connect_data->connmgr_path );
       
  6525     index += len + 1;
       
  6526     
       
  6527     //appending protocol
       
  6528     len = strlen(connect_data->protocol );
       
  6529     strcpy( smsg + index, connect_data->protocol );
       
  6530     index += len + 1;
       
  6531     
       
  6532     #ifdef __WINSCW__
       
  6533     //proxy server
       
  6534     len = strlen(connect_data->proxy_data->proxy_server );
       
  6535     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  6536     index += len + 1;
       
  6537     
       
  6538     //proxy port
       
  6539     len = strlen(connect_data->proxy_data->proxy_port );
       
  6540     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  6541     index += len + 1;
       
  6542     
       
  6543     #endif
       
  6544     // running isoserver
       
  6545     run_isoserver();
       
  6546     
       
  6547         
       
  6548     //create message queue for send request
       
  6549     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6550     //create message queue for response request
       
  6551     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6552 		
       
  6553 	
       
  6554 	/* Send Message to queueOne */
       
  6555 	
       
  6556 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6557     
       
  6558     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  6559     
       
  6560     if (status < 0)
       
  6561     {
       
  6562     return_value = KErrGeneral;
       
  6563 	goto return_code;	
       
  6564     }
       
  6565     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  6566 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  6567 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  6568 	
       
  6569 	if( msg_struct->response != 1)
       
  6570     {
       
  6571     	return_value = KErrGeneral;
       
  6572 	goto return_code;
       
  6573     }
       
  6574     
       
  6575     //fetch req..
       
  6576     for (int i= 0 ;i<3 ;i++)
       
  6577     {
       
  6578         
       
  6579     fp = fopen("c:\\fetch_contact.txt","a");
       
  6580 	do  {
       
  6581 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  6582 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6583 		fwrite(rmsg,1,status,fp);
       
  6584 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6585 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  6586 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  6587 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  6588 	fclose(fp);	
       
  6589 	
       
  6590     }
       
  6591 
       
  6592 	//fetch end
       
  6593 	
       
  6594 	
       
  6595 	//send messge to our self--------------------------------------------
       
  6596    
       
  6597     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6598 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6599 	index=0;
       
  6600     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6601     msgHdr->message_type = ESend_Request;	
       
  6602     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6603 	index += sizeof( message_hdr_req );
       
  6604 	TBool ESend = EFalse , EReceive = EFalse;
       
  6605 	
       
  6606     // adding recipient
       
  6607     len = strlen(connect_data->msg_data->recipient );
       
  6608     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  6609     index += len + 1;
       
  6610     
       
  6611      // adding recipient
       
  6612     /*len = strlen(connect_data->msg_data->recipient );
       
  6613     strcpy( smsg + index, connect_data->msg_data->recipient );
       
  6614     index += len + 1;*/
       
  6615     
       
  6616     smsg[index++] = '\0';
       
  6617     
       
  6618     // adding message part
       
  6619      
       
  6620     len = strlen(connect_data->msg_data->message );
       
  6621     strcpy( smsg + index, connect_data->msg_data->message );
       
  6622     index += len + 1;
       
  6623      
       
  6624     
       
  6625     
       
  6626      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6627      do  {
       
  6628 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6629 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6630 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6631 	    if(msg_struct->hdr_req.message_type==ESend_Request)
       
  6632 	    ESend=ETrue;
       
  6633 	    if(msg_struct->hdr_req.message_type==EText_Message_Receive)
       
  6634 	    ESend=ETrue;
       
  6635 		} while (ESend/* == ETrue */&& EReceive/* ==ETrue*/) ;//(msg_struct->hdr_req.message_type!=ESend_Request);
       
  6636    
       
  6637  /*    if ( msg_struct->response != 1)
       
  6638     {
       
  6639     	return_value = KErrGeneral;
       
  6640 	goto return_code;
       
  6641     }    
       
  6642             
       
  6643     memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6644         //wait for message receive 
       
  6645     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  6646     if (status < 0)
       
  6647     {
       
  6648     return_value = KErrGeneral;
       
  6649 	goto return_code;	
       
  6650     }
       
  6651     fprintf( fp, "receive message %s\n", rmsg+24 ); 
       
  6652     
       
  6653     for ( i=24 ; i <rmsg[i]!='\0';i++)
       
  6654     msglen++;
       
  6655     fprintf( fp, "receive message %s\n", rmsg+24+msglen+1 ); 
       
  6656     */
       
  6657     
       
  6658     // login end
       
  6659     // logout test code from server
       
  6660     index=0;
       
  6661     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6662 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6663 	
       
  6664 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6665     
       
  6666     msgHdr->message_type = ELogout_Request;
       
  6667  
       
  6668     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6669     index += sizeof( message_hdr_req );
       
  6670 
       
  6671 	
       
  6672 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6673      do  {
       
  6674 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6675 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6676 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6677 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  6678    
       
  6679      if ( msg_struct->response != 1)
       
  6680     {
       
  6681     	return_value = KErrGeneral;
       
  6682 	goto return_code;
       
  6683     }
       
  6684     
       
  6685      //killing isoserver
       
  6686     return_code:
       
  6687     index=0;
       
  6688     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6689 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6690 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6691     msgHdr->message_type = EKill_Process;
       
  6692     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6693     index += sizeof( message_hdr_req );
       
  6694 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  6695     free( msg_struct );
       
  6696     return return_value;
       
  6697     
       
  6698     }
       
  6699 
       
  6700 
       
  6701 // -----------------------------------------------------------------------------
       
  6702 // Cisolationserver::add member message
       
  6703 // Example test method function.
       
  6704 // (other items were commented in a header).
       
  6705 // -----------------------------------------------------------------------------
       
  6706 //
       
  6707 TInt Cisolationserver::AddExistingContact( CStifItemParser& aItem )
       
  6708     {
       
  6709 
       
  6710     	
       
  6711    ConnectData  *connect_data = NULL;
       
  6712     char smsg[MAX_MSG_SIZE];
       
  6713     char rmsg[MAX_MSG_SIZE];
       
  6714     int index=0;
       
  6715     FILE *fp;
       
  6716 		
       
  6717 	int timeout = 200;
       
  6718 	int nBytes;
       
  6719 
       
  6720     int result = 0;
       
  6721     int err = 0;
       
  6722     int status = 0;
       
  6723     message_hdr_req *msgHdr = NULL;  
       
  6724     message_hdr_resp* msg_struct = NULL;
       
  6725     TInt return_value = 0;
       
  6726         	// Read data from the CFG file
       
  6727 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  6728 		{
       
  6729 		iLog->Log ( _L ( "read_data failed" ) );
       
  6730 		free_data ( connect_data );
       
  6731 		return_value = KErrGeneral;
       
  6732 		goto return_code;
       
  6733 		}
       
  6734 	//request formation	
       
  6735 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  6736 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6737 	
       
  6738 	//message header use
       
  6739 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  6740     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6741     
       
  6742     msgHdr->message_type = ELogin_Request;
       
  6743  
       
  6744     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6745     index += sizeof( message_hdr_req );
       
  6746     
       
  6747     int len = strlen(connect_data->username);
       
  6748     strcpy( smsg + index, connect_data->username );
       
  6749     index += len + 1;
       
  6750     
       
  6751     //appending password
       
  6752     
       
  6753     len = strlen(connect_data->password );
       
  6754     strcpy( smsg + index, connect_data->password );
       
  6755     index += len + 1;
       
  6756     
       
  6757     //appending server name
       
  6758     
       
  6759     len = strlen(connect_data->server );
       
  6760     strcpy( smsg + index, connect_data->server );
       
  6761     index += len + 1;
       
  6762     
       
  6763     //appending resource
       
  6764     len = strlen(connect_data->resource );
       
  6765     strcpy( smsg + index, connect_data->resource );
       
  6766     index += len + 1;
       
  6767     
       
  6768     //appending ssl
       
  6769     smsg[index++]= '1';
       
  6770     smsg[index++]= '\0';
       
  6771     
       
  6772     //appending server port
       
  6773     len = strlen(connect_data->port );
       
  6774     strcpy( smsg + index, connect_data->port );
       
  6775     index += len + 1;
       
  6776     
       
  6777     // appending IAP id
       
  6778     
       
  6779     smsg[index++]= '1';
       
  6780     smsg[index++]= '\0';
       
  6781     
       
  6782     //appending connmgr_bus
       
  6783     len = strlen(connect_data->connmgr_bus );
       
  6784     strcpy( smsg + index, connect_data->connmgr_bus );
       
  6785     index += len + 1;
       
  6786     
       
  6787     //appending connmgr_path
       
  6788     len = strlen(connect_data->connmgr_path );
       
  6789     strcpy( smsg + index, connect_data->connmgr_path );
       
  6790     index += len + 1;
       
  6791     
       
  6792     //appending protocol
       
  6793     len = strlen(connect_data->protocol );
       
  6794     strcpy( smsg + index, connect_data->protocol );
       
  6795     index += len + 1;
       
  6796     
       
  6797     #ifdef __WINSCW__
       
  6798     //proxy server
       
  6799     len = strlen(connect_data->proxy_data->proxy_server );
       
  6800     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  6801     index += len + 1;
       
  6802     
       
  6803     //proxy port
       
  6804     len = strlen(connect_data->proxy_data->proxy_port );
       
  6805     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  6806     index += len + 1;
       
  6807     
       
  6808     #endif
       
  6809     
       
  6810     //running isoserver   
       
  6811     run_isoserver(); 
       
  6812     
       
  6813         
       
  6814     //create message queue for send request
       
  6815     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6816     //create message queue for response request
       
  6817     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  6818 		
       
  6819 	
       
  6820 	/* Send Message to queueOne */
       
  6821 	
       
  6822 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6823     
       
  6824     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  6825     
       
  6826     if (status < 0)
       
  6827     {
       
  6828     return_value = KErrGeneral;
       
  6829 	goto return_code;	
       
  6830     }
       
  6831     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  6832 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  6833 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  6834 	
       
  6835 	if( msg_struct->response != 1)
       
  6836     {
       
  6837     	return_value = KErrGeneral;
       
  6838 	goto return_code;
       
  6839     }
       
  6840     
       
  6841     
       
  6842     // login end
       
  6843 
       
  6844      //fetch req..
       
  6845     for (int i= 0 ;i<3 ;i++)
       
  6846     {
       
  6847         
       
  6848     fp = fopen("c:\\fetch_contact.txt","a");
       
  6849 	do  {
       
  6850 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  6851 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6852 		fwrite(rmsg,1,status,fp);
       
  6853 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6854 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  6855 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  6856 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  6857 	fclose(fp);	
       
  6858 	
       
  6859     }
       
  6860 
       
  6861 	//fetch end
       
  6862 	
       
  6863 	
       
  6864     //adding contact --------------------------------------------
       
  6865    
       
  6866     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6867 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6868 	index=0;
       
  6869     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6870     msgHdr->message_type = EAdd_Contact_Request;	
       
  6871     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6872 	index += sizeof( message_hdr_req );
       
  6873 	// adding add contact
       
  6874     len = strlen(connect_data->contact );
       
  6875     strcpy( smsg + index, connect_data->contact );
       
  6876     index += len + 1;
       
  6877     smsg[index++]='\0';
       
  6878     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6879      do  {
       
  6880 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6881 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6882 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6883 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  6884    
       
  6885      if ( msg_struct->response != 1)
       
  6886     {
       
  6887     	return_value = KErrGeneral;
       
  6888 	goto return_code;
       
  6889     }
       
  6890     
       
  6891     //add contact end---------------------------------------
       
  6892     
       
  6893     
       
  6894    // logout test code from server
       
  6895     index=0;
       
  6896     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6897 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6898 	
       
  6899 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6900     
       
  6901     msgHdr->message_type = ELogout_Request;
       
  6902  
       
  6903     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6904     index += sizeof( message_hdr_req );
       
  6905 
       
  6906 	
       
  6907 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  6908      do  {
       
  6909 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  6910 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  6911 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6912 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  6913    
       
  6914      if ( msg_struct->response != 1)
       
  6915     {
       
  6916     	return_value = KErrGeneral;
       
  6917 	goto return_code;
       
  6918     }
       
  6919     //killing isoserver
       
  6920     return_code:
       
  6921     index=0;
       
  6922     memset( smsg, '\0', MAX_MSG_SIZE );
       
  6923 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6924 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6925     msgHdr->message_type = EKill_Process;
       
  6926     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6927     index += sizeof( message_hdr_req );
       
  6928 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  6929     free( msg_struct );
       
  6930     return return_value;
       
  6931     }
       
  6932 
       
  6933 // -----------------------------------------------------------------------------
       
  6934 // Cisolationserver::add member message
       
  6935 // Example test method function.
       
  6936 // (other items were commented in a header).
       
  6937 // -----------------------------------------------------------------------------
       
  6938 //
       
  6939 TInt Cisolationserver::AddUnexistingUserID( CStifItemParser& aItem )
       
  6940     {
       
  6941 
       
  6942     	
       
  6943    ConnectData  *connect_data = NULL;
       
  6944     char smsg[MAX_MSG_SIZE];
       
  6945     char rmsg[MAX_MSG_SIZE];
       
  6946     int index=0;
       
  6947     FILE *fp;
       
  6948 		
       
  6949 	int timeout = 200;
       
  6950 	int nBytes;
       
  6951 
       
  6952     int result = 0;
       
  6953     int err = 0;
       
  6954     int status = 0;
       
  6955     message_hdr_req *msgHdr = NULL;  
       
  6956     message_hdr_resp* msg_struct = NULL;
       
  6957     TInt return_value = 0;
       
  6958         	// Read data from the CFG file
       
  6959 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  6960 		{
       
  6961 		iLog->Log ( _L ( "read_data failed" ) );
       
  6962 		free_data ( connect_data );
       
  6963 		return_value = KErrGeneral;
       
  6964 		goto return_code;
       
  6965 		}
       
  6966 	//request formation	
       
  6967 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  6968 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  6969 	
       
  6970 	//message header use
       
  6971 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  6972     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  6973     
       
  6974     msgHdr->message_type = ELogin_Request;
       
  6975  
       
  6976     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  6977     index += sizeof( message_hdr_req );
       
  6978     
       
  6979     int len = strlen(connect_data->username);
       
  6980     strcpy( smsg + index, connect_data->username );
       
  6981     index += len + 1;
       
  6982     
       
  6983     //appending password
       
  6984     
       
  6985     len = strlen(connect_data->password );
       
  6986     strcpy( smsg + index, connect_data->password );
       
  6987     index += len + 1;
       
  6988     
       
  6989     //appending server name
       
  6990     
       
  6991     len = strlen(connect_data->server );
       
  6992     strcpy( smsg + index, connect_data->server );
       
  6993     index += len + 1;
       
  6994     
       
  6995     //appending resource
       
  6996     len = strlen(connect_data->resource );
       
  6997     strcpy( smsg + index, connect_data->resource );
       
  6998     index += len + 1;
       
  6999     
       
  7000     //appending ssl
       
  7001     smsg[index++]= '1';
       
  7002     smsg[index++]= '\0';
       
  7003     
       
  7004     //appending server port
       
  7005     len = strlen(connect_data->port );
       
  7006     strcpy( smsg + index, connect_data->port );
       
  7007     index += len + 1;
       
  7008     
       
  7009     // appending IAP id
       
  7010     
       
  7011     smsg[index++]= '1';
       
  7012     smsg[index++]= '\0';
       
  7013     
       
  7014     //appending connmgr_bus
       
  7015     len = strlen(connect_data->connmgr_bus );
       
  7016     strcpy( smsg + index, connect_data->connmgr_bus );
       
  7017     index += len + 1;
       
  7018     
       
  7019     //appending connmgr_path
       
  7020     len = strlen(connect_data->connmgr_path );
       
  7021     strcpy( smsg + index, connect_data->connmgr_path );
       
  7022     index += len + 1;
       
  7023     
       
  7024     //appending protocol
       
  7025     len = strlen(connect_data->protocol );
       
  7026     strcpy( smsg + index, connect_data->protocol );
       
  7027     index += len + 1;
       
  7028     
       
  7029     #ifdef __WINSCW__
       
  7030     //proxy server
       
  7031     len = strlen(connect_data->proxy_data->proxy_server );
       
  7032     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  7033     index += len + 1;
       
  7034     
       
  7035     //proxy port
       
  7036     len = strlen(connect_data->proxy_data->proxy_port );
       
  7037     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  7038     index += len + 1;
       
  7039     
       
  7040     #endif
       
  7041     
       
  7042     //running isoserver   
       
  7043     run_isoserver(); 
       
  7044     
       
  7045         
       
  7046     //create message queue for send request
       
  7047     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7048     //create message queue for response request
       
  7049     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7050 		
       
  7051 	
       
  7052 	/* Send Message to queueOne */
       
  7053 	
       
  7054 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7055     
       
  7056     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  7057     
       
  7058     if (status < 0)
       
  7059     {
       
  7060     return_value = KErrGeneral;
       
  7061 	goto return_code;	
       
  7062     }
       
  7063     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  7064 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  7065 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  7066 	
       
  7067 	if( msg_struct->response != 1)
       
  7068     {
       
  7069     	return_value = KErrGeneral;
       
  7070 	goto return_code;
       
  7071     }
       
  7072     
       
  7073     
       
  7074     // login end
       
  7075    //fetch req..
       
  7076     for (int i= 0 ;i<3 ;i++)
       
  7077     {
       
  7078         
       
  7079     fp = fopen("c:\\fetch_contact.txt","a");
       
  7080 	do  {
       
  7081 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  7082 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7083 		fwrite(rmsg,1,status,fp);
       
  7084 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7085 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  7086 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  7087 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  7088 	fclose(fp);	
       
  7089 	
       
  7090     }
       
  7091 
       
  7092 	//fetch end
       
  7093     //add contact --------------------------------------------
       
  7094    
       
  7095     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7096 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7097 	index=0;
       
  7098     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7099     msgHdr->message_type = EAdd_Contact_Request;	
       
  7100     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7101 	index += sizeof( message_hdr_req );
       
  7102 	// adding add contact
       
  7103     len = strlen(connect_data->contact );
       
  7104     strcpy( smsg + index, connect_data->contact );
       
  7105     index += len + 1;
       
  7106     smsg[index++] = '\0';
       
  7107     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7108      do  {
       
  7109 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7110 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7111 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7112 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  7113    
       
  7114      if ( msg_struct->response != 1)
       
  7115     {
       
  7116     	return_value = KErrGeneral;
       
  7117 	goto return_code;
       
  7118     }
       
  7119     
       
  7120     //add contact end---------------------------------------
       
  7121     
       
  7122     
       
  7123     // logout test code from server
       
  7124     index=0;
       
  7125     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7126 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7127 	
       
  7128 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7129     
       
  7130     msgHdr->message_type = ELogout_Request;
       
  7131  
       
  7132     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7133     index += sizeof( message_hdr_req );
       
  7134 
       
  7135 	
       
  7136 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7137      do  {
       
  7138 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7139 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7140 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7141 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  7142    
       
  7143      if ( msg_struct->response != 1)
       
  7144     {
       
  7145     	return_value = KErrGeneral;
       
  7146 	goto return_code;
       
  7147     }
       
  7148     //killing isoserver
       
  7149     return_code:
       
  7150     index=0;
       
  7151     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7152 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7153 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7154     msgHdr->message_type = EKill_Process;
       
  7155     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7156     index += sizeof( message_hdr_req );
       
  7157 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  7158     free( msg_struct );
       
  7159     return return_value;
       
  7160     }
       
  7161 
       
  7162 // -----------------------------------------------------------------------------
       
  7163 // Cisolationserver::add member message
       
  7164 // Example test method function.
       
  7165 // (other items were commented in a header).
       
  7166 // -----------------------------------------------------------------------------
       
  7167 //
       
  7168 TInt Cisolationserver::AddContactWhichIsAlreadyAdded( CStifItemParser& aItem )
       
  7169     {
       
  7170 
       
  7171     	
       
  7172    ConnectData  *connect_data = NULL;
       
  7173     char smsg[MAX_MSG_SIZE];
       
  7174     char rmsg[MAX_MSG_SIZE];
       
  7175     int index=0;
       
  7176     FILE *fp;
       
  7177 		
       
  7178 	int timeout = 200;
       
  7179 	int nBytes;
       
  7180 
       
  7181     int result = 0;
       
  7182     int err = 0;
       
  7183     int status = 0;
       
  7184     message_hdr_req *msgHdr = NULL;  
       
  7185     message_hdr_resp* msg_struct = NULL;
       
  7186     TInt return_value = 0;
       
  7187         	// Read data from the CFG file
       
  7188 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  7189 		{
       
  7190 		iLog->Log ( _L ( "read_data failed" ) );
       
  7191 		free_data ( connect_data );
       
  7192 		return_value = KErrGeneral;
       
  7193 		goto return_code;
       
  7194 		}
       
  7195 	//request formation	
       
  7196 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  7197 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7198 	
       
  7199 	//message header use
       
  7200 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  7201     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7202     
       
  7203     msgHdr->message_type = ELogin_Request;
       
  7204  
       
  7205     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7206     index += sizeof( message_hdr_req );
       
  7207     
       
  7208     int len = strlen(connect_data->username);
       
  7209     strcpy( smsg + index, connect_data->username );
       
  7210     index += len + 1;
       
  7211     
       
  7212     //appending password
       
  7213     
       
  7214     len = strlen(connect_data->password );
       
  7215     strcpy( smsg + index, connect_data->password );
       
  7216     index += len + 1;
       
  7217     
       
  7218     //appending server name
       
  7219     
       
  7220     len = strlen(connect_data->server );
       
  7221     strcpy( smsg + index, connect_data->server );
       
  7222     index += len + 1;
       
  7223     
       
  7224     //appending resource
       
  7225     len = strlen(connect_data->resource );
       
  7226     strcpy( smsg + index, connect_data->resource );
       
  7227     index += len + 1;
       
  7228     
       
  7229     //appending ssl
       
  7230     smsg[index++]= '1';
       
  7231     smsg[index++]= '\0';
       
  7232     
       
  7233     //appending server port
       
  7234     len = strlen(connect_data->port );
       
  7235     strcpy( smsg + index, connect_data->port );
       
  7236     index += len + 1;
       
  7237     
       
  7238     // appending IAP id
       
  7239     
       
  7240     smsg[index++]= '1';
       
  7241     smsg[index++]= '\0';
       
  7242     
       
  7243     //appending connmgr_bus
       
  7244     len = strlen(connect_data->connmgr_bus );
       
  7245     strcpy( smsg + index, connect_data->connmgr_bus );
       
  7246     index += len + 1;
       
  7247     
       
  7248     //appending connmgr_path
       
  7249     len = strlen(connect_data->connmgr_path );
       
  7250     strcpy( smsg + index, connect_data->connmgr_path );
       
  7251     index += len + 1;
       
  7252     
       
  7253     //appending protocol
       
  7254     len = strlen(connect_data->protocol );
       
  7255     strcpy( smsg + index, connect_data->protocol );
       
  7256     index += len + 1;
       
  7257     
       
  7258     #ifdef __WINSCW__
       
  7259     //proxy server
       
  7260     len = strlen(connect_data->proxy_data->proxy_server );
       
  7261     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  7262     index += len + 1;
       
  7263     
       
  7264     //proxy port
       
  7265     len = strlen(connect_data->proxy_data->proxy_port );
       
  7266     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  7267     index += len + 1;
       
  7268     
       
  7269     #endif
       
  7270     
       
  7271     //running isoserver   
       
  7272     run_isoserver(); 
       
  7273     
       
  7274         
       
  7275     //create message queue for send request
       
  7276     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7277     //create message queue for response request
       
  7278     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7279 		
       
  7280 	
       
  7281 	/* Send Message to queueOne */
       
  7282 	
       
  7283 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7284     
       
  7285     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  7286     
       
  7287     if (status < 0)
       
  7288     {
       
  7289     return_value = KErrGeneral;
       
  7290 	goto return_code;	
       
  7291     }
       
  7292     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  7293 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  7294 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  7295 	
       
  7296 	if( msg_struct->response != 1)
       
  7297     {
       
  7298     	return_value = KErrGeneral;
       
  7299 	goto return_code;
       
  7300     }
       
  7301     
       
  7302     
       
  7303     // login end
       
  7304     //fetch req..
       
  7305     for (int i= 0 ;i<3 ;i++)
       
  7306     {
       
  7307         
       
  7308     fp = fopen("c:\\fetch_contact.txt","a");
       
  7309 	do  {
       
  7310 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  7311 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7312 		fwrite(rmsg,1,status,fp);
       
  7313 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7314 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  7315 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  7316 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  7317 	fclose(fp);	
       
  7318 	
       
  7319     }
       
  7320 
       
  7321 	//fetch end
       
  7322     //add member  1 st time--------------------------------------------
       
  7323    
       
  7324     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7325 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7326 	index=0;
       
  7327     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7328     msgHdr->message_type = EAdd_Contact_Request;	
       
  7329     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7330 	index += sizeof( message_hdr_req );
       
  7331 	
       
  7332 	
       
  7333     // adding add contact
       
  7334     len = strlen(connect_data->contact );
       
  7335     strcpy( smsg + index, connect_data->contact );
       
  7336     index += len + 1;
       
  7337     
       
  7338      
       
  7339     
       
  7340      
       
  7341        
       
  7342     
       
  7343     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7344      do  {
       
  7345 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7346 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7347 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7348 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  7349    
       
  7350      if ( msg_struct->response != 1)
       
  7351     {
       
  7352     	return_value = KErrGeneral;
       
  7353 	goto return_code;
       
  7354     }
       
  7355     
       
  7356     //add contact end---------------------------------------
       
  7357     
       
  7358      //add member  2 nd time--------------------------------------------
       
  7359    
       
  7360     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7361 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7362 	index=0;
       
  7363     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7364     msgHdr->message_type = EAdd_Contact_Request;	
       
  7365     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7366 	index += sizeof( message_hdr_req );
       
  7367 	
       
  7368 	
       
  7369     // adding add contact
       
  7370     len = strlen(connect_data->contact );
       
  7371     strcpy( smsg + index, connect_data->contact );
       
  7372     index += len + 1;
       
  7373     
       
  7374     
       
  7375     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7376      do  {
       
  7377 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7378 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7379 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7380 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  7381    
       
  7382      if ( msg_struct->response != 1)
       
  7383     {
       
  7384     	return_value = KErrGeneral;
       
  7385 	goto return_code;
       
  7386     }
       
  7387     
       
  7388     //add contact end---------------------------------------
       
  7389     
       
  7390 
       
  7391     // logout test code from server
       
  7392     index=0;
       
  7393     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7394 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7395 	
       
  7396 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7397     
       
  7398     msgHdr->message_type = ELogout_Request;
       
  7399  
       
  7400     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7401     index += sizeof( message_hdr_req );
       
  7402 
       
  7403 	
       
  7404 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7405      do  {
       
  7406 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7407 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7408 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7409 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  7410    
       
  7411      if ( msg_struct->response != 1)
       
  7412     {
       
  7413     	return_value = KErrGeneral;
       
  7414 	goto return_code;
       
  7415     }
       
  7416     //killing isoserver
       
  7417     return_code:
       
  7418     index=0;
       
  7419     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7420 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7421 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7422     msgHdr->message_type = EKill_Process;
       
  7423     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7424     index += sizeof( message_hdr_req );
       
  7425 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  7426     free( msg_struct );
       
  7427     return return_value;
       
  7428     }
       
  7429 
       
  7430 
       
  7431   // -----------------------------------------------------------------------------
       
  7432 // Cisolationserver::add member message
       
  7433 // Example test method function.
       
  7434 // (other items were commented in a header).
       
  7435 // -----------------------------------------------------------------------------
       
  7436 //
       
  7437 TInt Cisolationserver::ClientSendBlankUserIdForADD( CStifItemParser& aItem )
       
  7438     {
       
  7439 
       
  7440     	
       
  7441    ConnectData  *connect_data = NULL;
       
  7442     char smsg[MAX_MSG_SIZE];
       
  7443     char rmsg[MAX_MSG_SIZE];
       
  7444     int index=0;
       
  7445     FILE *fp;
       
  7446 		
       
  7447 	int timeout = 200;
       
  7448 	int nBytes;
       
  7449 
       
  7450     int result = 0;
       
  7451     int err = 0;
       
  7452     int status = 0;
       
  7453     message_hdr_req *msgHdr = NULL;  
       
  7454     message_hdr_resp* msg_struct = NULL;
       
  7455      TInt return_value = 0;
       
  7456         	// Read data from the CFG file
       
  7457 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  7458 		{
       
  7459 		iLog->Log ( _L ( "read_data failed" ) );
       
  7460 		free_data ( connect_data );
       
  7461 		return_value = KErrGeneral;
       
  7462 		goto return_code;
       
  7463 		}
       
  7464 	//request formation	
       
  7465 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  7466 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7467 	
       
  7468 	//message header use
       
  7469 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  7470     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7471     
       
  7472     msgHdr->message_type = ELogin_Request;
       
  7473  
       
  7474     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7475     index += sizeof( message_hdr_req );
       
  7476     
       
  7477     int len = strlen(connect_data->username);
       
  7478     strcpy( smsg + index, connect_data->username );
       
  7479     index += len + 1;
       
  7480     
       
  7481     //appending password
       
  7482     
       
  7483     len = strlen(connect_data->password );
       
  7484     strcpy( smsg + index, connect_data->password );
       
  7485     index += len + 1;
       
  7486     
       
  7487     //appending server name
       
  7488     
       
  7489     len = strlen(connect_data->server );
       
  7490     strcpy( smsg + index, connect_data->server );
       
  7491     index += len + 1;
       
  7492     
       
  7493     //appending resource
       
  7494     len = strlen(connect_data->resource );
       
  7495     strcpy( smsg + index, connect_data->resource );
       
  7496     index += len + 1;
       
  7497     
       
  7498     //appending ssl
       
  7499     smsg[index++]= '1';
       
  7500     smsg[index++]= '\0';
       
  7501     
       
  7502     //appending server port
       
  7503     len = strlen(connect_data->port );
       
  7504     strcpy( smsg + index, connect_data->port );
       
  7505     index += len + 1;
       
  7506     
       
  7507     // appending IAP id
       
  7508     
       
  7509     smsg[index++]= '1';
       
  7510     smsg[index++]= '\0';
       
  7511     
       
  7512     //appending connmgr_bus
       
  7513     len = strlen(connect_data->connmgr_bus );
       
  7514     strcpy( smsg + index, connect_data->connmgr_bus );
       
  7515     index += len + 1;
       
  7516     
       
  7517     //appending connmgr_path
       
  7518     len = strlen(connect_data->connmgr_path );
       
  7519     strcpy( smsg + index, connect_data->connmgr_path );
       
  7520     index += len + 1;
       
  7521     
       
  7522     //appending protocol
       
  7523     len = strlen(connect_data->protocol );
       
  7524     strcpy( smsg + index, connect_data->protocol );
       
  7525     index += len + 1;
       
  7526     
       
  7527     #ifdef __WINSCW__
       
  7528     //proxy server
       
  7529     len = strlen(connect_data->proxy_data->proxy_server );
       
  7530     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  7531     index += len + 1;
       
  7532     
       
  7533     //proxy port
       
  7534     len = strlen(connect_data->proxy_data->proxy_port );
       
  7535     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  7536     index += len + 1;
       
  7537     
       
  7538     #endif
       
  7539     //running isoserver   
       
  7540     run_isoserver(); 
       
  7541     
       
  7542     
       
  7543         
       
  7544     //create message queue for send request
       
  7545     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7546     //create message queue for response request
       
  7547     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7548 		
       
  7549 	
       
  7550 	/* Send Message to queueOne */
       
  7551 	
       
  7552 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7553     
       
  7554     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  7555     
       
  7556     if (status < 0)
       
  7557     {
       
  7558     return_value = KErrGeneral;
       
  7559 	goto return_code;	
       
  7560     }
       
  7561     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  7562 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  7563 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  7564 	
       
  7565 	if( msg_struct->response != 1)
       
  7566     {
       
  7567     return_value = KErrGeneral;
       
  7568 	goto return_code;
       
  7569     }
       
  7570     
       
  7571     
       
  7572     // login end
       
  7573 
       
  7574     //fetch req..
       
  7575     for (int i= 0 ;i<3 ;i++)
       
  7576     {
       
  7577         
       
  7578     fp = fopen("c:\\fetch_contact.txt","a");
       
  7579 	do  {
       
  7580 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  7581 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7582 		fwrite(rmsg,1,status,fp);
       
  7583 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7584 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  7585 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  7586 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  7587 	fclose(fp);	
       
  7588 	
       
  7589     }
       
  7590 
       
  7591 	//fetch end
       
  7592     //add contact --------------------------------------------
       
  7593    
       
  7594     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7595 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7596 	index=0;
       
  7597     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7598     msgHdr->message_type = EAdd_Contact_Request;	
       
  7599     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7600 	index += sizeof( message_hdr_req );
       
  7601 	
       
  7602 	
       
  7603     smsg[index++]='\0';
       
  7604     //client is sending blank user id
       
  7605     smsg[index++]='\0';
       
  7606     
       
  7607      
       
  7608        
       
  7609     
       
  7610     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7611      do  {
       
  7612 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7613 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7614 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7615 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  7616    
       
  7617      if( msg_struct->error_type >0)
       
  7618     {
       
  7619     return_value = KErrGeneral;
       
  7620 	goto return_code;
       
  7621     }
       
  7622     
       
  7623     //add contact end---------------------------------------
       
  7624     
       
  7625     
       
  7626    // logout test code from server
       
  7627     index=0;
       
  7628     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7629 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7630 	
       
  7631 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7632     
       
  7633     msgHdr->message_type = ELogout_Request;
       
  7634  
       
  7635     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7636     index += sizeof( message_hdr_req );
       
  7637 
       
  7638 	
       
  7639 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7640      do  {
       
  7641 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7642 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7643 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7644 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  7645    
       
  7646    if( msg_struct->response != 1)
       
  7647     {
       
  7648     return_value = KErrGeneral;
       
  7649 	goto return_code;
       
  7650     }
       
  7651     //killing isoserver
       
  7652     return_code:
       
  7653     index=0;
       
  7654     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7655 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7656 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7657     msgHdr->message_type = EKill_Process;
       
  7658     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7659     index += sizeof( message_hdr_req );
       
  7660 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  7661     free( msg_struct );
       
  7662     return return_value;
       
  7663     }
       
  7664 
       
  7665 // -----------------------------------------------------------------------------
       
  7666 // Cisolationserver::add member message
       
  7667 // Example test method function.
       
  7668 // (other items were commented in a header).
       
  7669 // -----------------------------------------------------------------------------
       
  7670 //
       
  7671 TInt Cisolationserver::AddExistingContactWIthSpace( CStifItemParser& aItem )
       
  7672     {
       
  7673 
       
  7674     	
       
  7675    ConnectData  *connect_data = NULL;
       
  7676     char smsg[MAX_MSG_SIZE];
       
  7677     char rmsg[MAX_MSG_SIZE];
       
  7678     int index=0;
       
  7679     FILE *fp;
       
  7680 		
       
  7681 	int timeout = 200;
       
  7682 	int nBytes;
       
  7683 
       
  7684     int result = 0;
       
  7685     int err = 0;
       
  7686     int status = 0;
       
  7687     message_hdr_req *msgHdr = NULL;  
       
  7688     message_hdr_resp* msg_struct = NULL;
       
  7689     TInt return_value = 0;
       
  7690         	// Read data from the CFG file
       
  7691 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  7692 		{
       
  7693 		iLog->Log ( _L ( "read_data failed" ) );
       
  7694 		free_data ( connect_data );
       
  7695 		return_value = KErrGeneral;
       
  7696 		goto return_code;
       
  7697 		}
       
  7698 	//request formation	
       
  7699 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  7700 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7701 	
       
  7702 	//message header use
       
  7703 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  7704     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7705     
       
  7706     msgHdr->message_type = ELogin_Request;
       
  7707  
       
  7708     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7709     index += sizeof( message_hdr_req );
       
  7710     
       
  7711     int len = strlen(connect_data->username);
       
  7712     strcpy( smsg + index, connect_data->username );
       
  7713     index += len + 1;
       
  7714     
       
  7715     //appending password
       
  7716     
       
  7717     len = strlen(connect_data->password );
       
  7718     strcpy( smsg + index, connect_data->password );
       
  7719     index += len + 1;
       
  7720     
       
  7721     //appending server name
       
  7722     
       
  7723     len = strlen(connect_data->server );
       
  7724     strcpy( smsg + index, connect_data->server );
       
  7725     index += len + 1;
       
  7726     
       
  7727     //appending resource
       
  7728     len = strlen(connect_data->resource );
       
  7729     strcpy( smsg + index, connect_data->resource );
       
  7730     index += len + 1;
       
  7731     
       
  7732     //appending ssl
       
  7733     smsg[index++]= '1';
       
  7734     smsg[index++]= '\0';
       
  7735     
       
  7736     //appending server port
       
  7737     len = strlen(connect_data->port );
       
  7738     strcpy( smsg + index, connect_data->port );
       
  7739     index += len + 1;
       
  7740     
       
  7741     // appending IAP id
       
  7742     
       
  7743     smsg[index++]= '1';
       
  7744     smsg[index++]= '\0';
       
  7745     
       
  7746     //appending connmgr_bus
       
  7747     len = strlen(connect_data->connmgr_bus );
       
  7748     strcpy( smsg + index, connect_data->connmgr_bus );
       
  7749     index += len + 1;
       
  7750     
       
  7751     //appending connmgr_path
       
  7752     len = strlen(connect_data->connmgr_path );
       
  7753     strcpy( smsg + index, connect_data->connmgr_path );
       
  7754     index += len + 1;
       
  7755     
       
  7756     //appending protocol
       
  7757     len = strlen(connect_data->protocol );
       
  7758     strcpy( smsg + index, connect_data->protocol );
       
  7759     index += len + 1;
       
  7760     
       
  7761     #ifdef __WINSCW__
       
  7762     //proxy server
       
  7763     len = strlen(connect_data->proxy_data->proxy_server );
       
  7764     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  7765     index += len + 1;
       
  7766     
       
  7767     //proxy port
       
  7768     len = strlen(connect_data->proxy_data->proxy_port );
       
  7769     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  7770     index += len + 1;
       
  7771     
       
  7772     #endif
       
  7773     
       
  7774     //running isoserver   
       
  7775     run_isoserver(); 
       
  7776     
       
  7777         
       
  7778     //create message queue for send request
       
  7779     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7780     //create message queue for response request
       
  7781     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  7782 		
       
  7783 	
       
  7784 	/* Send Message to queueOne */
       
  7785 	
       
  7786 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7787     
       
  7788     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  7789     
       
  7790     if (status < 0)
       
  7791     {
       
  7792     return_value = KErrGeneral;
       
  7793 	goto return_code;	
       
  7794     }
       
  7795     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  7796 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  7797 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  7798 	
       
  7799 	if( msg_struct->response != 1)
       
  7800     {
       
  7801     	return_value = KErrGeneral;
       
  7802 	goto return_code;
       
  7803     }
       
  7804     
       
  7805     
       
  7806     // login end
       
  7807 
       
  7808     //fetch req..
       
  7809     for (int i= 0 ;i<3 ;i++)
       
  7810     {
       
  7811         
       
  7812     fp = fopen("c:\\fetch_contact.txt","a");
       
  7813 	do  {
       
  7814 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  7815 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7816 		fwrite(rmsg,1,status,fp);
       
  7817 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7818 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  7819 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  7820 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  7821 	fclose(fp);	
       
  7822 	
       
  7823     }
       
  7824 
       
  7825 	//fetch end
       
  7826 	
       
  7827     //send messge--------------------------------------------
       
  7828    
       
  7829     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7830 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7831 	index=0;
       
  7832     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7833     msgHdr->message_type = EAdd_Contact_Request;	
       
  7834     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7835 	index += sizeof( message_hdr_req );
       
  7836 	
       
  7837 	
       
  7838     // adding add contact
       
  7839     len = strlen(connect_data->contact );
       
  7840     strcpy( smsg + index, connect_data->contact );
       
  7841     index += len + 1;
       
  7842     smsg[index++]=' ';
       
  7843     
       
  7844     smsg[index++]= '\0'; 
       
  7845     
       
  7846      
       
  7847     
       
  7848      
       
  7849        
       
  7850     
       
  7851     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7852      do  {
       
  7853 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7854 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7855 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7856 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  7857    
       
  7858      if( msg_struct->response != 0)
       
  7859     {
       
  7860     	return_value = KErrGeneral;
       
  7861 	goto return_code;
       
  7862     }
       
  7863     //add contact end---------------------------------------
       
  7864     
       
  7865     
       
  7866    // logout test code from server
       
  7867     index=0;
       
  7868     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7869 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7870 	
       
  7871 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7872     
       
  7873     msgHdr->message_type = ELogout_Request;
       
  7874  
       
  7875     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7876     index += sizeof( message_hdr_req );
       
  7877 
       
  7878 	
       
  7879 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  7880      do  {
       
  7881 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  7882 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  7883 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7884 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  7885    
       
  7886      if ( msg_struct->response != 1)
       
  7887     {
       
  7888     	return_value = KErrGeneral;
       
  7889 	goto return_code;
       
  7890     }
       
  7891     //killing isoserver
       
  7892     return_code:
       
  7893     index=0;
       
  7894     memset( smsg, '\0', MAX_MSG_SIZE );
       
  7895 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7896 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7897     msgHdr->message_type = EKill_Process;
       
  7898     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7899     index += sizeof( message_hdr_req );
       
  7900 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  7901     free( msg_struct );
       
  7902     return return_value;
       
  7903     }
       
  7904 
       
  7905 // -----------------------------------------------------------------------------
       
  7906 // Cisolationserver::add member message
       
  7907 // Example test method function.
       
  7908 // (other items were commented in a header).
       
  7909 // -----------------------------------------------------------------------------
       
  7910 //
       
  7911 TInt Cisolationserver::AddExistingContactWIthMixedLetter( CStifItemParser& aItem )
       
  7912     {
       
  7913 
       
  7914     	
       
  7915    ConnectData  *connect_data = NULL;
       
  7916     char smsg[MAX_MSG_SIZE];
       
  7917     char rmsg[MAX_MSG_SIZE];
       
  7918     int index=0;
       
  7919     FILE *fp;
       
  7920 		
       
  7921 	int timeout = 200;
       
  7922 	int nBytes;
       
  7923 
       
  7924     int result = 0;
       
  7925     int err = 0;
       
  7926     int status = 0;
       
  7927     message_hdr_req *msgHdr = NULL;  
       
  7928     message_hdr_resp* msg_struct = NULL;
       
  7929     TInt return_value = 0;
       
  7930         	// Read data from the CFG file
       
  7931 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  7932 		{
       
  7933 		iLog->Log ( _L ( "read_data failed" ) );
       
  7934 		free_data ( connect_data );
       
  7935 		return_value = KErrGeneral;
       
  7936 		goto return_code;
       
  7937 		}
       
  7938 	//request formation	
       
  7939 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  7940 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  7941 	
       
  7942 	//message header use
       
  7943 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  7944     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  7945     
       
  7946     msgHdr->message_type = ELogin_Request;
       
  7947  
       
  7948     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  7949     index += sizeof( message_hdr_req );
       
  7950     
       
  7951     int len = strlen(connect_data->username);
       
  7952     strcpy( smsg + index, connect_data->username );
       
  7953     index += len + 1;
       
  7954     
       
  7955     //appending password
       
  7956     
       
  7957     len = strlen(connect_data->password );
       
  7958     strcpy( smsg + index, connect_data->password );
       
  7959     index += len + 1;
       
  7960     
       
  7961     //appending server name
       
  7962     
       
  7963     len = strlen(connect_data->server );
       
  7964     strcpy( smsg + index, connect_data->server );
       
  7965     index += len + 1;
       
  7966     
       
  7967     //appending resource
       
  7968     len = strlen(connect_data->resource );
       
  7969     strcpy( smsg + index, connect_data->resource );
       
  7970     index += len + 1;
       
  7971     
       
  7972     //appending ssl
       
  7973     smsg[index++]= '1';
       
  7974     smsg[index++]= '\0';
       
  7975     
       
  7976     //appending server port
       
  7977     len = strlen(connect_data->port );
       
  7978     strcpy( smsg + index, connect_data->port );
       
  7979     index += len + 1;
       
  7980     
       
  7981     // appending IAP id
       
  7982     
       
  7983     smsg[index++]= '1';
       
  7984     smsg[index++]= '\0';
       
  7985     
       
  7986     //appending connmgr_bus
       
  7987     len = strlen(connect_data->connmgr_bus );
       
  7988     strcpy( smsg + index, connect_data->connmgr_bus );
       
  7989     index += len + 1;
       
  7990     
       
  7991     //appending connmgr_path
       
  7992     len = strlen(connect_data->connmgr_path );
       
  7993     strcpy( smsg + index, connect_data->connmgr_path );
       
  7994     index += len + 1;
       
  7995     
       
  7996     //appending protocol
       
  7997     len = strlen(connect_data->protocol );
       
  7998     strcpy( smsg + index, connect_data->protocol );
       
  7999     index += len + 1;
       
  8000     
       
  8001     #ifdef __WINSCW__
       
  8002     //proxy server
       
  8003     len = strlen(connect_data->proxy_data->proxy_server );
       
  8004     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  8005     index += len + 1;
       
  8006     
       
  8007     //proxy port
       
  8008     len = strlen(connect_data->proxy_data->proxy_port );
       
  8009     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  8010     index += len + 1;
       
  8011     
       
  8012     #endif
       
  8013     
       
  8014     //running isoserver   
       
  8015     run_isoserver(); 
       
  8016     
       
  8017         
       
  8018     //create message queue for send request
       
  8019     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8020     //create message queue for response request
       
  8021     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8022 		
       
  8023 	
       
  8024 	/* Send Message to queueOne */
       
  8025 	
       
  8026 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8027     
       
  8028     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  8029     
       
  8030     if (status < 0)
       
  8031     {
       
  8032     return_value = KErrGeneral;
       
  8033 	goto return_code;	
       
  8034     }
       
  8035     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  8036 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  8037 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  8038 	
       
  8039 	if( msg_struct->response != 1)
       
  8040     {
       
  8041     	return_value = KErrGeneral;
       
  8042 	goto return_code;
       
  8043     }
       
  8044     
       
  8045     
       
  8046     // login end
       
  8047     //fetch req..
       
  8048     for (int i= 0 ;i<3 ;i++)
       
  8049     {
       
  8050         
       
  8051     fp = fopen("c:\\fetch_contact.txt","a");
       
  8052 	do  {
       
  8053 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  8054 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8055 		fwrite(rmsg,1,status,fp);
       
  8056 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8057 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  8058 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  8059 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  8060 	fclose(fp);	
       
  8061 	
       
  8062     }
       
  8063 
       
  8064 	//fetch end
       
  8065      
       
  8066     //send messge--------------------------------------------
       
  8067    
       
  8068     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8069 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8070 	index=0;
       
  8071     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8072     msgHdr->message_type = EAdd_Contact_Request;	
       
  8073     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8074 	index += sizeof( message_hdr_req );
       
  8075 	
       
  8076 	
       
  8077     // adding add contact
       
  8078     len = strlen(connect_data->contact );
       
  8079     strcpy( smsg + index, connect_data->contact );
       
  8080     index += len + 1;
       
  8081     smsg[index++]='\0';
       
  8082      
       
  8083     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8084      do  {
       
  8085 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8086 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8087 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8088 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  8089    
       
  8090      if ( msg_struct->response != 1)
       
  8091     {
       
  8092     	return_value = KErrGeneral;
       
  8093 	goto return_code;
       
  8094     }
       
  8095     
       
  8096     //add contact end---------------------------------------
       
  8097     
       
  8098     
       
  8099    // logout test code from server
       
  8100     index=0;
       
  8101     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8102 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8103 	
       
  8104 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8105     
       
  8106     msgHdr->message_type = ELogout_Request;
       
  8107  
       
  8108     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8109     index += sizeof( message_hdr_req );
       
  8110 
       
  8111 	
       
  8112 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8113      do  {
       
  8114 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8115 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8116 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8117 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  8118    
       
  8119      if ( msg_struct->response != 1)
       
  8120     {
       
  8121     	return_value = KErrGeneral;
       
  8122 	goto return_code;
       
  8123     }
       
  8124     //killing isoserver
       
  8125     return_code:
       
  8126     index=0;
       
  8127     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8128 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8129 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8130     msgHdr->message_type = EKill_Process;
       
  8131     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8132     index += sizeof( message_hdr_req );
       
  8133 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  8134     free( msg_struct );
       
  8135     return return_value;
       
  8136     }
       
  8137 
       
  8138   // -----------------------------------------------------------------------------
       
  8139 // Cisolationserver::add member message
       
  8140 // Example test method function.
       
  8141 // (other items were commented in a header).
       
  8142 // -----------------------------------------------------------------------------
       
  8143 //
       
  8144 TInt Cisolationserver::AddInvalidContactWIthSpecialLetter( CStifItemParser& aItem )
       
  8145     {
       
  8146 
       
  8147     	
       
  8148    ConnectData  *connect_data = NULL;
       
  8149     char smsg[MAX_MSG_SIZE];
       
  8150     char rmsg[MAX_MSG_SIZE];
       
  8151     int index=0;
       
  8152     FILE *fp;
       
  8153 		
       
  8154 	int timeout = 200;
       
  8155 	int nBytes;
       
  8156 
       
  8157     int result = 0;
       
  8158     int err = 0;
       
  8159     int status = 0;
       
  8160     message_hdr_req *msgHdr = NULL;  
       
  8161     message_hdr_resp* msg_struct = NULL;
       
  8162     TInt return_value = 0;
       
  8163         	// Read data from the CFG file
       
  8164 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  8165 		{
       
  8166 		iLog->Log ( _L ( "read_data failed" ) );
       
  8167 		free_data ( connect_data );
       
  8168 		return_value = KErrGeneral;
       
  8169 		goto return_code;
       
  8170 		}
       
  8171 	//request formation	
       
  8172 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  8173 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8174 	
       
  8175 	//message header use
       
  8176 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  8177     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8178     
       
  8179     msgHdr->message_type = ELogin_Request;
       
  8180  
       
  8181     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8182     index += sizeof( message_hdr_req );
       
  8183     
       
  8184     int len = strlen(connect_data->username);
       
  8185     strcpy( smsg + index, connect_data->username );
       
  8186     index += len + 1;
       
  8187     
       
  8188     //appending password
       
  8189     
       
  8190     len = strlen(connect_data->password );
       
  8191     strcpy( smsg + index, connect_data->password );
       
  8192     index += len + 1;
       
  8193     
       
  8194     //appending server name
       
  8195     
       
  8196     len = strlen(connect_data->server );
       
  8197     strcpy( smsg + index, connect_data->server );
       
  8198     index += len + 1;
       
  8199     
       
  8200     //appending resource
       
  8201     len = strlen(connect_data->resource );
       
  8202     strcpy( smsg + index, connect_data->resource );
       
  8203     index += len + 1;
       
  8204     
       
  8205     //appending ssl
       
  8206     smsg[index++]= '1';
       
  8207     smsg[index++]= '\0';
       
  8208     
       
  8209     //appending server port
       
  8210     len = strlen(connect_data->port );
       
  8211     strcpy( smsg + index, connect_data->port );
       
  8212     index += len + 1;
       
  8213     
       
  8214     // appending IAP id
       
  8215     
       
  8216     smsg[index++]= '1';
       
  8217     smsg[index++]= '\0';
       
  8218     
       
  8219     //appending connmgr_bus
       
  8220     len = strlen(connect_data->connmgr_bus );
       
  8221     strcpy( smsg + index, connect_data->connmgr_bus );
       
  8222     index += len + 1;
       
  8223     
       
  8224     //appending connmgr_path
       
  8225     len = strlen(connect_data->connmgr_path );
       
  8226     strcpy( smsg + index, connect_data->connmgr_path );
       
  8227     index += len + 1;
       
  8228     
       
  8229     //appending protocol
       
  8230     len = strlen(connect_data->protocol );
       
  8231     strcpy( smsg + index, connect_data->protocol );
       
  8232     index += len + 1;
       
  8233     
       
  8234     #ifdef __WINSCW__
       
  8235     //proxy server
       
  8236     len = strlen(connect_data->proxy_data->proxy_server );
       
  8237     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  8238     index += len + 1;
       
  8239     
       
  8240     //proxy port
       
  8241     len = strlen(connect_data->proxy_data->proxy_port );
       
  8242     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  8243     index += len + 1;
       
  8244     
       
  8245     #endif
       
  8246     
       
  8247     //running isoserver   
       
  8248     run_isoserver(); 
       
  8249     
       
  8250         
       
  8251     //create message queue for send request
       
  8252     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8253     //create message queue for response request
       
  8254     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8255 		
       
  8256 	
       
  8257 	/* Send Message to queueOne */
       
  8258 	
       
  8259 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8260     
       
  8261     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  8262     
       
  8263     if (status < 0)
       
  8264     {
       
  8265     return_value = KErrGeneral;
       
  8266 	goto return_code;	
       
  8267     }
       
  8268     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  8269 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  8270 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  8271 	
       
  8272 	if( msg_struct->response != 1)
       
  8273     {
       
  8274     	return_value = KErrGeneral;
       
  8275 	goto return_code;
       
  8276     }
       
  8277     
       
  8278     
       
  8279     // login end
       
  8280 
       
  8281    //fetch req..
       
  8282     for (int i= 0 ;i<3 ;i++)
       
  8283     {
       
  8284         
       
  8285     fp = fopen("c:\\fetch_contact.txt","a");
       
  8286 	do  {
       
  8287 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  8288 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8289 		fwrite(rmsg,1,status,fp);
       
  8290 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8291 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  8292 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  8293 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  8294 	fclose(fp);	
       
  8295 	
       
  8296     }
       
  8297 
       
  8298 	//fetch end
       
  8299     //send messge--------------------------------------------
       
  8300    
       
  8301     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8302 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8303 	index=0;
       
  8304     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8305     msgHdr->message_type = EAdd_Contact_Request;	
       
  8306     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8307 	index += sizeof( message_hdr_req );
       
  8308 	
       
  8309 	
       
  8310     // adding add contact
       
  8311     len = strlen(connect_data->contact );
       
  8312     strcpy( smsg + index, connect_data->contact );
       
  8313     index += len + 1;
       
  8314      
       
  8315     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8316      do  {
       
  8317 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8318 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8319 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8320 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  8321    
       
  8322      if ( msg_struct->response != 1)
       
  8323     {
       
  8324     	return_value = KErrGeneral;
       
  8325 	goto return_code;
       
  8326     }
       
  8327     
       
  8328     //add contact end---------------------------------------
       
  8329     
       
  8330     
       
  8331     // logout test code from server
       
  8332     index=0;
       
  8333     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8334 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8335 	
       
  8336 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8337     
       
  8338     msgHdr->message_type = ELogout_Request;
       
  8339  
       
  8340     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8341     index += sizeof( message_hdr_req );
       
  8342 
       
  8343 	
       
  8344 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8345      do  {
       
  8346 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8347 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8348 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8349 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  8350    
       
  8351      if ( msg_struct->response != 1)
       
  8352     {
       
  8353     	return_value = KErrGeneral;
       
  8354 	goto return_code;
       
  8355     }
       
  8356     //killing isoserver
       
  8357     return_code:
       
  8358     index=0;
       
  8359     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8360 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8361 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8362     msgHdr->message_type = EKill_Process;
       
  8363     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8364     index += sizeof( message_hdr_req );
       
  8365 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  8366     free( msg_struct );
       
  8367     return return_value;
       
  8368     }
       
  8369 
       
  8370 
       
  8371 // -----------------------------------------------------------------------------
       
  8372 // Cisolationserver::add member message
       
  8373 // Example test method function.
       
  8374 // (other items were commented in a header).
       
  8375 // -----------------------------------------------------------------------------
       
  8376 //
       
  8377 TInt Cisolationserver::DeleteExistingContact( CStifItemParser& aItem )
       
  8378     {
       
  8379 
       
  8380     	
       
  8381    ConnectData  *connect_data = NULL;
       
  8382     char smsg[MAX_MSG_SIZE];
       
  8383     char rmsg[MAX_MSG_SIZE];
       
  8384     int index=0;
       
  8385     FILE *fp;
       
  8386 		
       
  8387 	int timeout = 200;
       
  8388 	int nBytes;
       
  8389 
       
  8390     int result = 0;
       
  8391     int err = 0;
       
  8392     int status = 0;
       
  8393     message_hdr_req *msgHdr = NULL;  
       
  8394     message_hdr_resp* msg_struct = NULL;
       
  8395     TInt return_value = 0;
       
  8396         	// Read data from the CFG file
       
  8397 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  8398 		{
       
  8399 		iLog->Log ( _L ( "read_data failed" ) );
       
  8400 		free_data ( connect_data );
       
  8401 		return_value = KErrGeneral;
       
  8402 		goto return_code;
       
  8403 		}
       
  8404 	//request formation	
       
  8405 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  8406 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8407 	
       
  8408 	//message header use
       
  8409 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  8410     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8411     
       
  8412     msgHdr->message_type = ELogin_Request;
       
  8413  
       
  8414     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8415     index += sizeof( message_hdr_req );
       
  8416     
       
  8417     int len = strlen(connect_data->username);
       
  8418     strcpy( smsg + index, connect_data->username );
       
  8419     index += len + 1;
       
  8420     
       
  8421     //appending password
       
  8422     
       
  8423     len = strlen(connect_data->password );
       
  8424     strcpy( smsg + index, connect_data->password );
       
  8425     index += len + 1;
       
  8426     
       
  8427     //appending server name
       
  8428     
       
  8429     len = strlen(connect_data->server );
       
  8430     strcpy( smsg + index, connect_data->server );
       
  8431     index += len + 1;
       
  8432     
       
  8433     //appending resource
       
  8434     len = strlen(connect_data->resource );
       
  8435     strcpy( smsg + index, connect_data->resource );
       
  8436     index += len + 1;
       
  8437     
       
  8438     //appending ssl
       
  8439     smsg[index++]= '1';
       
  8440     smsg[index++]= '\0';
       
  8441     
       
  8442     //appending server port
       
  8443     len = strlen(connect_data->port );
       
  8444     strcpy( smsg + index, connect_data->port );
       
  8445     index += len + 1;
       
  8446     
       
  8447     // appending IAP id
       
  8448     
       
  8449     smsg[index++]= '1';
       
  8450     smsg[index++]= '\0';
       
  8451     
       
  8452     //appending connmgr_bus
       
  8453     len = strlen(connect_data->connmgr_bus );
       
  8454     strcpy( smsg + index, connect_data->connmgr_bus );
       
  8455     index += len + 1;
       
  8456     
       
  8457     //appending connmgr_path
       
  8458     len = strlen(connect_data->connmgr_path );
       
  8459     strcpy( smsg + index, connect_data->connmgr_path );
       
  8460     index += len + 1;
       
  8461     
       
  8462     //appending protocol
       
  8463     len = strlen(connect_data->protocol );
       
  8464     strcpy( smsg + index, connect_data->protocol );
       
  8465     index += len + 1;
       
  8466     
       
  8467     #ifdef __WINSCW__
       
  8468     //proxy server
       
  8469     len = strlen(connect_data->proxy_data->proxy_server );
       
  8470     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  8471     index += len + 1;
       
  8472     
       
  8473     //proxy port
       
  8474     len = strlen(connect_data->proxy_data->proxy_port );
       
  8475     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  8476     index += len + 1;
       
  8477     
       
  8478     #endif
       
  8479     //running isoserver   
       
  8480     run_isoserver(); 
       
  8481     
       
  8482     //create message queue for send request
       
  8483     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8484     //create message queue for response request
       
  8485     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8486 		
       
  8487 	
       
  8488 	/* Send Message to queueOne */
       
  8489 	
       
  8490 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8491     
       
  8492     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  8493     
       
  8494     if (status < 0)
       
  8495     {
       
  8496     return_value = KErrGeneral;
       
  8497 	goto return_code;	
       
  8498     }
       
  8499     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  8500 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  8501 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  8502 	
       
  8503 	if( msg_struct->response != 1)
       
  8504     {
       
  8505     	return_value = KErrGeneral;
       
  8506 	goto return_code;
       
  8507     }
       
  8508     
       
  8509     
       
  8510     // login end
       
  8511     //fetch req..
       
  8512     for (int i= 0 ;i<3 ;i++)
       
  8513     {
       
  8514         
       
  8515     fp = fopen("c:\\fetch_contact.txt","a");
       
  8516 	do  {
       
  8517 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  8518 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8519 		fwrite(rmsg,1,status,fp);
       
  8520 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8521 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  8522 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  8523 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  8524 	fclose(fp);	
       
  8525 	
       
  8526     }
       
  8527 
       
  8528 	//fetch end
       
  8529      
       
  8530     //delete contact--------------------------------------------
       
  8531    
       
  8532     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8533 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8534 	index=0;
       
  8535     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8536     msgHdr->message_type = EDelete_Contact_Request;	
       
  8537     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8538 	index += sizeof( message_hdr_req );
       
  8539 	
       
  8540 	
       
  8541     // adding add contact
       
  8542     len = strlen(connect_data->contact );
       
  8543     strcpy( smsg + index, connect_data->contact );
       
  8544     index += len + 1;
       
  8545     smsg[index++] = '\0';
       
  8546      
       
  8547     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8548      do  {
       
  8549 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8550 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8551 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8552 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  8553    
       
  8554      if ( msg_struct->response != 1)
       
  8555     {
       
  8556     	return_value = KErrGeneral;
       
  8557 	goto return_code;
       
  8558     }
       
  8559     
       
  8560     //add contact end---------------------------------------
       
  8561     
       
  8562     
       
  8563    // logout test code from server
       
  8564    // logout test code from server
       
  8565     index=0;
       
  8566     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8567 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8568 	
       
  8569 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8570     
       
  8571     msgHdr->message_type = ELogout_Request;
       
  8572  
       
  8573     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8574     index += sizeof( message_hdr_req );
       
  8575 
       
  8576 	
       
  8577 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8578      do  {
       
  8579 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8580 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8581 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8582 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  8583    
       
  8584      if ( msg_struct->response != 1)
       
  8585     {
       
  8586     	return_value = KErrGeneral;
       
  8587 	goto return_code;
       
  8588     }
       
  8589     return_code:
       
  8590     index=0;
       
  8591     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8592 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8593 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8594     msgHdr->message_type = EKill_Process;
       
  8595     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8596     index += sizeof( message_hdr_req );
       
  8597 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  8598     free( msg_struct );
       
  8599     return return_value;
       
  8600     }
       
  8601 
       
  8602 // -----------------------------------------------------------------------------
       
  8603 // Cisolationserver::add member message
       
  8604 // Example test method function.
       
  8605 // (other items were commented in a header).
       
  8606 // -----------------------------------------------------------------------------
       
  8607 //
       
  8608 TInt Cisolationserver::DeleteUnexistingUserID( CStifItemParser& aItem )
       
  8609     {
       
  8610 
       
  8611     	
       
  8612    ConnectData  *connect_data = NULL;
       
  8613     char smsg[MAX_MSG_SIZE];
       
  8614     char rmsg[MAX_MSG_SIZE];
       
  8615     int index=0;
       
  8616     FILE *fp;
       
  8617 		
       
  8618 	int timeout = 200;
       
  8619 	int nBytes;
       
  8620 
       
  8621     int result = 0;
       
  8622     int err = 0;
       
  8623     int status = 0;
       
  8624     message_hdr_req *msgHdr = NULL;  
       
  8625     message_hdr_resp* msg_struct = NULL;
       
  8626     TInt return_value = 0;
       
  8627         	// Read data from the CFG file
       
  8628 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  8629 		{
       
  8630 		iLog->Log ( _L ( "read_data failed" ) );
       
  8631 		free_data ( connect_data );
       
  8632 		return_value = KErrGeneral;
       
  8633 		goto return_code;
       
  8634 		}
       
  8635 	//request formation	
       
  8636 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  8637 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8638 	
       
  8639 	//message header use
       
  8640 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  8641     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8642     
       
  8643     msgHdr->message_type = ELogin_Request;
       
  8644  
       
  8645     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8646     index += sizeof( message_hdr_req );
       
  8647     
       
  8648     int len = strlen(connect_data->username);
       
  8649     strcpy( smsg + index, connect_data->username );
       
  8650     index += len + 1;
       
  8651     
       
  8652     //appending password
       
  8653     
       
  8654     len = strlen(connect_data->password );
       
  8655     strcpy( smsg + index, connect_data->password );
       
  8656     index += len + 1;
       
  8657     
       
  8658     //appending server name
       
  8659     
       
  8660     len = strlen(connect_data->server );
       
  8661     strcpy( smsg + index, connect_data->server );
       
  8662     index += len + 1;
       
  8663     
       
  8664     //appending resource
       
  8665     len = strlen(connect_data->resource );
       
  8666     strcpy( smsg + index, connect_data->resource );
       
  8667     index += len + 1;
       
  8668     
       
  8669     //appending ssl
       
  8670     smsg[index++]= '1';
       
  8671     smsg[index++]= '\0';
       
  8672     
       
  8673     //appending server port
       
  8674     len = strlen(connect_data->port );
       
  8675     strcpy( smsg + index, connect_data->port );
       
  8676     index += len + 1;
       
  8677     
       
  8678     // appending IAP id
       
  8679     
       
  8680     smsg[index++]= '1';
       
  8681     smsg[index++]= '\0';
       
  8682     
       
  8683     //appending connmgr_bus
       
  8684     len = strlen(connect_data->connmgr_bus );
       
  8685     strcpy( smsg + index, connect_data->connmgr_bus );
       
  8686     index += len + 1;
       
  8687     
       
  8688     //appending connmgr_path
       
  8689     len = strlen(connect_data->connmgr_path );
       
  8690     strcpy( smsg + index, connect_data->connmgr_path );
       
  8691     index += len + 1;
       
  8692     
       
  8693     //appending protocol
       
  8694     len = strlen(connect_data->protocol );
       
  8695     strcpy( smsg + index, connect_data->protocol );
       
  8696     index += len + 1;
       
  8697     
       
  8698     #ifdef __WINSCW__
       
  8699     //proxy server
       
  8700     len = strlen(connect_data->proxy_data->proxy_server );
       
  8701     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  8702     index += len + 1;
       
  8703     
       
  8704     //proxy port
       
  8705     len = strlen(connect_data->proxy_data->proxy_port );
       
  8706     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  8707     index += len + 1;
       
  8708     
       
  8709     #endif
       
  8710     //running isoserver   
       
  8711     run_isoserver(); 
       
  8712     //create message queue for send request
       
  8713     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8714     //create message queue for response request
       
  8715     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8716 		
       
  8717 	
       
  8718 	/* Send Message to queueOne */
       
  8719 	
       
  8720 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8721     
       
  8722     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  8723     
       
  8724     if (status < 0)
       
  8725     {
       
  8726     return_value = KErrGeneral;
       
  8727 	goto return_code;	
       
  8728     }
       
  8729     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  8730 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  8731 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  8732 	
       
  8733 	if( msg_struct->response != 1)
       
  8734     {
       
  8735     	return_value = KErrGeneral;
       
  8736 	goto return_code;
       
  8737     }
       
  8738     
       
  8739     
       
  8740     // login end
       
  8741    //fetch req..
       
  8742     for (int i= 0 ;i<3 ;i++)
       
  8743     {
       
  8744         
       
  8745     fp = fopen("c:\\fetch_contact.txt","a");
       
  8746 	do  {
       
  8747 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  8748 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8749 		fwrite(rmsg,1,status,fp);
       
  8750 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8751 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  8752 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  8753 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  8754 	fclose(fp);	
       
  8755 	
       
  8756     }
       
  8757 
       
  8758 	//fetch end     
       
  8759     //delete contact--------------------------------------------
       
  8760    
       
  8761     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8762 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8763 	index=0;
       
  8764     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8765     msgHdr->message_type = EDelete_Contact_Request;	
       
  8766     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8767 	index += sizeof( message_hdr_req );
       
  8768 	
       
  8769 	
       
  8770     // adding add contact
       
  8771     len = strlen(connect_data->contact );
       
  8772     strcpy( smsg + index, connect_data->contact );
       
  8773     index += len + 1;
       
  8774    
       
  8775     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8776      do  {
       
  8777 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8778 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8779 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8780 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  8781    
       
  8782      if ( msg_struct->response != 1)
       
  8783     {
       
  8784     	return_value = KErrGeneral;
       
  8785 	goto return_code;
       
  8786     }
       
  8787     
       
  8788     //add contact end---------------------------------------
       
  8789     
       
  8790     
       
  8791     // logout test code from server
       
  8792     index=0;
       
  8793     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8794 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8795 	
       
  8796 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8797     
       
  8798     msgHdr->message_type = ELogout_Request;
       
  8799  
       
  8800     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8801     index += sizeof( message_hdr_req );
       
  8802 
       
  8803 	
       
  8804 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8805      do  {
       
  8806 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  8807 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8808 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8809 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  8810    
       
  8811      if ( msg_struct->response != 1)
       
  8812     {
       
  8813     	return_value = KErrGeneral;
       
  8814 	goto return_code;
       
  8815     }
       
  8816     //killing isoserver
       
  8817     return_code:
       
  8818     index=0;
       
  8819     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8820 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8821 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8822     msgHdr->message_type = EKill_Process;
       
  8823     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8824     index += sizeof( message_hdr_req );
       
  8825 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  8826     free( msg_struct );
       
  8827     return return_value;
       
  8828     }
       
  8829 
       
  8830 // -----------------------------------------------------------------------------
       
  8831 // Cisolationserver::add member message
       
  8832 // Example test method function.
       
  8833 // (other items were commented in a header).
       
  8834 // -----------------------------------------------------------------------------
       
  8835 //
       
  8836 TInt Cisolationserver::DeleteContactWhichIsAlreadyDeleted( CStifItemParser& aItem )
       
  8837     {
       
  8838 
       
  8839     	
       
  8840    ConnectData  *connect_data = NULL;
       
  8841     char smsg[MAX_MSG_SIZE];
       
  8842     char rmsg[MAX_MSG_SIZE];
       
  8843     int index=0;
       
  8844     FILE *fp;
       
  8845 		
       
  8846 	int timeout = 200;
       
  8847 	int nBytes;
       
  8848 
       
  8849     int result = 0;
       
  8850     int err = 0;
       
  8851     int status = 0;
       
  8852     message_hdr_req *msgHdr = NULL;  
       
  8853     message_hdr_resp* msg_struct = NULL;
       
  8854     TInt return_value = 0;
       
  8855         	// Read data from the CFG file
       
  8856 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  8857 		{
       
  8858 		iLog->Log ( _L ( "read_data failed" ) );
       
  8859 		free_data ( connect_data );
       
  8860 		return_value = KErrGeneral;
       
  8861 		goto return_code;
       
  8862 		}
       
  8863 	//request formation	
       
  8864 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  8865 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8866 	
       
  8867 	//message header use
       
  8868 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  8869     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8870     
       
  8871     msgHdr->message_type = ELogin_Request;
       
  8872  
       
  8873     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  8874     index += sizeof( message_hdr_req );
       
  8875     
       
  8876     int len = strlen(connect_data->username);
       
  8877     strcpy( smsg + index, connect_data->username );
       
  8878     index += len + 1;
       
  8879     
       
  8880     //appending password
       
  8881     
       
  8882     len = strlen(connect_data->password );
       
  8883     strcpy( smsg + index, connect_data->password );
       
  8884     index += len + 1;
       
  8885     
       
  8886     //appending server name
       
  8887     
       
  8888     len = strlen(connect_data->server );
       
  8889     strcpy( smsg + index, connect_data->server );
       
  8890     index += len + 1;
       
  8891     
       
  8892     //appending resource
       
  8893     len = strlen(connect_data->resource );
       
  8894     strcpy( smsg + index, connect_data->resource );
       
  8895     index += len + 1;
       
  8896     
       
  8897     //appending ssl
       
  8898     smsg[index++]= '1';
       
  8899     smsg[index++]= '\0';
       
  8900     
       
  8901     //appending server port
       
  8902     len = strlen(connect_data->port );
       
  8903     strcpy( smsg + index, connect_data->port );
       
  8904     index += len + 1;
       
  8905     
       
  8906     // appending IAP id
       
  8907     
       
  8908     smsg[index++]= '1';
       
  8909     smsg[index++]= '\0';
       
  8910     
       
  8911     //appending connmgr_bus
       
  8912     len = strlen(connect_data->connmgr_bus );
       
  8913     strcpy( smsg + index, connect_data->connmgr_bus );
       
  8914     index += len + 1;
       
  8915     
       
  8916     //appending connmgr_path
       
  8917     len = strlen(connect_data->connmgr_path );
       
  8918     strcpy( smsg + index, connect_data->connmgr_path );
       
  8919     index += len + 1;
       
  8920     
       
  8921     //appending protocol
       
  8922     len = strlen(connect_data->protocol );
       
  8923     strcpy( smsg + index, connect_data->protocol );
       
  8924     index += len + 1;
       
  8925     
       
  8926     #ifdef __WINSCW__
       
  8927     //proxy server
       
  8928     len = strlen(connect_data->proxy_data->proxy_server );
       
  8929     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  8930     index += len + 1;
       
  8931     
       
  8932     //proxy port
       
  8933     len = strlen(connect_data->proxy_data->proxy_port );
       
  8934     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  8935     index += len + 1;
       
  8936     
       
  8937     #endif
       
  8938     
       
  8939     //running isoserver   
       
  8940     run_isoserver(); 
       
  8941     
       
  8942         
       
  8943     //create message queue for send request
       
  8944     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8945     //create message queue for response request
       
  8946     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  8947 		
       
  8948 	
       
  8949 	/* Send Message to queueOne */
       
  8950 	
       
  8951 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  8952     
       
  8953     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  8954     
       
  8955     if (status < 0)
       
  8956     {
       
  8957     return_value = KErrGeneral;
       
  8958 	goto return_code;	
       
  8959     }
       
  8960     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  8961 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  8962 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  8963 	
       
  8964 	if( msg_struct->response != 1)
       
  8965     {
       
  8966     	return_value = KErrGeneral;
       
  8967 	goto return_code;
       
  8968     }
       
  8969     
       
  8970     
       
  8971     // login end
       
  8972    //fetch req..
       
  8973     for (int i= 0 ;i<3 ;i++)
       
  8974     {
       
  8975         
       
  8976     fp = fopen("c:\\fetch_contact.txt","a");
       
  8977 	do  {
       
  8978 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  8979 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  8980 		fwrite(rmsg,1,status,fp);
       
  8981 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8982 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  8983 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  8984 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  8985 	fclose(fp);	
       
  8986 	
       
  8987     }
       
  8988 
       
  8989 	//fetch end
       
  8990      
       
  8991      
       
  8992       //add member  1 st time--------------------------------------------
       
  8993    
       
  8994     memset( smsg, '\0', MAX_MSG_SIZE );
       
  8995 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  8996 	index=0;
       
  8997     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  8998     msgHdr->message_type = EAdd_Contact_Request;	
       
  8999     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9000 	index += sizeof( message_hdr_req );
       
  9001 	
       
  9002     // addiing in q for deleting contact
       
  9003     len = strlen(connect_data->contact );
       
  9004     strcpy( smsg + index, connect_data->contact );
       
  9005     index += len + 1;
       
  9006         
       
  9007     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9008      do  {
       
  9009 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9010 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9011 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9012 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
  9013    
       
  9014      if ( msg_struct->response != 1)
       
  9015     {
       
  9016     	return_value = KErrGeneral;
       
  9017 	goto return_code;
       
  9018     }
       
  9019     
       
  9020     //add contact end 1---------------------------------------
       
  9021     
       
  9022     //delete member  1 st time--------------------------------------------
       
  9023    
       
  9024     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9025 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9026 	index=0;
       
  9027     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9028     msgHdr->message_type = EDelete_Contact_Request;	
       
  9029     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9030 	index += sizeof( message_hdr_req );
       
  9031 	
       
  9032 	
       
  9033     // addiing in q for deleting contact
       
  9034     len = strlen(connect_data->contact );
       
  9035     strcpy( smsg + index, connect_data->contact );
       
  9036     index += len + 1;
       
  9037         
       
  9038     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9039      do  {
       
  9040 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9041 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9042 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9043 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  9044    
       
  9045      if ( msg_struct->response != 1)
       
  9046     {
       
  9047     	return_value = KErrGeneral;
       
  9048 	goto return_code;
       
  9049     }    
       
  9050     //delete contact end 1---------------------------------------
       
  9051     
       
  9052      //delete contact  2 nd time--------------------------------------------
       
  9053    
       
  9054     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9055 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9056 	index=0;
       
  9057     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9058     msgHdr->message_type = EDelete_Contact_Request;	
       
  9059     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9060 	index += sizeof( message_hdr_req );
       
  9061 	
       
  9062 	
       
  9063     // delete  contact
       
  9064     len = strlen(connect_data->contact );
       
  9065     strcpy( smsg + index, connect_data->contact );
       
  9066     index += len + 1;
       
  9067     
       
  9068     
       
  9069     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9070      do  {
       
  9071 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9072 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9073 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9074 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  9075    
       
  9076      if ( msg_struct->response != 1)
       
  9077     {
       
  9078     	return_value = KErrGeneral;
       
  9079 	goto return_code;
       
  9080     }
       
  9081     
       
  9082     //delete contact end---------------------------------------
       
  9083     
       
  9084 
       
  9085     // logout test code from server
       
  9086     index=0;
       
  9087     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9088 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9089 	
       
  9090 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9091     
       
  9092     msgHdr->message_type = ELogout_Request;
       
  9093  
       
  9094     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9095     index += sizeof( message_hdr_req );
       
  9096 
       
  9097 	
       
  9098 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9099      do  {
       
  9100 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9101 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9102 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9103 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  9104    
       
  9105      if ( msg_struct->response != 1)
       
  9106     {
       
  9107     	return_value = KErrGeneral;
       
  9108 	goto return_code;
       
  9109     }
       
  9110    //killing isoserver
       
  9111     return_code:
       
  9112     index=0;
       
  9113     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9114 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9115 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9116     msgHdr->message_type = EKill_Process;
       
  9117     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9118     index += sizeof( message_hdr_req );
       
  9119 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  9120     free( msg_struct );
       
  9121     return return_value;
       
  9122     }
       
  9123 
       
  9124 
       
  9125   // -----------------------------------------------------------------------------
       
  9126 // Cisolationserver::add member message
       
  9127 // Example test method function.
       
  9128 // (other items were commented in a header).
       
  9129 // -----------------------------------------------------------------------------
       
  9130 //
       
  9131 TInt Cisolationserver::ClientSendBlankUserIdForDELETE( CStifItemParser& aItem )
       
  9132     {
       
  9133 
       
  9134     	
       
  9135    ConnectData  *connect_data = NULL;
       
  9136     char smsg[MAX_MSG_SIZE];
       
  9137     char rmsg[MAX_MSG_SIZE];
       
  9138     int index=0;
       
  9139     FILE *fp;
       
  9140 		
       
  9141 	int timeout = 200;
       
  9142 	int nBytes;
       
  9143 
       
  9144     int result = 0;
       
  9145     int err = 0;
       
  9146     int status = 0;
       
  9147     message_hdr_req *msgHdr = NULL;  
       
  9148     message_hdr_resp* msg_struct = NULL;
       
  9149     TInt return_value = 0;
       
  9150         	// Read data from the CFG file
       
  9151 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  9152 		{
       
  9153 		iLog->Log ( _L ( "read_data failed" ) );
       
  9154 		free_data ( connect_data );
       
  9155 		return_value = KErrGeneral;
       
  9156 		goto return_code;
       
  9157 		}
       
  9158 	//request formation	
       
  9159 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  9160 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9161 	
       
  9162 	//message header use
       
  9163 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  9164     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9165     
       
  9166     msgHdr->message_type = ELogin_Request;
       
  9167  
       
  9168     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9169     index += sizeof( message_hdr_req );
       
  9170     
       
  9171     int len = strlen(connect_data->username);
       
  9172     strcpy( smsg + index, connect_data->username );
       
  9173     index += len + 1;
       
  9174     
       
  9175     //appending password
       
  9176     
       
  9177     len = strlen(connect_data->password );
       
  9178     strcpy( smsg + index, connect_data->password );
       
  9179     index += len + 1;
       
  9180     
       
  9181     //appending server name
       
  9182     
       
  9183     len = strlen(connect_data->server );
       
  9184     strcpy( smsg + index, connect_data->server );
       
  9185     index += len + 1;
       
  9186     
       
  9187     //appending resource
       
  9188     len = strlen(connect_data->resource );
       
  9189     strcpy( smsg + index, connect_data->resource );
       
  9190     index += len + 1;
       
  9191     
       
  9192     //appending ssl
       
  9193     smsg[index++]= '1';
       
  9194     smsg[index++]= '\0';
       
  9195     
       
  9196     //appending server port
       
  9197     len = strlen(connect_data->port );
       
  9198     strcpy( smsg + index, connect_data->port );
       
  9199     index += len + 1;
       
  9200     
       
  9201     // appending IAP id
       
  9202     
       
  9203     smsg[index++]= '1';
       
  9204     smsg[index++]= '\0';
       
  9205     
       
  9206     //appending connmgr_bus
       
  9207     len = strlen(connect_data->connmgr_bus );
       
  9208     strcpy( smsg + index, connect_data->connmgr_bus );
       
  9209     index += len + 1;
       
  9210     
       
  9211     //appending connmgr_path
       
  9212     len = strlen(connect_data->connmgr_path );
       
  9213     strcpy( smsg + index, connect_data->connmgr_path );
       
  9214     index += len + 1;
       
  9215     
       
  9216     //appending protocol
       
  9217     len = strlen(connect_data->protocol );
       
  9218     strcpy( smsg + index, connect_data->protocol );
       
  9219     index += len + 1;
       
  9220     
       
  9221     #ifdef __WINSCW__
       
  9222     //proxy server
       
  9223     len = strlen(connect_data->proxy_data->proxy_server );
       
  9224     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  9225     index += len + 1;
       
  9226     
       
  9227     //proxy port
       
  9228     len = strlen(connect_data->proxy_data->proxy_port );
       
  9229     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  9230     index += len + 1;
       
  9231     
       
  9232     #endif
       
  9233     //running isoserver   
       
  9234     run_isoserver(); 
       
  9235     
       
  9236     
       
  9237         
       
  9238     //create message queue for send request
       
  9239     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9240     //create message queue for response request
       
  9241     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9242 		
       
  9243 	
       
  9244 	/* Send Message to queueOne */
       
  9245 	
       
  9246 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9247     
       
  9248     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  9249     
       
  9250     if (status < 0)
       
  9251     {
       
  9252     return_value = KErrGeneral;
       
  9253 	goto return_code;	
       
  9254     }
       
  9255     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  9256 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  9257 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  9258 	
       
  9259 	if( msg_struct->response != 1)
       
  9260     {
       
  9261     	return_value = KErrGeneral;
       
  9262 	goto return_code;
       
  9263     }
       
  9264     
       
  9265     
       
  9266     // login end
       
  9267    //fetch req..
       
  9268     for (int i= 0 ;i<3 ;i++)
       
  9269     {
       
  9270         
       
  9271     fp = fopen("c:\\fetch_contact.txt","a");
       
  9272 	do  {
       
  9273 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  9274 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9275 		fwrite(rmsg,1,status,fp);
       
  9276 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9277 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  9278 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  9279 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  9280 	fclose(fp);	
       
  9281 	
       
  9282     }
       
  9283 
       
  9284 	//fetch end
       
  9285      
       
  9286     //delete contact --------------------------------------------
       
  9287    
       
  9288     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9289 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9290 	index=0;
       
  9291     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9292     msgHdr->message_type = EDelete_Contact_Request;	
       
  9293     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9294 	index += sizeof( message_hdr_req );
       
  9295 	
       
  9296 	
       
  9297     smsg[index++]='\0';
       
  9298     //client is sending blank user id
       
  9299     smsg[index++]='\0';
       
  9300     
       
  9301      
       
  9302        
       
  9303     
       
  9304     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9305      do  {
       
  9306 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9307 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9308 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9309 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  9310    
       
  9311      if( msg_struct->error_type >0)
       
  9312     {
       
  9313     	return_value = KErrGeneral;
       
  9314 	goto return_code;
       
  9315     }
       
  9316     
       
  9317     //delete contact end---------------------------------------
       
  9318     
       
  9319     
       
  9320     // logout test code from server
       
  9321     index=0;
       
  9322     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9323 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9324 	
       
  9325 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9326     
       
  9327     msgHdr->message_type = ELogout_Request;
       
  9328  
       
  9329     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9330     index += sizeof( message_hdr_req );
       
  9331 
       
  9332 	
       
  9333 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9334      do  {
       
  9335 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9336 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9337 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9338 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  9339    
       
  9340      if ( msg_struct->response != 1)
       
  9341     {
       
  9342     	return_value = KErrGeneral;
       
  9343 	goto return_code;
       
  9344     }
       
  9345     //killing isoserver
       
  9346     return_code:
       
  9347     index=0;
       
  9348     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9349 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9350 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9351     msgHdr->message_type = EKill_Process;
       
  9352     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9353     index += sizeof( message_hdr_req );
       
  9354 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  9355     free( msg_struct );
       
  9356     return return_value;
       
  9357     }
       
  9358 
       
  9359 // -----------------------------------------------------------------------------
       
  9360 // Cisolationserver::add member message
       
  9361 // Example test method function.
       
  9362 // (other items were commented in a header).
       
  9363 // -----------------------------------------------------------------------------
       
  9364 //
       
  9365 TInt Cisolationserver::DeleteExistingContactWIthSpace( CStifItemParser& aItem )
       
  9366     {
       
  9367 
       
  9368     	
       
  9369    ConnectData  *connect_data = NULL;
       
  9370     char smsg[MAX_MSG_SIZE];
       
  9371     char rmsg[MAX_MSG_SIZE];
       
  9372     int index=0;
       
  9373     FILE *fp;
       
  9374 		
       
  9375 	int timeout = 200;
       
  9376 	int nBytes;
       
  9377 
       
  9378     int result = 0;
       
  9379     int err = 0;
       
  9380     int status = 0;
       
  9381     message_hdr_req *msgHdr = NULL;  
       
  9382     message_hdr_resp* msg_struct = NULL;
       
  9383     TInt return_value = 0;
       
  9384         	// Read data from the CFG file
       
  9385 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  9386 		{
       
  9387 		iLog->Log ( _L ( "read_data failed" ) );
       
  9388 		free_data ( connect_data );
       
  9389 		return_value = KErrGeneral;
       
  9390 		goto return_code;
       
  9391 		}
       
  9392 	//request formation	
       
  9393 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  9394 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9395 	
       
  9396 	//message header use
       
  9397 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  9398     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9399     
       
  9400     msgHdr->message_type = ELogin_Request;
       
  9401  
       
  9402     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9403     index += sizeof( message_hdr_req );
       
  9404     
       
  9405     int len = strlen(connect_data->username);
       
  9406     strcpy( smsg + index, connect_data->username );
       
  9407     index += len + 1;
       
  9408     
       
  9409     //appending password
       
  9410     
       
  9411     len = strlen(connect_data->password );
       
  9412     strcpy( smsg + index, connect_data->password );
       
  9413     index += len + 1;
       
  9414     
       
  9415     //appending server name
       
  9416     
       
  9417     len = strlen(connect_data->server );
       
  9418     strcpy( smsg + index, connect_data->server );
       
  9419     index += len + 1;
       
  9420     
       
  9421     //appending resource
       
  9422     len = strlen(connect_data->resource );
       
  9423     strcpy( smsg + index, connect_data->resource );
       
  9424     index += len + 1;
       
  9425     
       
  9426     //appending ssl
       
  9427     smsg[index++]= '1';
       
  9428     smsg[index++]= '\0';
       
  9429     
       
  9430     //appending server port
       
  9431     len = strlen(connect_data->port );
       
  9432     strcpy( smsg + index, connect_data->port );
       
  9433     index += len + 1;
       
  9434     
       
  9435     // appending IAP id
       
  9436     
       
  9437     smsg[index++]= '1';
       
  9438     smsg[index++]= '\0';
       
  9439     
       
  9440     //appending connmgr_bus
       
  9441     len = strlen(connect_data->connmgr_bus );
       
  9442     strcpy( smsg + index, connect_data->connmgr_bus );
       
  9443     index += len + 1;
       
  9444     
       
  9445     //appending connmgr_path
       
  9446     len = strlen(connect_data->connmgr_path );
       
  9447     strcpy( smsg + index, connect_data->connmgr_path );
       
  9448     index += len + 1;
       
  9449     
       
  9450     //appending protocol
       
  9451     len = strlen(connect_data->protocol );
       
  9452     strcpy( smsg + index, connect_data->protocol );
       
  9453     index += len + 1;
       
  9454     
       
  9455     #ifdef __WINSCW__
       
  9456     //proxy server
       
  9457     len = strlen(connect_data->proxy_data->proxy_server );
       
  9458     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  9459     index += len + 1;
       
  9460     
       
  9461     //proxy port
       
  9462     len = strlen(connect_data->proxy_data->proxy_port );
       
  9463     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  9464     index += len + 1;
       
  9465     
       
  9466     #endif
       
  9467     //running isoserver   
       
  9468     run_isoserver(); 
       
  9469     //create message queue for send request
       
  9470     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9471     //create message queue for response request
       
  9472     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9473 		
       
  9474 	
       
  9475 	/* Send Message to queueOne */
       
  9476 	
       
  9477 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9478     
       
  9479     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  9480     
       
  9481     if (status < 0)
       
  9482     {
       
  9483     return_value = KErrGeneral;
       
  9484 	goto return_code;	
       
  9485     }
       
  9486     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  9487 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  9488 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  9489 	
       
  9490 	if( msg_struct->response != 1)
       
  9491     {
       
  9492     	return_value = KErrGeneral;
       
  9493 	goto return_code;
       
  9494     }
       
  9495     
       
  9496     
       
  9497     // login end
       
  9498 
       
  9499      //fetch req..
       
  9500     for (int i= 0 ;i<3 ;i++)
       
  9501     {
       
  9502         
       
  9503     fp = fopen("c:\\fetch_contact.txt","a");
       
  9504 	do  {
       
  9505 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  9506 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9507 		fwrite(rmsg,1,status,fp);
       
  9508 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9509 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  9510 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  9511 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  9512 	fclose(fp);	
       
  9513 	
       
  9514     }
       
  9515 
       
  9516 	//fetch end
       
  9517 	
       
  9518     //delete contact--------------------------------------------
       
  9519    
       
  9520     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9521 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9522 	index=0;
       
  9523     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9524     msgHdr->message_type = EDelete_Contact_Request;	
       
  9525     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9526 	index += sizeof( message_hdr_req );
       
  9527 	
       
  9528 	
       
  9529     // adding delete contact in queue
       
  9530     len = strlen(connect_data->contact );
       
  9531     strcpy( smsg + index, connect_data->contact );
       
  9532     index += len + 1;
       
  9533     smsg[index++]='\0';
       
  9534         
       
  9535     
       
  9536     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9537      do  {
       
  9538 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9539 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9540 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9541 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  9542    
       
  9543       if( msg_struct->response != 0)
       
  9544     {
       
  9545     	return_value = KErrGeneral;
       
  9546 	goto return_code;
       
  9547     }
       
  9548     //delete contact end---------------------------------------
       
  9549     
       
  9550     
       
  9551     // logout test code from server
       
  9552     index=0;
       
  9553     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9554 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9555 	
       
  9556 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9557     
       
  9558     msgHdr->message_type = ELogout_Request;
       
  9559  
       
  9560     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9561     index += sizeof( message_hdr_req );
       
  9562 
       
  9563 	
       
  9564 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9565      do  {
       
  9566 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9567 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9568 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9569 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  9570    
       
  9571      if ( msg_struct->response != 1)
       
  9572     {
       
  9573     	return_value = KErrGeneral;
       
  9574 	goto return_code;
       
  9575     }
       
  9576    //killing isoserver
       
  9577     return_code:
       
  9578     index=0;
       
  9579     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9580 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9581 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9582     msgHdr->message_type = EKill_Process;
       
  9583     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9584     index += sizeof( message_hdr_req );
       
  9585 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  9586     free( msg_struct );
       
  9587     return return_value;
       
  9588     }
       
  9589 
       
  9590 // -----------------------------------------------------------------------------
       
  9591 // Cisolationserver::add member message
       
  9592 // Example test method function.
       
  9593 // (other items were commented in a header).
       
  9594 // -----------------------------------------------------------------------------
       
  9595 //
       
  9596 TInt Cisolationserver::DeleteExistingContactWIthMixedLetter( CStifItemParser& aItem )
       
  9597     {
       
  9598 
       
  9599     	
       
  9600    ConnectData  *connect_data = NULL;
       
  9601     char smsg[MAX_MSG_SIZE];
       
  9602     char rmsg[MAX_MSG_SIZE];
       
  9603     int index=0;
       
  9604     FILE *fp;
       
  9605 		
       
  9606 	int timeout = 200;
       
  9607 	int nBytes;
       
  9608 
       
  9609     int result = 0;
       
  9610     int err = 0;
       
  9611     int status = 0;
       
  9612     message_hdr_req *msgHdr = NULL;  
       
  9613     message_hdr_resp* msg_struct = NULL;
       
  9614     TInt return_value = 0;
       
  9615         	// Read data from the CFG file
       
  9616 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  9617 		{
       
  9618 		iLog->Log ( _L ( "read_data failed" ) );
       
  9619 		free_data ( connect_data );
       
  9620 		return_value = KErrGeneral;
       
  9621 		goto return_code;
       
  9622 		}
       
  9623 	//request formation	
       
  9624 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  9625 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9626 	
       
  9627 	//message header use
       
  9628 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  9629     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9630     
       
  9631     msgHdr->message_type = ELogin_Request;
       
  9632  
       
  9633     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9634     index += sizeof( message_hdr_req );
       
  9635     
       
  9636     int len = strlen(connect_data->username);
       
  9637     strcpy( smsg + index, connect_data->username );
       
  9638     index += len + 1;
       
  9639     
       
  9640     //appending password
       
  9641     
       
  9642     len = strlen(connect_data->password );
       
  9643     strcpy( smsg + index, connect_data->password );
       
  9644     index += len + 1;
       
  9645     
       
  9646     //appending server name
       
  9647     
       
  9648     len = strlen(connect_data->server );
       
  9649     strcpy( smsg + index, connect_data->server );
       
  9650     index += len + 1;
       
  9651     
       
  9652     //appending resource
       
  9653     len = strlen(connect_data->resource );
       
  9654     strcpy( smsg + index, connect_data->resource );
       
  9655     index += len + 1;
       
  9656     
       
  9657     //appending ssl
       
  9658     smsg[index++]= '1';
       
  9659     smsg[index++]= '\0';
       
  9660     
       
  9661     //appending server port
       
  9662     len = strlen(connect_data->port );
       
  9663     strcpy( smsg + index, connect_data->port );
       
  9664     index += len + 1;
       
  9665     
       
  9666     // appending IAP id
       
  9667     
       
  9668     smsg[index++]= '1';
       
  9669     smsg[index++]= '\0';
       
  9670     
       
  9671     //appending connmgr_bus
       
  9672     len = strlen(connect_data->connmgr_bus );
       
  9673     strcpy( smsg + index, connect_data->connmgr_bus );
       
  9674     index += len + 1;
       
  9675     
       
  9676     //appending connmgr_path
       
  9677     len = strlen(connect_data->connmgr_path );
       
  9678     strcpy( smsg + index, connect_data->connmgr_path );
       
  9679     index += len + 1;
       
  9680     
       
  9681     //appending protocol
       
  9682     len = strlen(connect_data->protocol );
       
  9683     strcpy( smsg + index, connect_data->protocol );
       
  9684     index += len + 1;
       
  9685     
       
  9686     #ifdef __WINSCW__
       
  9687     //proxy server
       
  9688     len = strlen(connect_data->proxy_data->proxy_server );
       
  9689     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  9690     index += len + 1;
       
  9691     
       
  9692     //proxy port
       
  9693     len = strlen(connect_data->proxy_data->proxy_port );
       
  9694     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  9695     index += len + 1;
       
  9696     
       
  9697     #endif
       
  9698     
       
  9699     //running isoserver   
       
  9700     run_isoserver(); 
       
  9701     //create message queue for send request
       
  9702     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9703     //create message queue for response request
       
  9704     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9705 	/* Send Message to queueOne */
       
  9706 	
       
  9707 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9708     
       
  9709     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  9710     
       
  9711     if (status < 0)
       
  9712     {
       
  9713     return_value = KErrGeneral;
       
  9714 	goto return_code;	
       
  9715     }
       
  9716     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  9717 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  9718 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  9719 	
       
  9720 	if( msg_struct->response != 1)
       
  9721     {
       
  9722     	return_value = KErrGeneral;
       
  9723 	goto return_code;
       
  9724     }
       
  9725     
       
  9726     
       
  9727     // login end
       
  9728 
       
  9729     //fetch req..
       
  9730     for (int i= 0 ;i<3 ;i++)
       
  9731     {
       
  9732         
       
  9733     fp = fopen("c:\\fetch_contact.txt","a");
       
  9734 	do  {
       
  9735 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  9736 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9737 		fwrite(rmsg,1,status,fp);
       
  9738 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9739 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  9740 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  9741 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  9742 	fclose(fp);	
       
  9743 	
       
  9744     }
       
  9745 
       
  9746 	//fetch end
       
  9747 	
       
  9748     //delete contact--------------------------------------------
       
  9749    
       
  9750     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9751 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9752 	index=0;
       
  9753     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9754     msgHdr->message_type = EDelete_Contact_Request;	
       
  9755     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9756 	index += sizeof( message_hdr_req );
       
  9757 	
       
  9758 	
       
  9759     // adding delete contact id
       
  9760     len = strlen(connect_data->contact );
       
  9761     strcpy( smsg + index, connect_data->contact );
       
  9762     index += len + 1;
       
  9763      
       
  9764     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9765      do  {
       
  9766 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9767 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9768 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9769 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  9770    
       
  9771     
       
  9772     //delete contact end---------------------------------------
       
  9773     
       
  9774     
       
  9775     // logout test code from server
       
  9776     index=0;
       
  9777     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9778 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9779 	
       
  9780 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9781     
       
  9782     msgHdr->message_type = ELogout_Request;
       
  9783  
       
  9784     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9785     index += sizeof( message_hdr_req );
       
  9786 
       
  9787 	
       
  9788 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9789      do  {
       
  9790 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9791 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9792 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9793 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
  9794    
       
  9795      if ( msg_struct->response != 1)
       
  9796     {
       
  9797     	return_value = KErrGeneral;
       
  9798 	goto return_code;
       
  9799     }
       
  9800     //killing isoserver
       
  9801     return_code:
       
  9802     index=0;
       
  9803     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9804 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9805 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9806     msgHdr->message_type = EKill_Process;
       
  9807     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9808     index += sizeof( message_hdr_req );
       
  9809 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
  9810     free( msg_struct );
       
  9811     return return_value;
       
  9812     }
       
  9813 
       
  9814   // -----------------------------------------------------------------------------
       
  9815 // Cisolationserver::add member message
       
  9816 // Example test method function.
       
  9817 // (other items were commented in a header).
       
  9818 // -----------------------------------------------------------------------------
       
  9819 //
       
  9820 TInt Cisolationserver::DeleteInvalidContactWIthSpecialLetter( CStifItemParser& aItem )
       
  9821     {
       
  9822 
       
  9823     	
       
  9824    ConnectData  *connect_data = NULL;
       
  9825     char smsg[MAX_MSG_SIZE];
       
  9826     char rmsg[MAX_MSG_SIZE];
       
  9827     int index=0;
       
  9828     FILE *fp;
       
  9829 		
       
  9830 	int timeout = 200;
       
  9831 	int nBytes;
       
  9832 
       
  9833     int result = 0;
       
  9834     int err = 0;
       
  9835     int status = 0;
       
  9836     message_hdr_req *msgHdr = NULL;  
       
  9837     message_hdr_resp* msg_struct = NULL;
       
  9838     TInt return_value = 0;
       
  9839         	// Read data from the CFG file
       
  9840 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
  9841 		{
       
  9842 		iLog->Log ( _L ( "read_data failed" ) );
       
  9843 		free_data ( connect_data );
       
  9844 		return_value = KErrGeneral;
       
  9845 		goto return_code;
       
  9846 		}
       
  9847 	//request formation	
       
  9848 	memset( smsg, '\0', MAX_MSG_SIZE );
       
  9849 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9850 	
       
  9851 	//message header use
       
  9852 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
  9853     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9854     
       
  9855     msgHdr->message_type = ELogin_Request;
       
  9856  
       
  9857     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9858     index += sizeof( message_hdr_req );
       
  9859     
       
  9860     int len = strlen(connect_data->username);
       
  9861     strcpy( smsg + index, connect_data->username );
       
  9862     index += len + 1;
       
  9863     
       
  9864     //appending password
       
  9865     
       
  9866     len = strlen(connect_data->password );
       
  9867     strcpy( smsg + index, connect_data->password );
       
  9868     index += len + 1;
       
  9869     
       
  9870     //appending server name
       
  9871     
       
  9872     len = strlen(connect_data->server );
       
  9873     strcpy( smsg + index, connect_data->server );
       
  9874     index += len + 1;
       
  9875     
       
  9876     //appending resource
       
  9877     len = strlen(connect_data->resource );
       
  9878     strcpy( smsg + index, connect_data->resource );
       
  9879     index += len + 1;
       
  9880     
       
  9881     //appending ssl
       
  9882     smsg[index++]= '1';
       
  9883     smsg[index++]= '\0';
       
  9884     
       
  9885     //appending server port
       
  9886     len = strlen(connect_data->port );
       
  9887     strcpy( smsg + index, connect_data->port );
       
  9888     index += len + 1;
       
  9889     
       
  9890     // appending IAP id
       
  9891     
       
  9892     smsg[index++]= '1';
       
  9893     smsg[index++]= '\0';
       
  9894     
       
  9895     //appending connmgr_bus
       
  9896     len = strlen(connect_data->connmgr_bus );
       
  9897     strcpy( smsg + index, connect_data->connmgr_bus );
       
  9898     index += len + 1;
       
  9899     
       
  9900     //appending connmgr_path
       
  9901     len = strlen(connect_data->connmgr_path );
       
  9902     strcpy( smsg + index, connect_data->connmgr_path );
       
  9903     index += len + 1;
       
  9904     
       
  9905     //appending protocol
       
  9906     len = strlen(connect_data->protocol );
       
  9907     strcpy( smsg + index, connect_data->protocol );
       
  9908     index += len + 1;
       
  9909     
       
  9910     #ifdef __WINSCW__
       
  9911     //proxy server
       
  9912     len = strlen(connect_data->proxy_data->proxy_server );
       
  9913     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
  9914     index += len + 1;
       
  9915     
       
  9916     //proxy port
       
  9917     len = strlen(connect_data->proxy_data->proxy_port );
       
  9918     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
  9919     index += len + 1;
       
  9920     
       
  9921     #endif
       
  9922     //running isoserver   
       
  9923     run_isoserver(); 
       
  9924     //create message queue for send request
       
  9925     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9926     //create message queue for response request
       
  9927     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
  9928 		
       
  9929 	
       
  9930 	/* Send Message to queueOne */
       
  9931 	
       
  9932 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9933     
       
  9934     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
  9935     
       
  9936     if (status < 0)
       
  9937     {
       
  9938     return_value = KErrGeneral;
       
  9939 	goto return_code;	
       
  9940     }
       
  9941     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
  9942 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
  9943 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
  9944 	
       
  9945 	if( msg_struct->response != 1)
       
  9946     {
       
  9947     	return_value = KErrGeneral;
       
  9948 	goto return_code;
       
  9949     }
       
  9950     
       
  9951     
       
  9952     // login end
       
  9953     
       
  9954    //fetch req..
       
  9955     for (int i= 0 ;i<3 ;i++)
       
  9956     {
       
  9957         
       
  9958     fp = fopen("c:\\fetch_contact.txt","a");
       
  9959 	do  {
       
  9960 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
  9961 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9962 		fwrite(rmsg,1,status,fp);
       
  9963 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9964 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
  9965 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
  9966 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
  9967 	fclose(fp);	
       
  9968 	
       
  9969     }
       
  9970 
       
  9971 	//fetch end
       
  9972      
       
  9973     //delete contact--------------------------------------------
       
  9974    
       
  9975     memset( smsg, '\0', MAX_MSG_SIZE );
       
  9976 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9977 	index=0;
       
  9978     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
  9979     msgHdr->message_type = EDelete_Contact_Request;	
       
  9980     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
  9981 	index += sizeof( message_hdr_req );
       
  9982 	
       
  9983 	
       
  9984     // adding delete contact
       
  9985     len = strlen(connect_data->contact );
       
  9986     strcpy( smsg + index, connect_data->contact );
       
  9987     index += len + 1;
       
  9988      
       
  9989     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
  9990      do  {
       
  9991 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
  9992 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
  9993 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
  9994 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
  9995    
       
  9996      if ( msg_struct->response != 1)
       
  9997     {
       
  9998     	return_value = KErrGeneral;
       
  9999 	goto return_code;
       
 10000     }
       
 10001     
       
 10002     //delete contact end---------------------------------------
       
 10003     
       
 10004     
       
 10005    // logout test code from server
       
 10006     index=0;
       
 10007     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10008 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10009 	
       
 10010 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10011     
       
 10012     msgHdr->message_type = ELogout_Request;
       
 10013  
       
 10014     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10015     index += sizeof( message_hdr_req );
       
 10016 
       
 10017 	
       
 10018 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10019      do  {
       
 10020 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10021 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10022 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10023 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 10024    
       
 10025      if ( msg_struct->response != 1)
       
 10026     {
       
 10027     	return_value = KErrGeneral;
       
 10028 	goto return_code;
       
 10029     }
       
 10030     //killing isoserver
       
 10031     return_code:
       
 10032     index=0;
       
 10033     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10034 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10035 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10036     msgHdr->message_type = EKill_Process;
       
 10037     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10038     index += sizeof( message_hdr_req );
       
 10039 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 10040     free( msg_struct );
       
 10041     return return_value;
       
 10042     }
       
 10043 
       
 10044 // -----------------------------------------------------------------------------
       
 10045 // Cisolationserver::Login with correct data
       
 10046 // Example test method function.
       
 10047 // (other items were commented in a header).
       
 10048 // -----------------------------------------------------------------------------
       
 10049 //
       
 10050 TInt Cisolationserver::FetchContatcs( CStifItemParser& aItem )
       
 10051     {
       
 10052 
       
 10053     	
       
 10054     ConnectData  *connect_data = NULL;
       
 10055     char smsg[MAX_MSG_SIZE];
       
 10056     char rmsg[MAX_MSG_SIZE];
       
 10057     int index=0;
       
 10058     FILE *fp;
       
 10059 		
       
 10060 	int timeout = 100;
       
 10061 	int nBytes;
       
 10062 
       
 10063     int result = 0;
       
 10064     int err = 0;
       
 10065     int status = 0;
       
 10066     message_hdr_req *msgHdr = NULL;  
       
 10067     message_hdr_resp* msg_struct = NULL;
       
 10068     TInt return_value = 0;
       
 10069         	// Read data from the CFG file
       
 10070 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 10071 		{
       
 10072 		iLog->Log ( _L ( "read_data failed" ) );
       
 10073 		free_data ( connect_data );
       
 10074 		return_value = KErrGeneral;
       
 10075 		goto return_code;
       
 10076 		}
       
 10077 	//request formation	
       
 10078 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 10079 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10080 	
       
 10081 	//message header use
       
 10082 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 10083     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10084     
       
 10085     msgHdr->message_type = ELogin_Request;
       
 10086  
       
 10087     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10088     index += sizeof( message_hdr_req );
       
 10089     
       
 10090     int len = strlen(connect_data->username);
       
 10091     strcpy( smsg + index, connect_data->username );
       
 10092     index += len + 1;
       
 10093     
       
 10094     //appending password
       
 10095     
       
 10096     len = strlen(connect_data->password );
       
 10097     strcpy( smsg + index, connect_data->password );
       
 10098     index += len + 1;
       
 10099     
       
 10100     //appending server name
       
 10101     
       
 10102     len = strlen(connect_data->server );
       
 10103     strcpy( smsg + index, connect_data->server );
       
 10104     index += len + 1;
       
 10105     
       
 10106     //appending resource
       
 10107     len = strlen(connect_data->resource );
       
 10108     strcpy( smsg + index, connect_data->resource );
       
 10109     index += len + 1;
       
 10110     
       
 10111     //appending ssl
       
 10112     smsg[index++]= '1';
       
 10113     smsg[index++]= '\0';
       
 10114     
       
 10115     //appending server port
       
 10116     len = strlen(connect_data->port );
       
 10117     strcpy( smsg + index, connect_data->port );
       
 10118     index += len + 1;
       
 10119     
       
 10120     // appending IAP id
       
 10121     
       
 10122     smsg[index++]= '1';
       
 10123     smsg[index++]= '\0';
       
 10124     
       
 10125     
       
 10126     //appending connmgr_bus
       
 10127     len = strlen(connect_data->connmgr_bus );
       
 10128     strcpy( smsg + index, connect_data->connmgr_bus );
       
 10129     index += len + 1;
       
 10130     
       
 10131     //appending connmgr_path
       
 10132     len = strlen(connect_data->connmgr_path );
       
 10133     strcpy( smsg + index, connect_data->connmgr_path );
       
 10134     index += len + 1;
       
 10135     
       
 10136     //appending protocol
       
 10137     len = strlen(connect_data->protocol );
       
 10138     strcpy( smsg + index, connect_data->protocol );
       
 10139     index += len + 1;
       
 10140     
       
 10141     #ifdef __WINSCW__
       
 10142     //proxy server
       
 10143     len = strlen(connect_data->proxy_data->proxy_server );
       
 10144     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 10145     index += len + 1;
       
 10146     
       
 10147     //proxy port
       
 10148     len = strlen(connect_data->proxy_data->proxy_port );
       
 10149     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 10150     index += len + 1;
       
 10151     
       
 10152     #endif
       
 10153     //running isoserver   
       
 10154     run_isoserver(); 
       
 10155     //create message queue for send request
       
 10156     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 10157     //create message queue for response request
       
 10158     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 10159 		
       
 10160 	
       
 10161 	/* Send Message to queueOne */
       
 10162 	
       
 10163 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10164     
       
 10165     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 10166     
       
 10167     if (status < 0)
       
 10168     {
       
 10169     return_value = KErrGeneral;
       
 10170 	goto return_code;	
       
 10171     }
       
 10172     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 10173 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 10174 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 10175 	
       
 10176 	if( msg_struct->response != 1)
       
 10177     {
       
 10178     	return_value = KErrGeneral;
       
 10179 	goto return_code;
       
 10180     }
       
 10181     
       
 10182     
       
 10183     // login end
       
 10184     //fetch req..
       
 10185     for (int i= 0 ;i<3 ;i++)
       
 10186     {
       
 10187         
       
 10188     fp = fopen("c:\\fetch_contact.txt","a");
       
 10189 	do  {
       
 10190 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 10191 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10192 		fwrite(rmsg,1,status,fp);
       
 10193 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10194 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 10195 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 10196 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 10197 	fclose(fp);	
       
 10198 	
       
 10199     }
       
 10200 
       
 10201 	//fetch end
       
 10202     // logout test code from server
       
 10203    // logout test code from server
       
 10204     index=0;
       
 10205     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10206 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10207 	
       
 10208 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10209     
       
 10210     msgHdr->message_type = ELogout_Request;
       
 10211  
       
 10212     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10213     index += sizeof( message_hdr_req );
       
 10214 
       
 10215 	
       
 10216 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10217      do  {
       
 10218 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10219 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10220 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10221 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 10222    
       
 10223      if ( msg_struct->response != 1)
       
 10224     {
       
 10225     	return_value = KErrGeneral;
       
 10226 	goto return_code;
       
 10227     }
       
 10228     //killing isoserver
       
 10229     return_code:
       
 10230     index=0;
       
 10231     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10232 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10233 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10234     msgHdr->message_type = EKill_Process;
       
 10235     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10236     index += sizeof( message_hdr_req );
       
 10237 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 10238     free( msg_struct );
       
 10239     return return_value;
       
 10240     }
       
 10241 
       
 10242 
       
 10243 TInt Cisolationserver::AddContatcs( CStifItemParser& aItem )
       
 10244    	{ 	
       
 10245    	ConnectData  *connect_data = NULL;
       
 10246     char smsg[MAX_MSG_SIZE];
       
 10247     char rmsg[MAX_MSG_SIZE];
       
 10248     int index=0;
       
 10249     FILE *fp;
       
 10250 		
       
 10251 	int timeout = 200;
       
 10252 	int nBytes;
       
 10253 
       
 10254     int result = 0;
       
 10255     int err = 0;
       
 10256     int status = 0;
       
 10257     message_hdr_req *msgHdr = NULL;  
       
 10258     message_hdr_resp* msg_struct = NULL;
       
 10259     TInt return_value = 0;
       
 10260         	// Read data from the CFG file
       
 10261 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 10262 		{
       
 10263 		iLog->Log ( _L ( "read_data failed" ) );
       
 10264 		free_data ( connect_data );
       
 10265 		return_value = KErrGeneral;
       
 10266 		goto return_code;
       
 10267 		}
       
 10268 	//request formation	
       
 10269 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 10270 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10271 	
       
 10272 	//message header use
       
 10273 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 10274     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10275     
       
 10276     msgHdr->message_type = ELogin_Request;
       
 10277  
       
 10278     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10279     index += sizeof( message_hdr_req );
       
 10280     
       
 10281     int len = strlen(connect_data->username);
       
 10282     strcpy( smsg + index, connect_data->username );
       
 10283     index += len + 1;
       
 10284     
       
 10285     //appending password
       
 10286     
       
 10287     len = strlen(connect_data->password );
       
 10288     strcpy( smsg + index, connect_data->password );
       
 10289     index += len + 1;
       
 10290     
       
 10291     //appending server name
       
 10292     
       
 10293     len = strlen(connect_data->server );
       
 10294     strcpy( smsg + index, connect_data->server );
       
 10295     index += len + 1;
       
 10296     
       
 10297     //appending resource
       
 10298     len = strlen(connect_data->resource );
       
 10299     strcpy( smsg + index, connect_data->resource );
       
 10300     index += len + 1;
       
 10301     
       
 10302     //appending ssl
       
 10303     smsg[index++]= '1';
       
 10304     smsg[index++]= '\0';
       
 10305     
       
 10306     //appending server port
       
 10307     len = strlen(connect_data->port );
       
 10308     strcpy( smsg + index, connect_data->port );
       
 10309     index += len + 1;
       
 10310     
       
 10311     // appending IAP id
       
 10312     
       
 10313     smsg[index++]= '1';
       
 10314     smsg[index++]= '\0';
       
 10315     
       
 10316     //appending connmgr_bus
       
 10317     len = strlen(connect_data->connmgr_bus );
       
 10318     strcpy( smsg + index, connect_data->connmgr_bus );
       
 10319     index += len + 1;
       
 10320     
       
 10321     //appending connmgr_path
       
 10322     len = strlen(connect_data->connmgr_path );
       
 10323     strcpy( smsg + index, connect_data->connmgr_path );
       
 10324     index += len + 1;
       
 10325     
       
 10326     //appending protocol
       
 10327     len = strlen(connect_data->protocol );
       
 10328     strcpy( smsg + index, connect_data->protocol );
       
 10329     index += len + 1;
       
 10330     
       
 10331     #ifdef __WINSCW__
       
 10332     //proxy server
       
 10333     len = strlen(connect_data->proxy_data->proxy_server );
       
 10334     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 10335     index += len + 1;
       
 10336     
       
 10337     //proxy port
       
 10338     len = strlen(connect_data->proxy_data->proxy_port );
       
 10339     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 10340     index += len + 1;
       
 10341     
       
 10342     #endif
       
 10343     
       
 10344     
       
 10345     //running isoserver   
       
 10346     run_isoserver(); 
       
 10347         
       
 10348     //create message queue for send request
       
 10349     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 10350     //create message queue for response request
       
 10351     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 10352 		
       
 10353 	
       
 10354 	/* Send Message to queueOne */
       
 10355 	
       
 10356 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10357     
       
 10358     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 10359     
       
 10360     if (status < 0)
       
 10361     {
       
 10362     return_value = KErrGeneral;
       
 10363 	goto return_code;	
       
 10364     }
       
 10365     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 10366 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 10367 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 10368 	
       
 10369 	if( msg_struct->response != 1)
       
 10370     {
       
 10371     	return_value = KErrGeneral;
       
 10372 	goto return_code;
       
 10373     }
       
 10374     
       
 10375     
       
 10376     // login end
       
 10377     //fetch req..
       
 10378     for (int i= 0 ;i<3 ;i++)
       
 10379     {
       
 10380         
       
 10381     fp = fopen("c:\\fetch_contact.txt","a");
       
 10382 	do  {
       
 10383 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 10384 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10385 		fwrite(rmsg,1,status,fp);
       
 10386 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10387 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 10388 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 10389 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 10390 	fclose(fp);	
       
 10391 	
       
 10392     }
       
 10393 
       
 10394 	//fetch end
       
 10395 	//send msg copy	
       
 10396 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 10397 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10398 	index=0;
       
 10399     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10400     msgHdr->message_type = ESend_Request;	
       
 10401     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10402 	index += sizeof( message_hdr_req );
       
 10403 	
       
 10404 	//------------------------1
       
 10405     // adding recipient
       
 10406     len = strlen( "santhosh09431243.ic@gmail.com" );
       
 10407     strcpy( smsg + index, "santhosh09431243.ic@gmail.com" );
       
 10408     index += len + 1;
       
 10409     
       
 10410     smsg[index++] = '\0';
       
 10411     
       
 10412     // adding message part
       
 10413      
       
 10414     len = strlen(connect_data->msg_data->message );
       
 10415     strcpy( smsg + index, connect_data->msg_data->message );
       
 10416     index += len + 1;
       
 10417          
       
 10418     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10419     
       
 10420     do  {
       
 10421 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10422 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10423 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10424 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
 10425    
       
 10426     if ( msg_struct->response != 1)
       
 10427     {
       
 10428     	return_value = KErrGeneral;
       
 10429 	goto return_code;
       
 10430     }
       
 10431     //send msg copy	end
       
 10432     
       
 10433     
       
 10434  	
       
 10435    //EAdd_Contact_Request messge--------------------------------------------
       
 10436    
       
 10437     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10438 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10439 	index=0;
       
 10440     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10441     msgHdr->message_type = EAdd_Contact_Request;	
       
 10442     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10443 	index += sizeof( message_hdr_req );
       
 10444 	
       
 10445 	
       
 10446     // adding recipient
       
 10447     //len = strlen( "tele1236@gmail.com" );
       
 10448     //strcpy( smsg + index, "tele1236@gmail.com" );
       
 10449     //index += len + 1;
       
 10450     
       
 10451     strcpy( smsg + index, "testlm123@gmail.com" );
       
 10452     index += strlen( "testlm123@gmail.com" ) + 1;	
       
 10453     
       
 10454     smsg[index++] = '\0';
       
 10455     
       
 10456     // adding message part
       
 10457      
       
 10458     len = strlen(connect_data->msg_data->message );
       
 10459     strcpy( smsg + index, connect_data->msg_data->message );
       
 10460     index += len + 1;
       
 10461         
       
 10462     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10463     
       
 10464     do  {
       
 10465 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10466 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10467 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10468 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
 10469    
       
 10470     if ( msg_struct->response != 1)
       
 10471     {
       
 10472     	return_value = KErrGeneral;
       
 10473 	goto return_code;
       
 10474     }
       
 10475     
       
 10476     
       
 10477    // sleep( 50 );
       
 10478     //EAdd_Contact_Request message end---------------------------------------
       
 10479  
       
 10480  /*	sleep( 100 );
       
 10481  //--------------------------------Trying to add client notification----------------------
       
 10482  
       
 10483  	status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 10484     
       
 10485     if ( status < 0 )
       
 10486     {
       
 10487     return_value = KErrGeneral;
       
 10488 	goto return_code;	
       
 10489     }
       
 10490 	msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 10491 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 10492 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 10493 	if ( msg_struct->response != 1)
       
 10494     {
       
 10495     	return_value = KErrGeneral;
       
 10496 	goto return_code;
       
 10497     }
       
 10498     */
       
 10499  //--------------------------------Trying to add client end----------------------
       
 10500  
       
 10501  
       
 10502  
       
 10503      
       
 10504     //EAdd_Contact_Request messge--------------------------------------------
       
 10505    
       
 10506     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10507 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10508 	index=0;
       
 10509     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10510     msgHdr->message_type = EAdd_Contact_Request;	
       
 10511     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10512 	index += sizeof( message_hdr_req );
       
 10513 	
       
 10514 	
       
 10515     // adding recipient
       
 10516     len = strlen(connect_data->msg_data->recipient );
       
 10517     strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10518     index += len + 1;
       
 10519     
       
 10520     strcpy( smsg + index, "tele1236@gmail.com" );
       
 10521     index += strlen( "tele1236@gmail.com" ) + 1;	
       
 10522     
       
 10523      // adding recipient
       
 10524     //len = strlen(connect_data->msg_data->recipient );
       
 10525     //strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10526     //index += len + 1;
       
 10527     
       
 10528     smsg[index++] = '\0';
       
 10529     
       
 10530     // adding message part
       
 10531      
       
 10532     len = strlen(connect_data->msg_data->message );
       
 10533     strcpy( smsg + index, connect_data->msg_data->message );
       
 10534     index += len + 1;
       
 10535         
       
 10536     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10537     
       
 10538     do  {
       
 10539 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10540 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10541 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10542 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
 10543    
       
 10544     if ( msg_struct->response != 1)
       
 10545     {
       
 10546     	return_value = KErrGeneral;
       
 10547 	goto return_code;
       
 10548     }
       
 10549     
       
 10550     //EAdd_Contact_Request message end---------------------------------------
       
 10551  
       
 10552  
       
 10553     
       
 10554     //EAdd_Contact_Request -ve messge--------------------------------------------
       
 10555    
       
 10556     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10557 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10558 	index=0;
       
 10559     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10560     msgHdr->message_type = EAdd_Contact_Request;	
       
 10561     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10562 	index += sizeof( message_hdr_req );
       
 10563 	
       
 10564 	//-----------------1
       
 10565     // adding recipient
       
 10566     len = strlen(connect_data->msg_data->recipient );
       
 10567     strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10568     index += len + 1;
       
 10569     
       
 10570     strcpy( smsg + index, "tele1236@gmail.com" );
       
 10571     index += strlen( "tele1236@gmail.com" ) + 1;	
       
 10572     
       
 10573     smsg[index++] = '\0';
       
 10574     
       
 10575     // adding message part
       
 10576         
       
 10577     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10578     
       
 10579     do  {
       
 10580 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10581 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10582 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10583 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
 10584    
       
 10585     if ( msg_struct->response != 1)
       
 10586     {
       
 10587     	return_value = KErrGeneral;
       
 10588 	goto return_code;
       
 10589     }
       
 10590     
       
 10591     //-----------------2 -ve
       
 10592     index = 0;
       
 10593     index += sizeof( message_hdr_req );
       
 10594     // adding recipient
       
 10595     len = strlen(connect_data->msg_data->recipient );
       
 10596     memcpy( smsg + index, connect_data->msg_data->recipient, len );
       
 10597     index += len;
       
 10598     
       
 10599     // adding message part
       
 10600         
       
 10601     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10602     
       
 10603     do  {
       
 10604 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10605 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10606 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10607 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
 10608    
       
 10609     if ( msg_struct->response != 1)
       
 10610     {
       
 10611     	return_value = KErrGeneral;
       
 10612 	goto return_code;
       
 10613     }
       
 10614     //-----------------
       
 10615     
       
 10616     
       
 10617     //EAdd_Contact_Request -ve message end---------------------------------------
       
 10618       
       
 10619     //send messge--------------------------------------------
       
 10620    
       
 10621     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10622 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10623 	index=0;
       
 10624     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10625     msgHdr->message_type = ESend_Request;	
       
 10626     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10627 	index += sizeof( message_hdr_req );
       
 10628 	
       
 10629 	//------------------------1
       
 10630     // adding recipient
       
 10631     len = strlen( "santhosh.ic@gmail.com" );
       
 10632     strcpy( smsg + index, "santhosh.ic@gmail.com" );
       
 10633     index += len + 1;
       
 10634     
       
 10635      // adding recipient
       
 10636     len = strlen(connect_data->msg_data->recipient );
       
 10637     strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10638     index += len + 1;
       
 10639     
       
 10640     smsg[index++] = '\0';
       
 10641     
       
 10642     // adding message part
       
 10643      
       
 10644     len = strlen(connect_data->msg_data->message );
       
 10645     strcpy( smsg + index, connect_data->msg_data->message );
       
 10646     index += len + 1;
       
 10647      
       
 10648        
       
 10649     
       
 10650     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10651     
       
 10652     do  {
       
 10653 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10654 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10655 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10656 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
 10657    
       
 10658     if ( msg_struct->response != 1)
       
 10659     {
       
 10660     	return_value = KErrGeneral;
       
 10661 	goto return_code;
       
 10662     }
       
 10663     //-----------------------------------2 -ve
       
 10664     index = 0;
       
 10665     index += sizeof( message_hdr_req );
       
 10666     // adding recipient
       
 10667     for ( int i = 0; i <= 11; i++ ) 
       
 10668 	    {
       
 10669 	    len = strlen( "santhosh.ic@gmail.com" );
       
 10670 	    strcpy( smsg + index, "santhosh.ic@gmail.com" );
       
 10671 	    index += len + 1;
       
 10672 	    }
       
 10673     smsg[index++] = '\0';
       
 10674     // adding message part
       
 10675         
       
 10676     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10677     
       
 10678     do  {
       
 10679 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10680 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10681 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10682 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
 10683    
       
 10684     if ( msg_struct->response != 0)
       
 10685     {
       
 10686     	return_value = KErrGeneral;
       
 10687 	goto return_code;
       
 10688     }
       
 10689     
       
 10690     
       
 10691     //-----------------------------------3 -ve
       
 10692     index = 0;
       
 10693     index += sizeof( message_hdr_req );
       
 10694     // adding recipient
       
 10695     len = strlen(connect_data->msg_data->recipient );
       
 10696     memcpy( smsg + index, connect_data->msg_data->recipient, len );
       
 10697     index += len;
       
 10698     
       
 10699     // adding message part
       
 10700         
       
 10701     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10702     
       
 10703     do  {
       
 10704 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10705 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10706 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10707 		} while (msg_struct->hdr_req.message_type!=ESend_Request);
       
 10708    
       
 10709     if ( msg_struct->response != 0)
       
 10710     {
       
 10711     	return_value = KErrGeneral;
       
 10712 	goto return_code;
       
 10713     }
       
 10714     
       
 10715     //send message end---------------------------------------
       
 10716     
       
 10717    //EDelete_Contact_Request messge--------------------------------------------
       
 10718    
       
 10719     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10720 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10721 	index=0;
       
 10722     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10723     msgHdr->message_type = EDelete_Contact_Request;	
       
 10724     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10725 	index += sizeof( message_hdr_req );
       
 10726 	
       
 10727 	
       
 10728     // adding recipient
       
 10729     len = strlen(connect_data->msg_data->recipient );
       
 10730     strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10731     index += len + 1;
       
 10732     
       
 10733     strcpy( smsg + index, "tele1236@gmail.com" );
       
 10734     index += strlen( "tele1236@gmail.com" ) + 1;	
       
 10735     
       
 10736      // adding recipient
       
 10737     //len = strlen(connect_data->msg_data->recipient );
       
 10738     //strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10739     //index += len + 1;
       
 10740     
       
 10741     smsg[index++] = '\0';
       
 10742     
       
 10743     // adding message part
       
 10744      
       
 10745     len = strlen(connect_data->msg_data->message );
       
 10746     strcpy( smsg + index, connect_data->msg_data->message );
       
 10747     index += len + 1;
       
 10748         
       
 10749     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10750     
       
 10751     do  {
       
 10752 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10753 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10754 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10755 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
 10756    
       
 10757     if ( msg_struct->response != 0)
       
 10758     {
       
 10759     	return_value = KErrGeneral;
       
 10760 	goto return_code;
       
 10761     }
       
 10762     //--------------------delete----------------------
       
 10763     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10764 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10765 	index=0;
       
 10766     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10767     msgHdr->message_type = EDelete_Contact_Request;	
       
 10768     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10769 	index += sizeof( message_hdr_req );
       
 10770 	
       
 10771 	
       
 10772     // adding recipient
       
 10773     len = strlen(connect_data->msg_data->recipient );
       
 10774     strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10775     index += len + 1;
       
 10776     
       
 10777     strcpy( smsg + index, "rakesh.harsh@gmail.com" );
       
 10778     index += strlen( "rakesh.harsh@gmail.com" ) + 1;	
       
 10779     
       
 10780      // adding recipient
       
 10781     //len = strlen(connect_data->msg_data->recipient );
       
 10782     //strcpy( smsg + index, connect_data->msg_data->recipient );
       
 10783     //index += len + 1;
       
 10784     
       
 10785     smsg[index++] = '\0';
       
 10786     
       
 10787     // adding message part
       
 10788      
       
 10789     len = strlen(connect_data->msg_data->message );
       
 10790     strcpy( smsg + index, connect_data->msg_data->message );
       
 10791     index += len + 1;
       
 10792         
       
 10793     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10794     
       
 10795     do  {
       
 10796 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10797 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10798 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10799 		} while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
       
 10800    
       
 10801     
       
 10802 
       
 10803     //EDelete_Contact_Request message end--------------------------------------- 
       
 10804     
       
 10805     //--------------Recieve message-----------------------------------
       
 10806    /* do  {
       
 10807 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10808 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10809 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10810 		} while (msg_struct->hdr_req.message_type!=EText_Message_Receive);
       
 10811    
       
 10812     if ( msg_struct->response != 1)
       
 10813     {
       
 10814     	return_value = KErrGeneral;
       
 10815 	goto return_code;
       
 10816     }
       
 10817     do  {
       
 10818 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10819 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10820 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10821 		} while (msg_struct->hdr_req.message_type!=EText_Message_Receive);
       
 10822    
       
 10823     if ( msg_struct->response != 1)
       
 10824     {
       
 10825     	return_value = KErrGeneral;
       
 10826 	goto return_code;
       
 10827     } */   //------------------------Recieve message end---------------------
       
 10828   
       
 10829    //-------------update presence with available---------------
       
 10830    
       
 10831     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10832 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10833 	index=0;
       
 10834     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10835     msgHdr->message_type = EUpdateOwnPresence;	
       
 10836     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10837 	index += sizeof( message_hdr_req );
       
 10838 	
       
 10839 	
       
 10840     // updating availability
       
 10841     char *availability = "available";
       
 10842     memcpy( smsg + index, availability, strlen( availability ) );
       
 10843     index += strlen( availability ); 
       
 10844     
       
 10845     smsg[index++]='\0';
       
 10846     
       
 10847     //updating status text
       
 10848      char *statustext = "i m busy";
       
 10849      memcpy( smsg + index, statustext, strlen( statustext ) );
       
 10850      index += strlen( statustext ); 
       
 10851     
       
 10852        
       
 10853     
       
 10854     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10855     
       
 10856     do  {
       
 10857 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10858 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10859 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10860 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 10861    
       
 10862     if ( msg_struct->response != 1)
       
 10863     {
       
 10864     	return_value = KErrGeneral;
       
 10865 	goto return_code;
       
 10866     }
       
 10867 //  ------------------------------------------------------------------
       
 10868 
       
 10869      //-------------update presence with available---------------
       
 10870    
       
 10871     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10872 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10873 	index=0;
       
 10874     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10875     msgHdr->message_type = EUpdateOwnPresence;	
       
 10876     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10877 	index += sizeof( message_hdr_req );
       
 10878 	
       
 10879 	
       
 10880     // updating availability
       
 10881      char *availability1 = "dnd";
       
 10882     memcpy( smsg + index, availability1, strlen( availability1 ) );
       
 10883     index += strlen( availability1 ); 
       
 10884     
       
 10885     smsg[index++]='\0';
       
 10886     
       
 10887     //updating status text
       
 10888       char *statustext1 = "i m busy";
       
 10889      memcpy( smsg + index, statustext1, strlen( statustext1 ) );
       
 10890      index += strlen( statustext1 ); 
       
 10891     
       
 10892        
       
 10893     
       
 10894     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10895     
       
 10896     do  {
       
 10897 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10898 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10899 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10900 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 10901    
       
 10902     if ( msg_struct->response != 1)
       
 10903     {
       
 10904     	return_value = KErrGeneral;
       
 10905 	goto return_code;
       
 10906     }
       
 10907 //  ------------------------------------------------------------------
       
 10908 
       
 10909  //-------------update presence with available---------------
       
 10910    
       
 10911     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10912 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10913 	index=0;
       
 10914     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10915     msgHdr->message_type = EUpdateOwnPresence;	
       
 10916     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10917 	index += sizeof( message_hdr_req );
       
 10918 	
       
 10919 	
       
 10920     // updating availability
       
 10921     char *availability2 = "away";
       
 10922     memcpy( smsg + index, availability2, strlen( availability2 ) );
       
 10923     index += strlen( availability2 ); 
       
 10924     
       
 10925     smsg[index++]='\0';
       
 10926     
       
 10927     //updating status text
       
 10928      char *statustext2 = "i m busy";
       
 10929      memcpy( smsg + index, statustext2, strlen( statustext2 ) );
       
 10930      index += strlen( statustext2 ); 
       
 10931     
       
 10932        
       
 10933     
       
 10934     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10935     
       
 10936     do  {
       
 10937 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10938 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10939 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10940 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 10941    
       
 10942     if ( msg_struct->response != 1)
       
 10943     {
       
 10944     	return_value = KErrGeneral;
       
 10945 	goto return_code;
       
 10946     }
       
 10947 //  ------------------------------------------------------------------
       
 10948 
       
 10949    //----------------------------presence negative case------------------
       
 10950    
       
 10951    memset( smsg, '\0', MAX_MSG_SIZE );
       
 10952 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10953 	index=0;
       
 10954     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10955     msgHdr->message_type = EUpdateOwnPresence;	
       
 10956     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10957 	index += sizeof( message_hdr_req );
       
 10958 	
       
 10959 	
       
 10960     // updating availability with blank 
       
 10961     smsg[index++]='\0';
       
 10962     smsg[index++]='\0';
       
 10963     //smsg[index++]='\0';
       
 10964     
       
 10965     //updating status text
       
 10966     char *statustext4 = "i m not on desk";
       
 10967     memcpy( smsg + index, statustext4, strlen( statustext4 ) );
       
 10968     index += strlen( statustext4 );  
       
 10969     
       
 10970      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 10971     
       
 10972     do  {
       
 10973 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 10974 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 10975 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10976 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 10977    
       
 10978     if ( msg_struct->error_type > 0)
       
 10979     {
       
 10980     	return_value = KErrGeneral;
       
 10981 	goto return_code;
       
 10982     }
       
 10983    
       
 10984   //-------------------------1 end 
       
 10985   
       
 10986   // update 2 negative
       
 10987     memset( smsg, '\0', MAX_MSG_SIZE );
       
 10988 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 10989 	index=0;
       
 10990     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 10991     msgHdr->message_type = EUpdateOwnPresence;	
       
 10992     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 10993 	index += sizeof( message_hdr_req );
       
 10994 	
       
 10995 	
       
 10996     // updating availability
       
 10997     char *availability4 = "available";
       
 10998     memcpy( smsg + index, availability, strlen( availability4 ) );
       
 10999     index += strlen( availability4 ); 
       
 11000       
       
 11001        
       
 11002     
       
 11003      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11004     
       
 11005     do  {
       
 11006 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11007 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11008 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11009 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 11010    
       
 11011     if ( msg_struct->response != 1)
       
 11012     {
       
 11013     	return_value = KErrGeneral;
       
 11014 	goto return_code;
       
 11015     }
       
 11016     //----
       
 11017    // logout test code from server
       
 11018     index=0;
       
 11019     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11020 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11021 	
       
 11022 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11023     
       
 11024     msgHdr->message_type = ELogout_Request;
       
 11025  
       
 11026     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11027     index += sizeof( message_hdr_req );
       
 11028 
       
 11029 	
       
 11030 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11031     
       
 11032     do  {
       
 11033 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11034 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11035 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11036 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 11037    
       
 11038     if ( msg_struct->response != 1)
       
 11039     {
       
 11040     	return_value = KErrGeneral;
       
 11041 	goto return_code;
       
 11042     }
       
 11043     //killing isoserver
       
 11044     return_code:
       
 11045     index=0;
       
 11046     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11047 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11048 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11049     msgHdr->message_type = EKill_Process;
       
 11050     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11051     index += sizeof( message_hdr_req );
       
 11052 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 11053     free( msg_struct );
       
 11054     return return_value;
       
 11055     	}
       
 11056 
       
 11057  // -----------------------------------------------------------------------------
       
 11058 // Cisolationserver::UpdatePresenceWithAway
       
 11059 // Example test method function.
       
 11060 // (other items were commented in a header).
       
 11061 // -----------------------------------------------------------------------------
       
 11062 //
       
 11063 TInt Cisolationserver::UpdatePresenceWithAway( CStifItemParser& aItem )
       
 11064     {
       
 11065 
       
 11066     	
       
 11067     ConnectData  *connect_data = NULL;
       
 11068     char smsg[MAX_MSG_SIZE];
       
 11069     char rmsg[MAX_MSG_SIZE];
       
 11070     int index=0;
       
 11071     
       
 11072 		
       
 11073 	int timeout = 100;
       
 11074 	int nBytes;
       
 11075 
       
 11076     int result = 0;
       
 11077     int err = 0;
       
 11078     int status = 0;
       
 11079     FILE *fp;
       
 11080     message_hdr_req *msgHdr = NULL;  
       
 11081     message_hdr_resp* msg_struct = NULL;
       
 11082     TInt return_value = 0;
       
 11083         	// Read data from the CFG file
       
 11084 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 11085 		{
       
 11086 		iLog->Log ( _L ( "read_data failed" ) );
       
 11087 		free_data ( connect_data );
       
 11088 		return_value = KErrGeneral;
       
 11089 		goto return_code;
       
 11090 		}
       
 11091 	//request formation	
       
 11092 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 11093 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11094 	
       
 11095 	//message header use
       
 11096 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 11097     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11098     
       
 11099     msgHdr->message_type = ELogin_Request;
       
 11100  
       
 11101     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11102     index += sizeof( message_hdr_req );
       
 11103     
       
 11104     int len = strlen(connect_data->username);
       
 11105     strcpy( smsg + index, connect_data->username );
       
 11106     index += len + 1;
       
 11107     
       
 11108     //appending password
       
 11109     
       
 11110     len = strlen(connect_data->password );
       
 11111     strcpy( smsg + index, connect_data->password );
       
 11112     index += len + 1;
       
 11113 
       
 11114     //appending server name
       
 11115     
       
 11116     len = strlen(connect_data->server );
       
 11117     strcpy( smsg + index, connect_data->server );
       
 11118     index += len + 1;
       
 11119     
       
 11120     //appending resource
       
 11121     len = strlen(connect_data->resource );
       
 11122     strcpy( smsg + index, connect_data->resource );
       
 11123     index += len + 1;
       
 11124     
       
 11125     //appending ssl
       
 11126     smsg[index++]= '1';
       
 11127     smsg[index++]= '\0';
       
 11128     
       
 11129     //appending server port
       
 11130     len = strlen(connect_data->port );
       
 11131     strcpy( smsg + index, connect_data->port );
       
 11132     index += len + 1;
       
 11133     
       
 11134     // appending IAP id
       
 11135     
       
 11136     smsg[index++]= '1';
       
 11137     smsg[index++]= '\0';
       
 11138     
       
 11139     //appending connmgr_bus
       
 11140     len = strlen(connect_data->connmgr_bus );
       
 11141     strcpy( smsg + index, connect_data->connmgr_bus );
       
 11142     index += len + 1;
       
 11143     
       
 11144     //appending connmgr_path
       
 11145     len = strlen(connect_data->connmgr_path );
       
 11146     strcpy( smsg + index, connect_data->connmgr_path );
       
 11147     index += len + 1;
       
 11148     
       
 11149     //appending protocol
       
 11150     len = strlen(connect_data->protocol );
       
 11151     strcpy( smsg + index, connect_data->protocol );
       
 11152     index += len + 1;
       
 11153     
       
 11154     #ifdef __WINSCW__
       
 11155     //proxy server
       
 11156     len = strlen(connect_data->proxy_data->proxy_server );
       
 11157     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 11158     index += len + 1;
       
 11159     
       
 11160     //proxy port
       
 11161     len = strlen(connect_data->proxy_data->proxy_port );
       
 11162     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 11163     index += len + 1;
       
 11164     
       
 11165     #endif
       
 11166     //running isoserver   
       
 11167     run_isoserver(); 
       
 11168     //create message queue for send request
       
 11169     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11170     //create message queue for response request
       
 11171     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11172 		
       
 11173 
       
 11174 	/* Send Message to queueOne */
       
 11175 	
       
 11176 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11177     
       
 11178     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 11179     
       
 11180     if (status < 0)
       
 11181     {
       
 11182     return_value = KErrGeneral;
       
 11183 	goto return_code;	
       
 11184     }
       
 11185     
       
 11186  
       
 11187     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 11188 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 11189 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 11190 	
       
 11191 	if( msg_struct->response != 1)
       
 11192     {
       
 11193     	return_value = KErrGeneral;
       
 11194 	goto return_code;
       
 11195     }
       
 11196     
       
 11197     
       
 11198     // login end
       
 11199     //fetch req..
       
 11200     for (int i= 0 ;i<3 ;i++)
       
 11201     {
       
 11202         
       
 11203     fp = fopen("c:\\fetch_contact.txt","a");
       
 11204 	do  {
       
 11205 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 11206 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11207 		fwrite(rmsg,1,status,fp);
       
 11208 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11209 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 11210 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 11211 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 11212 	fclose(fp);	
       
 11213 	
       
 11214     }
       
 11215 
       
 11216 	//fetch end
       
 11217 	//fetch end
       
 11218 	
       
 11219 	 //-------------update presence---------------
       
 11220    
       
 11221     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11222 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11223 	index=0;
       
 11224     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11225     msgHdr->message_type = EUpdateOwnPresence;	
       
 11226     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11227 	index += sizeof( message_hdr_req );
       
 11228 	
       
 11229 	
       
 11230     // updating availability
       
 11231     char *availability = "away";
       
 11232     memcpy( smsg + index, availability, strlen( availability ) );
       
 11233     index += strlen( availability ); 
       
 11234     
       
 11235     smsg[index++]='\0';
       
 11236     
       
 11237     //updating status text
       
 11238      char *statustext = "i m busy";
       
 11239      memcpy( smsg + index, statustext, strlen( statustext ) );
       
 11240      index += strlen( statustext ); 
       
 11241     
       
 11242        
       
 11243     
       
 11244     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11245     
       
 11246     do  {
       
 11247 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11248 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11249 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11250 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 11251    
       
 11252     if ( msg_struct->response != 1)
       
 11253     {
       
 11254     	return_value = KErrGeneral;
       
 11255 	goto return_code;
       
 11256     }
       
 11257     
       
 11258     // logout test code from server
       
 11259     index=0;
       
 11260     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11261 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11262 	
       
 11263 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11264     
       
 11265     msgHdr->message_type = ELogout_Request;
       
 11266  
       
 11267     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11268     index += sizeof( message_hdr_req );
       
 11269 
       
 11270 	
       
 11271 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11272     
       
 11273     do  {
       
 11274 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11275 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11276 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11277 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 11278    
       
 11279     if ( msg_struct->response != 1)
       
 11280     {
       
 11281     	return_value = KErrGeneral;
       
 11282 	goto return_code;
       
 11283     }
       
 11284     //killing isoserver
       
 11285     return_code:
       
 11286     index=0;
       
 11287     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11288 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11289 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11290     msgHdr->message_type = EKill_Process;
       
 11291     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11292     index += sizeof( message_hdr_req );
       
 11293 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 11294     free( msg_struct );
       
 11295     return return_value;
       
 11296     }
       
 11297 
       
 11298   // -----------------------------------------------------------------------------
       
 11299 // Cisolationserver::UpdatePresenceWithAway
       
 11300 // Example test method function.
       
 11301 // (other items were commented in a header).
       
 11302 // -----------------------------------------------------------------------------
       
 11303 //
       
 11304 TInt Cisolationserver::UpdatePresenceWithAvailable( CStifItemParser& aItem )
       
 11305     {
       
 11306 
       
 11307     	
       
 11308     ConnectData  *connect_data = NULL;
       
 11309     char smsg[MAX_MSG_SIZE];
       
 11310     char rmsg[MAX_MSG_SIZE];
       
 11311     int index=0;
       
 11312     
       
 11313 		
       
 11314 	int timeout = 100;
       
 11315 	int nBytes;
       
 11316 
       
 11317     int result = 0;
       
 11318     int err = 0;
       
 11319     int status = 0;
       
 11320     FILE *fp;
       
 11321     message_hdr_req *msgHdr = NULL;  
       
 11322     message_hdr_resp* msg_struct = NULL;
       
 11323     TInt return_value = 0;
       
 11324         	// Read data from the CFG file
       
 11325 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 11326 		{
       
 11327 		iLog->Log ( _L ( "read_data failed" ) );
       
 11328 		free_data ( connect_data );
       
 11329 		return_value = KErrGeneral;
       
 11330 		goto return_code;
       
 11331 		}
       
 11332 	//request formation	
       
 11333 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 11334 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11335 	
       
 11336 	//message header use
       
 11337 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 11338     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11339     
       
 11340     msgHdr->message_type = ELogin_Request;
       
 11341  
       
 11342     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11343     index += sizeof( message_hdr_req );
       
 11344     
       
 11345     int len = strlen(connect_data->username);
       
 11346     strcpy( smsg + index, connect_data->username );
       
 11347     index += len + 1;
       
 11348     
       
 11349     //appending password
       
 11350     
       
 11351     len = strlen(connect_data->password );
       
 11352     strcpy( smsg + index, connect_data->password );
       
 11353     index += len + 1;
       
 11354 
       
 11355     //appending server name
       
 11356     
       
 11357     len = strlen(connect_data->server );
       
 11358     strcpy( smsg + index, connect_data->server );
       
 11359     index += len + 1;
       
 11360     
       
 11361     //appending resource
       
 11362     len = strlen(connect_data->resource );
       
 11363     strcpy( smsg + index, connect_data->resource );
       
 11364     index += len + 1;
       
 11365     
       
 11366     //appending ssl
       
 11367     smsg[index++]= '1';
       
 11368     smsg[index++]= '\0';
       
 11369     
       
 11370     //appending server port
       
 11371     len = strlen(connect_data->port );
       
 11372     strcpy( smsg + index, connect_data->port );
       
 11373     index += len + 1;
       
 11374     
       
 11375     // appending IAP id
       
 11376     
       
 11377     smsg[index++]= '1';
       
 11378     smsg[index++]= '\0';
       
 11379     
       
 11380     //appending connmgr_bus
       
 11381     len = strlen(connect_data->connmgr_bus );
       
 11382     strcpy( smsg + index, connect_data->connmgr_bus );
       
 11383     index += len + 1;
       
 11384     
       
 11385     //appending connmgr_path
       
 11386     len = strlen(connect_data->connmgr_path );
       
 11387     strcpy( smsg + index, connect_data->connmgr_path );
       
 11388     index += len + 1;
       
 11389     
       
 11390     //appending protocol
       
 11391     len = strlen(connect_data->protocol );
       
 11392     strcpy( smsg + index, connect_data->protocol );
       
 11393     index += len + 1;
       
 11394     
       
 11395     #ifdef __WINSCW__
       
 11396     //proxy server
       
 11397     len = strlen(connect_data->proxy_data->proxy_server );
       
 11398     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 11399     index += len + 1;
       
 11400     
       
 11401     //proxy port
       
 11402     len = strlen(connect_data->proxy_data->proxy_port );
       
 11403     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 11404     index += len + 1;
       
 11405     
       
 11406     #endif
       
 11407     //running isoserver   
       
 11408     run_isoserver(); 
       
 11409     //create message queue for send request
       
 11410     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11411     //create message queue for response request
       
 11412     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11413 		
       
 11414 
       
 11415 	/* Send Message to queueOne */
       
 11416 	
       
 11417 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11418     
       
 11419     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 11420     
       
 11421     if (status < 0)
       
 11422     {
       
 11423     return_value = KErrGeneral;
       
 11424 	goto return_code;	
       
 11425     }
       
 11426     
       
 11427  
       
 11428     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 11429 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 11430 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 11431 	
       
 11432 	if( msg_struct->response != 1)
       
 11433     {
       
 11434     	return_value = KErrGeneral;
       
 11435 	goto return_code;
       
 11436     }
       
 11437     
       
 11438     
       
 11439     // login end
       
 11440     //fetch req..
       
 11441     for (int i= 0 ;i<3 ;i++)
       
 11442     {
       
 11443         
       
 11444     fp = fopen("c:\\fetch_contact.txt","a");
       
 11445 	do  {
       
 11446 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 11447 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11448 		fwrite(rmsg,1,status,fp);
       
 11449 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11450 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 11451 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 11452 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 11453 	fclose(fp);	
       
 11454 	
       
 11455     }
       
 11456 
       
 11457 	//fetch end
       
 11458 	//fetch end
       
 11459 	
       
 11460 	 //-------------update presence---------------
       
 11461    
       
 11462     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11463 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11464 	index=0;
       
 11465     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11466     msgHdr->message_type = EUpdateOwnPresence;	
       
 11467     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11468 	index += sizeof( message_hdr_req );
       
 11469 	
       
 11470 	
       
 11471     // updating availability
       
 11472     char *availability = "available";
       
 11473     memcpy( smsg + index, availability, strlen( availability ) );
       
 11474     index += strlen( availability ); 
       
 11475     smsg[index++]='\0';
       
 11476     
       
 11477     //updating status text
       
 11478     char *statustext = "there is difference between thought and execution";
       
 11479     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 11480     index += strlen( statustext ); 
       
 11481     
       
 11482        
       
 11483     
       
 11484     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11485     
       
 11486     do  {
       
 11487 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11488 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11489 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11490 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 11491    
       
 11492     if ( msg_struct->response != 1)
       
 11493     {
       
 11494     	return_value = KErrGeneral;
       
 11495 	goto return_code;
       
 11496     }
       
 11497     // logout test code from server
       
 11498     index=0;
       
 11499     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11500 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11501 	
       
 11502 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11503     
       
 11504     msgHdr->message_type = ELogout_Request;
       
 11505  
       
 11506     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11507     index += sizeof( message_hdr_req );
       
 11508 
       
 11509 	
       
 11510 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11511      do  {
       
 11512 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11513 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11514 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11515 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 11516    
       
 11517      if ( msg_struct->response != 1)
       
 11518     {
       
 11519     	return_value = KErrGeneral;
       
 11520 	goto return_code;
       
 11521     }
       
 11522     //killing isoserver
       
 11523     return_code:
       
 11524     index=0;
       
 11525     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11526 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11527 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11528     msgHdr->message_type = EKill_Process;
       
 11529     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11530     index += sizeof( message_hdr_req );
       
 11531 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 11532     free( msg_struct );
       
 11533     return return_value;
       
 11534     }
       
 11535 
       
 11536 // -----------------------------------------------------------------------------
       
 11537 // Cisolationserver::UpdatePresenceWithDnd
       
 11538 // Example test method function.
       
 11539 // (other items were commented in a header).
       
 11540 // -----------------------------------------------------------------------------
       
 11541 //
       
 11542 TInt Cisolationserver::UpdatePresenceWithDnd( CStifItemParser& aItem )
       
 11543     {
       
 11544 
       
 11545     	
       
 11546     ConnectData  *connect_data = NULL;
       
 11547     char smsg[MAX_MSG_SIZE];
       
 11548     char rmsg[MAX_MSG_SIZE];
       
 11549     int index=0;
       
 11550     
       
 11551 		
       
 11552 	int timeout = 100;
       
 11553 	int nBytes;
       
 11554 
       
 11555     int result = 0;
       
 11556     int err = 0;
       
 11557     int status = 0;
       
 11558     FILE *fp;
       
 11559     message_hdr_req *msgHdr = NULL;  
       
 11560     message_hdr_resp* msg_struct = NULL;
       
 11561     TInt return_value = 0;
       
 11562         	// Read data from the CFG file
       
 11563 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 11564 		{
       
 11565 		iLog->Log ( _L ( "read_data failed" ) );
       
 11566 		free_data ( connect_data );
       
 11567 		return_value = KErrGeneral;
       
 11568 		goto return_code;
       
 11569 		}
       
 11570 	//request formation	
       
 11571 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 11572 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11573 	
       
 11574 	//message header use
       
 11575 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 11576     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11577     
       
 11578     msgHdr->message_type = ELogin_Request;
       
 11579  
       
 11580     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11581     index += sizeof( message_hdr_req );
       
 11582     
       
 11583     int len = strlen(connect_data->username);
       
 11584     strcpy( smsg + index, connect_data->username );
       
 11585     index += len + 1;
       
 11586     
       
 11587     //appending password
       
 11588     
       
 11589     len = strlen(connect_data->password );
       
 11590     strcpy( smsg + index, connect_data->password );
       
 11591     index += len + 1;
       
 11592 
       
 11593     //appending server name
       
 11594     
       
 11595     len = strlen(connect_data->server );
       
 11596     strcpy( smsg + index, connect_data->server );
       
 11597     index += len + 1;
       
 11598     
       
 11599     //appending resource
       
 11600     len = strlen(connect_data->resource );
       
 11601     strcpy( smsg + index, connect_data->resource );
       
 11602     index += len + 1;
       
 11603     
       
 11604     //appending ssl
       
 11605     smsg[index++]= '1';
       
 11606     smsg[index++]= '\0';
       
 11607     
       
 11608     //appending server port
       
 11609     len = strlen(connect_data->port );
       
 11610     strcpy( smsg + index, connect_data->port );
       
 11611     index += len + 1;
       
 11612     
       
 11613     // appending IAP id
       
 11614     
       
 11615     smsg[index++]= '1';
       
 11616     smsg[index++]= '\0';
       
 11617     
       
 11618     //appending connmgr_bus
       
 11619     len = strlen(connect_data->connmgr_bus );
       
 11620     strcpy( smsg + index, connect_data->connmgr_bus );
       
 11621     index += len + 1;
       
 11622     
       
 11623     //appending connmgr_path
       
 11624     len = strlen(connect_data->connmgr_path );
       
 11625     strcpy( smsg + index, connect_data->connmgr_path );
       
 11626     index += len + 1;
       
 11627     
       
 11628     //appending protocol
       
 11629     len = strlen(connect_data->protocol );
       
 11630     strcpy( smsg + index, connect_data->protocol );
       
 11631     index += len + 1;
       
 11632     
       
 11633     #ifdef __WINSCW__
       
 11634     //proxy server
       
 11635     len = strlen(connect_data->proxy_data->proxy_server );
       
 11636     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 11637     index += len + 1;
       
 11638     
       
 11639     //proxy port
       
 11640     len = strlen(connect_data->proxy_data->proxy_port );
       
 11641     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 11642     index += len + 1;
       
 11643     
       
 11644     #endif
       
 11645     //running isoserver   
       
 11646     run_isoserver(); 
       
 11647      //create message queue for send request
       
 11648     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11649     //create message queue for response request
       
 11650     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11651 		
       
 11652 
       
 11653 	/* Send Message to queueOne */
       
 11654 	
       
 11655 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11656     
       
 11657     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 11658     
       
 11659     if (status < 0)
       
 11660     {
       
 11661     return_value = KErrGeneral;
       
 11662 	goto return_code;	
       
 11663     }
       
 11664     
       
 11665  
       
 11666     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 11667 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 11668 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 11669 	
       
 11670 	if( msg_struct->response != 1)
       
 11671     {
       
 11672     	return_value = KErrGeneral;
       
 11673 	goto return_code;
       
 11674     }
       
 11675     
       
 11676     
       
 11677     // login end
       
 11678     //fetch req..
       
 11679     for (int i= 0 ;i<3 ;i++)
       
 11680     {
       
 11681         
       
 11682     fp = fopen("c:\\fetch_contact.txt","a");
       
 11683 	do  {
       
 11684 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 11685 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11686 		fwrite(rmsg,1,status,fp);
       
 11687 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11688 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 11689 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 11690 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 11691 	fclose(fp);	
       
 11692 	
       
 11693     }
       
 11694 
       
 11695 	//fetch end
       
 11696 	//fetch end
       
 11697 	
       
 11698 	 //-------------update presence---------------
       
 11699    
       
 11700     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11701 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11702 	index=0;
       
 11703     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11704     msgHdr->message_type = EUpdateOwnPresence;	
       
 11705     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11706 	index += sizeof( message_hdr_req );
       
 11707 	
       
 11708 	
       
 11709     // updating availability
       
 11710     char *availability = "dnd";
       
 11711     memcpy( smsg + index, availability, strlen( availability ) );
       
 11712     index += strlen( availability ); 
       
 11713     smsg[index++]='\0';
       
 11714     
       
 11715     //updating status text
       
 11716     char *statustext = "i m busy";
       
 11717     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 11718     index += strlen( statustext ); 
       
 11719     
       
 11720        
       
 11721     
       
 11722      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11723     
       
 11724     do  {
       
 11725 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11726 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11727 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11728 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 11729    
       
 11730     if ( msg_struct->response != 1)
       
 11731     {
       
 11732     	return_value = KErrGeneral;
       
 11733 	goto return_code;
       
 11734     }
       
 11735     
       
 11736     // logout test code from server
       
 11737     index=0;
       
 11738     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11739 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11740 	
       
 11741 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11742     
       
 11743     msgHdr->message_type = ELogout_Request;
       
 11744  
       
 11745     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11746     index += sizeof( message_hdr_req );
       
 11747 
       
 11748 	
       
 11749 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11750      do  {
       
 11751 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11752 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11753 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11754 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 11755    
       
 11756      if ( msg_struct->response != 1)
       
 11757     {
       
 11758     	return_value = KErrGeneral;
       
 11759 	goto return_code;
       
 11760     }
       
 11761     
       
 11762     //killing isoserver
       
 11763     return_code:
       
 11764     index=0;
       
 11765     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11766 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11767 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11768     msgHdr->message_type = EKill_Process;
       
 11769     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11770     index += sizeof( message_hdr_req );
       
 11771 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 11772     free( msg_struct );
       
 11773     return return_value;
       
 11774     }
       
 11775 
       
 11776 // -----------------------------------------------------------------------------
       
 11777 // Cisolationserver::UpdatePresenceWithDnd
       
 11778 // Example test method function.
       
 11779 // (other items were commented in a header).
       
 11780 // -----------------------------------------------------------------------------
       
 11781 //
       
 11782 TInt Cisolationserver::UpdatePresenceMultipleTimeInSameSession( CStifItemParser& aItem )
       
 11783     {
       
 11784 
       
 11785     	
       
 11786     ConnectData  *connect_data = NULL;
       
 11787     char smsg[MAX_MSG_SIZE];
       
 11788     char rmsg[MAX_MSG_SIZE];
       
 11789     int index=0;
       
 11790     
       
 11791 		
       
 11792 	int timeout = 100;
       
 11793 	int nBytes;
       
 11794 
       
 11795     int result = 0;
       
 11796     int err = 0;
       
 11797     int status = 0;
       
 11798     FILE *fp;
       
 11799     message_hdr_req *msgHdr = NULL;  
       
 11800     message_hdr_resp* msg_struct = NULL;
       
 11801     TInt return_value = 0;
       
 11802         	// Read data from the CFG file
       
 11803 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 11804 		{
       
 11805 		iLog->Log ( _L ( "read_data failed" ) );
       
 11806 		free_data ( connect_data );
       
 11807 		return_value = KErrGeneral;
       
 11808 		goto return_code;
       
 11809 		}
       
 11810 	//request formation	
       
 11811 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 11812 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11813 	
       
 11814 	//message header use
       
 11815 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 11816     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11817     
       
 11818     msgHdr->message_type = ELogin_Request;
       
 11819  
       
 11820     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11821     index += sizeof( message_hdr_req );
       
 11822     
       
 11823     int len = strlen(connect_data->username);
       
 11824     strcpy( smsg + index, connect_data->username );
       
 11825     index += len + 1;
       
 11826     
       
 11827     //appending password
       
 11828     
       
 11829     len = strlen(connect_data->password );
       
 11830     strcpy( smsg + index, connect_data->password );
       
 11831     index += len + 1;
       
 11832 
       
 11833     //appending server name
       
 11834     
       
 11835     len = strlen(connect_data->server );
       
 11836     strcpy( smsg + index, connect_data->server );
       
 11837     index += len + 1;
       
 11838     
       
 11839     //appending resource
       
 11840     len = strlen(connect_data->resource );
       
 11841     strcpy( smsg + index, connect_data->resource );
       
 11842     index += len + 1;
       
 11843     
       
 11844     //appending ssl
       
 11845     smsg[index++]= '1';
       
 11846     smsg[index++]= '\0';
       
 11847     
       
 11848     //appending server port
       
 11849     len = strlen(connect_data->port );
       
 11850     strcpy( smsg + index, connect_data->port );
       
 11851     index += len + 1;
       
 11852     
       
 11853     // appending IAP id
       
 11854     
       
 11855     smsg[index++]= '1';
       
 11856     smsg[index++]= '\0';
       
 11857     
       
 11858     //appending connmgr_bus
       
 11859     len = strlen(connect_data->connmgr_bus );
       
 11860     strcpy( smsg + index, connect_data->connmgr_bus );
       
 11861     index += len + 1;
       
 11862     
       
 11863     //appending connmgr_path
       
 11864     len = strlen(connect_data->connmgr_path );
       
 11865     strcpy( smsg + index, connect_data->connmgr_path );
       
 11866     index += len + 1;
       
 11867     
       
 11868     //appending protocol
       
 11869     len = strlen(connect_data->protocol );
       
 11870     strcpy( smsg + index, connect_data->protocol );
       
 11871     index += len + 1;
       
 11872     
       
 11873     #ifdef __WINSCW__
       
 11874     //proxy server
       
 11875     len = strlen(connect_data->proxy_data->proxy_server );
       
 11876     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 11877     index += len + 1;
       
 11878     
       
 11879     //proxy port
       
 11880     len = strlen(connect_data->proxy_data->proxy_port );
       
 11881     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 11882     index += len + 1;
       
 11883     
       
 11884     #endif
       
 11885     //running isoserver   
       
 11886     run_isoserver(); 
       
 11887     //create message queue for send request
       
 11888     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11889     //create message queue for response request
       
 11890     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 11891 		
       
 11892 
       
 11893 	/* Send Message to queueOne */
       
 11894 	
       
 11895 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11896     
       
 11897     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 11898     
       
 11899     if (status < 0)
       
 11900     {
       
 11901     return_value = KErrGeneral;
       
 11902 	goto return_code;	
       
 11903     }
       
 11904     
       
 11905  
       
 11906     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 11907 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 11908 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 11909 	
       
 11910 	if( msg_struct->response != 1)
       
 11911     {
       
 11912     	return_value = KErrGeneral;
       
 11913 	goto return_code;
       
 11914     }
       
 11915     
       
 11916     
       
 11917     // login end
       
 11918     //fetch req..
       
 11919     for (int i= 0 ;i<3 ;i++)
       
 11920     {
       
 11921         
       
 11922     fp = fopen("c:\\fetch_contact.txt","a");
       
 11923 	do  {
       
 11924 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 11925 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11926 		fwrite(rmsg,1,status,fp);
       
 11927 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11928 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 11929 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 11930 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 11931 	fclose(fp);	
       
 11932 	
       
 11933     }
       
 11934 
       
 11935 	//fetch end
       
 11936 	//fetch end
       
 11937 	
       
 11938 	 //-------------update presence---------------
       
 11939    
       
 11940     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11941 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11942 	index=0;
       
 11943     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11944     msgHdr->message_type = EUpdateOwnPresence;	
       
 11945     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11946 	index += sizeof( message_hdr_req );
       
 11947 	
       
 11948 	
       
 11949     // updating availability
       
 11950     char *availability = "dnd";
       
 11951     memcpy( smsg + index, availability, strlen( availability ) );
       
 11952     index += strlen( availability ); 
       
 11953     smsg[index++]='\0';
       
 11954     
       
 11955    //updating status text
       
 11956     char *statustext = "i m busy";
       
 11957     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 11958     index += strlen( statustext ); 
       
 11959     
       
 11960        
       
 11961     
       
 11962      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 11963     
       
 11964     do  {
       
 11965 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 11966 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 11967 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11968 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 11969    
       
 11970     if ( msg_struct->response != 1)
       
 11971     {
       
 11972     return_value = KErrGeneral;
       
 11973 	goto return_code;
       
 11974     }
       
 11975     	 //-------------update presence 2nd time---------------
       
 11976    
       
 11977     memset( smsg, '\0', MAX_MSG_SIZE );
       
 11978 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 11979 	index=0;
       
 11980     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 11981     msgHdr->message_type = EUpdateOwnPresence;	
       
 11982     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 11983 	index += sizeof( message_hdr_req );
       
 11984 	
       
 11985 	
       
 11986     // updating availability
       
 11987     char *availability1 = "away";
       
 11988     memcpy( smsg + index, availability1, strlen( availability1 ) );
       
 11989     index += strlen( availability1 ); 
       
 11990     smsg[index++]='\0';
       
 11991     
       
 11992    //updating status text
       
 11993     char *statustext1 = "i m not on desk";
       
 11994     memcpy( smsg + index, statustext1, strlen( statustext1 ) );
       
 11995     index += strlen( statustext1 ); 
       
 11996     
       
 11997        
       
 11998     
       
 11999     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12000     
       
 12001     do  {
       
 12002 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12003 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12004 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12005 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 12006    
       
 12007     if ( msg_struct->response != 1)
       
 12008     {
       
 12009     return_value = KErrGeneral;
       
 12010 	goto return_code;
       
 12011     }
       
 12012     
       
 12013 
       
 12014    // logout test code from server
       
 12015     index=0;
       
 12016     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12017 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12018 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12019     msgHdr->message_type = ELogout_Request;
       
 12020     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12021     index += sizeof( message_hdr_req );
       
 12022 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12023      do  {
       
 12024 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12025 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12026 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12027 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 12028    
       
 12029     if ( msg_struct->response != 1)
       
 12030     {
       
 12031     return_value = KErrGeneral;
       
 12032 	goto return_code;
       
 12033     }
       
 12034     //killing isoserver
       
 12035     return_code:
       
 12036     index=0;
       
 12037     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12038 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12039 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12040     msgHdr->message_type = EKill_Process;
       
 12041     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12042     index += sizeof( message_hdr_req );
       
 12043 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 12044     free( msg_struct );
       
 12045     return return_value;
       
 12046     }
       
 12047 // -----------------------------------------------------------------------------
       
 12048 // Cisolationserver::UpdatePresenceWithDnd
       
 12049 // Example test method function.
       
 12050 // (other items were commented in a header).
       
 12051 // -----------------------------------------------------------------------------
       
 12052 //
       
 12053 TInt Cisolationserver::UpdateOnlyStatusText( CStifItemParser& aItem )
       
 12054     {
       
 12055 
       
 12056     	
       
 12057     ConnectData  *connect_data = NULL;
       
 12058     char smsg[MAX_MSG_SIZE];
       
 12059     char rmsg[MAX_MSG_SIZE];
       
 12060     int index=0;
       
 12061     
       
 12062 		
       
 12063 	int timeout = 100;
       
 12064 	int nBytes;
       
 12065 
       
 12066     int result = 0;
       
 12067     int err = 0;
       
 12068     int status = 0;
       
 12069     FILE *fp;
       
 12070     message_hdr_req *msgHdr = NULL;  
       
 12071     message_hdr_resp* msg_struct = NULL;
       
 12072     TInt return_value = 0;
       
 12073         	// Read data from the CFG file
       
 12074 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 12075 		{
       
 12076 		iLog->Log ( _L ( "read_data failed" ) );
       
 12077 		free_data ( connect_data );
       
 12078 		return_value = KErrGeneral;
       
 12079 		goto return_code;
       
 12080 		}
       
 12081 	//request formation	
       
 12082 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 12083 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12084 	
       
 12085 	//message header use
       
 12086 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 12087     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12088     
       
 12089     msgHdr->message_type = ELogin_Request;
       
 12090  
       
 12091     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12092     index += sizeof( message_hdr_req );
       
 12093     
       
 12094     int len = strlen(connect_data->username);
       
 12095     strcpy( smsg + index, connect_data->username );
       
 12096     index += len + 1;
       
 12097     
       
 12098     //appending password
       
 12099     
       
 12100     len = strlen(connect_data->password );
       
 12101     strcpy( smsg + index, connect_data->password );
       
 12102     index += len + 1;
       
 12103 
       
 12104     //appending server name
       
 12105     
       
 12106     len = strlen(connect_data->server );
       
 12107     strcpy( smsg + index, connect_data->server );
       
 12108     index += len + 1;
       
 12109     
       
 12110     //appending resource
       
 12111     len = strlen(connect_data->resource );
       
 12112     strcpy( smsg + index, connect_data->resource );
       
 12113     index += len + 1;
       
 12114     
       
 12115     //appending ssl
       
 12116     smsg[index++]= '1';
       
 12117     smsg[index++]= '\0';
       
 12118     
       
 12119     //appending server port
       
 12120     len = strlen(connect_data->port );
       
 12121     strcpy( smsg + index, connect_data->port );
       
 12122     index += len + 1;
       
 12123     
       
 12124     // appending IAP id
       
 12125     
       
 12126     smsg[index++]= '1';
       
 12127     smsg[index++]= '\0';
       
 12128     
       
 12129     //appending connmgr_bus
       
 12130     len = strlen(connect_data->connmgr_bus );
       
 12131     strcpy( smsg + index, connect_data->connmgr_bus );
       
 12132     index += len + 1;
       
 12133     
       
 12134     //appending connmgr_path
       
 12135     len = strlen(connect_data->connmgr_path );
       
 12136     strcpy( smsg + index, connect_data->connmgr_path );
       
 12137     index += len + 1;
       
 12138     
       
 12139     //appending protocol
       
 12140     len = strlen(connect_data->protocol );
       
 12141     strcpy( smsg + index, connect_data->protocol );
       
 12142     index += len + 1;
       
 12143     
       
 12144     #ifdef __WINSCW__
       
 12145     //proxy server
       
 12146     len = strlen(connect_data->proxy_data->proxy_server );
       
 12147     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 12148     index += len + 1;
       
 12149     
       
 12150     //proxy port
       
 12151     len = strlen(connect_data->proxy_data->proxy_port );
       
 12152     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 12153     index += len + 1;
       
 12154     
       
 12155     #endif
       
 12156     //running isoserver   
       
 12157     run_isoserver(); 
       
 12158     //create message queue for send request
       
 12159     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12160     //create message queue for response request
       
 12161     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12162 		
       
 12163 
       
 12164 	/* Send Message to queueOne */
       
 12165 	
       
 12166 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12167     
       
 12168     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 12169     
       
 12170     if (status < 0)
       
 12171     {
       
 12172     return_value = KErrGeneral;
       
 12173 	goto return_code;	
       
 12174     }
       
 12175     
       
 12176  
       
 12177     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 12178 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 12179 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 12180 	
       
 12181 	if( msg_struct->response != 1)
       
 12182     {
       
 12183     	return_value = KErrGeneral;
       
 12184 	goto return_code;
       
 12185     }
       
 12186     
       
 12187     
       
 12188     // login end
       
 12189     //fetch req..
       
 12190     for (int i= 0 ;i<3 ;i++)
       
 12191     {
       
 12192         
       
 12193     fp = fopen("c:\\fetch_contact.txt","a");
       
 12194 	do  {
       
 12195 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 12196 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12197 		fwrite(rmsg,1,status,fp);
       
 12198 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12199 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 12200 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 12201 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 12202 	fclose(fp);	
       
 12203 	
       
 12204     }
       
 12205 
       
 12206 	//fetch end
       
 12207 	
       
 12208 	 //-------------update presence---------------
       
 12209    
       
 12210     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12211 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12212 	index=0;
       
 12213     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12214     msgHdr->message_type = EUpdateOwnPresence;	
       
 12215     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12216 	index += sizeof( message_hdr_req );
       
 12217 	
       
 12218 	
       
 12219     // updating availability with blank 
       
 12220     smsg[index++]='\0';
       
 12221     smsg[index++]='\0';
       
 12222     //smsg[index++]='\0';
       
 12223     
       
 12224     //updating status text
       
 12225     char *statustext = "i m not on desk";
       
 12226     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 12227     index += strlen( statustext );  
       
 12228     
       
 12229      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12230     
       
 12231     do  {
       
 12232 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12233 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12234 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12235 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 12236    
       
 12237     if ( msg_struct->error_type > 0)
       
 12238     {
       
 12239     	return_value = KErrGeneral;
       
 12240 	goto return_code;
       
 12241     }
       
 12242     
       
 12243     // logout test code from server
       
 12244     index=0;
       
 12245     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12246 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12247 	
       
 12248 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12249     
       
 12250     msgHdr->message_type = ELogout_Request;
       
 12251  
       
 12252     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12253     index += sizeof( message_hdr_req );
       
 12254 
       
 12255 	
       
 12256 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12257      do  {
       
 12258 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12259 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12260 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12261 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 12262    
       
 12263      if ( msg_struct->response != 1)
       
 12264     {
       
 12265     	return_value = KErrGeneral;
       
 12266 	goto return_code;
       
 12267     }
       
 12268     //killing isoserver
       
 12269     return_code:
       
 12270     index=0;
       
 12271     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12272 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12273 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12274     msgHdr->message_type = EKill_Process;
       
 12275     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12276     index += sizeof( message_hdr_req );
       
 12277 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 12278     free( msg_struct );
       
 12279     return return_value;
       
 12280     }
       
 12281 
       
 12282  // -----------------------------------------------------------------------------
       
 12283 // Cisolationserver::UpdatePresenceWithAway
       
 12284 // Example test method function.
       
 12285 // (other items were commented in a header).
       
 12286 // -----------------------------------------------------------------------------
       
 12287 //
       
 12288 TInt Cisolationserver::UpdateOnlyUserAvailability( CStifItemParser& aItem )
       
 12289     {
       
 12290 
       
 12291     	
       
 12292     ConnectData  *connect_data = NULL;
       
 12293     char smsg[MAX_MSG_SIZE];
       
 12294     char rmsg[MAX_MSG_SIZE];
       
 12295     int index=0;
       
 12296     
       
 12297 		
       
 12298 	int timeout = 100;
       
 12299 	int nBytes;
       
 12300 
       
 12301     int result = 0;
       
 12302     int err = 0;
       
 12303     int status = 0;
       
 12304     FILE *fp;
       
 12305     message_hdr_req *msgHdr = NULL;  
       
 12306     message_hdr_resp* msg_struct = NULL;
       
 12307     TInt return_value = 0;
       
 12308         	// Read data from the CFG file
       
 12309 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 12310 		{
       
 12311 		iLog->Log ( _L ( "read_data failed" ) );
       
 12312 		free_data ( connect_data );
       
 12313 		return_value = KErrGeneral;
       
 12314 		goto return_code;
       
 12315 		}
       
 12316 	//request formation	
       
 12317 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 12318 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12319 	
       
 12320 	//message header use
       
 12321 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 12322     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12323     
       
 12324     msgHdr->message_type = ELogin_Request;
       
 12325  
       
 12326     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12327     index += sizeof( message_hdr_req );
       
 12328     
       
 12329     int len = strlen(connect_data->username);
       
 12330     strcpy( smsg + index, connect_data->username );
       
 12331     index += len + 1;
       
 12332     
       
 12333     //appending password
       
 12334     
       
 12335     len = strlen(connect_data->password );
       
 12336     strcpy( smsg + index, connect_data->password );
       
 12337     index += len + 1;
       
 12338 
       
 12339     //appending server name
       
 12340     
       
 12341     len = strlen(connect_data->server );
       
 12342     strcpy( smsg + index, connect_data->server );
       
 12343     index += len + 1;
       
 12344     
       
 12345     //appending resource
       
 12346     len = strlen(connect_data->resource );
       
 12347     strcpy( smsg + index, connect_data->resource );
       
 12348     index += len + 1;
       
 12349     
       
 12350     //appending ssl
       
 12351     smsg[index++]= '1';
       
 12352     smsg[index++]= '\0';
       
 12353     
       
 12354     //appending server port
       
 12355     len = strlen(connect_data->port );
       
 12356     strcpy( smsg + index, connect_data->port );
       
 12357     index += len + 1;
       
 12358     
       
 12359     // appending IAP id
       
 12360     
       
 12361     smsg[index++]= '1';
       
 12362     smsg[index++]= '\0';
       
 12363     
       
 12364     //appending connmgr_bus
       
 12365     len = strlen(connect_data->connmgr_bus );
       
 12366     strcpy( smsg + index, connect_data->connmgr_bus );
       
 12367     index += len + 1;
       
 12368     
       
 12369     //appending connmgr_path
       
 12370     len = strlen(connect_data->connmgr_path );
       
 12371     strcpy( smsg + index, connect_data->connmgr_path );
       
 12372     index += len + 1;
       
 12373     
       
 12374     //appending protocol
       
 12375     len = strlen(connect_data->protocol );
       
 12376     strcpy( smsg + index, connect_data->protocol );
       
 12377     index += len + 1;
       
 12378     
       
 12379     #ifdef __WINSCW__
       
 12380     //proxy server
       
 12381     len = strlen(connect_data->proxy_data->proxy_server );
       
 12382     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 12383     index += len + 1;
       
 12384     
       
 12385     //proxy port
       
 12386     len = strlen(connect_data->proxy_data->proxy_port );
       
 12387     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 12388     index += len + 1;
       
 12389     
       
 12390     #endif
       
 12391     //running isoserver   
       
 12392     run_isoserver(); 
       
 12393     
       
 12394     
       
 12395         
       
 12396     //create message queue for send request
       
 12397     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12398     //create message queue for response request
       
 12399     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12400 		
       
 12401 
       
 12402 	/* Send Message to queueOne */
       
 12403 	
       
 12404 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12405     
       
 12406     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 12407     
       
 12408     if (status < 0)
       
 12409     {
       
 12410     return_value = KErrGeneral;
       
 12411 	goto return_code;	
       
 12412     }
       
 12413     
       
 12414  
       
 12415     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 12416 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 12417 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 12418 	
       
 12419 	if( msg_struct->response != 1)
       
 12420     {
       
 12421     	return_value = KErrGeneral;
       
 12422 	goto return_code;
       
 12423     }
       
 12424     
       
 12425     
       
 12426     // login end
       
 12427    //fetch req..
       
 12428     for (int i= 0 ;i<3 ;i++)
       
 12429     {
       
 12430         
       
 12431     fp = fopen("c:\\fetch_contact.txt","a");
       
 12432 	do  {
       
 12433 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 12434 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12435 		fwrite(rmsg,1,status,fp);
       
 12436 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12437 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 12438 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 12439 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 12440 	fclose(fp);	
       
 12441 	
       
 12442     }
       
 12443 
       
 12444 	//fetch end
       
 12445 	
       
 12446 	 //-------------update presence---------------
       
 12447    
       
 12448     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12449 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12450 	index=0;
       
 12451     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12452     msgHdr->message_type = EUpdateOwnPresence;	
       
 12453     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12454 	index += sizeof( message_hdr_req );
       
 12455 	
       
 12456 	
       
 12457     // updating availability
       
 12458     char *availability = "available";
       
 12459     memcpy( smsg + index, availability, strlen( availability ) );
       
 12460     index += strlen( availability ); 
       
 12461       
       
 12462        
       
 12463     
       
 12464      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12465     
       
 12466     do  {
       
 12467 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12468 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12469 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12470 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 12471    
       
 12472     if ( msg_struct->response != 1)
       
 12473     {
       
 12474     	return_value = KErrGeneral;
       
 12475 	goto return_code;
       
 12476     }
       
 12477     
       
 12478    // logout test code from server
       
 12479     index=0;
       
 12480     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12481 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12482 	
       
 12483 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12484     
       
 12485     msgHdr->message_type = ELogout_Request;
       
 12486  
       
 12487     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12488     index += sizeof( message_hdr_req );
       
 12489 
       
 12490 	
       
 12491 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12492      do  {
       
 12493 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12494 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12495 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12496 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 12497    
       
 12498      if ( msg_struct->response != 1)
       
 12499     {
       
 12500     	return_value = KErrGeneral;
       
 12501 	goto return_code;
       
 12502     }
       
 12503     
       
 12504     //killing isoserver
       
 12505     return_code:
       
 12506     index=0;
       
 12507     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12508 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12509 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12510     msgHdr->message_type = EKill_Process;
       
 12511     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12512     index += sizeof( message_hdr_req );
       
 12513 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 12514     free( msg_struct );
       
 12515     return return_value;
       
 12516     }
       
 12517 
       
 12518 // -----------------------------------------------------------------------------
       
 12519 // Cisolationserver::UpdatePresenceWithAway
       
 12520 // Example test method function.
       
 12521 // (other items were commented in a header).
       
 12522 // -----------------------------------------------------------------------------
       
 12523 //
       
 12524 TInt Cisolationserver::UpdateOwnPresenceWithBlankData( CStifItemParser& aItem )
       
 12525     {
       
 12526 
       
 12527     	
       
 12528     ConnectData  *connect_data = NULL;
       
 12529     char smsg[MAX_MSG_SIZE];
       
 12530     char rmsg[MAX_MSG_SIZE];
       
 12531     int index=0;
       
 12532     
       
 12533 		
       
 12534 	int timeout = 100;
       
 12535 	int nBytes;
       
 12536 
       
 12537     int result = 0;
       
 12538     int err = 0;
       
 12539     int status = 0;
       
 12540     FILE *fp;
       
 12541     message_hdr_req *msgHdr = NULL;  
       
 12542     message_hdr_resp* msg_struct = NULL;
       
 12543     TInt return_value = 0;
       
 12544         	// Read data from the CFG file
       
 12545 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 12546 		{
       
 12547 		iLog->Log ( _L ( "read_data failed" ) );
       
 12548 		free_data ( connect_data );
       
 12549 		return_value = KErrGeneral;
       
 12550 		goto return_code;
       
 12551 		}
       
 12552 	//request formation	
       
 12553 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 12554 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12555 	
       
 12556 	//message header use
       
 12557 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 12558     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12559     
       
 12560     msgHdr->message_type = ELogin_Request;
       
 12561  
       
 12562     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12563     index += sizeof( message_hdr_req );
       
 12564     
       
 12565     int len = strlen(connect_data->username);
       
 12566     strcpy( smsg + index, connect_data->username );
       
 12567     index += len + 1;
       
 12568     
       
 12569     //appending password
       
 12570     
       
 12571     len = strlen(connect_data->password );
       
 12572     strcpy( smsg + index, connect_data->password );
       
 12573     index += len + 1;
       
 12574 
       
 12575     //appending server name
       
 12576     
       
 12577     len = strlen(connect_data->server );
       
 12578     strcpy( smsg + index, connect_data->server );
       
 12579     index += len + 1;
       
 12580     
       
 12581     //appending resource
       
 12582     len = strlen(connect_data->resource );
       
 12583     strcpy( smsg + index, connect_data->resource );
       
 12584     index += len + 1;
       
 12585     
       
 12586     //appending ssl
       
 12587     smsg[index++]= '1';
       
 12588     smsg[index++]= '\0';
       
 12589     
       
 12590     //appending server port
       
 12591     len = strlen(connect_data->port );
       
 12592     strcpy( smsg + index, connect_data->port );
       
 12593     index += len + 1;
       
 12594     
       
 12595     // appending IAP id
       
 12596     
       
 12597     smsg[index++]= '1';
       
 12598     smsg[index++]= '\0';
       
 12599     
       
 12600     //appending connmgr_bus
       
 12601     len = strlen(connect_data->connmgr_bus );
       
 12602     strcpy( smsg + index, connect_data->connmgr_bus );
       
 12603     index += len + 1;
       
 12604     
       
 12605     //appending connmgr_path
       
 12606     len = strlen(connect_data->connmgr_path );
       
 12607     strcpy( smsg + index, connect_data->connmgr_path );
       
 12608     index += len + 1;
       
 12609     
       
 12610     //appending protocol
       
 12611     len = strlen(connect_data->protocol );
       
 12612     strcpy( smsg + index, connect_data->protocol );
       
 12613     index += len + 1;
       
 12614     
       
 12615     #ifdef __WINSCW__
       
 12616     //proxy server
       
 12617     len = strlen(connect_data->proxy_data->proxy_server );
       
 12618     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 12619     index += len + 1;
       
 12620     
       
 12621     //proxy port
       
 12622     len = strlen(connect_data->proxy_data->proxy_port );
       
 12623     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 12624     index += len + 1;
       
 12625     
       
 12626     #endif
       
 12627     //running isoserver   
       
 12628     run_isoserver(); 
       
 12629     
       
 12630     
       
 12631         
       
 12632     //create message queue for send request
       
 12633     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12634     //create message queue for response request
       
 12635     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12636 		
       
 12637 
       
 12638 	/* Send Message to queueOne */
       
 12639 	
       
 12640 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12641     
       
 12642     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 12643     
       
 12644     if (status < 0)
       
 12645     {
       
 12646     return_value = KErrGeneral;
       
 12647 	goto return_code;	
       
 12648     }
       
 12649     
       
 12650  
       
 12651     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 12652 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 12653 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 12654 	
       
 12655 	if( msg_struct->response != 1)
       
 12656     {
       
 12657     	return_value = KErrGeneral;
       
 12658 	goto return_code;
       
 12659     }
       
 12660     
       
 12661     
       
 12662     // login end
       
 12663    //fetch req..
       
 12664     for (int i= 0 ;i<3 ;i++)
       
 12665     {
       
 12666         
       
 12667     fp = fopen("c:\\fetch_contact.txt","a");
       
 12668 	do  {
       
 12669 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 12670 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12671 		fwrite(rmsg,1,status,fp);
       
 12672 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12673 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 12674 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 12675 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 12676 	fclose(fp);	
       
 12677 	
       
 12678     }
       
 12679 
       
 12680 	//fetch end
       
 12681 	
       
 12682 	 //-------------update presence---------------
       
 12683    
       
 12684     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12685 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12686 	index=0;
       
 12687     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12688     msgHdr->message_type = EUpdateOwnPresence;	
       
 12689     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12690 	index += sizeof( message_hdr_req );
       
 12691 	
       
 12692 	   
       
 12693     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12694     
       
 12695     do  {
       
 12696 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12697 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12698 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12699 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 12700    
       
 12701     if ( msg_struct->error_type > 0)
       
 12702     {
       
 12703     	return_value = KErrGeneral;
       
 12704 	goto return_code;
       
 12705     }
       
 12706    // logout test code from server
       
 12707     index=0;
       
 12708     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12709 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12710 	
       
 12711 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12712     
       
 12713     msgHdr->message_type = ELogout_Request;
       
 12714  
       
 12715     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12716     index += sizeof( message_hdr_req );
       
 12717 
       
 12718 	
       
 12719 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12720      do  {
       
 12721 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12722 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12723 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12724 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 12725    
       
 12726      if ( msg_struct->response != 1)
       
 12727     {
       
 12728     	return_value = KErrGeneral;
       
 12729 	goto return_code;
       
 12730     }
       
 12731     //killing isoserver
       
 12732     return_code:
       
 12733     index=0;
       
 12734     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12735 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12736 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12737     msgHdr->message_type = EKill_Process;
       
 12738     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12739     index += sizeof( message_hdr_req );
       
 12740 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 12741     free( msg_struct );
       
 12742     return return_value;
       
 12743     }
       
 12744 // -----------------------------------------------------------------------------
       
 12745 // Cisolationserver::UpdatePresenceWithDnd
       
 12746 // Example test method function.
       
 12747 // (other items were commented in a header).
       
 12748 // -----------------------------------------------------------------------------
       
 12749 //
       
 12750 TInt Cisolationserver::UpdateStatusTextWithSpecialCharacter( CStifItemParser& aItem )
       
 12751     {
       
 12752 
       
 12753     	
       
 12754     ConnectData  *connect_data = NULL;
       
 12755     char smsg[MAX_MSG_SIZE];
       
 12756     char rmsg[MAX_MSG_SIZE];
       
 12757     int index=0;
       
 12758     
       
 12759 		
       
 12760 	int timeout = 100;
       
 12761 	int nBytes;
       
 12762 
       
 12763     int result = 0;
       
 12764     int err = 0;
       
 12765     int status = 0;
       
 12766     FILE *fp;
       
 12767     message_hdr_req *msgHdr = NULL;  
       
 12768     message_hdr_resp* msg_struct = NULL;
       
 12769     TInt return_value = 0;
       
 12770         	// Read data from the CFG file
       
 12771 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 12772 		{
       
 12773 		iLog->Log ( _L ( "read_data failed" ) );
       
 12774 		free_data ( connect_data );
       
 12775 		return_value = KErrGeneral;
       
 12776 		goto return_code;
       
 12777 		}
       
 12778 	//request formation	
       
 12779 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 12780 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12781 	
       
 12782 	//message header use
       
 12783 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 12784     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12785     
       
 12786     msgHdr->message_type = ELogin_Request;
       
 12787  
       
 12788     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12789     index += sizeof( message_hdr_req );
       
 12790     
       
 12791     int len = strlen(connect_data->username);
       
 12792     strcpy( smsg + index, connect_data->username );
       
 12793     index += len + 1;
       
 12794     
       
 12795     //appending password
       
 12796     
       
 12797     len = strlen(connect_data->password );
       
 12798     strcpy( smsg + index, connect_data->password );
       
 12799     index += len + 1;
       
 12800 
       
 12801     //appending server name
       
 12802     
       
 12803     len = strlen(connect_data->server );
       
 12804     strcpy( smsg + index, connect_data->server );
       
 12805     index += len + 1;
       
 12806     
       
 12807     //appending resource
       
 12808     len = strlen(connect_data->resource );
       
 12809     strcpy( smsg + index, connect_data->resource );
       
 12810     index += len + 1;
       
 12811     
       
 12812     //appending ssl
       
 12813     smsg[index++]= '1';
       
 12814     smsg[index++]= '\0';
       
 12815     
       
 12816     //appending server port
       
 12817     len = strlen(connect_data->port );
       
 12818     strcpy( smsg + index, connect_data->port );
       
 12819     index += len + 1;
       
 12820     
       
 12821     // appending IAP id
       
 12822     
       
 12823     smsg[index++]= '1';
       
 12824     smsg[index++]= '\0';
       
 12825     
       
 12826     //appending connmgr_bus
       
 12827     len = strlen(connect_data->connmgr_bus );
       
 12828     strcpy( smsg + index, connect_data->connmgr_bus );
       
 12829     index += len + 1;
       
 12830     
       
 12831     //appending connmgr_path
       
 12832     len = strlen(connect_data->connmgr_path );
       
 12833     strcpy( smsg + index, connect_data->connmgr_path );
       
 12834     index += len + 1;
       
 12835     
       
 12836     //appending protocol
       
 12837     len = strlen(connect_data->protocol );
       
 12838     strcpy( smsg + index, connect_data->protocol );
       
 12839     index += len + 1;
       
 12840     
       
 12841     #ifdef __WINSCW__
       
 12842     //proxy server
       
 12843     len = strlen(connect_data->proxy_data->proxy_server );
       
 12844     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 12845     index += len + 1;
       
 12846     
       
 12847     //proxy port
       
 12848     len = strlen(connect_data->proxy_data->proxy_port );
       
 12849     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 12850     index += len + 1;
       
 12851     
       
 12852     #endif
       
 12853     //running isoserver   
       
 12854     run_isoserver(); 
       
 12855     //create message queue for send request
       
 12856     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12857     //create message queue for response request
       
 12858     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 12859 		
       
 12860 
       
 12861 	/* Send Message to queueOne */
       
 12862 	
       
 12863 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12864     
       
 12865     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 12866     
       
 12867     if (status < 0)
       
 12868     {
       
 12869     return_value = KErrGeneral;
       
 12870 	goto return_code;	
       
 12871     }
       
 12872     
       
 12873  
       
 12874     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 12875 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 12876 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 12877 	
       
 12878 	if( msg_struct->response != 1)
       
 12879     {
       
 12880     	return_value = KErrGeneral;
       
 12881 	goto return_code;
       
 12882     }
       
 12883     
       
 12884     
       
 12885     // login end
       
 12886     //fetch req..
       
 12887     for (int i= 0 ;i<3 ;i++)
       
 12888     {
       
 12889         
       
 12890     fp = fopen("c:\\fetch_contact.txt","a");
       
 12891 	do  {
       
 12892 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 12893 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12894 		fwrite(rmsg,1,status,fp);
       
 12895 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12896 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 12897 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 12898 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 12899 	fclose(fp);	
       
 12900 	
       
 12901     }
       
 12902 
       
 12903 	//fetch end
       
 12904 	
       
 12905 	 //-------------update presence---------------
       
 12906    
       
 12907     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12908 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12909 	index=0;
       
 12910     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12911     msgHdr->message_type = EUpdateOwnPresence;	
       
 12912     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12913 	index += sizeof( message_hdr_req );
       
 12914 	
       
 12915 	
       
 12916     // updating availability
       
 12917     char *availability = "dnd";
       
 12918     memcpy( smsg + index, availability, strlen( availability ) );
       
 12919     index += strlen( availability ); 
       
 12920     smsg[index++]='\0';
       
 12921     
       
 12922     //updating status text
       
 12923     char *statustext = "hi i m_ fine here @@@@@ ********* &&&&&&&&&&&&";
       
 12924     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 12925     index += strlen( statustext ); 
       
 12926     
       
 12927        
       
 12928     
       
 12929      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12930     
       
 12931     do  {
       
 12932 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12933 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12934 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12935 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 12936    
       
 12937     if ( msg_struct->response != 1)
       
 12938     {
       
 12939     	return_value = KErrGeneral;
       
 12940 	goto return_code;
       
 12941     }    
       
 12942     // logout test code from server
       
 12943     index=0;
       
 12944     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12945 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12946 	
       
 12947 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12948     
       
 12949     msgHdr->message_type = ELogout_Request;
       
 12950  
       
 12951     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12952     index += sizeof( message_hdr_req );
       
 12953 
       
 12954 	
       
 12955 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 12956      do  {
       
 12957 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 12958 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 12959 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12960 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 12961    
       
 12962      if ( msg_struct->response != 1)
       
 12963     {
       
 12964     	return_value = KErrGeneral;
       
 12965 	goto return_code;
       
 12966     }
       
 12967     //killing isoserver
       
 12968     return_code:
       
 12969     index=0;
       
 12970     memset( smsg, '\0', MAX_MSG_SIZE );
       
 12971 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 12972 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 12973     msgHdr->message_type = EKill_Process;
       
 12974     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 12975     index += sizeof( message_hdr_req );
       
 12976 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 12977     free( msg_struct );
       
 12978     return return_value;
       
 12979     }
       
 12980 
       
 12981 // -----------------------------------------------------------------------------
       
 12982 // Cisolationserver::UpdatePresenceWithDnd
       
 12983 // Example test method function.
       
 12984 // (other items were commented in a header).
       
 12985 // -----------------------------------------------------------------------------
       
 12986 //
       
 12987 TInt Cisolationserver::UpdateStatusTextWithMaxLen( CStifItemParser& aItem )
       
 12988     {
       
 12989 
       
 12990     	
       
 12991     ConnectData  *connect_data = NULL;
       
 12992     char smsg[MAX_MSG_SIZE];
       
 12993     char rmsg[MAX_MSG_SIZE];
       
 12994     int index=0;
       
 12995     
       
 12996 		
       
 12997 	int timeout = 100;
       
 12998 	int nBytes;
       
 12999 
       
 13000     int result = 0;
       
 13001     int err = 0;
       
 13002     int status = 0;
       
 13003     FILE *fp;
       
 13004     message_hdr_req *msgHdr = NULL;  
       
 13005     message_hdr_resp* msg_struct = NULL;
       
 13006     TInt return_value = 0;
       
 13007         	// Read data from the CFG file
       
 13008 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 13009 		{
       
 13010 		iLog->Log ( _L ( "read_data failed" ) );
       
 13011 		free_data ( connect_data );
       
 13012 		return_value = KErrGeneral;
       
 13013 		goto return_code;
       
 13014 		}
       
 13015 	//request formation	
       
 13016 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 13017 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13018 	
       
 13019 	//message header use
       
 13020 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 13021     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13022     
       
 13023     msgHdr->message_type = ELogin_Request;
       
 13024  
       
 13025     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13026     index += sizeof( message_hdr_req );
       
 13027     
       
 13028     int len = strlen(connect_data->username);
       
 13029     strcpy( smsg + index, connect_data->username );
       
 13030     index += len + 1;
       
 13031     
       
 13032     //appending password
       
 13033     
       
 13034     len = strlen(connect_data->password );
       
 13035     strcpy( smsg + index, connect_data->password );
       
 13036     index += len + 1;
       
 13037 
       
 13038     //appending server name
       
 13039     
       
 13040     len = strlen(connect_data->server );
       
 13041     strcpy( smsg + index, connect_data->server );
       
 13042     index += len + 1;
       
 13043     
       
 13044     //appending resource
       
 13045     len = strlen(connect_data->resource );
       
 13046     strcpy( smsg + index, connect_data->resource );
       
 13047     index += len + 1;
       
 13048     
       
 13049     //appending ssl
       
 13050     smsg[index++]= '1';
       
 13051     smsg[index++]= '\0';
       
 13052     
       
 13053     //appending server port
       
 13054     len = strlen(connect_data->port );
       
 13055     strcpy( smsg + index, connect_data->port );
       
 13056     index += len + 1;
       
 13057     
       
 13058     // appending IAP id
       
 13059     
       
 13060     smsg[index++]= '1';
       
 13061     smsg[index++]= '\0';
       
 13062     
       
 13063     //appending connmgr_bus
       
 13064     len = strlen(connect_data->connmgr_bus );
       
 13065     strcpy( smsg + index, connect_data->connmgr_bus );
       
 13066     index += len + 1;
       
 13067     
       
 13068     //appending connmgr_path
       
 13069     len = strlen(connect_data->connmgr_path );
       
 13070     strcpy( smsg + index, connect_data->connmgr_path );
       
 13071     index += len + 1;
       
 13072     
       
 13073     //appending protocol
       
 13074     len = strlen(connect_data->protocol );
       
 13075     strcpy( smsg + index, connect_data->protocol );
       
 13076     index += len + 1;
       
 13077     
       
 13078     #ifdef __WINSCW__
       
 13079     //proxy server
       
 13080     len = strlen(connect_data->proxy_data->proxy_server );
       
 13081     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 13082     index += len + 1;
       
 13083     
       
 13084     //proxy port
       
 13085     len = strlen(connect_data->proxy_data->proxy_port );
       
 13086     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 13087     index += len + 1;
       
 13088     
       
 13089     #endif
       
 13090     //running isoserver   
       
 13091     run_isoserver(); 
       
 13092     //create message queue for send request
       
 13093     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13094     //create message queue for response request
       
 13095     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13096 		
       
 13097 
       
 13098 	/* Send Message to queueOne */
       
 13099 	
       
 13100 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13101     
       
 13102     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13103     
       
 13104     if (status < 0)
       
 13105     {
       
 13106     return_value = KErrGeneral;
       
 13107 	goto return_code;	
       
 13108     }
       
 13109     
       
 13110  
       
 13111     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 13112 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 13113 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 13114 	
       
 13115 	if( msg_struct->response != 1)
       
 13116     {
       
 13117     return_value = KErrGeneral;
       
 13118 	goto return_code;
       
 13119     }
       
 13120     
       
 13121     
       
 13122     // login end
       
 13123     //fetch req..
       
 13124     for (int i= 0 ;i<3 ;i++)
       
 13125     {
       
 13126         
       
 13127     fp = fopen("c:\\fetch_contact.txt","a");
       
 13128 	do  {
       
 13129 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 13130 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13131 		fwrite(rmsg,1,status,fp);
       
 13132 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13133 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 13134 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 13135 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 13136 	fclose(fp);	
       
 13137 	
       
 13138     }
       
 13139 
       
 13140 	//fetch end
       
 13141 	
       
 13142 	 //-------------update presence---------------
       
 13143    
       
 13144     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13145 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13146 	index=0;
       
 13147     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13148     msgHdr->message_type = EUpdateOwnPresence;	
       
 13149     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13150 	index += sizeof( message_hdr_req );
       
 13151 	
       
 13152 	
       
 13153     // updating availability
       
 13154     char *availability = "dnd";
       
 13155     memcpy( smsg + index, availability, strlen( availability ) );
       
 13156     index += strlen( availability ); 
       
 13157     smsg[index++]='\0';
       
 13158     
       
 13159     //updating status text
       
 13160     char *statustext = "thesr is difference between thoughts and execution ";
       
 13161     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 13162     index += strlen( statustext ); 
       
 13163     
       
 13164        
       
 13165     
       
 13166      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13167     
       
 13168     do  {
       
 13169 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13170 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13171 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13172 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 13173    
       
 13174     if ( msg_struct->response != 1)
       
 13175     {
       
 13176     return_value = KErrGeneral;
       
 13177 	goto return_code;
       
 13178     }
       
 13179     
       
 13180     // logout test code from server
       
 13181     index=0;
       
 13182     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13183 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13184 	
       
 13185 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13186     
       
 13187     msgHdr->message_type = ELogout_Request;
       
 13188  
       
 13189     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13190     index += sizeof( message_hdr_req );
       
 13191 
       
 13192 	
       
 13193 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13194      do  {
       
 13195 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13196 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13197 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13198 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 13199    
       
 13200      if ( msg_struct->response != 1)
       
 13201     {
       
 13202     	return_value = KErrGeneral;
       
 13203 	goto return_code;
       
 13204     }
       
 13205     
       
 13206     //killing isoserver
       
 13207     return_code:
       
 13208     index=0;
       
 13209     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13210 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13211 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13212     msgHdr->message_type = EKill_Process;
       
 13213     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13214     index += sizeof( message_hdr_req );
       
 13215 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 13216     free( msg_struct );
       
 13217     return return_value;
       
 13218     }
       
 13219 
       
 13220 // -----------------------------------------------------------------------------
       
 13221 // Cisolationserver::UpdatePresenceWithDnd
       
 13222 // Example test method function.
       
 13223 // (other items were commented in a header).
       
 13224 // -----------------------------------------------------------------------------
       
 13225 //
       
 13226 TInt Cisolationserver::HandelingPresenceNotification( CStifItemParser& aItem )
       
 13227     {
       
 13228 
       
 13229     /*	
       
 13230     ConnectData  *connect_data = NULL;
       
 13231     char smsg[MAX_MSG_SIZE];
       
 13232     char rmsg[MAX_MSG_SIZE];
       
 13233     int index=0;
       
 13234     
       
 13235 		
       
 13236 	int timeout = 100;
       
 13237 	int nBytes;
       
 13238 
       
 13239     int result = 0;
       
 13240     int err = 0;
       
 13241     int status = 0;
       
 13242     FILE *fp;
       
 13243     message_hdr_req *msgHdr = NULL;  
       
 13244     message_hdr_resp* msg_struct = NULL;
       
 13245     TInt return_value = 0;
       
 13246         	// Read data from the CFG file
       
 13247 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 13248 		{
       
 13249 		iLog->Log ( _L ( "read_data failed" ) );
       
 13250 		free_data ( connect_data );
       
 13251 		return_value = KErrGeneral;
       
 13252 		goto return_code;
       
 13253 		}
       
 13254 	//request formation	
       
 13255 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 13256 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13257 	
       
 13258 	//message header use
       
 13259 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 13260     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13261     
       
 13262     msgHdr->message_type = ELogin_Request;
       
 13263  
       
 13264     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13265     index += sizeof( message_hdr_req );
       
 13266     
       
 13267     int len = strlen(connect_data->username);
       
 13268     strcpy( smsg + index, connect_data->username );
       
 13269     index += len + 1;
       
 13270     
       
 13271     //appending password
       
 13272     
       
 13273     len = strlen(connect_data->password );
       
 13274     strcpy( smsg + index, connect_data->password );
       
 13275     index += len + 1;
       
 13276 
       
 13277     //appending server name
       
 13278     
       
 13279     len = strlen(connect_data->server );
       
 13280     strcpy( smsg + index, connect_data->server );
       
 13281     index += len + 1;
       
 13282     
       
 13283     //appending resource
       
 13284     len = strlen(connect_data->resource );
       
 13285     strcpy( smsg + index, connect_data->resource );
       
 13286     index += len + 1;
       
 13287     
       
 13288     //appending ssl
       
 13289     smsg[index++]= '1';
       
 13290     smsg[index++]= '\0';
       
 13291     
       
 13292     //appending server port
       
 13293     len = strlen(connect_data->port );
       
 13294     strcpy( smsg + index, connect_data->port );
       
 13295     index += len + 1;
       
 13296     
       
 13297     // appending IAP id
       
 13298     
       
 13299     smsg[index++]= '1';
       
 13300     smsg[index++]= '\0';
       
 13301     
       
 13302     //appending connmgr_bus
       
 13303     len = strlen(connect_data->connmgr_bus );
       
 13304     strcpy( smsg + index, connect_data->connmgr_bus );
       
 13305     index += len + 1;
       
 13306     
       
 13307     //appending connmgr_path
       
 13308     len = strlen(connect_data->connmgr_path );
       
 13309     strcpy( smsg + index, connect_data->connmgr_path );
       
 13310     index += len + 1;
       
 13311     
       
 13312     //appending protocol
       
 13313     len = strlen(connect_data->protocol );
       
 13314     strcpy( smsg + index, connect_data->protocol );
       
 13315     index += len + 1;
       
 13316     
       
 13317     #ifdef __WINSCW__
       
 13318     //proxy server
       
 13319     len = strlen(connect_data->proxy_data->proxy_server );
       
 13320     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 13321     index += len + 1;
       
 13322     
       
 13323     //proxy port
       
 13324     len = strlen(connect_data->proxy_data->proxy_port );
       
 13325     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 13326     index += len + 1;
       
 13327     
       
 13328     #endif
       
 13329     //running isoserver   
       
 13330     run_isoserver();    
       
 13331     //create message queue for send request
       
 13332     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13333     //create message queue for response request
       
 13334     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13335 		
       
 13336 
       
 13337 	// Send Message to queueOne 
       
 13338 	
       
 13339 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13340     
       
 13341     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13342     
       
 13343     if (status < 0)
       
 13344     {
       
 13345     return_value = KErrGeneral;
       
 13346 	goto return_code;	
       
 13347     }
       
 13348     
       
 13349  
       
 13350     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 13351 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 13352 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 13353 	
       
 13354 	if( msg_struct->response != 1)
       
 13355     {
       
 13356     	return_value = KErrGeneral;
       
 13357 	goto return_code;
       
 13358     }
       
 13359     
       
 13360     
       
 13361     // login end
       
 13362     //fetch req..
       
 13363     for (int i= 0 ;i<3 ;i++)
       
 13364     {
       
 13365         
       
 13366     fp = fopen("c:\\fetch_contact.txt","a");
       
 13367 	do  {
       
 13368 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 13369 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13370 		fwrite(rmsg,1,status,fp);
       
 13371 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13372 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 13373 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 13374 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 13375 	fclose(fp);	
       
 13376 	
       
 13377     }
       
 13378 
       
 13379 	//fetch end
       
 13380 	
       
 13381 	 //-------------update presence---------------
       
 13382    
       
 13383     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13384 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13385 	index=0;
       
 13386     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13387     msgHdr->message_type = EUpdateOwnPresence;	
       
 13388     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13389 	index += sizeof( message_hdr_req );
       
 13390 	
       
 13391 	
       
 13392     // updating availability
       
 13393     char *availability = "dnd";
       
 13394     memcpy( smsg + index, availability, strlen( availability ) );
       
 13395     index += strlen( availability ); 
       
 13396     smsg[index++]='\0';
       
 13397     
       
 13398     //updating status text
       
 13399     char *statustext = "i m busy";
       
 13400     memcpy( smsg + index, statustext, strlen( statustext ) );
       
 13401     index += strlen( statustext ); 
       
 13402     
       
 13403        
       
 13404     
       
 13405      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13406     
       
 13407     do  {
       
 13408 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13409 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13410 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13411 		} while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
       
 13412    
       
 13413     if ( msg_struct->response != 1)
       
 13414     {
       
 13415     	return_value = KErrGeneral;
       
 13416 	goto return_code;
       
 13417     }
       
 13418     
       
 13419    //  waiting for second change 
       
 13420     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13421         //wait for message receive 
       
 13422     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13423     if (status < 0)
       
 13424     {
       
 13425     return_value = KErrGeneral;
       
 13426 	goto return_code;	
       
 13427     }
       
 13428     //  waiting for first change 
       
 13429     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13430         //wait for message receive 
       
 13431     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13432     if (status < 0)
       
 13433     {
       
 13434     return_value = KErrGeneral;
       
 13435 	goto return_code;	
       
 13436     }
       
 13437     
       
 13438      //  waiting for first change 
       
 13439     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13440         //wait for message receive 
       
 13441     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13442     if (status < 0)
       
 13443     {
       
 13444     return_value = KErrGeneral;
       
 13445 	goto return_code;	
       
 13446     }
       
 13447     
       
 13448     
       
 13449      //  waiting for first change 
       
 13450     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13451         //wait for message receive 
       
 13452     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13453     if (status < 0)
       
 13454     {
       
 13455     return_value = KErrGeneral;
       
 13456 	goto return_code;	
       
 13457     }
       
 13458     
       
 13459     
       
 13460      //  waiting for first change 
       
 13461     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13462         //wait for message receive 
       
 13463     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13464     if (status < 0)
       
 13465     {
       
 13466     return_value = KErrGeneral;
       
 13467 	goto return_code;	
       
 13468     }
       
 13469     // logout test code from server
       
 13470     index=0;
       
 13471     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13472 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13473 	
       
 13474 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13475     
       
 13476     msgHdr->message_type = ELogout_Request;
       
 13477  
       
 13478     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13479     index += sizeof( message_hdr_req );
       
 13480 
       
 13481 	
       
 13482 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13483      do  {
       
 13484 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13485 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13486 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13487 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 13488    
       
 13489      if ( msg_struct->response != 1)
       
 13490     {
       
 13491     	return_value = KErrGeneral;
       
 13492 	    goto return_code;
       
 13493     }
       
 13494     //killing isoserver
       
 13495     return_code:
       
 13496     index=0;
       
 13497     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13498 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13499 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13500     msgHdr->message_type = EKill_Process;
       
 13501     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13502     index += sizeof( message_hdr_req );
       
 13503 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 13504     free( msg_struct );
       
 13505     return return_value; */
       
 13506     return KErrNone;
       
 13507     }
       
 13508     
       
 13509     
       
 13510 Cisolationserver::SearchKeyValue( CStifItemParser& aItem )
       
 13511 	{
       
 13512 	ConnectData  *connect_data = NULL;
       
 13513     char smsg[MAX_MSG_SIZE];
       
 13514     char rmsg[MAX_MSG_SIZE];
       
 13515     int index=0;
       
 13516     FILE *fp;
       
 13517 		
       
 13518 	int timeout = 200;
       
 13519 	int nBytes;
       
 13520 
       
 13521     int result = 0;
       
 13522     int err = 0;
       
 13523     int status = 0;
       
 13524     TInt return_value = 0;
       
 13525     message_hdr_req *msgHdr = NULL;  
       
 13526     message_hdr_resp* msg_struct = NULL;
       
 13527       
       
 13528     	// Read data from the CFG file
       
 13529 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 13530 		{
       
 13531 		iLog->Log ( _L ( "read_data failed" ) );
       
 13532 		free_data ( connect_data );
       
 13533 		return KErrGeneral;
       
 13534 		}
       
 13535 	//request formation	
       
 13536 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 13537 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13538 	
       
 13539 	//message header use
       
 13540 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 13541     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13542     
       
 13543     msgHdr->message_type = ELogin_Request;
       
 13544  
       
 13545     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13546     index += sizeof( message_hdr_req );
       
 13547     
       
 13548     int len = strlen(connect_data->username);
       
 13549     strcpy( smsg + index, connect_data->username );
       
 13550     index += len + 1;
       
 13551     
       
 13552     //appending password
       
 13553     
       
 13554     len = strlen(connect_data->password );
       
 13555     strcpy( smsg + index, connect_data->password );
       
 13556     index += len + 1;
       
 13557     
       
 13558     //appending server name
       
 13559     
       
 13560     len = strlen(connect_data->server );
       
 13561     strcpy( smsg + index, connect_data->server );
       
 13562     index += len + 1;
       
 13563     
       
 13564     //appending resource
       
 13565     len = strlen(connect_data->resource );
       
 13566     strcpy( smsg + index, connect_data->resource );
       
 13567     index += len + 1;
       
 13568     
       
 13569     //appending ssl
       
 13570     smsg[index++]= '0';
       
 13571     smsg[index++]= '\0';
       
 13572     
       
 13573     //appending server port
       
 13574     len = strlen(connect_data->port );
       
 13575     strcpy( smsg + index, connect_data->port );
       
 13576     index += len + 1;
       
 13577     
       
 13578     // appending IAP id
       
 13579     
       
 13580     smsg[index++]= '1';
       
 13581     smsg[index++]= '\0';
       
 13582     
       
 13583     //appending connmgr_bus
       
 13584     len = strlen(connect_data->connmgr_bus );
       
 13585     strcpy( smsg + index, connect_data->connmgr_bus );
       
 13586     index += len + 1;
       
 13587     
       
 13588     //appending connmgr_path
       
 13589     len = strlen(connect_data->connmgr_path );
       
 13590     strcpy( smsg + index, connect_data->connmgr_path );
       
 13591     index += len + 1;
       
 13592     
       
 13593     //appending protocol
       
 13594     len = strlen(connect_data->protocol );
       
 13595     strcpy( smsg + index, connect_data->protocol );
       
 13596     index += len + 1;
       
 13597     
       
 13598     #ifdef __WINSCW__
       
 13599     //proxy server
       
 13600     len = strlen(connect_data->proxy_data->proxy_server );
       
 13601     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 13602     index += len + 1;
       
 13603     
       
 13604     //proxy port
       
 13605     len = strlen(connect_data->proxy_data->proxy_port );
       
 13606     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 13607     index += len + 1;
       
 13608     
       
 13609     #endif
       
 13610     run_isoserver();
       
 13611     
       
 13612     
       
 13613         
       
 13614     //create message queue for send request
       
 13615     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13616     //create message queue for response request
       
 13617     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13618 		
       
 13619 	
       
 13620 	/* Send Message to queueOne */
       
 13621 	
       
 13622 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13623     
       
 13624     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13625     
       
 13626     if (status < 0)
       
 13627     {
       
 13628     return_value = KErrGeneral;	
       
 13629     goto return_code;
       
 13630     }
       
 13631     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 13632 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 13633 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 13634 	
       
 13635 	if( msg_struct->response != 1)
       
 13636     {
       
 13637     	return_value = KErrGeneral;	
       
 13638     	goto return_code;
       
 13639     }
       
 13640     
       
 13641     
       
 13642     // login end
       
 13643     //fetch req..
       
 13644     for (int i= 0 ;i<3 ;i++)
       
 13645     {
       
 13646         
       
 13647     fp = fopen("c:\\fetch_contact.txt","a");
       
 13648 	do  {
       
 13649 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 13650 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13651 		fwrite(rmsg,1,status,fp);
       
 13652 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13653 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 13654 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 13655 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 13656 	fclose(fp);	
       
 13657 	
       
 13658     }
       
 13659 
       
 13660 	//fetch end
       
 13661      
       
 13662     //search messge--------------------------------------------
       
 13663    
       
 13664     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13665 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13666 	index=0;
       
 13667     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13668     msgHdr->message_type = ESearch;	
       
 13669     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13670 	index += sizeof( message_hdr_req );
       
 13671 	
       
 13672 	
       
 13673 	const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 13674     // adding key
       
 13675     len = strlen(search_label);
       
 13676     strcpy( smsg + index, search_label );
       
 13677     index += len + 1;
       
 13678     
       
 13679 
       
 13680     
       
 13681     // adding value
       
 13682      
       
 13683     len = strlen("santhosh" );
       
 13684     strcpy( smsg + index, "santhosh" );
       
 13685     index += len + 1;
       
 13686     
       
 13687 
       
 13688     smsg[index++] = '\0';
       
 13689      
       
 13690     
       
 13691     
       
 13692      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13693      do  {
       
 13694 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13695 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13696 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13697 		} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 13698    
       
 13699      if ( msg_struct->response != 1)
       
 13700     {
       
 13701     	return_value = KErrGeneral;	
       
 13702     	goto return_code;
       
 13703     }    
       
 13704      ///-------------------------------------------------------------
       
 13705  
       
 13706     
       
 13707     //search message end---------------------------------------
       
 13708     
       
 13709     
       
 13710     // logout test code from server
       
 13711     index=0;
       
 13712     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13713 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13714 	
       
 13715 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13716     
       
 13717     msgHdr->message_type = ELogout_Request;
       
 13718  
       
 13719     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13720     index += sizeof( message_hdr_req );
       
 13721 
       
 13722 	
       
 13723 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13724      do  {
       
 13725 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13726 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13727 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13728 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 13729    
       
 13730      if ( msg_struct->response != 1)
       
 13731     {
       
 13732     	return_value = KErrGeneral;	
       
 13733     	goto return_code;
       
 13734     }
       
 13735 
       
 13736     
       
 13737    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 13738    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 13739     return_value = KErrNone;	
       
 13740     goto return_code;
       
 13741     //killing isoserver
       
 13742     return_code:
       
 13743     index=0;
       
 13744     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13745 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13746 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13747     msgHdr->message_type = EKill_Process;
       
 13748     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13749     index += sizeof( message_hdr_req );
       
 13750 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 13751     free( msg_struct );
       
 13752     return return_value;	
       
 13753 	}
       
 13754 
       
 13755 Cisolationserver::SearchKeyValueWithResult( CStifItemParser& aItem )
       
 13756 	{
       
 13757 	ConnectData  *connect_data = NULL;
       
 13758     char smsg[MAX_MSG_SIZE];
       
 13759     char rmsg[MAX_MSG_SIZE];
       
 13760     int index=0;
       
 13761     FILE *fp;
       
 13762 		
       
 13763 	int timeout = 200;
       
 13764 	int nBytes;
       
 13765 	TInt return_value = 0;
       
 13766     int result = 0;
       
 13767     int err = 0;
       
 13768     int status = 0;
       
 13769     message_hdr_req *msgHdr = NULL;  
       
 13770     message_hdr_resp* msg_struct = NULL;
       
 13771       
       
 13772     	// Read data from the CFG file
       
 13773 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 13774 		{
       
 13775 		iLog->Log ( _L ( "read_data failed" ) );
       
 13776 		free_data ( connect_data );
       
 13777 		return_value = KErrGeneral;	
       
 13778     	goto return_code;
       
 13779 		}
       
 13780 	//request formation	
       
 13781 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 13782 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13783 	
       
 13784 	//message header use
       
 13785 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 13786     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13787     
       
 13788     msgHdr->message_type = ELogin_Request;
       
 13789  
       
 13790     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13791     index += sizeof( message_hdr_req );
       
 13792     
       
 13793     int len = strlen(connect_data->username);
       
 13794     strcpy( smsg + index, connect_data->username );
       
 13795     index += len + 1;
       
 13796     
       
 13797     //appending password
       
 13798     
       
 13799     len = strlen(connect_data->password );
       
 13800     strcpy( smsg + index, connect_data->password );
       
 13801     index += len + 1;
       
 13802     
       
 13803     //appending server name
       
 13804     
       
 13805     len = strlen(connect_data->server );
       
 13806     strcpy( smsg + index, connect_data->server );
       
 13807     index += len + 1;
       
 13808     
       
 13809     //appending resource
       
 13810     len = strlen(connect_data->resource );
       
 13811     strcpy( smsg + index, connect_data->resource );
       
 13812     index += len + 1;
       
 13813     
       
 13814     //appending ssl
       
 13815     smsg[index++]= '0';
       
 13816     smsg[index++]= '\0';
       
 13817     
       
 13818     //appending server port
       
 13819     len = strlen(connect_data->port );
       
 13820     strcpy( smsg + index, connect_data->port );
       
 13821     index += len + 1;
       
 13822     
       
 13823     // appending IAP id
       
 13824     
       
 13825     smsg[index++]= '1';
       
 13826     smsg[index++]= '\0';
       
 13827     
       
 13828     //appending connmgr_bus
       
 13829     len = strlen(connect_data->connmgr_bus );
       
 13830     strcpy( smsg + index, connect_data->connmgr_bus );
       
 13831     index += len + 1;
       
 13832     
       
 13833     //appending connmgr_path
       
 13834     len = strlen(connect_data->connmgr_path );
       
 13835     strcpy( smsg + index, connect_data->connmgr_path );
       
 13836     index += len + 1;
       
 13837     
       
 13838     //appending protocol
       
 13839     len = strlen(connect_data->protocol );
       
 13840     strcpy( smsg + index, connect_data->protocol );
       
 13841     index += len + 1;
       
 13842     
       
 13843     #ifdef __WINSCW__
       
 13844     //proxy server
       
 13845     len = strlen(connect_data->proxy_data->proxy_server );
       
 13846     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 13847     index += len + 1;
       
 13848     
       
 13849     //proxy port
       
 13850     len = strlen(connect_data->proxy_data->proxy_port );
       
 13851     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 13852     index += len + 1;
       
 13853     
       
 13854     #endif
       
 13855     run_isoserver();
       
 13856     
       
 13857     
       
 13858         
       
 13859     //create message queue for send request
       
 13860     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13861     //create message queue for response request
       
 13862     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 13863 		
       
 13864 	
       
 13865 	/* Send Message to queueOne */
       
 13866 	
       
 13867 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13868     
       
 13869     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 13870     
       
 13871     if (status < 0)
       
 13872     {
       
 13873     	return_value = KErrGeneral;	
       
 13874     	goto return_code;
       
 13875     }
       
 13876     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 13877 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 13878 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 13879 	
       
 13880 	if( msg_struct->response != 1)
       
 13881     {
       
 13882     	return_value = KErrGeneral;	
       
 13883     	goto return_code;
       
 13884     }
       
 13885     
       
 13886     
       
 13887     // login end
       
 13888     //fetch req..
       
 13889     for (int i= 0 ;i<3 ;i++)
       
 13890     {
       
 13891         
       
 13892     fp = fopen("c:\\fetch_contact.txt","a");
       
 13893 	do  {
       
 13894 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 13895 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13896 		fwrite(rmsg,1,status,fp);
       
 13897 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13898 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 13899 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 13900 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 13901 	fclose(fp);	
       
 13902 	
       
 13903     }
       
 13904 
       
 13905 	//fetch end
       
 13906      
       
 13907     //search messge--------------------------------------------
       
 13908    
       
 13909     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13910 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13911 	index=0;
       
 13912     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13913     msgHdr->message_type = ESearch;	
       
 13914     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13915 	index += sizeof( message_hdr_req );
       
 13916 	
       
 13917 	
       
 13918 	const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 13919     // adding key
       
 13920     len = strlen(search_label);
       
 13921     strcpy( smsg + index, search_label );
       
 13922     index += len + 1;	
       
 13923     
       
 13924     // adding value
       
 13925      
       
 13926     len = strlen("rakesh" );
       
 13927     strcpy( smsg + index, "rakesh" );
       
 13928     index += len + 1;
       
 13929     
       
 13930     smsg[index++] = '\0';
       
 13931      
       
 13932     
       
 13933     
       
 13934      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13935      do  {
       
 13936 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13937 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13938 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13939 		} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 13940    
       
 13941      if ( msg_struct->response != 1)
       
 13942     {
       
 13943     	return_value = KErrGeneral;	
       
 13944     	goto return_code;
       
 13945     }    
       
 13946     
       
 13947     
       
 13948     
       
 13949     //search message end---------------------------------------
       
 13950     
       
 13951     
       
 13952     // logout test code from server
       
 13953     index=0;
       
 13954     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13955 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13956 	
       
 13957 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13958     
       
 13959     msgHdr->message_type = ELogout_Request;
       
 13960  
       
 13961     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13962     index += sizeof( message_hdr_req );
       
 13963 
       
 13964 	
       
 13965 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 13966      do  {
       
 13967 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 13968 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 13969 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13970 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 13971    
       
 13972      if ( msg_struct->response != 1)
       
 13973     {
       
 13974     	return_value = KErrGeneral;	
       
 13975     	goto return_code;
       
 13976     }
       
 13977 
       
 13978     
       
 13979    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 13980    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 13981     return_value = KErrNone;	
       
 13982     goto return_code;
       
 13983     //killing isoserver
       
 13984     return_code:
       
 13985     index=0;
       
 13986     memset( smsg, '\0', MAX_MSG_SIZE );
       
 13987 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 13988 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 13989     msgHdr->message_type = EKill_Process;
       
 13990     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 13991     index += sizeof( message_hdr_req );
       
 13992 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 13993     free( msg_struct );
       
 13994     return return_value;	
       
 13995 	}
       
 13996 
       
 13997 
       
 13998 
       
 13999 Cisolationserver::SearchKeyValueInvalidParam( CStifItemParser& aItem )
       
 14000 	{
       
 14001 	ConnectData  *connect_data = NULL;
       
 14002     char smsg[MAX_MSG_SIZE];
       
 14003     char rmsg[MAX_MSG_SIZE];
       
 14004     int index=0;
       
 14005     FILE *fp;
       
 14006 		
       
 14007 	int timeout = 200;
       
 14008 	int nBytes;
       
 14009 	TInt return_value = 0;
       
 14010     int result = 0;
       
 14011     int err = 0;
       
 14012     int status = 0;
       
 14013     message_hdr_req *msgHdr = NULL;  
       
 14014     message_hdr_resp* msg_struct = NULL;
       
 14015       
       
 14016     	// Read data from the CFG file
       
 14017 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 14018 		{
       
 14019 		iLog->Log ( _L ( "read_data failed" ) );
       
 14020 		free_data ( connect_data );
       
 14021 		return_value = KErrGeneral;	
       
 14022     	goto return_code;
       
 14023 		}
       
 14024 	//request formation	
       
 14025 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 14026 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14027 	
       
 14028 	//message header use
       
 14029 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 14030     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14031     
       
 14032     msgHdr->message_type = ELogin_Request;
       
 14033  
       
 14034     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14035     index += sizeof( message_hdr_req );
       
 14036     
       
 14037     int len = strlen(connect_data->username);
       
 14038     strcpy( smsg + index, connect_data->username );
       
 14039     index += len + 1;
       
 14040     
       
 14041     //appending password
       
 14042     
       
 14043     len = strlen(connect_data->password );
       
 14044     strcpy( smsg + index, connect_data->password );
       
 14045     index += len + 1;
       
 14046     
       
 14047     //appending server name
       
 14048     
       
 14049     len = strlen(connect_data->server );
       
 14050     strcpy( smsg + index, connect_data->server );
       
 14051     index += len + 1;
       
 14052     
       
 14053     //appending resource
       
 14054     len = strlen(connect_data->resource );
       
 14055     strcpy( smsg + index, connect_data->resource );
       
 14056     index += len + 1;
       
 14057     
       
 14058     //appending ssl
       
 14059     smsg[index++]= '0';
       
 14060     smsg[index++]= '\0';
       
 14061     
       
 14062     //appending server port
       
 14063     len = strlen(connect_data->port );
       
 14064     strcpy( smsg + index, connect_data->port );
       
 14065     index += len + 1;
       
 14066     
       
 14067     // appending IAP id
       
 14068     
       
 14069     smsg[index++]= '1';
       
 14070     smsg[index++]= '\0';
       
 14071     
       
 14072     //appending connmgr_bus
       
 14073     len = strlen(connect_data->connmgr_bus );
       
 14074     strcpy( smsg + index, connect_data->connmgr_bus );
       
 14075     index += len + 1;
       
 14076     
       
 14077     //appending connmgr_path
       
 14078     len = strlen(connect_data->connmgr_path );
       
 14079     strcpy( smsg + index, connect_data->connmgr_path );
       
 14080     index += len + 1;
       
 14081     
       
 14082     //appending protocol
       
 14083     len = strlen(connect_data->protocol );
       
 14084     strcpy( smsg + index, connect_data->protocol );
       
 14085     index += len + 1;
       
 14086     
       
 14087     #ifdef __WINSCW__
       
 14088     //proxy server
       
 14089     len = strlen(connect_data->proxy_data->proxy_server );
       
 14090     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 14091     index += len + 1;
       
 14092     
       
 14093     //proxy port
       
 14094     len = strlen(connect_data->proxy_data->proxy_port );
       
 14095     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 14096     index += len + 1;
       
 14097     
       
 14098     #endif
       
 14099     run_isoserver();
       
 14100     
       
 14101     //create message queue for send request
       
 14102     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14103     //create message queue for response request
       
 14104     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14105 		
       
 14106 	
       
 14107 	/* Send Message to queueOne */
       
 14108 	
       
 14109 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14110     
       
 14111     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 14112     
       
 14113     if (status < 0)
       
 14114     {
       
 14115     return_value = KErrGeneral;	
       
 14116     	goto return_code;
       
 14117     }
       
 14118     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 14119 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 14120 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 14121 	
       
 14122 	if( msg_struct->response != 1)
       
 14123     {
       
 14124     	return_value = KErrGeneral;	
       
 14125     	goto return_code;
       
 14126     }
       
 14127     
       
 14128     
       
 14129     // login end
       
 14130     //fetch req..
       
 14131     for (int i= 0 ;i<3 ;i++)
       
 14132     {
       
 14133         
       
 14134     fp = fopen("c:\\fetch_contact.txt","a");
       
 14135 	do  {
       
 14136 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 14137 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14138 		fwrite(rmsg,1,status,fp);
       
 14139 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14140 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 14141 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 14142 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 14143 	fclose(fp);	
       
 14144 	
       
 14145     }
       
 14146 
       
 14147 	//fetch end
       
 14148      
       
 14149     //search messge--------------------------------------------
       
 14150    
       
 14151     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14152 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14153 	index=0;
       
 14154     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14155     msgHdr->message_type = ESearch;	
       
 14156     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14157 	index += sizeof( message_hdr_req );
       
 14158 	
       
 14159 	const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 14160     // adding key
       
 14161     len = strlen(search_label);
       
 14162     strcpy( smsg + index, search_label );
       
 14163     index += len + 1;
       
 14164     
       
 14165     smsg[index++] = '\0';
       
 14166      
       
 14167      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14168      do  {
       
 14169 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14170 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14171 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14172 		} while (msg_struct->hdr_req.message_type!= ESearch );
       
 14173    
       
 14174      if ( msg_struct->response != 0)
       
 14175     {
       
 14176     	return_value = KErrGeneral;	
       
 14177     	goto return_code;
       
 14178     }    
       
 14179     
       
 14180     
       
 14181     
       
 14182     //search message end---------------------------------------
       
 14183     
       
 14184     
       
 14185     // logout test code from server
       
 14186     index=0;
       
 14187     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14188 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14189 	
       
 14190 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14191     
       
 14192     msgHdr->message_type = ELogout_Request;
       
 14193  
       
 14194     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14195     index += sizeof( message_hdr_req );
       
 14196 
       
 14197 	
       
 14198 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14199      do  {
       
 14200 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14201 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14202 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14203 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 14204    
       
 14205      if ( msg_struct->response != 1)
       
 14206     {
       
 14207     	return_value = KErrGeneral;	
       
 14208     	goto return_code;
       
 14209     }
       
 14210      
       
 14211    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 14212    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 14213     return_value = KErrNone;	
       
 14214     goto return_code;
       
 14215     //killing isoserver
       
 14216     return_code:
       
 14217     index=0;
       
 14218     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14219 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14220 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14221     msgHdr->message_type = EKill_Process;
       
 14222     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14223     index += sizeof( message_hdr_req );
       
 14224 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 14225     free( msg_struct );
       
 14226     return return_value;
       
 14227 
       
 14228 	}
       
 14229 
       
 14230 
       
 14231 Cisolationserver::SearchForLargeNoOfResult( CStifItemParser& aItem )
       
 14232 	{
       
 14233 	ConnectData  *connect_data = NULL;
       
 14234     char smsg[MAX_MSG_SIZE];
       
 14235     char rmsg[MAX_MSG_SIZE];
       
 14236     int index=0;
       
 14237     FILE *fp;
       
 14238 		
       
 14239 	int timeout = 200;
       
 14240 	int nBytes;
       
 14241 	TInt return_value = 0;
       
 14242     int result = 0;
       
 14243     int err = 0;
       
 14244     int status = 0;
       
 14245     message_hdr_req *msgHdr = NULL;  
       
 14246     message_hdr_resp* msg_struct = NULL;
       
 14247       
       
 14248     	// Read data from the CFG file
       
 14249 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 14250 		{
       
 14251 		iLog->Log ( _L ( "read_data failed" ) );
       
 14252 		free_data ( connect_data );
       
 14253 		return_value = KErrGeneral;	
       
 14254     	goto return_code;
       
 14255 		}
       
 14256 	//request formation	
       
 14257 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 14258 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14259 	
       
 14260 	//message header use
       
 14261 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 14262     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14263     
       
 14264     msgHdr->message_type = ELogin_Request;
       
 14265  
       
 14266     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14267     index += sizeof( message_hdr_req );
       
 14268     
       
 14269     int len = strlen(connect_data->username);
       
 14270     strcpy( smsg + index, connect_data->username );
       
 14271     index += len + 1;
       
 14272     
       
 14273     //appending password
       
 14274     
       
 14275     len = strlen(connect_data->password );
       
 14276     strcpy( smsg + index, connect_data->password );
       
 14277     index += len + 1;
       
 14278     
       
 14279     //appending server name
       
 14280     
       
 14281     len = strlen(connect_data->server );
       
 14282     strcpy( smsg + index, connect_data->server );
       
 14283     index += len + 1;
       
 14284     
       
 14285     //appending resource
       
 14286     len = strlen(connect_data->resource );
       
 14287     strcpy( smsg + index, connect_data->resource );
       
 14288     index += len + 1;
       
 14289     
       
 14290     //appending ssl
       
 14291     smsg[index++]= '0';
       
 14292     smsg[index++]= '\0';
       
 14293     
       
 14294     //appending server port
       
 14295     len = strlen(connect_data->port );
       
 14296     strcpy( smsg + index, connect_data->port );
       
 14297     index += len + 1;
       
 14298     
       
 14299     // appending IAP id
       
 14300     
       
 14301     smsg[index++]= '1';
       
 14302     smsg[index++]= '\0';
       
 14303     
       
 14304     //appending connmgr_bus
       
 14305     len = strlen(connect_data->connmgr_bus );
       
 14306     strcpy( smsg + index, connect_data->connmgr_bus );
       
 14307     index += len + 1;
       
 14308     
       
 14309     //appending connmgr_path
       
 14310     len = strlen(connect_data->connmgr_path );
       
 14311     strcpy( smsg + index, connect_data->connmgr_path );
       
 14312     index += len + 1;
       
 14313     
       
 14314     //appending protocol
       
 14315     len = strlen(connect_data->protocol );
       
 14316     strcpy( smsg + index, connect_data->protocol );
       
 14317     index += len + 1;
       
 14318     
       
 14319     #ifdef __WINSCW__
       
 14320     //proxy server
       
 14321     len = strlen(connect_data->proxy_data->proxy_server );
       
 14322     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 14323     index += len + 1;
       
 14324     
       
 14325     //proxy port
       
 14326     len = strlen(connect_data->proxy_data->proxy_port );
       
 14327     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 14328     index += len + 1;
       
 14329     
       
 14330     #endif
       
 14331     run_isoserver();
       
 14332     
       
 14333     
       
 14334         
       
 14335     //create message queue for send request
       
 14336     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14337     //create message queue for response request
       
 14338     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14339 		
       
 14340 	
       
 14341 	/* Send Message to queueOne */
       
 14342 	
       
 14343 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14344     
       
 14345     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 14346     
       
 14347     if (status < 0)
       
 14348     {
       
 14349     return_value = KErrGeneral;	
       
 14350     	goto return_code;
       
 14351     }
       
 14352     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 14353 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 14354 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 14355 	
       
 14356 	if( msg_struct->response != 1)
       
 14357     {
       
 14358     	return_value = KErrGeneral;	
       
 14359     	goto return_code;
       
 14360     }
       
 14361     
       
 14362     
       
 14363     // login end
       
 14364     //fetch req..
       
 14365     for (int i= 0 ;i<3 ;i++)
       
 14366     {
       
 14367         
       
 14368     fp = fopen("c:\\fetch_contact.txt","a");
       
 14369 	do  {
       
 14370 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 14371 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14372 		fwrite(rmsg,1,status,fp);
       
 14373 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14374 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 14375 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 14376 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 14377 	fclose(fp);	
       
 14378 	
       
 14379     }
       
 14380 
       
 14381 	//fetch end
       
 14382      
       
 14383     //search messge--------------------------------------------
       
 14384    
       
 14385     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14386 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14387 	index=0;
       
 14388     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14389     msgHdr->message_type = ESearch;	
       
 14390     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14391 	index += sizeof( message_hdr_req );
       
 14392 	
       
 14393 	
       
 14394    	const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 14395     // adding key
       
 14396     len = strlen(search_label);
       
 14397     strcpy( smsg + index, search_label );
       
 14398     index += len + 1;
       
 14399     
       
 14400 
       
 14401     
       
 14402     // adding value
       
 14403      
       
 14404     len = strlen("a*" );
       
 14405     strcpy( smsg + index, "a*" );
       
 14406     index += len + 1;
       
 14407     
       
 14408     smsg[index++] = '\0';
       
 14409      
       
 14410     
       
 14411     
       
 14412      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14413      do  {
       
 14414 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14415 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14416 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14417 		} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 14418    
       
 14419      if ( msg_struct->response != 1)
       
 14420     {
       
 14421     	return_value = KErrGeneral;	
       
 14422     	goto return_code;
       
 14423     }    
       
 14424     
       
 14425     
       
 14426     
       
 14427     //search message end---------------------------------------
       
 14428     
       
 14429     
       
 14430     // logout test code from server
       
 14431     index=0;
       
 14432     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14433 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14434 	
       
 14435 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14436     
       
 14437     msgHdr->message_type = ELogout_Request;
       
 14438  
       
 14439     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14440     index += sizeof( message_hdr_req );
       
 14441 
       
 14442 	
       
 14443 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14444      do  {
       
 14445 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14446 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14447 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14448 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 14449    
       
 14450      if ( msg_struct->response != 1)
       
 14451     {
       
 14452     	return_value = KErrGeneral;	
       
 14453     	goto return_code;
       
 14454     }
       
 14455 
       
 14456     
       
 14457    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 14458    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 14459     return_value = KErrNone;	
       
 14460     goto return_code;
       
 14461     
       
 14462     //killing isoserver
       
 14463     return_code:
       
 14464     index=0;
       
 14465     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14466 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14467 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14468     msgHdr->message_type = EKill_Process;
       
 14469     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14470     index += sizeof( message_hdr_req );
       
 14471 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 14472     free( msg_struct );
       
 14473     return return_value;	
       
 14474 	}
       
 14475 
       
 14476 Cisolationserver::SearchKeyValueInvalidParam2( CStifItemParser& aItem )
       
 14477 	{
       
 14478 	ConnectData  *connect_data = NULL;
       
 14479     char smsg[MAX_MSG_SIZE];
       
 14480     char rmsg[MAX_MSG_SIZE];
       
 14481     int index=0;
       
 14482     FILE *fp;
       
 14483 		
       
 14484 	int timeout = 200;
       
 14485 	int nBytes;
       
 14486 	TInt return_value = 0;
       
 14487     int result = 0;
       
 14488     int err = 0;
       
 14489     int status = 0;
       
 14490     message_hdr_req *msgHdr = NULL;  
       
 14491     message_hdr_resp* msg_struct = NULL;
       
 14492       
       
 14493     	// Read data from the CFG file
       
 14494 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 14495 		{
       
 14496 		iLog->Log ( _L ( "read_data failed" ) );
       
 14497 		free_data ( connect_data );
       
 14498 		return_value = KErrGeneral;	
       
 14499     	goto return_code;
       
 14500 		}
       
 14501 	//request formation	
       
 14502 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 14503 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14504 	
       
 14505 	//message header use
       
 14506 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 14507     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14508     
       
 14509     msgHdr->message_type = ELogin_Request;
       
 14510  
       
 14511     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14512     index += sizeof( message_hdr_req );
       
 14513     
       
 14514     int len = strlen(connect_data->username);
       
 14515     strcpy( smsg + index, connect_data->username );
       
 14516     index += len + 1;
       
 14517     
       
 14518     //appending password
       
 14519     
       
 14520     len = strlen(connect_data->password );
       
 14521     strcpy( smsg + index, connect_data->password );
       
 14522     index += len + 1;
       
 14523     
       
 14524     //appending server name
       
 14525     
       
 14526     len = strlen(connect_data->server );
       
 14527     strcpy( smsg + index, connect_data->server );
       
 14528     index += len + 1;
       
 14529     
       
 14530     //appending resource
       
 14531     len = strlen(connect_data->resource );
       
 14532     strcpy( smsg + index, connect_data->resource );
       
 14533     index += len + 1;
       
 14534     
       
 14535     //appending ssl
       
 14536     smsg[index++]= '0';
       
 14537     smsg[index++]= '\0';
       
 14538     
       
 14539     //appending server port
       
 14540     len = strlen(connect_data->port );
       
 14541     strcpy( smsg + index, connect_data->port );
       
 14542     index += len + 1;
       
 14543     
       
 14544     // appending IAP id
       
 14545     
       
 14546     smsg[index++]= '1';
       
 14547     smsg[index++]= '\0';
       
 14548     
       
 14549     //appending connmgr_bus
       
 14550     len = strlen(connect_data->connmgr_bus );
       
 14551     strcpy( smsg + index, connect_data->connmgr_bus );
       
 14552     index += len + 1;
       
 14553     
       
 14554     //appending connmgr_path
       
 14555     len = strlen(connect_data->connmgr_path );
       
 14556     strcpy( smsg + index, connect_data->connmgr_path );
       
 14557     index += len + 1;
       
 14558     
       
 14559     //appending protocol
       
 14560     len = strlen(connect_data->protocol );
       
 14561     strcpy( smsg + index, connect_data->protocol );
       
 14562     index += len + 1;
       
 14563     
       
 14564     #ifdef __WINSCW__
       
 14565     //proxy server
       
 14566     len = strlen(connect_data->proxy_data->proxy_server );
       
 14567     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 14568     index += len + 1;
       
 14569     
       
 14570     //proxy port
       
 14571     len = strlen(connect_data->proxy_data->proxy_port );
       
 14572     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 14573     index += len + 1;
       
 14574     
       
 14575     #endif
       
 14576     run_isoserver();
       
 14577     
       
 14578     //create message queue for send request
       
 14579     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14580     //create message queue for response request
       
 14581     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14582 		
       
 14583 	
       
 14584 	/* Send Message to queueOne */
       
 14585 	
       
 14586 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14587     
       
 14588     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 14589     
       
 14590     if (status < 0)
       
 14591     {
       
 14592     return_value = KErrGeneral;	
       
 14593     goto return_code;	
       
 14594     }
       
 14595     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 14596 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 14597 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 14598 	
       
 14599 	if( msg_struct->response != 1)
       
 14600     {
       
 14601     	return_value = KErrGeneral;	
       
 14602     	goto return_code;
       
 14603     }
       
 14604     
       
 14605     
       
 14606     // login end
       
 14607     //fetch req..
       
 14608     for (int i= 0 ;i<3 ;i++)
       
 14609     {
       
 14610         
       
 14611     fp = fopen("c:\\fetch_contact.txt","a");
       
 14612 	do  {
       
 14613 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 14614 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14615 		fwrite(rmsg,1,status,fp);
       
 14616 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14617 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 14618 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 14619 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 14620 	fclose(fp);	
       
 14621 	
       
 14622     }
       
 14623 
       
 14624 	//fetch end
       
 14625      
       
 14626     //search messge--------------------------------------------
       
 14627    
       
 14628     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14629 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14630 	index=0;
       
 14631     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14632     msgHdr->message_type = ESearch;	
       
 14633     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14634 	index += sizeof( message_hdr_req );
       
 14635      
       
 14636      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14637      do  {
       
 14638 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14639 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14640 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14641 		} while (msg_struct->hdr_req.message_type!= ESearch );
       
 14642    
       
 14643      if ( msg_struct->response != 0 )
       
 14644     {
       
 14645     	return_value = KErrGeneral;	
       
 14646     	goto return_code;
       
 14647     }    
       
 14648     
       
 14649     
       
 14650     
       
 14651     //search message end---------------------------------------
       
 14652     
       
 14653     
       
 14654     // logout test code from server
       
 14655     index=0;
       
 14656     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14657 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14658 	
       
 14659 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14660     
       
 14661     msgHdr->message_type = ELogout_Request;
       
 14662  
       
 14663     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14664     index += sizeof( message_hdr_req );
       
 14665 
       
 14666 	
       
 14667 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14668      do  {
       
 14669 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14670 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14671 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14672 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 14673    
       
 14674      if ( msg_struct->response != 1)
       
 14675     {
       
 14676     	return_value = KErrGeneral;	
       
 14677     	goto return_code;
       
 14678     }
       
 14679      
       
 14680    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 14681    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 14682     return_value = KErrNone;	
       
 14683     goto return_code;
       
 14684     //killing isoserver
       
 14685     return_code:
       
 14686     index=0;
       
 14687     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14688 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14689 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14690     msgHdr->message_type = EKill_Process;
       
 14691     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14692     index += sizeof( message_hdr_req );
       
 14693 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 14694     free( msg_struct );
       
 14695     return return_value;
       
 14696 
       
 14697 	}
       
 14698 Cisolationserver::SearchKeyValueInvalidHashValues( CStifItemParser& aItem )
       
 14699 	{
       
 14700 	ConnectData  *connect_data = NULL;
       
 14701     char smsg[MAX_MSG_SIZE];
       
 14702     char rmsg[MAX_MSG_SIZE];
       
 14703     int index=0;
       
 14704     FILE *fp;
       
 14705 		
       
 14706 	int timeout = 200;
       
 14707 	int nBytes;
       
 14708 	TInt return_value = 0;
       
 14709     int result = 0;
       
 14710     int err = 0;
       
 14711     int status = 0;
       
 14712     message_hdr_req *msgHdr = NULL;  
       
 14713     message_hdr_resp* msg_struct = NULL;
       
 14714       
       
 14715     	// Read data from the CFG file
       
 14716 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 14717 		{
       
 14718 		iLog->Log ( _L ( "read_data failed" ) );
       
 14719 		free_data ( connect_data );
       
 14720 		return_value = KErrGeneral;	
       
 14721     	goto return_code;
       
 14722 		}
       
 14723 	//request formation	
       
 14724 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 14725 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14726 	
       
 14727 	//message header use
       
 14728 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 14729     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14730     
       
 14731     msgHdr->message_type = ELogin_Request;
       
 14732  
       
 14733     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14734     index += sizeof( message_hdr_req );
       
 14735     
       
 14736     int len = strlen(connect_data->username);
       
 14737     strcpy( smsg + index, connect_data->username );
       
 14738     index += len + 1;
       
 14739     
       
 14740     //appending password
       
 14741     
       
 14742     len = strlen(connect_data->password );
       
 14743     strcpy( smsg + index, connect_data->password );
       
 14744     index += len + 1;
       
 14745     
       
 14746     //appending server name
       
 14747     
       
 14748     len = strlen(connect_data->server );
       
 14749     strcpy( smsg + index, connect_data->server );
       
 14750     index += len + 1;
       
 14751     
       
 14752     //appending resource
       
 14753     len = strlen(connect_data->resource );
       
 14754     strcpy( smsg + index, connect_data->resource );
       
 14755     index += len + 1;
       
 14756     
       
 14757     //appending ssl
       
 14758     smsg[index++]= '0';
       
 14759     smsg[index++]= '\0';
       
 14760     
       
 14761     //appending server port
       
 14762     len = strlen(connect_data->port );
       
 14763     strcpy( smsg + index, connect_data->port );
       
 14764     index += len + 1;
       
 14765     
       
 14766     // appending IAP id
       
 14767     
       
 14768     smsg[index++]= '1';
       
 14769     smsg[index++]= '\0';
       
 14770     
       
 14771     //appending connmgr_bus
       
 14772     len = strlen(connect_data->connmgr_bus );
       
 14773     strcpy( smsg + index, connect_data->connmgr_bus );
       
 14774     index += len + 1;
       
 14775     
       
 14776     //appending connmgr_path
       
 14777     len = strlen(connect_data->connmgr_path );
       
 14778     strcpy( smsg + index, connect_data->connmgr_path );
       
 14779     index += len + 1;
       
 14780     
       
 14781     //appending protocol
       
 14782     len = strlen(connect_data->protocol );
       
 14783     strcpy( smsg + index, connect_data->protocol );
       
 14784     index += len + 1;
       
 14785     
       
 14786     #ifdef __WINSCW__
       
 14787     //proxy server
       
 14788     len = strlen(connect_data->proxy_data->proxy_server );
       
 14789     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 14790     index += len + 1;
       
 14791     
       
 14792     //proxy port
       
 14793     len = strlen(connect_data->proxy_data->proxy_port );
       
 14794     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 14795     index += len + 1;
       
 14796     
       
 14797     #endif
       
 14798     run_isoserver();
       
 14799     
       
 14800     //create message queue for send request
       
 14801     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14802     //create message queue for response request
       
 14803     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 14804 		
       
 14805 	
       
 14806 	/* Send Message to queueOne */
       
 14807 	
       
 14808 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14809     
       
 14810     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 14811     
       
 14812     if (status < 0)
       
 14813     {
       
 14814     return_value = KErrGeneral;	
       
 14815     	goto return_code;	
       
 14816     }
       
 14817     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 14818 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 14819 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 14820 	
       
 14821 	if( msg_struct->response != 1)
       
 14822     {
       
 14823     	return_value = KErrGeneral;	
       
 14824     	goto return_code;
       
 14825     }
       
 14826     
       
 14827     
       
 14828     // login end
       
 14829     //fetch req..
       
 14830     for (int i= 0 ;i<3 ;i++)
       
 14831     {
       
 14832         
       
 14833     fp = fopen("c:\\fetch_contact.txt","a");
       
 14834 	do  {
       
 14835 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 14836 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14837 		fwrite(rmsg,1,status,fp);
       
 14838 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14839 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 14840 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 14841 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 14842 	fclose(fp);	
       
 14843 	
       
 14844     }
       
 14845 
       
 14846 	//fetch end
       
 14847      
       
 14848     //search messge--------------------------------------------
       
 14849    
       
 14850     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14851 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14852 	index=0;
       
 14853     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14854     msgHdr->message_type = ESearch;	
       
 14855     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14856 	index += sizeof( message_hdr_req );
       
 14857 	
       
 14858 	
       
 14859     // adding key
       
 14860     len = strlen( "firstGname" );
       
 14861     strcpy( smsg + index, "firstGname" );
       
 14862     index += len + 1;
       
 14863         
       
 14864     // adding value
       
 14865     len = strlen("I" );
       
 14866     strcpy( smsg + index, "I" );
       
 14867     index += len + 1;
       
 14868     
       
 14869     smsg[index++] = '\0';
       
 14870      
       
 14871      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14872      do  {
       
 14873 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14874 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14875 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14876 		} while (msg_struct->hdr_req.message_type!= ESearch );
       
 14877    
       
 14878      if ( msg_struct->response != 0)
       
 14879     {
       
 14880     	return_value = KErrGeneral;	
       
 14881     	goto return_code;
       
 14882     }    
       
 14883     
       
 14884     
       
 14885     
       
 14886     //search message end---------------------------------------
       
 14887     
       
 14888     
       
 14889     // logout test code from server
       
 14890     index=0;
       
 14891     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14892 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14893 	
       
 14894 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14895     
       
 14896     msgHdr->message_type = ELogout_Request;
       
 14897  
       
 14898     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14899     index += sizeof( message_hdr_req );
       
 14900 
       
 14901 	
       
 14902 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 14903      do  {
       
 14904 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 14905 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 14906 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14907 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 14908    
       
 14909      if ( msg_struct->response != 1)
       
 14910     {
       
 14911     	return_value = KErrGeneral;	
       
 14912     	goto return_code;
       
 14913     }
       
 14914      
       
 14915    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 14916    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 14917     return_value = KErrNone;	
       
 14918     goto return_code;
       
 14919     
       
 14920 //killing isoserver
       
 14921     return_code:
       
 14922     index=0;
       
 14923     memset( smsg, '\0', MAX_MSG_SIZE );
       
 14924 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14925 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14926     msgHdr->message_type = EKill_Process;
       
 14927     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14928     index += sizeof( message_hdr_req );
       
 14929 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 14930     free( msg_struct );
       
 14931     return return_value;
       
 14932 	}
       
 14933 
       
 14934 Cisolationserver::SearchKeyValueBlank( CStifItemParser& aItem )
       
 14935 	{
       
 14936 	ConnectData  *connect_data = NULL;
       
 14937     char smsg[MAX_MSG_SIZE];
       
 14938     char rmsg[MAX_MSG_SIZE];
       
 14939     int index=0;
       
 14940     FILE *fp;
       
 14941 		
       
 14942 	int timeout = 200;
       
 14943 	int nBytes;
       
 14944 	TInt return_value = 0;
       
 14945     int result = 0;
       
 14946     int err = 0;
       
 14947     int status = 0;
       
 14948     message_hdr_req *msgHdr = NULL;  
       
 14949     message_hdr_resp* msg_struct = NULL;
       
 14950       
       
 14951     	// Read data from the CFG file
       
 14952 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 14953 		{
       
 14954 		iLog->Log ( _L ( "read_data failed" ) );
       
 14955 		free_data ( connect_data );
       
 14956 		return_value = KErrGeneral;	
       
 14957     	goto return_code;
       
 14958 		}
       
 14959 	//request formation	
       
 14960 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 14961 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 14962 	
       
 14963 	//message header use
       
 14964 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 14965     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 14966     
       
 14967     msgHdr->message_type = ELogin_Request;
       
 14968  
       
 14969     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 14970     index += sizeof( message_hdr_req );
       
 14971     
       
 14972     int len = strlen(connect_data->username);
       
 14973     strcpy( smsg + index, connect_data->username );
       
 14974     index += len + 1;
       
 14975     
       
 14976     //appending password
       
 14977     
       
 14978     len = strlen(connect_data->password );
       
 14979     strcpy( smsg + index, connect_data->password );
       
 14980     index += len + 1;
       
 14981     
       
 14982     //appending server name
       
 14983     
       
 14984     len = strlen(connect_data->server );
       
 14985     strcpy( smsg + index, connect_data->server );
       
 14986     index += len + 1;
       
 14987     
       
 14988     //appending resource
       
 14989     len = strlen(connect_data->resource );
       
 14990     strcpy( smsg + index, connect_data->resource );
       
 14991     index += len + 1;
       
 14992     
       
 14993     //appending ssl
       
 14994     smsg[index++]= '0';
       
 14995     smsg[index++]= '\0';
       
 14996     
       
 14997     //appending server port
       
 14998     len = strlen(connect_data->port );
       
 14999     strcpy( smsg + index, connect_data->port );
       
 15000     index += len + 1;
       
 15001     
       
 15002     // appending IAP id
       
 15003     
       
 15004     smsg[index++]= '1';
       
 15005     smsg[index++]= '\0';
       
 15006     
       
 15007     //appending connmgr_bus
       
 15008     len = strlen(connect_data->connmgr_bus );
       
 15009     strcpy( smsg + index, connect_data->connmgr_bus );
       
 15010     index += len + 1;
       
 15011     
       
 15012     //appending connmgr_path
       
 15013     len = strlen(connect_data->connmgr_path );
       
 15014     strcpy( smsg + index, connect_data->connmgr_path );
       
 15015     index += len + 1;
       
 15016     
       
 15017     //appending protocol
       
 15018     len = strlen(connect_data->protocol );
       
 15019     strcpy( smsg + index, connect_data->protocol );
       
 15020     index += len + 1;
       
 15021     
       
 15022     #ifdef __WINSCW__
       
 15023     //proxy server
       
 15024     len = strlen(connect_data->proxy_data->proxy_server );
       
 15025     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 15026     index += len + 1;
       
 15027     
       
 15028     //proxy port
       
 15029     len = strlen(connect_data->proxy_data->proxy_port );
       
 15030     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 15031     index += len + 1;
       
 15032     
       
 15033     #endif
       
 15034     run_isoserver();
       
 15035     
       
 15036     //create message queue for send request
       
 15037     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15038     //create message queue for response request
       
 15039     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15040 		
       
 15041 	
       
 15042 	/* Send Message to queueOne */
       
 15043 	
       
 15044 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15045     
       
 15046     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 15047     
       
 15048     if (status < 0)
       
 15049     {
       
 15050     return_value = KErrGeneral;	
       
 15051     	goto return_code;	
       
 15052     }
       
 15053     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 15054 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 15055 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 15056 	
       
 15057 	if( msg_struct->response != 1)
       
 15058     {
       
 15059     	return_value = KErrGeneral;	
       
 15060     	goto return_code;
       
 15061     }
       
 15062     
       
 15063     
       
 15064     // login end
       
 15065     //fetch req..
       
 15066     for (int i= 0 ;i<3 ;i++)
       
 15067     {
       
 15068         
       
 15069     fp = fopen("c:\\fetch_contact.txt","a");
       
 15070 	do  {
       
 15071 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 15072 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15073 		fwrite(rmsg,1,status,fp);
       
 15074 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15075 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 15076 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 15077 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 15078 	fclose(fp);	
       
 15079 	
       
 15080     }
       
 15081 
       
 15082 	//fetch end
       
 15083      
       
 15084     //search messge--------------------------------------------
       
 15085    
       
 15086     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15087 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15088 	index=0;
       
 15089     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15090     msgHdr->message_type = ESearch;	
       
 15091     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15092 	index += sizeof( message_hdr_req );
       
 15093 	
       
 15094 	
       
 15095     // adding key
       
 15096     len = strlen( connect_data->key_jid );
       
 15097     strcpy( smsg + index, connect_data->key_jid );
       
 15098     index += len + 1;
       
 15099         
       
 15100     // adding value
       
 15101     len = strlen("" );
       
 15102     strcpy( smsg + index, "" );
       
 15103     index += len + 1;
       
 15104     
       
 15105     smsg[index++] = '\0';
       
 15106      
       
 15107      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15108      do  {
       
 15109 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15110 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15111 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15112 		} while (msg_struct->hdr_req.message_type!= ESearch );
       
 15113    
       
 15114    
       
 15115    if( msg_struct->error_type != INVALID_PARAMETERES )
       
 15116     {
       
 15117     return_value = KErrGeneral;
       
 15118 	goto return_code;
       
 15119     }
       
 15120     
       
 15121      
       
 15122     
       
 15123     
       
 15124     //search message end---------------------------------------
       
 15125     
       
 15126     
       
 15127     // logout test code from server
       
 15128     index=0;
       
 15129     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15130 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15131 	
       
 15132 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15133     
       
 15134     msgHdr->message_type = ELogout_Request;
       
 15135  
       
 15136     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15137     index += sizeof( message_hdr_req );
       
 15138 
       
 15139 	
       
 15140 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15141      do  {
       
 15142 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15143 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15144 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15145 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 15146    
       
 15147      if ( msg_struct->response != 1)
       
 15148     {
       
 15149     	return_value = KErrGeneral;	
       
 15150     	goto return_code;
       
 15151     }
       
 15152      
       
 15153    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 15154    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 15155     return_value = KErrNone;	
       
 15156     goto return_code;
       
 15157     
       
 15158 //killing isoserver
       
 15159     return_code:
       
 15160     index=0;
       
 15161     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15162 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15163 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15164     msgHdr->message_type = EKill_Process;
       
 15165     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15166     index += sizeof( message_hdr_req );
       
 15167 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 15168     free( msg_struct );
       
 15169     return return_value;
       
 15170 	}
       
 15171 
       
 15172 Cisolationserver::SearchKeyValueLargeString( CStifItemParser& aItem )
       
 15173 	{
       
 15174 	ConnectData  *connect_data = NULL;
       
 15175     char smsg[MAX_MSG_SIZE];
       
 15176     char rmsg[MAX_MSG_SIZE];
       
 15177     int index=0;
       
 15178     FILE *fp;
       
 15179 		
       
 15180 	int timeout = 200;
       
 15181 	int nBytes;
       
 15182 	TInt return_value = 0;
       
 15183     int result = 0;
       
 15184     int err = 0;
       
 15185     int status = 0;
       
 15186     message_hdr_req *msgHdr = NULL;  
       
 15187     message_hdr_resp* msg_struct = NULL;
       
 15188       
       
 15189     	// Read data from the CFG file
       
 15190 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 15191 		{
       
 15192 		iLog->Log ( _L ( "read_data failed" ) );
       
 15193 		free_data ( connect_data );
       
 15194 		return_value = KErrGeneral;	
       
 15195     	goto return_code;
       
 15196 		}
       
 15197 	//request formation	
       
 15198 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 15199 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15200 	
       
 15201 	//message header use
       
 15202 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 15203     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15204     
       
 15205     msgHdr->message_type = ELogin_Request;
       
 15206  
       
 15207     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15208     index += sizeof( message_hdr_req );
       
 15209     
       
 15210     int len = strlen(connect_data->username);
       
 15211     strcpy( smsg + index, connect_data->username );
       
 15212     index += len + 1;
       
 15213     
       
 15214     //appending password
       
 15215     
       
 15216     len = strlen(connect_data->password );
       
 15217     strcpy( smsg + index, connect_data->password );
       
 15218     index += len + 1;
       
 15219     
       
 15220     //appending server name
       
 15221     
       
 15222     len = strlen(connect_data->server );
       
 15223     strcpy( smsg + index, connect_data->server );
       
 15224     index += len + 1;
       
 15225     
       
 15226     //appending resource
       
 15227     len = strlen(connect_data->resource );
       
 15228     strcpy( smsg + index, connect_data->resource );
       
 15229     index += len + 1;
       
 15230     
       
 15231     //appending ssl
       
 15232     smsg[index++]= '0';
       
 15233     smsg[index++]= '\0';
       
 15234     
       
 15235     //appending server port
       
 15236     len = strlen(connect_data->port );
       
 15237     strcpy( smsg + index, connect_data->port );
       
 15238     index += len + 1;
       
 15239     
       
 15240     // appending IAP id
       
 15241     
       
 15242     smsg[index++]= '1';
       
 15243     smsg[index++]= '\0';
       
 15244     
       
 15245     //appending connmgr_bus
       
 15246     len = strlen(connect_data->connmgr_bus );
       
 15247     strcpy( smsg + index, connect_data->connmgr_bus );
       
 15248     index += len + 1;
       
 15249     
       
 15250     //appending connmgr_path
       
 15251     len = strlen(connect_data->connmgr_path );
       
 15252     strcpy( smsg + index, connect_data->connmgr_path );
       
 15253     index += len + 1;
       
 15254     
       
 15255     //appending protocol
       
 15256     len = strlen(connect_data->protocol );
       
 15257     strcpy( smsg + index, connect_data->protocol );
       
 15258     index += len + 1;
       
 15259     
       
 15260     #ifdef __WINSCW__
       
 15261     //proxy server
       
 15262     len = strlen(connect_data->proxy_data->proxy_server );
       
 15263     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 15264     index += len + 1;
       
 15265     
       
 15266     //proxy port
       
 15267     len = strlen(connect_data->proxy_data->proxy_port );
       
 15268     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 15269     index += len + 1;
       
 15270     
       
 15271     #endif
       
 15272     run_isoserver();
       
 15273     
       
 15274     //create message queue for send request
       
 15275     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15276     //create message queue for response request
       
 15277     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15278 		
       
 15279 	
       
 15280 	/* Send Message to queueOne */
       
 15281 	
       
 15282 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15283     
       
 15284     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 15285     
       
 15286     if (status < 0)
       
 15287     {
       
 15288     return_value = KErrGeneral;	
       
 15289     	goto return_code;	
       
 15290     }
       
 15291     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 15292 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 15293 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 15294 	
       
 15295 	if( msg_struct->response != 1)
       
 15296     {
       
 15297     	return_value = KErrGeneral;	
       
 15298     	goto return_code;
       
 15299     }
       
 15300     
       
 15301     
       
 15302     // login end
       
 15303     //fetch req..
       
 15304     for (int i= 0 ;i<3 ;i++)
       
 15305     {
       
 15306         
       
 15307     fp = fopen("c:\\fetch_contact.txt","a");
       
 15308 	do  {
       
 15309 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 15310 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15311 		fwrite(rmsg,1,status,fp);
       
 15312 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15313 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 15314 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 15315 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 15316 	fclose(fp);	
       
 15317 	
       
 15318     }
       
 15319 
       
 15320 	//fetch end
       
 15321      
       
 15322     //search messge--------------------------------------------
       
 15323    
       
 15324     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15325 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15326 	index=0;
       
 15327     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15328     msgHdr->message_type = ESearch;	
       
 15329     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15330 	index += sizeof( message_hdr_req );
       
 15331 	
       
 15332 	
       
 15333     const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 15334     // adding key
       
 15335     len = strlen(search_label);
       
 15336     strcpy( smsg + index, search_label );
       
 15337     index += len + 1;
       
 15338         
       
 15339     // adding value
       
 15340     len = strlen( "Gmail is a new kind of webmail built on \
       
 15341     the idea that email can be more intuitive efficient and useful" );
       
 15342     
       
 15343     strcpy( smsg + index, "Gmail is a new kind of webmail built on \
       
 15344     the idea that email can be more intuitive efficient and useful" );
       
 15345     index += len + 1;
       
 15346     
       
 15347     smsg[index++] = '\0';
       
 15348      
       
 15349      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15350      do  {
       
 15351 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15352 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15353 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15354 		} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 15355    
       
 15356      if ( msg_struct->response != 1)
       
 15357     {
       
 15358     	return_value = KErrGeneral;	
       
 15359     	goto return_code;
       
 15360     }    
       
 15361     
       
 15362     
       
 15363     
       
 15364     //search message end---------------------------------------
       
 15365     
       
 15366     
       
 15367     // logout test code from server
       
 15368     index=0;
       
 15369     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15370 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15371 	
       
 15372 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15373     
       
 15374     msgHdr->message_type = ELogout_Request;
       
 15375  
       
 15376     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15377     index += sizeof( message_hdr_req );
       
 15378 
       
 15379 	
       
 15380 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15381      do  {
       
 15382 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15383 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15384 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15385 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 15386    
       
 15387      if ( msg_struct->response != 1)
       
 15388     {
       
 15389     	return_value = KErrGeneral;	
       
 15390     	goto return_code;
       
 15391     }
       
 15392      
       
 15393    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 15394    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 15395     return_value = KErrNone;	
       
 15396     goto return_code;
       
 15397     
       
 15398 //killing isoserver
       
 15399     return_code:
       
 15400     index=0;
       
 15401     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15402 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15403 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15404     msgHdr->message_type = EKill_Process;
       
 15405     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15406     index += sizeof( message_hdr_req );
       
 15407 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 15408     free( msg_struct );
       
 15409     return return_value;
       
 15410 	}
       
 15411 
       
 15412 Cisolationserver::SearchKeyValueSpecialChar( CStifItemParser& aItem )
       
 15413 	{
       
 15414 	ConnectData  *connect_data = NULL;
       
 15415     char smsg[MAX_MSG_SIZE];
       
 15416     char rmsg[MAX_MSG_SIZE];
       
 15417     int index=0;
       
 15418     FILE *fp;
       
 15419 		
       
 15420 	int timeout = 200;
       
 15421 	int nBytes;
       
 15422 	TInt return_value = 0;
       
 15423     int result = 0;
       
 15424     int err = 0;
       
 15425     int status = 0;
       
 15426     message_hdr_req *msgHdr = NULL;  
       
 15427     message_hdr_resp* msg_struct = NULL;
       
 15428       
       
 15429     	// Read data from the CFG file
       
 15430 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 15431 		{
       
 15432 		iLog->Log ( _L ( "read_data failed" ) );
       
 15433 		free_data ( connect_data );
       
 15434 		return_value = KErrGeneral;	
       
 15435     	goto return_code;
       
 15436 		}
       
 15437 	//request formation	
       
 15438 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 15439 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15440 	
       
 15441 	//message header use
       
 15442 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 15443     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15444     
       
 15445     msgHdr->message_type = ELogin_Request;
       
 15446  
       
 15447     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15448     index += sizeof( message_hdr_req );
       
 15449     
       
 15450     int len = strlen(connect_data->username);
       
 15451     strcpy( smsg + index, connect_data->username );
       
 15452     index += len + 1;
       
 15453     
       
 15454     //appending password
       
 15455     
       
 15456     len = strlen(connect_data->password );
       
 15457     strcpy( smsg + index, connect_data->password );
       
 15458     index += len + 1;
       
 15459     
       
 15460     //appending server name
       
 15461     
       
 15462     len = strlen(connect_data->server );
       
 15463     strcpy( smsg + index, connect_data->server );
       
 15464     index += len + 1;
       
 15465     
       
 15466     //appending resource
       
 15467     len = strlen(connect_data->resource );
       
 15468     strcpy( smsg + index, connect_data->resource );
       
 15469     index += len + 1;
       
 15470     
       
 15471     //appending ssl
       
 15472     smsg[index++]= '0';
       
 15473     smsg[index++]= '\0';
       
 15474     
       
 15475     //appending server port
       
 15476     len = strlen(connect_data->port );
       
 15477     strcpy( smsg + index, connect_data->port );
       
 15478     index += len + 1;
       
 15479     
       
 15480     // appending IAP id
       
 15481     
       
 15482     smsg[index++]= '1';
       
 15483     smsg[index++]= '\0';
       
 15484     
       
 15485     //appending connmgr_bus
       
 15486     len = strlen(connect_data->connmgr_bus );
       
 15487     strcpy( smsg + index, connect_data->connmgr_bus );
       
 15488     index += len + 1;
       
 15489     
       
 15490     //appending connmgr_path
       
 15491     len = strlen(connect_data->connmgr_path );
       
 15492     strcpy( smsg + index, connect_data->connmgr_path );
       
 15493     index += len + 1;
       
 15494     
       
 15495     //appending protocol
       
 15496     len = strlen(connect_data->protocol );
       
 15497     strcpy( smsg + index, connect_data->protocol );
       
 15498     index += len + 1;
       
 15499     
       
 15500     #ifdef __WINSCW__
       
 15501     //proxy server
       
 15502     len = strlen(connect_data->proxy_data->proxy_server );
       
 15503     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 15504     index += len + 1;
       
 15505     
       
 15506     //proxy port
       
 15507     len = strlen(connect_data->proxy_data->proxy_port );
       
 15508     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 15509     index += len + 1;
       
 15510     
       
 15511     #endif
       
 15512     run_isoserver();
       
 15513     
       
 15514     //create message queue for send request
       
 15515     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15516     //create message queue for response request
       
 15517     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15518 		
       
 15519 	
       
 15520 	/* Send Message to queueOne */
       
 15521 	
       
 15522 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15523     
       
 15524     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 15525     
       
 15526     if (status < 0)
       
 15527     {
       
 15528     return_value = KErrGeneral;	
       
 15529     	goto return_code;	
       
 15530     }
       
 15531     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 15532 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 15533 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 15534 	
       
 15535 	if( msg_struct->response != 1)
       
 15536     {
       
 15537     	return_value = KErrGeneral;	
       
 15538     	goto return_code;
       
 15539     }
       
 15540     
       
 15541     
       
 15542     // login end
       
 15543     //fetch req..
       
 15544     for (int i= 0 ;i<3 ;i++)
       
 15545     {
       
 15546         
       
 15547     fp = fopen("c:\\fetch_contact.txt","a");
       
 15548 	do  {
       
 15549 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 15550 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15551 		fwrite(rmsg,1,status,fp);
       
 15552 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15553 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 15554 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 15555 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 15556 	fclose(fp);	
       
 15557 	
       
 15558     }
       
 15559 
       
 15560 	//fetch end
       
 15561      
       
 15562     //search messge--------------------------------------------
       
 15563    
       
 15564     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15565 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15566 	index=0;
       
 15567     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15568     msgHdr->message_type = ESearch;	
       
 15569     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15570 	index += sizeof( message_hdr_req );
       
 15571 	
       
 15572 	
       
 15573     const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 15574     // adding key
       
 15575     len = strlen(search_label);
       
 15576     strcpy( smsg + index, search_label );
       
 15577     index += len + 1;
       
 15578         
       
 15579     // adding value
       
 15580     len = strlen("happy_123@chat.gizmoproject.com" );
       
 15581     strcpy( smsg + index, "happy_123@chat.gizmoproject.com" );
       
 15582     index += len + 1;
       
 15583     
       
 15584     smsg[index++] = '\0';
       
 15585      
       
 15586      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15587      do  {
       
 15588 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15589 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15590 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15591 		} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 15592    
       
 15593      if ( msg_struct->response != 1)
       
 15594     {
       
 15595     	return_value = KErrGeneral;	
       
 15596     	goto return_code;
       
 15597     }    
       
 15598     
       
 15599     
       
 15600     
       
 15601     //search message end---------------------------------------
       
 15602     
       
 15603     
       
 15604     // logout test code from server
       
 15605     index=0;
       
 15606     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15607 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15608 	
       
 15609 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15610     
       
 15611     msgHdr->message_type = ELogout_Request;
       
 15612  
       
 15613     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15614     index += sizeof( message_hdr_req );
       
 15615 
       
 15616 	
       
 15617 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15618      do  {
       
 15619 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15620 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15621 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15622 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 15623    
       
 15624      if ( msg_struct->response != 1)
       
 15625     {
       
 15626     	return_value = KErrGeneral;	
       
 15627     	goto return_code;
       
 15628     }
       
 15629      
       
 15630    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 15631    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 15632     return_value = KErrNone;	
       
 15633     goto return_code;
       
 15634     
       
 15635 //killing isoserver
       
 15636     return_code:
       
 15637     index=0;
       
 15638     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15639 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15640 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15641     msgHdr->message_type = EKill_Process;
       
 15642     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15643     index += sizeof( message_hdr_req );
       
 15644 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 15645     free( msg_struct );
       
 15646     return return_value;
       
 15647 	}
       
 15648 
       
 15649     // -----------------------------------------------------------------------------
       
 15650 // Cisolationserver::RejectAddRequestFromUser
       
 15651 // Example test method function.
       
 15652 // (other items were commented in a header).
       
 15653 // -----------------------------------------------------------------------------
       
 15654 //RejectAddRequestFromUser
       
 15655 TInt Cisolationserver::RejectAddRequestFromUser( CStifItemParser& aItem )
       
 15656     {
       
 15657 
       
 15658     	
       
 15659     ConnectData  *connect_data = NULL;
       
 15660     char smsg[MAX_MSG_SIZE];
       
 15661     char rmsg[MAX_MSG_SIZE];
       
 15662     int index=0;
       
 15663     
       
 15664 		
       
 15665 	int timeout = 100;
       
 15666 	int nBytes;
       
 15667 
       
 15668     int result = 0;
       
 15669     int err = 0;
       
 15670     int status = 0;
       
 15671     FILE *fp;
       
 15672     message_hdr_req *msgHdr = NULL;  
       
 15673     message_hdr_resp* msg_struct = NULL;
       
 15674     TInt return_value = 0;
       
 15675         	// Read data from the CFG file
       
 15676 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 15677 		{
       
 15678 		iLog->Log ( _L ( "read_data failed" ) );
       
 15679 		free_data ( connect_data );
       
 15680 		return_value = KErrGeneral;
       
 15681 		goto return_code;
       
 15682 		}
       
 15683 	//request formation	
       
 15684 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 15685 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15686 	
       
 15687 	//message header use
       
 15688 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 15689     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15690     
       
 15691     msgHdr->message_type = ELogin_Request;
       
 15692  
       
 15693     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15694     index += sizeof( message_hdr_req );
       
 15695     
       
 15696     int len = strlen(connect_data->username);
       
 15697     strcpy( smsg + index, connect_data->username );
       
 15698     index += len + 1;
       
 15699     
       
 15700     //appending password
       
 15701     
       
 15702     len = strlen(connect_data->password );
       
 15703     strcpy( smsg + index, connect_data->password );
       
 15704     index += len + 1;
       
 15705 
       
 15706     //appending server name
       
 15707     
       
 15708     len = strlen(connect_data->server );
       
 15709     strcpy( smsg + index, connect_data->server );
       
 15710     index += len + 1;
       
 15711     
       
 15712     //appending resource
       
 15713     len = strlen(connect_data->resource );
       
 15714     strcpy( smsg + index, connect_data->resource );
       
 15715     index += len + 1;
       
 15716     
       
 15717     //appending ssl
       
 15718     smsg[index++]= '1';
       
 15719     smsg[index++]= '\0';
       
 15720     
       
 15721     //appending server port
       
 15722     len = strlen(connect_data->port );
       
 15723     strcpy( smsg + index, connect_data->port );
       
 15724     index += len + 1;
       
 15725     
       
 15726     // appending IAP id
       
 15727     
       
 15728     smsg[index++]= '1';
       
 15729     smsg[index++]= '\0';
       
 15730     
       
 15731     //appending connmgr_bus
       
 15732     len = strlen(connect_data->connmgr_bus );
       
 15733     strcpy( smsg + index, connect_data->connmgr_bus );
       
 15734     index += len + 1;
       
 15735     
       
 15736     //appending connmgr_path
       
 15737     len = strlen(connect_data->connmgr_path );
       
 15738     strcpy( smsg + index, connect_data->connmgr_path );
       
 15739     index += len + 1;
       
 15740     
       
 15741     //appending protocol
       
 15742     len = strlen(connect_data->protocol );
       
 15743     strcpy( smsg + index, connect_data->protocol );
       
 15744     index += len + 1;
       
 15745     
       
 15746     #ifdef __WINSCW__
       
 15747     //proxy server
       
 15748     len = strlen(connect_data->proxy_data->proxy_server );
       
 15749     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 15750     index += len + 1;
       
 15751     
       
 15752     //proxy port
       
 15753     len = strlen(connect_data->proxy_data->proxy_port );
       
 15754     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 15755     index += len + 1;
       
 15756     
       
 15757     #endif
       
 15758     //running isoserver   
       
 15759     run_isoserver(); 
       
 15760     //create message queue for send request
       
 15761     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15762     //create message queue for response request
       
 15763     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 15764 		
       
 15765 
       
 15766 	/* Send Message to queueOne */
       
 15767 	
       
 15768 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15769     
       
 15770     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 15771     
       
 15772     if (status < 0)
       
 15773     {
       
 15774     return_value = KErrGeneral;
       
 15775 	goto return_code;	
       
 15776     }
       
 15777     
       
 15778  
       
 15779     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 15780 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 15781 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 15782 	
       
 15783 	if( msg_struct->response != 1)
       
 15784     {
       
 15785     	return_value = KErrGeneral;
       
 15786 	goto return_code;
       
 15787     }
       
 15788     
       
 15789     
       
 15790     // login end
       
 15791     //fetch req..
       
 15792     for (int i= 0 ;i<3 ;i++)
       
 15793     {
       
 15794         
       
 15795     fp = fopen("c:\\fetch_contact.txt","a");
       
 15796 	do  {
       
 15797 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 15798 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15799 		fwrite(rmsg,1,status,fp);
       
 15800 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15801 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 15802 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 15803 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 15804 	fclose(fp);	
       
 15805 	
       
 15806     }
       
 15807 
       
 15808 	//fetch end
       
 15809 	//fetch end
       
 15810 	// getting add notification from user
       
 15811 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 15812 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15813 	index=0;
       
 15814     
       
 15815 	do  {
       
 15816     	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15817 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15818 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15819 	  //  memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15820 		} while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
       
 15821    
       
 15822     if ( msg_struct->response != 1)
       
 15823     {
       
 15824     return_value = KErrGeneral;
       
 15825 	goto return_code;
       
 15826     }
       
 15827     char *userid = (char *)malloc(100);
       
 15828     len=0;
       
 15829     len+=sizeof(message_hdr_resp);
       
 15830     strcpy(userid,rmsg+len);
       
 15831     
       
 15832     
       
 15833     
       
 15834 
       
 15835     // rejecting add request from user 
       
 15836     
       
 15837     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15838 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15839 	index=0;
       
 15840     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15841     msgHdr->message_type = EReject_Contact_Request;	
       
 15842     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15843 	index += sizeof( message_hdr_req );
       
 15844 	len=0;
       
 15845     len+=strlen(userid);
       
 15846 	strcpy( smsg + index ,userid   );
       
 15847     index += len + 1;
       
 15848 	
       
 15849 	
       
 15850     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15851     
       
 15852     do  {
       
 15853 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15854 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15855 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15856 		} while (msg_struct->hdr_req.message_type!=EReject_Contact_Request);
       
 15857    
       
 15858     if ( msg_struct->response != 1)
       
 15859     {
       
 15860     return_value = KErrGeneral;
       
 15861 	goto return_code;
       
 15862     }
       
 15863     
       
 15864     // logout test code from server
       
 15865     index=0;
       
 15866     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15867 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15868 	
       
 15869 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15870     
       
 15871     msgHdr->message_type = ELogout_Request;
       
 15872  
       
 15873     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15874     index += sizeof( message_hdr_req );
       
 15875 
       
 15876 	
       
 15877 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 15878     
       
 15879     do  {
       
 15880 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 15881 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 15882 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15883 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 15884    
       
 15885     if ( msg_struct->response != 1)
       
 15886     {
       
 15887     	return_value = KErrGeneral;
       
 15888 	goto return_code;
       
 15889     }
       
 15890     //killing isoserver
       
 15891     return_code:
       
 15892     index=0;
       
 15893     memset( smsg, '\0', MAX_MSG_SIZE );
       
 15894 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15895 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15896     msgHdr->message_type = EKill_Process;
       
 15897     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15898     index += sizeof( message_hdr_req );
       
 15899 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 15900     free( msg_struct );
       
 15901     return return_value;
       
 15902     }
       
 15903 
       
 15904      // -----------------------------------------------------------------------------
       
 15905 // Cisolationserver::AcceptAddRequestFromUser
       
 15906 // Example test method function.
       
 15907 // (other items were commented in a header).
       
 15908 // -----------------------------------------------------------------------------
       
 15909 //
       
 15910 Cisolationserver::SearchAndAddContact( CStifItemParser& aItem )
       
 15911 	{
       
 15912 	
       
 15913 	ConnectData  *connect_data = NULL;
       
 15914     char smsg[MAX_MSG_SIZE];
       
 15915     char rmsg[MAX_MSG_SIZE];
       
 15916     int index=0;
       
 15917     FILE *fp;
       
 15918 		
       
 15919 	int timeout = 200;
       
 15920 	int nBytes;
       
 15921 	TInt return_value = 0;
       
 15922     int result = 0;
       
 15923     int err = 0;
       
 15924     int status = 0;
       
 15925     message_hdr_req *msgHdr = NULL;  
       
 15926     message_hdr_resp* msg_struct = NULL;
       
 15927       
       
 15928     	// Read data from the CFG file
       
 15929 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 15930 		{
       
 15931 		iLog->Log ( _L ( "read_data failed" ) );
       
 15932 		free_data ( connect_data );
       
 15933 		return_value = KErrGeneral;	
       
 15934     	goto return_code;
       
 15935 		}
       
 15936 	//request formation	
       
 15937 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 15938 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 15939 	
       
 15940 	//message header use
       
 15941 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 15942     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 15943     
       
 15944     msgHdr->message_type = ELogin_Request;
       
 15945  
       
 15946     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 15947     index += sizeof( message_hdr_req );
       
 15948     
       
 15949     int len = strlen(connect_data->username);
       
 15950     strcpy( smsg + index, connect_data->username );
       
 15951     index += len + 1;
       
 15952     
       
 15953     //appending password
       
 15954     
       
 15955     len = strlen(connect_data->password );
       
 15956     strcpy( smsg + index, connect_data->password );
       
 15957     index += len + 1;
       
 15958     
       
 15959     //appending server name
       
 15960     
       
 15961     len = strlen(connect_data->server );
       
 15962     strcpy( smsg + index, connect_data->server );
       
 15963     index += len + 1;
       
 15964     
       
 15965     //appending resource
       
 15966     len = strlen(connect_data->resource );
       
 15967     strcpy( smsg + index, connect_data->resource );
       
 15968     index += len + 1;
       
 15969     
       
 15970     //appending ssl
       
 15971     smsg[index++]= '0';
       
 15972     smsg[index++]= '\0';
       
 15973     
       
 15974     //appending server port
       
 15975     len = strlen(connect_data->port );
       
 15976     strcpy( smsg + index, connect_data->port );
       
 15977     index += len + 1;
       
 15978     
       
 15979     // appending IAP id
       
 15980     
       
 15981     smsg[index++]= '1';
       
 15982     smsg[index++]= '\0';
       
 15983     
       
 15984     //appending connmgr_bus
       
 15985     len = strlen(connect_data->connmgr_bus );
       
 15986     strcpy( smsg + index, connect_data->connmgr_bus );
       
 15987     index += len + 1;
       
 15988     
       
 15989     //appending connmgr_path
       
 15990     len = strlen(connect_data->connmgr_path );
       
 15991     strcpy( smsg + index, connect_data->connmgr_path );
       
 15992     index += len + 1;
       
 15993     
       
 15994     //appending protocol
       
 15995     len = strlen(connect_data->protocol );
       
 15996     strcpy( smsg + index, connect_data->protocol );
       
 15997     index += len + 1;
       
 15998     
       
 15999     #ifdef __WINSCW__
       
 16000     //proxy server
       
 16001     len = strlen(connect_data->proxy_data->proxy_server );
       
 16002     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 16003     index += len + 1;
       
 16004     
       
 16005     //proxy port
       
 16006     len = strlen(connect_data->proxy_data->proxy_port );
       
 16007     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 16008     index += len + 1;
       
 16009     
       
 16010     #endif
       
 16011     run_isoserver();
       
 16012     
       
 16013     //create message queue for send request
       
 16014     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16015     //create message queue for response request
       
 16016     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16017 		
       
 16018 	
       
 16019 	/* Send Message to queueOne */
       
 16020 	
       
 16021 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16022     
       
 16023     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 16024     
       
 16025     if (status < 0)
       
 16026     {
       
 16027     return_value = KErrGeneral;	
       
 16028     	goto return_code;	
       
 16029     }
       
 16030     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 16031 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 16032 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 16033 	
       
 16034 	if( msg_struct->response != 1)
       
 16035     {
       
 16036     	return_value = KErrGeneral;	
       
 16037     	goto return_code;
       
 16038     }
       
 16039     
       
 16040     
       
 16041     // login end
       
 16042     //fetch req..
       
 16043     for (int i= 0 ;i<3 ;i++)
       
 16044     {
       
 16045         
       
 16046     fp = fopen("c:\\fetch_contact.txt","a");
       
 16047 	do  {
       
 16048 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 16049 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16050 		fwrite(rmsg,1,status,fp);
       
 16051 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16052 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 16053 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 16054 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 16055 	fclose(fp);	
       
 16056 	
       
 16057     }
       
 16058 
       
 16059 	//fetch end
       
 16060      
       
 16061     //search messge--------------------------------------------
       
 16062    
       
 16063     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16064 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16065 	index=0;
       
 16066     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16067     msgHdr->message_type = ESearch;	
       
 16068     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16069 	index += sizeof( message_hdr_req );
       
 16070 	
       
 16071 	
       
 16072     const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 16073     // adding key
       
 16074     len = strlen(search_label);
       
 16075     strcpy( smsg + index, search_label );
       
 16076     index += len + 1;
       
 16077         
       
 16078     // adding value
       
 16079     len = strlen("rakesh" );
       
 16080     strcpy( smsg + index, "rakesh" );
       
 16081     index += len + 1;
       
 16082     
       
 16083     smsg[index++] = '\0';
       
 16084     
       
 16085     gint temp = 0;
       
 16086     gchar* add_contact = NULL;
       
 16087      
       
 16088      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16089      do  
       
 16090      	{
       
 16091 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16092 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16093 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16094 	    //To add contact only once for the first time
       
 16095 	    if ( 0 == temp && ESearch == msg_struct->hdr_req.message_type )
       
 16096 	    	{
       
 16097 	        // length will point to the start of the contact to be added
       
 16098 		    int length = 0;
       
 16099 		    length += sizeof( message_hdr_resp );
       
 16100 		    
       
 16101 		    while ( 0 != strcmp( "jid", rmsg + length ) 
       
 16102 		    	&& '\0' != *( rmsg + length + 1) )
       
 16103 			    {
       
 16104 			    length += strlen( rmsg + length ) + 1;
       
 16105 			    gchar* add_contact = rmsg + length;
       
 16106 			    }
       
 16107 		    length += strlen( rmsg + length ) + 1;
       
 16108 		    
       
 16109 		    add_contact = strdup( rmsg + length );
       
 16110 		    //add contact end---------------------------------------   	
       
 16111 	   		temp++;
       
 16112 	   	 }
       
 16113 	    
       
 16114 	    
       
 16115 	 	} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 16116    
       
 16117      if ( msg_struct->response != 1 )
       
 16118     	{
       
 16119     	return_value = KErrGeneral;	
       
 16120     	goto return_code;
       
 16121    		}    
       
 16122    		
       
 16123     //search message end---------------------------------------
       
 16124  
       
 16125   //adding contact --------------------------------------------
       
 16126 		   
       
 16127     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16128 	index=0;
       
 16129     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16130     msgHdr->message_type = EAdd_Contact_Request;	
       
 16131     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16132 	index += sizeof( message_hdr_req );
       
 16133 	// adding add contact
       
 16134     len = strlen( add_contact );
       
 16135     strcpy( smsg + index, add_contact );
       
 16136     index += len + 1;
       
 16137     smsg[index++]='\0';
       
 16138     
       
 16139     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16140      do  {
       
 16141 		
       
 16142 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16143 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16144 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16145 	    
       
 16146 		} while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
       
 16147    
       
 16148      if ( msg_struct->response != 1 )
       
 16149     {
       
 16150     	return_value = KErrGeneral;
       
 16151 		goto return_code;
       
 16152     }
       
 16153  
       
 16154  
       
 16155     // logout test code from server
       
 16156     index=0;
       
 16157     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16158 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16159 	
       
 16160 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16161     
       
 16162     msgHdr->message_type = ELogout_Request;
       
 16163  
       
 16164     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16165     index += sizeof( message_hdr_req );
       
 16166 
       
 16167 	
       
 16168 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16169      do  {
       
 16170 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16171 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16172 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16173 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 16174    
       
 16175      if ( msg_struct->response != 1)
       
 16176     {
       
 16177     	return_value = KErrGeneral;	
       
 16178     	goto return_code;
       
 16179     }
       
 16180      
       
 16181    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 16182    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 16183     return_value = KErrNone;	
       
 16184     goto return_code;
       
 16185     
       
 16186 //killing isoserver
       
 16187     return_code:
       
 16188     index=0;
       
 16189     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16190 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16191 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16192     msgHdr->message_type = EKill_Process;
       
 16193     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16194     index += sizeof( message_hdr_req );
       
 16195 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 16196     free( msg_struct );
       
 16197     return return_value;		
       
 16198 	}
       
 16199 
       
 16200 // -----------------------------------------------------------------------------
       
 16201 // Cisolationserver::AcceptAddRequestFromUser
       
 16202 // Example test method function.
       
 16203 // (other items were commented in a header).
       
 16204 // -----------------------------------------------------------------------------
       
 16205 //
       
 16206 Cisolationserver::SecondSearch( CStifItemParser& aItem )
       
 16207 	{
       
 16208 	
       
 16209 	ConnectData  *connect_data = NULL;
       
 16210     char smsg[MAX_MSG_SIZE];
       
 16211     char rmsg[MAX_MSG_SIZE];
       
 16212     int index=0;
       
 16213     FILE *fp;
       
 16214 		
       
 16215 	int timeout = 200;
       
 16216 	int nBytes;
       
 16217 	TInt return_value = 0;
       
 16218     int result = 0;
       
 16219     int err = 0;
       
 16220     int status = 0;
       
 16221     message_hdr_req *msgHdr = NULL;  
       
 16222     message_hdr_resp* msg_struct = NULL;
       
 16223       
       
 16224     	// Read data from the CFG file
       
 16225 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 16226 		{
       
 16227 		iLog->Log ( _L ( "read_data failed" ) );
       
 16228 		free_data ( connect_data );
       
 16229 		return_value = KErrGeneral;	
       
 16230     	goto return_code;
       
 16231 		}
       
 16232 	//request formation	
       
 16233 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 16234 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16235 	
       
 16236 	//message header use
       
 16237 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 16238     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16239     
       
 16240     msgHdr->message_type = ELogin_Request;
       
 16241  
       
 16242     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16243     index += sizeof( message_hdr_req );
       
 16244     
       
 16245     int len = strlen(connect_data->username);
       
 16246     strcpy( smsg + index, connect_data->username );
       
 16247     index += len + 1;
       
 16248     
       
 16249     //appending password
       
 16250     
       
 16251     len = strlen(connect_data->password );
       
 16252     strcpy( smsg + index, connect_data->password );
       
 16253     index += len + 1;
       
 16254     
       
 16255     //appending server name
       
 16256     
       
 16257     len = strlen(connect_data->server );
       
 16258     strcpy( smsg + index, connect_data->server );
       
 16259     index += len + 1;
       
 16260     
       
 16261     //appending resource
       
 16262     len = strlen(connect_data->resource );
       
 16263     strcpy( smsg + index, connect_data->resource );
       
 16264     index += len + 1;
       
 16265     
       
 16266     //appending ssl
       
 16267     smsg[index++]= '0';
       
 16268     smsg[index++]= '\0';
       
 16269     
       
 16270     //appending server port
       
 16271     len = strlen(connect_data->port );
       
 16272     strcpy( smsg + index, connect_data->port );
       
 16273     index += len + 1;
       
 16274     
       
 16275     // appending IAP id
       
 16276     
       
 16277     smsg[index++]= '1';
       
 16278     smsg[index++]= '\0';
       
 16279     
       
 16280     //appending connmgr_bus
       
 16281     len = strlen(connect_data->connmgr_bus );
       
 16282     strcpy( smsg + index, connect_data->connmgr_bus );
       
 16283     index += len + 1;
       
 16284     
       
 16285     //appending connmgr_path
       
 16286     len = strlen(connect_data->connmgr_path );
       
 16287     strcpy( smsg + index, connect_data->connmgr_path );
       
 16288     index += len + 1;
       
 16289     
       
 16290     //appending protocol
       
 16291     len = strlen(connect_data->protocol );
       
 16292     strcpy( smsg + index, connect_data->protocol );
       
 16293     index += len + 1;
       
 16294     
       
 16295     #ifdef __WINSCW__
       
 16296     //proxy server
       
 16297     len = strlen(connect_data->proxy_data->proxy_server );
       
 16298     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 16299     index += len + 1;
       
 16300     
       
 16301     //proxy port
       
 16302     len = strlen(connect_data->proxy_data->proxy_port );
       
 16303     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 16304     index += len + 1;
       
 16305     
       
 16306     #endif
       
 16307     run_isoserver();
       
 16308     
       
 16309     //create message queue for send request
       
 16310     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16311     //create message queue for response request
       
 16312     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16313 		
       
 16314 	
       
 16315 	/* Send Message to queueOne */
       
 16316 	
       
 16317 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16318     
       
 16319     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 16320     
       
 16321     if (status < 0)
       
 16322     {
       
 16323     return_value = KErrGeneral;	
       
 16324     	goto return_code;	
       
 16325     }
       
 16326     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 16327 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 16328 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 16329 	
       
 16330 	if( msg_struct->response != 1)
       
 16331     {
       
 16332     	return_value = KErrGeneral;	
       
 16333     	goto return_code;
       
 16334     }
       
 16335     
       
 16336     
       
 16337     // login end
       
 16338     //fetch req..
       
 16339     for (int i= 0 ;i<3 ;i++)
       
 16340     {
       
 16341         
       
 16342     fp = fopen("c:\\fetch_contact.txt","a");
       
 16343 	do  {
       
 16344 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 16345 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16346 		fwrite(rmsg,1,status,fp);
       
 16347 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16348 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 16349 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 16350 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 16351 	fclose(fp);	
       
 16352 	
       
 16353     }
       
 16354 
       
 16355 	//fetch end
       
 16356      
       
 16357     //search messge--------------------------------------------
       
 16358    
       
 16359     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16360 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16361 	index=0;
       
 16362     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16363     msgHdr->message_type = ESearch;	
       
 16364     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16365 	index += sizeof( message_hdr_req );
       
 16366 	
       
 16367 	const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
       
 16368     // adding key
       
 16369     len = strlen(search_label);
       
 16370     strcpy( smsg + index, search_label );
       
 16371     index += len + 1;
       
 16372         
       
 16373     // adding value
       
 16374     len = strlen("sharath" );
       
 16375     strcpy( smsg + index, "sharath" );
       
 16376     index += len + 1;
       
 16377     
       
 16378     smsg[index++] = '\0';
       
 16379     
       
 16380     gint temp = 0;
       
 16381     gchar* add_contact = NULL;
       
 16382      
       
 16383      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16384      do  
       
 16385      	{
       
 16386 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16387 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16388 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );		    
       
 16389 	    
       
 16390 	 	} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 16391    
       
 16392      if ( msg_struct->response != 1 )
       
 16393     	{
       
 16394     	return_value = KErrGeneral;	
       
 16395     	goto return_code;
       
 16396    		}    
       
 16397    		
       
 16398     //search message end---------------------------------------
       
 16399  
       
 16400  
       
 16401      //second search messge--------------------------------------------
       
 16402    
       
 16403     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16404 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16405 	index=0;
       
 16406     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16407     msgHdr->message_type = ESearch;	
       
 16408     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16409 	index += sizeof( message_hdr_req );
       
 16410 	
       
 16411 	
       
 16412 
       
 16413     
       
 16414     const gchar* search_label1 = GetSearchLabelL(connect_data->server,connect_data->key_middle_name);
       
 16415     // adding key
       
 16416     len = strlen(search_label1);
       
 16417     strcpy( smsg + index, search_label1 );
       
 16418     index += len + 1;
       
 16419         
       
 16420     // adding value
       
 16421     len = strlen("Jeppu" );
       
 16422     strcpy( smsg + index, "Jeppu" );
       
 16423     index += len + 1;
       
 16424     
       
 16425     smsg[index++] = '\0';
       
 16426     
       
 16427 
       
 16428      
       
 16429      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16430      do  
       
 16431      	{
       
 16432 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16433 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16434 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );		    
       
 16435 	 	} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 16436    
       
 16437      if ( msg_struct->response != 1 )
       
 16438     	{
       
 16439     	return_value = KErrGeneral;	
       
 16440     	goto return_code;
       
 16441    		}    
       
 16442    	
       
 16443     //search message end---------------------------------------
       
 16444  
       
 16445  
       
 16446  
       
 16447     // logout test code from server
       
 16448     index=0;
       
 16449     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16450 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16451 	
       
 16452 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16453     
       
 16454     msgHdr->message_type = ELogout_Request;
       
 16455  
       
 16456     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16457     index += sizeof( message_hdr_req );
       
 16458 
       
 16459 	
       
 16460 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16461      do  {
       
 16462 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16463 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16464 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16465 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 16466    
       
 16467      if ( msg_struct->response != 1)
       
 16468     {
       
 16469     	return_value = KErrGeneral;	
       
 16470     	goto return_code;
       
 16471     }
       
 16472      
       
 16473    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 16474    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 16475     return_value = KErrNone;	
       
 16476     goto return_code;
       
 16477     
       
 16478 //killing isoserver
       
 16479     return_code:
       
 16480     index=0;
       
 16481     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16482 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16483 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16484     msgHdr->message_type = EKill_Process;
       
 16485     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16486     index += sizeof( message_hdr_req );
       
 16487 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 16488     free( msg_struct );
       
 16489     return return_value;		
       
 16490 	}
       
 16491 
       
 16492 
       
 16493 TInt Cisolationserver::AcceptAddRequestFromUser( CStifItemParser& aItem )
       
 16494     {
       
 16495 
       
 16496     	
       
 16497     ConnectData  *connect_data = NULL;
       
 16498     char smsg[MAX_MSG_SIZE];
       
 16499     char rmsg[MAX_MSG_SIZE];
       
 16500     int index=0;
       
 16501     
       
 16502 		
       
 16503 	int timeout = 100;
       
 16504 	int nBytes;
       
 16505 
       
 16506     int result = 0;
       
 16507     int err = 0;
       
 16508     int status = 0;
       
 16509     FILE *fp;
       
 16510     message_hdr_req *msgHdr = NULL;  
       
 16511     message_hdr_resp* msg_struct = NULL;
       
 16512     TInt return_value = 0;
       
 16513         	// Read data from the CFG file
       
 16514 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 16515 		{
       
 16516 		iLog->Log ( _L ( "read_data failed" ) );
       
 16517 		free_data ( connect_data );
       
 16518 		return_value = KErrGeneral;
       
 16519 		goto return_code;
       
 16520 		}
       
 16521 	//request formation	
       
 16522 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 16523 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16524 	
       
 16525 	//message header use
       
 16526 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 16527     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16528     
       
 16529     msgHdr->message_type = ELogin_Request;
       
 16530  
       
 16531     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16532     index += sizeof( message_hdr_req );
       
 16533     
       
 16534     int len = strlen(connect_data->username);
       
 16535     strcpy( smsg + index, connect_data->username );
       
 16536     index += len + 1;
       
 16537     
       
 16538     //appending password
       
 16539     
       
 16540     len = strlen(connect_data->password );
       
 16541     strcpy( smsg + index, connect_data->password );
       
 16542     index += len + 1;
       
 16543 
       
 16544     //appending server name
       
 16545     
       
 16546     len = strlen(connect_data->server );
       
 16547     strcpy( smsg + index, connect_data->server );
       
 16548     index += len + 1;
       
 16549     
       
 16550     //appending resource
       
 16551     len = strlen(connect_data->resource );
       
 16552     strcpy( smsg + index, connect_data->resource );
       
 16553     index += len + 1;
       
 16554     
       
 16555     //appending ssl
       
 16556     smsg[index++]= '1';
       
 16557     smsg[index++]= '\0';
       
 16558     
       
 16559     //appending server port
       
 16560     len = strlen(connect_data->port );
       
 16561     strcpy( smsg + index, connect_data->port );
       
 16562     index += len + 1;
       
 16563     
       
 16564     // appending IAP id
       
 16565     
       
 16566     smsg[index++]= '1';
       
 16567     smsg[index++]= '\0';
       
 16568     
       
 16569     //appending connmgr_bus
       
 16570     len = strlen(connect_data->connmgr_bus );
       
 16571     strcpy( smsg + index, connect_data->connmgr_bus );
       
 16572     index += len + 1;
       
 16573     
       
 16574     //appending connmgr_path
       
 16575     len = strlen(connect_data->connmgr_path );
       
 16576     strcpy( smsg + index, connect_data->connmgr_path );
       
 16577     index += len + 1;
       
 16578     
       
 16579     //appending protocol
       
 16580     len = strlen(connect_data->protocol );
       
 16581     strcpy( smsg + index, connect_data->protocol );
       
 16582     index += len + 1;
       
 16583     
       
 16584     #ifdef __WINSCW__
       
 16585     //proxy server
       
 16586     len = strlen(connect_data->proxy_data->proxy_server );
       
 16587     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 16588     index += len + 1;
       
 16589     
       
 16590     //proxy port
       
 16591     len = strlen(connect_data->proxy_data->proxy_port );
       
 16592     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 16593     index += len + 1;
       
 16594     
       
 16595     #endif
       
 16596     //running isoserver   
       
 16597     run_isoserver(); 
       
 16598     //create message queue for send request
       
 16599     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16600     //create message queue for response request
       
 16601     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16602 		
       
 16603 
       
 16604 	/* Send Message to queueOne */
       
 16605 	
       
 16606 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16607     
       
 16608     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 16609     
       
 16610     if (status < 0)
       
 16611     {
       
 16612     return_value = KErrGeneral;
       
 16613 	goto return_code;	
       
 16614     }
       
 16615     
       
 16616  
       
 16617     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 16618 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 16619 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 16620 	
       
 16621 	if( msg_struct->response != 1)
       
 16622     {
       
 16623     	return_value = KErrGeneral;
       
 16624 	goto return_code;
       
 16625     }
       
 16626     
       
 16627     
       
 16628     // login end
       
 16629     //fetch req..
       
 16630     for (int i= 0 ;i<3 ;i++)
       
 16631     {
       
 16632         
       
 16633     fp = fopen("c:\\fetch_contact.txt","a");
       
 16634 	do  {
       
 16635 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 16636 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16637 		fwrite(rmsg,1,status,fp);
       
 16638 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16639 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 16640 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 16641 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 16642 	fclose(fp);	
       
 16643 	
       
 16644     }
       
 16645 
       
 16646 	//fetch end
       
 16647 	//fetch end
       
 16648 	// getting add notification from user
       
 16649 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 16650 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16651 	index=0;
       
 16652     
       
 16653 	do  {
       
 16654     	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16655 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16656 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16657 	  //  memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16658 		} while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
       
 16659    
       
 16660     if ( msg_struct->response != 1)
       
 16661     {
       
 16662     return_value = KErrGeneral;
       
 16663 	goto return_code;
       
 16664     }
       
 16665     char *userid = (char *)malloc(100);
       
 16666     len=0;
       
 16667     len+=sizeof(message_hdr_resp);
       
 16668     strcpy(userid,rmsg+len);
       
 16669      // accepting add request from user 
       
 16670     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16671 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16672 	index=0;
       
 16673     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16674     msgHdr->message_type = EReject_Contact_Request;	
       
 16675     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16676 	index += sizeof( message_hdr_req );
       
 16677 	len=0;
       
 16678     len+=strlen(userid);
       
 16679 	strcpy( smsg + index ,userid   );
       
 16680     index += len + 1;
       
 16681 	
       
 16682 	
       
 16683     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16684     
       
 16685     do  {
       
 16686 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16687 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16688 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16689 		} while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request);
       
 16690    
       
 16691     if ( msg_struct->response != 1)
       
 16692     {
       
 16693     return_value = KErrGeneral;
       
 16694 	goto return_code;
       
 16695     }
       
 16696     
       
 16697     // logout test code from server
       
 16698     index=0;
       
 16699     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16700 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16701 	
       
 16702 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16703     
       
 16704     msgHdr->message_type = ELogout_Request;
       
 16705  
       
 16706     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16707     index += sizeof( message_hdr_req );
       
 16708 
       
 16709 	
       
 16710 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16711     
       
 16712     do  {
       
 16713 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16714 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16715 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16716 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 16717    
       
 16718     if ( msg_struct->response != 1)
       
 16719     {
       
 16720     	return_value = KErrGeneral;
       
 16721 	goto return_code;
       
 16722     }
       
 16723     //killing isoserver
       
 16724     return_code:
       
 16725     index=0;
       
 16726     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16727 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16728 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16729     msgHdr->message_type = EKill_Process;
       
 16730     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16731     index += sizeof( message_hdr_req );
       
 16732 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 16733     free( msg_struct );
       
 16734     return return_value;
       
 16735     }
       
 16736 
       
 16737  
       
 16738 	  // -----------------------------------------------------------------------------
       
 16739 // Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest
       
 16740 // Example test method function.
       
 16741 // (other items were commented in a header).
       
 16742 // -----------------------------------------------------------------------------
       
 16743 //
       
 16744 TInt Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest( CStifItemParser& aItem )
       
 16745     {
       
 16746 
       
 16747     	
       
 16748    ConnectData  *connect_data = NULL;
       
 16749     char smsg[MAX_MSG_SIZE];
       
 16750     char rmsg[MAX_MSG_SIZE];
       
 16751     int index=0;
       
 16752     FILE *fp;
       
 16753 		
       
 16754 	int timeout = 200;
       
 16755 	int nBytes;
       
 16756 
       
 16757     int result = 0;
       
 16758     int err = 0;
       
 16759     int status = 0;
       
 16760     message_hdr_req *msgHdr = NULL;  
       
 16761     message_hdr_resp* msg_struct = NULL;
       
 16762     TInt return_value = 0;
       
 16763         	// Read data from the CFG file
       
 16764 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 16765 		{
       
 16766 		iLog->Log ( _L ( "read_data failed" ) );
       
 16767 		free_data ( connect_data );
       
 16768 		return_value = KErrGeneral;
       
 16769 		goto return_code;
       
 16770 		}
       
 16771 	//request formation	
       
 16772 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 16773 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16774 	
       
 16775 	//message header use
       
 16776 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 16777     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16778     
       
 16779     msgHdr->message_type = ELogin_Request;
       
 16780  
       
 16781     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16782     index += sizeof( message_hdr_req );
       
 16783     
       
 16784     int len = strlen(connect_data->username);
       
 16785     strcpy( smsg + index, connect_data->username );
       
 16786     index += len + 1;
       
 16787     
       
 16788     //appending password
       
 16789     
       
 16790     len = strlen(connect_data->password );
       
 16791     strcpy( smsg + index, connect_data->password );
       
 16792     index += len + 1;
       
 16793     
       
 16794     //appending server name
       
 16795     
       
 16796     len = strlen(connect_data->server );
       
 16797     strcpy( smsg + index, connect_data->server );
       
 16798     index += len + 1;
       
 16799     
       
 16800     //appending resource
       
 16801     len = strlen(connect_data->resource );
       
 16802     strcpy( smsg + index, connect_data->resource );
       
 16803     index += len + 1;
       
 16804     
       
 16805     //appending ssl
       
 16806     smsg[index++]= '1';
       
 16807     smsg[index++]= '\0';
       
 16808     
       
 16809     //appending server port
       
 16810     len = strlen(connect_data->port );
       
 16811     strcpy( smsg + index, connect_data->port );
       
 16812     index += len + 1;
       
 16813     
       
 16814     // appending IAP id
       
 16815     
       
 16816     smsg[index++]= '1';
       
 16817     smsg[index++]= '\0';
       
 16818     
       
 16819     //appending connmgr_bus
       
 16820     len = strlen(connect_data->connmgr_bus );
       
 16821     strcpy( smsg + index, connect_data->connmgr_bus );
       
 16822     index += len + 1;
       
 16823     
       
 16824     //appending connmgr_path
       
 16825     len = strlen(connect_data->connmgr_path );
       
 16826     strcpy( smsg + index, connect_data->connmgr_path );
       
 16827     index += len + 1;
       
 16828     
       
 16829     //appending protocol
       
 16830     len = strlen(connect_data->protocol );
       
 16831     strcpy( smsg + index, connect_data->protocol );
       
 16832     index += len + 1;
       
 16833     
       
 16834     #ifdef __WINSCW__
       
 16835     //proxy server
       
 16836     len = strlen(connect_data->proxy_data->proxy_server );
       
 16837     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 16838     index += len + 1;
       
 16839     
       
 16840     //proxy port
       
 16841     len = strlen(connect_data->proxy_data->proxy_port );
       
 16842     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 16843     index += len + 1;
       
 16844     
       
 16845     #endif
       
 16846     
       
 16847     //running isoserver   
       
 16848     run_isoserver(); 
       
 16849     
       
 16850         
       
 16851     //create message queue for send request
       
 16852     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16853     //create message queue for response request
       
 16854     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 16855 		
       
 16856 	
       
 16857 	/* Send Message to queueOne */
       
 16858 	
       
 16859 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16860     
       
 16861     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 16862     
       
 16863     if (status < 0)
       
 16864     {
       
 16865     return_value = KErrGeneral;
       
 16866 	goto return_code;	
       
 16867     }
       
 16868     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 16869 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 16870 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 16871 	
       
 16872 	if( msg_struct->response != 1)
       
 16873     {
       
 16874     	return_value = KErrGeneral;
       
 16875 	goto return_code;
       
 16876     }
       
 16877     
       
 16878     
       
 16879     // login end
       
 16880    //fetch req..
       
 16881     for (int i= 0 ;i<3 ;i++)
       
 16882     {
       
 16883         
       
 16884     fp = fopen("c:\\fetch_contact.txt","a");
       
 16885 	do  {
       
 16886 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 16887 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16888 		fwrite(rmsg,1,status,fp);
       
 16889 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16890 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 16891 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 16892 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 16893 	fclose(fp);	
       
 16894 	
       
 16895     }
       
 16896 
       
 16897 	//fetch end
       
 16898     //Accepting Add request from  contact without ne add notification --------------------------------------------
       
 16899    
       
 16900     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16901 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16902 	index=0;
       
 16903     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16904     msgHdr->message_type = EAccept_Contact_Request;	
       
 16905     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16906 	index += sizeof( message_hdr_req );
       
 16907 	// adding add contact
       
 16908     len = strlen(connect_data->contact );
       
 16909     strcpy( smsg + index, connect_data->contact );
       
 16910     index += len + 1;
       
 16911     smsg[index++] = '\0';
       
 16912     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16913      do  {
       
 16914 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16915 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16916 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16917 		} while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request);
       
 16918    
       
 16919      if ( msg_struct->response != 0)
       
 16920     {
       
 16921     	return_value = KErrGeneral;
       
 16922 	goto return_code;
       
 16923     }
       
 16924     
       
 16925     //add contact end---------------------------------------
       
 16926     
       
 16927     
       
 16928     // logout test code from server
       
 16929     index=0;
       
 16930     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16931 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16932 	
       
 16933 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16934     
       
 16935     msgHdr->message_type = ELogout_Request;
       
 16936  
       
 16937     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16938     index += sizeof( message_hdr_req );
       
 16939 
       
 16940 	
       
 16941 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 16942      do  {
       
 16943 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 16944 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 16945 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16946 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 16947    
       
 16948      if ( msg_struct->response != 1)
       
 16949     {
       
 16950     	return_value = KErrGeneral;
       
 16951 	goto return_code;
       
 16952     }
       
 16953     //killing isoserver
       
 16954     return_code:
       
 16955     index=0;
       
 16956     memset( smsg, '\0', MAX_MSG_SIZE );
       
 16957 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 16958 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 16959     msgHdr->message_type = EKill_Process;
       
 16960     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 16961     index += sizeof( message_hdr_req );
       
 16962 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 16963     free( msg_struct );
       
 16964     return return_value;
       
 16965     }
       
 16966 
       
 16967 	  // -----------------------------------------------------------------------------
       
 16968 // Cisolationserver::SendRejectRequestWithoutReceivingAddrequest
       
 16969 // Example test method function.
       
 16970 // (other items were commented in a header).
       
 16971 // -----------------------------------------------------------------------------
       
 16972 //
       
 16973 TInt Cisolationserver::SendRejectRequestWithoutReceivingAddrequest( CStifItemParser& aItem )
       
 16974     {
       
 16975 
       
 16976     	
       
 16977    ConnectData  *connect_data = NULL;
       
 16978     char smsg[MAX_MSG_SIZE];
       
 16979     char rmsg[MAX_MSG_SIZE];
       
 16980     int index=0;
       
 16981     FILE *fp;
       
 16982 		
       
 16983 	int timeout = 200;
       
 16984 	int nBytes;
       
 16985 
       
 16986     int result = 0;
       
 16987     int err = 0;
       
 16988     int status = 0;
       
 16989     message_hdr_req *msgHdr = NULL;  
       
 16990     message_hdr_resp* msg_struct = NULL;
       
 16991     TInt return_value = 0;
       
 16992         	// Read data from the CFG file
       
 16993 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 16994 		{
       
 16995 		iLog->Log ( _L ( "read_data failed" ) );
       
 16996 		free_data ( connect_data );
       
 16997 		return_value = KErrGeneral;
       
 16998 		goto return_code;
       
 16999 		}
       
 17000 	//request formation	
       
 17001 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 17002 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17003 	
       
 17004 	//message header use
       
 17005 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 17006     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17007     
       
 17008     msgHdr->message_type = ELogin_Request;
       
 17009  
       
 17010     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17011     index += sizeof( message_hdr_req );
       
 17012     
       
 17013     int len = strlen(connect_data->username);
       
 17014     strcpy( smsg + index, connect_data->username );
       
 17015     index += len + 1;
       
 17016     
       
 17017     //appending password
       
 17018     
       
 17019     len = strlen(connect_data->password );
       
 17020     strcpy( smsg + index, connect_data->password );
       
 17021     index += len + 1;
       
 17022     
       
 17023     //appending server name
       
 17024     
       
 17025     len = strlen(connect_data->server );
       
 17026     strcpy( smsg + index, connect_data->server );
       
 17027     index += len + 1;
       
 17028     
       
 17029     //appending resource
       
 17030     len = strlen(connect_data->resource );
       
 17031     strcpy( smsg + index, connect_data->resource );
       
 17032     index += len + 1;
       
 17033     
       
 17034     //appending ssl
       
 17035     smsg[index++]= '1';
       
 17036     smsg[index++]= '\0';
       
 17037     
       
 17038     //appending server port
       
 17039     len = strlen(connect_data->port );
       
 17040     strcpy( smsg + index, connect_data->port );
       
 17041     index += len + 1;
       
 17042     
       
 17043     // appending IAP id
       
 17044     
       
 17045     smsg[index++]= '1';
       
 17046     smsg[index++]= '\0';
       
 17047     
       
 17048     //appending connmgr_bus
       
 17049     len = strlen(connect_data->connmgr_bus );
       
 17050     strcpy( smsg + index, connect_data->connmgr_bus );
       
 17051     index += len + 1;
       
 17052     
       
 17053     //appending connmgr_path
       
 17054     len = strlen(connect_data->connmgr_path );
       
 17055     strcpy( smsg + index, connect_data->connmgr_path );
       
 17056     index += len + 1;
       
 17057     
       
 17058     //appending protocol
       
 17059     len = strlen(connect_data->protocol );
       
 17060     strcpy( smsg + index, connect_data->protocol );
       
 17061     index += len + 1;
       
 17062     
       
 17063     #ifdef __WINSCW__
       
 17064     //proxy server
       
 17065     len = strlen(connect_data->proxy_data->proxy_server );
       
 17066     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 17067     index += len + 1;
       
 17068     
       
 17069     //proxy port
       
 17070     len = strlen(connect_data->proxy_data->proxy_port );
       
 17071     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 17072     index += len + 1;
       
 17073     
       
 17074     #endif
       
 17075     
       
 17076     //running isoserver   
       
 17077     run_isoserver(); 
       
 17078     
       
 17079         
       
 17080     //create message queue for send request
       
 17081     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17082     //create message queue for response request
       
 17083     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17084 		
       
 17085 	
       
 17086 	/* Send Message to queueOne */
       
 17087 	
       
 17088 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17089     
       
 17090     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 17091     
       
 17092     if (status < 0)
       
 17093     {
       
 17094     return_value = KErrGeneral;
       
 17095 	goto return_code;	
       
 17096     }
       
 17097     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 17098 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 17099 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 17100 	
       
 17101 	if( msg_struct->response != 0)
       
 17102     {
       
 17103     	return_value = KErrGeneral;
       
 17104 	goto return_code;
       
 17105     }
       
 17106     
       
 17107     
       
 17108     // login end
       
 17109    //fetch req..
       
 17110     for (int i= 0 ;i<3 ;i++)
       
 17111     {
       
 17112         
       
 17113     fp = fopen("c:\\fetch_contact.txt","a");
       
 17114 	do  {
       
 17115 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 17116 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17117 		fwrite(rmsg,1,status,fp);
       
 17118 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17119 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 17120 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 17121 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 17122 	fclose(fp);	
       
 17123 	
       
 17124     }
       
 17125 
       
 17126 	//fetch end
       
 17127     //Accepting Add request from  contact without ne add notification --------------------------------------------
       
 17128    
       
 17129     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17130 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17131 	index=0;
       
 17132     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17133     msgHdr->message_type = EReject_Contact_Request;	
       
 17134     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17135 	index += sizeof( message_hdr_req );
       
 17136 	// adding add contact
       
 17137     len = strlen(connect_data->contact );
       
 17138     strcpy( smsg + index, connect_data->contact );
       
 17139     index += len + 1;
       
 17140     smsg[index++] = '\0';
       
 17141     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17142      do  {
       
 17143 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17144 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17145 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17146 		} while (msg_struct->hdr_req.message_type!=EReject_Contact_Request);
       
 17147    
       
 17148      if ( msg_struct->response != 1)
       
 17149     {
       
 17150     	return_value = KErrGeneral;
       
 17151 	goto return_code;
       
 17152     }
       
 17153     
       
 17154     //add contact end---------------------------------------
       
 17155     
       
 17156     
       
 17157     // logout test code from server
       
 17158     index=0;
       
 17159     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17160 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17161 	
       
 17162 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17163     
       
 17164     msgHdr->message_type = ELogout_Request;
       
 17165  
       
 17166     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17167     index += sizeof( message_hdr_req );
       
 17168 
       
 17169 	
       
 17170 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17171      do  {
       
 17172 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17173 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17174 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17175 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 17176    
       
 17177      if ( msg_struct->response != 1)
       
 17178     {
       
 17179     	return_value = KErrGeneral;
       
 17180 	goto return_code;
       
 17181     }
       
 17182     //killing isoserver
       
 17183     return_code:
       
 17184     index=0;
       
 17185     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17186 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17187 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17188     msgHdr->message_type = EKill_Process;
       
 17189     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17190     index += sizeof( message_hdr_req );
       
 17191 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 17192     free( msg_struct );
       
 17193     return return_value;
       
 17194     }
       
 17195 
       
 17196 
       
 17197 	  // -----------------------------------------------------------------------------
       
 17198 // Cisolationserver::SendAcceptRequestWithoutAnyUserID
       
 17199 // Example test method function.
       
 17200 // (other items were commented in a header).
       
 17201 // -----------------------------------------------------------------------------
       
 17202 //
       
 17203 TInt Cisolationserver::SendAcceptRequestWithoutAnyUserID( CStifItemParser& aItem )
       
 17204     {
       
 17205 
       
 17206     	
       
 17207     ConnectData  *connect_data = NULL;
       
 17208     char smsg[MAX_MSG_SIZE];
       
 17209     char rmsg[MAX_MSG_SIZE];
       
 17210     int index=0;
       
 17211     
       
 17212 		
       
 17213 	int timeout = 100;
       
 17214 	int nBytes;
       
 17215 
       
 17216     int result = 0;
       
 17217     int err = 0;
       
 17218     int status = 0;
       
 17219     FILE *fp;
       
 17220     message_hdr_req *msgHdr = NULL;  
       
 17221     message_hdr_resp* msg_struct = NULL;
       
 17222     TInt return_value = 0;
       
 17223         	// Read data from the CFG file
       
 17224 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 17225 		{
       
 17226 		iLog->Log ( _L ( "read_data failed" ) );
       
 17227 		free_data ( connect_data );
       
 17228 		return_value = KErrGeneral;
       
 17229 		goto return_code;
       
 17230 		}
       
 17231 	//request formation	
       
 17232 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 17233 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17234 	
       
 17235 	//message header use
       
 17236 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 17237     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17238     
       
 17239     msgHdr->message_type = ELogin_Request;
       
 17240  
       
 17241     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17242     index += sizeof( message_hdr_req );
       
 17243     
       
 17244     int len = strlen(connect_data->username);
       
 17245     strcpy( smsg + index, connect_data->username );
       
 17246     index += len + 1;
       
 17247     
       
 17248     //appending password
       
 17249     
       
 17250     len = strlen(connect_data->password );
       
 17251     strcpy( smsg + index, connect_data->password );
       
 17252     index += len + 1;
       
 17253 
       
 17254     //appending server name
       
 17255     
       
 17256     len = strlen(connect_data->server );
       
 17257     strcpy( smsg + index, connect_data->server );
       
 17258     index += len + 1;
       
 17259     
       
 17260     //appending resource
       
 17261     len = strlen(connect_data->resource );
       
 17262     strcpy( smsg + index, connect_data->resource );
       
 17263     index += len + 1;
       
 17264     
       
 17265     //appending ssl
       
 17266     smsg[index++]= '1';
       
 17267     smsg[index++]= '\0';
       
 17268     
       
 17269     //appending server port
       
 17270     len = strlen(connect_data->port );
       
 17271     strcpy( smsg + index, connect_data->port );
       
 17272     index += len + 1;
       
 17273     
       
 17274     // appending IAP id
       
 17275     
       
 17276     smsg[index++]= '1';
       
 17277     smsg[index++]= '\0';
       
 17278     
       
 17279     //appending connmgr_bus
       
 17280     len = strlen(connect_data->connmgr_bus );
       
 17281     strcpy( smsg + index, connect_data->connmgr_bus );
       
 17282     index += len + 1;
       
 17283     
       
 17284     //appending connmgr_path
       
 17285     len = strlen(connect_data->connmgr_path );
       
 17286     strcpy( smsg + index, connect_data->connmgr_path );
       
 17287     index += len + 1;
       
 17288     
       
 17289     //appending protocol
       
 17290     len = strlen(connect_data->protocol );
       
 17291     strcpy( smsg + index, connect_data->protocol );
       
 17292     index += len + 1;
       
 17293     
       
 17294     #ifdef __WINSCW__
       
 17295     //proxy server
       
 17296     len = strlen(connect_data->proxy_data->proxy_server );
       
 17297     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 17298     index += len + 1;
       
 17299     
       
 17300     //proxy port
       
 17301     len = strlen(connect_data->proxy_data->proxy_port );
       
 17302     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 17303     index += len + 1;
       
 17304     
       
 17305     #endif
       
 17306     //running isoserver   
       
 17307     run_isoserver(); 
       
 17308     //create message queue for send request
       
 17309     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17310     //create message queue for response request
       
 17311     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17312 		
       
 17313 
       
 17314 	/* Send Message to queueOne */
       
 17315 	
       
 17316 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17317     
       
 17318     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 17319     
       
 17320     if (status < 0)
       
 17321     {
       
 17322     return_value = KErrGeneral;
       
 17323 	goto return_code;	
       
 17324     }
       
 17325     
       
 17326  
       
 17327     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 17328 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 17329 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 17330 	
       
 17331 	if( msg_struct->response != 1)
       
 17332     {
       
 17333     	return_value = KErrGeneral;
       
 17334 	goto return_code;
       
 17335     }
       
 17336     
       
 17337     
       
 17338     // login end
       
 17339     //fetch req..
       
 17340     for (int i= 0 ;i<3 ;i++)
       
 17341     {
       
 17342         
       
 17343     fp = fopen("c:\\fetch_contact.txt","a");
       
 17344 	do  {
       
 17345 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 17346 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17347 		fwrite(rmsg,1,status,fp);
       
 17348 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17349 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 17350 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 17351 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 17352 	fclose(fp);	
       
 17353 	
       
 17354     }
       
 17355 
       
 17356 	//fetch end
       
 17357 	//fetch end
       
 17358 	// getting add notification from user
       
 17359 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 17360 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17361 	index=0;
       
 17362     
       
 17363 	do  {
       
 17364     	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17365 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17366 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17367 	  //  memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17368 		} while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
       
 17369    
       
 17370     if ( msg_struct->response != 1)
       
 17371     {
       
 17372     return_value = KErrGeneral;
       
 17373 	goto return_code;
       
 17374     }
       
 17375     char *userid = (char *)malloc(100);
       
 17376     len=0;
       
 17377     len+=sizeof(message_hdr_resp);
       
 17378     strcpy(userid,rmsg+len);
       
 17379      // accepting add request from user 
       
 17380     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17381 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17382 	index=0;
       
 17383     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17384     msgHdr->message_type = EReject_Contact_Request;	
       
 17385     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17386 	index += sizeof( message_hdr_req );
       
 17387 	
       
 17388 	//no need to send user id with this message
       
 17389 	//len=0;
       
 17390     //len+=strlen(userid);
       
 17391 	//strcpy( smsg + index ,userid   );
       
 17392     //index += len + 1;
       
 17393 	
       
 17394 	
       
 17395     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17396     
       
 17397     do  {
       
 17398 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17399 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17400 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17401 		} while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request);
       
 17402    // need to check response
       
 17403     if ( msg_struct->response != 0)
       
 17404     {
       
 17405     return_value = KErrGeneral;
       
 17406 	goto return_code;
       
 17407     }
       
 17408     
       
 17409     // logout test code from server
       
 17410     index=0;
       
 17411     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17412 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17413 	
       
 17414 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17415     
       
 17416     msgHdr->message_type = ELogout_Request;
       
 17417  
       
 17418     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17419     index += sizeof( message_hdr_req );
       
 17420 
       
 17421 	
       
 17422 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17423     
       
 17424     do  {
       
 17425 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17426 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17427 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17428 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 17429    
       
 17430     if ( msg_struct->response != 1)
       
 17431     {
       
 17432     	return_value = KErrGeneral;
       
 17433 	goto return_code;
       
 17434     }
       
 17435     //killing isoserver
       
 17436     return_code:
       
 17437     index=0;
       
 17438     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17439 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17440 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17441     msgHdr->message_type = EKill_Process;
       
 17442     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17443     index += sizeof( message_hdr_req );
       
 17444 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 17445     free( msg_struct );
       
 17446     return return_value;
       
 17447     }
       
 17448 
       
 17449     // -----------------------------------------------------------------------------
       
 17450 // Cisolationserver::SendRejectRequestWithoutAnyUserID
       
 17451 // Example test method function.
       
 17452 // (other items were commented in a header).
       
 17453 // -----------------------------------------------------------------------------
       
 17454 //RejectAddRequestFromUser
       
 17455 TInt Cisolationserver::SendRejectRequestWithoutAnyUserID( CStifItemParser& aItem )
       
 17456     {
       
 17457 
       
 17458     	
       
 17459     ConnectData  *connect_data = NULL;
       
 17460     char smsg[MAX_MSG_SIZE];
       
 17461     char rmsg[MAX_MSG_SIZE];
       
 17462     int index=0;
       
 17463     
       
 17464 		
       
 17465 	int timeout = 100;
       
 17466 	int nBytes;
       
 17467 
       
 17468     int result = 0;
       
 17469     int err = 0;
       
 17470     int status = 0;
       
 17471     FILE *fp;
       
 17472     message_hdr_req *msgHdr = NULL;  
       
 17473     message_hdr_resp* msg_struct = NULL;
       
 17474     TInt return_value = 0;
       
 17475         	// Read data from the CFG file
       
 17476 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 17477 		{
       
 17478 		iLog->Log ( _L ( "read_data failed" ) );
       
 17479 		free_data ( connect_data );
       
 17480 		return_value = KErrGeneral;
       
 17481 		goto return_code;
       
 17482 		}
       
 17483 	//request formation	
       
 17484 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 17485 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17486 	
       
 17487 	//message header use
       
 17488 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 17489     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17490     
       
 17491     msgHdr->message_type = ELogin_Request;
       
 17492  
       
 17493     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17494     index += sizeof( message_hdr_req );
       
 17495     
       
 17496     int len = strlen(connect_data->username);
       
 17497     strcpy( smsg + index, connect_data->username );
       
 17498     index += len + 1;
       
 17499     
       
 17500     //appending password
       
 17501     
       
 17502     len = strlen(connect_data->password );
       
 17503     strcpy( smsg + index, connect_data->password );
       
 17504     index += len + 1;
       
 17505 
       
 17506     //appending server name
       
 17507     
       
 17508     len = strlen(connect_data->server );
       
 17509     strcpy( smsg + index, connect_data->server );
       
 17510     index += len + 1;
       
 17511     
       
 17512     //appending resource
       
 17513     len = strlen(connect_data->resource );
       
 17514     strcpy( smsg + index, connect_data->resource );
       
 17515     index += len + 1;
       
 17516     
       
 17517     //appending ssl
       
 17518     smsg[index++]= '1';
       
 17519     smsg[index++]= '\0';
       
 17520     
       
 17521     //appending server port
       
 17522     len = strlen(connect_data->port );
       
 17523     strcpy( smsg + index, connect_data->port );
       
 17524     index += len + 1;
       
 17525     
       
 17526     // appending IAP id
       
 17527     
       
 17528     smsg[index++]= '1';
       
 17529     smsg[index++]= '\0';
       
 17530     
       
 17531     //appending connmgr_bus
       
 17532     len = strlen(connect_data->connmgr_bus );
       
 17533     strcpy( smsg + index, connect_data->connmgr_bus );
       
 17534     index += len + 1;
       
 17535     
       
 17536     //appending connmgr_path
       
 17537     len = strlen(connect_data->connmgr_path );
       
 17538     strcpy( smsg + index, connect_data->connmgr_path );
       
 17539     index += len + 1;
       
 17540     
       
 17541     //appending protocol
       
 17542     len = strlen(connect_data->protocol );
       
 17543     strcpy( smsg + index, connect_data->protocol );
       
 17544     index += len + 1;
       
 17545     
       
 17546     #ifdef __WINSCW__
       
 17547     //proxy server
       
 17548     len = strlen(connect_data->proxy_data->proxy_server );
       
 17549     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 17550     index += len + 1;
       
 17551     
       
 17552     //proxy port
       
 17553     len = strlen(connect_data->proxy_data->proxy_port );
       
 17554     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 17555     index += len + 1;
       
 17556     
       
 17557     #endif
       
 17558     //running isoserver   
       
 17559     run_isoserver(); 
       
 17560     //create message queue for send request
       
 17561     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17562     //create message queue for response request
       
 17563     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17564 		
       
 17565 
       
 17566 	/* Send Message to queueOne */
       
 17567 	
       
 17568 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17569     
       
 17570     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 17571     
       
 17572     if (status < 0)
       
 17573     {
       
 17574     return_value = KErrGeneral;
       
 17575 	goto return_code;	
       
 17576     }
       
 17577     
       
 17578  
       
 17579     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 17580 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 17581 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 17582 	
       
 17583 	if( msg_struct->response != 1)
       
 17584     {
       
 17585     	return_value = KErrGeneral;
       
 17586 	goto return_code;
       
 17587     }
       
 17588     
       
 17589     
       
 17590     // login end
       
 17591     //fetch req..
       
 17592     for (int i= 0 ;i<3 ;i++)
       
 17593     {
       
 17594         
       
 17595     fp = fopen("c:\\fetch_contact.txt","a");
       
 17596 	do  {
       
 17597 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 17598 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17599 		fwrite(rmsg,1,status,fp);
       
 17600 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17601 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 17602 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 17603 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 17604 	fclose(fp);	
       
 17605 	
       
 17606     }
       
 17607 
       
 17608 	//fetch end
       
 17609 	//fetch end
       
 17610 	// getting add notification from user
       
 17611 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 17612 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17613 	index=0;
       
 17614     
       
 17615 	do  {
       
 17616     	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17617 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17618 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17619 	  //  memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17620 		} while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
       
 17621    
       
 17622     if ( msg_struct->response != 1)
       
 17623     {
       
 17624     return_value = KErrGeneral;
       
 17625 	goto return_code;
       
 17626     }
       
 17627     char *userid = (char *)malloc(100);
       
 17628     len=0;
       
 17629     len+=sizeof(message_hdr_resp);
       
 17630     strcpy(userid,rmsg+len);
       
 17631     
       
 17632     
       
 17633     
       
 17634 
       
 17635     // rejecting add request from user 
       
 17636     
       
 17637     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17638 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17639 	index=0;
       
 17640     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17641     msgHdr->message_type = EReject_Contact_Request;	
       
 17642     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17643 	index += sizeof( message_hdr_req );
       
 17644 	//len=0;
       
 17645     //len+=strlen(userid);
       
 17646 	//strcpy( smsg + index ,userid   );
       
 17647     //index += len + 1;
       
 17648 	
       
 17649 	
       
 17650     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17651     
       
 17652     do  {
       
 17653 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17654 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17655 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17656 		} while (msg_struct->hdr_req.message_type!=EReject_Contact_Request);
       
 17657    
       
 17658     if ( msg_struct->response != 0)
       
 17659     {
       
 17660     return_value = KErrGeneral;
       
 17661 	goto return_code;
       
 17662     }
       
 17663     
       
 17664     // logout test code from server
       
 17665     index=0;
       
 17666     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17667 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17668 	
       
 17669 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17670     
       
 17671     msgHdr->message_type = ELogout_Request;
       
 17672  
       
 17673     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17674     index += sizeof( message_hdr_req );
       
 17675 
       
 17676 	
       
 17677 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17678     
       
 17679     do  {
       
 17680 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17681 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17682 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17683 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 17684    
       
 17685     if ( msg_struct->response != 1)
       
 17686     {
       
 17687     	return_value = KErrGeneral;
       
 17688 	goto return_code;
       
 17689     }
       
 17690     //killing isoserver
       
 17691     return_code:
       
 17692     index=0;
       
 17693     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17694 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17695 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17696     msgHdr->message_type = EKill_Process;
       
 17697     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17698     index += sizeof( message_hdr_req );
       
 17699 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 17700     free( msg_struct );
       
 17701     return return_value;
       
 17702     }
       
 17703 
       
 17704     // -----------------------------------------------------------------------------
       
 17705 // Cisolationserver::Login with correct data
       
 17706 // Example test method function.
       
 17707 // (other items were commented in a header).
       
 17708 // -----------------------------------------------------------------------------
       
 17709 //
       
 17710 TInt Cisolationserver::LogoutWhileUserIsNotLoggedIn( CStifItemParser& aItem )
       
 17711     {
       
 17712   	
       
 17713     ConnectData  *connect_data = NULL;
       
 17714     char smsg[MAX_MSG_SIZE];
       
 17715     char rmsg[MAX_MSG_SIZE];
       
 17716     int index=0;
       
 17717 
       
 17718 	FILE *fp;	
       
 17719 	int timeout = 100;
       
 17720 	int nBytes;
       
 17721     int result = 0;
       
 17722     int err = 0;
       
 17723     int status = 0;
       
 17724     message_hdr_req *msgHdr = NULL;  
       
 17725     message_hdr_resp* msg_struct = NULL;
       
 17726     TInt return_value = 0;
       
 17727         	// Read data from the CFG file
       
 17728 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 17729 		{
       
 17730 		iLog->Log ( _L ( "read_data failed" ) );
       
 17731 		free_data ( connect_data );
       
 17732 		return_value = KErrGeneral;
       
 17733 		goto return_code;
       
 17734 		}
       
 17735 	//request formation	
       
 17736 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 17737 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17738 	//message header use
       
 17739 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 17740     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17741     msgHdr->message_type = ELogin_Request;
       
 17742     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17743     index += sizeof( message_hdr_req );
       
 17744     int len = strlen(connect_data->username);
       
 17745     strcpy( smsg + index, connect_data->username );
       
 17746     index += len + 1;
       
 17747     //appending password
       
 17748     len = strlen(connect_data->password );
       
 17749     strcpy( smsg + index, connect_data->password );
       
 17750     index += len + 1;
       
 17751     //appending server name
       
 17752     len = strlen(connect_data->server );
       
 17753     strcpy( smsg + index, connect_data->server );
       
 17754     index += len + 1;
       
 17755     //appending resource
       
 17756     len = strlen(connect_data->resource );
       
 17757     strcpy( smsg + index, connect_data->resource );
       
 17758     index += len + 1;
       
 17759     //appending ssl
       
 17760     smsg[index++]= '1';
       
 17761     smsg[index++]= '\0';
       
 17762     //appending server port
       
 17763     len = strlen(connect_data->port );
       
 17764     strcpy( smsg + index, connect_data->port );
       
 17765     index += len + 1;
       
 17766     // appending IAP id
       
 17767     smsg[index++]= '1';
       
 17768     smsg[index++]= '\0';
       
 17769     //appending connmgr_bus
       
 17770     len = strlen(connect_data->connmgr_bus );
       
 17771     strcpy( smsg + index, connect_data->connmgr_bus );
       
 17772     index += len + 1;
       
 17773     //appending connmgr_path
       
 17774     len = strlen(connect_data->connmgr_path );
       
 17775     strcpy( smsg + index, connect_data->connmgr_path );
       
 17776     index += len + 1;
       
 17777     //appending protocol
       
 17778     len = strlen(connect_data->protocol );
       
 17779     strcpy( smsg + index, connect_data->protocol );
       
 17780     index += len + 1;
       
 17781     #ifdef __WINSCW__
       
 17782     //proxy server
       
 17783     len = strlen(connect_data->proxy_data->proxy_server );
       
 17784     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 17785     index += len + 1;
       
 17786     //proxy port
       
 17787     len = strlen(connect_data->proxy_data->proxy_port );
       
 17788     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 17789     index += len + 1;
       
 17790     #endif
       
 17791      //running isoserver   
       
 17792     run_isoserver(); 
       
 17793     //create message queue for send request
       
 17794     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17795     //create message queue for response request
       
 17796     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 17797     
       
 17798 	//fetch end
       
 17799     
       
 17800     // logout test code from server
       
 17801     index=0;
       
 17802     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17803 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17804 	
       
 17805 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17806     
       
 17807     msgHdr->message_type = ELogout_Request;
       
 17808  
       
 17809     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17810     index += sizeof( message_hdr_req );
       
 17811 
       
 17812 	
       
 17813 	 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 17814     
       
 17815     do  {
       
 17816 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 17817 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 17818 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17819 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 17820    
       
 17821     if ( msg_struct->response != 1)
       
 17822     {
       
 17823     return_value = KErrGeneral;
       
 17824 	goto return_code;
       
 17825     }
       
 17826     return_value = KErrNone;
       
 17827 	goto return_code;
       
 17828     //killing isoserver
       
 17829     return_code:
       
 17830     index=0;
       
 17831     memset( smsg, '\0', MAX_MSG_SIZE );
       
 17832 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 17833 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 17834     msgHdr->message_type = EKill_Process;
       
 17835  
       
 17836     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 17837     index += sizeof( message_hdr_req );
       
 17838 
       
 17839 	
       
 17840 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 17841     free( msg_struct );
       
 17842     return return_value;
       
 17843 
       
 17844     }
       
 17845 
       
 17846 
       
 17847 // -----------------------------------------------------------------------------
       
 17848 // Cisolationserver::GetSearchLabelForYukonL
       
 17849 // -----------------------------------------------------------------------------
       
 17850 const gchar* Cisolationserver::GetSearchLabelForYukonL(gchar *search_key)
       
 17851 {
       
 17852 if(strcmp(search_key,"user") == 0)
       
 17853 	{
       
 17854 	gchar* label= "User";
       
 17855 	return label;	
       
 17856 	}
       
 17857 else if(strcmp(search_key,"fn") == 0)
       
 17858 	{
       
 17859 	gchar* label= "Full Name";
       
 17860 	return label;	
       
 17861 	}	
       
 17862 else if(strcmp(search_key,"first") == 0)
       
 17863 	{
       
 17864 	gchar* label= "Name";
       
 17865 	return label;	
       
 17866 	}	
       
 17867 else if(strcmp(search_key,"middle") == 0)
       
 17868 	{
       
 17869 	gchar* label= "Middle Name";
       
 17870 	return label;	
       
 17871 	}		
       
 17872 else if(strcmp(search_key,"last") == 0)
       
 17873 	{
       
 17874 	gchar* label= "Family Name";
       
 17875 	return label;	
       
 17876 	}
       
 17877 else if(strcmp(search_key,"nick") == 0)
       
 17878 	{
       
 17879 	gchar* label= "Nickname";
       
 17880 	return label;	
       
 17881 	}
       
 17882 else if(strcmp(search_key,"email") == 0)
       
 17883 	{
       
 17884 	gchar* label= "Email";
       
 17885 	return label;	
       
 17886 	}	
       
 17887 else if(strcmp(search_key,"bday") == 0)
       
 17888 	{
       
 17889 	gchar* label= "Birthday";
       
 17890 	return label;	
       
 17891 	}	
       
 17892 else if(strcmp(search_key,"ctry") == 0)
       
 17893 	{
       
 17894 	gchar* label= "Country";
       
 17895 	return label;	
       
 17896 	}		
       
 17897 else if(strcmp(search_key,"orgname") == 0)
       
 17898 	{
       
 17899 	gchar* label= "Organization Name";
       
 17900 	return label;	
       
 17901 	}
       
 17902 else if(strcmp(search_key,"locality") == 0)
       
 17903 	{
       
 17904 	gchar* label= "City";
       
 17905 	return label;	
       
 17906 	}
       
 17907 else if(strcmp(search_key,"orgunit") == 0)
       
 17908 	{
       
 17909 	gchar* label= "Organization Unit";
       
 17910 	return label;	
       
 17911 	}			
       
 17912 }
       
 17913 
       
 17914 
       
 17915 // -----------------------------------------------------------------------------
       
 17916 // Cisolationserver::GetSearchLabelForGizmoL
       
 17917 // -----------------------------------------------------------------------------
       
 17918 const gchar* Cisolationserver::GetSearchLabelForGizmoL(gchar *search_key)
       
 17919 {
       
 17920 if(strcmp(search_key,"xmpp_user") == 0)
       
 17921 	{
       
 17922 	gchar* label= "Account Name";
       
 17923 	return label;	
       
 17924 	}
       
 17925 else if(strcmp(search_key,"email_address") == 0)
       
 17926 	{
       
 17927 	gchar* label= "Email Address";
       
 17928 	return label;	
       
 17929 	}	
       
 17930 else if(strcmp(search_key,"first_name") == 0)
       
 17931 	{
       
 17932 	gchar* label= "First Name";
       
 17933 	return label;	
       
 17934 	}	
       
 17935 else if(strcmp(search_key,"last_name") == 0)
       
 17936 	{
       
 17937 	gchar* label= "Family Name";
       
 17938 	return label;	
       
 17939 	}
       
 17940 else if(strcmp(search_key,"country") == 0)
       
 17941 	{
       
 17942 	gchar* label= "Country";
       
 17943 	return label;	
       
 17944 	}		
       
 17945 else if(strcmp(search_key,"state") == 0)
       
 17946 	{
       
 17947 	gchar* label= "State/Province";
       
 17948 	return label;	
       
 17949 	}
       
 17950 else if(strcmp(search_key,"city") == 0)
       
 17951 	{
       
 17952 	gchar* label= "City";
       
 17953 	return label;	
       
 17954 	}
       
 17955 else if(strcmp(search_key,"max_results") == 0)
       
 17956 	{
       
 17957 	gchar* label= "Maximum # of Results";
       
 17958 	return label;	
       
 17959 	}			
       
 17960 }
       
 17961 
       
 17962 // -----------------------------------------------------------------------------
       
 17963 // Cisolationserver::GetSearchLabelL
       
 17964 // -----------------------------------------------------------------------------
       
 17965 const gchar* Cisolationserver::GetSearchLabelL(gchar* aService,gchar* aSearchKey)
       
 17966 {
       
 17967 if(strcmp(aService,"chat.gizmoproject.com") == 0)
       
 17968 	{
       
 17969 	GetSearchLabelForGizmoL(aSearchKey);	
       
 17970 	}
       
 17971 else if(strcmp(aService,"chat.ovi.com") == 0 )
       
 17972 	{
       
 17973 	GetSearchLabelForYukonL(aSearchKey);	
       
 17974 	}
       
 17975 }
       
 17976 	
       
 17977   
       
 17978 // -----------------------------------------------------------------------------
       
 17979 // Cisolationserver::?member_function
       
 17980 // ?implementation_description
       
 17981 // (other items were commented in a header).
       
 17982 
       
 17983 // -----------------------------------------------------------------------------
       
 17984 // Cisolationserver::AcceptAddRequestFromUser
       
 17985 // Example test method function.
       
 17986 // (other items were commented in a header).
       
 17987 // -----------------------------------------------------------------------------
       
 17988 //
       
 17989 Cisolationserver::GetKeysAndSearch( CStifItemParser& aItem )
       
 17990 	{
       
 17991 	
       
 17992 	ConnectData  *connect_data = NULL;
       
 17993     char smsg[MAX_MSG_SIZE];
       
 17994     char rmsg[MAX_MSG_SIZE];
       
 17995     int index=0;
       
 17996     FILE *fp;
       
 17997 		
       
 17998 	int timeout = 200;
       
 17999 	int nBytes;
       
 18000 	TInt return_value = 0;
       
 18001     int result = 0;
       
 18002     int err = 0;
       
 18003     int status = 0;
       
 18004     message_hdr_req *msgHdr = NULL;  
       
 18005     message_hdr_resp* msg_struct = NULL;
       
 18006       
       
 18007     	// Read data from the CFG file
       
 18008 	if ( read_data ( connect_data, aItem ) != RC_OK )
       
 18009 		{
       
 18010 		iLog->Log ( _L ( "read_data failed" ) );
       
 18011 		free_data ( connect_data );
       
 18012 		return_value = KErrGeneral;	
       
 18013     	goto return_code;
       
 18014 		}
       
 18015 	//request formation	
       
 18016 	memset( smsg, '\0', MAX_MSG_SIZE );
       
 18017 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18018 	
       
 18019 	//message header use
       
 18020 	msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 18021     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18022     
       
 18023     msgHdr->message_type = ELogin_Request;
       
 18024  
       
 18025     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18026     index += sizeof( message_hdr_req );
       
 18027     
       
 18028     int len = strlen(connect_data->username);
       
 18029     strcpy( smsg + index, connect_data->username );
       
 18030     index += len + 1;
       
 18031     
       
 18032     //appending password
       
 18033     
       
 18034     len = strlen(connect_data->password );
       
 18035     strcpy( smsg + index, connect_data->password );
       
 18036     index += len + 1;
       
 18037     
       
 18038     //appending server name
       
 18039     
       
 18040     len = strlen(connect_data->server );
       
 18041     strcpy( smsg + index, connect_data->server );
       
 18042     index += len + 1;
       
 18043     
       
 18044     //appending resource
       
 18045     len = strlen(connect_data->resource );
       
 18046     strcpy( smsg + index, connect_data->resource );
       
 18047     index += len + 1;
       
 18048     
       
 18049     //appending ssl
       
 18050     smsg[index++]= '0';
       
 18051     smsg[index++]= '\0';
       
 18052     
       
 18053     //appending server port
       
 18054     len = strlen(connect_data->port );
       
 18055     strcpy( smsg + index, connect_data->port );
       
 18056     index += len + 1;
       
 18057     
       
 18058     // appending IAP id
       
 18059     
       
 18060     smsg[index++]= '1';
       
 18061     smsg[index++]= '\0';
       
 18062     
       
 18063     //appending connmgr_bus
       
 18064     len = strlen(connect_data->connmgr_bus );
       
 18065     strcpy( smsg + index, connect_data->connmgr_bus );
       
 18066     index += len + 1;
       
 18067     
       
 18068     //appending connmgr_path
       
 18069     len = strlen(connect_data->connmgr_path );
       
 18070     strcpy( smsg + index, connect_data->connmgr_path );
       
 18071     index += len + 1;
       
 18072     
       
 18073     //appending protocol
       
 18074     len = strlen(connect_data->protocol );
       
 18075     strcpy( smsg + index, connect_data->protocol );
       
 18076     index += len + 1;
       
 18077     
       
 18078     #ifdef __WINSCW__
       
 18079     //proxy server
       
 18080     len = strlen(connect_data->proxy_data->proxy_server );
       
 18081     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 18082     index += len + 1;
       
 18083     
       
 18084     //proxy port
       
 18085     len = strlen(connect_data->proxy_data->proxy_port );
       
 18086     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 18087     index += len + 1;
       
 18088     
       
 18089     #endif
       
 18090     run_isoserver();
       
 18091     
       
 18092     //create message queue for send request
       
 18093     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18094     //create message queue for response request
       
 18095     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18096 		
       
 18097 	
       
 18098 	/* Send Message to queueOne */
       
 18099 	
       
 18100 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18101     
       
 18102     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 18103     
       
 18104     if (status < 0)
       
 18105     {
       
 18106     return_value = KErrGeneral;	
       
 18107     	goto return_code;	
       
 18108     }
       
 18109     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 18110 	memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 18111 	memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 18112 	
       
 18113 	if( msg_struct->response != 1)
       
 18114     {
       
 18115     	return_value = KErrGeneral;	
       
 18116     	goto return_code;
       
 18117     }
       
 18118     
       
 18119     
       
 18120     // login end
       
 18121     //fetch req..
       
 18122     for (int i= 0 ;i<3 ;i++)
       
 18123     {
       
 18124         
       
 18125     fp = fopen("c:\\fetch_contact.txt","a");
       
 18126 	do  {
       
 18127 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 18128 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 18129 		fwrite(rmsg,1,status,fp);
       
 18130 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18131 		} while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 18132 		          ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 18133 		          ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 18134 	fclose(fp);	
       
 18135 	
       
 18136     }
       
 18137 
       
 18138 	//fetch end
       
 18139  
       
 18140  
       
 18141  
       
 18142     // get search keys test code from server
       
 18143     index=0;
       
 18144     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18145 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18146 	
       
 18147 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18148     
       
 18149     msgHdr->message_type = ESearch_Get_Keys;
       
 18150  
       
 18151     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18152     index += sizeof( message_hdr_req );
       
 18153 
       
 18154 	
       
 18155 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18156      do  {
       
 18157 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18158 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18159 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 18160 	    
       
 18161 		} while (msg_struct->hdr_req.message_type!= ESearch_Get_Keys );
       
 18162    
       
 18163      if ( msg_struct->response != 1)
       
 18164     	{
       
 18165     	return_value = KErrGeneral;	
       
 18166     	goto return_code;
       
 18167     	}
       
 18168     	
       
 18169     int length = sizeof( message_hdr_resp );
       
 18170     char* search_value = NULL;
       
 18171     do  {
       
 18172 		search_value = strdup ( rmsg + length );
       
 18173 	    	
       
 18174 		if ( !search_value )
       
 18175 			{
       
 18176 			return_value = KErrGeneral;	
       
 18177 	    	goto return_code;
       
 18178 			}  
       
 18179 		length += strlen( search_value ) + 1;
       
 18180 	    } while ( ( 0 != strcmp( "First Name", search_value ) )
       
 18181 		    && length < status &&( free ( search_value ), search_value = NULL, 1 ) );
       
 18182     
       
 18183  
       
 18184  
       
 18185      
       
 18186     //search messge--------------------------------------------
       
 18187    
       
 18188     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18189 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18190 	index=0;
       
 18191     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18192     msgHdr->message_type = ESearch;	
       
 18193     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18194 	index += sizeof( message_hdr_req );
       
 18195 	
       
 18196 	
       
 18197     // adding key
       
 18198     len = strlen( search_value );
       
 18199     strcpy( smsg + index, search_value );
       
 18200     index += len + 1;
       
 18201         
       
 18202     // adding value
       
 18203     len = strlen( "santhosh" );
       
 18204     strcpy( smsg + index, "santhosh" );
       
 18205     index += len + 1;
       
 18206     
       
 18207     smsg[index++] = '\0';
       
 18208     
       
 18209     gint temp = 0;
       
 18210     gchar* add_contact = NULL;
       
 18211      
       
 18212      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18213      do  
       
 18214      	{
       
 18215 		memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18216 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18217 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );		    
       
 18218 	    
       
 18219 	 	} while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
       
 18220    
       
 18221      if ( msg_struct->response != 1 )
       
 18222     	{
       
 18223     	return_value = KErrGeneral;	
       
 18224     	goto return_code;
       
 18225    		}    
       
 18226    		
       
 18227     //search message end---------------------------------------
       
 18228  
       
 18229  
       
 18230     // logout test code from server
       
 18231     index=0;
       
 18232     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18233 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18234 	
       
 18235 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18236     
       
 18237     msgHdr->message_type = ELogout_Request;
       
 18238  
       
 18239     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18240     index += sizeof( message_hdr_req );
       
 18241 
       
 18242 	
       
 18243 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18244      do  {
       
 18245 		status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18246 		memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );	
       
 18247 	    memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18248 		} while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 18249    
       
 18250      if ( msg_struct->response != 1)
       
 18251     {
       
 18252     	return_value = KErrGeneral;	
       
 18253     	goto return_code;
       
 18254     }
       
 18255      
       
 18256    // result = MsgQDelete(REQUEST_QUEUE, &err);
       
 18257    // result = MsgQDelete(RESPONSE_QUEUE, &err);
       
 18258     return_value = KErrNone;	
       
 18259     goto return_code;
       
 18260     
       
 18261 //killing isoserver
       
 18262     return_code:
       
 18263     index=0;
       
 18264     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18265 	memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18266 	memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18267     msgHdr->message_type = EKill_Process;
       
 18268     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18269     index += sizeof( message_hdr_req );
       
 18270 	result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 18271     free( msg_struct );
       
 18272     return return_value;		
       
 18273 	}
       
 18274 
       
 18275 // -----------------------------------------------------------------------------
       
 18276 // Cisolationserver::set avatar
       
 18277 // Example test method function.
       
 18278 // (other items were commented in a header).
       
 18279 // -----------------------------------------------------------------------------
       
 18280 //
       
 18281 TInt Cisolationserver::SetOwnAvatar( CStifItemParser& aItem )
       
 18282     {
       
 18283 
       
 18284         
       
 18285    ConnectData  *connect_data = NULL;
       
 18286     char smsg[MAX_MSG_SIZE];
       
 18287     char rmsg[MAX_MSG_SIZE];
       
 18288     int index=0;
       
 18289     FILE *fp;
       
 18290         
       
 18291     int timeout = 200;
       
 18292     int nBytes;
       
 18293 
       
 18294     int result = 0;
       
 18295     int err = 0;
       
 18296     int status = 0;
       
 18297     message_hdr_req *msgHdr = NULL;  
       
 18298     message_hdr_resp* msg_struct = NULL;
       
 18299     TInt return_value = 0;
       
 18300             // Read data from the CFG file
       
 18301     if ( read_data ( connect_data, aItem ) != RC_OK )
       
 18302         {
       
 18303         iLog->Log ( _L ( "read_data failed" ) );
       
 18304         free_data ( connect_data );
       
 18305         return_value = KErrGeneral;
       
 18306         goto return_code;
       
 18307         }
       
 18308     //request formation 
       
 18309     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18310     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18311     
       
 18312     //message header use
       
 18313     msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 18314     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18315     
       
 18316     msgHdr->message_type = ELogin_Request;
       
 18317  
       
 18318     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18319     index += sizeof( message_hdr_req );
       
 18320     
       
 18321     int len = strlen(connect_data->username);
       
 18322     strcpy( smsg + index, connect_data->username );
       
 18323     index += len + 1;
       
 18324     
       
 18325     //appending password
       
 18326     
       
 18327     len = strlen(connect_data->password );
       
 18328     strcpy( smsg + index, connect_data->password );
       
 18329     index += len + 1;
       
 18330     
       
 18331     //appending server name
       
 18332     
       
 18333     len = strlen(connect_data->server );
       
 18334     strcpy( smsg + index, connect_data->server );
       
 18335     index += len + 1;
       
 18336     
       
 18337     //appending resource
       
 18338     len = strlen(connect_data->resource );
       
 18339     strcpy( smsg + index, connect_data->resource );
       
 18340     index += len + 1;
       
 18341     
       
 18342     //appending ssl
       
 18343     smsg[index++]= '1';
       
 18344     smsg[index++]= '\0';
       
 18345     
       
 18346     //appending server port
       
 18347     len = strlen(connect_data->port );
       
 18348     strcpy( smsg + index, connect_data->port );
       
 18349     index += len + 1;
       
 18350     
       
 18351     // appending IAP id
       
 18352     
       
 18353     smsg[index++]= '1';
       
 18354     smsg[index++]= '\0';
       
 18355     
       
 18356     //appending connmgr_bus
       
 18357     len = strlen(connect_data->connmgr_bus );
       
 18358     strcpy( smsg + index, connect_data->connmgr_bus );
       
 18359     index += len + 1;
       
 18360     
       
 18361     //appending connmgr_path
       
 18362     len = strlen(connect_data->connmgr_path );
       
 18363     strcpy( smsg + index, connect_data->connmgr_path );
       
 18364     index += len + 1;
       
 18365     
       
 18366     //appending protocol
       
 18367     len = strlen(connect_data->protocol );
       
 18368     strcpy( smsg + index, connect_data->protocol );
       
 18369     index += len + 1;
       
 18370     
       
 18371     #ifdef __WINSCW__
       
 18372     //proxy server
       
 18373     len = strlen(connect_data->proxy_data->proxy_server );
       
 18374     strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 18375     index += len + 1;
       
 18376     
       
 18377     //proxy port
       
 18378     len = strlen(connect_data->proxy_data->proxy_port );
       
 18379     strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 18380     index += len + 1;
       
 18381     
       
 18382     #endif
       
 18383     
       
 18384     //running isoserver   
       
 18385     run_isoserver(); 
       
 18386     
       
 18387         
       
 18388     //create message queue for send request
       
 18389     result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18390     //create message queue for response request
       
 18391     result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18392         
       
 18393     
       
 18394     /* Send Message to queueOne */
       
 18395     
       
 18396     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18397     
       
 18398     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 18399     
       
 18400     if (status < 0)
       
 18401     {
       
 18402     return_value = KErrGeneral;
       
 18403     goto return_code;   
       
 18404     }
       
 18405     msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 18406     memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 18407     memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 18408     
       
 18409     if( msg_struct->response != 1)
       
 18410     {
       
 18411         return_value = KErrGeneral;
       
 18412     goto return_code;
       
 18413     }
       
 18414     
       
 18415     
       
 18416     // login end
       
 18417 
       
 18418     //fetch req..
       
 18419        for (int i= 0 ;i<3 ;i++)
       
 18420        {
       
 18421            
       
 18422        fp = fopen("c:\\fetch_contact.txt","a");
       
 18423        do  {
       
 18424            status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 18425            memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18426            fwrite(rmsg,1,status,fp);
       
 18427            memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18428            } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 18429                      ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 18430                      ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 18431        fclose(fp); 
       
 18432        
       
 18433        }
       
 18434 
       
 18435        //fetch end
       
 18436     //set avatar
       
 18437     TPtrC               filename;
       
 18438     TPtrC               mimetype;
       
 18439     gchar        *file_name;
       
 18440     gchar        *mime_type;
       
 18441     gchar        *filecontent; 
       
 18442     int n;
       
 18443     TBuf8<KMaxFileName> temp;
       
 18444    
       
 18445    index = 0;
       
 18446     index += sizeof( message_hdr_req );
       
 18447     // setting avatar
       
 18448     FILE *file;
       
 18449     char *buffer;
       
 18450     unsigned long fileLen;
       
 18451 
       
 18452     //Open file
       
 18453     file = fopen(connect_data->image_file_name, "rb");
       
 18454     if (!file)
       
 18455         {
       
 18456         fprintf(stderr, "Unable to open file %s", file_name);
       
 18457         return;
       
 18458         }
       
 18459 
       
 18460     //Get file length
       
 18461     fseek(file, 0, SEEK_END);
       
 18462     fileLen=ftell(file);
       
 18463     fseek(file, 0, SEEK_SET);
       
 18464 
       
 18465    
       
 18466     //strcpy(mime_type,"image\jpeg");
       
 18467     len = fileLen + strlen(connect_data->mimetype) + 1;
       
 18468     buffer=(char *)malloc(len);
       
 18469     if (!buffer)
       
 18470         {
       
 18471         fprintf(stderr, "Memory error!");
       
 18472         fclose(file);
       
 18473         return;
       
 18474         }
       
 18475     memset( buffer, '\0', len );
       
 18476 	memcpy( buffer, connect_data->mimetype, strlen(connect_data->mimetype) );
       
 18477     //Read file contents into buffer
       
 18478     
       
 18479     fread(buffer + strlen(connect_data->mimetype) + 1, fileLen, 1, file);
       
 18480     fclose(file);
       
 18481 
       
 18482     //Do what ever with buffer
       
 18483     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18484     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18485     index=0;
       
 18486     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18487     msgHdr->message_type = EUpdateOwnAvtar;    
       
 18488     // memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18489     /* Send Message to queueOne */
       
 18490     TInt header_size = sizeof( message_hdr_req );
       
 18491     //crashes for perticuler image.Need to fix
       
 18492     char* one_pdu = ( char* ) malloc( ONE_K_OPENC_FIX );
       
 18493     //run a loop for rest of the data and keep track of the case of nBytes being 
       
 18494     //multiple of 1020 - sizeof(msghdr) and it being not
       
 18495     //Amount of payload that can be sent
       
 18496     TInt single_read = ONE_K_OPENC_FIX - header_size;
       
 18497     //Data recieved from PublishOwnPresenceL has message header at begining
       
 18498     TInt actual_data = fileLen;
       
 18499     //No of packets needed to send the image data
       
 18500     TInt total_packets = (TInt)ceil( ( double ) ( actual_data ) / single_read );
       
 18501     //This offset moves thru the msg pointer
       
 18502     TInt navigate_offset = 0;
       
 18503     for ( TInt i = 0; i < total_packets; i++ )
       
 18504         {
       
 18505         //till the last packet size_tobe_sent will be ONE_K_OPENC_FIX
       
 18506         //last packet data is actual_data % single_read if less than single_read else ONE_K_OPENC_FIX
       
 18507         TInt size_tobe_sent = ( i < total_packets - 1 ) ? ONE_K_OPENC_FIX : 
       
 18508         ( actual_data % single_read ? 
       
 18509             actual_data % single_read  + header_size : ONE_K_OPENC_FIX );
       
 18510 
       
 18511         if ( i < total_packets - 1 )
       
 18512             {
       
 18513             msgHdr->continue_flag = 1;
       
 18514             }
       
 18515         else 
       
 18516             {
       
 18517             msgHdr->continue_flag = 0;
       
 18518             }
       
 18519 
       
 18520         //memcpy ( msg + header_size , msg + navigate_offset, size_tobe_sent - header_size );
       
 18521         memcpy( one_pdu , msgHdr, header_size );
       
 18522         memcpy( one_pdu + header_size, buffer + navigate_offset, size_tobe_sent - header_size );
       
 18523         result = MsgQSend ( REQUEST_QUEUE, one_pdu, size_tobe_sent, 
       
 18524                 MSG_PRI_NORMAL, timeout, &err );
       
 18525         User::LeaveIfError ( result );
       
 18526         navigate_offset += single_read;
       
 18527         }
       
 18528     free(one_pdu);
       
 18529     free(buffer);
       
 18530     do  {
       
 18531     status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18532     memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18533     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18534     } while (msg_struct->hdr_req.message_type!=EUpdateOwnAvtar);
       
 18535 
       
 18536     if ( msg_struct->response != 1)
       
 18537         {
       
 18538         return_value = KErrGeneral;
       
 18539         goto return_code;
       
 18540         }
       
 18541 
       
 18542     //set avatar end     
       
 18543     // logout test code from server
       
 18544     index=0;
       
 18545     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18546     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18547     
       
 18548     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18549     
       
 18550     msgHdr->message_type = ELogout_Request;
       
 18551  
       
 18552     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18553     index += sizeof( message_hdr_req );
       
 18554 
       
 18555     
       
 18556     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18557      do  {
       
 18558         status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18559         memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18560         memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18561         } while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 18562    
       
 18563      if ( msg_struct->response != 1)
       
 18564     {
       
 18565         return_value = KErrGeneral;
       
 18566     goto return_code;
       
 18567     }
       
 18568     //killing isoserver
       
 18569     return_code:
       
 18570     index=0;
       
 18571     memset( smsg, '\0', MAX_MSG_SIZE );
       
 18572     memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18573     memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18574     msgHdr->message_type = EKill_Process;
       
 18575     memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18576     index += sizeof( message_hdr_req );
       
 18577     result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 18578     free( msg_struct );
       
 18579     return return_value;
       
 18580     }
       
 18581 
       
 18582 // -----------------------------------------------------------------------------
       
 18583 // Cisolationserver::clear avatar
       
 18584 // Example test method function.
       
 18585 // (other items were commented in a header).
       
 18586 // -----------------------------------------------------------------------------
       
 18587 //
       
 18588 TInt Cisolationserver::ClearOwnAvatar( CStifItemParser& aItem )
       
 18589     {
       
 18590 
       
 18591     
       
 18592     ConnectData  *connect_data = NULL;
       
 18593      char smsg[MAX_MSG_SIZE];
       
 18594      char rmsg[MAX_MSG_SIZE];
       
 18595      int index=0;
       
 18596      FILE *fp;
       
 18597          
       
 18598      int timeout = 200;
       
 18599      int nBytes;
       
 18600 
       
 18601      int result = 0;
       
 18602      int err = 0;
       
 18603      int status = 0;
       
 18604      message_hdr_req *msgHdr = NULL;  
       
 18605      message_hdr_resp* msg_struct = NULL;
       
 18606      TInt return_value = 0;
       
 18607              // Read data from the CFG file
       
 18608      if ( read_data ( connect_data, aItem ) != RC_OK )
       
 18609          {
       
 18610          iLog->Log ( _L ( "read_data failed" ) );
       
 18611          free_data ( connect_data );
       
 18612          return_value = KErrGeneral;
       
 18613          goto return_code;
       
 18614          }
       
 18615      //request formation 
       
 18616      memset( smsg, '\0', MAX_MSG_SIZE );
       
 18617      memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18618      
       
 18619      //message header use
       
 18620      msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 18621      memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18622      
       
 18623      msgHdr->message_type = ELogin_Request;
       
 18624   
       
 18625      memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18626      index += sizeof( message_hdr_req );
       
 18627      
       
 18628      int len = strlen(connect_data->username);
       
 18629      strcpy( smsg + index, connect_data->username );
       
 18630      index += len + 1;
       
 18631      
       
 18632      //appending password
       
 18633      
       
 18634      len = strlen(connect_data->password );
       
 18635      strcpy( smsg + index, connect_data->password );
       
 18636      index += len + 1;
       
 18637      
       
 18638      //appending server name
       
 18639      
       
 18640      len = strlen(connect_data->server );
       
 18641      strcpy( smsg + index, connect_data->server );
       
 18642      index += len + 1;
       
 18643      
       
 18644      //appending resource
       
 18645      len = strlen(connect_data->resource );
       
 18646      strcpy( smsg + index, connect_data->resource );
       
 18647      index += len + 1;
       
 18648      
       
 18649      //appending ssl
       
 18650      smsg[index++]= '1';
       
 18651      smsg[index++]= '\0';
       
 18652      
       
 18653      //appending server port
       
 18654      len = strlen(connect_data->port );
       
 18655      strcpy( smsg + index, connect_data->port );
       
 18656      index += len + 1;
       
 18657      
       
 18658      // appending IAP id
       
 18659      
       
 18660      smsg[index++]= '1';
       
 18661      smsg[index++]= '\0';
       
 18662      
       
 18663      //appending connmgr_bus
       
 18664      len = strlen(connect_data->connmgr_bus );
       
 18665      strcpy( smsg + index, connect_data->connmgr_bus );
       
 18666      index += len + 1;
       
 18667      
       
 18668      //appending connmgr_path
       
 18669      len = strlen(connect_data->connmgr_path );
       
 18670      strcpy( smsg + index, connect_data->connmgr_path );
       
 18671      index += len + 1;
       
 18672      
       
 18673      //appending protocol
       
 18674      len = strlen(connect_data->protocol );
       
 18675      strcpy( smsg + index, connect_data->protocol );
       
 18676      index += len + 1;
       
 18677      
       
 18678      #ifdef __WINSCW__
       
 18679      //proxy server
       
 18680      len = strlen(connect_data->proxy_data->proxy_server );
       
 18681      strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 18682      index += len + 1;
       
 18683      
       
 18684      //proxy port
       
 18685      len = strlen(connect_data->proxy_data->proxy_port );
       
 18686      strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 18687      index += len + 1;
       
 18688      
       
 18689      #endif
       
 18690      
       
 18691      //running isoserver   
       
 18692      run_isoserver(); 
       
 18693      
       
 18694          
       
 18695      //create message queue for send request
       
 18696      result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18697      //create message queue for response request
       
 18698      result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18699          
       
 18700      
       
 18701      /* Send Message to queueOne */
       
 18702      
       
 18703      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18704      
       
 18705      status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 18706      
       
 18707      if (status < 0)
       
 18708      {
       
 18709      return_value = KErrGeneral;
       
 18710      goto return_code;   
       
 18711      }
       
 18712      msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 18713      memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 18714      memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 18715      
       
 18716      if( msg_struct->response != 1)
       
 18717      {
       
 18718          return_value = KErrGeneral;
       
 18719      goto return_code;
       
 18720      }
       
 18721      
       
 18722      
       
 18723      // login end
       
 18724 
       
 18725      //fetch req..
       
 18726         for (int i= 0 ;i<3 ;i++)
       
 18727         {
       
 18728             
       
 18729         fp = fopen("c:\\fetch_contact.txt","a");
       
 18730         do  {
       
 18731             status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 18732             memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18733             fwrite(rmsg,1,status,fp);
       
 18734             memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18735             } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 18736                       ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 18737                       ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
       
 18738         fclose(fp); 
       
 18739         
       
 18740         }
       
 18741 
       
 18742         //fetch end
       
 18743         
       
 18744         //clear avatar
       
 18745         memset( smsg, '\0', MAX_MSG_SIZE );
       
 18746         memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18747         index=0;
       
 18748         memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18749         msgHdr->message_type = EClearOwnAvatar;    
       
 18750         memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18751         index += sizeof( message_hdr_req );
       
 18752         smsg[index++]='\0';
       
 18753         result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18754          do  {
       
 18755             status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18756             memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18757             memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18758             } while (msg_struct->hdr_req.message_type!=EClearOwnAvatar);
       
 18759        
       
 18760          if ( msg_struct->response != 1)
       
 18761         {
       
 18762             return_value = KErrGeneral;
       
 18763         goto return_code;
       
 18764         }
       
 18765              //clear avatar end     
       
 18766      // logout test code from server
       
 18767      index=0;
       
 18768      memset( smsg, '\0', MAX_MSG_SIZE );
       
 18769      memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18770      
       
 18771      memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18772      
       
 18773      msgHdr->message_type = ELogout_Request;
       
 18774   
       
 18775      memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18776      index += sizeof( message_hdr_req );
       
 18777 
       
 18778      
       
 18779      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18780       do  {
       
 18781          status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 18782          memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18783          memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18784          } while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 18785     
       
 18786       if ( msg_struct->response != 1)
       
 18787      {
       
 18788          return_value = KErrGeneral;
       
 18789      goto return_code;
       
 18790      }
       
 18791      //killing isoserver
       
 18792      return_code:
       
 18793      index=0;
       
 18794      memset( smsg, '\0', MAX_MSG_SIZE );
       
 18795      memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18796      memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18797      msgHdr->message_type = EKill_Process;
       
 18798      memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18799      index += sizeof( message_hdr_req );
       
 18800      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 18801      free( msg_struct );
       
 18802      return return_value;
       
 18803      }  
       
 18804 
       
 18805 
       
 18806 // -----------------------------------------------------------------------------
       
 18807 // Cisolationserver::clear avatar
       
 18808 // Example test method function.
       
 18809 // (other items were commented in a header).
       
 18810 // -----------------------------------------------------------------------------
       
 18811 //
       
 18812 TInt Cisolationserver::FetchCachedContacts( CStifItemParser& aItem )
       
 18813     {
       
 18814 
       
 18815     
       
 18816     ConnectData  *connect_data = NULL;
       
 18817      char smsg[MAX_MSG_SIZE];
       
 18818      char rmsg[MAX_MSG_SIZE];
       
 18819      int index=0;
       
 18820      FILE *fp;
       
 18821          
       
 18822      int timeout = 200;
       
 18823      int nBytes;
       
 18824 
       
 18825      int result = 0;
       
 18826      int err = 0;
       
 18827      int status = 0;
       
 18828      message_hdr_req *msgHdr = NULL;  
       
 18829      message_hdr_resp* msg_struct = NULL;
       
 18830      TInt return_value = 0;
       
 18831              // Read data from the CFG file
       
 18832      if ( read_data ( connect_data, aItem ) != RC_OK )
       
 18833          {
       
 18834          iLog->Log ( _L ( "read_data failed" ) );
       
 18835          free_data ( connect_data );
       
 18836          return_value = KErrGeneral;
       
 18837          goto return_code;
       
 18838          }
       
 18839      //request formation 
       
 18840      memset( smsg, '\0', MAX_MSG_SIZE );
       
 18841      memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18842      
       
 18843      //message header use
       
 18844      msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
       
 18845      memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18846      
       
 18847      msgHdr->message_type = ELogin_Request;
       
 18848   
       
 18849      memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18850      index += sizeof( message_hdr_req );
       
 18851      
       
 18852      int len = strlen(connect_data->username);
       
 18853      strcpy( smsg + index, connect_data->username );
       
 18854      index += len + 1;
       
 18855      
       
 18856      //appending password
       
 18857      
       
 18858      len = strlen(connect_data->password );
       
 18859      strcpy( smsg + index, connect_data->password );
       
 18860      index += len + 1;
       
 18861      
       
 18862      //appending server name
       
 18863      
       
 18864      len = strlen(connect_data->server );
       
 18865      strcpy( smsg + index, connect_data->server );
       
 18866      index += len + 1;
       
 18867      
       
 18868      //appending resource
       
 18869      len = strlen(connect_data->resource );
       
 18870      strcpy( smsg + index, connect_data->resource );
       
 18871      index += len + 1;
       
 18872      
       
 18873      //appending ssl
       
 18874      smsg[index++]= '1';
       
 18875      smsg[index++]= '\0';
       
 18876      
       
 18877      //appending server port
       
 18878      len = strlen(connect_data->port );
       
 18879      strcpy( smsg + index, connect_data->port );
       
 18880      index += len + 1;
       
 18881      
       
 18882      // appending IAP id
       
 18883      
       
 18884      smsg[index++]= '1';
       
 18885      smsg[index++]= '\0';
       
 18886      
       
 18887      //appending connmgr_bus
       
 18888      len = strlen(connect_data->connmgr_bus );
       
 18889      strcpy( smsg + index, connect_data->connmgr_bus );
       
 18890      index += len + 1;
       
 18891      
       
 18892      //appending connmgr_path
       
 18893      len = strlen(connect_data->connmgr_path );
       
 18894      strcpy( smsg + index, connect_data->connmgr_path );
       
 18895      index += len + 1;
       
 18896      
       
 18897      //appending protocol
       
 18898      len = strlen(connect_data->protocol );
       
 18899      strcpy( smsg + index, connect_data->protocol );
       
 18900      index += len + 1;
       
 18901      
       
 18902      #ifdef __WINSCW__
       
 18903      //proxy server
       
 18904      len = strlen(connect_data->proxy_data->proxy_server );
       
 18905      strcpy( smsg + index, connect_data->proxy_data->proxy_server );
       
 18906      index += len + 1;
       
 18907      
       
 18908      //proxy port
       
 18909      len = strlen(connect_data->proxy_data->proxy_port );
       
 18910      strcpy( smsg + index, connect_data->proxy_data->proxy_port );
       
 18911      index += len + 1;
       
 18912      
       
 18913      #endif
       
 18914      
       
 18915      //running isoserver   
       
 18916      run_isoserver(); 
       
 18917      
       
 18918          
       
 18919      //create message queue for send request
       
 18920      result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18921      //create message queue for response request
       
 18922      result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
       
 18923          
       
 18924      
       
 18925      /* Send Message to queueOne */
       
 18926      
       
 18927      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18928      
       
 18929      status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); 
       
 18930      
       
 18931      if (status < 0)
       
 18932      {
       
 18933      return_value = KErrGeneral;
       
 18934      goto return_code;   
       
 18935      }
       
 18936      msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
       
 18937      memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
       
 18938      memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
       
 18939      
       
 18940      if( msg_struct->response != 1)
       
 18941      {
       
 18942          return_value = KErrGeneral;
       
 18943      goto return_code;
       
 18944      }
       
 18945      
       
 18946      
       
 18947      // login end
       
 18948 
       
 18949      //fetch req..
       
 18950      TInt count = 0;
       
 18951             
       
 18952         fp = fopen("c:\\fetch_contact.txt","a");
       
 18953         do  {
       
 18954             status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 18955             memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18956             fwrite(rmsg,1,status,fp);
       
 18957             memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18958             
       
 18959             if ( (msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 18960                                   ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 18961                                   ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts) && 0 == msg_struct->continue_flag )
       
 18962                         {
       
 18963                         count++;
       
 18964                         }
       
 18965             
       
 18966             
       
 18967             } while (count < 3 );
       
 18968         fclose(fp); 
       
 18969 
       
 18970         
       
 18971         
       
 18972 
       
 18973         //fetch end
       
 18974         FILE* fop = NULL;
       
 18975         //clear avatar
       
 18976         memset( smsg, '\0', MAX_MSG_SIZE );
       
 18977         memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18978         index=0;
       
 18979         memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 18980         msgHdr->message_type = EFetchCachedContacts;    
       
 18981         memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 18982         index += sizeof( message_hdr_req );
       
 18983         smsg[index++]='\0';
       
 18984         result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 18985         fop = fopen("c:\\santhosh.txt","a");
       
 18986         count = 0;
       
 18987         do  {
       
 18988             status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err); 
       
 18989             memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 18990             fwrite(rmsg,1,status,fop);
       
 18991             memset( rmsg, '\0', MAX_MSG_SIZE );
       
 18992             
       
 18993             if ( ((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts) 
       
 18994                                   ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts) 
       
 18995                                   ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts)) && 0 == msg_struct->continue_flag )
       
 18996                         {
       
 18997                         count++;
       
 18998                         }
       
 18999             
       
 19000             
       
 19001             } while (count < 3 );
       
 19002         fclose(fop); 
       
 19003 
       
 19004      //clear avatar end     
       
 19005      // logout test code from server
       
 19006      index=0;
       
 19007      memset( smsg, '\0', MAX_MSG_SIZE );
       
 19008      memset( rmsg, '\0', MAX_MSG_SIZE );
       
 19009      
       
 19010      memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 19011      
       
 19012      msgHdr->message_type = ELogout_Request;
       
 19013   
       
 19014      memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 19015      index += sizeof( message_hdr_req );
       
 19016 
       
 19017      
       
 19018      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
       
 19019       do  {
       
 19020          status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
       
 19021          memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) ); 
       
 19022          memset( rmsg, '\0', MAX_MSG_SIZE );
       
 19023          } while (msg_struct->hdr_req.message_type!=ELogout_Request);
       
 19024     
       
 19025       if ( msg_struct->response != 1)
       
 19026      {
       
 19027          return_value = KErrGeneral;
       
 19028      goto return_code;
       
 19029      }
       
 19030      //killing isoserver
       
 19031      return_code:
       
 19032      index=0;
       
 19033      memset( smsg, '\0', MAX_MSG_SIZE );
       
 19034      memset( rmsg, '\0', MAX_MSG_SIZE );
       
 19035      memset( msgHdr, '\0', sizeof( message_hdr_req ) );
       
 19036      msgHdr->message_type = EKill_Process;
       
 19037      memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
       
 19038      index += sizeof( message_hdr_req );
       
 19039      result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); 
       
 19040      free( msg_struct );
       
 19041      return return_value;
       
 19042      }  
       
 19043 
       
 19044 // -----------------------------------------------------------------------------
       
 19045 // Cisolationserver::?member_function
       
 19046 // ?implementation_description
       
 19047 // (other items were commented in a header).
       
 19048 // -----------------------------------------------------------------------------
       
 19049 //
       
 19050 /*
       
 19051 TInt Cisolationserver::?member_function(
       
 19052    CItemParser& aItem )
       
 19053    {
       
 19054 
       
 19055    ?code
       
 19056 
       
 19057    }
       
 19058 */
       
 19059 
       
 19060 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
 19061 // None
       
 19062 
       
 19063 //  [End of File] - Do not remove