terminalsecurity/SCP/SCPPatternPlugin/src/SCPPatternPlugin.cpp
branchRCL_3
changeset 26 19bba8228ff0
parent 25 b183ec05bd8c
child 27 5cc2995847ea
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
    22 #include <ecom/implementationproxy.h>
    22 #include <ecom/implementationproxy.h>
    23 #include <SCPParamObject.h>
    23 #include <SCPParamObject.h>
    24 #include <featmgr.h>
    24 #include <featmgr.h>
    25 
    25 
    26 #include "SCPPatternPlugin.h"
    26 #include "SCPPatternPlugin.h"
    27 #include <scppatternpluginlang.rsg>
    27 #include <SCPPatternPluginLang.rsg>
    28 #include "SCP_IDs.h"
    28 #include "SCP_IDs.h"
    29 #include <SCPServerInterface.h>
    29 
    30 
    30 
    31 
    31 
    32 
    32 
    33 // ============================= LOCAL FUNCTIONS  =============================
    33 // ============================= LOCAL FUNCTIONS  =============================
    34 
    34 
    83    	FeatureManager::UnInitializeLib();    
    83    	FeatureManager::UnInitializeLib();    
    84     Dprint ( ( _L( "CSCPPatternPlugin::ConstructL()" ) ) );
    84     Dprint ( ( _L( "CSCPPatternPlugin::ConstructL()" ) ) );
    85     return;
    85     return;
    86     }
    86     }
    87     
    87     
       
    88 
       
    89 // ----------------------------------------------------------------------------
       
    90 // CSCPPatternPlugin::GetResource
       
    91 // GetResource, opens the localisation filesystem
       
    92 // Status : Approved
       
    93 // ----------------------------------------------------------------------------
       
    94 //
       
    95 TInt CSCPPatternPlugin::GetResource()
       
    96     {
       
    97  	Dprint( (_L("CSCPPatternPlugin::GetResource()") ));
       
    98 	// The resource has to be loaded manually since it is not an application.        
       
    99 	
       
   100 	if ( iFs == NULL )
       
   101 	    {
       
   102 	    return KErrNotReady;
       
   103 	    }
       
   104 
       
   105     // can't use resource here because it is not added yet....
       
   106     TFileName resourceFile;
       
   107     resourceFile.Append( KDriveZ );
       
   108     resourceFile.Append( SCPPatternPluginSrcFile );
       
   109     BaflUtils::NearestLanguageFile( *iFs, resourceFile );
       
   110     
       
   111     TRAPD( err, 
       
   112         iRf.OpenL( *iFs, resourceFile );
       
   113         iRf.ConfirmSignatureL();
       
   114         );
       
   115         
       
   116     return err;
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CSCPPatternPlugin::LoadResourceLC
       
   121 // LoadResourceLC, loads the localisation resource
       
   122 // Status : Approved
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 HBufC16* CSCPPatternPlugin::LoadResourceLC( TInt aResId )
       
   126     {
       
   127 	Dprint ( ( _L( "CSCPPatternPlugin::LoadResourceLC()" ) ) );
       
   128 
       
   129 	// load the actual resource
       
   130     HBufC8* readBuffer = iRf.AllocReadLC( aResId );
       
   131     // as we are expecting HBufC16...
       
   132     const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(),
       
   133                                  ( readBuffer->Length() + 1 ) >> 1 );
       
   134     HBufC16* textBuffer=HBufC16::NewL( ptrReadBuffer.Length() );    
       
   135     *textBuffer=ptrReadBuffer;
       
   136     CleanupStack::PopAndDestroy( readBuffer ); // readBuffer
       
   137     CleanupStack::PushL( textBuffer );
       
   138   	return textBuffer;
       
   139     }
       
   140 
       
   141 
    88 // ----------------------------------------------------------------------------
   142 // ----------------------------------------------------------------------------
    89 // CSCPPatternPlugin::~CSCPPatternPlugin
   143 // CSCPPatternPlugin::~CSCPPatternPlugin
    90 // Destructor
   144 // Destructor
    91 // Status : Approved
   145 // Status : Approved
    92 // ----------------------------------------------------------------------------
   146 // ----------------------------------------------------------------------------
   106 // 
   160 // 
   107 // 
   161 // 
   108 // Status : Approved
   162 // Status : Approved
   109 // ----------------------------------------------------------------------------
   163 // ----------------------------------------------------------------------------
   110 //    
   164 //    
   111 void CSCPPatternPlugin :: HandleEventL( TInt aID, CSCPParamObject& aParam, CSCPParamObject& aOutParam )
   165 CSCPParamObject* CSCPPatternPlugin::HandleEvent( TInt aID, CSCPParamObject& aParam )
   112 	{	
   166 	{	
       
   167 	
   113 	Dprint ( ( _L( "CSCPPatternPlugin::HandleEvent()" ) ) );
   168 	Dprint ( ( _L( "CSCPPatternPlugin::HandleEvent()" ) ) );
       
   169 	
       
   170 	// Make the ParamObject for success ack, Delete later
       
   171 	CSCPParamObject* retParams = NULL;
       
   172 		
       
   173 	TBool errRaised;
       
   174 	errRaised = EFalse;
   114 	
   175 	
   115 	TBool isInvalid = EFalse;
   176 	TBool isInvalid = EFalse;
   116 	
   177 	
   117 	// check for Case
   178 	// check for Case
   118     switch ( aID )
   179     switch ( aID )
   158                     passcodeminspecialcharacters = 0;
   219                     passcodeminspecialcharacters = 0;
   159             		
   220             		
   160             if ( config.Get( (RTerminalControl3rdPartySession::EPasscodeDisallowSimple), 
   221             if ( config.Get( (RTerminalControl3rdPartySession::EPasscodeDisallowSimple), 
   161                  passcodedisallowsimple ) !=  KErrNone )
   222                  passcodedisallowsimple ) !=  KErrNone )
   162                     passcodedisallowsimple = EFalse;
   223                     passcodedisallowsimple = EFalse;
   163             Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL): EPasscodeMinLength :%d, EPasscodeMaxLength :%d, "), passcodeminlength,passcodemaxlength ) );		
   224 			
   164             Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL):  EPasscodeMaxRepeatedCharacters :%d, EPasscodeRequireCharsAndNumbers :%d"), passcodemaxrepeatedcharacters,passcoderequirecharsandnumbers ) );
       
   165             Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL): EPasscodeRequireUpperAndLower :%d,minspecialcharacters :%d  "), passcoderequireupperandlower ,passcodeminspecialcharacters) );
       
   166             Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL):  EPasscodeConsecutiveNumbers :%d, EPasscodeDisallowSimple :%d, "), passcodeconsecutivenumbers,passcodeminspecialcharacters ) );
       
   167             // Get the password from the paramObject
   225             // Get the password from the paramObject
   168             TBuf<KSCPPasscodeMaxLength> password;
   226             TBuf<KSCPPasscodeMaxLength> password;
   169             if ( aParam.Get( KSCPParamPassword, password ) != KErrNone )
   227             if ( aParam.Get( KSCPParamPassword, password ) != KErrNone )
   170                 {
   228                 {
   171                 // Nothing to do anymore
   229                 // Nothing to do anymore
   172                 break;
   230                 break;
   173                 }
   231                 }            
   174             
   232             
   175         	// The first rule is to check if securitycode has any
   233         	// The first rule is to check if securitycode has any
   176         	// forbidden chars, like WhiteSpace etc...
   234         	// forbidden chars, like WhiteSpace etc...
   177         	// If so, there is a problem >> KErrArgument
   235         	// If so, there is a problem >> KErrArgument
   178 			for (TInt c1=0; c1 < password.Length(); c1++)
   236 			for (TInt c1=0; c1 < password.Length(); c1++)
   179 			    {
   237 			    {
   180 			  TChar ch = static_cast<TChar>( password[c1] );
   238 			  TChar ch = static_cast<TChar>( password[c1] );
   181 			  TChar::TCategory chCat = ch.GetCategory();
   239 			  TChar::TCategory chCat = ch.GetCategory();
   182 			  if ( ch.IsSpace() )
   240 			  if ( ch.IsSpace() )
   183 				    {   
   241 				    {   
   184 					aOutParam.Set( KSCPParamStatus, KErrArgument );
   242 					TRAPD( err, retParams  = CSCPParamObject::NewL() );
       
   243 					if ( err == KErrNone )
       
   244 					    {
       
   245 					    retParams->Set( KSCPParamStatus, KErrArgument );    
       
   246 					    }
       
   247 					    					    
   185 					argumentError = ETrue;
   248 					argumentError = ETrue;
   186 					break;
   249 					break;
   187 				    }
   250 				    }
   188 			    }			 
   251 			    }			 
   189 						
   252 						
   199 				 passcoderequirecharsandnumbers || 
   262 				 passcoderequirecharsandnumbers || 
   200 				 passcodeconsecutivenumbers ||
   263 				 passcodeconsecutivenumbers ||
   201 				 passcodeminspecialcharacters != 0 ||
   264 				 passcodeminspecialcharacters != 0 ||
   202 				 passcodedisallowsimple)
   265 				 passcodedisallowsimple)
   203 			    {			
   266 			    {			
       
   267 				// Get the filesystem for Resource
       
   268 				// If fail, bail out
       
   269 				TInt errgGR = GetResource();
       
   270 				if (errgGR != KErrNone)
       
   271 				    {
       
   272 					errRaised = ETrue;
       
   273 					break; // Break out 
       
   274 				    }
       
   275 
   204 				// Declare the Check flags										
   276 				// Declare the Check flags										
   205 				TBool istoosimilar = EFalse;					
   277 				TBool istoosimilar = EFalse;					
   206 				TBool consecutively = EFalse;
   278 				TBool consecutively = EFalse;
   207 				TBool consecutivechars = ETrue;
   279 				TBool consecutivechars = ETrue;
   208 				TBool singlerepeat = ETrue;
   280 				TBool singlerepeat = ETrue;
   212 				TInt upperCount = 0;	// for passcoderequireupperandlower
   284 				TInt upperCount = 0;	// for passcoderequireupperandlower
   213 				TInt alphaCount = 0;	// for passcoderequirecharsandnumbers
   285 				TInt alphaCount = 0;	// for passcoderequirecharsandnumbers
   214 				TInt specialCount = 0;  // for passcodeminspecialcharacters
   286 				TInt specialCount = 0;  // for passcodeminspecialcharacters
   215 				TChar temp = '1';
   287 				TChar temp = '1';
   216 			
   288 			
       
   289 
       
   290 				// Prompt buf, iNote can show only 97 chars,
       
   291 				// without ... markings.
       
   292 				HBufC* hbuf = NULL;
       
   293 				
   217 			 	 // Check for required check or not.
   294 			 	 // Check for required check or not.
   218 	        	if (passcodeminlength != 0)
   295 	        	if (passcodeminlength != 0)
   219 	        	    {
   296 	        	    {
   220 		        	// check for Min lenght
   297 		        	// check for Min lenght
   221 		            if (  password.Length() < passcodeminlength )
   298 		            if (  password.Length() < passcodeminlength )
   222 		                {
   299 		                {
   223 		                //koya: return error code to SecUi
       
   224 		                Dprint ( ( _L( "EDeviceLockMinlength Failed" ) ) );
       
   225 		                aOutParam.AddtoFailedPolices(EDeviceLockMinlength);
       
   226 		                isInvalid = ETrue;
   300 		                isInvalid = ETrue;
       
   301 		                TRAP_IGNORE(
       
   302 		                    hbuf = LoadAndFormatResL( R_SET_SEC_CODE_MIN, &passcodeminlength ) 
       
   303 		                    );
   227 		                }
   304 		                }
   228 
   305 	                }
       
   306 
       
   307 				if (!hbuf)
       
   308 				    {
   229 		        	// Check for required check or not.
   309 		        	// Check for required check or not.
       
   310 		        	if (passcodemaxlength!=0)
       
   311 		        	    {
   230 		        		// Check for Max Lenght
   312 		        		// Check for Max Lenght
   231 		            else if ( password.Length() > passcodemaxlength )
   313 	             	    if ( password.Length() > passcodemaxlength )
   232 		             	    {
   314 		             	    {
   233 		                Dprint ( ( _L( "EDeviceLockMaxlength Failed" ) ) );
       
   234                             aOutParam.AddtoFailedPolices(EDeviceLockMaxlength);
       
   235 		                    isInvalid = ETrue;
   315 		                    isInvalid = ETrue;
       
   316 		                    TRAP_IGNORE(
       
   317 		                        hbuf = LoadAndFormatResL( R_SET_SEC_CODE_MAX, &passcodemaxlength );
       
   318 		                        );
       
   319 		             	    }
   236 		           	    }
   320 		           	    }
   237 				    }
   321 				    }
   238  	
   322  	
       
   323 				if (!hbuf)
       
   324 				    {
   239 		  			// Check for required check or not.
   325 		  			// Check for required check or not.
   240 		  			if ( passcodemaxrepeatedcharacters != 0 )
   326 		  			if ( passcodemaxrepeatedcharacters != 0 )
   241 		  			    {
   327 		  			    {
   242 			  			// Check for TooManySameChars
   328 			  			// Check for TooManySameChars
   243 			  			TRAPD( err, istoosimilar = TooManySameCharsL(password,passcodemaxrepeatedcharacters) );
   329 			  			TRAPD( err, istoosimilar = TooManySameCharsL(password,passcodemaxrepeatedcharacters) );
   244 					  	if ( ( err == KErrNone ) && ( istoosimilar ) )
   330 					  	if ( ( err == KErrNone ) && ( istoosimilar ) )
   245 					  	    {					  
   331 					  	    {					  		
   246 					  	  Dprint ( ( _L( "EDeviceLockAllowedMaxRepeatedChars Failed" ) ) );
   332 					  		if ( passcodemaxrepeatedcharacters > 1 )
   247                             aOutParam.AddtoFailedPolices(EDeviceLockAllowedMaxRepeatedChars);
   333 					  		    {
   248                             isInvalid = ETrue;
   334 		                        isInvalid = ETrue;
   249                             }
   335 		                        TRAP_IGNORE(
       
   336 		                            hbuf = LoadAndFormatResL( R_SET_SEC_CODE_REPEATED,
       
   337 					  		                              &passcodemaxrepeatedcharacters );
       
   338 		                            );						  		    						  		    					  		    
       
   339 					  		    }
       
   340 					  		else // passcodemaxrepeatedcharacters == 1
       
   341 					  		    {
       
   342 		                        isInvalid = ETrue;
       
   343 		                        TRAP_IGNORE(
       
   344 		                            hbuf = LoadAndFormatResL( R_SET_SEC_CODE_REPEATED_ONCE );
       
   345 		                            );					  		   
       
   346 					  		    }						  								  				  						
       
   347 					  	    }						  		
   250 				  	    }
   348 				  	    }
       
   349 				    }
   251 				    
   350 				    
       
   351    		   		if (!hbuf)
       
   352 				    {
   252 	   				// Check for Alphadigit
   353 	   				// Check for Alphadigit
   253 	   				if ( passcoderequirecharsandnumbers)
   354 	   				if ( passcoderequirecharsandnumbers)
   254 	   				    {
   355 	   				    {
   255 	   					for (TInt adcounter=0; adcounter < password.Length(); adcounter++)
   356 	   					for (TInt adcounter=0; adcounter < password.Length(); adcounter++)
   256 			  			    {						
   357 			  			    {						
   262 						    }
   363 						    }
   263 						
   364 						
   264 		  				if (digitCount >= password.Length() || alphaCount >= password.Length()
   365 		  				if (digitCount >= password.Length() || alphaCount >= password.Length()
   265 		  				           || digitCount == 0 || alphaCount == 0 )
   366 		  				           || digitCount == 0 || alphaCount == 0 )
   266 		  				    {
   367 		  				    {
   267 		  				  Dprint ( ( _L( "EDeviceLockRequireCharsAndNumbers Failed" ) ) );
   368 		                    isInvalid = ETrue;
   268                               aOutParam.AddtoFailedPolices(EDeviceLockRequireCharsAndNumbers);
   369 		                    TRAP_IGNORE(
   269                               isInvalid = ETrue;
   370 		                        hbuf = LoadAndFormatResL( R_SET_SEC_CODE_LETTERS_NUMBERS );
       
   371 		                        );		  				    				  				
   270 		  				    }
   372 		  				    }
   271 	   				    }	// End of Alphadigit Check
   373 	   				    }	// End of Alphadigit Check
       
   374 				    }
   272 				  	
   375 				  	
   273 				  							
   376 				  							
       
   377 				if (!hbuf)
       
   378 			    	{
   274 					// passcodeconsecutivenumbers
   379 					// passcodeconsecutivenumbers
   275 					if (passcodeconsecutivenumbers)
   380 					if (passcodeconsecutivenumbers)
   276 					    {
   381 					    {
   277 						consecutively = consecutivelyCheck(password);
   382 						consecutively = consecutivelyCheck(password);
   278 
   383 
   279 						if ( consecutively )
   384 						if ( consecutively )
   280 						    {
   385 						    {
   281 						    Dprint ( ( _L( "EDeviceLockConsecutiveNumbers Failed" ) ) );
       
   282 						    aOutParam.AddtoFailedPolices(EDeviceLockConsecutiveNumbers);
       
   283 		                    isInvalid = ETrue;
   386 		                    isInvalid = ETrue;
       
   387 		                    TRAP_IGNORE(
       
   388 		                        hbuf = LoadAndFormatResL( R_SET_SEC_CODE_CONSECUTIVE );
       
   389 		                        );	
   284 						    }
   390 						    }
   285 					    } 
   391 					    } 
       
   392 				    }
       
   393         
       
   394         		/*
       
   395         		if (!hbuf)
       
   396 				    {
       
   397 		        	// Check for required check or not.
       
   398 		        	if (passcoderequireupperandlower)
       
   399 		        	    {				        	
       
   400 		        		// Count the IsDigits first and miinus them from the lenghth!
       
   401 		        		// Count the possible NUM's count first!
       
   402 		        		for (TInt numcounter=0; numcounter < password.Length(); numcounter++)
       
   403 			  			    {
       
   404 			  				if ( static_cast<TChar>( password[numcounter] ).IsDigit() )
       
   405 						  		numberCount++;
       
   406 			  			    }
       
   407 
       
   408 		   			// Check for Caps, both
       
   409 		  			for (TInt capscounter=0; capscounter < password.Length(); capscounter++)
       
   410 		  			    {
       
   411 						if ( static_cast<TChar>( password[capscounter] ).IsUpper() )
       
   412 					  		upperCount++;
       
   413 						
       
   414 						if ( static_cast<TChar>( password[capscounter] ).IsLower() )
       
   415 					  		lowerCount++;
       
   416 		  			    }
       
   417 		  			    					  								  			
       
   418                         if (upperCount >= (password.Length()-numberCount ) )
       
   419                         	isallcaps = ETrue;
       
   420 				  			
       
   421 		  				if (lowerCount >= (password.Length() -numberCount) )
       
   422 		  					isallsmall = ETrue;				  			
       
   423 				
       
   424 						if (isallsmall || isallcaps)
       
   425 						    {	  
       
   426 		                    isInvalid = ETrue;
       
   427 		                    TRAP_IGNORE(
       
   428 		                        hbuf = LoadAndFormatResL( R_SET_SEC_CODE_UPPER_LOWER );
       
   429 		                        );			                          							    	  							    
       
   430 						    }	  							    	  							    		
       
   431 			        	}	// End of Caps check
       
   432 				    }
       
   433 				 */	   		   		
       
   434 
       
   435         		if (!hbuf)
       
   436 				    {
   286 		        	// Check for required check or not.
   437 		        	// Check for required check or not.
   287 		        	if (passcoderequireupperandlower)
   438 		        	if (passcoderequireupperandlower)
   288 		        	    {
   439 		        	    {
   289 		        	    for (TInt counter=0; counter < password.Length(); counter++)
   440 		        	    for (TInt counter=0; counter < password.Length(); counter++)
   290 		  			    {
   441 		  			    {
   298 							}
   449 							}
   299 		  			    }
   450 		  			    }
   300 		  			    
   451 		  			    
   301 		  			    if ( upperCount == 0 || lowerCount == 0)
   452 		  			    if ( upperCount == 0 || lowerCount == 0)
   302 		  			    	{
   453 		  			    	{
   303 		  			      Dprint ( ( _L( "EDeviceLockRequireUpperAndLower Failed" ) ) );
       
   304 		  			    	aOutParam.AddtoFailedPolices(EDeviceLockRequireUpperAndLower);
       
   305 		  			    	isInvalid = ETrue;
   454 		  			    	isInvalid = ETrue;
       
   455 		                    TRAP_IGNORE(
       
   456 		                        hbuf = LoadAndFormatResL( R_SET_SEC_CODE_UPPER_LOWER );
       
   457 		                        );		
   306 		  			    	}
   458 		  			    	}
   307 		        	    }        		
   459 		        	    }
       
   460 				    }
       
   461 		        	    
       
   462 		        	    				        	
       
   463         		
       
   464         		if (!hbuf)
       
   465         		   {
   308                     // Check for required check or not.
   466                     // Check for required check or not.
   309                     if (passcodeminspecialcharacters != 0)
   467                     if (passcodeminspecialcharacters != 0)
   310                         {
   468                         {
   311                         for (TInt specialcounter=0; specialcounter< password.Length(); specialcounter++)
   469                         for (TInt specialcounter=0; specialcounter< password.Length(); specialcounter++)
   312                             {
   470                             {
   314                                 specialCount++;
   472                                 specialCount++;
   315                             }
   473                             }
   316                         
   474                         
   317                         if ( specialCount < passcodeminspecialcharacters )
   475                         if ( specialCount < passcodeminspecialcharacters )
   318                             {
   476                             {
   319                             //koya: return error code to SecUi
       
   320                             Dprint ( ( _L( "EDeviceLockMinSpecialCharacters Failed" ) ) );
       
   321                             aOutParam.AddtoFailedPolices(EDeviceLockMinSpecialCharacters);
       
   322                             isInvalid = ETrue;
   477                             isInvalid = ETrue;
   323                             }                        
   478                             TRAP_IGNORE(
       
   479                                     hbuf = LoadAndFormatResL( R_SET_SEC_CODE_MIN_SPECIAL_CHARS, 
       
   480                                     &passcodeminspecialcharacters );
       
   481                             );
       
   482                             }
       
   483                         
   324                     	}
   484                     	}
   325 						    		                
   485         		   }
       
   486         		                
       
   487         		if (!hbuf)
       
   488         		   {
   326                     if (passcodedisallowsimple)
   489                     if (passcodedisallowsimple)
   327                         {
   490                         {
   328                         for (TInt counter=0; counter< (password.Length()-1); counter++)
   491                         for (TInt counter=0; counter< (password.Length()-1); counter++)
   329                             {
   492                             {
   330                             if ( (static_cast<TChar>(password[counter])) != (static_cast<TChar>(password[counter+1])) )
   493                             if ( (static_cast<TChar>(password[counter])) != (static_cast<TChar>(password[counter+1])) )
   333                                 break;
   496                                 break;
   334                                 }
   497                                 }
   335                             }
   498                             }
   336                         if (singlerepeat)
   499                         if (singlerepeat)
   337                             {
   500                             {
   338                             //koya: return error code to SecUi
       
   339                             Dprint ( ( _L( "EDeviceLockSingleCharRepeatNotAllowed Failed" ) ) );
       
   340                             aOutParam.AddtoFailedPolices(EDeviceLockSingleCharRepeatNotAllowed);
       
   341                             isInvalid = ETrue;
   501                             isInvalid = ETrue;
       
   502                             TRAP_IGNORE(
       
   503                                     hbuf = LoadAndFormatResL( R_SET_SEC_CODE_SINGLE_REPEAT ) );                            
   342                             }
   504                             }
   343                         
   505                         if (!hbuf)
       
   506                             {
   344                             for (TInt counter=0; counter< (password.Length()-1); counter++)
   507                             for (TInt counter=0; counter< (password.Length()-1); counter++)
   345                                 {
   508                                 {
   346                                 //The consecutivity to be checked with only Alphanumeric characters.
   509                                 //The consecutivity to be checked with only Alphanumeric characters.
   347                                 //The check is being made for only the increasing order. Decreasing order is left for
   510                                 //The check is being made for only the increasing order. Decreasing order is left for
   348                                 //future implementation if needed. Right now it is left out as this will hit the
   511                                 //future implementation if needed. Right now it is left out as this will hit the
   362                                     break;
   525                                     break;
   363                                     }
   526                                     }
   364                                 }
   527                                 }
   365                             if (consecutivechars)
   528                             if (consecutivechars)
   366                                 {
   529                                 {
   367                                 //koya: return error code to SecUi
       
   368                                 Dprint ( ( _L( "EDevicelockConsecutiveCharsNotAllowed Failed" ) ) );
       
   369                                 aOutParam.AddtoFailedPolices(EDevicelockConsecutiveCharsNotAllowed);
       
   370                                 isInvalid = ETrue;
   530                                 isInvalid = ETrue;
       
   531                                 TRAP_IGNORE(
       
   532                                         hbuf = LoadAndFormatResL( R_SET_SEC_CODE_CONSECUTIVE_CHARS ) );
   371                                 }
   533                                 }
   372                         }			  	
   534                             }
       
   535                         }
       
   536                     }
       
   537 				  	
       
   538 			  	
   373 				if ( isInvalid )
   539 				if ( isInvalid )
   374 				    {	    							
   540 				    {	    							
   375 			            aOutParam.Set( KSCPParamStatus, KErrSCPInvalidCode );		                
   541 			    	// Create the result-object to return
   376 		            }
   542 				    TRAPD( err, retParams  = CSCPParamObject::NewL() );
       
   543                     
       
   544                     if ( err == KErrNone )
       
   545 				        {
       
   546 			            retParams->Set( KSCPParamStatus, KErrSCPInvalidCode );
       
   547     		            retParams->Set( KSCPParamAction, KSCPActionShowUI );
       
   548 	    	            retParams->Set( KSCPParamUIMode, KSCPUINote );
       
   549 		                
       
   550 		                if ( hbuf != NULL )
       
   551 		                    {
       
   552 		                    FormatResourceString(*hbuf);	
       
   553 		                    TPtr ptr = hbuf->Des();
       
   554 		                    retParams->Set( KSCPParamPromptText, ptr );
       
   555 		                    delete hbuf;
       
   556 		                    }
       
   557 				        }
       
   558 				    }
   377 				    
   559 				    
   378                 } // end of All Zero check
   560                 } // end of All Zero check
       
   561 		    // All params were zero! no check!
       
   562             else 
       
   563                 {
       
   564                 retParams = NULL;
       
   565                 }
       
   566                 			
   379             break;  
   567             break;  
   380             } // KSCPEventValidate
   568             } // KSCPEventValidate
   381                 
   569                 
   382         case ( KSCPEventConfigurationQuery ):
   570         case ( KSCPEventConfigurationQuery ):
   383             {            
   571             {            
   397 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeMaxRepeatedCharacters)
   585 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeMaxRepeatedCharacters)
   398 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeConsecutiveNumbers )
   586 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeConsecutiveNumbers )
   399 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeMinSpecialCharacters)
   587 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeMinSpecialCharacters)
   400 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeDisallowSimple))
   588 				||  paramID ==  (RTerminalControl3rdPartySession::EPasscodeDisallowSimple))
   401                 {
   589                 {
       
   590                 
       
   591                 // OK, we're interested, check that the value is valid
       
   592                 TRAPD( err, retParams  = CSCPParamObject::NewL() );
       
   593                 
       
   594                 if ( err != KErrNone )
       
   595                     {
       
   596                     break; // Fatal, cannot create paramObject
       
   597                     }
       
   598                 
   402                 // All of our params are TInts
   599                 // All of our params are TInts
   403                 TInt paramValue;
   600                 TInt paramValue;
   404                 if ( aParam.Get( KSCPParamValue, paramValue ) != KErrNone )
   601                 if ( aParam.Get( KSCPParamValue, paramValue ) != KErrNone )
   405                     {
   602                     {
   406                     aOutParam.Set( KSCPParamStatus, KErrArgument );
   603                     retParams->Set( KSCPParamStatus, KErrGeneral );
   407                     break;
   604                     break;
   408                     }
   605                     }
   409                                 
   606                                 
   410                 TInt retStatus = KErrNone;
   607                 TInt retStatus = KErrNone;
   411                 switch ( paramID )
   608                 switch ( paramID )
   476                                  retStatus = KErrArgument;
   673                                  retStatus = KErrArgument;
   477                                  }
   674                                  }
   478                         break;
   675                         break;
   479                     }
   676                     }
   480                 
   677                 
   481                 aOutParam.Set( KSCPParamStatus, retStatus );
   678                 retParams->Set( KSCPParamStatus, retStatus );
   482                 }
   679                 }
       
   680             else
       
   681                 {
       
   682                 retParams = NULL;
       
   683                 }
       
   684                
   483             break;
   685             break;
   484             } //KSCPEventConfigurationQuery                         
   686             } //KSCPEventConfigurationQuery                         
   485         } //  switch ( aID )
   687         } //  switch ( aID )
       
   688 
       
   689    	// Check if Any errors were raised and handle it
       
   690     if (errRaised) 
       
   691         {
       
   692         if ( retParams != NULL )
       
   693             {
       
   694             delete retParams;
       
   695             }
       
   696         retParams = NULL;
       
   697         }
       
   698         
   486     // The caller will own this pointer from now on   
   699     // The caller will own this pointer from now on   
       
   700     return retParams; 
   487 	}
   701 	}
   488 
   702 
   489 // ----------------------------------------------------------------------------
   703 // ----------------------------------------------------------------------------
   490 // CSCPPatternPlugin::SetEventHandler
   704 // CSCPPatternPlugin::SetEventHandler
   491 // 
   705 // 
   600         }
   814         }
   601         
   815         
   602     return charTooManyInRow;
   816     return charTooManyInRow;
   603     }
   817     }
   604     
   818     
       
   819 
       
   820 // ----------------------------------------------------------------------------
       
   821 // CSCPPatternPlugin::LoadAndFormatResL
       
   822 // Load the given resouce, and format the string according to the TInt parameters
       
   823 // if given.
       
   824 // 
       
   825 // Status : Approved
       
   826 // ----------------------------------------------------------------------------
       
   827 //
       
   828 HBufC* CSCPPatternPlugin::LoadAndFormatResL( TInt aResId, TInt* aParam1, TInt* aParam2 )
       
   829     {
       
   830     HBufC16* resource = NULL;
       
   831     HBufC* hbuf = NULL;
       
   832     
       
   833     resource = LoadResourceLC( aResId );
       
   834     FormatResourceString(*resource);
       
   835     TInt allocLen = 0;
       
   836     if ( aParam1 != NULL )
       
   837         {
       
   838         allocLen += KSCPMaxIntLength;
       
   839         }
       
   840     if ( aParam2 != NULL )
       
   841         {
       
   842         allocLen += KSCPMaxIntLength;
       
   843         }
       
   844                 
       
   845 	hbuf = HBufC::NewL( resource->Length() + allocLen );
       
   846 	
       
   847 	if ( ( aParam1 == NULL ) && ( aParam2 == NULL ) )
       
   848 	    {
       
   849 	    hbuf->Des().Copy( resource->Des() );
       
   850 	    }
       
   851 	else
       
   852 	    {
       
   853 	    if ( aParam1 == NULL )
       
   854 	        {
       
   855 	        hbuf->Des().Format( resource->Des(), *aParam2 );
       
   856 	        }
       
   857 	    else if ( aParam2 == NULL )
       
   858 	        {
       
   859 	        hbuf->Des().Format(resource->Des(), *aParam1 );
       
   860 	        }
       
   861 	    else
       
   862 	        {
       
   863 	        hbuf->Des().Format(resource->Des(), *aParam1, *aParam2 );
       
   864 	        }	    
       
   865 	    }
       
   866 								    
       
   867 	CleanupStack::PopAndDestroy( resource );
       
   868 	return hbuf;
       
   869     }
       
   870 
       
   871 // ----------------------------------------------------------------------------
       
   872 // CSCPPatternPlugin::FormatResourceString
       
   873 // The buffer that is passed is formatted to have only %i as a format specifier instead of %N or %0N etc.
       
   874 // 
       
   875 // Status : Approved
       
   876 // ----------------------------------------------------------------------------
       
   877 //
       
   878 void CSCPPatternPlugin::FormatResourceString(HBufC16 &aResStr)
       
   879 {
       
   880 		TInt pos = 0;
       
   881 		TInt flag = 0;
       
   882         TPtr16 bufPtr = aResStr.Des();
       
   883         _LIT (mess1, "%N");
       
   884         _LIT (mess2, "%i");
       
   885         _LIT (mess3, "%0N");
       
   886         _LIT (mess4, "%1N");
       
   887                               
       
   888         while ((pos = bufPtr.Find(mess1)) !=KErrNotFound)
       
   889         {
       
   890               bufPtr.Replace(pos,2,mess2); 
       
   891               flag = 1;
       
   892               break;                    
       
   893         }
       
   894                
       
   895         if(flag == 0)
       
   896         {
       
   897               while ((pos = bufPtr.Find(mess3)) != KErrNotFound)
       
   898               {
       
   899               		bufPtr.Replace(pos,3,mess2);
       
   900               }
       
   901                		
       
   902               while ((pos = bufPtr.Find(mess4)) != KErrNotFound)
       
   903               {
       
   904                 	bufPtr.Replace(pos,3,mess2);
       
   905               }
       
   906         }	
       
   907 }    
       
   908 
   605 // End of File
   909 // End of File