pressrv_plat/authorization_api/inc/cpresencexdm.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 is primary class for Presence XDM
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __PRESENCEXDM_H__
       
    21 #define __PRESENCEXDM_H__
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32base.h>
       
    25 #include <badesca.h>
       
    26 #include <rlspresxdmconsts.h>
       
    27 
       
    28 #include "prescondidentityone.h"
       
    29 #include "prescondidentitymany.h"
       
    30 #include "prescondmisc.h"
       
    31 #include "prescondvalidity.h"
       
    32 #include "prescondsphere.h"
       
    33 #include "presenceactionxdm.h"
       
    34 #include "presencetransformxdm.h"
       
    35 
       
    36 // Forward declarations
       
    37 class MRLSPresXDMAsyncHandler;
       
    38 class CXdmDocumentNode;
       
    39 class CXdmProtocolInfo;
       
    40 class CXdmEngine;
       
    41 class CXdmDocument;
       
    42 
       
    43 // Class declaration
       
    44 /** 
       
    45 * This class deals with the Presence rules as a whole and has communication
       
    46 *  with the server. Rules can be manipulated using this class, however the 
       
    47 *  three childrens of rule namely condition, action and transform manipulation
       
    48 *  also requires their respective classes in conjunction with this class.
       
    49 *  
       
    50 *  @lib rlspresxdm.lib
       
    51 *  @since S60 3.2
       
    52 */
       
    53 class CPresenceXDM : public CActive
       
    54     {
       
    55     public:
       
    56         
       
    57         /**
       
    58         * Create CPresenceXDM
       
    59         *
       
    60         * @param TInt XDMSettingsList ID, see XDMSettingsApi.h for more info
       
    61         * @return Pointer to created CPresenceXDM
       
    62         */
       
    63         IMPORT_C static CPresenceXDM* NewL(const TInt aSettingId);
       
    64         
       
    65         /**
       
    66         * Create CPresenceXDM, leaves pointer to stack
       
    67         *
       
    68         * @param TInt XDMSettingsList ID, see XDMSettingsApi.h for more info
       
    69         * @return Pointer to created CPresenceXDM, pushed on cleanup stack
       
    70         */
       
    71         IMPORT_C static CPresenceXDM* NewLC( const TInt aSettingId );
       
    72 
       
    73         
       
    74         /**
       
    75         * Updates information (document) to server. This results in
       
    76         * HandlePresUpdateDocumentL on completion.
       
    77         *
       
    78         * @param aHandler, pointer to MRLSPresXDMAsyncHandler callback handler
       
    79         * @return Error code, KErrAlreadyExist if some async already going on
       
    80         */
       
    81         IMPORT_C TInt UpdateToServerL(MRLSPresXDMAsyncHandler* const aHandler);
       
    82         
       
    83         /**
       
    84         * Updates all information (document) from server. This results in
       
    85         * HandlePresUpdateDocumentL on completion.
       
    86         *
       
    87         * @param aHandler, pointer to MRLSPresXDMAsyncHandler callback handler
       
    88         * @return Error code, KErrAlreadyExist if some async already going on
       
    89         */
       
    90         IMPORT_C TInt UpdateAllFromServerL(MRLSPresXDMAsyncHandler* const aHandler);
       
    91         
       
    92         /**
       
    93         * Cancels document update to/from server if going on. This results in
       
    94         * HandlePresUpdateCancelL on completion.
       
    95         */
       
    96         IMPORT_C void CancelUpdateL();
       
    97         
       
    98         /**
       
    99         * Gets all rule IDs in an array
       
   100         *
       
   101         * @param CDesCArray& aRuleIds, reference to rule IDs
       
   102         */
       
   103         IMPORT_C void GetAllRulesL(CDesCArray& aRuleIds);
       
   104         
       
   105         /**
       
   106         * Delete Rule and associated coditions/actions/transforms
       
   107         *
       
   108         * @param TDesC& aRuleId rule ID
       
   109         * @return KErrNotFound if not found. System wide error codes
       
   110         */
       
   111         IMPORT_C TInt DeleteRuleL(const TDesC& aRuleId);
       
   112         
       
   113         /**
       
   114         * Add a new rule. If aRuleId contains a valid descriptor it is used as
       
   115         * rule id for the new rule. If a NULL descriptor is provided instead,
       
   116         * a random id is generated automatically and returned in aRuleId. 
       
   117         * The new rule is created without condition, action or transformation.
       
   118         * Those elements can be created using their respective classes.
       
   119         *
       
   120         * @param TDesC& aRuleId, if provided treated as rule id. Otherwise a
       
   121         /  random rule id is created and returned.
       
   122         * @return Error code, KErrAlreadyExists, KErrNone, KErrNotFound if
       
   123         *  document root doesnt found.
       
   124         */
       
   125         IMPORT_C TInt CreateNewRuleL(TDes& aRuleId);
       
   126         
       
   127         /**
       
   128         * Finds if a Rule Exist
       
   129         *
       
   130         * @param TDesC& aRuleId rule ID
       
   131         * @return TBool if rule exist
       
   132         */
       
   133         IMPORT_C TBool IsRuleExist(const TDesC& aRuleId);
       
   134         
       
   135         /**
       
   136         * Delete all data by deleting all rules and their children
       
   137         */
       
   138         IMPORT_C void DeleteAllRules();
       
   139         
       
   140         /**
       
   141         * Deletes all rules which are empty
       
   142         */
       
   143         IMPORT_C void DeleteEmptyRulesL();
       
   144         
       
   145 
       
   146         /**
       
   147         * From CActive
       
   148         *
       
   149         */
       
   150         void DoCancel();
       
   151         
       
   152         /**
       
   153         * From CActive
       
   154         *
       
   155         */
       
   156         void RunL();
       
   157         
       
   158         /**
       
   159         * From CActive
       
   160         *
       
   161         */
       
   162         TInt RunError(TInt aError);
       
   163         
       
   164         /**
       
   165         * Destructor
       
   166         *
       
   167         */
       
   168         ~CPresenceXDM();
       
   169         
       
   170         /**
       
   171         * Friend classes
       
   172         *
       
   173         */
       
   174         friend class TPresenceActionXDM;
       
   175         friend class TPresenceTransformXDM;
       
   176         friend class TPresCondIdentityOne;
       
   177         friend class TPresCondIdentityMany;
       
   178         friend class TPresCondSphere;
       
   179         friend class TPresCondValidity;
       
   180         friend class TPresCondMisc;
       
   181         
       
   182 
       
   183         
       
   184     protected:
       
   185     
       
   186         /**
       
   187         * Removes given node from document model
       
   188         *
       
   189         * @param CXdmDocumentNode* aNode
       
   190         */
       
   191         void RemoveFromModelL( CXdmDocumentNode* aNode );
       
   192         
       
   193        
       
   194     private:
       
   195 
       
   196         /**
       
   197         * Second phase constructor
       
   198         *
       
   199         * @param TInt XDMSettingsList ID
       
   200         */
       
   201         void ConstructL(const TInt aSettingId );
       
   202         
       
   203         /**
       
   204         * C++ constructor
       
   205         *
       
   206         * @param none
       
   207         * @return none
       
   208         */
       
   209         CPresenceXDM();
       
   210         
       
   211         /**
       
   212         * Creates the document root if needed
       
   213         */
       
   214         void CreateRootIfNeededL();
       
   215         
       
   216         /**
       
   217         * Finds if a Rule Exist, returns its pointer
       
   218         *
       
   219         * @param TDesC& aRuleId rule ID
       
   220         * @return CXdmDocumentNode if rule exist
       
   221         */
       
   222         CXdmDocumentNode* IsRuleExistInt(const TDesC& aRuleId);
       
   223         
       
   224         /**
       
   225         * Gets the condition, action or transform node. It is
       
   226         * caller's responsiblity to provide a valid child name.
       
   227         *
       
   228         * @param TDesC& aRuleId rule ID.
       
   229         * @param aRuleChild child node of a rule
       
   230         * @param TBool aCreate if ETrue, creates child node if not exist
       
   231         * @return CXdmDocumentNode* pointer to rule child node or NULL
       
   232         */
       
   233         CXdmDocumentNode* GetRuleChildNodeL(const TDesC& aRuleId, 
       
   234                                 const TDesC& aRuleChild, TBool aCreate);
       
   235 
       
   236         /**
       
   237         * Gets the conditions child node pointer in a rule. It is
       
   238         * caller's responsiblity to provide a valid child name.
       
   239         *
       
   240         * @param TDesC& aRuleId rule ID.
       
   241         * @param aCondChild child node of condition
       
   242         * @param TBool aCreate if ETrue, creates child node if not exist
       
   243         * @return CXdmDocumentNode* pointer to condition child node or NULL
       
   244         */
       
   245         CXdmDocumentNode* GetConditionChildNodeL(const TDesC& aRuleId,
       
   246                                 const TDesC& aCondChild, TBool aCreate);
       
   247         
       
   248         /**
       
   249         * Gets a unique rule id
       
   250         *
       
   251         * @param TDesC& aRuleId unique rule id
       
   252         */
       
   253         void GetUniqueRuleId(TDes& aRuleId);
       
   254         
       
   255     private: // data
       
   256         
       
   257         CXdmProtocolInfo*       iXDMProtocolInfo;
       
   258         CXdmEngine*             iXDMEngine;
       
   259         CXdmDocument*           iPresDocument;
       
   260         TInt                    iAsyncReq;
       
   261         MRLSPresXDMAsyncHandler* iAsyncHandler;
       
   262 
       
   263     };
       
   264     
       
   265 #endif //__PRESENCEXDM_H__
       
   266         
       
   267