omaprovisioning/provisioning/ProvisioningHandler/Src/CWPMessage.cpp
branchRCL_3
changeset 76 3cdbd92ee07b
parent 65 5cc2995847ea
equal deleted inserted replaced
69:a082c848c9a9 76:3cdbd92ee07b
   152         {
   152         {
   153         iPhone = WPPhoneFactory::CreateL();
   153         iPhone = WPPhoneFactory::CreateL();
   154         }
   154         }
   155 
   155 
   156     FLOG( _L( "CWPMessage::ProcessL: Creating engine" ) );
   156     FLOG( _L( "CWPMessage::ProcessL: Creating engine" ) );
   157 		
   157 
   158 				
       
   159 	  TInt value( 0 );
       
   160     CRepository* rep = CRepository::NewLC( KOMAProvAuthenticationLV );	
       
   161     	
       
   162     TInt error = rep->Set(KOMAProvIsUserPin, value);              
       
   163     if(error != KErrNone)
       
   164     	{
       
   165         FLOG( _L( "CWPMessage::ProcessL: set KOMAProvIsUserPin Failed" ) );
       
   166       }
       
   167     
       
   168     error =  rep->Set(KOMAProvCriticalAdapterSettingCount, value);      
       
   169     if(error != KErrNone)
       
   170     	{
       
   171         FLOG( _L( "CWPMessage::ProcessL: set KOMAProvCriticalAdapterSettingCount Failed" ) );
       
   172       }
       
   173       
       
   174     CleanupStack::PopAndDestroy(); // rep
       
   175     	
       
   176     // Read the message into the engine
   158     // Read the message into the engine
   177     CWPEngine* engine = CWPEngine::NewLC(); // on CS
   159     CWPEngine* engine = CWPEngine::NewLC(); // on CS
   178 
   160 
   179     FLOG( _L( "CWPMessage::ProcessL: Importing document" ) );
   161     FLOG( _L( "CWPMessage::ProcessL: Importing document" ) );
   180     engine->ImportDocumentL( iMessage->Body() );
   162     engine->ImportDocumentL( iMessage->Body() );
   181 
   163 
   182     FLOG( _L( "CWPMessage::ProcessL: Populating adapters" ) );
   164     FLOG( _L( "CWPMessage::ProcessL: Populating adapters" ) );
   183    	
       
   184     engine->PopulateL();
   165     engine->PopulateL();
   185 
   166 
   186     FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Number of settings: (%d)"), engine->ItemCount()));
   167     FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Number of settings: (%d)"), engine->ItemCount()));
   187     // Check if the sender can be trusted
   168     // Check if the sender can be trusted
   188     TPtrC8 orig8( iMessage->Originator() );
   169     TPtrC8 orig8( iMessage->Originator() );
   197     
   178     
   198     // Try bootstrapping
   179     // Try bootstrapping
   199     FLOG( _L( "CWPMessage::ProcessL: Bootstrapping" ) );
   180     FLOG( _L( "CWPMessage::ProcessL: Bootstrapping" ) );
   200     CWPBootstrap* bootstrap = CWPBootstrap::NewL( iPhone->SubscriberId() );
   181     CWPBootstrap* bootstrap = CWPBootstrap::NewL( iPhone->SubscriberId() );
   201     CleanupStack::PushL( bootstrap );
   182     CleanupStack::PushL( bootstrap );
   202     	
   183 
   203     CWPBootstrap::TBootstrapResult result( 
   184     CWPBootstrap::TBootstrapResult result( 
   204         bootstrap->BootstrapL( *iMessage, *engine, KNullDesC ) );
   185         bootstrap->BootstrapL( *iMessage, *engine, KNullDesC ) );
   205     CleanupStack::PopAndDestroy(); // bootstrap
   186     CleanupStack::PopAndDestroy(); // bootstrap
   206 
   187 
   207     FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Bootstrap result: (%d)"), result));
   188     FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Bootstrap result: (%d)"), result));
   208         // See UI specs figure 1 
   189         // See UI specs figure 1 
   209         
       
   210 	TInt adapterCount( 0 );
       
   211 	TInt userPin(0);
       
   212 	TInt allowCriticalSetting(0);
       
   213 	
       
   214 	CRepository* repository = CRepository::NewLC( KOMAProvAuthenticationLV );
       
   215 	TInt getErr = repository->Get( KOMAProvCriticalAdapterSettingCount, adapterCount);
       
   216 	if(getErr != KErrNone)
       
   217     	{
       
   218         FLOG( _L( "CWPMessage::ProcessL: set KOMAProvCriticalAdapterSettingCount Failed" ) );
       
   219       }
       
   220       
       
   221   getErr = repository->Get( KOMAProvIsUserPin, userPin );  
       
   222 	if(getErr != KErrNone)
       
   223       { 
       
   224       FLOG( _L( "CWPMessage::PrepareEntryLC: set KOMAProvIsUserPin Failed" ) );
       
   225       }
       
   226   
       
   227   getErr = repository->Get( KOMAProvAllowCriticalAdapterSetting, allowCriticalSetting );  
       
   228 	if(getErr != KErrNone)
       
   229       { 
       
   230       FLOG( _L( "CWPMessage::PrepareEntryLC: set KOMAProvIsUserPin Failed" ) );
       
   231       }    
       
   232 	        
       
   233 	CleanupStack::PopAndDestroy(); // repository		
       
   234 		
       
   235 
       
   236 		    
       
   237     TBool haveSettings( engine->ItemCount() > 0 );
   190     TBool haveSettings( engine->ItemCount() > 0 );
   238     switch( result )
   191     switch( result )
   239         {
   192         {
   240         case CWPBootstrap::ENoBootstrap:
   193         case CWPBootstrap::ENoBootstrap:
   241             {
   194             {
   242             FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENoBootstrap" ) );
   195             FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENoBootstrap" ) );
   243             // If there's no bootstrap, just save the message
   196             // If there's no bootstrap, just save the message
   244             
   197             if( haveSettings )
   245             if( haveSettings)
   198                 {
   246                 {
   199                 StoreMsgL();
   247  	               	 if(allowCriticalSetting)
       
   248  	               	 	{
       
   249  	               	 		if(!userPin)
       
   250                 			{
       
   251                 		 	StoreMsgL();
       
   252                 			}
       
   253                 			else if(adapterCount != engine->ItemCount())
       
   254                 			{
       
   255                 			StoreMsgL();
       
   256                 			}
       
   257                 		}
       
   258                 		else
       
   259                 		{
       
   260                 			StoreMsgL();
       
   261                 		}	
       
   262                 }
   200                 }
   263             else
   201             else
   264                 {
   202                 {
   265                 User::Leave( KErrCorrupt );
   203                 User::Leave( KErrCorrupt );
   266                 }
   204                 }
   268             }
   206             }
   269 
   207 
   270         case CWPBootstrap::ENotAuthenticated:
   208         case CWPBootstrap::ENotAuthenticated:
   271             {
   209             {
   272             FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENotAuthenticated" ) );
   210             FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENotAuthenticated" ) );
   273             
   211             if( haveSettings )
   274             if(haveSettings)
   212                 {
   275             	{
   213                 StoreMsgL();
   276             		if(allowCriticalSetting)
   214                 }
   277             			{
       
   278             				if(adapterCount != engine->ItemCount())
       
   279             					{
       
   280             		       StoreMsgL();
       
   281                 			}
       
   282               		}
       
   283               		else
       
   284               		{ 
       
   285               		StoreMsgL();
       
   286               		}
       
   287               }
       
   288             else
   215             else
   289             {
   216             {
       
   217                 
   290             // Message is ignored and an information SMs is put to Inbox.
   218             // Message is ignored and an information SMs is put to Inbox.
   291             //Information SMs can be Class0,  based on operator requirement.
   219             //Information SMs can be Class0,  based on operator requirement.
   292             if(allowCriticalSetting)
   220             TInt auth_value;
   293             	{
   221             CRepository * rep = 0;
   294             		if(adapterCount != engine->ItemCount())
   222             TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV ));
   295             		{
   223             if(err == KErrNone)
   296             		TInt auth_value;
   224             {
   297             		CRepository * rep = 0;
   225             	rep->Get( KOMAProvAuthFailMsgHandling, auth_value );
   298             		TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV ));
   226             	delete rep;
   299             			if(err == KErrNone)
       
   300             			{
       
   301             			rep->Get( KOMAProvAuthFailMsgHandling, auth_value );
       
   302             			delete rep;
       
   303             	
   227             	
   304             			if(auth_value == 1)
   228             	if(auth_value == 1)
   305             			StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED);
   229             	StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED);
   306             			else
   230             	else
   307             			StoreMsgL(R_TEXT_AUTHENTICATION_FAILED);
   231             	StoreMsgL(R_TEXT_AUTHENTICATION_FAILED);
   308             	
   232             	
   309             			User::Leave( KErrAccessDenied ); 
   233             	User::Leave( KErrAccessDenied ); 
   310             			}
   234             }
   311             			else
   235             else
   312             			{
   236             {
   313             			StoreMsgL(R_TEXT_AUTHENTICATION_FAILED);
   237             StoreMsgL(R_TEXT_AUTHENTICATION_FAILED);
   314             			User::Leave( KErrAccessDenied );                         
   238             User::Leave( KErrAccessDenied );                         
   315             			}
   239             }
   316             		}
   240                 }
   317             	}
       
   318             	else
       
   319             	{
       
   320             	TInt auth_value;
       
   321             	CRepository * rep = 0;
       
   322             	TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV ));
       
   323             	if(err == KErrNone)
       
   324             	{
       
   325             		rep->Get( KOMAProvAuthFailMsgHandling, auth_value );
       
   326             		delete rep;
       
   327             	
       
   328             		if(auth_value == 1)
       
   329             		StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED);
       
   330             		else
       
   331             		StoreMsgL(R_TEXT_AUTHENTICATION_FAILED);
       
   332             	
       
   333             		User::Leave( KErrAccessDenied ); 
       
   334             	}
       
   335             	else
       
   336             	{
       
   337             		StoreMsgL(R_TEXT_AUTHENTICATION_FAILED);
       
   338             		User::Leave( KErrAccessDenied );                         
       
   339             	}
       
   340             }
       
   341               }
       
   342             break;
   241             break;
   343             }
   242             }
   344 
   243 
   345         case CWPBootstrap::EPinRequired:
   244         case CWPBootstrap::EPinRequired:
   346             {
   245             {
   347             FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EPinRequired" ) );
   246             FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EPinRequired" ) );
   348             
   247             
   349             // If PIN is required, defer authentication to ProvisioningBC
   248             // If PIN is required, defer authentication to ProvisioningBC
   350             if(haveSettings)
   249             if( haveSettings )
   351                 {
   250                 {
   352                 	if(allowCriticalSetting)
   251                 StoreMsgL();
   353                 		{             			
       
   354                 			if(!userPin)
       
   355                 			{
       
   356                 			StoreMsgL();
       
   357                 			}
       
   358                 			else if(adapterCount != engine->ItemCount())
       
   359                 			{
       
   360                 			StoreMsgL();	
       
   361                 			}
       
   362                 		}
       
   363                 		else
       
   364                 		{
       
   365                 		StoreMsgL();
       
   366                 		}                			
       
   367                 }
   252                 }
   368             else
   253             else
   369                 {              	            
   254                 {
   370                 User::Leave( KErrCorrupt );
   255                 User::Leave( KErrCorrupt );
   371                 }
   256                 }
   372             break;
   257             break;
   373             }
   258             }
   374 
   259 
   684     aEntry.iDate = time;
   569     aEntry.iDate = time;
   685     aEntry.iServiceId = KMsvLocalServiceIndexEntryId;
   570     aEntry.iServiceId = KMsvLocalServiceIndexEntryId;
   686     aEntry.iError = KErrNone;
   571     aEntry.iError = KErrNone;
   687     // iMtmData1 is been used/reserved for count, please don't use for any other purpose.
   572     // iMtmData1 is been used/reserved for count, please don't use for any other purpose.
   688     aEntry.SetMtmData1(3);
   573     aEntry.SetMtmData1(3);
   689     aEntry.SetMtmData2(0);   
       
   690 
       
   691     TInt userPin = 0;
       
   692 	  CRepository* repository = CRepository::NewLC( KOMAProvAuthenticationLV );
       
   693 	  TInt err = repository->Get( KOMAProvIsUserPin, userPin );
       
   694 	  if(err != KErrNone)
       
   695       { 
       
   696       FLOG( _L( "CWPMessage::PrepareEntryLC: set KOMAProvIsUserPin Failed" ) );
       
   697       }
       
   698 	  CleanupStack::PopAndDestroy(); // repository	
       
   699 		
       
   700 	  if(userPin == 1)
       
   701 	    {			
       
   702 	    aEntry.SetMtmData2(1);		
       
   703 	    }
       
   704 				
       
   705     FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) );
   574     FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) );
   706     // Look up the details
   575     // Look up the details
   707     HBufC* details = NULL;
   576     HBufC* details = NULL;
   708     if( iMessage->Authenticated() )
   577     if( iMessage->Authenticated() )
   709         {
   578         {