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