commsfwtools/preparedefaultcommsdatabase/src/CommsDatValidator.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Data validation rules for CommsDat data
       
    15 // FILE CONTENTS :
       
    16 // 1/  CCDValidator Base class
       
    17 // 2/  Validator classes for particular records
       
    18 // a) CCDValidatorProxiesRecord
       
    19 // b) CCDValidatorLANServiceRecord
       
    20 // c) CCDValidatorTierRecord
       
    21 // d) CCDValidatorConnPref
       
    22 // e) CCDValidatorIAPRecord
       
    23 // VALIDATION
       
    24 // CCDValidator and derived classes implement validation rules for elements in the database
       
    25 // Not every element needs validation.  Database writers are trusted components
       
    26 // Validation is only necessary when data is written to the database
       
    27 // MAINTENANCE
       
    28 // Rules may need modification when the CommsDat schema changes
       
    29 // 
       
    30 //
       
    31 
       
    32 /**
       
    33  @file 
       
    34  @internalTechnology
       
    35 */
       
    36 
       
    37 
       
    38 #if (!defined COMMSDATVALIDATOR_H)
       
    39 #define       COMMSDATVALIDATOR_H
       
    40 
       
    41 #include <cdbcols.h>
       
    42 
       
    43 //forward declarations
       
    44 //class CCDAPPrioritySelectionPolicyRecord;
       
    45 //class CCDAccessPointRecord;
       
    46 
       
    47 namespace CommsDatInternal
       
    48 /*
       
    49 @internalTechnology
       
    50 */
       
    51 {
       
    52 
       
    53 
       
    54 /**************************************************************************************************
       
    55  * 1/ VALIDATION BASE CLASSES 
       
    56  *************************************************************************************************/
       
    57 
       
    58 
       
    59 NONSHARABLE_CLASS(CCDValidator) : public CBase
       
    60 /*
       
    61 Validates input data 
       
    62 
       
    63 Only for use where it is vital the data is correct
       
    64 Not all data entry is validated
       
    65 
       
    66 @internalComponent
       
    67 */
       
    68     {
       
    69 public :
       
    70     
       
    71     // Creates a validator class if there are validation rules for aElement
       
    72     static void ValidateL(CMDBElement* aElement,CMDBSessionImpl& aSession
       
    73 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
    74                           , TOperation aValidatorOperation = EModify
       
    75 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
    76                           );
       
    77             
       
    78     virtual ~CCDValidator();
       
    79 
       
    80     // Performs any housekeeping if necessary upon deletion of a record.
       
    81     // For example, applies the opposite rules to ValidateL().
       
    82     virtual void OnDeleteL();
       
    83 
       
    84     // Only ever created by the factory
       
    85     CCDValidator(CMDBElement* aElement,CMDBSessionImpl& aSession);
       
    86     
       
    87 
       
    88 private:
       
    89 
       
    90     // Validates data using validation rules
       
    91     // Leaves if it finds any errors in the data being submitted
       
    92     virtual void DoValidateL();
       
    93 
       
    94     CCDValidator();
       
    95 
       
    96 protected:
       
    97     
       
    98     //CMDBElement& iElement; // A reference to the element being validated
       
    99     
       
   100 	// A pointer to the element being validated (the object DOESN'T 
       
   101 	// own the pointer!!!!!!)
       
   102     CMDBElement* iElement; 
       
   103     
       
   104     CMDBSessionImpl& iSession;
       
   105 
       
   106     };
       
   107 
       
   108 
       
   109 
       
   110     
       
   111 /**************************************************************************************************
       
   112  * 2/ VALIDATOR CLASSES FOR INDIVIDUAL ELEMENTS
       
   113  *************************************************************************************************/
       
   114 
       
   115 
       
   116 
       
   117 /************************* 2 a) Validator for Proxy Table ******************************************
       
   118  */
       
   119 NONSHARABLE_CLASS(CCDValidatorProxyRecord) : public CCDValidator
       
   120     {
       
   121 public:
       
   122     
       
   123     virtual ~CCDValidatorProxyRecord()
       
   124     	{
       
   125     	delete iShadowElement;
       
   126     	}
       
   127     
       
   128     CCDValidatorProxyRecord(CMDBElement* aElement,CMDBSessionImpl& aSession):CCDValidator(aElement,aSession){}
       
   129     
       
   130 protected:
       
   131 
       
   132     void DoValidateL();
       
   133 
       
   134 private:
       
   135     //when only field validation is done the validator reads the whole record from the DB and acts as
       
   136     //originally a record validation would be called. This element points to the record read from the
       
   137     //dB.
       
   138     CMDBElement* iShadowElement;
       
   139     
       
   140 	void SetShadowElementL();
       
   141     };
       
   142 
       
   143 
       
   144 /************************* 2 b) Validator for LanService Table ******************************************
       
   145  */
       
   146 
       
   147 NONSHARABLE_CLASS(CCDValidatorLANServiceRecord) : public CCDValidator
       
   148     {
       
   149 public:
       
   150     
       
   151     virtual ~CCDValidatorLANServiceRecord()
       
   152     	{
       
   153     	delete iShadowElement;
       
   154     	}
       
   155     
       
   156     CCDValidatorLANServiceRecord(CMDBElement* aElement,CMDBSessionImpl& aSession):CCDValidator(aElement,aSession){}
       
   157     
       
   158 protected:
       
   159 
       
   160     void DoValidateL();
       
   161     
       
   162 private:
       
   163     //when only field validation is done the validator reads the whole record from the DB and acts as
       
   164     //originally a record validation would be called. This element points to the record read from the
       
   165     //dB.
       
   166     CMDBElement* iShadowElement;
       
   167     
       
   168 	void SetShadowElementL();
       
   169     };
       
   170 
       
   171 
       
   172 
       
   173 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   174 
       
   175  /************************* 2 c) Validator for Tier Table ******************************************
       
   176  */
       
   177 NONSHARABLE_CLASS(CCDValidatorTierRecord) : public CCDValidator
       
   178     {
       
   179 public:
       
   180     
       
   181     virtual ~CCDValidatorTierRecord()
       
   182     	{
       
   183     	delete iShadowElement;
       
   184     	}
       
   185     
       
   186     CCDValidatorTierRecord(CMDBElement* aElement,CMDBSessionImpl& aSession):CCDValidator(aElement,aSession){}
       
   187     
       
   188 protected:
       
   189 
       
   190     void DoValidateL();
       
   191 
       
   192 private:
       
   193     //when only field validation is done the validator reads the whole record from the DB and acts as
       
   194     //originally a record validation would be called. This element points to the record read from the
       
   195     //dB.
       
   196     CMDBElement* iShadowElement;
       
   197     
       
   198 	void SetShadowElementL();
       
   199     };
       
   200 
       
   201 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   202 
       
   203 
       
   204 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   205 /**
       
   206  This class is used by the CCDValidatorConnPref to generate the IPProto level AccessPoints
       
   207  by mapping the ConnectionPreferences records to AccessPoint records.
       
   208 */
       
   209 NONSHARABLE_CLASS(CIPProtoAPGenerator) : public CBase
       
   210     {
       
   211     public:
       
   212         CIPProtoAPGenerator(CCDAPPrioritySelectionPolicyRecord* aSelPolRec,
       
   213                             CMDBElement& aElement,  
       
   214                             CMDBSessionImpl& aSession,
       
   215                             TInt aLinkAPTagId)
       
   216             : iSession(aSession)
       
   217             , iElement(aElement)
       
   218             , iAPSelPolRec(aSelPolRec)
       
   219             , iLinkAPTagId(aLinkAPTagId)
       
   220             {}
       
   221                                        
       
   222         virtual void DoTheWorkL() = 0;
       
   223         
       
   224         virtual ~CIPProtoAPGenerator() 
       
   225             {
       
   226             delete iAPSelPolRec;
       
   227             }
       
   228     
       
   229     //protected to be able to access to these members from the derived classes.
       
   230     //There is no point to write accessors just to access these members form the 
       
   231     //dervied classes...
       
   232     protected:
       
   233         //void GenerateRecordName(TDes& aBuffer);
       
   234         
       
   235         
       
   236         CMDBSessionImpl& iSession;
       
   237         CMDBElement& iElement; // A reference to the element being validated                               CMDBSessionImpl& iSession
       
   238         CCDAPPrioritySelectionPolicyRecord* iAPSelPolRec; //the ownership is here...
       
   239         TInt iLinkAPTagId;
       
   240     };
       
   241 
       
   242 NONSHARABLE_CLASS(CIPProtoAPModifier) : public CIPProtoAPGenerator
       
   243     {
       
   244     public:
       
   245         CIPProtoAPModifier(CCDAPPrioritySelectionPolicyRecord* aSelPolRec,
       
   246                            CMDBElement& aElement,  
       
   247                            CMDBSessionImpl& aSession,
       
   248                            TInt aLinkAPTagId)
       
   249             : CIPProtoAPGenerator(aSelPolRec, aElement, aSession, aLinkAPTagId)
       
   250             {}
       
   251                            
       
   252         virtual void DoTheWorkL();
       
   253     };
       
   254 
       
   255 NONSHARABLE_CLASS(CIPProtoAPCreator) : public CIPProtoAPGenerator
       
   256     {
       
   257     public:
       
   258         CIPProtoAPCreator(CCDAPPrioritySelectionPolicyRecord* aSelPolRec,
       
   259                           CMDBElement& aElement,  
       
   260                           CMDBSessionImpl& aSession,
       
   261                           TInt aLinkAPTagId)
       
   262             : CIPProtoAPGenerator(aSelPolRec, aElement, aSession, aLinkAPTagId)
       
   263             {}
       
   264         
       
   265         virtual void DoTheWorkL();
       
   266     };
       
   267 
       
   268 NONSHARABLE_CLASS(CIPProtoAPRemover) : public CIPProtoAPGenerator
       
   269     {
       
   270     public:
       
   271         CIPProtoAPRemover(CCDAPPrioritySelectionPolicyRecord* aSelPolRec,
       
   272                           CMDBElement& aElement,  
       
   273                           CMDBSessionImpl& aSession)
       
   274             : CIPProtoAPGenerator(aSelPolRec, aElement, aSession, 0)
       
   275             {}
       
   276         
       
   277         virtual void DoTheWorkL();
       
   278     };
       
   279 
       
   280 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   281 
       
   282 /************************* 2 d) Validator for Connection Preference Table ************************
       
   283 */    
       
   284 NONSHARABLE_CLASS(CCDValidatorConnPref) : public CCDValidator
       
   285     {
       
   286 public:
       
   287 
       
   288     virtual ~CCDValidatorConnPref()
       
   289         {
       
   290 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   291         delete iIPProtoGenerator;
       
   292         delete iShadowElement;
       
   293 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   294         }
       
   295 
       
   296     CCDValidatorConnPref(CMDBElement* aElement,CMDBSessionImpl& aSession
       
   297 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   298                          ,TOperation aValidatorOperation
       
   299 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   300                          )
       
   301         :CCDValidator(aElement,aSession)
       
   302 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   303         , iOperation(aValidatorOperation)
       
   304 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   305         {}
       
   306     
       
   307 protected:
       
   308 
       
   309     void DoValidateL();
       
   310     
       
   311 private:
       
   312 
       
   313     void ValidateBearerAndDirectionL(const TDesC& aServiceType, 
       
   314                                      TCommDbConnectionDirection aDirection, 
       
   315                                      TUint32 aBearerSet, 
       
   316                                      TCommDbDialogPref aDlgPref);
       
   317     
       
   318 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   319     CCDAPPrioritySelectionPolicyRecord* FindTheAPPrioritySelPolRecL(TInt aReferredIAPRecId);
       
   320     
       
   321     //This function returns with an IAP record number in the case if the defaultIAP
       
   322     //field is not filled in the ConnPref record.
       
   323     TInt FindIAPWithoutDefIAPL();
       
   324     
       
   325     void IPProtoAPGenerationOrModificationL();
       
   326     
       
   327     void SetShadowElementL();
       
   328     
       
   329     CIPProtoAPGenerator* iIPProtoGenerator;
       
   330     TOperation iOperation;
       
   331     //when only field validation is done the validator reads the whole record from the DB and acts as
       
   332     //originally a record validation would be called. This element points to the record read from the
       
   333     //dB.
       
   334     CMDBElement* iShadowElement;
       
   335 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   336     };
       
   337 
       
   338 
       
   339 
       
   340 /************************* 2 e) Validator for IAP Table ******************************************
       
   341 */  
       
   342   
       
   343 NONSHARABLE_CLASS(CCDValidatorIAPRecord) : public CCDValidator
       
   344     {
       
   345 public:
       
   346         
       
   347     virtual ~CCDValidatorIAPRecord()
       
   348     	{
       
   349 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   350     	delete iShadowElement;
       
   351 #endif
       
   352     	}
       
   353 
       
   354     CCDValidatorIAPRecord(CMDBElement* aElement,CMDBSessionImpl& aSession
       
   355 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   356                          ,TOperation aValidatorOperation
       
   357 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   358                          )
       
   359     	:CCDValidator(aElement,aSession)
       
   360 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   361         , iOperation(aValidatorOperation)
       
   362 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   363         {}
       
   364 
       
   365 protected:
       
   366 
       
   367     void DoValidateL();
       
   368     
       
   369     void OnDeleteL();
       
   370 
       
   371 private:
       
   372 
       
   373 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   374 	TOperation iOperation;
       
   375 	
       
   376     //when only field validation is done the validator reads the whole record from the DB and acts as
       
   377     //originally a record validation would be called. This element points to the record read from the
       
   378     //dB.
       
   379     CMDBElement* iShadowElement;
       
   380     
       
   381     void InitialiseAccessPointRecordL(      CCDAccessPointRecord& lhs,
       
   382                                       const TDesC&                aRecordName,
       
   383                                             TInt                  aRecordId,
       
   384                                             TInt                  aTag,
       
   385                                             TUint32               aTier,
       
   386                                             TUint32               aMCpr,
       
   387                                             TUint32               aSelectionPolicy,
       
   388                                             TUint32               aCpr,
       
   389                                             TUint32               aCprConfig,
       
   390                                             TUint32               aSCpr,
       
   391                                             TUint32               aProtocol);
       
   392    
       
   393 
       
   394     CCDBearerTypeRecord* NewBearerTypeRecordL(CMDBSession& aSessionOwner, CCDIAPRecord& aIAPRecord);
       
   395     
       
   396     void DeleteAssociatedLinkLevelAPL();
       
   397     void AssociatedLinkLevelAPGenerationL();
       
   398     void SetShadowElementL();
       
   399 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   400 
       
   401     void ServiceAndBearerValidationL();    
       
   402     };
       
   403 
       
   404 } //end namespace CommsDatInternal
       
   405 
       
   406 
       
   407        
       
   408 #endif //COMMSDATMAPPER_H
       
   409         
       
   410 
       
   411 
       
   412 
       
   413 
       
   414 
       
   415 
       
   416 
       
   417 
       
   418 
       
   419 
       
   420 
       
   421 
       
   422 
       
   423 
       
   424 
       
   425