ximpfw/tsrc/tsrcprotocols/pr_prfwtestprotocol/pr_prfwtestprotocol.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Test Protocol implementation for XIMP Framework
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <badesca.h>
       
    20 #include <ecom/implementationproxy.h>
       
    21 
       
    22 #include <ximpstatus.h>
       
    23 #include <ximpserviceinfo.h>
       
    24 #include <ximpcontextclientinfo.h>
       
    25 
       
    26 #include <ximpprotocolconnectionhost.h>
       
    27 #include <protocolpresencepublishingdatahost.h>
       
    28 #include <protocolpresencefeatures.h>
       
    29 #include <ximprestrictedobjectcollection.h>
       
    30 #include <ximpidentity.h>
       
    31 #include <presentitygroupinfo.h>
       
    32 #include <presentitygroupmemberinfo.h>
       
    33 #include <ximpobjectfactory.h>
       
    34 #include <ximpprotocolrequestcompleteevent.h>
       
    35 #include <presencefeatures.h>
       
    36 #include <presenceobjectfactory.h>
       
    37 #include <protocolpresencedatahost.h>
       
    38 
       
    39 
       
    40 #include "pr_prfwtestprotocol.h"
       
    41 #include "prfwgeneralwaiter.h"
       
    42 #include "prfwtestmessaging.h"
       
    43 #include "prfwtestmessenger.h"
       
    44 #include "prfwtestfilelogichelper.h"
       
    45 #include "prfwtestfiletool.h"
       
    46 #include "ximprequestidbuilder.h"
       
    47 #include "prfwtestprotocols.h"
       
    48 
       
    49 
       
    50 
       
    51 const TInt KWaitTime = 1;
       
    52 
       
    53 T_XIMPTestConnection::ClientWrapper* T_XIMPTestConnection::ClientWrapper::NewLC( const TDesC& aClientId )
       
    54     {
       
    55     ClientWrapper* self = new ( ELeave ) ClientWrapper;
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL( aClientId );
       
    58     return self;
       
    59     }
       
    60 
       
    61 void T_XIMPTestConnection::ClientWrapper::ConstructL( const TDesC& aClientId )
       
    62     {
       
    63     iId.CreateL( aClientId );
       
    64     }
       
    65 
       
    66 void T_XIMPTestConnection::ClientWrapper::InitializeL( MXIMPProtocolConnectionHost& aConnectionHost )
       
    67     {
       
    68     if( !iMessenger )
       
    69         {
       
    70         TLex lex( iId );
       
    71         TInt index = 0;
       
    72         User::LeaveIfError( lex.Val( index ) );
       
    73         // TEST CODE
       
    74         __ASSERT_ALWAYS( index != -1, User::Panic(_L("Protocol"), 666));
       
    75         iMessenger = CXIMPTestMessenger::NewForAdaptationSideL( index );
       
    76         iPluginIndex = index;
       
    77         }
       
    78 
       
    79     if( !iFileLogicHelper )
       
    80         {
       
    81         iFileLogicHelper = CXIMPTestFileLogicHelper::NewL( aConnectionHost, *iMessenger );
       
    82         }
       
    83 
       
    84     if( !iFileTool )
       
    85         {
       
    86         // TODO FIX FILETOOL CREATION
       
    87         iFileTool = CXIMPTestFileTool::NewL( K_PRFW_TST_PROTOCOL_1_IMPLEMENTATION_UID, iId );
       
    88         iFileTool->RegisterObserverL( iFileLogicHelper );
       
    89         }
       
    90     }
       
    91 
       
    92 T_XIMPTestConnection::ClientWrapper::~ClientWrapper()
       
    93     {
       
    94     if( iFileTool && iFileLogicHelper )
       
    95         {
       
    96         iFileTool->UnregisterObserver( iFileLogicHelper );
       
    97         }
       
    98     delete iFileTool;
       
    99     delete iFileLogicHelper;
       
   100     delete iMessenger;
       
   101 
       
   102     iId.Close();
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // OrderOfClients()
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 TInt T_XIMPTestConnection::OrderOfClients( const T_XIMPTestConnection::ClientWrapper& aFirst,
       
   110                                            const T_XIMPTestConnection::ClientWrapper& aSecond )
       
   111     {
       
   112     return aFirst.iId.Compare( aSecond.iId );
       
   113     }
       
   114 
       
   115 // ======== MEMBER FUNCTIONS ========
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // OrderOfConnections()
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 TInt T_XIMPTestConnection::OrderOfConnections( const T_XIMPTestConnection& aFirst,
       
   123                                                const T_XIMPTestConnection& aSecond )
       
   124     {
       
   125     TInt retVal = aFirst.iServerAddress->Compare( *aSecond.iServerAddress );
       
   126     if( retVal != 0 )
       
   127         {
       
   128         return retVal;
       
   129         }
       
   130     retVal = aFirst.iUserName->Compare( *aSecond.iUserName );
       
   131     if( retVal != 0 )
       
   132         {
       
   133         return retVal;
       
   134         }
       
   135 
       
   136     return aFirst.iPassword->Compare( *aSecond.iPassword );
       
   137     }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // T_XIMPTestConnection::T_XIMPTestConnection()
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 T_XIMPTestConnection::T_XIMPTestConnection()
       
   145     {
       
   146     }
       
   147 
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // T_XIMPTestConnection::ConstructL()
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void T_XIMPTestConnection::ConstructL( const MXIMPServiceInfo& aServiceInfo,
       
   154                                        const MXIMPContextClientInfo& aClientCtxInfo )
       
   155     {
       
   156     iWaitter = CXIMPTestGeneralWaiter::NewL( this );
       
   157 
       
   158     iAuxTimer = CPeriodic::NewL( CActive::EPriorityIdle );
       
   159 
       
   160     iServerAddress = aServiceInfo.ServiceAddress().AllocL();
       
   161     iUserName = aServiceInfo.UserId().AllocL();
       
   162     iPassword = aServiceInfo.Password().AllocL();
       
   163     iClientId = aClientCtxInfo.ClientId().Identity().AllocL();
       
   164     }
       
   165 
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // T_XIMPTestConnection::NewLC()
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 T_XIMPTestConnection* T_XIMPTestConnection::NewLC( const MXIMPServiceInfo& aServiceInfo,
       
   172                                                    const MXIMPContextClientInfo& aClientCtxInfo )
       
   173     {
       
   174     T_XIMPTestConnection* self = new( ELeave ) T_XIMPTestConnection(  );
       
   175     CleanupStack::PushL( self );
       
   176     self->ConstructL( aServiceInfo, aClientCtxInfo );
       
   177     return self;
       
   178     }
       
   179 
       
   180 
       
   181 // ---------------------------------------------------------------------------
       
   182 // T_XIMPTestConnection::NewL()
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 T_XIMPTestConnection* T_XIMPTestConnection::NewL( const MXIMPServiceInfo& aServiceInfo,
       
   186                                                   const MXIMPContextClientInfo& aClientCtxInfo )
       
   187     {
       
   188     T_XIMPTestConnection* self = T_XIMPTestConnection::NewLC( aServiceInfo, aClientCtxInfo );
       
   189     CleanupStack::Pop( self );
       
   190     return self;
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // T_XIMPTestConnection::~T_XIMPTestConnection()
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 T_XIMPTestConnection::~T_XIMPTestConnection()
       
   198     {
       
   199     SetBoolean( EXIMPPlgTestDeath );
       
   200 
       
   201     if ( iAuxTimer )
       
   202         {
       
   203         iAuxTimer->Deque();
       
   204         }
       
   205     delete iAuxTimer;
       
   206 
       
   207     delete iWaitter;
       
   208 
       
   209     iClients.ResetAndDestroy();
       
   210 
       
   211     delete iServerAddress;
       
   212     delete iUserName;
       
   213     delete iPassword;
       
   214     delete iClientId;
       
   215 
       
   216     delete iClientToBeDeleted;
       
   217     }
       
   218 
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // T_XIMPTestConnection::PrimeHost()
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 void T_XIMPTestConnection::PrimeHost( MXIMPProtocolConnectionHost& aHost )
       
   225     {
       
   226     iConnectionHost = &aHost;
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // T_XIMPTestConnection::PresenceFeatures()
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 MProtocolPresenceFeatures& T_XIMPTestConnection::ProtocolPresenceFeatures()
       
   234     {
       
   235     return *this;
       
   236     }
       
   237 
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // T_XIMPTestConnection::PresenceFeatures()
       
   241 // ---------------------------------------------------------------------------
       
   242 //	MProtocolImFeatures* ProtocolImFeatures();
       
   243 //MProtocolImFeatures* T_XIMPTestConnection::ProtocolImFeatures()
       
   244 //    {
       
   245 //    return NULL;
       
   246 //    }
       
   247 // ---------------------------------------------------------------------------
       
   248 // T_XIMPTestConnection::GetProtocolInterface()
       
   249 // ---------------------------------------------------------------------------
       
   250 TAny* T_XIMPTestConnection::GetProtocolInterface(TInt aInterfaceId)
       
   251 	{
       
   252 	return NULL ;
       
   253 	}
       
   254     
       
   255     
       
   256     
       
   257 // ---------------------------------------------------------------------------
       
   258 // T_XIMPTestConnection::PresenceWatching()
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 MProtocolPresenceWatching& T_XIMPTestConnection::PresenceWatching()
       
   262     {
       
   263     return *this;
       
   264     }
       
   265 // ---------------------------------------------------------------------------
       
   266 // T_XIMPTestConnection::PresencePublishing()
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 MProtocolPresencePublishing& T_XIMPTestConnection::PresencePublishing()
       
   270     {
       
   271     return *this;
       
   272     }
       
   273 // ---------------------------------------------------------------------------
       
   274 // T_XIMPTestConnection::PresentityGroups()
       
   275 // ---------------------------------------------------------------------------
       
   276 //
       
   277 MProtocolPresentityGroups& T_XIMPTestConnection::PresentityGroups()
       
   278     {
       
   279     return *this;
       
   280     }
       
   281 // ---------------------------------------------------------------------------
       
   282 // T_XIMPTestConnection::PresenceAuthorization()
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 MProtocolPresenceAuthorization& T_XIMPTestConnection::PresenceAuthorization()
       
   286     {
       
   287     return *this;
       
   288     }
       
   289 
       
   290 // ---------------------------------------------------------------------------
       
   291 // T_XIMPTestConnection::HandleProtocolConnectionHostEvent()
       
   292 // ---------------------------------------------------------------------------
       
   293 //
       
   294 void T_XIMPTestConnection::HandleProtocolConnectionHostEvent(
       
   295     const MXIMPProtocolConnectionHost& aHost,
       
   296     const MXIMPBase& aEvent )
       
   297     {
       
   298     if( &aHost != iConnectionHost )
       
   299         {
       
   300         User::Panic(_L("Protocol"), -42 );
       
   301         }
       
   302     
       
   303     
       
   304     if( aEvent.GetInterfaceId() == MXIMPProtocolRequestCompleteEvent::KInterfaceId )
       
   305         {
       
   306         const MXIMPProtocolRequestCompleteEvent* eventIf =
       
   307         TXIMPGetInterface< const MXIMPProtocolRequestCompleteEvent >::From( aEvent,
       
   308                                                                             MXIMPBase::EPanicIfUnknown );
       
   309         RDebug::Print( _L("   T_XIMPTestConnection: received ProtocolRequestCompleteEvent with result [%d]"), 
       
   310                        eventIf->ResultCode() );
       
   311         }
       
   312     }
       
   313     
       
   314     
       
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 // T_XIMPTestConnection::OpenSessionL()
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 void T_XIMPTestConnection::OpenSessionL( const MXIMPContextClientInfo& aClientCtxInfo,
       
   321                                        TXIMPRequestId aReqId )
       
   322     {
       
   323     iConnectionHost->RegisterObserverL( *this );
       
   324 
       
   325     ClientWrapper* client = ClientWrapper::NewLC( aClientCtxInfo.ClientId().Identity() );
       
   326 
       
   327     TLinearOrder< T_XIMPTestConnection::ClientWrapper > order( T_XIMPTestConnection::OrderOfClients );
       
   328     TInt indexOfClient = iClients.FindInOrder( client, order );
       
   329 
       
   330     if( indexOfClient != KErrNotFound )
       
   331         {
       
   332         User::LeaveIfError( indexOfClient );
       
   333         CleanupStack::PopAndDestroy(); //id
       
   334         client = iClients[ indexOfClient ];
       
   335         }
       
   336     else
       
   337         {
       
   338         client->InitializeL( *iConnectionHost );
       
   339         iCurrentMessenger = client->iMessenger;
       
   340         }
       
   341 
       
   342     PluginAPIMethodCommonL( aReqId );
       
   343 
       
   344     if( indexOfClient == KErrNotFound )
       
   345         {
       
   346         iClients.InsertInOrderL( client, order );
       
   347         CleanupStack::Pop(); //id
       
   348         }
       
   349 
       
   350 
       
   351     SetBooleanToCurrent( EXIMPPlgTestOpenSessionCalled );
       
   352     iWaitter->WaitForL( KWaitTime );
       
   353     }
       
   354 
       
   355 // ---------------------------------------------------------------------------
       
   356 // T_XIMPTestConnection::OpenSessionL()
       
   357 // ---------------------------------------------------------------------------
       
   358 //
       
   359 void T_XIMPTestConnection::OpenSessionL(
       
   360                 const TInt& aSettingsId,
       
   361                 TXIMPRequestId aReqId )
       
   362 
       
   363     {
       
   364     iConnectionHost->RegisterObserverL( *this );
       
   365 
       
   366     ClientWrapper* client = ClientWrapper::NewLC( _L("0") );
       
   367 
       
   368     TLinearOrder< T_XIMPTestConnection::ClientWrapper > order( T_XIMPTestConnection::OrderOfClients );
       
   369     TInt indexOfClient = iClients.FindInOrder( client, order );
       
   370 
       
   371     if( indexOfClient != KErrNotFound )
       
   372         {
       
   373         User::LeaveIfError( indexOfClient );
       
   374         CleanupStack::PopAndDestroy(); //id
       
   375         client = iClients[ indexOfClient ];
       
   376         }
       
   377     else
       
   378         {
       
   379         client->InitializeL( *iConnectionHost );
       
   380         iCurrentMessenger = client->iMessenger;
       
   381         }
       
   382 
       
   383     PluginAPIMethodCommonL( aReqId );
       
   384 
       
   385     if( indexOfClient == KErrNotFound )
       
   386         {
       
   387         iClients.InsertInOrderL( client, order );
       
   388         CleanupStack::Pop(); //id
       
   389         }
       
   390 
       
   391 
       
   392     SetBooleanToCurrent( EXIMPPlgTestOpenSessionCalled );
       
   393     iWaitter->WaitForL( KWaitTime );
       
   394     }
       
   395         
       
   396         
       
   397 
       
   398 // ---------------------------------------------------------------------------
       
   399 // T_XIMPTestConnection::CloseSession()
       
   400 // ---------------------------------------------------------------------------
       
   401 //
       
   402 void T_XIMPTestConnection::CloseSession( const MXIMPContextClientInfo& aClientCtxInfo,
       
   403                                          TXIMPRequestId aReqId )
       
   404     {
       
   405     PluginAPIMethodCommonL( aReqId );
       
   406 
       
   407     iClientToBeDeleted = NULL;
       
   408     TInt count = iClients.Count();
       
   409     TBool found(EFalse);
       
   410     for( TInt a = 0; a < count && !iClientToBeDeleted; ++a )
       
   411         {
       
   412         if( aClientCtxInfo.ClientId().Identity().Compare( iClients[ a ]->iId ) == 0 )
       
   413             {
       
   414             iClientToBeDeleted = iClients[ a ];
       
   415             iClients.Remove( a );
       
   416             found = ETrue;
       
   417             }
       
   418         }
       
   419 
       
   420     SetBooleanToCurrent( EXIMPPlgTestCloseSessionCalled );
       
   421 
       
   422     if(found)
       
   423     iWaitter->WaitForL( KWaitTime );
       
   424     else
       
   425     	{
       
   426 	    MXIMPStatus* status = iConnectionHost->ObjectFactory().NewStatusLC();
       
   427 	    CleanupStack::Pop(); // status.
       
   428 	    status->SetResultCode(KErrNone);
       
   429     	iConnectionHost->HandleRequestCompleted( aReqId, status);    		
       
   430     	}
       
   431     	
       
   432     
       
   433     	
       
   434     }
       
   435 
       
   436 
       
   437 // ---------------------------------------------------------------------------
       
   438 // T_XIMPTestConnection::GetSupportedFeaturesL()
       
   439 // ---------------------------------------------------------------------------
       
   440 //
       
   441 void T_XIMPTestConnection::GetSupportedFeaturesL( CDesC8Array& aFeatures ) const
       
   442     {
       
   443     if ( ! iClients.Count() )
       
   444         {
       
   445         User::LeaveIfError( KErrNotReady );
       
   446         }
       
   447 
       
   448     // first empty the whole array
       
   449     aFeatures.Reset();
       
   450 
       
   451     // then add two features there: 1 supported by XIMP, 1 not
       
   452     aFeatures.AppendL( _L8("feat/pres/pub") );
       
   453     aFeatures.AppendL( _L8("feat/worlddomination") );
       
   454     }
       
   455 
       
   456 // ---------------------------------------------------------------------------
       
   457 // T_XIMPTestConnection::DoSubscribeOwnPresenceL
       
   458 // ---------------------------------------------------------------------------
       
   459 //
       
   460 void T_XIMPTestConnection::DoSubscribeOwnPresenceL( const MPresenceInfoFilter& aPif,
       
   461         TXIMPRequestId aReqId )
       
   462     {
       
   463     PluginAPIMethodCommonL( aReqId );
       
   464 
       
   465     SetBooleanToCurrent( EXIMPPlgTestSubscribeOwnPresenceCalled );
       
   466 
       
   467     // TODO do something, like in PublishPresence
       
   468 
       
   469     iWaitter->WaitForL( KWaitTime );
       
   470     }
       
   471 
       
   472 // ---------------------------------------------------------------------------
       
   473 // T_XIMPTestConnection::DoUpdateOwnPresenceSubscriptionL
       
   474 // ---------------------------------------------------------------------------
       
   475 //
       
   476 void T_XIMPTestConnection::DoUpdateOwnPresenceSubscriptionPifL( const MPresenceInfoFilter& aPif,
       
   477         TXIMPRequestId aReqId )
       
   478     {
       
   479     PluginAPIMethodCommonL( aReqId );
       
   480 
       
   481     SetBooleanToCurrent( EXIMPPlgTestUpdateOwnSubscriptionCalled );
       
   482 
       
   483     // TODO do something, like in PublishPresence
       
   484 
       
   485     iWaitter->WaitForL( KWaitTime );
       
   486     }
       
   487 
       
   488 
       
   489 // ---------------------------------------------------------------------------
       
   490 // From MPscPlugin class.
       
   491 // T_XIMPTestConnection::DoSubscribePresenceWatcherListL()
       
   492 // ---------------------------------------------------------------------------
       
   493 //
       
   494 void T_XIMPTestConnection::DoSubscribePresenceWatcherListL( TXIMPRequestId aReqId )
       
   495     {
       
   496     PluginAPIMethodCommonL( aReqId );
       
   497 
       
   498     SetBooleanToCurrent( EXIMPPlgTestSubscribePresenceWatcherListCalled );
       
   499 
       
   500     // TODO do something, like in PublishPresence
       
   501 
       
   502     iWaitter->WaitForL( KWaitTime );
       
   503     }
       
   504 
       
   505 // ---------------------------------------------------------------------------
       
   506 // From MPscPlugin class.
       
   507 // T_XIMPTestConnection::DoUnsubscribePresenceWatcherListL()
       
   508 // ---------------------------------------------------------------------------
       
   509 //
       
   510 void T_XIMPTestConnection::DoUnsubscribePresenceWatcherListL( TXIMPRequestId aReqId )
       
   511     {
       
   512     PluginAPIMethodCommonL( aReqId );
       
   513 
       
   514     SetBooleanToCurrent( EXIMPPlgTestUnsubscribePresenceWatcherListCalled );
       
   515 
       
   516     // TODO do something, like in PublishPresence
       
   517 
       
   518     iWaitter->WaitForL( KWaitTime );
       
   519     }
       
   520 
       
   521 // ---------------------------------------------------------------------------
       
   522 // T_XIMPTestConnection::DoSubscribePresentityGroupListL
       
   523 // ---------------------------------------------------------------------------
       
   524 //
       
   525 void T_XIMPTestConnection::DoSubscribePresentityGroupListL( TXIMPRequestId aReqId )
       
   526     {
       
   527     PluginAPIMethodCommonL( aReqId );
       
   528 
       
   529     SetBooleanToCurrent( EXIMPPlgTestSubscribeGroupListCalled );
       
   530 
       
   531     // TODO do something, like in PublishPresence
       
   532 
       
   533     iWaitter->WaitForL( KWaitTime );
       
   534     }
       
   535 
       
   536 // ---------------------------------------------------------------------------
       
   537 // T_XIMPTestConnection::DoUnsubscribePresentityGroupListL
       
   538 // ---------------------------------------------------------------------------
       
   539 //
       
   540 void T_XIMPTestConnection::DoUnsubscribePresentityGroupListL( TXIMPRequestId aReqId )
       
   541     {
       
   542     PluginAPIMethodCommonL( aReqId );
       
   543 
       
   544     SetBooleanToCurrent( EXIMPPlgTestUnsubscribeGroupListCalled );
       
   545 
       
   546     // TODO do something, like in PublishPresence
       
   547 
       
   548     iWaitter->WaitForL( KWaitTime );
       
   549     }
       
   550 
       
   551 
       
   552 // ---------------------------------------------------------------------------
       
   553 // T_XIMPTestConnection::PublishPresenceL()
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 void T_XIMPTestConnection::DoPublishOwnPresenceL(
       
   557         const MPresenceInfo& aPresence,
       
   558         TXIMPRequestId aReqId )
       
   559     {
       
   560     // With SetupLeave we leave here
       
   561     PluginAPIMethodCommonL( aReqId );
       
   562 
       
   563     SetBooleanToCurrent( EXIMPPlgTestPublishPresenceCalled );
       
   564 
       
   565     MProtocolPresenceDataHost& presHost = iConnectionHost->ProtocolPresenceDataHost();
       
   566     // Set own presence data in data cache
       
   567     MPresenceInfo* presence = presHost.PresenceObjectFactory().NewPresenceInfoLC();
       
   568     TXIMPRequestId reqid = presHost.PublishingDataHost().HandleSubscribedOwnPresenceL( presence );
       
   569     CleanupStack::Pop(); //presence
       
   570 
       
   571     
       
   572     if(iCurrentMessenger->GetError()==KErrTimedOut)
       
   573     	{
       
   574 	    MXIMPStatus* status1 = iConnectionHost->ObjectFactory().NewStatusLC();
       
   575 	    iConnectionHost->HandleConnectionTerminated(status1);
       
   576 
       
   577 		CleanupStack::PopAndDestroy(1);
       
   578     	}
       
   579 
       
   580     iWaitter->WaitForL( KWaitTime );
       
   581 
       
   582     // TODO when implemented, write the data received for test case verification
       
   583     }
       
   584 
       
   585 // ---------------------------------------------------------------------------
       
   586 // T_XIMPTestConnection::DoUnsubscribeOwnPresenceL()
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 void T_XIMPTestConnection::DoUnsubscribeOwnPresenceL( TXIMPRequestId aReqId )
       
   590     {
       
   591     PluginAPIMethodCommonL( aReqId );
       
   592 
       
   593     // prepare the message for test code
       
   594     SetBooleanToCurrent( EXIMPPlgTestUnsubscribeOwnPresenceCalled );
       
   595     // TODO when implemented, read the data given by test case and
       
   596     //      generate the required events
       
   597     iWaitter->WaitForL( KWaitTime );
       
   598     }
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // T_XIMPTestConnection::DoCreatePresentityGroupL
       
   602 // ---------------------------------------------------------------------------
       
   603 //
       
   604 void T_XIMPTestConnection::DoCreatePresentityGroupL( const MXIMPIdentity& aIdentity,
       
   605                                            const TDesC16& aDisplayName,
       
   606                                            TXIMPRequestId aReqId )
       
   607     {
       
   608     PluginAPIMethodCommonL( aReqId );
       
   609 
       
   610     // prepare the message for test code
       
   611     SetBooleanToCurrent( EXIMPPlgTestCreatePresentityGroupCalled );
       
   612     // TODO when implemented, read the data given by test case and
       
   613     //      generate the required events
       
   614     iWaitter->WaitForL( KWaitTime );
       
   615     }
       
   616 
       
   617 // ---------------------------------------------------------------------------
       
   618 // T_XIMPTestConnection::DoCreatePresentityGroupL
       
   619 // ---------------------------------------------------------------------------
       
   620 //
       
   621 void T_XIMPTestConnection::DoDeletePresentityGroupL( const MXIMPIdentity& aIdentity,
       
   622                                            TXIMPRequestId aReqId )
       
   623     {
       
   624     PluginAPIMethodCommonL( aReqId );
       
   625 
       
   626     // prepare the message for test code
       
   627     SetBooleanToCurrent( EXIMPPlgTestDeletePresentityGroupCalled );
       
   628     // TODO when implemented, read the data given by test case and
       
   629     //      generate the required events
       
   630     iWaitter->WaitForL( KWaitTime );
       
   631     }
       
   632 
       
   633 // ---------------------------------------------------------------------------
       
   634 // T_XIMPTestConnection::DoCreatePresentityGroupL
       
   635 // ---------------------------------------------------------------------------
       
   636 //
       
   637 void T_XIMPTestConnection::DoUpdatePresentityGroupDisplayNameL( const MXIMPIdentity& aIdentity,
       
   638                                            const TDesC16& aDisplayName,
       
   639                                            TXIMPRequestId aReqId )
       
   640     {
       
   641     PluginAPIMethodCommonL( aReqId );
       
   642 
       
   643     // prepare the message for test code
       
   644     SetBooleanToCurrent( EXIMPPlgTestUpdatePresentityGroupDisplayNameCalled );
       
   645     // TODO when implemented, read the data given by test case and
       
   646     //      generate the required events
       
   647     iWaitter->WaitForL( KWaitTime );
       
   648     }
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // T_XIMPTestConnection::DoSubscribePresentityPresenceL
       
   652 // ---------------------------------------------------------------------------
       
   653 //
       
   654 void T_XIMPTestConnection::DoSubscribePresentityPresenceL(
       
   655                                     const MXIMPIdentity& aIdentity,
       
   656                                     const MPresenceInfoFilter& aPif,
       
   657                                     TXIMPRequestId aReqId )
       
   658     {
       
   659     PluginAPIMethodCommonL( aReqId );
       
   660 
       
   661     // prepare the message for test code
       
   662     SetBooleanToCurrent( EXIMPPlgTestSubscribePresentityPresesenceCalled );
       
   663     // TODO when implemented, read the data given by test case and
       
   664     //      generate the required events
       
   665     iWaitter->WaitForL( KWaitTime );
       
   666     }
       
   667 
       
   668 // ---------------------------------------------------------------------------
       
   669 // T_XIMPTestConnection::DoUpdatePresentityPresenceSubscriptionL
       
   670 // ---------------------------------------------------------------------------
       
   671 //
       
   672 void T_XIMPTestConnection::DoUpdatePresentityPresenceSubscriptionPifL(
       
   673                                     const MXIMPIdentity& aIdentity,
       
   674                                     const MPresenceInfoFilter& aPif,
       
   675                                     TXIMPRequestId aReqId )
       
   676     {
       
   677     PluginAPIMethodCommonL( aReqId );
       
   678 
       
   679     // prepare the message for test code
       
   680     SetBooleanToCurrent( EXIMPPlgTestUpdatePresentityPresesenceCalled );
       
   681     // TODO when implemented, read the data given by test case and
       
   682     //      generate the required events
       
   683     iWaitter->WaitForL( KWaitTime );
       
   684     }
       
   685 
       
   686 // ---------------------------------------------------------------------------
       
   687 // T_XIMPTestConnection::DoUnsubscribePresentityPresenceL
       
   688 // ---------------------------------------------------------------------------
       
   689 //
       
   690 void T_XIMPTestConnection::DoUnsubscribePresentityPresenceL(
       
   691                                         const MXIMPIdentity& aIdentity,
       
   692                                         TXIMPRequestId aReqId )
       
   693     {
       
   694     PluginAPIMethodCommonL( aReqId );
       
   695 
       
   696     // prepare the message for test code
       
   697     SetBooleanToCurrent( EXIMPPlgTestUnsubscribePresentityPresesenceCalled );
       
   698     // TODO when implemented, read the data given by test case and
       
   699     //      generate the required events
       
   700     iWaitter->WaitForL( KWaitTime );
       
   701     }
       
   702 
       
   703 
       
   704 // ---------------------------------------------------------------------------
       
   705 // T_XIMPTestConnection::DoSubscribePresentityGroupMembersPresenceL
       
   706 // ---------------------------------------------------------------------------
       
   707 //
       
   708 void T_XIMPTestConnection::DoSubscribePresentityGroupMembersPresenceL(
       
   709                                     const MXIMPIdentity& aIdentity,
       
   710                                     const MPresenceInfoFilter& aPif,
       
   711                                     TXIMPRequestId aReqId )
       
   712     {
       
   713     PluginAPIMethodCommonL( aReqId );
       
   714 
       
   715     // prepare the message for test code
       
   716     SetBooleanToCurrent( EXIMPPlgTestSubscribePresentityGroupMembersPresesenceCalled );
       
   717     // TODO when implemented, read the data given by test case and
       
   718     //      generate the required events
       
   719     iWaitter->WaitForL( KWaitTime );
       
   720     }
       
   721 
       
   722 // ---------------------------------------------------------------------------
       
   723 // T_XIMPTestConnection::DoUpdatePresentityPresenceSubscriptionL
       
   724 // ---------------------------------------------------------------------------
       
   725 //
       
   726 void T_XIMPTestConnection::DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
       
   727                                     const MXIMPIdentity& aIdentity,
       
   728                                     const MPresenceInfoFilter& aPif,
       
   729                                     TXIMPRequestId aReqId )
       
   730     {
       
   731     PluginAPIMethodCommonL( aReqId );
       
   732 
       
   733     // prepare the message for test code
       
   734     SetBooleanToCurrent( EXIMPPlgTestUpdatePresentityGroupMembersPresesenceCalled );
       
   735     // TODO when implemented, read the data given by test case and
       
   736     //      generate the required events
       
   737     iWaitter->WaitForL( KWaitTime );
       
   738     }
       
   739 
       
   740 // ---------------------------------------------------------------------------
       
   741 // T_XIMPTestConnection::DoUnsubscribePresentityPresenceL
       
   742 // ---------------------------------------------------------------------------
       
   743 //
       
   744 void T_XIMPTestConnection::DoUnsubscribePresentityGroupMembersPresenceL(
       
   745                                         const MXIMPIdentity& aIdentity,
       
   746                                         TXIMPRequestId aReqId )
       
   747     {
       
   748     PluginAPIMethodCommonL( aReqId );
       
   749 
       
   750     // prepare the message for test code
       
   751     SetBooleanToCurrent( EXIMPPlgTestUnsubscribePresentityGroupMembersPresesenceCalled );
       
   752     // TODO when implemented, read the data given by test case and
       
   753     //      generate the required events
       
   754     iWaitter->WaitForL( KWaitTime );
       
   755     }
       
   756 
       
   757 
       
   758 
       
   759 // ---------------------------------------------------------------------------
       
   760 // From MPscPlugin class.
       
   761 // T_XIMPTestConnection::DoSubscribePresentityGroupContentL
       
   762 // ---------------------------------------------------------------------------
       
   763 //
       
   764 void T_XIMPTestConnection::DoSubscribePresentityGroupContentL(
       
   765                                             const MXIMPIdentity& aGroupId,
       
   766                                             TXIMPRequestId aReqId )
       
   767     {
       
   768     PluginAPIMethodCommonL( aReqId );
       
   769 
       
   770     // prepare the message for test code
       
   771     SetBooleanToCurrent( EXIMPPlgTestSubscribePresentityGroupContentCalled );
       
   772     // TODO when implemented, read the data given by test case and
       
   773     //      generate the required events
       
   774     iWaitter->WaitForL( KWaitTime );
       
   775     }
       
   776 
       
   777 // ---------------------------------------------------------------------------
       
   778 // From MPscPlugin class.
       
   779 // T_XIMPTestConnection::DoUnsubscribePresentityGroupContentL
       
   780 // ---------------------------------------------------------------------------
       
   781 //
       
   782 void T_XIMPTestConnection::DoUnsubscribePresentityGroupContentL(
       
   783                                             const MXIMPIdentity& aGroupId,
       
   784                                             TXIMPRequestId aReqId )
       
   785     {
       
   786     PluginAPIMethodCommonL( aReqId );
       
   787     // prepare the message for test code
       
   788     SetBooleanToCurrent( EXIMPPlgTestUnsubscribePresentityGroupContentCalled );
       
   789     // TODO when implemented, read the data given by test case and
       
   790     //      generate the required events
       
   791     iWaitter->WaitForL( KWaitTime );
       
   792 
       
   793     }
       
   794 
       
   795 // ---------------------------------------------------------------------------
       
   796 // From MPscPlugin class.
       
   797 // T_XIMPTestConnection::DoAddPresentityGroupMemberL
       
   798 // ---------------------------------------------------------------------------
       
   799 //
       
   800 void T_XIMPTestConnection::DoAddPresentityGroupMemberL(
       
   801                                             const MXIMPIdentity& aGroupId,
       
   802                                             const MXIMPIdentity& aMemberId,
       
   803                                             const TDesC16& aMemberDisplayName,
       
   804                                             TXIMPRequestId aReqId )
       
   805     {
       
   806         /*
       
   807         //Req complete parameter template
       
   808         {
       
   809         MXIMPRestrictedObjectCollection* collection =
       
   810             iConnectionHost->ObjectFactory().NewRestrictedObjectCollectionLC();
       
   811 
       
   812         MXIMPIdentity* identityClone = iConnectionHost->ObjectFactory().NewIdentityLC();
       
   813         identityClone->SetIdentityL( aMemberId.Identity() );
       
   814 
       
   815         MPresentityGroupMemberInfo* grpMember =
       
   816         iConnectionHost->ObjectFactory().NewPresentityGroupMemberInfoLC( *identityClone,
       
   817                                                                          _L("AlteredDisplayname") );
       
   818         CleanupStack::Pop(); //grpMember
       
   819         CleanupStack::PopAndDestroy(); //identityClone
       
   820 
       
   821         CleanupDeletePushL( grpMember );
       
   822         collection->AddOrReplaceTypeL( grpMember );
       
   823         CleanupStack::Pop(); //grpMember
       
   824 
       
   825         delete iReqCompleteParams;
       
   826         iReqCompleteParams = NULL;
       
   827         iReqCompleteParams = collection;
       
   828 
       
   829         CleanupStack::Pop(); //collection
       
   830         }
       
   831         */
       
   832 
       
   833     PluginAPIMethodCommonL( aReqId );
       
   834 
       
   835     // prepare the message for test code
       
   836     SetBooleanToCurrent( EXIMPPlgTestAddPresentityGroupMemberCalled );
       
   837     // TODO when implemented, read the data given by test case and
       
   838     //      generate the required events
       
   839     iWaitter->WaitForL( KWaitTime );
       
   840     }
       
   841 
       
   842 // ---------------------------------------------------------------------------
       
   843 // From MPscPlugin class.
       
   844 // T_XIMPTestConnection::DoRemovePresentityGroupMemberL
       
   845 // ---------------------------------------------------------------------------
       
   846 //
       
   847 void T_XIMPTestConnection::DoRemovePresentityGroupMemberL(
       
   848                                             const MXIMPIdentity& aGroupId,
       
   849                                             const MXIMPIdentity& aMemberId,
       
   850                                             TXIMPRequestId aReqId )
       
   851     {
       
   852     PluginAPIMethodCommonL( aReqId );
       
   853 
       
   854     // prepare the message for test code
       
   855     SetBooleanToCurrent( EXIMPPlgTestRemovePresentityGroupMemberCalled );
       
   856     // TODO when implemented, read the data given by test case and
       
   857     //      generate the required events
       
   858     iWaitter->WaitForL( KWaitTime );
       
   859     }
       
   860 
       
   861 // ---------------------------------------------------------------------------
       
   862 // From MPscPlugin class.
       
   863 // T_XIMPTestConnection::DoUpdatePresentityGroupMemberDisplayNameL
       
   864 // ---------------------------------------------------------------------------
       
   865 //
       
   866 void T_XIMPTestConnection::DoUpdatePresentityGroupMemberDisplayNameL(
       
   867                                             const MXIMPIdentity& aGroupId,
       
   868                                             const MXIMPIdentity& aMemberId,
       
   869                                             const TDesC16& aMemberDisplayName,
       
   870                                             TXIMPRequestId aReqId )
       
   871     {
       
   872     PluginAPIMethodCommonL( aReqId );
       
   873 
       
   874     // prepare the message for test code
       
   875     SetBooleanToCurrent( EXIMPPlgTestUpdatePresentityGroupMemberDisplayNameCalled );
       
   876     // TODO when implemented, read the data given by test case and
       
   877     //      generate the required events
       
   878     iWaitter->WaitForL( KWaitTime );
       
   879     }
       
   880 
       
   881 
       
   882 // ---------------------------------------------------------------------------
       
   883 // From MPscPlugin class.
       
   884 // T_XIMPTestConnection::DoSubscribePresenceGrantRequestListL
       
   885 // ---------------------------------------------------------------------------
       
   886 //
       
   887 void T_XIMPTestConnection::DoSubscribePresenceGrantRequestListL( TXIMPRequestId aReqId )
       
   888     {
       
   889     PluginAPIMethodCommonL( aReqId );
       
   890 
       
   891     SetBooleanToCurrent( EXIMPPlgTestSubscribePresenceGrantRequestListCalled );
       
   892 
       
   893     // TODO do something, like in PublishPresence
       
   894 
       
   895     iWaitter->WaitForL( KWaitTime );
       
   896     }
       
   897 
       
   898 // ---------------------------------------------------------------------------
       
   899 // From MPscPlugin class.
       
   900 // T_XIMPTestConnection::DoUnsubscribePresenceGrantRequestListL
       
   901 // ---------------------------------------------------------------------------
       
   902 //
       
   903 void T_XIMPTestConnection::DoUnsubscribePresenceGrantRequestListL( TXIMPRequestId aReqId )
       
   904     {
       
   905     PluginAPIMethodCommonL( aReqId );
       
   906 
       
   907     SetBooleanToCurrent( EXIMPPlgTestUnsubscribePresenceGrantRequestListCalled );
       
   908 
       
   909     // TODO do something, like in PublishPresence
       
   910 
       
   911     iWaitter->WaitForL( KWaitTime );
       
   912     }
       
   913 
       
   914 
       
   915 void T_XIMPTestConnection::DoGrantPresenceForPresentityL( const MXIMPIdentity& aIdentity,
       
   916                                            const MPresenceInfoFilter& aPif,
       
   917                                            TXIMPRequestId aReqId )
       
   918     {
       
   919     PluginAPIMethodCommonL( aReqId );
       
   920 
       
   921     SetBooleanToCurrent( EXIMPPlgTestGrantPresenceForPresentityCalled );
       
   922 
       
   923     // TODO do something, like in PublishPresence
       
   924 
       
   925     iWaitter->WaitForL( KWaitTime );
       
   926 
       
   927     }
       
   928 void T_XIMPTestConnection::DoGrantPresenceForPresentityGroupMembersL( const MXIMPIdentity& aGroupId,
       
   929                                                         const MPresenceInfoFilter& aPif,
       
   930                                                         TXIMPRequestId aReqId )
       
   931     {
       
   932     PluginAPIMethodCommonL( aReqId );
       
   933 
       
   934     SetBooleanToCurrent( EXIMPPlgTestGrantPresenceForPresentityGroupMembersCalled );
       
   935 
       
   936     // TODO do something, like in PublishPresence
       
   937 
       
   938     iWaitter->WaitForL( KWaitTime );
       
   939 
       
   940     }
       
   941 
       
   942 void T_XIMPTestConnection::DoGrantPresenceForEveryoneL( const MPresenceInfoFilter& aPif,
       
   943                                                         TXIMPRequestId aReqId )
       
   944     {
       
   945     PluginAPIMethodCommonL( aReqId );
       
   946 
       
   947     SetBooleanToCurrent( EXIMPPlgTestGrantPresenceForEveryoneCalled );
       
   948 
       
   949     // TODO do something, like in PublishPresence
       
   950 
       
   951     iWaitter->WaitForL( KWaitTime );
       
   952 
       
   953     }
       
   954 
       
   955 
       
   956 void T_XIMPTestConnection::DoUpdatePresenceGrantPifForPresentityL( const MXIMPIdentity& aIdentity,
       
   957                                            const MPresenceInfoFilter& aPif,
       
   958                                            TXIMPRequestId aReqId )
       
   959     {
       
   960     PluginAPIMethodCommonL( aReqId );
       
   961 
       
   962     SetBooleanToCurrent( EXIMPPlgTestUpdateGrantPresenceForPresentityCalled );
       
   963 
       
   964     // TODO do something, like in PublishPresence
       
   965 
       
   966     iWaitter->WaitForL( KWaitTime );
       
   967 
       
   968     }
       
   969 
       
   970 void T_XIMPTestConnection::DoUpdatePresenceGrantPifForPresentityGroupMembersL( const MXIMPIdentity& aGroupId,
       
   971                                                         const MPresenceInfoFilter& aPif,
       
   972                                                         TXIMPRequestId aReqId )
       
   973     {
       
   974     PluginAPIMethodCommonL( aReqId );
       
   975 
       
   976     SetBooleanToCurrent( EXIMPPlgTestUpdateGrantPresenceForPresentityGroupMembersCalled );
       
   977 
       
   978     // TODO do something, like in PublishPresence
       
   979 
       
   980     iWaitter->WaitForL( KWaitTime );
       
   981 
       
   982     }
       
   983 
       
   984 void T_XIMPTestConnection::DoUpdatePresenceGrantPifForEveryoneL( const MPresenceInfoFilter& aPif,
       
   985                                                                  TXIMPRequestId aReqId )
       
   986     {
       
   987     PluginAPIMethodCommonL( aReqId );
       
   988 
       
   989     SetBooleanToCurrent( EXIMPPlgTestUpdateGrantPresenceForEveryoneCalled );
       
   990 
       
   991     // TODO do something, like in PublishPresence
       
   992 
       
   993     iWaitter->WaitForL( KWaitTime );
       
   994 
       
   995     }
       
   996 
       
   997 
       
   998 void T_XIMPTestConnection::DoWithdrawPresenceGrantFromPresentityL( const MXIMPIdentity& aIdentity, TXIMPRequestId aReqId )
       
   999     {
       
  1000     PluginAPIMethodCommonL( aReqId );
       
  1001 
       
  1002     SetBooleanToCurrent( EXIMPPlgTestWithdrawPresenceFromPresentityCalled );
       
  1003 
       
  1004     // TODO do something, like in PublishPresence
       
  1005 
       
  1006     iWaitter->WaitForL( KWaitTime );
       
  1007 
       
  1008     }
       
  1009 
       
  1010 void T_XIMPTestConnection::DoWithdrawPresenceGrantFromEveryoneL( TXIMPRequestId aReqId )
       
  1011     {
       
  1012     PluginAPIMethodCommonL( aReqId );
       
  1013 
       
  1014     SetBooleanToCurrent( EXIMPPlgTestWithdrawPresenceFromEveryoneCalled );
       
  1015 
       
  1016     // TODO do something, like in PublishPresence
       
  1017 
       
  1018     iWaitter->WaitForL( KWaitTime );
       
  1019 
       
  1020     }
       
  1021 
       
  1022 void T_XIMPTestConnection::DoWithdrawPresenceGrantFromPresentityGroupMembersL( const MXIMPIdentity& aGroupId,
       
  1023                                                             TXIMPRequestId aReqId )
       
  1024     {
       
  1025     PluginAPIMethodCommonL( aReqId );
       
  1026 
       
  1027     SetBooleanToCurrent( EXIMPPlgTestWithdrawPresenceFromPresentityGroupMembersCalled );
       
  1028 
       
  1029     // TODO do something, like in PublishPresence
       
  1030 
       
  1031     iWaitter->WaitForL( KWaitTime );
       
  1032 
       
  1033     }
       
  1034 
       
  1035 void T_XIMPTestConnection::DoSubscribePresenceBlockListL( TXIMPRequestId aReqId )
       
  1036     {
       
  1037     PluginAPIMethodCommonL( aReqId );
       
  1038 
       
  1039     SetBooleanToCurrent( EXIMPPlgTestSubscribePresenceBlockListCalled );
       
  1040 
       
  1041     // TODO do something, like in PublishPresence
       
  1042 
       
  1043     iWaitter->WaitForL( KWaitTime );
       
  1044 
       
  1045     }
       
  1046 
       
  1047 void T_XIMPTestConnection::DoUnsubscribePresenceBlockListL( TXIMPRequestId aReqId )
       
  1048     {
       
  1049     PluginAPIMethodCommonL( aReqId );
       
  1050 
       
  1051     SetBooleanToCurrent( EXIMPPlgTestUnsubscribePresenceBlockListCalled );
       
  1052 
       
  1053     // TODO do something, like in PublishPresence
       
  1054 
       
  1055     iWaitter->WaitForL( KWaitTime );
       
  1056 
       
  1057     }
       
  1058 void T_XIMPTestConnection::DoBlockPresenceForPresentityL( const MXIMPIdentity& aPresentityId,
       
  1059                                     TXIMPRequestId aReqId )
       
  1060     {
       
  1061     PluginAPIMethodCommonL( aReqId );
       
  1062 
       
  1063     SetBooleanToCurrent( EXIMPPlgTestBlockPresenceForPresentityCalled );
       
  1064 
       
  1065     // TODO do something, like in PublishPresence
       
  1066 
       
  1067     iWaitter->WaitForL( KWaitTime );
       
  1068 
       
  1069     }
       
  1070 void T_XIMPTestConnection::DoCancelPresenceBlockFromPresentityL( const MXIMPIdentity& aPresentityId,
       
  1071                                            TXIMPRequestId aReqId )
       
  1072     {
       
  1073     PluginAPIMethodCommonL( aReqId );
       
  1074 
       
  1075     SetBooleanToCurrent( EXIMPPlgTestCancelPresenceBlockFromPresentityCalled );
       
  1076 
       
  1077     // TODO do something, like in PublishPresence
       
  1078 
       
  1079     iWaitter->WaitForL( KWaitTime );
       
  1080 
       
  1081     }
       
  1082 
       
  1083 
       
  1084 
       
  1085 // ---------------------------------------------------------------------------
       
  1086 // T_XIMPTestConnection::PluginAPIMethodCommonL
       
  1087 // ---------------------------------------------------------------------------
       
  1088 //
       
  1089 void T_XIMPTestConnection::PluginAPIMethodCommonL( TXIMPRequestId& aOpId )
       
  1090     {
       
  1091     iReqId = aOpId;
       
  1092 
       
  1093     TInt index = CXIMPTestMessenger::GetPluginIndex();
       
  1094     TInt count = iClients.Count();
       
  1095     for( TInt a = 0; a < count; ++a )
       
  1096         {
       
  1097         if( iClients[ a ]->iPluginIndex == index )
       
  1098             {
       
  1099             iCurrentMessenger = iClients[ a ]->iMessenger;
       
  1100             }
       
  1101         }
       
  1102     iCurrentMessenger->HandleLeaveL();
       
  1103     // handle other errors here
       
  1104     if ( iCurrentMessenger->GetBoolean( EXIMPTestPlgBehaveInvalidReqId ) )
       
  1105         {
       
  1106         // arbitrarily mangle the given request id
       
  1107         TXIMPRequestIdBuilder idBuilder;
       
  1108         idBuilder.SetProtocolId( 123 );
       
  1109         idBuilder.SetSessionId( 456 );
       
  1110         idBuilder.SetRequestId( 789 );
       
  1111         //iReqId = TXIMPRequestId( 123, 456, 789 );
       
  1112         iReqId = idBuilder.BuildRequestId();
       
  1113         }
       
  1114     }
       
  1115 
       
  1116 // ---------------------------------------------------------------------------
       
  1117 // T_XIMPTestConnection::WaitCompleted()
       
  1118 // ---------------------------------------------------------------------------
       
  1119 //
       
  1120 void T_XIMPTestConnection::WaitCompleted( TInt /* aRetVal */ )
       
  1121     {
       
  1122     TInt errorCode = iCurrentMessenger->GetError();
       
  1123 
       
  1124 /*
       
  1125     if ( iSessionLostFailReconnects )
       
  1126         {
       
  1127         // fail all reconnects
       
  1128         errorCode = KErrTimedOut;
       
  1129         iConnectedClients = 0;
       
  1130         }
       
  1131 */
       
  1132     MXIMPStatus* status = iConnectionHost->ObjectFactory().NewStatusLC();
       
  1133     CleanupStack::Pop(); // status.
       
  1134     status->SetResultCode( errorCode );
       
  1135 
       
  1136     MXIMPRestrictedObjectCollection* reqCompleteParams = iCurrentMessenger->GetReqCompleteParams();
       
  1137 
       
  1138     if( reqCompleteParams )
       
  1139         {
       
  1140         iConnectionHost->HandleRequestCompleted( iReqId, status, reqCompleteParams );
       
  1141         reqCompleteParams = NULL;
       
  1142         }
       
  1143     else
       
  1144         {
       
  1145         iConnectionHost->HandleRequestCompleted( iReqId, status );
       
  1146         }
       
  1147 
       
  1148     if ( iSessionLostFailReconnects )
       
  1149         {
       
  1150         // doing a sequence of failing reconnects
       
  1151         return;
       
  1152         }
       
  1153 
       
  1154     // check if test code wants us to fake session lost
       
  1155     TInt val = iCurrentMessenger->GetValueFor( EXIMPTestPlgSessionLostStrategy );
       
  1156 
       
  1157     if ( val != EXIMPPrtValSessionLostEmpty )
       
  1158         {
       
  1159         // yep, fake session lost
       
  1160 
       
  1161         // reset the old value! otherwise timer will restart upon next operation.
       
  1162         iCurrentMessenger->SetValueFor( EXIMPTestPlgSessionLostStrategy, EXIMPPrtValSessionLostEmpty );
       
  1163 
       
  1164         iSessionLostReconnect = val == EXIMPPrtValSessionLostReconnect;
       
  1165         iSessionLostFailReconnects = val == EXIMPPrtValSessionLostReconnectExhaustAttempts;
       
  1166 
       
  1167         // start another wait (5 sec) with callback.
       
  1168         TInt time = 1000000 * 5;
       
  1169         TCallBack callback( ReconnectSimulator, this );
       
  1170         iAuxTimer->Start( time, time, callback );
       
  1171         }
       
  1172 
       
  1173     delete iClientToBeDeleted;
       
  1174     iClientToBeDeleted = NULL;
       
  1175     
       
  1176     }
       
  1177 
       
  1178 // ---------------------------------------------------------------------------
       
  1179 // RECONNECTION SIMULATOR ROUTINES
       
  1180 // ---------------------------------------------------------------------------
       
  1181 //
       
  1182 TInt T_XIMPTestConnection::ReconnectSimulator( TAny* aMyself )
       
  1183     {
       
  1184 //    (static_cast<T_XIMPTestConnection*>(aMyself))->DoReconnectSimulator();
       
  1185     return 0; // ignored by CPeriodic
       
  1186     }
       
  1187 
       
  1188 void T_XIMPTestConnection::DoReconnectSimulator()
       
  1189     {
       
  1190 /*    TRAPD( err, DoReconnectSimulatorL() );
       
  1191     if ( err != KErrNone )
       
  1192         {
       
  1193         // TODO what to do? is this enough to fail testcode
       
  1194         User::Panic( _L("XIMPTestPrt"), 424242 );
       
  1195         }
       
  1196         */
       
  1197     }
       
  1198 
       
  1199 void T_XIMPTestConnection::DoReconnectSimulatorL()
       
  1200     {
       
  1201     iAuxTimer->Cancel();    // must stop it from running again
       
  1202 /*
       
  1203     // connection dies.
       
  1204     iConnectedClients = 0;
       
  1205 
       
  1206     if ( iSessionLostReconnect || iSessionLostFailReconnects )
       
  1207         {
       
  1208         // tell host to try to reconnect
       
  1209         iConnectionHost->HandleConnectionLost( iStatus );
       
  1210         }
       
  1211     else
       
  1212         {
       
  1213         // tell host to kill connection
       
  1214         iConnectionHost->HandleConnectionTerminated( iStatus );
       
  1215         }
       
  1216 */
       
  1217     }
       
  1218 
       
  1219 void T_XIMPTestConnection::SetBooleanToCurrent( TXIMPTestPropertyKeys aKey )
       
  1220     {
       
  1221     if( iCurrentMessenger )
       
  1222         {
       
  1223         iCurrentMessenger->SetBoolean( aKey );
       
  1224         }
       
  1225     }
       
  1226 
       
  1227 void T_XIMPTestConnection::SetBoolean( TXIMPTestPropertyKeys aKey )
       
  1228     {
       
  1229     TInt count = iClients.Count();
       
  1230     for( TInt a = 0; a < count ; ++a )
       
  1231         {
       
  1232         iClients[ a ]->iMessenger->SetBoolean( aKey );
       
  1233         }
       
  1234     }
       
  1235 
       
  1236 // ---------------------------------------------------------------------------
       
  1237 // T_XIMPTestConnection::GetInterface()
       
  1238 // ---------------------------------------------------------------------------
       
  1239 //
       
  1240 TAny* T_XIMPTestConnection::GetInterface(
       
  1241         TInt32 aInterfaceId,
       
  1242         TIfGetOps /* aOptions */ )
       
  1243     {
       
  1244     if ( aInterfaceId == MXIMPProtocolConnection::KInterfaceId )
       
  1245         {
       
  1246         // caller wants this interface
       
  1247         MXIMPProtocolConnection* myIf = this;
       
  1248         return myIf;
       
  1249         }
       
  1250     else if( aInterfaceId == MProtocolPresencePublishing::KInterfaceId )
       
  1251         {
       
  1252         // caller wants this interface
       
  1253         MProtocolPresencePublishing* myIf = this;
       
  1254         return myIf;
       
  1255         }
       
  1256     else if( aInterfaceId == MProtocolPresenceWatching::KInterfaceId )
       
  1257         {
       
  1258         // caller wants this interface
       
  1259         MProtocolPresenceWatching* myIf = this;
       
  1260         return myIf;
       
  1261         }
       
  1262     else if( aInterfaceId == MProtocolPresenceAuthorization::KInterfaceId )
       
  1263         {
       
  1264         // caller wants this interface
       
  1265         MProtocolPresenceAuthorization* myIf = this;
       
  1266         return myIf;
       
  1267         }
       
  1268     else if( aInterfaceId == MProtocolPresentityGroups::KInterfaceId )
       
  1269         {
       
  1270         // caller wants this interface
       
  1271         MProtocolPresentityGroups* myIf = this;
       
  1272         return myIf;
       
  1273         }
       
  1274     else if( aInterfaceId == T_XIMPTestConnection::KClassId )
       
  1275         {
       
  1276         return this;
       
  1277         }
       
  1278     else
       
  1279         {
       
  1280         return NULL;
       
  1281         }
       
  1282     }
       
  1283 
       
  1284 // ---------------------------------------------------------------------------
       
  1285 // T_XIMPTestConnection::GetInterface()
       
  1286 // ---------------------------------------------------------------------------
       
  1287 //
       
  1288 const TAny* T_XIMPTestConnection::GetInterface(
       
  1289         TInt32 aInterfaceId,
       
  1290         TIfGetOps /* aOptions */ ) const
       
  1291     {
       
  1292     if ( aInterfaceId == MXIMPProtocolConnection::KInterfaceId )
       
  1293         {
       
  1294         // caller wants this interface
       
  1295         const MXIMPProtocolConnection* myIf = this;
       
  1296         return myIf;
       
  1297         }
       
  1298     else if( aInterfaceId == MProtocolPresencePublishing::KInterfaceId )
       
  1299         {
       
  1300         // caller wants this interface
       
  1301         const MProtocolPresencePublishing* myIf = this;
       
  1302         return myIf;
       
  1303         }
       
  1304     else if( aInterfaceId == MProtocolPresenceWatching::KInterfaceId )
       
  1305         {
       
  1306         // caller wants this interface
       
  1307         const MProtocolPresenceWatching* myIf = this;
       
  1308         return myIf;
       
  1309         }
       
  1310     else if( aInterfaceId == MProtocolPresenceAuthorization::KInterfaceId )
       
  1311         {
       
  1312         // caller wants this interface
       
  1313         const MProtocolPresenceAuthorization* myIf = this;
       
  1314         return myIf;
       
  1315         }
       
  1316     else if( aInterfaceId == MProtocolPresentityGroups::KInterfaceId )
       
  1317         {
       
  1318         // caller wants this interface
       
  1319         const MProtocolPresentityGroups* myIf = this;
       
  1320         return myIf;
       
  1321         }
       
  1322     else if( aInterfaceId == T_XIMPTestConnection::KClassId )
       
  1323         {
       
  1324         return this;
       
  1325         }
       
  1326     else
       
  1327         {
       
  1328         return NULL;
       
  1329         }
       
  1330     }
       
  1331 
       
  1332 // ---------------------------------------------------------------------------
       
  1333 // T_XIMPTestConnection::GetInterfaceId()
       
  1334 // ---------------------------------------------------------------------------
       
  1335 //
       
  1336 TInt32 T_XIMPTestConnection::GetInterfaceId() const
       
  1337     {
       
  1338     return MXIMPProtocolConnection::KInterfaceId;
       
  1339     }
       
  1340 
       
  1341 
       
  1342 // ---------------------------------------------------------------------------
       
  1343 // Key value pair table to identify correct constructor
       
  1344 // function for the requested interface.
       
  1345 // ---------------------------------------------------------------------------
       
  1346 //
       
  1347 const TImplementationProxy ImplementationTable[] =
       
  1348     {
       
  1349     IMPLEMENTATION_PROXY_ENTRY( K_PRFW_TST_PROTOCOL_1_IMPLEMENTATION_UID,
       
  1350                                 T_XIMPTestProtocol::NewL )
       
  1351     };
       
  1352 
       
  1353 
       
  1354 // ---------------------------------------------------------------------------
       
  1355 // Exported function to return the implementation proxy table
       
  1356 // ---------------------------------------------------------------------------
       
  1357 //
       
  1358 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
  1359     {
       
  1360     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
  1361     return ImplementationTable;
       
  1362     }
       
  1363 
       
  1364 // ---------------------------------------------------------------------------
       
  1365 // T_XIMPTestProtocol::T_XIMPTestProtocol()
       
  1366 // ---------------------------------------------------------------------------
       
  1367 //
       
  1368 T_XIMPTestProtocol::T_XIMPTestProtocol()
       
  1369     {
       
  1370     }
       
  1371 
       
  1372 
       
  1373 // ---------------------------------------------------------------------------
       
  1374 // T_XIMPTestProtocol::ConstructL()
       
  1375 // ---------------------------------------------------------------------------
       
  1376 //
       
  1377 void T_XIMPTestProtocol::ConstructL()
       
  1378     {
       
  1379     }
       
  1380 
       
  1381 
       
  1382 // ---------------------------------------------------------------------------
       
  1383 // T_XIMPTestProtocol::NewLC()
       
  1384 // ---------------------------------------------------------------------------
       
  1385 //
       
  1386 T_XIMPTestProtocol* T_XIMPTestProtocol::NewLC()
       
  1387     {
       
  1388     T_XIMPTestProtocol* self = new( ELeave ) T_XIMPTestProtocol();
       
  1389     CleanupStack::PushL( self );
       
  1390     self->ConstructL();
       
  1391     return self;
       
  1392     }
       
  1393 
       
  1394 
       
  1395 // ---------------------------------------------------------------------------
       
  1396 // T_XIMPTestProtocol::NewL()
       
  1397 // ---------------------------------------------------------------------------
       
  1398 //
       
  1399 T_XIMPTestProtocol* T_XIMPTestProtocol::NewL()
       
  1400     {
       
  1401     T_XIMPTestProtocol* self = T_XIMPTestProtocol::NewLC();
       
  1402     CleanupStack::Pop( self );
       
  1403     return self;
       
  1404     }
       
  1405 
       
  1406 // ---------------------------------------------------------------------------
       
  1407 // T_XIMPTestProtocol::~T_XIMPTestProtocol()
       
  1408 // ---------------------------------------------------------------------------
       
  1409 //
       
  1410 T_XIMPTestProtocol::~T_XIMPTestProtocol()
       
  1411     {
       
  1412     iConnections.Close();
       
  1413     }
       
  1414 
       
  1415 // ---------------------------------------------------------------------------
       
  1416 // T_XIMPTestProtocol::PrimeHost()
       
  1417 // ---------------------------------------------------------------------------
       
  1418 //
       
  1419 void T_XIMPTestProtocol::PrimeHost( MXIMPProtocolPluginHost& aHost )
       
  1420     {
       
  1421     iHost = &aHost;
       
  1422     }
       
  1423 
       
  1424 // ---------------------------------------------------------------------------
       
  1425 // T_XIMPTestProtocol::AcquireConnectionL()
       
  1426 // ---------------------------------------------------------------------------
       
  1427 //
       
  1428 MXIMPProtocolConnection& T_XIMPTestProtocol::AcquireConnectionL(
       
  1429                                     const MXIMPServiceInfo& aServiceInfo,
       
  1430                                     const MXIMPContextClientInfo& aClientCtxInfo )
       
  1431     {
       
  1432     T_XIMPTestConnection* newConnection = T_XIMPTestConnection::NewLC( aServiceInfo, aClientCtxInfo );
       
  1433     TLinearOrder< T_XIMPTestConnection > order( T_XIMPTestConnection::OrderOfConnections );
       
  1434     TInt index = iConnections.FindInOrder( newConnection, order );
       
  1435     if( index != KErrNotFound )
       
  1436         {
       
  1437         User::LeaveIfError( index );
       
  1438         CleanupStack::PopAndDestroy(); // newConnection
       
  1439         newConnection = iConnections[ index ];
       
  1440         }
       
  1441     else
       
  1442         {
       
  1443         iConnections.InsertInOrderL( newConnection, order );
       
  1444         CleanupStack::Pop(); //newConnection
       
  1445         }
       
  1446     return *newConnection;
       
  1447     }
       
  1448 
       
  1449 // ---------------------------------------------------------------------------
       
  1450 // T_XIMPTestProtocol::ReleaseConnection()
       
  1451 // ---------------------------------------------------------------------------
       
  1452 //
       
  1453 void T_XIMPTestProtocol::ReleaseConnection( MXIMPProtocolConnection& aConnection )
       
  1454     {
       
  1455     TLinearOrder< T_XIMPTestConnection > order( T_XIMPTestConnection::OrderOfConnections );
       
  1456     T_XIMPTestConnection* connection = ( T_XIMPTestConnection* )( aConnection.GetInterface(
       
  1457                     T_XIMPTestConnection::KClassId,
       
  1458                     MXIMPBase::EPanicIfUnknown ) );
       
  1459     TInt index = iConnections.FindInOrder( connection, order );
       
  1460     if( index >= 0 )
       
  1461         {
       
  1462         iConnections.Remove( index );
       
  1463         }
       
  1464     delete connection;
       
  1465     }
       
  1466 
       
  1467 // ---------------------------------------------------------------------------
       
  1468 // T_XIMPTestProtocol::GetInterface()
       
  1469 // ---------------------------------------------------------------------------
       
  1470 //
       
  1471 TAny* T_XIMPTestProtocol::GetInterface(
       
  1472         TInt32 aInterfaceId,
       
  1473         TIfGetOps /* aOptions */ )
       
  1474     {
       
  1475     if ( aInterfaceId == MXIMPProtocolPlugin::KInterfaceId )
       
  1476         {
       
  1477         // caller wants this interface
       
  1478         MXIMPProtocolPlugin* myIf = this;
       
  1479         return myIf;
       
  1480         }
       
  1481     else
       
  1482         {
       
  1483         return NULL;
       
  1484         }
       
  1485     }
       
  1486 
       
  1487 // ---------------------------------------------------------------------------
       
  1488 // T_XIMPTestProtocol::GetInterface()
       
  1489 // ---------------------------------------------------------------------------
       
  1490 //
       
  1491 const TAny* T_XIMPTestProtocol::GetInterface(
       
  1492         TInt32 aInterfaceId,
       
  1493         TIfGetOps /* aOptions */ ) const
       
  1494     {
       
  1495     if ( aInterfaceId == MXIMPProtocolPlugin::KInterfaceId )
       
  1496         {
       
  1497         // caller wants this interface
       
  1498         const MXIMPProtocolPlugin* myIf = this;
       
  1499         return myIf;
       
  1500         }
       
  1501     else
       
  1502         {
       
  1503         return NULL;
       
  1504         }
       
  1505     }
       
  1506 
       
  1507 // ---------------------------------------------------------------------------
       
  1508 // T_XIMPTestProtocol::GetInterfaceId()
       
  1509 // ---------------------------------------------------------------------------
       
  1510 //
       
  1511 TInt32 T_XIMPTestProtocol::GetInterfaceId() const
       
  1512     {
       
  1513     return MXIMPProtocolPlugin::KInterfaceId;
       
  1514     }
       
  1515 
       
  1516 
       
  1517 
       
  1518 // End of file
       
  1519