javaextensions/pim/framework/src.s60/cpimtodovalidator.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Valid to-do data info.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include  "cpimtodovalidator.h"
       
    21 #include  "pimtodo.h"
       
    22 #include "logger.h"
       
    23 
       
    24 CPIMToDoValidator* CPIMToDoValidator::NewL()
       
    25 {
       
    26     JELOG2(EPim);
       
    27     CPIMToDoValidator* self = NewLC();
       
    28     CleanupStack::Pop(self);
       
    29     return self;
       
    30 }
       
    31 
       
    32 CPIMToDoValidator* CPIMToDoValidator::NewLC()
       
    33 {
       
    34     JELOG2(EPim);
       
    35     CPIMToDoValidator* self = new(ELeave) CPIMToDoValidator();
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL();
       
    38     return self;
       
    39 }
       
    40 
       
    41 CPIMToDoValidator::CPIMToDoValidator() :
       
    42         CPIMValidator(KPIMAttrNone) // ToDo defines no attributes
       
    43 {
       
    44     JELOG2(EPim);
       
    45 }
       
    46 
       
    47 void CPIMToDoValidator::ConstructL()
       
    48 {
       
    49     JELOG2(EPim);
       
    50     CPIMValidator::ConstructL();
       
    51 
       
    52     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoClass, EPIMFieldInt));
       
    53 
       
    54     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoCompleted, EPIMFieldBoolean));
       
    55 
       
    56     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoCompletionDate,
       
    57                                            EPIMFieldDate));
       
    58 
       
    59     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoDue, EPIMFieldDate));
       
    60 
       
    61     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoNote, EPIMFieldString));
       
    62 
       
    63     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoPriority, EPIMFieldInt));
       
    64 
       
    65     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoRevision, EPIMFieldDate));
       
    66 
       
    67     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoSummary, EPIMFieldString));
       
    68 
       
    69     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoUid, EPIMFieldString));
       
    70 
       
    71     iValidFields->AppendL(TPIMFieldAndType(EPIMToDoExtAlarm, EPIMFieldInt));
       
    72 }
       
    73 
       
    74 CPIMToDoValidator::~CPIMToDoValidator()
       
    75 {
       
    76     JELOG2(EPim);
       
    77 }
       
    78 
       
    79 TBool CPIMToDoValidator::IsValidIntegerValue(const TPIMField& aField,
       
    80         const TInt& aValue) const
       
    81 {
       
    82     JELOG2(EPim);
       
    83     TBool retVal = ETrue;
       
    84 
       
    85     if (aField == EPIMToDoClass)
       
    86     {
       
    87         // to-do class has predefined values
       
    88         if ((aValue != EPIMToDoClassConfidential) && (aValue
       
    89                 != EPIMToDoClassPrivate) && (aValue != EPIMToDoClassPublic))
       
    90         {
       
    91             // not one of the predefined values
       
    92             retVal = EFalse;
       
    93         }
       
    94     }
       
    95     else if (aField == EPIMToDoPriority)
       
    96     {
       
    97         if ((aValue < EPIMToDoPriorityMinValue) || (aValue
       
    98                 > EPIMToDoPriorityMaxValue))
       
    99         {
       
   100             retVal = EFalse;
       
   101         }
       
   102     }
       
   103     // else any integer is OK
       
   104 
       
   105     return retVal;
       
   106 }
       
   107 
       
   108 //  End of File