multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/CMCETestUIEngineOutRefer.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // MCE API
       
    22 
       
    23 #include <MCEManager.h>
       
    24 #include <MCEOutRefer.h>
       
    25 #include <MCERefer.h>
       
    26 #include <Uri8.h>
       
    27 
       
    28 #include "MCETestUIEngineDefaultValues.h"
       
    29 #include "CMCETestUIQuestionDataQuery.h"
       
    30 #include "CMCETestUIEngine.h"
       
    31 #include "CMCETestUIEngineProfileContainer.h"
       
    32 #include "CMCETestUIEngineProfile.h"
       
    33 #include "CMCETestUIEngineOutRefer.h"
       
    34 #include "TMCETestUIEngineCmdSubscribeEvent.h"
       
    35 #include "TMCETestUIEngineCmdDeleteEvent.h"
       
    36 #include "cmcetestuienginesession.h"
       
    37 #include "cmcetestuiengineevent.h"
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CMCETestUIEngineOutRefer::NewL()
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CMCETestUIEngineOutRefer* CMCETestUIEngineOutRefer::NewL(
       
    46             CMCETestUIEngine& aEngine,
       
    47             CMCETestUIEngineProfile& aProfile) 
       
    48     {
       
    49 
       
    50     CMCETestUIEngineOutRefer* self = 
       
    51         new (ELeave) CMCETestUIEngineOutRefer( aEngine, 
       
    52                                                  aProfile);
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL(aProfile);
       
    55     CleanupStack::Pop( self );
       
    56     return self;  
       
    57     }
       
    58 // -----------------------------------------------------------------------------
       
    59 // CMCETestUIEngineOutRefer::NewL()
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CMCETestUIEngineOutRefer* CMCETestUIEngineOutRefer::NewL(
       
    63             CMCETestUIEngine& aEngine,
       
    64             CMCETestUIEngineSession& aSession) 
       
    65     {
       
    66 
       
    67     CMCETestUIEngineOutRefer* self = 
       
    68         new (ELeave) CMCETestUIEngineOutRefer( aEngine, 
       
    69                                                  aSession);
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL(aSession);
       
    72     CleanupStack::Pop( self );
       
    73     return self;  
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CMCETestUIEngineOutRefer::NewL()
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CMCETestUIEngineOutRefer* CMCETestUIEngineOutRefer::NewL(
       
    81             CMCETestUIEngine& aEngine,
       
    82             CMCETestUIEngineEvent& aEvent) 
       
    83     {
       
    84 
       
    85     CMCETestUIEngineOutRefer* self = 
       
    86         new (ELeave) CMCETestUIEngineOutRefer( aEngine, 
       
    87                                                  aEvent);
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL(aEvent);
       
    90     CleanupStack::Pop( self );
       
    91     return self;  
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CMCETestUIEngineOutRefer::CMCETestUIEngineOutRefer
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 CMCETestUIEngineOutRefer::CMCETestUIEngineOutRefer( 
       
    99                 CMCETestUIEngine& aEngine,
       
   100                 CMCETestUIEngineProfile& aProfile )
       
   101     : CMCETestUIEngineRefer( aEngine ),
       
   102       iProfile( &aProfile ),
       
   103       iId( 0 )
       
   104     {
       
   105     }
       
   106 // -----------------------------------------------------------------------------
       
   107 // CMCETestUIEngineOutRefer::CMCETestUIEngineOutRefer
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 CMCETestUIEngineOutRefer::CMCETestUIEngineOutRefer( 
       
   111                 CMCETestUIEngine& aEngine,
       
   112                 CMCETestUIEngineSession& aSession )
       
   113     : CMCETestUIEngineRefer( aEngine ),
       
   114       iSession( &aSession ),
       
   115       iId( 0 )
       
   116     {
       
   117     }
       
   118 // -----------------------------------------------------------------------------
       
   119 // CMCETestUIEngineOutRefer::CMCETestUIEngineOutRefer
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 CMCETestUIEngineOutRefer::CMCETestUIEngineOutRefer( 
       
   123                 CMCETestUIEngine& aEngine,
       
   124                 CMCETestUIEngineEvent& aEvent )
       
   125     : CMCETestUIEngineRefer( aEngine ),
       
   126       iEvent( &aEvent ),
       
   127       iId( 0 )
       
   128     {
       
   129     }
       
   130 
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CMCETestUIEngineOutRefer::ConstructL()
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CMCETestUIEngineOutRefer::ConstructL(CMCETestUIEngineProfile& /*aProfile*/)
       
   137     {
       
   138  
       
   139      /////////////////////
       
   140     //
       
   141     // TODO: After implementing wrappers for streams, sinks and sources 
       
   142     //       this function should be refactored to make use of them. That will 
       
   143     //       also simplify the function to some extent.
       
   144     //
       
   145     //////////////////////
       
   146     
       
   147  
       
   148     BaseConstructL();
       
   149     if(iProfile )
       
   150     	{
       
   151     	FillProfileRegistrar();
       
   152     
       
   153     if(ReferParamsL(iReferParams))
       
   154     	{
       
   155     	// Solve recipient
       
   156 	    CMCETestUIQuestionDataQuery* question = 
       
   157 		    CMCETestUIQuestionDataQuery::NewLC();
       
   158 		question->SetCaptionL( KUserQuestionInputRecipient );
       
   159 		question->SetDefaultValueL(iReferParams.iRecipentAddress  );
       
   160 		question->SetAnswerL( iReferParams.iRecipentAddress  );
       
   161 		TBufC8<100> recipient( question->Answer8() );
       
   162 		
       
   163 		CleanupStack::PopAndDestroy( question );
       
   164 		//solve referTo
       
   165 		
       
   166 		CMCETestUIQuestionDataQuery* questionreferto = 
       
   167 		    CMCETestUIQuestionDataQuery::NewLC();
       
   168 		questionreferto->SetCaptionL( KUserQuestionInputReferTo );
       
   169 		questionreferto->SetDefaultValueL(iReferParams.iReferTo  );
       
   170 		questionreferto->SetAnswerL( iReferParams.iReferTo  );
       
   171 		TBufC8<100> referTo( questionreferto->Answer8() );
       
   172 		
       
   173 		CleanupStack::PopAndDestroy( questionreferto );
       
   174 	   // solve originator
       
   175 	   
       
   176 	   if ( iReferParams.originator.Compare(KNone))
       
   177 	   	{
       
   178 		   	HBufC8* orig8 = HBufC8::NewL(iReferParams.originator.Length());
       
   179 		   	TPtr8 ptr = orig8->Des();
       
   180 		    ptr.Copy(iReferParams.originator);
       
   181 		    // Create OutRfer
       
   182 		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
       
   183 		       	iEngine.MCEManager(), 
       
   184 			    iProfile->Profile(),
       
   185 			    recipient,referTo);
       
   186 			CleanupStack::PushL(outRefer);
       
   187 		    CleanupStack::Pop( outRefer );
       
   188 			iRefer = outRefer;
       
   189 			iOutRefer = outRefer;        
       
   190 	   	}
       
   191 	   else 
       
   192 	   	{
       
   193 		   	// Create OutEvent
       
   194 		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
       
   195 		       iEngine.MCEManager(),
       
   196 		       iProfile->Profile(),
       
   197 			   recipient,referTo );
       
   198 			CleanupStack::PushL(outRefer);
       
   199 		    CleanupStack::Pop( outRefer );
       
   200 			iRefer = outRefer;
       
   201 			iOutRefer = outRefer;
       
   202 	   	}
       
   203 	    // Get identity
       
   204 	    iId = iEngine.NextOutReferId();
       
   205     	}
       
   206     	}
       
   207     
       
   208     
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CMCETestUIEngineOutRefer::ConstructL(CMCETestUIEngineSession& aSession)
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CMCETestUIEngineOutRefer::ConstructL(CMCETestUIEngineSession& aSession)
       
   216     {
       
   217  
       
   218      /////////////////////
       
   219     //
       
   220     // TODO: After implementing wrappers for streams, sinks and sources 
       
   221     //       this function should be refactored to make use of them. That will 
       
   222     //       also simplify the function to some extent.
       
   223     //
       
   224     //////////////////////
       
   225     
       
   226  
       
   227     BaseConstructL();
       
   228     if(iSession )
       
   229     	{
       
   230         
       
   231     if(ReferToParamsL(iReferParams))
       
   232     	{
       
   233     
       
   234 		//solve referTo
       
   235 		
       
   236 		CMCETestUIQuestionDataQuery* questionreferto = 
       
   237 		    CMCETestUIQuestionDataQuery::NewLC();
       
   238 		questionreferto->SetCaptionL( KUserQuestionInputReferTo );
       
   239 		questionreferto->SetDefaultValueL(iReferParams.iReferTo  );
       
   240 		questionreferto->SetAnswerL( iReferParams.iReferTo  );
       
   241 		TBufC8<100> referTo( questionreferto->Answer8() );
       
   242 		
       
   243 		CleanupStack::PopAndDestroy( questionreferto );
       
   244 	   
       
   245 	   
       
   246 	    	// Create OutEvent
       
   247 		   CMceOutRefer* outRefer = CMceOutRefer::NewL(
       
   248 		       aSession.Session(),referTo );
       
   249 			iRefer = outRefer;
       
   250 			iOutRefer = outRefer;
       
   251 	       // Get identity
       
   252 	    iId = iEngine.NextOutReferId();
       
   253     	}
       
   254     	}
       
   255     
       
   256     
       
   257     }
       
   258 // -----------------------------------------------------------------------------
       
   259 // CMCETestUIEngineOutRefer::ConstructL()
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 void CMCETestUIEngineOutRefer::ConstructL(CMCETestUIEngineEvent& aEvent)
       
   263     {
       
   264  
       
   265      /////////////////////
       
   266     //
       
   267     // TODO: After implementing wrappers for streams, sinks and sources 
       
   268     //       this function should be refactored to make use of them. That will 
       
   269     //       also simplify the function to some extent.
       
   270     //
       
   271     //////////////////////
       
   272     
       
   273  
       
   274     BaseConstructL();
       
   275     if(iEvent )
       
   276     	{
       
   277         
       
   278     if(ReferParamsL(iReferParams))
       
   279     	{
       
   280     	//solve referTo
       
   281 		
       
   282 		CMCETestUIQuestionDataQuery* questionreferto = 
       
   283 		    CMCETestUIQuestionDataQuery::NewLC();
       
   284 		questionreferto->SetCaptionL( KUserQuestionInputReferTo );
       
   285 		questionreferto->SetDefaultValueL(iReferParams.iReferTo  );
       
   286 		questionreferto->SetAnswerL( iReferParams.iReferTo  );
       
   287 		TBufC8<100> referTo( questionreferto->Answer8() );
       
   288 		
       
   289 		CleanupStack::PopAndDestroy( questionreferto );
       
   290 	  // Create Outrefer
       
   291 		    CMceOutRefer* outRefer = CMceOutRefer::NewL(
       
   292 		       aEvent.Event(),referTo );
       
   293 			CleanupStack::PushL(outRefer);
       
   294 		    CleanupStack::Pop( outRefer );
       
   295 			iRefer = outRefer;
       
   296 			iOutRefer = outRefer;
       
   297 	    // Get identity
       
   298 	    iId = iEngine.NextOutReferId();
       
   299     	}
       
   300     	}
       
   301     
       
   302     
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CMCETestUIEngineOutRefer::~CMCETestUIEngineOutRefer
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 EXPORT_C CMCETestUIEngineOutRefer::~CMCETestUIEngineOutRefer()
       
   310     {
       
   311     delete iOutRefer;
       
   312     }
       
   313 
       
   314 // -----------------------------------------------------------------------------
       
   315 // CMCETestUIEngineOutRefer::GetCommands
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 const RPointerArray<TMCETestUIEngineCmdBase>& 
       
   319             CMCETestUIEngineOutRefer::GetCommandsL()
       
   320     {
       
   321     iCommands.ResetAndDestroy();
       
   322 
       
   323     // Get base class commands
       
   324     CMCETestUIEngineRefer::GetCommandsL();
       
   325         
       
   326     // Get own commands       
       
   327     TInt state = iOutRefer->State();
       
   328 
       
   329 	switch( state ) 
       
   330 		{
       
   331 		case CMceRefer::EIdle:
       
   332 			{
       
   333 			iCommands.Append( new (ELeave) 
       
   334 		        TMCETestUIEngineCmdRefer( iEngine, *this ) );	  
       
   335 		    break;
       
   336 			}
       
   337             
       
   338 		case CMceRefer::EAccepted: 	 
       
   339 			{
       
   340 			break;
       
   341 			}	  
       
   342 		    
       
   343 		case CMceRefer::EPending:  
       
   344 			{
       
   345 			break;   
       
   346 			}
       
   347 		default: 
       
   348 		    break;
       
   349 		}  
       
   350 		  
       
   351     return iCommands; 
       
   352     }
       
   353 
       
   354 // -----------------------------------------------------------------------------
       
   355 // CMCETestUIEngineOutRefer::Id
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 EXPORT_C TInt CMCETestUIEngineOutRefer::Id() const
       
   359     {
       
   360     return iId;
       
   361     }
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // CMCETestUIEngineOutRefer::OutSession
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 CMceOutRefer& CMCETestUIEngineOutRefer::OutRefer()
       
   368     {
       
   369     return *iOutRefer;
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CMCETestUIEngineOutRefer::ReferParams
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 
       
   377 TBool CMCETestUIEngineOutRefer::ReferParamsL(TReferParams &aReferParams)
       
   378 {
       
   379   return iEngine.ReferParamsL( aReferParams);
       
   380  
       
   381 }
       
   382 // -----------------------------------------------------------------------------
       
   383 // CMCETestUIEngineOutRefer::ReferToParams
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 
       
   387 TBool CMCETestUIEngineOutRefer::ReferToParamsL(TReferParams &aReferParams)
       
   388 {
       
   389   return iEngine.ReferToParamsL( aReferParams);
       
   390  
       
   391 }
       
   392 // -----------------------------------------------------------------------------
       
   393 // CMCETestUIEngineOutRefer::FillProfileRegistrar
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 
       
   397 void CMCETestUIEngineOutRefer::FillProfileRegistrar()
       
   398 	{
       
   399 	// trying to get profile registrar 
       
   400           
       
   401     TUriParser8 parser;
       
   402     const TDesC8& aor = iProfile->Aor();
       
   403     parser.Parse( aor ) ; 
       
   404     CUri8* uri8 = CUri8::NewLC( parser );
       
   405     const TDesC8& registrar =  uri8->Uri().Extract( EUriHost ) ;
       
   406     
       
   407     HBufC*registrar16 = HBufC16::NewLC( KRecipent().Length() + registrar.Length() );
       
   408     TPtr registrarPtr = registrar16->Des();
       
   409     registrarPtr.Copy( registrar );
       
   410     
       
   411     iReferParams.iRecipentAddress.Append(KRecipent) ;
       
   412     iReferParams.iRecipentAddress.Append(*registrar16)  ;
       
   413     
       
   414     iReferParams.iReferTo.Append(KRecipent) ;
       
   415     iReferParams.iReferTo.Append(*registrar16)  ;
       
   416     
       
   417     CleanupStack::PopAndDestroy( registrar16 );
       
   418     registrar16 = NULL;
       
   419     
       
   420     CleanupStack::PopAndDestroy( uri8 );
       
   421     uri8 = NULL; 
       
   422     // profile registrar end .....
       
   423 	}