customization/supadapter/inc/supadapter.h
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     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:  DM Startup Adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __NSMLSUPADAPTER_H__
       
    21 #define __NSMLSUPADAPTER_H__
       
    22 
       
    23 // ------------------------------------------------------------------------------------------------
       
    24 // Includes
       
    25 // ------------------------------------------------------------------------------------------------
       
    26 // symbian
       
    27 #include <e32base.h>
       
    28 #include <smldmadapter.h>
       
    29 // s60
       
    30 #include "TARMDmStreamAdapter.h"
       
    31 #include "UISettingsSrvClient.h"
       
    32 //#ifdef __SAP_POLICY_MANAGEMENT
       
    33 #include <PolicyEngineClient.h>
       
    34 //#endif
       
    35 
       
    36 const TUint KNSmlDMSUPAdapterImplUid = 0x10207822;
       
    37 
       
    38 // the DDF version must be changed if any changes in DDF structure ( built in DDFStructureL() function )
       
    39 _LIT8( KNSmlSUPDDFVersion, "1.0" ); 
       
    40 
       
    41 _LIT8( KNSmlSUPTextPlain, "text/plain" );
       
    42 _LIT8( KNSmlSUPNodeName, "Apps" );
       
    43 _LIT8( KNSmlSUPDescription, "This node is the common parent to all customization objects." );
       
    44 _LIT8( KNSmlSUPStartupNodeDescription, "Startup is a common parent node to nodes customizing startup functionality");
       
    45 _LIT8( KNSmlSUPWelcomeDataNodeDescription, "Image node stores the WelcomeData (image or text) as binary data, and its runtime Type determines the interpretation");
       
    46 _LIT8( KNSmlSUPWelcomeTextNodeDescription, "Text node stores the Welcome Text");
       
    47 
       
    48 _LIT8( KNSmlSUPDynamicNode, "" );
       
    49 _LIT8( KNSmlSUPWelcomeDataNodeName, "Data" );
       
    50 _LIT8( KNSmlSUPWelcomeTextNodeName, "Text" );
       
    51 _LIT8( KNSmlSUPStartupNodeName, "Startup" );
       
    52 _LIT8( KNSmlCustomizationNodeName, "Customization" );
       
    53 _LIT8( KNSmlSUPImage8, "WelcomeData" );
       
    54 _LIT8( KNSmlSUPStartup8, "Startup" );
       
    55 _LIT8( KNSmlCustomizationNodeName8, "Customization" );
       
    56 
       
    57 //
       
    58 // Policies:
       
    59 //
       
    60 #define SUPADAPTER_POLICY1_SUBJECT_P1 "urn:oasis:names:tc:xacml:2.0:subject:role_id"
       
    61 #define SUPADAPTER_POLICY1_SUBJECT_P2 ""
       
    62 #define SUPADAPTER_POLICY1_SUBJECT_P3 "http://www.w3.org/2001/XMLSchema#string"
       
    63 #define SUPADAPTER_POLICY1_RESOURCE_P1 "urn:oasis:names:tc:xacml:2.0:resource:resource_id"
       
    64 #define SUPADAPTER_POLICY1_RESOURCE_P2 "CustomizationManagement"
       
    65 #define SUPADAPTER_POLICY1_RESOURCE_P3 "http://www.w3.org/2001/XMLSchema#string"
       
    66 _LIT8( KSUPAdapterPolicy1SubjectParam1, SUPADAPTER_POLICY1_SUBJECT_P1 );
       
    67 _LIT8( KSUPAdapterPolicy1SubjectParam2, SUPADAPTER_POLICY1_SUBJECT_P2 );
       
    68 _LIT8( KSUPAdapterPolicy1SubjectParam3, SUPADAPTER_POLICY1_SUBJECT_P3 );
       
    69 _LIT8( KSUPAdapterPolicy1ResourceParam1, SUPADAPTER_POLICY1_RESOURCE_P1 );
       
    70 _LIT8( KSUPAdapterPolicy1ResourceParam2, SUPADAPTER_POLICY1_RESOURCE_P2 );
       
    71 _LIT8( KSUPAdapterPolicy1ResourceParam3, SUPADAPTER_POLICY1_RESOURCE_P3 );
       
    72 
       
    73 
       
    74 #ifndef MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64
       
    75 #define MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64 21
       
    76 #endif
       
    77 
       
    78 // ------------------------------------------------------------------------------------------------
       
    79 // CSupAdapter 
       
    80 // ------------------------------------------------------------------------------------------------
       
    81 class CSupAdapter : public CTARMDmStreamAdapter//, public MMsvSessionObserver
       
    82 	{
       
    83 private:
       
    84 	enum TStartupAdapterLeafType
       
    85 	{
       
    86 		EText 		= 0,
       
    87 		EImage 		= 1,
       
    88 		EUnknown 	= 2	
       
    89 	};
       
    90 
       
    91     enum TSupNodeIdentifier
       
    92         {
       
    93         ESupNodeCustomization = 0,
       
    94         ESupNodeStartup,
       
    95         ESupNodeWelcomeData,
       
    96         ESupNodeWelcomeText,
       
    97         ESupNodeNotUsedAndAlwaysLast
       
    98         };
       
    99 
       
   100 public:
       
   101 	CSupAdapter(TAny* aEcomArguments);
       
   102 
       
   103 	static CSupAdapter* NewL( MSmlDmCallback* aDmCallback );
       
   104 	static CSupAdapter* NewLC( MSmlDmCallback* aDmCallback );
       
   105 
       
   106 	virtual ~CSupAdapter();
       
   107 
       
   108 	// Pure virtual methods
       
   109 	void DDFVersionL( CBufBase& aVersion );
       
   110 
       
   111 	void DDFStructureL( MSmlDmDDFObject& aDDF );
       
   112 
       
   113 	void UpdateLeafObjectL( CSmlDmAdapter::TError& aStatus, const TDesC8& aURI,
       
   114 	                        const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType );
       
   115 
       
   116 	CSmlDmAdapter::TError FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, TDes8& aNewMime, CBufFlat* object, TInt &aUncodedSize );
       
   117 
       
   118 	void _UpdateLeafObjectL     ( const TDesC8& aURI, const TDesC8& aLUID,
       
   119 	                              const TDesC8& aObject, const TDesC8& aType, TInt aStatusRef );
       
   120 	void _UpdateLeafObjectL     ( const TDesC8& aURI, const TDesC8& aLUID,
       
   121 	                              RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef );
       
   122 	void _DeleteObjectL         ( const TDesC8& aURI, const TDesC8& aLUID, TInt aStatusRef );
       
   123 	void _FetchLeafObjectL      ( const TDesC8& aURI, const TDesC8& aLUID,
       
   124 	                              const TDesC8& aType, TInt aResultsRef, TInt aStatusRef );
       
   125 	void _FetchLeafObjectSizeL  ( const TDesC8& aURI, const TDesC8& aLUID,
       
   126 	                              const TDesC8& aType, TInt aResultsRef, TInt aStatusRef );
       
   127     void _ChildURIListL         ( const TDesC8& aURI, const TDesC8& aLUID,
       
   128                                   const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
       
   129                                   TInt aResultsRef, TInt aStatusRef );
       
   130 	void _AddNodeObjectL        ( const TDesC8& aURI, const TDesC8& aParentLUID, TInt aStatusRef );
       
   131 	void _ExecuteCommandL       ( const TDesC8& aURI, const TDesC8& aLUID,
       
   132 	                              const TDesC8& aArgument, const TDesC8& aType, TInt aStatusRef );
       
   133     void _ExecuteCommandL       ( const TDesC8& aURI, const TDesC8& aLUID,
       
   134                                   RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef );
       
   135     void _CopyCommandL          ( const TDesC8& aTargetURI, const TDesC8& aTargetLUID,
       
   136                                   const TDesC8& aSourceURI, const TDesC8& aSourceLUID,
       
   137                                   const TDesC8& aType, TInt aStatusRef );
       
   138 
       
   139     void StartAtomicL();
       
   140     void CommitAtomicL();
       
   141     void RollbackAtomicL();
       
   142 
       
   143     TAdapterStreamType StreamType( const TDesC8& aURI );
       
   144     TBool StreamingSupport( TInt& aItemSize );
       
   145     void CompleteOutstandingCmdsL();
       
   146 
       
   147 //#ifdef __SAP_POLICY_MANAGEMENT
       
   148     TInt CheckPolicyL();    
       
   149 //#endif
       
   150 
       
   151 private:
       
   152 	void ConstructL(MSmlDmCallback* aDmCallback);
       
   153 	
       
   154 	void FillNodeInfoL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes,MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription,const TDesC8& aMimeType);
       
   155 	
       
   156 	TStartupAdapterLeafType	GetObjectType(const TDesC8& aMime);
       
   157 	TBool IsSupportedImageType(const TDesC8& aMime);
       
   158 	TBool IsSupportedTextType(const TDesC8& aMime);
       
   159 
       
   160 	void SetStartupTextL(CSmlDmAdapter::TError& aStatus, const TDesC16& aText);
       
   161 	void SetStartupImageL(CSmlDmAdapter::TError& aStatus, const TDesC8& aObject, const TDesC8& aType);
       
   162 	
       
   163 	CBufFlat* GetStartupTextL(CSmlDmAdapter::TError& aStatus, const TDesC8& aType);
       
   164 	CBufFlat* GetStartupImageL(CSmlDmAdapter::TError& aStatus, const TDesC8& aType, TInt &aImageSize);
       
   165 	
       
   166 	void CopyAndTrimMimeType(TDes8& aNewMime, const TDesC8& aType);
       
   167 	
       
   168     CSupAdapter::TSupNodeIdentifier GetNodeIdentifier(const TDesC8& aURI);
       
   169 	TStartupAdapterLeafType GetFetchTypeL(CSmlDmAdapter::TError& aStatus, const TDesC8& aType);
       
   170 	TStartupAdapterLeafType GetSelectedTypeL(CSmlDmAdapter::TError& aStatus);	
       
   171 
       
   172 //#ifdef __SAP_POLICY_MANAGEMENT
       
   173     TPtrC8 PolicyRequestResourceL( const TDesC8& aURI );
       
   174 //#endif
       
   175 
       
   176 #ifdef __WINS__	
       
   177 public:	
       
   178 	void DebugTestsL();
       
   179 #endif
       
   180 
       
   181 
       
   182 private:
       
   183 
       
   184 //#ifdef __SAP_POLICY_MANAGEMENT
       
   185     RPolicyEngine   iPE;
       
   186     RPolicyRequest  iPR;
       
   187 //#endif
       
   188 
       
   189 	MSmlDmCallback* iCallBack;
       
   190 	CBufBase *iUndoImage;
       
   191 	CBufBase *iUndoText;
       
   192 	TInt     iUndoNoteType;
       
   193 
       
   194     TFileName iTemporaryImageFile;
       
   195 };
       
   196 
       
   197 #endif // __NSMLSUPADAPTER_H__