applicationmanagement/server/inc/AMDeploymentComponent.h
changeset 47 d316aecb87fd
equal deleted inserted replaced
46:b9b00b134b0d 47:d316aecb87fd
       
     1 /*
       
     2  * Copyright (c) 2000 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: Implementation of applicationmanagement components
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #ifndef __CAMDEPLOYMENTCOMPONENT__
       
    20 #define __CAMDEPLOYMENTCOMPONENT__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <centralrepository.h>
       
    24 #include <f32file.h> 
       
    25 #include <SyncMLDef.h>
       
    26 #include "ApplicationManagementCommon.h"
       
    27 #include "aminstalloptions.h"
       
    28 #include "amdeploymentcomponentdata.h"
       
    29 
       
    30 
       
    31 namespace NApplicationManagement
       
    32     {
       
    33     _LIT8( KAMDCDelimiter, "|" );
       
    34 
       
    35     // FORWARD DECLARATIONS
       
    36     class CDeploymentComponent;
       
    37     class CAMDownload;
       
    38 
       
    39       class MAMDownloadStateObserver
       
    40         {
       
    41 public:
       
    42         /**
       
    43          * StatusUpdateL Sets the current download status. This is 
       
    44          *	currently HTTP status code 
       
    45          *	(200 is success, 400+ failure, 100-199 in progress)
       
    46          * @param	aNewStatus	The new download status 
       
    47          */
       
    48         virtual void StatusUpdateL(TInt aNewStatus) = 0;
       
    49         virtual void SuccessStatusUpdateL(const TDesC &aDlFileName,
       
    50                 const TDesC8& aDlMimeType) = 0;
       
    51         };
       
    52 
       
    53 
       
    54     class MDownloadCallback
       
    55         {
       
    56     public:
       
    57         virtual void DownloadComplete( class CDeploymentComponent *aComponent, TInt aStatus ) = 0;
       
    58         virtual TBool UidExistsL( const TUid &aUid, CDeploymentComponent *& aCompo, CDeploymentComponent *aIgnored ) = 0;
       
    59         };
       
    60 
       
    61     class CDeploymentComponent : public CBase, public MAMDownloadStateObserver
       
    62         {
       
    63 
       
    64     public: // From MAMDownloadStateObserver	
       
    65         void StatusUpdateL( TInt aNewStatus );
       
    66         void SuccessStatusUpdateL( const TDesC &aDlFileName, const TDesC8& aDlMimeType );
       
    67 
       
    68         void SetStatusNode(const TSCOMOStatusNodeStates &aStatus) const;
       
    69     private:
       
    70         // Data
       
    71         TDeploymentComponentId iId;
       
    72         TDeploymentComponentName iName;
       
    73         TDeploymentComponentVersion iVersion;
       
    74         TDeploymentComponentState iState;
       
    75         TDeploymentComponentDescription iDescription;
       
    76         TDeploymentComponentPkgId iPkgID;
       
    77         TDeploymentComponentPkgIdRef iPkgIDRef;
       
    78         TDeploymentComponentPkgType iPkgType;
       
    79         TDeploymentComponentName iMidletName;
       
    80         TDeploymentComponentName iMideltVendorName;
       
    81         TDeploymentComponentVersion iMidletVersion;
       
    82         TUint32 iInternalId;
       
    83         TUid iUid;
       
    84         TDCUserId iUserId;
       
    85         
       
    86         CDeploymentComponentData *iMetaData;
       
    87         CDeploymentComponentData *iData;
       
    88         TAMInstallOptions iInstallOpts;
       
    89         TBool iInstallOptsSet;
       
    90         TUint32 iPkgVersion;
       
    91         TBool iRemovableApp;
       
    92         TBool iDriveSelection;
       
    93         TInt iComponentId;
       
    94         TInt iDownloadStatus;
       
    95         mutable TInt iStatus;
       
    96         TBuf8<KMaxUrlLength> iDownloadURI;
       
    97         TDownloadTarget iDownloadTarget;
       
    98         SwiUI::TUninstallOptions iUninstallOpts;
       
    99 
       
   100         TInt iOwner; // TCertInfo index in CAMStorage::iCertificates
       
   101         TDeploymentComponentState iOldState;
       
   102         MDownloadCallback *iCallback; // not owned
       
   103 
       
   104         TSmlProfileId iOwnerProfile; // profile stored only runtime until download has completed
       
   105         CRepository *iRepository;
       
   106 
       
   107         // Constructors	
       
   108         CDeploymentComponent( TInt iInternalId ); 
       
   109         static CDeploymentComponent* NewL( TInt iInternalId, const TDCUserId &aUserId);
       
   110         static CDeploymentComponent* NewLC( TInt iInternalId, const TDCUserId &aUserId );
       
   111         static CDeploymentComponent* LoadL( TInt iInternalId, const TDesC8 &aBuffer );
       
   112         static CDeploymentComponent* LoadLC( TInt iInternalId, const TDesC8 &aBuffer );
       
   113 
       
   114         void ConstructL( const TDCUserId &aUserId );
       
   115         void ConstructLoadL( const TDesC8 &aBuffer );
       
   116 
       
   117         void SetAttr( TDes8 &aAttr, const TDesC8 &aNewVal ) const;
       
   118 
       
   119         /**
       
   120          * @param aState The new state
       
   121          * @return TInt KErrNone if all ok, system error code if visiblity change failed
       
   122          */
       
   123 
       
   124         TInt SetState( const TDeploymentComponentState &aState ) ;
       
   125         /**
       
   126 	Returns number of bytes written to aBuffer
       
   127          */
       
   128         virtual TInt SerializedFormL( RWriteStream &aBuffer ) const;
       
   129         /**
       
   130 	Returns length of serizlied form
       
   131          */
       
   132         virtual TInt SerializedFormLength() const;
       
   133         HBufC8* IntToDes8LC( const TInt aLuid );
       
   134     public:
       
   135         virtual ~CDeploymentComponent();
       
   136         TInt DownloadStatus() const;
       
   137         inline const TDeploymentComponentId &ComponentId() const;
       
   138 
       
   139         inline const TDeploymentComponentName &ComponentName() const;
       
   140 
       
   141         inline const TDeploymentComponentVersion &ComponentVersion() const;
       
   142 
       
   143         inline TDeploymentComponentState State() const;
       
   144 
       
   145         inline TUint32 InternalId() const;
       
   146 
       
   147         inline const TUid & Uid() const;
       
   148 
       
   149         //inline const TInt DownloadStatus() const;
       
   150 
       
   151         inline const TDesC8 &DownloadURI() const ;
       
   152 
       
   153         inline const TDeploymentComponentPkgId& PkgId() const ;
       
   154 
       
   155         inline const TDeploymentComponentDescription& Description() const;
       
   156 
       
   157         inline const TDeploymentComponentPkgIdRef& PkgIDRef() const;
       
   158 
       
   159         inline const TDeploymentComponentPkgType& PkgType() const;
       
   160 
       
   161         inline const TMidletnameName& MidletName() const;
       
   162         inline const TMidletVendorName& MidletVendor() const;
       
   163         inline const TMidletVersion& MidletVersion() const;
       
   164 
       
   165 
       
   166 
       
   167         virtual void PersistL( CRepository &aRepository ) const;
       
   168 
       
   169         virtual void DestroyL( CRepository &aRepository ) ;
       
   170         /**
       
   171 	Copies current state to argument
       
   172          */
       
   173         void CopyStateTo( TDeploymentComponent &aInfo ) const;
       
   174 
       
   175         void SetUid( const TUid aUid );
       
   176 
       
   177         void Set( const TDeploymentComponent &aInfo );
       
   178 
       
   179         void SetDownloadURIL( const TDesC8 &aURI );
       
   180 
       
   181         void SetDownloadTarget( const TDownloadTarget& aDownloadTarget );
       
   182 
       
   183         void SetDescriptionL( const TDesC8 &aVersion );
       
   184 
       
   185         void SetPkgIDL( const TDesC8 &aPkgID );
       
   186 
       
   187         void SetPkgTypeL( const TDesC8 &aPkgType );
       
   188 
       
   189         void SetMidletNameL( const TDesC8 &aMidletName );
       
   190 
       
   191         void SetMidletVendorL( const TDesC8 &aMidletVendor );
       
   192 
       
   193         void SetMidletVersionL( const TDesC8 &aMidletVersion );
       
   194 
       
   195         void SetAppRemovableStatus(const TBool &aRemovable);
       
   196         
       
   197         void SetDriveSelectionStatus(const TBool &aDriveSelection);
       
   198         
       
   199         void SetComponentId(const TInt &aComponentId);
       
   200 
       
   201         void SetCallback( MDownloadCallback *aListener )
       
   202             {
       
   203             iCallback = aListener;
       
   204             }
       
   205 
       
   206 
       
   207         /**
       
   208 	UserId returns the id specified by user
       
   209          */
       
   210         inline const TDesC8& UserId() const;
       
   211         /*
       
   212          * Returns the status Node value of the Component ID.
       
   213          * */
       
   214         inline TInt Status() const;
       
   215 
       
   216         CDeploymentComponent &operator=( const CDeploymentComponent &aData );
       
   217 
       
   218 
       
   219 
       
   220         /**
       
   221          * SetIAPL Sets the iap
       
   222          * @param The new iap id
       
   223          */
       
   224         void SetIAPL( const TInt aIap );
       
   225 
       
   226 
       
   227         /**
       
   228          * @return The iap id
       
   229          */
       
   230         TInt GetIAP() const;
       
   231 
       
   232         /**
       
   233          * IsJavaMimeL
       
   234          * @return ETrue if mime is recognised Java mime
       
   235          */
       
   236         static TBool IsJavaMimeL( const TDesC8& aMime );
       
   237         /**
       
   238                  * IsSisMimeL
       
   239                  * @return ETrue if mime is recognised Sis mime
       
   240                  */
       
   241                 static TBool IsSisMimeL( const TDesC8& aMime );
       
   242 
       
   243         /**
       
   244          * DownloadFailed
       
   245          * @return ETrue if download status is such that it indicates failure, EFalse otherwise
       
   246          */
       
   247         TBool DownloadFailed() const;
       
   248 
       
   249         /**
       
   250          * OwnerProfile returns the owner profile - -1 if there's no such
       
   251          */
       
   252         const TSmlProfileId& OwnerProfile() const;
       
   253 
       
   254         /**
       
   255          * OwnerProfile 
       
   256          */
       
   257         void SetOwnerProfile( TSmlProfileId aOwnerProfile);
       
   258 
       
   259 
       
   260         /**
       
   261          * MimeType
       
   262          * @return Component mimetype. This can be mimetype from data or metadata. Usually metadata mimetype is returned in Java case.
       
   263          * In case of Java if both Jad and Jar exist, then it is Jad mimetype.
       
   264          * In case of Java if only Jar exist, then it is Jar mimetype.
       
   265          * In case of Java if only Jad exist, the it is Jad mimetype.
       
   266          */
       
   267         const TDesC8& MimeType() const;
       
   268 
       
   269 
       
   270     protected:
       
   271 
       
   272         static CDeploymentComponent *LoadComponentL (  TInt aInternalId, const TDesC8 &aBuffer ) ;
       
   273     public:
       
   274         CDeploymentComponentData &Data();
       
   275         const CDeploymentComponentData &Data() const;
       
   276         CDeploymentComponentData &MetaData();
       
   277         const CDeploymentComponentData &MetaData() const;
       
   278         const TAMInstallOptions &InstallOpts() const;
       
   279         const SwiUI::TUninstallOptions &UninstallOpts() const;
       
   280         TBool InstallOptsSet() const;
       
   281         TBool AppRemovable() const;
       
   282         TBool DriveSelected() const;
       
   283         TInt GetComponentId() const;
       
   284         void SetDataL( const TDesC8 &aMimeType );
       
   285         void SetMetaDataL( const TDesC8 &aMimeType );
       
   286         void SetDataL( const TDesC8 &aData, const TDesC8 &aMimeType );
       
   287         void SetDataL( const TDesC &aFileName, const TDesC8 &aMimeType );
       
   288         void SetMetaDataL( const TDesC8 &aMetaData, const TDesC8 &aMimeType );
       
   289         void SetInstallOptsL( const TDesC8 &aInstallOptions );
       
   290         void ResetDataL( RFs &aFs );
       
   291 
       
   292         void SetIdL( const TDesC8 &aId );
       
   293         void SetNameL( const TDesC8 &aName );
       
   294         void SetVersionL( const TDesC8 &aVersion );
       
   295         void SetMimeTypeL( const TDesC8 &aMimeType );
       
   296         void SetOwner( const TInt &aCertInfoId );
       
   297         TInt Owner( ) const
       
   298         {
       
   299         return iOwner;
       
   300         }
       
   301         TDownloadTarget DownloadTarget() const
       
   302         {
       
   303         return iDownloadTarget;
       
   304         }
       
   305 
       
   306         inline const TDeploymentComponentState& OldState() const;
       
   307 
       
   308         inline void StateChangeComplete();
       
   309 
       
   310 
       
   311         friend class CDeliveryComponentStorage;
       
   312         };
       
   313 
       
   314 #include "amdeploymentcomponent.inl"
       
   315 
       
   316     }
       
   317 
       
   318 
       
   319 #endif	
       
   320 
       
   321 //  End of File