applicationmanagement/server/src/AMDownload.cpp
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2  * Copyright (c) 2002-2004 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 // INCLUDE FILES
       
    19 #include "AMDownload.h"
       
    20 #include "AMDownloader.h"
       
    21 #include "AMDeploymentComponent.h"
       
    22 #include "debug.h"
       
    23 
       
    24 using namespace NApplicationManagement;
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CAMDownload::CAMDownload
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CAMDownload::CAMDownload(CDeploymentComponent *aComponent) :
       
    35     iComponent(aComponent)
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CAMDownload::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CAMDownload::ConstructL(RHttpDownload& aDownload)
       
    45     {
       
    46     iDownloader = CAMDownloader::NewL(aDownload, *this);
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CAMDownload::NewL
       
    51 // Two-phased constructor.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CAMDownload* CAMDownload::NewL(RHttpDownload& aDownload,
       
    55         CDeploymentComponent *aComponent)
       
    56     {
       
    57     CAMDownload* self = new( ELeave ) CAMDownload( aComponent );
       
    58 
       
    59     CleanupStack::PushL(self);
       
    60     self->ConstructL(aDownload);
       
    61     CleanupStack::Pop();
       
    62 
       
    63     return self;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // Destructor
       
    68 // ---------------------------------------------------------------------------
       
    69 CAMDownload::~CAMDownload()
       
    70     {
       
    71     RDEBUG_3( "CAMDownload::~CAMDownload 0x%X - 0x%X", reinterpret_cast<TUint>( this ),
       
    72             reinterpret_cast<TUint>(this)+sizeof( CAMDownload ) );
       
    73 
       
    74     delete iDownloader;
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // DownloadCompleted
       
    79 // ---------------------------------------------------------------------------
       
    80 void CAMDownload::DownloadCompleted()
       
    81     {
       
    82     RDEBUG( "CAMDownload::DownloadCompleted: start");
       
    83 
       
    84     TInt err(KErrNone);
       
    85     TRAP( err, iComponent->SuccessStatusUpdateL( iDownloader->FileName(), iDownloader->MimeType() ) );
       
    86     if (err != KErrNone)
       
    87         {
       
    88         RDEBUG_2(" ->iComponent::StatusUpdateL: %d", err );
       
    89         }
       
    90     RDEBUG_2( "CAMDownload::DownloadCompleted: end Download delete ERROR (%d)", err );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // DownloadFailed
       
    95 //
       
    96 // EDlAttrStatusCode = 500,// Status code from response header (TInt32 - read-only)
       
    97 // EDlAttrErrorId,         // See THttpDownloadMgrError (TInt32 - read-only)
       
    98 // EDlAttrGlobalErrorId,   // Global error id (TInt32 - read-only)
       
    99 // EDlAttrContentType,     // Content type from response header
       
   100 //   (String8<KMaxContentTypeLength> - read/write. Write is accepted only if EDlAttrContinue is ETrue)
       
   101 // ---------------------------------------------------------------------------
       
   102 void CAMDownload::DownloadFailedL(THttpDownloadState aDownloadState)
       
   103     {
       
   104     RDEBUG( "CAMDownload::DownloadFailed: start");
       
   105     TInt err(KErrNone);
       
   106     TInt32 errorCode = iDownloader->DownloadStatusCodeL(aDownloadState);
       
   107     TRAP( err, iComponent->StatusUpdateL( errorCode ) );
       
   108 
       
   109     if (err != KErrNone)
       
   110         {
       
   111         RDEBUG_2(" ->iComponent::StatusUpdateL: %d", err );
       
   112         }
       
   113     RDEBUG_2( "CAMDownload::DownloadFailed: end Download delete ERROR (%d)", err );
       
   114     }
       
   115 
       
   116 void CAMDownload::SetStatus(TInt aStatus)
       
   117     {
       
   118     TRAPD( err, iComponent->StatusUpdateL( aStatus ) )
       
   119     ;
       
   120     if (err != KErrNone)
       
   121         {
       
   122         RDEBUG_2(" ->iComponent::StatusUpdateL: %d", err );
       
   123         }
       
   124     RDEBUG_2( "CAMDownload::DownloadFailed: end Download delete ERROR (%d)", err );
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // DownloadErrorCodeL
       
   129 //
       
   130 // EDlAttrStatusCode = 500,// Status code from response header (TInt32 - read-only)
       
   131 // EDlAttrErrorId,         // See THttpDownloadMgrError (TInt32 - read-only)
       
   132 // EDlAttrGlobalErrorId,   // Global error id (TInt32 - read-only)
       
   133 // EDlAttrContentType,     // Content type from response header
       
   134 //   (String8<KMaxContentTypeLength> - read/write. Write is accepted only if EDlAttrContinue is ETrue)
       
   135 // ---------------------------------------------------------------------------
       
   136 /*TInt32 CAMDownload::DownloadErrorCodeL()
       
   137     {
       
   138     return iDownloader->DownloadStatusCodeL();
       
   139     }*/
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // ContinueDownload
       
   143 // ---------------------------------------------------------------------------
       
   144 TInt CAMDownload::ContinueDownload()
       
   145     {
       
   146     RDEBUG("CAMDownload::ContinueDownload");
       
   147     TInt result(KErrNone);
       
   148     result = iDownloader->ContinueDownload();
       
   149     return result;
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // StartDownload
       
   154 // ---------------------------------------------------------------------------
       
   155 TInt CAMDownload::StartDownload()
       
   156     {
       
   157     RDEBUG("CAMDownload::StartDownload");
       
   158     TInt result(KErrNone);
       
   159     result = iDownloader->StartDownload();
       
   160     return result;
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // StopDownload
       
   165 // ---------------------------------------------------------------------------
       
   166 TInt CAMDownload::StopDownload()
       
   167     {
       
   168     RDEBUG("CAMDownload::StopDownload");
       
   169     TInt result(KErrNone);
       
   170     result = iDownloader->StopDownload();
       
   171     return result;
       
   172     }
       
   173 
       
   174 void CAMDownload::ProgressDialogL(TInt32 aDownloadedSize, TInt32 aContentSize, THttpProgressState aState)
       
   175     {
       
   176 
       
   177     iDownloader->CreateAndUpdateProgressDialogL(aDownloadedSize, aContentSize, aState);
       
   178 
       
   179     }
       
   180 // ---------------------------------------------------------------------------
       
   181 // DownloadURIMatch
       
   182 // ---------------------------------------------------------------------------
       
   183 TBool CAMDownload::DownloadURIMatch(const TDesC8& aURI)
       
   184     {
       
   185     return iDownloader->CompareDownloadURI(aURI);
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // DownloadURI
       
   190 // ---------------------------------------------------------------------------
       
   191 const TDesC8& CAMDownload::DownloadURI()
       
   192     {
       
   193     return iDownloader->DownloadURI();
       
   194     }
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // ContentMimeType
       
   198 // ---------------------------------------------------------------------------
       
   199 const TDesC8& CAMDownload::ContentMimeType()
       
   200     {
       
   201     return iDownloader->MimeType();
       
   202     }
       
   203 
       
   204 //  End of File