simpleengine/presencedm/inc/presencedmadapter.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:    OMA Presence Settings Device Management Adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __PRESDMADAPTER_H__
       
    22 #define __PRESDMADAPTER_H__
       
    23 
       
    24 // Non-local includes
       
    25 #include <e32base.h>
       
    26 #include <smldmadapter.h>
       
    27 #include <pressettingsapi.h>
       
    28 
       
    29 // LITERALS
       
    30 _LIT8(KPresDMDDFVersion, "1.0");
       
    31 
       
    32 _LIT8(KPresDMIdentifier, "org.openmobilealliance/1.0/PRESENCE");
       
    33 _LIT8(KPresDMNodeName, "OMA_PRESENCE");
       
    34 
       
    35 // OMA Presence DM leaves
       
    36 _LIT8(KPresDMName, "NAME");
       
    37 _LIT8(KPresDMProviderId, "PROVIDER-ID");
       
    38 _LIT8(KPresDMClientObjDataLim, "CLIENT-OBJ-DATA-LIMIT");
       
    39 _LIT8(KPresDMContentSrvUri, "CONTENT-SERVER-URI");
       
    40 _LIT8(KPresDMSrcThPublish, "SOURCE-THROTTLE-PUBLISH");
       
    41 _LIT8(KPresDMMaxPresSubs, "MAX-NUMBER-OF-PRESENCE-SUBSCRIPTIONS");
       
    42 _LIT8(KPresDMMaxPresSubsInLists, "MAX-NUMBER-OF-SUBSCRIPTIONS-IN-PRESENCE-LIST");
       
    43 _LIT8(KPresDMServiceUriTemp, "SERVICE-URI-TEMPLATE");
       
    44 
       
    45 // For holding additional S60 Presence leaves
       
    46 _LIT8(KPresDMToConRef, "ToConRef");
       
    47 _LIT8(KPresDMConRef, "ConRef");
       
    48 
       
    49 // S60 additional leaves
       
    50 _LIT8(KPresDMSIPProfile, "SIP-PROFILE");
       
    51 _LIT8(KPresDMXDMSet, "XDM-SET");
       
    52 
       
    53 // Descriptions
       
    54 _LIT8(KPresDMNodeNameDescription, "This interior node acts as a placeholder for one or more accounts for a fixed node" );
       
    55 _LIT8(KPresDMNameDescription, "User displayable name for the presence enabler");
       
    56 _LIT8(KPresDMProviderIdDescription, "An identifier for the Presence application service access point");
       
    57 _LIT8(KPresDMClientObjDataLimDescription, "Limits the size of the MIME object data to the specified value in bytes when PUBLISH and NOTIFY methods are used in the presence client");
       
    58 _LIT8(KPresDMContentSrvUriDescription, "Defines the HTTP URI of the content server to be used for content indirection");
       
    59 _LIT8(KPresDMSrcThPublishDescription, "Defines the minimum time interval (in seconds) between two consecutive publications from a Presence source");
       
    60 _LIT8(KPresDMMaxPresSubsDescription, "Limits the total number of presence subscriptions");
       
    61 _LIT8(KPresDMMaxPresSubsInListsDescription, "Limits the number of back-end subscriptions allowed for presence list");
       
    62 _LIT8(KPresDMServiceUriTempDescription, "Defines the syntax of the service URI, in the form of a URI Template as specified in XDM Core Specification [XDMSPEC] subclause C.1");
       
    63 
       
    64 _LIT8(KPresDMToConRefDescription, "Refers to a collection of connectivity definitions" );
       
    65 _LIT8(KPresDMConRefDescription, "Indicates the linkage to connectivity parameters" );
       
    66 
       
    67 _LIT8(KPresDMSIPProfileDescription, "SIP profile used");
       
    68 _LIT8(KPresDMXDMSetDescription, "XDM settings set used");
       
    69 
       
    70 _LIT8(KPresDmDynamicDescription, "Placeholder for one or more connectivity parameters");
       
    71 
       
    72 
       
    73 // other constants
       
    74 _LIT8(KPresDMTextPlain, "text/plain" );
       
    75 _LIT8(KPresDMSeparator, "/" );
       
    76 _LIT( KPresDMOpenBrack,    "(" );
       
    77 _LIT( KPresDMCloseBrack,   ")" );
       
    78 
       
    79 _LIT8(KPresDMSipLinkPrefix, "./SIP");
       
    80 _LIT8(KPresDMSipIdPrefix, "SIPId");
       
    81 
       
    82 _LIT8(KPresDMSipDMNode, "SIP"); // as specified in OMA SIP
       
    83 _LIT8(KPresDMXdmDMNode, "OMA_XDM"); // as specified in OMA XDM
       
    84 
       
    85 // CONSTANTS
       
    86 const TInt KPresDMLogBufferMaxSize    = 2000;
       
    87 const TInt KPresDMDefaultResultSize = 255;
       
    88 const TInt KPresDMLevel = 2;
       
    89 const TInt KPresDMHexLength = 8;
       
    90 const TUint8 KPresDMObjectSizeWidth = 4;
       
    91 const TUint8 KPresDMSeparatorDef = 0x2f; // forward slash
       
    92 const TInt KPresDMMaxIntLength = 10;     // max length of 32bit integer
       
    93 const TInt KPresSipIdLinkLength = 19;
       
    94 
       
    95 /**
       
    96 * The main class of the OMA Presence DM adapter. Handles
       
    97 * requests of fetching and updating settings sets and 
       
    98 * settings items.
       
    99 *
       
   100 * @since S60 3.2
       
   101 */
       
   102 class CPresenceDMAdapter : public CSmlDmAdapter
       
   103     {
       
   104     public:
       
   105     
       
   106         /**
       
   107         * Symbian first phase constructor
       
   108         *
       
   109         * @since S60 3.2
       
   110         * @param MSmlDmCallback* aDmCallback
       
   111         * @return pointer to newly created CPresenceDMAdapter
       
   112         */
       
   113         static CPresenceDMAdapter* NewL( MSmlDmCallback* aDmCallback );
       
   114 
       
   115         /**
       
   116         * Destructor
       
   117         */
       
   118         ~CPresenceDMAdapter();
       
   119         
       
   120         // Adapter interface from CSmlDmAdapter, see CSmlDmAdapter
       
   121         void DDFVersionL(CBufBase& aDDFVersion);
       
   122         void DDFStructureL(MSmlDmDDFObject& aDDF);
       
   123         void UpdateLeafObjectL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   124                                 const TDesC8& aObject, const TDesC8& aType, 
       
   125                                 TInt aStatusRef);
       
   126         void DeleteObjectL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   127                             const TInt aStatusRef); 
       
   128         void FetchLeafObjectL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   129                                const TDesC8& aType, const TInt aResultsRef, 
       
   130                                const TInt aStatusRef); 
       
   131         void ChildURIListL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   132                             const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
       
   133                             const TInt aResultsRef, const TInt aStatusRef);
       
   134         void AddNodeObjectL(const TDesC8& aUri, const TDesC8& aParentLUID, 
       
   135                              const TInt aStatusRef);
       
   136         void UpdateLeafObjectL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   137                                 RWriteStream*& aStream, const TDesC8& aType, 
       
   138                                 const TInt aStatusRef);
       
   139         void FetchLeafObjectSizeL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   140                                    const TDesC8& aType, const TInt aResultsRef, 
       
   141                                    const TInt aStatusRef);
       
   142         void ExecuteCommandL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   143                               const TDesC8& aArgument, const TDesC8& aType, 
       
   144                               const TInt aStatusRef);
       
   145         void ExecuteCommandL(const TDesC8& aUri, const TDesC8& aLUID, 
       
   146                               RWriteStream*& aStream, const TDesC8& aType, 
       
   147                               const TInt aStatusRef);
       
   148         void CopyCommandL(const TDesC8& aTargetURI, const TDesC8& aTargetLUID, 
       
   149                            const TDesC8& aSourceURI, const TDesC8& aSourceLUID, 
       
   150                            const TDesC8& aType, TInt aStatusRef);
       
   151         void StartAtomicL();
       
   152         void CommitAtomicL();
       
   153         void RollbackAtomicL();
       
   154         TBool StreamingSupport(TInt& aItemSize);
       
   155         void StreamCommittedL();
       
   156         void CompleteOutstandingCmdsL();
       
   157 
       
   158     private:
       
   159 
       
   160         /**
       
   161          * Default constructor
       
   162          *
       
   163          * @since S60 3.2
       
   164          * @param   aDmCallback Pointer to callback interface 
       
   165          */
       
   166         CPresenceDMAdapter( MSmlDmCallback* aDmCallback );
       
   167 
       
   168         /**
       
   169         * Fetches an object from the given uri
       
   170         *
       
   171         * @since S60 3.2
       
   172         * @param aUri Uri to the fetched object
       
   173         * @param aObject The result is inserted to this buffer
       
   174         * @return Error code
       
   175         */
       
   176         CSmlDmAdapter::TError FetchObjectL(const TDesC8& aUri, CBufBase& aObject);
       
   177 
       
   178         /**
       
   179         * Updates the parameters of given DDF node
       
   180         *
       
   181         * @since S60 3.2
       
   182         * @param aNode The node to update.
       
   183         * @param aAccTypes Access types of the node.
       
   184         * @param aOccurrence Occurrance of the node.
       
   185         * @param aScope Scope of the node.
       
   186         * @param aFormat Format of the node.
       
   187         * @param aDescription A description of the node.   
       
   188         */
       
   189         void FillNodeInfoL(MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes,
       
   190                             MSmlDmDDFObject::TOccurence aOccurrence, 
       
   191                             MSmlDmDDFObject::TScope aScope, 
       
   192                             MSmlDmDDFObject::TDFFormat aFormat,
       
   193                             const TDesC8& aDescription);
       
   194 
       
   195         /**
       
   196         * Get property from settings storage
       
   197         *
       
   198         * @since S60 3.2
       
   199         * @param aSetId unique id of the settings set
       
   200         * @param aProperty type of asked property
       
   201         * @param aObject returns property value
       
   202         * @return CSmlDmAdapter::EOk if successfull
       
   203         */
       
   204         CSmlDmAdapter::TError GetPropertyL( TInt aSetId, 
       
   205                                             TPresSettingsProperty aProperty, 
       
   206                                             CBufBase& aObject );
       
   207 
       
   208         /**
       
   209         * Create/update settings property
       
   210         *
       
   211         * @since S60 3.2
       
   212         * @param aSetId unique id of the settings set
       
   213         * @param aProperty type of property
       
   214         * @param aObject property value
       
   215         * @return CSmlDmAdapter::EOk if successfull
       
   216         */
       
   217         CSmlDmAdapter::TError UpdatePropertyL( TInt aSetId, 
       
   218                                                TPresSettingsProperty aProperty, 
       
   219                                                const TDesC8& aObject );
       
   220         
       
   221         /**
       
   222         * Compares strings
       
   223         *
       
   224         * @since S60 3.2
       
   225         * @param aLeft first string
       
   226         * @param aRight second string
       
   227         * @return True if the strings are identical
       
   228         */
       
   229         TBool Match( const TDesC8& aLeft, const TDesC8& aRight );
       
   230         
       
   231         /**
       
   232         * Finds uri based on SIP id, updates result
       
   233         *
       
   234         * @since S60 3.2
       
   235         * @param aSipID SIP ID
       
   236         * @param aObject object to be updated
       
   237         * @return Ok or Error
       
   238         */
       
   239         CPresenceDMAdapter::TError GetConRefFromSipIDL( TInt aSipID,
       
   240                                                CBufBase& aObject );
       
   241                                                
       
   242         /**
       
   243         * Finds uri based on XDM id, updates result
       
   244         *
       
   245         * @since S60 3.2
       
   246         * @param aXdmID XDM ID
       
   247         * @param aObject object to be updated
       
   248         * @return Ok or Error
       
   249         */
       
   250         CPresenceDMAdapter::TError GetConRefFromXdmIDL( TInt aXdmID,
       
   251                                                CBufBase& aObject );
       
   252                                                
       
   253         /**
       
   254         * Find SIP id based on uri
       
   255         *
       
   256         * @since S60 3.2
       
   257         * @param aUri uri of the wanted object
       
   258         * @return SIP id or KErrNotFound
       
   259         */  
       
   260         TInt GetSipIdFromConRefL(const TDesC8& aUri );
       
   261         
       
   262         /**
       
   263         * Find XDM id based on uri
       
   264         *
       
   265         * @since S60 3.2
       
   266         * @param aUri uri of the wanted object
       
   267         * @return XDM id or KErrNotFound
       
   268         */  
       
   269         TInt GetXdmIdFromConRefL(const TDesC8& aUri );
       
   270         
       
   271         /**
       
   272         * Finds whether the given persence id is valid or not
       
   273         *
       
   274         * @since S60 3.2
       
   275         * @param aSetId presence id to check
       
   276         * @return ETrue if valid
       
   277         */  
       
   278         TBool IsPresIDValidL(TInt aSetId);
       
   279         
       
   280         /**
       
   281         * Check presence settings duplicate names, provides alternate name
       
   282         *  if necessary
       
   283         *
       
   284         * @since S60 3.2
       
   285         * @param aSetId presence id
       
   286         * @param aSetName presence set name needs to be checked, 
       
   287         *   alternate name returns here
       
   288         * @return none
       
   289         */  
       
   290         void CheckDuplicateNameL(TDes& aSetName, const TInt& aSetId);
       
   291         
       
   292         /**
       
   293         * sets the proper length of presence settings discriptor items,
       
   294         * give shorter descriptor if necessary
       
   295         *
       
   296         * @since S60 3.2
       
   297         * @param aValue presence settings descriptor item to be evaluated
       
   298         * @param aProp which property this descriptor belongs to.
       
   299         * @return ETrue if name is validated, EFalse if it cant be validated
       
   300         */  
       
   301         TBool SetProperLength(TPresSettingsProperty aProp, TPtr& aValue); 
       
   302         
       
   303         /** 
       
   304         * Checks if there is ordinal numbering at the end of
       
   305         * descriptor and rips it off if there is.
       
   306         *
       
   307         * @param aName pointer to source descriptor
       
   308         * @return HBufC* containing the name ready for the numbering
       
   309         */
       
   310         HBufC* GetPrefixL( HBufC* aName );
       
   311         
       
   312         /**
       
   313         * 8 bit descriptor to integer
       
   314         *
       
   315         * @since S60 3.2
       
   316         * @param aLuid Descriptor to convert
       
   317         * @return TInt converted integer
       
   318         */
       
   319         TInt DesToInt( const TDesC8& aLuid ) const;
       
   320         
       
   321         /**
       
   322         * Integer to 8 bit descriptor, leaves pointer to stack
       
   323         *
       
   324         * @since S60 3.2
       
   325         * @param aLuid Integer to convert
       
   326         * @return HBufC8* 8 bit heap pointer to descriptor
       
   327         */        
       
   328         HBufC8* IntToDes8LC( const TInt aLuid ) const;
       
   329         
       
   330         /**
       
   331         * Integer to 16 bit descriptor, leaves pointer to stack
       
   332         *
       
   333         * @since S60 3.2
       
   334         * @param aLuid Integer to convert
       
   335         * @return HBufC* 16 bit heap pointer to descriptor
       
   336         */        
       
   337         HBufC* IntToDesLC( const TInt aLuid ) const;
       
   338         
       
   339         /**
       
   340         * 16 bit descriptor to 8 bit descriptor, leaves pointer to stack
       
   341         *
       
   342         * @since S60 3.2
       
   343         * @param aSource 16 bit descriptor to convert
       
   344         * @return HBufC8* pointer to 8 bit heap descriptor
       
   345         */        
       
   346         HBufC8* ConvertLC(const TDesC& aSource) const;
       
   347         
       
   348         /**
       
   349         * 8 bit descriptor to 16 bit descriptor, leaves pointer to stack
       
   350         *
       
   351         * @since S60 3.2
       
   352         * @param aSource 8 bit descriptor to convert
       
   353         * @return HBufC* pointer to 16 bit heap descriptor
       
   354         */        
       
   355         HBufC* ConvertLC(const TDesC8& aSource) const;
       
   356         
       
   357     private: // Data
       
   358     
       
   359         /**
       
   360         * Settings ID of presence set which is in cache
       
   361         */
       
   362         TInt iGetSetID;
       
   363         
       
   364         /**
       
   365         * Presence set which is in cache
       
   366         */
       
   367         TPresSettingsSet iGetSet;
       
   368 
       
   369     };
       
   370 
       
   371 #endif // __PRESDMADAPTER_H__
       
   372 
       
   373 // End of File