omadrm/drmhelper/drmhelperserver/src/EndTimeBased.cpp
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002 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:  End time based item data structure
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <e32base.h>
       
    22 #include    <e32std.h>
       
    23 #include    "EndTimeBased.h"
       
    24 #include    "DRMHelperCommon.h"
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 // CONSTANTS
       
    29 // MACROS
       
    30 // LOCAL CONSTANTS AND MACROS
       
    31 // MODULE DATA STRUCTURES
       
    32 // LOCAL FUNCTION PROTOTYPES
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 // ============================= LOCAL FUNCTIONS ===============================
       
    36 
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CEndTimeBased::CEndTimeBased
       
    42 // C++ default constructor can NOT contain any code, that
       
    43 // might leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CEndTimeBased::CEndTimeBased( 
       
    47         const TUint8& aPermType , 
       
    48         const TUint8& aRegType , 
       
    49         const TUint8& aAutoType)
       
    50             :iIsExpired(EFalse),
       
    51                 iCount(-1),
       
    52                 iCountReg(1),
       
    53                 iPermType(aPermType),
       
    54                 iRegType(aRegType),
       
    55                 iAutoType(aAutoType)
       
    56     {
       
    57     TTimeIntervalYears years(KTimeIntervalYears);
       
    58     iEndTime.HomeTime();
       
    59     iEndTime += years;
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CEndTimeBased::ConstructL
       
    64 // Symbian 2nd phase constructor can leave.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CEndTimeBased::ConstructL(const TDesC8& aUri)
       
    68     {
       
    69     iUri = HBufC8::NewL( aUri.Length() );
       
    70     *iUri = aUri;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CEndTimeBased::NewL
       
    75 // Two-phased constructor.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CEndTimeBased* CEndTimeBased::NewL( 
       
    79             const TDesC8& aUri , 
       
    80             const TUint8& aPermType , 
       
    81             const TUint8& aRegType , 
       
    82             const TUint8& aAutoType )
       
    83     {
       
    84     CEndTimeBased* self = 
       
    85         new( ELeave ) CEndTimeBased(aPermType , aRegType , aAutoType);
       
    86     
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL(aUri);
       
    89     CleanupStack::Pop(self);
       
    90 
       
    91     return self;
       
    92     }
       
    93 
       
    94     
       
    95 // Destructor
       
    96 CEndTimeBased::~CEndTimeBased()
       
    97     {
       
    98     delete iUri;
       
    99     }
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CEndTimeBased::SetIsExpired
       
   104 // set whether the content rights is expired
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CEndTimeBased::SetIsExpired( TBool aIsExpired )
       
   108     {
       
   109     iIsExpired = aIsExpired;
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CEndTimeBased::SetIsExpired
       
   115 // check if the content rights is expired
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 TBool CEndTimeBased::IsExpired() const 
       
   119     {
       
   120     return iIsExpired;
       
   121     }
       
   122 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CEndTimeBased::SetCount
       
   126 // Set the value of count
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CEndTimeBased::SetCount( TInt8 aCount )
       
   130     {
       
   131     iCount = aCount;
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CEndTimeBased::IncreaseCount
       
   136 // Set the value of count
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CEndTimeBased::IncreaseCount()
       
   140     {
       
   141     iCount++;
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CEndTimeBased::Count
       
   146 // get the value of count
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 TInt8 CEndTimeBased::Count() const
       
   150     {
       
   151     return iCount;
       
   152     }
       
   153 
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CEndTimeBased::DecreaseRegTimes
       
   157 // Set the value of registered times
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void CEndTimeBased::DecreaseRegTimes()
       
   161     {
       
   162     iCountReg--;
       
   163     }
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CEndTimeBased::IncreaseRegTimes
       
   167 // Set the value of registered times
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void CEndTimeBased::IncreaseRegTimes()
       
   171     {
       
   172     iCountReg++;
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CEndTimeBased::SetRegTimes
       
   177 // Set the value of count
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CEndTimeBased::SetRegTimes( TInt aRegTimes )
       
   181     {
       
   182     iCountReg = aRegTimes;
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // CEndTimeBased::RegTimes
       
   187 // get the value of registered times
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 TInt CEndTimeBased::RegTimes() const
       
   191     {
       
   192     return iCountReg;
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CEndTimeBased::RegType
       
   197 // get the value of register type
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 TUint8 CEndTimeBased::RegType() const
       
   201     {
       
   202     return iRegType;
       
   203     }
       
   204     
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CEndTimeBased::AutoType
       
   208 // get the value of automated content type
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 TUint8 CEndTimeBased::AutoType() const
       
   212     {
       
   213     return iAutoType;
       
   214     }
       
   215     
       
   216 // -----------------------------------------------------------------------------
       
   217 // CEndTimeBased::PermType
       
   218 // get the value of permission type
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 TUint8 CEndTimeBased::PermType() const 
       
   222     {
       
   223     return iPermType;
       
   224     }    
       
   225     
       
   226 // -----------------------------------------------------------------------------
       
   227 // CEndTimeBased::SetEndTime
       
   228 // Set the value of end time
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 void CEndTimeBased::SetEndTime( TTime aEndTime )
       
   232     {
       
   233     iEndTime = aEndTime;
       
   234     }
       
   235 
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CEndTimeBased::EndTime
       
   239 // get the value of end time
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 TTime CEndTimeBased::EndTime() const
       
   243     {
       
   244     return iEndTime;
       
   245     }
       
   246 
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CEndTimeBased::EndTime
       
   250 // get the value of content uri
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 HBufC8* CEndTimeBased::Uri() const
       
   254     {
       
   255     return iUri;      
       
   256     }
       
   257 
       
   258 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   259 
       
   260 //  End of File