pressrv_plat/authorization_api/inc/prescondvalidity.h
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2006 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:    RLS and Presence XDM, This class represents Presence Condition
       
    15 *  validity part.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __PRESCONDVALIDITY_H__
       
    22 #define __PRESCONDVALIDITY_H__
       
    23 
       
    24 // Includes
       
    25 #include <e32std.h>
       
    26 #include <e32base.h>
       
    27 #include <badesca.h>
       
    28 #include <rlspresxdmconsts.h>
       
    29 
       
    30 // Forward declarations
       
    31 class CPresenceXDM;
       
    32 class CXdmDocumentNode;
       
    33 
       
    34 // Class declaration
       
    35 /** 
       
    36 * This class should be used in conjunction with an already created CPresenceXDM.
       
    37 *  The CPresenceXDM deals with the Presence rules as a whole and has communication
       
    38 *  with the server.
       
    39 *  TPresCondValidity is used to manipulate the validity part of Condition in a rule. 
       
    40 *  Remember to call Init function after constructing this object.
       
    41 *  
       
    42 *  @lib rlspresxdm.lib
       
    43 *  @since S60 3.2
       
    44 */
       
    45 class TPresCondValidity
       
    46     {
       
    47     public:
       
    48     
       
    49         /**
       
    50         * C++ Constructor, After contructing Init must be called before using
       
    51         * this object.
       
    52         */                                        
       
    53         IMPORT_C TPresCondValidity();
       
    54         
       
    55         /**
       
    56         * Initializes the object with the given pointer to CPresenceXDM.
       
    57         * This function must be called before using other functions.
       
    58         *
       
    59         * @param CPresenceXDM* pointer to created CPresenceXDM
       
    60         * @return none
       
    61         */
       
    62         IMPORT_C void Init(CPresenceXDM* const aPresXDM);
       
    63         
       
    64         /**
       
    65         * Gets condition validity values from a rule
       
    66         *
       
    67         * @param TDesC& aRuleID rule ID.
       
    68         * @param RArray<TTimePeriod>& returned array of valid times in local time.
       
    69         * @return TInt KErrNone, KErrNotFound if rule doesnt found or none
       
    70         *   of validities found
       
    71         */
       
    72         IMPORT_C TInt GetValidityL(const TDesC& aRuleID, 
       
    73                                         RArray<TTimePeriod>& aValidTimes);
       
    74                                         
       
    75         /**
       
    76         * Deletes condition validity values from a rule
       
    77         *
       
    78         * @param TDesC& aRuleID rule ID.
       
    79         * @return TInt KErrNone, KErrNotFound if rule doesnt found.
       
    80         */
       
    81         IMPORT_C TInt DeleteAllValidityL(const TDesC& aRuleID);
       
    82         
       
    83         /**
       
    84         * Adds condition validity to a rule
       
    85         *
       
    86         * @param TDesC& aRuleID rule ID.
       
    87         * @param TTimePeriod valid time to be added. In local time.
       
    88         * @return TInt KErrNone, KErrNotFound if rule doesnt found.
       
    89         */
       
    90         IMPORT_C TInt AddValidityL(const TDesC& aRuleID, 
       
    91                                                 const TTimePeriod aValidTime);
       
    92                                                 
       
    93         /**
       
    94         * Checks if rule is valid for given time
       
    95         *
       
    96         * @param TDesC& aRuleID rule ID.
       
    97         * @param TTimePeriod valid time to be checked, in local time
       
    98         * @return ETrue if given time is a subset of valid times in a rule
       
    99         */
       
   100         IMPORT_C TBool IsTimeValidL(const TDesC& aRuleID, 
       
   101                                                 const TTimePeriod aTime);
       
   102                                                 
       
   103     private:
       
   104     
       
   105         /**
       
   106         * Gets the Validity node pointer in a rule
       
   107         *
       
   108         * @param TDesC& aRuleID rule ID.
       
   109         * @param TBool aCreate if ETrue, creates Validity node if not exist
       
   110         * @return CXdmDocumentNode* pointer to Validity node or NULL
       
   111         */
       
   112         CXdmDocumentNode* GetValidityNodeL(const TDesC& aRuleID, 
       
   113                                                         TBool aCreate);
       
   114 
       
   115         /**
       
   116         * Parse from XML time string to TTime
       
   117         *
       
   118         * @param TDesC& aXMLTimeString, XML time string to parse
       
   119         * @param TTime& aDateTime, returned here in TTime format
       
   120         * @return error code
       
   121         */
       
   122         TInt ParseFromXMLTimeString(const TDesC& aXMLTimeString, 
       
   123                                                           TTime& aDateTime);
       
   124                                                           
       
   125         /**
       
   126         * Parse to XML time string from TTime
       
   127         *
       
   128         * @param TDes& aXMLTimeString, retuned XML time string
       
   129         * @param TTime aDateTime, input TTime
       
   130         * @return error code
       
   131         */
       
   132         TInt FormatToXMLTimeStringL(TDes& aXMLTimeString, const TTime aDateTime);
       
   133         
       
   134         /**
       
   135         * Convert local time to universal time
       
   136         *
       
   137         * @param TTime& aLocalDateTime, coverted to universal TTime
       
   138         * @return none
       
   139         */
       
   140         void ConvertToUniversal(TTime& aLocalDateTime);
       
   141         
       
   142         /**
       
   143         * Convert universal time to local time
       
   144         *
       
   145         * @param TTime& aUniversalDateTime, coverted to local TTime
       
   146         * @return none
       
   147         */
       
   148         void ConvertToLocal(TTime& aUniversalDateTime);
       
   149         
       
   150 
       
   151         /**
       
   152         * Logs Given dateTime
       
   153         *
       
   154         * @param TDateTime aDateTime date time to log
       
   155         * @return None
       
   156         */
       
   157         void LogDateTime(TDateTime aDateTime);
       
   158 
       
   159     private: // data
       
   160         
       
   161         // Pointer to CPresenceXDM - not owned
       
   162         CPresenceXDM*           iPresXDM;      // not owned
       
   163         
       
   164     };
       
   165     
       
   166    
       
   167 #endif //__PRESCONDVALIDITY_H__
       
   168