applicationmanagement/server/src/ApplicationManagementServer.cpp
author hgs
Fri, 06 Aug 2010 18:56:37 +0530
changeset 52 6e38e48ee756
parent 47 d316aecb87fd
child 56 a9afc3a8dbfa
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     1
/*
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     8
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    11
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    12
 * Contributors:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    13
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    14
 * Description: Implementation of applicationmanagement components
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    15
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    16
 */
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    17
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    18
#define __INCLUDE_CAPABILITY_NAMES__
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    19
#include <e32svr.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    20
#include <badesca.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    21
#include <e32cmn.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    22
#include <bautils.h> 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    23
#include <featmgr.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    24
#include <imcvcodc.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    25
#include <uikon.hrh>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    26
#include <e32property.h>
52
hgs
parents: 47
diff changeset
    27
#include <driveinfo.h>
47
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    28
#include <SWInstDefs.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    29
#include <PolicyEngineClient.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    30
#include <PolicyEngineXACML.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    31
#include <eikenv.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    32
#include <hbapplication.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    33
#include <apgwgnam.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    34
#include <nsmldmconst.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    35
#include <DevManInternalCRKeys.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    36
#include <apgtask.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    37
#include <apgwgnam.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    38
#include "ampskeys.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    39
#include "amprivateCRKeys.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    40
#include "ApplicationManagementConst.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    41
#include "ApplicationManagementCommon.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    42
#include "ApplicationManagementClientServer.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    43
#include "ApplicationManagementServer.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    44
#include "AMDeploymentComponent.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    45
#include "amsmlhelper.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    46
#include "ApplicationManagementUtility.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    47
#include "ApplicationManagementUtilityFactory.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    48
#include "debug.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    49
#include "coemain.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    50
#include "AMPreInstallApp.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    51
#include "amview.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    52
#include "appmgmtnotifier.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    53
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    54
using namespace NApplicationManagement;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    55
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    56
#ifdef __AM_CONNECT_INSTALLER_ONSTARTUP_	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    57
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    58
#pragma message("AM Connecting installer at startup")
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    59
#else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    60
#pragma message("AM Connecting installer when needed")
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    61
#endif
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    62
// Needed only for jad+jar installation  
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    63
_LIT( KInstallDir, "c:\\temp\\" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    64
_LIT8(KMIDletJarURL, "MIDlet-Jar-URL");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    65
//OMA SCOMO Specific
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    66
_LIT8(KDownloadState, "./SCOMO/Download/");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    67
_LIT8(KDeliveredState, "./SCOMO/Inventory/Delivered/");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    68
_LIT8(KDeployedState, "./SCOMO/Inventory/Deployed/");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    69
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    70
//Package all the above together into a policy
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    71
CPolicyServer::TPolicy KApplicationManagementSecurityPolicy;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    72
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    73
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    74
// CApplicationManagementServer::ComponentDownloadComplete()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    75
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    76
void CApplicationManagementServer::ComponentDownloadComplete(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    77
        CDeploymentComponent *aComponent, TInt iapid, HBufC8 *aServerId)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    78
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    79
    TInt err = KErrNone;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    80
    TRAP( err, DownloadCompleteL( aComponent, iapid, aServerId ));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    81
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    82
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    83
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    84
// CApplicationManagementServer::DownloadCompleteL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    85
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    86
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    87
void CApplicationManagementServer::DownloadCompleteL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    88
        CDeploymentComponent *aComponent, TInt iapid, HBufC8 *aServerId)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    89
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    90
    RDEBUG( "ApplicationManagementServer DownloadComplete - start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    91
    __ASSERT_DEBUG( aComponent, User::Invariant() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    92
    iComp = aComponent;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    93
    iStorage->UpdateL(*aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    94
    TInt errdownload = KErrNone;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    95
    TInt errInstall = KErrNone;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    96
    TInt status = KStatusSuccess;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    97
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    98
    if (!aComponent->DownloadFailed())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    99
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   100
        CDeploymentComponent *old = DoDataUpdateCheckL(*aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   101
        TDownloadTarget trgt = aComponent->DownloadTarget();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   102
        switch (trgt)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   103
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   104
            case EDeliver:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   105
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   106
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   107
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   108
            case EInstall:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   109
            case EInstallAndActivate:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   110
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   111
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   112
                TRAP(errInstall,DoTheInstallL( *aComponent));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   113
RDEBUG_2( "ApplicationManagementServer DownloadComplete - start %d", errInstall);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   114
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   115
                if (trgt == EInstall && errInstall == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   116
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   117
                    iStorage->DeactivateL(*aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   118
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   119
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   120
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   121
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   122
            case EUpdate:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   123
            case EUpdateAndActivate:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   124
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   125
                if (old)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   126
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   127
                    FullUpdateL(*aComponent, *old);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   128
                    if (trgt == EUpdate)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   129
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   130
                        iStorage->DeactivateL(*aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   131
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   132
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   133
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   134
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   135
            default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   136
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   137
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   138
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   139
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   140
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   141
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   142
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   143
        errdownload = aComponent->DownloadStatus();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   144
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   145
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   146
    RDEBUG( "ApplicationManagementServer DownloadComplete - Start Send to background" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   147
    //Download Completed/ Failed or installation success/ failure Send server to Background.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   148
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   149
    iOMASCOMOEnabled = IsOMASCOMOEnabledL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   150
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   151
    m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   152
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   153
    if (iOMASCOMOEnabled)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   154
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   155
        status = GetErrorStatus(errdownload, errInstall);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   156
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   157
        TInt ASyncSupported = -1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   158
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   159
        CRepository *repository = CRepository::NewLC(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   160
                KUidPSApplicationManagementKeys);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   161
        repository->Get(KAsyncEnabled, ASyncSupported);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   162
        CleanupStack::PopAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   163
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   164
        // For Sync Reporting
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   165
        if (!ASyncSupported)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   166
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   167
            // Update Central Repository with proper error code for Sync
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   168
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   169
            CRepository *repository = CRepository::NewLC(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   170
                    KUidPSApplicationManagementKeys);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   171
            repository->Set(KAMSyncStatus, status);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   172
            CleanupStack::PopAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   173
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   174
            RProperty counter;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   175
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   176
            TInt r = counter.Attach(KUidPSApplicationManagementKeys,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   177
                    KSyncNotifier, EOwnerThread);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   178
            User::LeaveIfError(r);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   179
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   180
            TInt err = counter.Set(KErrCancel);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   181
            User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   182
            counter.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   183
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   184
        else// Do AsyncReporting
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   185
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   186
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   187
            RDEBUG( "CApplicationManagementServer::ASync Reporting Step 1" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   188
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   189
            // Get deployement component entries
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   190
            TInt internalid = aComponent->InternalId();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   191
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   192
            RDEBUG( "CApplicationManagementServer::ASync Reporting Step 2" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   193
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   194
            TBuf8<256> targetURI;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   195
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   196
            TDeploymentComponentState state = aComponent->State();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   197
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   198
            RDEBUG( "CApplicationManagementServer::ASync Reporting Step 3" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   199
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   200
            if (state == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   201
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   202
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   203
                RDEBUG( "CApplicationManagementServer::ASync EDCSDownload Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   204
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   205
                targetURI.Append(KDownloadState);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   206
                targetURI.Append(aComponent->UserId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   207
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   208
                RDEBUG( "CApplicationManagementServer::ASync EDCSDownload End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   209
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   210
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   211
            else if (state == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   212
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   213
                RDEBUG( "CApplicationManagementServer::ASync EDCSDelivered Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   214
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   215
                targetURI.Append(KDeliveredState);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   216
                targetURI.Append(aComponent->UserId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   217
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   218
                RDEBUG( "CApplicationManagementServer::ASync EDCSDelivered End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   219
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   220
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   221
            else if (state == EDCSActive || state == EDCSInactive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   222
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   223
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   224
                RDEBUG( "CApplicationManagementServer::ASync EDCSActive Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   225
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   226
                targetURI.Append(KDeployedState);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   227
                targetURI.Append(aComponent->UserId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   228
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   229
                RDEBUG( "CApplicationManagementServer::ASync EDCSActive End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   230
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   231
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   232
            //Save Entry to database with status and target URI of deployment component
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   233
            TInt iapidval = 2;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   234
            TRAPD( err1, SmlHelper::GetDefaultIAPFromDMProfileL( iapid ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   235
            if (err1 == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   236
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   237
                RDEBUG_2("Application Mgmt Server service::DownloadCompleteL iapid to : %d", iapid );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   238
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   239
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   240
            TInt index;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   241
            iAMServerDB->SaveToDatabaseL(index, internalid, status,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   242
                    targetURI, iapidval);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   243
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   244
            RDEBUG( "CApplicationManagementServer::ASync SaveToDatabaseL completed" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   245
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   246
            EnableDMNetworkMonL(iapid, aServerId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   247
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   248
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   249
    int value = 0 ;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   250
    int err = RProperty::Set(TUid::Uid(KOmaDMAppUid), KDownloadActive, value);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   251
    RDEBUG_2("RProperty set (%d)", err  );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   252
    if (iDownloadMngr->DownloadCount() == 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   253
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   254
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   255
        RDEBUG_2( "CApplicationManagementServer::ConstructL - ERROR leaving cannot connect installer: %d", iSessionCount );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   256
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   257
        // Is session count is not modified whenever there is error then at the end of download complete decrement
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   258
        //  the session count.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   259
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   260
        if (status != KStatusSuccess && iSessionCount != 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   261
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   262
            iSessionCount--;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   263
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   264
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   265
        if (iSessionCount == 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   266
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   267
            iShutdown.Start();    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   268
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   269
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   270
    aComponent->SetDriveSelectionStatus(false);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   271
    RDEBUG( "ApplicationManagementServer DownloadComplete - end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   272
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   273
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   274
void CApplicationManagementServer::InstallationCancelled()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   275
	{
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   276
		iInstaller.CancelOperation();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   277
	}
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   278
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   279
// CApplicationManagementServer::IsOMASCOMOEnabledL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   280
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   281
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   282
TBool CApplicationManagementServer::IsOMASCOMOEnabledL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   283
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   284
    RDEBUG( "CApplicationManagementServer::IsOMASCOMOEnabledL Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   285
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   286
    TInt adapterValue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   287
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   288
    CRepository *repository = CRepository::NewLC(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   289
            KCRUidPrivateApplicationManagementKeys);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   290
    repository->Get(KAMAdapterValue, adapterValue);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   291
    CleanupStack::PopAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   292
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   293
    RDEBUG( "CApplicationManagementServer::IsOMASCOMOEnabledL End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   294
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   295
    if (adapterValue == 0 || adapterValue == 1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   296
        return EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   297
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   298
        return ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   299
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   300
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   301
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   302
// CApplicationManagementServer::GetErrorStatus()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   303
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   304
TInt CApplicationManagementServer::GetErrorStatus(TInt aErrorDownload,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   305
        TInt aErrorInstall)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   306
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   307
    TInt status = KStatusSuccess;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   308
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   309
    if (aErrorDownload != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   310
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   311
        if (aErrorDownload == KStatusUserCancelled || aErrorDownload
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   312
                == KStatusDowloadFailedOOM || aErrorDownload
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   313
                == KStatusUnSupportedEnvironment || aErrorDownload
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   314
                == KStatusAlternateDownldAuthFail || aErrorDownload
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   315
                == KStatusAltDowldUnavailable)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   316
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   317
            status = aErrorDownload;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   318
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   319
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   320
            status = KStatusDownloadFailed;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   321
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   322
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   323
    else if (aErrorInstall != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   324
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   325
        if (aErrorInstall == SwiUI::KSWInstErrSecurityFailure)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   326
            status = KStatusPkgValidationFailed;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   327
        if (aErrorInstall == SwiUI::KSWInstErrInsufficientMemory)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   328
            status = KStatusInstallFailedOOM;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   329
	  if (aErrorInstall == KStatusUserCancelled)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   330
		status = KStatusUserCancelled;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   331
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   332
            status = KStatusInstallFailed;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   333
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   334
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   335
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   336
    return status;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   337
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   338
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   339
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   340
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   341
// CApplicationManagementServer::EnableDMNetworkMonL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   342
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   343
void CApplicationManagementServer::EnableDMNetworkMonL(TInt iapid,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   344
        HBufC8 *aServerId)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   345
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   346
    TInt retryenabled = 1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   347
    _LIT( KNetMon,"\\dmnetworkmon.exe" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   348
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   349
    // Enable DM Network Monitoring for retry of Generic alert in case of N/W loss
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   350
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   351
    CRepository *repository = CRepository::NewLC(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   352
            KCRUidDeviceManagementInternalKeys);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   353
    TInt err_val = repository->Set(KDevManEnableDMNetworkMon, retryenabled);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   354
    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL Retry enabled err: %d", err_val );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   355
    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL Retry enabled value: %d", retryenabled );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   356
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   357
    err_val = repository->Set(KDevManIapIdKey, iapid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   358
    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL devmaniapid: %d", err_val );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   359
    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL iap id: %d", iapid );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   360
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   361
    err_val = repository->Set(KDevManServerIdKey, *aServerId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   362
    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL serveridkey: %d", err_val );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   363
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   364
    TBuf<256> buf1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   365
    buf1.Copy(*aServerId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   366
    RDEBUG_2( "Server ID -  '%S'", &buf1);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   367
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   368
    CleanupStack::PopAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   369
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   370
    // create NetMon EXE
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   371
    RProcess rp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   372
    TInt err = rp.Create(KNetMon, KNullDesC);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   373
    User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   374
    TRequestStatus stat;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   375
    rp.Rendezvous(stat);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   376
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   377
    if (stat != KRequestPending)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   378
        rp.Kill(0); // abort startup
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   379
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   380
        rp.Resume(); // logon OK - start the server
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   381
    TInt r = (rp.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   382
    rp.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   383
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   384
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   385
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   386
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   387
// CApplicationManagementServer::CApplicationManagementServer
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   388
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   389
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   390
inline CApplicationManagementServer::CApplicationManagementServer() :
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   391
    CPolicyServer(0, KApplicationManagementSecurityPolicy, ESharableSessions)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   392
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   393
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   394
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   395
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   396
// CApplicationManagementServer::AddSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   397
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   398
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   399
void CApplicationManagementServer::AddSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   400
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   401
    // A new session is being created
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   402
    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::AddSession" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   403
    ++iSessionCount;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   404
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   405
    // Cancel the shutdown timer if it was running
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   406
    iShutdown.Cancel();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   407
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   408
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   409
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   410
// CApplicationManagementServer::DropSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   411
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   412
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   413
void CApplicationManagementServer::DropSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   414
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   415
    // A session is being destroyed
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   416
    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::DropSession" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   417
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   418
    // Start the shutdown timer if it is the last session
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   419
    if (--iSessionCount == 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   420
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   421
        if (iDownloadMngr->DownloadCount() > 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   422
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   423
            RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::DropSession download in progress" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   424
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   425
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   426
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   427
            iShutdown.Start();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   428
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   429
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   430
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   431
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   432
// -----------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   433
// CApplicationManagementServer::AddDownloadL( CDeploymentComponent *aComponent )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   434
// -----------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   435
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   436
void CApplicationManagementServer::AddDownloadL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   437
        CDeploymentComponent *aComponent)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   438
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   439
    __ASSERT_DEBUG( aComponent, User::Invariant() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   440
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   441
    RDEBUG( "CApplicationManagementServer::AddDownloadL Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   442
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   443
    iDownloadMngr->AddDownloadL(aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   444
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   445
    RDEBUG( "CApplicationManagementServer::AddDownloadL End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   446
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   447
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   448
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   449
// CApplicationManagementServer
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   450
// -----------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   451
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   452
CServer2* CApplicationManagementServer::NewL(HbMainWindow *mainWindow)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   453
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   454
    //specifies all connect attempts should pass
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   455
    KApplicationManagementSecurityPolicy.iOnConnect
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   456
            = CPolicyServer::EAlwaysPass;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   457
    KApplicationManagementSecurityPolicy.iRangeCount
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   458
            = KApplicationManagementRangeCount; //number of ranges                                   
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   459
    KApplicationManagementSecurityPolicy.iRanges
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   460
            = KApplicationManagementRanges;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   461
    KApplicationManagementSecurityPolicy.iElementsIndex
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   462
            = KApplicationManagementSecurityElementsIndex;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   463
    KApplicationManagementSecurityPolicy.iElements
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   464
            = KApplicationManagementSecurityElements;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   465
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   466
    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::NewLC" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   467
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   468
    CApplicationManagementServer* self =
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   469
            new (ELeave) CApplicationManagementServer;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   470
    CleanupStack::PushL(self);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   471
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   472
    self->ConstructL(mainWindow);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   473
    CleanupStack::Pop();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   474
    return self;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   475
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   476
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   477
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   478
// -----------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   479
// CApplicationManagementServer::~CApplicationManagementServer
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   480
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   481
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   482
CApplicationManagementServer::~CApplicationManagementServer()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   483
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   484
    RDEBUG_3("CApplicationManagementServer::~CApplicationManagementServer 0x%X - 0x%X", reinterpret_cast<TUint>(this ),
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   485
            reinterpret_cast<TUint>(this)+sizeof( CApplicationManagementServer ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   486
    FeatureManager::UnInitializeLib();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   487
    iInstaller.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   488
    delete iStorage;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   489
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   490
    delete iUtility;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   491
    delete iAMServerDB;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   492
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   493
    RProperty::Delete(KUidPSApplicationManagementKeys, KAMServerUIEnabled);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   494
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   495
    RProperty::Delete(KUidPSApplicationManagementKeys, KAMOperationNonSilent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   496
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   497
    RProperty::Delete(KUidPSApplicationManagementKeys, KSyncNotifier);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   498
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   499
    RProperty::Delete(KUidPSApplicationManagementKeys, KDMUINotClosed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   500
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   501
    iInstallFile.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   502
    iInstallRFs.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   503
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   504
    delete iDownloadMngr;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   505
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   506
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   507
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   508
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   509
// CApplicationManagementServer::HandleAllClientsClosed
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   510
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   511
void CApplicationManagementServer::HandleAllClientsClosed()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   512
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   513
    // Do Nothing
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   514
    RDEBUG( "CApplicationManagementServer::HandleAllClientsClosed" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   515
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   516
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   517
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   518
// CApplicationManagementServer::ConstructL
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   519
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   520
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   521
void CApplicationManagementServer::ConstructL(HbMainWindow* aWindow)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   522
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   523
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   524
    // 2nd phase construction - ensure the timer and server objects are running
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   525
    RDEBUG( "CApplicationManagementServer::ConstructL - Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   526
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   527
    iOMASCOMOEnabled = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   528
    mUserCancelled = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   529
    TRAPD( errf, FeatureManager::InitializeLibL() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   530
    if (errf != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   531
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   532
        User::Leave(errf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   533
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   534
    m_Window = aWindow;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   535
    RDEBUG( "CApplicationManagementServer::ConstructL - start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   536
    StartL(KApplicationManagementServerName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   537
    iStorage = CDeliveryComponentStorage::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   538
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   539
    iUtility
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   540
            = ApplicationManagementUtilityFactory::CreateManagementUtilityL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   541
    iDownloadMngr = CAMDownloadStore::NewL(*this);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   542
    iAMServerDB = CAMDownloaddb::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   543
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   544
    // Define P&S Keys
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   545
    RProperty::Define(KUidPSApplicationManagementKeys, KAMServerUIEnabled,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   546
            RProperty::EInt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   547
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   548
    RProperty::Define(KUidPSApplicationManagementKeys, KAMOperationNonSilent,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   549
            RProperty::EInt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   550
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   551
    RProperty::Define(KUidPSApplicationManagementKeys, KSyncNotifier,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   552
            RProperty::EInt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   553
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   554
    RProperty::Define(KUidPSApplicationManagementKeys, KDMUINotClosed,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   555
            RProperty::EInt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   556
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   557
    RProperty syncproperty;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   558
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   559
    //Ignore error status
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   560
    syncproperty.Attach(KUidPSApplicationManagementKeys, KSyncNotifier,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   561
            EOwnerThread);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   562
    syncproperty.Set(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   563
    syncproperty.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   564
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   565
#ifdef __AM_CONNECT_INSTALLER_ONSTARTUP_	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   566
    TInt err( iInstaller.Connect() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   567
    if ( err != KErrNone )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   568
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   569
        RDEBUG_2( "CApplicationManagementServer::ConstructL - ERROR leaving cannot connect installer: %d", err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   570
        User::LeaveIfError( err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   571
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   572
#endif	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   573
    iShutdown.ConstructL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   574
    // ensure that the server still exits even if the 1st client fails to connect
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   575
    iShutdown.Start();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   576
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   577
    RDEBUG( "CApplicationManagementServer::ConstructL - end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   578
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   579
//---------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   580
// Create a new client session. 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   581
//---------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   582
CSession2* CApplicationManagementServer::NewSessionL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   583
        const TVersion& aVersion, const RMessage2& /*aMessage */) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   584
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   585
    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::NewSessionL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   586
    TVersion ver(KAMVerMajor, KAMVerMinor, KAMVerBuild);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   587
    if (!User::QueryVersionSupported(ver, aVersion))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   588
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   589
        RDEBUG( "CApplicationManagementServer::NewSessionL(): wrong version offered -> BAIL OUT!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   590
        User::Leave(KErrNotSupported);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   591
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   592
    return new (ELeave) CApplicationManagementSession();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   593
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   594
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   595
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   596
// CApplicationManagementServer::CustomSecurityCheckL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   597
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   598
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   599
CPolicyServer::TCustomResult CApplicationManagementServer::CustomSecurityCheckL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   600
        const RMessage2& /*aMsg*/, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   601
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   602
    return EPass;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   603
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   604
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   605
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   606
// CApplicationManagementServer::InstallCompleteL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   607
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   608
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   609
void CApplicationManagementServer::InstallCompleteL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   610
        const CDeploymentComponent& aCompo, const TBool &aInstallSuccess)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   611
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   612
    RDEBUG_2("CApplicationManagementServer::InstallCompleteL start (%d)", aInstallSuccess);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   613
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   614
    iInstallFile.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   615
    // if java jad + jar install, remove files from c:\temp directory
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   616
    if (CDeploymentComponent::IsJavaMimeL(aCompo.MetaData().MimeType() ) && CDeploymentComponent::IsJavaMimeL(aCompo.Data().MimeType() ) )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   617
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   618
        TFileName fn, fn2;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   619
        GenerateTempFileNameL(iInstallRFs, aCompo, fn, fn2);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   620
        RDEBUG_3("CApplicationManagementServer::InstallCompleteL delete files: (%S) (%S)", &fn, &fn2);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   621
        User::LeaveIfError(iInstallRFs.Delete(fn));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   622
        User::LeaveIfError(iInstallRFs.Delete(fn2));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   623
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   624
         TInt silentsession = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   625
        TInt r2 = RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   626
                silentsession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   627
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   628
	  if(r2 == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   629
		CApplicationManagementUtility::iSilentSession = silentsession;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   630
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   631
        if (!CApplicationManagementUtility::iSilentSession)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   632
        	{
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   633
    AppMgmtNotifier* note = new AppMgmtNotifier(m_appName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   634
    if (aInstallSuccess)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   635
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   636
        note->showInstallSuccessNote();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   637
        // Remove temporary files from private directory 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   638
        const_cast<CDeploymentComponent&> (aCompo).ResetDataL(iInstallRFs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   639
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   640
    else if(mUserCancelled == 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   641
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   642
        note->showInstallFailedNote();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   643
        m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   644
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   645
        
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   646
    delete note;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   647
     }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   648
     else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   649
     	{
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   650
     		 if (aInstallSuccess)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   651
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   652
        
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   653
        const_cast<CDeploymentComponent&> (aCompo).ResetDataL(iInstallRFs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   654
        m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   655
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   656
     	}
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   657
     
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   658
    iInstallRFs.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   659
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   660
    iInstallInProgress = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   661
#ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   662
    iInstaller.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   663
#endif
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   664
    RDEBUG("CApplicationManagementServer::InstallCompleteL end");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   665
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   666
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   667
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   668
// CApplicationManagementServer::GenerateTempJarFileNameL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   669
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   670
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   671
void CApplicationManagementServer::GenerateTempJarFileNameL(RFs &aFs,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   672
        const TDesC& aMetaSource, TFileName &aFileName) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   673
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   674
    if (aMetaSource != KNullDesC)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   675
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   676
        RFile file;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   677
        User::LeaveIfError(file.Open(aFs, aMetaSource, EFileRead));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   678
        CleanupClosePushL(file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   679
        TFileName temp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   680
        temp = ReadJarFileNameL(file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   681
        GenerateTempFileNameL(aFs, temp, aFileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   682
        CleanupStack::PopAndDestroy(&file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   683
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   684
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   685
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   686
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   687
// CApplicationManagementServer::GenerateTempFileNameL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   688
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   689
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   690
void CApplicationManagementServer::GenerateTempFileNameL(const RFs &aFs,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   691
        const TDesC& aSource, TFileName &aFileName) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   692
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   693
    if (aSource != KNullDesC)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   694
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   695
        aFileName.Copy(KInstallDir);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   696
        TParse p;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   697
        User::LeaveIfError(aFs.Parse(aSource, p));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   698
        aFileName.Append(p.NameAndExt());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   699
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   700
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   701
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   702
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   703
// CApplicationManagementServer::GenerateTempFileNameL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   704
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   705
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   706
void CApplicationManagementServer::GenerateTempFileNameL(RFs &aFs,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   707
        const CDeploymentComponent& aCompo, TFileName& aSource,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   708
        TFileName &aMetaSource, TFileName &aFileName,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   709
        TFileName &aMetaFileName) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   710
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   711
    if (!BaflUtils::FolderExists(aFs, KInstallDir))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   712
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   713
        aFs.MkDirAll(KInstallDir);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   714
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   715
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   716
    aMetaSource.Copy(aCompo.MetaData().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   717
    GenerateTempFileNameL(aFs, aMetaSource, aMetaFileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   718
    aSource.Copy(aCompo.Data().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   719
    GenerateTempJarFileNameL(aFs, aMetaSource, aFileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   720
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   721
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   722
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   723
// CApplicationManagementServer::GenerateTempFileNameL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   724
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   725
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   726
void CApplicationManagementServer::GenerateTempFileNameL(RFs &aFs,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   727
        const CDeploymentComponent& aCompo, TFileName &aFileName,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   728
        TFileName &aMetaFileName) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   729
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   730
    TFileName ftemp, msource;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   731
    GenerateTempFileNameL(aFs, aCompo, ftemp, msource, aFileName,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   732
            aMetaFileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   733
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   734
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   735
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   736
// CApplicationManagementServer::ReadJarFileNameL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   737
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   738
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   739
TFileName CApplicationManagementServer::ReadJarFileNameL(RFile& aFile) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   740
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   741
    TFileName jarFileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   742
    HBufC8* lineBuffer = HBufC8::NewLC(KMaxFileName + 72); // lets hope all lines fit to this
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   743
    TPtr8 linePtr(lineBuffer->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   744
    TInt length(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   745
    aFile.Size(length);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   746
    HBufC8* data = HBufC8::NewLC(length);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   747
    TPtr8 ptr(data->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   748
    aFile.Read(ptr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   749
    RDesReadStream stream(*data);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   750
    CleanupClosePushL(stream);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   751
    TInt colonIndex = -1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   752
    TInt err(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   753
    TInt found(KErrNotFound);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   754
    const TInt KJadNameValueSeparator = 0x3A; //':' 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   755
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   756
    for (;;)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   757
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   758
        TRAP( err, ReadLineL(stream, linePtr) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   759
        if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   760
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   761
            RDEBUG8_2("Read line: (%S)", &linePtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   762
            found = linePtr.Find(KMIDletJarURL);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   763
            if (found != KErrNotFound && found == 0) // found
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   764
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   765
                TPtrC8 filename(linePtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   766
                colonIndex = linePtr.Locate(KJadNameValueSeparator);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   767
                if (colonIndex != KErrNotFound)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   768
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   769
                    filename.Set(linePtr.Mid(colonIndex + 1)); // get jar filename, format is: MIDlet-Jar-URL: bomber.jar
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   770
                    jarFileName.Copy(filename);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   771
                    jarFileName.Trim();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   772
                    break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   773
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   774
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   775
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   776
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   777
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   778
            User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   779
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   780
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   781
    CleanupStack::PopAndDestroy(3, lineBuffer); // stream, data
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   782
    return jarFileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   783
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   784
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   785
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   786
// CApplicationManagementServer::ReadLineL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   787
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   788
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   789
void CApplicationManagementServer::ReadLineL(RReadStream& aStream,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   790
        TDes8& aLineBuffer) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   791
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   792
    TBuf8<1> input;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   793
    const TUint32 LF = 10;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   794
    const TUint32 CR = 13;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   795
    TBool endOfLine(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   796
    TInt errRead(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   797
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   798
    // reset
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   799
    aLineBuffer.Zero();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   800
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   801
    while (!endOfLine)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   802
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   803
        TRAP(errRead, aStream.ReadL(input, 1));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   804
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   805
        if (errRead == KErrEof)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   806
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   807
            // EOF
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   808
            User::Leave(KErrEof);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   809
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   810
        // check special characters	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   811
        if (input[0] == LF)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   812
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   813
            // End of line
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   814
            endOfLine = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   815
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   816
        else if (input[0] == CR)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   817
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   818
            // Only end of line if not followed by a LF
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   819
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   820
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   821
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   822
            // We put any other character in the buffer
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   823
            if (aLineBuffer.Length() < aLineBuffer.MaxLength())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   824
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   825
                aLineBuffer.Append(input[0]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   826
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   827
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   828
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   829
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   830
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   831
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   832
// CApplicationManagementServer::PrepareInstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   833
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   834
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   835
TBool CApplicationManagementServer::PrepareInstallL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   836
        const CDeploymentComponent &aComponent, TFileName &aFileName)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   837
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   838
    RDEBUG( "CApplicationManagementServer::PrepareInstallL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   839
    TBool res(ETrue);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   840
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   841
#ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   842
    TInt err(iInstaller.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   843
    if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   844
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   845
        RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - ERROR leaving cannot connect installer: %d", err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   846
        User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   847
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   848
    CleanupClosePushL(iInstaller);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   849
#endif
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   850
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   851
    RDEBUG( "CApplicationManagementServer::PrepareInstallL - connected to installer" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   852
    // Copy data file name (install file)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   853
    if (aComponent.Data().DataFileName().Length() > 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   854
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   855
        aFileName.Copy(aComponent.Data().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   856
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   857
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   858
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   859
        // data file has not been created for component!	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   860
        User::Leave(KErrNotFound);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   861
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   862
    // Open RFs session
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   863
    User::LeaveIfError(iInstallRFs.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   864
    User::LeaveIfError(iInstallRFs.ShareProtected());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   865
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   866
    // set installoptions and correct mime type
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   867
    using namespace SwiUI;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   868
    iInstallOptions = aComponent.InstallOpts().iOptions;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   869
    TInstallReq req;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   870
    if (aComponent.Data().MimeType() == SwiUI::KSisMimeType)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   871
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   872
        //convert if MIME type is application/vnd.symbian.install to x-epoc/x-sisx-app
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   873
        //as installer doesn't support application/vnd.symbian.install MIME type from S60 3rd edition onwards.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   874
        req.iMIME = SwiUI::KSisxMimeType;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   875
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   876
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   877
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   878
        req.iMIME = aComponent.Data().MimeType();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   879
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   880
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   881
    if (CDeploymentComponent::IsJavaMimeL(aComponent.MetaData().MimeType()))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   882
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   883
        // Check if both jad and jar files already exist in the phone	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   884
        if (CDeploymentComponent::IsJavaMimeL(aComponent.Data().MimeType())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   885
                && aComponent.MetaData().MimeType() == SwiUI::KJadMIMEType)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   886
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   887
            // Move both files to temporary location and use jad to install java application
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   888
            CFileMan *fm = CFileMan::NewL(iInstallRFs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   889
            CleanupStack::PushL(fm);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   890
            TFileName source, metasource, metatarget;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   891
            aFileName.Copy(KNullDesC8()); // reset
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   892
            GenerateTempFileNameL(iInstallRFs, aComponent, source,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   893
                    metasource, aFileName, metatarget);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   894
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   895
            RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - temp jar file '%S'", &aFileName );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   896
            RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - temp jad file '%S'", &metatarget );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   897
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   898
            // Copy datafile (jar)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   899
            TInt copyer(fm->Copy(source, aFileName));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   900
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   901
            // Copy metadatafile (jad)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   902
            TInt copyer2(fm->Copy(metasource, metatarget));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   903
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   904
            CleanupStack::PopAndDestroy(fm);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   905
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   906
            RDEBUG_3( "CApplicationManagementServer::PrepareInstallL - (%d)-(%d)", copyer, copyer2 );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   907
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   908
            if (copyer == KErrNone && copyer2 == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   909
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   910
                res = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   911
                aFileName = metatarget;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   912
                req.iMIME = aComponent.MetaData().MimeType();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   913
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   914
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   915
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   916
                User::Leave(KErrWrite);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   917
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   918
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   919
        else if (aComponent.MetaData().MimeType() == SwiUI::KJadMIMEType)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   920
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   921
            aFileName.Copy(aComponent.MetaData().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   922
            req.iMIME = aComponent.MetaData().MimeType();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   923
            RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - Using Jad file to install java application: %S", &aFileName );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   924
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   925
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   926
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   927
    if (aComponent.GetIAP() > -1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   928
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   929
        req.iIAP = aComponent.GetIAP();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   930
        RDEBUG_2( "CApplicationManagementServer::PrepareInstallL: setting iap to %d", req.iIAP );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   931
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   932
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   933
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   934
        TInt iap = KErrNotFound;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   935
        TRAPD( err, SmlHelper::GetDefaultIAPFromDMProfileL( iap ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   936
        if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   937
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   938
            req.iIAP = iap;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   939
            RDEBUG_2("	-> using DM profile default IAP: %d", iap);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   940
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   941
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   942
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   943
            RDEBUG_2("**** ERROR while fetching DM profile default iap: %d", err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   944
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   945
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   946
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   947
    iInstallReq = SwiUI::TInstallReqPckg(req);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   948
    RDEBUG8_2( "CApplicationManagementServer::PrepareInstallL: mime type is (%S)", &req.iMIME);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   949
    RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - Using temp file '%S'", &aFileName );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   950
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   951
    User::LeaveIfError(iInstallFile.Open(iInstallRFs, aFileName, EFileRead));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   952
    TInt sz;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   953
    User::LeaveIfError(iInstallFile.Size(sz));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   954
    if (!(sz > 0))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   955
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   956
        res = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   957
        RDEBUG( "CApplicationManagementServer::PrepareInstallL - ERROR size of source file is 0!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   958
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   959
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   960
#ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_   
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   961
    CleanupStack::Pop(&iInstaller);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   962
#endif
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   963
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   964
    RDEBUG( "CApplicationManagementServer::PrepareInstallL end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   965
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   966
    iAppname = aFileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   967
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   968
    return res;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   969
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   970
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   971
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   972
// CApplicationManagementServer::InstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   973
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   974
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   975
void CApplicationManagementServer::InstallL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   976
        const CDeploymentComponent &aComponent, TRequestStatus &aStatus)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   977
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   978
    RDEBUG( "CApplicationManagementServer::InstallL (async): begin" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   979
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   980
    if (iInstallInProgress == EFalse)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   981
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   982
        TFileName fn;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   983
        TInt type = EInstallWaitDlg;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   984
        TInt silentsession = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   985
        TInt r2 = RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   986
                silentsession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   987
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   988
	  if(r2 == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   989
		CApplicationManagementUtility::iSilentSession = silentsession;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   990
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   991
        if (!CApplicationManagementUtility::iSilentSession)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   992
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   993
            m_Dlg = new AMWaitProgDialog(m_appName, *this);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   994
            m_Dlg->createWaitDialog(type);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   995
            if (CApplicationManagementUtility::mHidden == 1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   996
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   997
                m_Dlg->startIndicator();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   998
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   999
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1000
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1001
                m_Window->raise();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1002
                CApplicationManagementUtility::mCurrDlg->setVisible(true);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1003
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1004
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1005
        if (PrepareInstallL(aComponent, fn))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1006
            {	  
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1007
            if (m_Dlg)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1008
                m_Dlg->registerInstallRequest(aStatus);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1009
            delete iArgu;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1010
            iArgu = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1011
            iArgu = Usif::COpaqueNamedParams::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1012
            iArgu->AddIntL(Usif::KSifInParam_InstallSilently, 1);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1013
            TAMInstallOptions opts = aComponent.InstallOpts();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1014
            TChar drive = opts.iOptions.iDrive;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1015
            RFs iFs;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1016
            TInt driveNumber;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1017
            iFs.CharToDrive(drive,driveNumber);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1018
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1019
            iArgu->AddIntL(Usif::KSifInParam_Drive, driveNumber);  
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1020
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1021
            delete iResults;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1022
            iResults = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1023
            iResults = Usif::COpaqueNamedParams::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1024
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1025
            RDEBUG_3( "CApplicationManagementServer::InstallL: Install '%S' sizeof opts: %d", &fn, sizeof (aComponent.InstallOpts()));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1026
		TRAPD( err ,iInstaller.Install( iInstallFile, *iArgu, *iResults, aStatus ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1027
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1028
            RDEBUG_2( "CApplicationManagementServer::InstallL: status: %d", err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1029
            User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1030
            iInstallInProgress = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1031
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1032
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1033
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1034
            RDEBUG( "CApplicationManagementServer::InstallL - PrepareInstallL failed, leaving" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1035
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1036
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1037
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1038
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1039
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1040
        RDEBUG( "CApplicationManagementServer::InstallL (async): previous install still in progress...bailing out" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1041
        TRequestStatus * status = &aStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1042
        User::RequestComplete(status, KErrInUse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1043
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1044
    RDEBUG( "CApplicationManagementServer::InstallL (async): end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1045
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1046
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1047
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1048
// CApplicationManagementServer::PrepareInstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1049
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1050
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1051
void CApplicationManagementServer::InstallL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1052
        const CDeploymentComponent &aComponent)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1053
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1054
    RDEBUG( "CApplicationManagementServer::InstallL: begin" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1055
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1056
    if (iInstallInProgress == EFalse)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1057
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1058
        TFileName fn;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1059
        if (PrepareInstallL(aComponent, fn))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1060
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1061
            iInstallInProgress = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1062
            RDEBUG_2( "CApplicationManagementServer::InstallL: Install '%S' ", &fn);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1063
            SwiUI::TInstallOptionsPckg pkg(aComponent.InstallOpts().iOptions);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1064
            iInstallInProgress = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1065
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1066
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1067
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1068
            RDEBUG( "CApplicationManagementServer::InstallL - PrepareInstallL failed, leaving" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1069
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1070
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1071
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1072
    RDEBUG( "CApplicationManagementServer::InstallL: end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1073
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1074
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1075
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1076
// CApplicationManagementServer::UninstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1077
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1078
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1079
void CApplicationManagementServer::UninstallL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1080
        const CDeploymentComponent &aComponent, TRequestStatus &aStatus)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1081
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1082
    RDEBUG( "CApplicationManagementServer::UninstallL: begin" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1083
    if (iInstallInProgress == EFalse)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1084
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1085
        TInt err(iInstaller.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1086
        User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1087
        RDEBUG_2( "CApplicationManagementServer::UninstallL: UninstallL '0x%X' ", aComponent.Uid());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1088
        using namespace SwiUI;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1089
        iUninstallOptions = aComponent.UninstallOpts();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1090
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1091
        delete iArgu;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1092
        iArgu = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1093
        iArgu = Usif::COpaqueNamedParams::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1094
        iArgu->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1095
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1096
        delete iResults;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1097
        iResults = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1098
        iResults = Usif::COpaqueNamedParams::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1099
        TRAP( err ,iInstaller.Uninstall( aComponent.GetComponentId(), *iArgu, *iResults, aStatus ));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1100
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1101
        RDEBUG_2( "CApplicationManagementServer::UninstallL: UninstallL result '0x%X'", err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1102
        User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1103
        iInstallInProgress = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1104
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1105
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1106
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1107
        RDEBUG( "CApplicationManagementServer::UninstallL: previous uninstall still in progress...bailing out" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1108
        TRequestStatus * status = &aStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1109
        User::RequestComplete(status, KErrInUse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1110
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1111
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1112
    RDEBUG( "CApplicationManagementServer::UninstallL: end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1113
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1114
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1115
// CApplicationManagementServer::PerformRFSL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1116
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1117
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1118
void CApplicationManagementServer::PerformRFSL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1119
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1120
    RDEBUG( "CApplicationManagementServer::PerformRFSL: begin" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1121
    const RComponentIdArray &arrt = iStorage->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1122
    TCertInfoPckg *corcert = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1123
    for (TInt i(0); i < arrt.Count(); i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1124
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1125
        RDEBUG_3( "CApplicationManagementServer::PerformRFSL processing dc %d of %d", i, arrt.Count() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1126
        CDeploymentComponent &c = iStorage->ComponentL(arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1127
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1128
        const RCertArray &certs = iStorage->Certificates();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1129
        TInt index = c.Owner();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1130
        TCertInfoPckg *certp = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1131
        if (index >= 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1132
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1133
            certp = certs[c.Owner()];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1134
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1135
        if (!corcert && certp)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1136
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1137
            if (CheckCertL((*certp)()))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1138
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1139
                corcert = certp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1140
                RDEBUG_2( "CApplicationManagementServer::PerformRFSL Found CORP Cert! Removing %d ", i );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1141
                RemoveInternalL(c);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1142
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1143
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1144
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1145
                RDEBUG_2( "CApplicationManagementServer::PerformRFSL skipping %d because not corp dc", i );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1146
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1147
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1148
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1149
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1150
            if (corcert == certp)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1151
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1152
                RDEBUG_2( "CApplicationManagementServer::PerformRFSL Removing %d ", i );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1153
                RemoveInternalL(c);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1154
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1155
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1156
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1157
                RDEBUG_2( "CApplicationManagementServer::PerformRFSL skipping %d because not corp dc", i );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1158
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1159
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1160
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1161
    RDEBUG( "CApplicationManagementServer::PerformRFSL: end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1162
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1163
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1164
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1165
// CApplicationManagementServer::RemoveInternalL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1166
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1167
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1168
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1169
void CApplicationManagementServer::RemoveInternalL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1170
        const CDeploymentComponent &aCompo, TBool aDoUninstall /* = ETrue */)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1171
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1172
    RDEBUG_2("CApplicationManagementServer: RemoveInternalL - Remove id: (%d)", aCompo.InternalId() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1173
    TInt err(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1174
    TDeploymentComponentName name = aCompo.ComponentName();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1175
    TBuf<KDeploymentComponentNameMaxLength> ne;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1176
    ne.Copy(name);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1177
    m_appName = QString::fromUtf16(ne.Ptr(), ne.Length());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1178
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1179
    RDEBUG("CApplicationManagementServer: RemoveInternalL - step1");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1180
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1181
    TInt err1 = KErrNone;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1182
    if (!err1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1183
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1184
        RDEBUG("CApplicationManagementServer: RemoveInternalL - step2");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1185
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1186
        aCompo.SetStatusNode(EDelivered_RemoveProgress);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1187
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1188
        TDeploymentComponentState st(aCompo.State());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1189
        if (st == EDCSDelivered || st == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1190
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1191
            RDEBUG("CApplicationManagementServer: RemoveInternalL - step3 start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1192
            TRAP(err,iStorage->RemoveL( aCompo.InternalId() ));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1193
            RDEBUG("CApplicationManagementServer: RemoveInternalL - step4 start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1194
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1195
        else if (st == EDCSActive || st == EDCSInactive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1196
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1197
            RDEBUG("CApplicationManagementServer: RemoveInternalL - step5 start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1198
            if (aDoUninstall)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1199
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1200
                if (aCompo.Uid() != TUid::Null())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1201
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1202
                    TInt nonSilentOperation = KErrNotFound;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1203
                    iOMASCOMOEnabled = IsOMASCOMOEnabledL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1204
                    if (!iOMASCOMOEnabled)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1205
                        nonSilentOperation = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1206
                    RDEBUG("CApplicationManagementServer: RemoveInternalL - step5 start 1");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1207
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1208
                    TInt silentsession = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1209
                    RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1210
                            silentsession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1211
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1212
                    CApplicationManagementUtility::iSilentSession
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1213
                            = silentsession;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1214
                    TRequestStatus s1 = KRequestPending;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1215
                    AppMgmtNotifier* note = new AppMgmtNotifier(m_appName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1216
                    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1217
                    // displaying uninstall confirm notes
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1218
                    if (!CApplicationManagementUtility::iSilentSession)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1219
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1220
                        CDialogWait* wait = CDialogWait::NewL(); 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1221
                        note->showUninstallDialog(aCompo, wait->iStatus);     
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1222
                        m_Window->raise();   
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1223
                        wait->StartWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1224
                        s1=wait->iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1225
                        delete wait;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1226
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1227
                    if (s1 != KStatusUserCancelled)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1228
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1229
                        TInt type = EUninstallWaitDlg;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1230
                        TRequestStatus s;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1231
                        if (!CApplicationManagementUtility::iSilentSession)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1232
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1233
                            m_Dlg = new AMWaitProgDialog(m_appName, *this);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1234
                            m_Dlg->createWaitDialog(type);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1235
                            m_Window->raise();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1236
                            CApplicationManagementUtility::mCurrDlg->setVisible(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1237
                                        true);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1238
                                
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1239
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1240
                        CDialogWait* wait1 = CDialogWait::NewL();           
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1241
                     
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1242
                        TRAP(err,UninstallL( aCompo, wait1->iStatus ));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1243
                        //wait till uninstall completes
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1244
                        wait1->StartWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1245
                        if (!CApplicationManagementUtility::iSilentSession)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1246
                            m_Dlg->closeAMWaitDialog();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1247
                        m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1248
                        s = wait1->iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1249
                        delete wait1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1250
                        iInstallInProgress = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1251
                        // Capturing Installer errors,if any
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1252
                        err = s.Int();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1253
                        if (s.Int() == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1254
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1255
                            note->showUnInstallSuccessNote();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1256
                            RDEBUG("CApplicationManagementServer::RemoveInternalL Uninstalled");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1257
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1258
                        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1259
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1260
                            note->showUnInstallFailedNote();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1261
                            if (s.Int() == KErrNotFound)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1262
                                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1263
                                RDEBUG( "CApplicationManagementServer: RemoveInternalL WARNING component was not found by uninstaller" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1264
                                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1265
                            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1266
                                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1267
                                RDEBUG_2("CApplicationManagementServer: RemoveInternalL ERROR uninstall failed %d", s.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1268
                                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1269
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1270
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1271
                    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1272
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1273
                        err = SwiUI::KSWInstErrUserCancel;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1274
                        aCompo.SetStatusNode(EDelivered_RemoveFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1275
                        RDEBUG( "CApplicationManagementServer: RemoveInternalL User cancelled" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1276
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1277
                    delete note;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1278
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1279
                else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1280
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1281
                    RDEBUG( "CApplicationManagementServer: RemoveInternalL ERROR component is deployed but has null uid - it cannot be uninstalled!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1282
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1283
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1284
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1285
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1286
                RDEBUG_2("CApplicationManagementServer: RemoveInternalL - Skipped uninstall of %d", aCompo.InternalId() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1287
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1288
            /*
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1289
             *   if (unstall is sucesss) then remove component from storage
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1290
             *   
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1291
             */
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1292
            if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1293
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1294
                iStorage->RemoveL(aCompo.InternalId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1295
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1296
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1297
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1298
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1299
            RDEBUG_2("CApplicationManagementServer: RemoveInternalL ERROR called with illegal state component id %d", aCompo.State() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1300
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1301
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1302
        /*  
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1303
         * if error set state to remove failed
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1304
         * Finally call userleaveiferror()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1305
         * */
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1306
        if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1307
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1308
            aCompo.SetStatusNode(EDelivered_RemoveFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1309
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1310
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1311
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1312
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1313
        err = SwiUI::KSWInstErrUserCancel;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1314
        aCompo.SetStatusNode(EDelivered_RemoveFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1315
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1316
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1317
    User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1318
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1319
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1320
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1321
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1322
// CApplicationManagementServer::CheckCertL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1323
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1324
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1325
TBool CApplicationManagementServer::CheckCertL(const TCertInfo &aInfo) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1326
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1327
    TBool go(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1328
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1329
    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1330
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1331
        //	#ifdef __SAP_POLICY_MANAGEMENT
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1332
        RPolicyEngine peng;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1333
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1334
        // The management session
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1335
        //
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1336
        TInt err(peng.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1337
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1338
        if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1339
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1340
            CleanupClosePushL(peng);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1341
            RPolicyRequest rq;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1342
            err = rq.Open(peng);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1343
            if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1344
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1345
                CleanupClosePushL(rq);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1346
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1347
                TRequestContext rc;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1348
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1349
                using namespace PolicyEngineXACML;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1350
                using namespace NPolicyConstants;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1351
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1352
                rc.AddSubjectAttributeL(KTrustedSubject, aInfo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1353
                rc.AddResourceAttributeL(KResourceId, KApplicationManagement,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1354
                        KStringDataType);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1355
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1356
                TResponse resp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1357
                err = rq.MakeRequest(rc, resp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1358
                if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1359
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1360
                    if (resp.GetResponseValue() == EResponsePermit
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1361
#ifdef _DEBUG
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1362
                            || resp.GetResponseValue()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1363
                                    == EResponseNotApplicable
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1364
#endif 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1365
                    )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1366
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1367
                        go = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1368
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1369
                    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1370
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1371
                        RDEBUG_2( "CApplicationManagementSession::CheckCertL; Policy response denies access! %d", resp.GetResponseValue());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1372
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1373
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1374
                else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1375
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1376
                    RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR making policy request! %d", err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1377
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1378
                CleanupStack::PopAndDestroy(&rq);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1379
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1380
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1381
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1382
                RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR Failed to open policy engine session! %d", err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1383
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1384
            CleanupStack::PopAndDestroy(&peng);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1385
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1386
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1387
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1388
            RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR Failed to connect policy engine! %d", err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1389
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1390
        User::LeaveIfError(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1391
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1392
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1393
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1394
        RDEBUG( "CApplicationManagementSession::CheckCertL; No PolicyManagement by featmgr-> cert ok!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1395
        go = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1396
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1397
    return go;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1398
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1399
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1400
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1401
// CApplicationManagementServer::HasUidL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1402
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1403
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1404
TBool CApplicationManagementServer::HasUidL(const TUid &aUid,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1405
        CDeploymentComponent *& aCompo, CDeploymentComponent *aIgnored /* = NULL */)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1406
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1407
    TBool found(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1408
    const RComponentIdArray &arrt = iStorage->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1409
    TInt count(arrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1410
    for (TInt i(0); i < count; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1411
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1412
        CDeploymentComponent &compo = iStorage->ComponentL(arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1413
        if (compo.Uid() == aUid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1414
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1415
            if (&compo != aIgnored)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1416
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1417
                aCompo = &compo;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1418
                found = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1419
                RDEBUG_3( "ApplicationManagementServer: UidExistsL 0x%X - Found NOT ignored %d", aUid.iUid, compo.InternalId() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1420
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1421
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1422
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1423
                RDEBUG( "ApplicationManagementServer: UidExistsL - Found ignored " );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1424
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1425
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1426
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1427
    if (!found)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1428
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1429
        found = FindInstalledSisUidL(aUid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1430
        if (!found)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1431
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1432
            found = FindInstalledJavaUidL(aUid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1433
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1434
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1435
    return found;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1436
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1437
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1438
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1439
// CApplicationManagementServer::FindInstalledSisUidL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1440
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1441
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1442
TBool CApplicationManagementServer::FindInstalledSisUidL(const TUid &aUid) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1443
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1444
    TBool found(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1445
    Swi::RSisRegistrySession sisses;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1446
    TInt r(sisses.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1447
    User::LeaveIfError(r);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1448
    CleanupClosePushL(sisses);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1449
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1450
    RArray<TUid> uids;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1451
    sisses.InstalledUidsL(uids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1452
    CleanupClosePushL(uids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1453
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1454
    TInt uidc(uids.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1455
    for (TInt j(0); found == EFalse && j < uidc; j++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1456
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1457
        if (uids[j] == aUid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1458
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1459
            found = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1460
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1461
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1462
    CleanupStack::PopAndDestroy(&uids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1463
    CleanupStack::PopAndDestroy(&sisses);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1464
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1465
    return found;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1466
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1467
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1468
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1469
// CApplicationManagementServer::FindInstalledJavaUidL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1470
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1471
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1472
TBool CApplicationManagementServer::FindInstalledJavaUidL(const TUid &aUid) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1473
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1474
    TBool found(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1475
    iUtility->RefreshJavaRegistryL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1476
    found = iUtility->FindInstalledJavaUidL(aUid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1477
    return found;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1478
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1479
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1480
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1481
// CApplicationManagementServer::FindNewUid()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1482
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1483
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1484
TUid CApplicationManagementServer::FindNewUid(const RArray<TUid> &aUidsOrig,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1485
        const RArray<TUid> &aUidsNew) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1486
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1487
    TUid ret(TUid::Null());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1488
    TInt c1(aUidsOrig.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1489
    TInt c2(aUidsNew.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1490
    if (c2 >= c1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1491
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1492
        for (TInt i(c2 - 1); i >= 0 && !ret.iUid; i--)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1493
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1494
            if (aUidsOrig.Find(aUidsNew[i]) == KErrNotFound)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1495
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1496
                ret = aUidsNew[i];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1497
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1498
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1499
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1500
    return ret;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1501
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1502
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1503
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1504
// CApplicationManagementServer::JavaUidsL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1505
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1506
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1507
void CApplicationManagementServer::JavaUidsL(RArray<TUid> &aUids) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1508
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1509
    iUtility->RefreshJavaRegistryL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1510
    iUtility->JavaUidsL(aUids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1511
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1512
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1513
void CApplicationManagementServer::CheckforDuplicateMidletsL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1514
        TMidletParameters& amidletParameters)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1515
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1516
    RDEBUG( "CApplicationManagementServer::CheckforDuplicateMidletsL: Start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1517
    const RComponentIdArray &arrt = iStorage->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1518
    TInt cont(arrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1519
    for (TInt i( 0); i < cont; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1520
     {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1521
     CDeploymentComponent &compo = iStorage->ComponentL(arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1522
     if (((compo.State() == EDCSActive) || (compo.State() == EDCSInactive ))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1523
     && (compo.MidletName()== amidletParameters.iMidletName)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1524
     && (compo.MidletVendor()== amidletParameters.iMidletVenorName))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1525
     {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1526
     //remove old one
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1527
     iStorage->RemoveL(compo.InternalId() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1528
     }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1529
     }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1530
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1531
    RDEBUG( "CApplicationManagementServer::CheckforDuplicateMidletsL: End");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1532
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1533
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1534
// CApplicationManagementServer::JavaInstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1535
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1536
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1537
void CApplicationManagementServer::JavaInstallL(CDeploymentComponent &aCompo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1538
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1539
    RDEBUG( "CApplicationManagementServer::JavaInstallL: Start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1540
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1541
    //TRequestStatus s;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1542
    TInt err(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1543
    // set state to install progressf
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1544
    CDialogWait* wait = CDialogWait::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1545
    aCompo.SetStatusNode(EDelivered_InstallProgress);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1546
    TRAP(err,InstallL( aCompo,wait->iStatus ));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1547
    if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1548
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1549
        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1550
        User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1551
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1552
    wait->StartWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1553
    if (!CApplicationManagementUtility::iSilentSession && CApplicationManagementUtility::mCurrDlg)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1554
        m_Dlg->closeAMWaitDialog();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1555
    m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1556
    TRequestStatus s1 = wait->iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1557
    delete wait;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1558
    RDEBUG_2( "ApplicationManagementSession: JavaInstallL 1 failed with code %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1559
                s1.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1560
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1561
    TInt usifdeplid = -1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1562
        if (iResults && wait->iStatus.Int()!=KErrCancel)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1563
	  {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1564
            iResults->GetIntByNameL(Usif::KSifOutParam_ComponentId, usifdeplid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1565
    		RDEBUG_2( "ApplicationManagementSession: JavaInstallL usifdeplid %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1566
                usifdeplid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1567
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1568
	  }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1569
      RDEBUG( "wait->StartWait() CApplicationManagementServer::javainstallL Step3");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1570
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1571
        aCompo.SetComponentId(usifdeplid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1572
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1573
         s1 = wait->iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1574
        delete wait;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1575
        RDEBUG_2("ApplicationManagementSession: javainstallL with code %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1576
                        s1.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1577
    if (s1 == KErrCancel)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1578
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1579
        RDEBUG_2( "ApplicationManagementSession: JavaInstallL failed with code %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1580
                s1.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1581
        // set state to install failed with data
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1582
        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1583
        User::Leave(s1.Int());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1584
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1585
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1586
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1587
        TMidletParameters midletParameters;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1588
        iUtility->RefreshJavaRegistryL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1589
        //Ignore if any error comes
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1590
        TRAPD(err,iUtility->GetInstalledMidletParametersL(midletParameters));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1591
        TRAP(err,CheckforDuplicateMidletsL(midletParameters));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1592
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1593
        if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1594
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1595
            aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1596
            User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1597
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1598
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1599
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1600
            aCompo.SetStatusNode(EIdle);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1601
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1602
        aCompo.SetUid(midletParameters.iMidletUid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1603
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1604
        RDEBUG( "CApplicationManagementServer::JavaInstallL: Step1");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1605
        if (aCompo.ComponentVersion() == KNullDesC8)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1606
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1607
            aCompo.SetVersionL(midletParameters.bufVersion);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1608
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1609
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1610
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1611
        TBool status = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1612
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1613
        //Since "C" drive is not removable
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1614
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1615
        if (midletParameters.iDrive != EDriveC)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1616
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1617
            status = IsInstalledAppRemovableL(midletParameters.iDrive);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1618
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1619
        if (status)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1620
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1621
            RDEBUG( "IsInstalledAppRemovableL(midletParameters.iDrive); True");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1622
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1623
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1624
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1625
            RDEBUG( "IsInstalledAppRemovableL(midletParameters.iDrive); False");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1626
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1627
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1628
        //check for status drive
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1629
        aCompo.SetAppRemovableStatus(status);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1630
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1631
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1632
    RDEBUG( "CApplicationManagementServer::JavaInstallL: End");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1633
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1634
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1635
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1636
// CApplicationManagementServer::SisInstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1637
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1638
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1639
void CApplicationManagementServer::SisInstallL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1640
        const CDeploymentComponent &aCompo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1641
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1642
    TRequestStatus s;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1643
    CDialogWait* wait = CDialogWait::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1644
    // set state to install progress
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1645
    aCompo.SetStatusNode(EDelivered_InstallProgress);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1646
    TInt err(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1647
    TRAP(err,InstallL( aCompo,wait->iStatus ));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1648
    if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1649
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1650
        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1651
        User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1652
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1653
    RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code before startwait %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1654
            wait->iStatus.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1655
    wait->StartWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1656
    RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code after startwait %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1657
                wait->iStatus.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1658
    RDEBUG( "wait->StartWait() CApplicationManagementServer::SisInstallL Step1");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1659
    if (!CApplicationManagementUtility::iSilentSession && CApplicationManagementUtility::mCurrDlg)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1660
        m_Dlg->closeAMWaitDialog();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1661
    delete m_Dlg;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1662
    m_Dlg=NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1663
    RDEBUG( "wait->StartWait() CApplicationManagementServer::SisInstallL Step2");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1664
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1665
    m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1666
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1667
    TInt usifdeplid = -1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1668
    if (iResults && wait->iStatus.Int()!=KErrCancel)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1669
        iResults->GetIntByNameL(Usif::KSifOutParam_ComponentId, usifdeplid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1670
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1671
    RDEBUG( "wait->StartWait() CApplicationManagementServer::SisInstallL Step3");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1672
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1673
    iComp->SetComponentId(usifdeplid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1674
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1675
    TRequestStatus s1 = wait->iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1676
    delete wait;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1677
    RDEBUG_2("ApplicationManagementSession: SisInstallL with code %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1678
                    s1.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1679
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1680
    if(s1 == KErrCancel)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1681
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1682
        s1 = KStatusUserCancelled;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1683
        RDEBUG( "KErrCancel visited operation cancelled");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1684
        mUserCancelled=1;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1685
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1686
    if (s1 != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1687
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1688
        RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1689
                s1.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1690
        // set state to install failed with data
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1691
        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1692
        User::Leave(s1.Int());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1693
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1694
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1695
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1696
        // set state to install sucessful
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1697
        aCompo.SetStatusNode(EIdle);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1698
        RDEBUG("ApplicationManagementSession: SisInstallL successfull" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1699
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1700
    RDEBUG( "CApplicationManagementServer::SisInstallL: End");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1701
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1702
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1703
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1704
// CApplicationManagementServer::DoTheInstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1705
// ---------------------------------------------------- --------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1706
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1707
void CApplicationManagementServer::DoTheInstallL(CDeploymentComponent &aCompo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1708
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1709
    RDEBUG( "CApplicationManagementServer::DoTheInstallL: Start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1710
    TInt error(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1711
    iComp = &aCompo;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1712
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1713
    TDeploymentComponentName name = aCompo.ComponentName();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1714
    if(name.Compare(KNullDesC8())==0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1715
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1716
        name = aCompo.UserId();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1717
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1718
    TBuf<KDeploymentComponentNameMaxLength> nameBuf;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1719
    nameBuf.Copy(name);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1720
    m_appName = QString::fromUtf16(nameBuf.Ptr(), nameBuf.Length());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1721
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1722
    TRequestStatus stat = KErrCompletion;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1723
    if (!aCompo.DriveSelected()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1724
            && !CApplicationManagementUtility::iSilentSession)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1725
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1726
        // displaying install confirm notes
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1727
        CDialogWait* ao = CDialogWait::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1728
        AppMgmtNotifier* note = new AppMgmtNotifier();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1729
        int err = KErrNone;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1730
        TRAP( err, QT_TRYCATCH_LEAVING(note->showInstallDialog(iComp, ao->iStatus)));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1731
        ao->StartWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1732
        stat = ao->iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1733
        delete ao;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1734
        m_Window->lower();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1735
        delete note;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1736
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1737
    aCompo.SetDriveSelectionStatus(false);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1738
    if (stat == KErrCompletion)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1739
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1740
        if (CDeploymentComponent::IsJavaMimeL(aCompo.Data().MimeType())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1741
                || CDeploymentComponent::IsJavaMimeL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1742
                        aCompo.MetaData().MimeType()))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1743
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1744
            TRAP( error, JavaInstallL( aCompo ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1745
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1746
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1747
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1748
            TRAP( error, SisInstallL( aCompo ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1749
            if(error==KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1750
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1751
                SetSisAppVersionAndDriveL(aCompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1752
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1753
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1754
      
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1755
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1756
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1757
        if (error == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1758
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1759
            InstallCompleteL(aCompo, ETrue);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1760
            CDeploymentComponent *old = DoDataUpdateCheckL(aCompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1761
            if (old)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1762
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1763
                if (aCompo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1764
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1765
                    if (old->State() == EDCSActive || old->State()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1766
                            == EDCSInactive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1767
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1768
                        RDEBUG("AMSession: DoTheInstallL ** deleting old node **" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1769
                        iStorage->RemoveL(old->InternalId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1770
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1771
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1772
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1773
            iStorage->InstalledL(aCompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1774
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1775
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1776
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1777
            InstallCompleteL(aCompo, EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1778
            User::Leave(error);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1779
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1780
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1781
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1782
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1783
        aCompo.SetStatusNode(EDelivered_InstallFailedwithOutData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1784
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1785
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1786
    RDEBUG( "CApplicationManagementServer::DoTheInstallL: End");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1787
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1788
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1789
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1790
// CApplicationManagementServer::DoDataUpdateCheckL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1791
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1792
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1793
CDeploymentComponent *CApplicationManagementServer::DoDataUpdateCheckL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1794
        CDeploymentComponent &aCompo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1795
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1796
    CDeploymentComponent *old = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1797
    if (aCompo.Uid() != TUid::Null() && HasUidL(aCompo.Uid(), old, &aCompo))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1798
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1799
        // check for Uid component.. Legacy code removed.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1800
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1801
    return old;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1802
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1803
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1804
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1805
// CApplicationManagementServer::SetDataL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1806
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1807
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1808
void CApplicationManagementServer::SetDataL(CDeploymentComponent &aCompo,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1809
        const TDesC8 &aData, const TDesC8 &aMime)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1810
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1811
    aCompo.SetDataL(aData, aMime);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1812
    DoDataUpdateCheckL(aCompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1813
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1814
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1815
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1816
// CApplicationManagementServer::FullUpdateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1817
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1818
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1819
void CApplicationManagementServer::FullUpdateL(const TUint32 sid,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1820
        const TUint32 tid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1821
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1822
    CDeploymentComponent &scompo = iStorage->ComponentL(sid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1823
    CDeploymentComponent &tcompo = iStorage->ComponentL(tid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1824
    FullUpdateL(scompo, tcompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1825
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1826
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1827
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1828
// CApplicationManagementServer::FullUpdateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1829
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1830
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1831
void CApplicationManagementServer::FullUpdateL(CDeploymentComponent &scompo,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1832
        const CDeploymentComponent &tcompo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1833
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1834
    if (scompo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1835
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1836
        if (tcompo.State() == EDCSActive || tcompo.State() == EDCSInactive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1837
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1838
            TRequestStatus s2;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1839
            InstallL(scompo, s2);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1840
            User::WaitForRequest(s2);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1841
            if (s2 != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1842
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1843
                RDEBUG_2( "ApplicationManagementSession: FullUpdateL failed with code %d", s2.Int() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1844
                User::Leave(s2.Int());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1845
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1846
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1847
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1848
                InstallCompleteL(scompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1849
                // Before deleting old node ,copy node values which are not set in new node from old node
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1850
                if (scompo.ComponentId() == KNullDesC8)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1851
                    scompo.SetIdL(tcompo.ComponentId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1852
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1853
                if (scompo.ComponentName() == KNullDesC8)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1854
                    scompo.SetNameL(tcompo.ComponentName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1855
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1856
                if (scompo.ComponentVersion() == KNullDesC8)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1857
                    scompo.SetVersionL(tcompo.ComponentVersion());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1858
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1859
                //Tag tcompo state for deletion. Cant delete now, since nsmldmtree woudnt be updated
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1860
                //Remove the const'ness since state needs to be updated.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1861
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1862
                iStorage->SetDeploymentComponentState(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1863
                        const_cast<CDeploymentComponent &> (tcompo),
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1864
                        EDCSDelete);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1865
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1866
                iStorage->InstalledL(scompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1867
                RDEBUG( "ApplicationManagementSession: FullUpdateL ok" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1868
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1869
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1870
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1871
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1872
            RDEBUG_2( "ApplicationManagementSession: ERROR FullUpdateL called for illegal state component: %d!", scompo.State() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1873
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1874
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1875
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1876
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1877
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1878
        RDEBUG( "ApplicationManagementSession: ERROR FullUpdateL called for illegal state message!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1879
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1880
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1881
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1882
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1883
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1884
// CApplicationManagementServer::IsDataFileB64EncodedL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1885
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1886
TBool CApplicationManagementServer::IsDataFileB64EncodedL(RFile &aFile,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1887
        TInt& aLength)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1888
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1889
    RDEBUG("CApplicationManagementServer::IsDataFileB64EncodedL()  : start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1890
    TBool encoded = ETrue; // assume b64 encoded
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1891
    TInt bufSize(KBase64BufSize);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1892
    TInt offset(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1893
    HBufC8 *dataBuf = HBufC8::NewLC(bufSize);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1894
    TPtr8 dataPtr = dataBuf->Des();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1895
    aFile.Size(aLength);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1896
    aFile.Seek(ESeekStart, offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1897
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1898
    while (encoded)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1899
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1900
        aFile.Read(dataPtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1901
        if (!dataPtr.Length())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1902
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1903
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1904
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1905
        offset = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1906
        aFile.Seek(ESeekCurrent, offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1907
        RDEBUG_2("OFFSET: %d", offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1908
        encoded = CheckB64Encode(dataPtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1909
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1910
    RDEBUG_2("Encoded: %d", encoded);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1911
    CleanupStack::PopAndDestroy(dataBuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1912
    offset = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1913
    aFile.Seek(ESeekStart, offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1914
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1915
    RDEBUG("CApplicationManagementServer::IsDataFileB64EncodedL()  : end");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1916
    return encoded;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1917
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1918
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1919
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1920
// CApplicationManagementServer::CheckB64Encode( const TDesC8& aData )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1921
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1922
TBool CApplicationManagementServer::CheckB64Encode(const TDesC8& aData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1923
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1924
    TInt inputIndex = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1925
    TInt inputLen = aData.Length();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1926
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1927
    while (inputIndex < inputLen)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1928
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1929
        const TUint8& p = aData[inputIndex];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1930
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1931
        if ((p >= 48 && p <= 57) || (p >= 65 && p <= 90) || (p >= 97 && p
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1932
                <= 122) || p == 43 || p == 47 || p == 61 || p == 10 || p
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1933
                == 13)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1934
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1935
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1936
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1937
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1938
            return EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1939
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1940
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1941
        inputIndex++;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1942
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1943
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1944
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1945
    return ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1946
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1947
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1948
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1949
// CApplicationManagementServer::GetAMServerDownloadDBL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1950
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1951
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1952
void CApplicationManagementServer::GetAMServerDownloadDBL(TUint32 internalid,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1953
        TInt& finalresult, TDes8& aTargetURI)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1954
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1955
    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step1" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1956
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1957
    TBuf<50> internalidbuf;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1958
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1959
    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step2" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1960
    internalidbuf.Num(internalid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1961
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1962
    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step3" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1963
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1964
    RPointerArray<CAMDbItem> aItemArray;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1965
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1966
    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step4" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1967
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1968
    iAMServerDB->GetEntryForLUIDL(aItemArray, internalidbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1969
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1970
    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step5" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1971
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1972
    if (aItemArray.Count() != 0)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1973
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1974
        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step6" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1975
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1976
        finalresult = aItemArray[0]->iResult;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1977
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1978
        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step7" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1979
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1980
        if (finalresult < KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1981
            User::Leave(KErrGeneral);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1982
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1983
        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step8" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1984
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1985
        if (*aItemArray[0]->iTargetURI == KNullDesC8())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1986
            User::Leave(KErrGeneral);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1987
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1988
        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step9" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1989
        aTargetURI.Copy(*aItemArray[0]->iTargetURI);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1990
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1991
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1992
    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step10" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1993
    aItemArray.ResetAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1994
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1995
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1996
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1997
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1998
// CApplicationManagementServer::DeleteGenericAlertForIDL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  1999
// ------------------------------------------------------------------------------------------------	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2000
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2001
void CApplicationManagementServer::DeleteGenericAlertForIDL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2002
        TUint32 internalid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2003
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2004
    iAMServerDB->DeleteFromDatabaseL(internalid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2005
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2006
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2007
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2008
// CApplicationManagementServer::DecodeB64DataFileL( RFile& aDataFile, RFile& aDestinationFile )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2009
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2010
void CApplicationManagementServer::DecodeB64DataFileL(RFile& aSourceFile,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2011
        RFile& aDestinationFile)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2012
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2013
    RDEBUG( "CApplicationManagementServer::DecodeB64DataFileL(): Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2014
    // Create buffers
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2015
    //TInt b64bufferSize = 131072;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2016
    TInt decodedBufferSize = ((KBase64BufSize * 3) / 4 + 16);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2017
    HBufC8 *dataBuf = HBufC8::NewLC(KBase64BufSize);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2018
    TPtr8 dataPtr = dataBuf->Des();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2019
    HBufC8* targetBuf = HBufC8::NewLC(decodedBufferSize);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2020
    TPtr8 targetPtr(targetBuf->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2021
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2022
    TInt offset(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2023
    TInt length(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2024
    TBool reading(ETrue);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2025
    aSourceFile.Size(length);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2026
    RDEBUG_2( "CApplicationManagementServer::DecodeB64DataFileL(): b64 file total size: (%d)", length );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2027
    aSourceFile.Seek(ESeekStart, offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2028
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2029
    // Initialize decoder
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2030
    TImCodecB64 B64Coder;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2031
    B64Coder.Initialise();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2032
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2033
    while (reading)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2034
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2035
        aSourceFile.Read(dataPtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2036
        if (!dataPtr.Length())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2037
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2038
            // EOF
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2039
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2040
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2041
        offset = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2042
        aSourceFile.Seek(ESeekCurrent, offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2043
        RDEBUG_2("OFFSET: %d", offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2044
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2045
        // decode data
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2046
        B64Coder.Decode(dataPtr, targetPtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2047
        // write decoded data to temporary file
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2048
        aDestinationFile.Write(targetPtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2049
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2050
    CleanupStack::PopAndDestroy(targetBuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2051
    CleanupStack::PopAndDestroy(dataBuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2052
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2053
    offset = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2054
    aDestinationFile.Seek(ESeekStart, offset);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2055
    RDEBUG( "CApplicationManagementServer::DecodeB64DataFileL(): end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2056
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2057
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2058
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2059
// CApplicationManagementServer::DecodeB64DataLC( const TDesC8& aData )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2060
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2061
HBufC8* CApplicationManagementServer::DecodeB64DataLC(const TDesC8 &aData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2062
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2063
    RDEBUG( "CApplicationManagementServer::DecodeB64DataLC(): Start" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2064
    TImCodecB64 B64Coder;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2065
    B64Coder.Initialise();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2066
    HBufC8 *target = HBufC8::NewLC((aData.Length() * 3) / 4 + 16);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2067
    TPtr8 targetPtr(target->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2068
    B64Coder.Decode(aData, targetPtr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2069
    RDEBUG( "CApplicationManagementServer::DecodeB64DataLC(): End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2070
    return target;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2071
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2072
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2073
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2074
//  CApplicationManagementServer::EncodeDataL( const TDesC8& aData, CBufBase &aTarget )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2075
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2076
void CApplicationManagementServer::EncodeDataL(const TDesC8& aData,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2077
        CBufBase &aTarget)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2078
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2079
    TInt outLen(aData.Length() * 2);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2080
    aTarget.ExpandL(0, outLen);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2081
    TImCodecB64 B64Coder;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2082
    B64Coder.Initialise();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2083
    TPtr8 target(aTarget.Ptr(0));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2084
    TInt decoded(B64Coder.Encode(aData, target));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2085
    TInt s(target.Length());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2086
    aTarget.ResizeL(s);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2087
    aTarget.Compress();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2088
    if (!decoded)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2089
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2090
        RDEBUG( "CApplicationManagementServer::EncodeDataL(): Encoding b64 failed?" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2091
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2092
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2093
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2094
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2095
// CApplicationManagementSession::CApplicationManagementSession
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2096
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2097
inline CApplicationManagementSession::CApplicationManagementSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2098
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2099
    RDEBUG_2( "CApplicationManagementSession::CApplicationManagementSession 0x%x", this);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2100
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2101
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2102
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2103
// CApplicationManagementSession::CApplicationManagementSession
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2104
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2105
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2106
inline CApplicationManagementSession::CApplicationManagementSession(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2107
        const TCertInfo &aInfo) :
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2108
    iCertInfo(aInfo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2109
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2110
    RDEBUG( "CApplicationManagementSession::CApplicationManagementSession (cert) " );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2111
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2112
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2113
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2114
// CApplicationManagementSession::Server()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2115
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2116
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2117
inline CApplicationManagementServer& CApplicationManagementSession::Server() const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2118
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2119
    return *static_cast<CApplicationManagementServer*> (const_cast<CServer2*> (CSession2::Server()));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2120
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2121
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2122
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2123
// CApplicationManagementSession::CreateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2124
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2125
// 2nd phase construct for sessions - called by the CServer framework
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2126
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2127
void CApplicationManagementSession::CreateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2128
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2129
    RDEBUG_2( "ApplicationManagementSession: CApplicationManagementSession::CreateL: 0x%x", this );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2130
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2131
    Server().AddSession();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2132
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2133
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2134
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2135
// CApplicationManagementSession::~CApplicationManagementSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2136
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2137
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2138
CApplicationManagementSession::~CApplicationManagementSession()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2139
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2140
    RDEBUG_3("CApplicationManagementSession::~CApplicationManagementSession 0x%X - 0x%X", reinterpret_cast<TUint>(this),
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2141
            reinterpret_cast<TUint>(this)+sizeof( CApplicationManagementSession ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2142
    RDEBUG_2("CApplicationManagementSession::~CApplicationManagementSession iCertInfo offs 0x%X",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2143
            reinterpret_cast<TUint>(&this->iCertInfo) - reinterpret_cast<TUint>(this) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2144
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2145
    Server().DropSession();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2146
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2147
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2148
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2149
// CApplicationManagementSession::ServiceL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2150
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2151
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2152
void CApplicationManagementSession::ServiceL(const RMessage2& aMessage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2153
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2154
    if (aMessage.Function() == EPerformRfs)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2155
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2156
        TRAPD( err, Server().PerformRFSL() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2157
        aMessage.Complete(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2158
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2159
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2160
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2161
        TBool handled(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2162
        TInt err(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2163
        TRAP( err, handled = PreDispatchMessageL( aMessage ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2164
        if (!handled)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2165
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2166
            TRAP(err,DispatchMessageL(aMessage));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2167
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2168
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2169
        // Some of the functions contains operations that already complete message
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2170
        // doing Complete() twice will cause panic
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2171
        if (aMessage.Handle())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2172
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2173
            aMessage.Complete(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2174
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2175
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2176
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2177
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2178
// CApplicationManagementSession::PreDispatchMessageL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2179
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2180
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2181
TBool CApplicationManagementSession::PreDispatchMessageL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2182
        const RMessage2 &aMessage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2183
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2184
    TBool ret(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2185
    // These succeed regardless of certificate....
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2186
    switch (aMessage.Function())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2187
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2188
        case EGetStateChangingIdsCountOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2189
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2190
            // gets count of items list of ids that are potentially changing state
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2191
            StateChangeComponentIdsCountL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2192
            ret = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2193
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2194
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2195
        case EGetStateChangingIdsOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2196
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2197
            // gets list of ids that are potentially changing state
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2198
            StateChangeComponentIdsL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2199
            ret = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2200
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2201
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2202
        case ECompleteStateChangeOperation: // completes change of state
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2203
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2204
            StateChangeCompleteL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2205
            ret = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2206
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2207
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2208
        default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2209
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2210
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2211
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2212
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2213
    return ret;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2214
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2215
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2216
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2217
// CApplicationManagementSession::DispatchMessageL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2218
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2219
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2220
void CApplicationManagementSession::DispatchMessageL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2221
        const RMessage2& aMessage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2222
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2223
    RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; %d" ,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2224
            aMessage.Function() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2225
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2226
    TBool go(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2227
    if (iTrustAdded)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2228
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2229
        go = Server().CheckCertL(iCertInfo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2230
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2231
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2232
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2233
        go = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2234
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2235
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2236
    if (go)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2237
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2238
        switch (aMessage.Function())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2239
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2240
            case EAddTrust:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2241
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2242
                RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; EAddTrust this=0x%x", this );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2243
                AddTrustL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2244
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2245
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2246
            case EDeplCompCountOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2247
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2248
                ComponentCountL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2249
                return;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2250
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2251
            case EDeplCompIdsOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2252
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2253
                ComponentIdsL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2254
                return;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2255
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2256
            case EDeplCompDeliverCompleteOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2257
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2258
                DeliverCompleteL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2259
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2260
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2261
            case EDeplCompGetOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2262
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2263
                GetComponentL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2264
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2265
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2266
            case EInstallOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2267
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2268
                InstallL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2269
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2270
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2271
            case EDeplCompAttrUpdateOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2272
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2273
                UpdateL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2274
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2275
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2276
            case EDeplCompGetDataOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2277
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2278
                GetDataL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2279
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2280
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2281
            case EDeplCompGetDataLengthOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2282
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2283
                GetDataLengthL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2284
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2285
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2286
            case EDeplCompRemoveOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2287
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2288
                RemoveL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2289
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2290
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2291
            case EDeplCompDeliverStartOperation2:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2292
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2293
                Deliver2L(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2294
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2295
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2296
            case EDeplCompUpdateDataOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2297
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2298
                UpdateDataL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2299
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2300
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2301
            case EDeplCompUpdateStreamedDataOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2302
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2303
                UpdateStreamedDataL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2304
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2305
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2306
            case EDeplCompDownloadOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2307
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2308
                DownloadL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2309
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2310
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2311
            case EDeplCompUpdateOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2312
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2313
                FullUpdateL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2314
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2315
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2316
            case EDeplCompGetUserIdOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2317
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2318
                GetUserIdL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2319
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2320
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2321
            case EDeplCompStartDownloadOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2322
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2323
                StartDownloadL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2324
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2325
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2326
            case EDeplCompDeactivateOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2327
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2328
                DeactivateL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2329
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2330
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2331
            case EDeplCompActivateOperation:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2332
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2333
                ActivateL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2334
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2335
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2336
            case EDeplCompGetTemporaryInstFile:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2337
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2338
                GetTemporaryInstFileL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2339
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2340
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2341
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2342
            case EDeplCompGetFinalResultForGA:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2343
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2344
                GetFinalResultForGAL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2345
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2346
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2347
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2348
            case EDeplCompGenericAlertSent:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2349
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2350
                GenericAlertSentForIdL(aMessage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2351
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2352
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2353
            case ECheckStatusNodes:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2354
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2355
                CheckStatusNodesValuesL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2356
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2357
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2358
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2359
            default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2360
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2361
                User::Leave(KErrNotSupported);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2362
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2363
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2364
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2365
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2366
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2367
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2368
        RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; Policy prevented action this=0x%x", this );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2369
        User::Leave(KErrAccessDenied);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2370
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2371
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2372
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2373
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2374
// CApplicationManagementSession::GenericAlertSentForIdL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2375
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2376
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2377
void CApplicationManagementSession::GenericAlertSentForIdL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2378
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2379
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2380
    TUint32 luid;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2381
    TPckg<TUint32> pk(luid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2382
    TInt read(aMessage.Read(0, pk));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2383
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2384
    Server().DeleteGenericAlertForIDL(luid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2385
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2386
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2387
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2388
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2389
// CApplicationManagementSession::GetFinalResultForGAL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2390
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2391
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2392
void CApplicationManagementSession::GetFinalResultForGAL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2393
        const RMessage2& aMessage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2394
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2395
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2396
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 1" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2397
    TUint32 luid;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2398
    TPckg<TUint32> pk(luid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2399
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2400
    TInt finalresult = KErrNone;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2401
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2402
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 2" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2403
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2404
    HBufC8 *targetURI = HBufC8::NewL(512);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2405
    TPtr8 ptr = targetURI->Des();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2406
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2407
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 3" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2408
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2409
    TInt read(aMessage.Read(0, pk));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2410
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2411
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 4" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2412
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2413
    Server().GetAMServerDownloadDBL(luid, finalresult, ptr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2414
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2415
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 5" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2416
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2417
    RDEBUG_2( "ApplicationManagementServer: GetFinalResultForGAL Count is %d", finalresult );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2418
    TPckg<TInt> p1(finalresult);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2419
    aMessage.WriteL(1, p1);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2420
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2421
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 6" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2422
    aMessage.WriteL(2, ptr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2423
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2424
    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 7" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2425
    if (targetURI)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2426
        delete targetURI;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2427
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2428
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2429
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2430
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2431
// CApplicationManagementSession::ComponentCountL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2432
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2433
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2434
void CApplicationManagementSession::ComponentCountL(const RMessage2& aMessage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2435
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2436
    RDEBUG( "CApplicationManagementSession: ComponentCountL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2437
    TDeploymentComponentState st;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2438
    TPckg<TDeploymentComponentState> pk(st);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2439
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2440
    TInt read(aMessage.Read(1, pk));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2441
    RDEBUG_3( "CApplicationManagementSession: ComponentCountL State is %d, read %d", st, read);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2442
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2443
    const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2444
    RComponentIdArray arr;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2445
    CleanupClosePushL(arr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2446
    if ((st == EDCSActive) || (st == EDCSInactive))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2447
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2448
        ActiveComponentsL(arrt, arr, st);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2449
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2450
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2451
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2452
        TInt count(arrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2453
        for (TInt i(0); i < count; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2454
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2455
            CDeploymentComponent &compo = Server().Storage()->ComponentL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2456
                    arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2457
            if (st == EDCSNone || compo.State() == st)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2458
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2459
                arr.Append(arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2460
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2461
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2462
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2463
    TInt n(arr.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2464
    CleanupStack::PopAndDestroy(&arr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2465
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2466
    RDEBUG_2( "ApplicationManagementServer: ComponentCountL Count is %d", n );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2467
    TPckg<TInt> p(n);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2468
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2469
    aMessage.WriteL(0, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2470
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2471
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2472
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2473
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2474
// CApplicationManagementSession::ActiveComponentsL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2475
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2476
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2477
void CApplicationManagementSession::ActiveComponentsL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2478
        const RComponentIdArray &aArrt, RComponentIdArray &aArr,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2479
        TDeploymentComponentState &aState) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2480
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2481
    Swi::RSisRegistrySession sisses;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2482
    TInt r(sisses.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2483
    User::LeaveIfError(r);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2484
    CleanupClosePushL(sisses);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2485
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2486
    RArray<TUid> uids;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2487
    sisses.InstalledUidsL(uids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2488
    CleanupClosePushL(uids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2489
    TInt cont(aArrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2490
    TInt uidc(uids.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2491
    RArray<TUid> juids;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2492
    Server().JavaUidsL(juids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2493
    CleanupClosePushL(juids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2494
    TInt juidc(juids.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2495
    RComponentIdArray rem;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2496
    CleanupClosePushL(rem);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2497
    for (TInt i(0); i < cont; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2498
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2499
        CDeploymentComponent &compo =
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2500
                Server().Storage()->ComponentL(aArrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2501
        TDeploymentComponentState state = compo.State();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2502
        if (state == aState)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2503
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2504
            TBool add(EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2505
            const TUid &uid(compo.Uid());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2506
            for (TInt j(0); add == EFalse && j < uidc; j++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2507
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2508
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2509
                if (uids[j] == uid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2510
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2511
                    RDEBUG( "CApplicationManagementSession::ActiveComponentsL Entered" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2512
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2513
                    // Check if this registry entry is present
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2514
                    Swi::RSisRegistrySession sisSession;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2515
                    User::LeaveIfError(sisSession.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2516
                    CleanupClosePushL(sisSession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2517
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2518
                    Swi::RSisRegistryEntry sisEntry;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2519
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2520
                    //Opens the base package entry by specifying a UID. 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2521
                    User::LeaveIfError(sisEntry.Open(sisSession, compo.Uid()));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2522
                    CleanupClosePushL(sisEntry);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2523
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2524
                    add = sisEntry.IsPresentL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2525
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2526
                    if (add)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2527
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2528
                        // If Present update the Version, name and other info to that deployement component. Since application would have got an update
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2529
                        // by some other means
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2530
                        TVersion version = sisEntry.VersionL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2531
                        TBuf8<KVersionLength> pkgDes;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2532
                        pkgDes.AppendNum(version.iMajor);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2533
                        pkgDes.Append(KLiteralPeriod);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2534
                        pkgDes.AppendNum(version.iMinor);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2535
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2536
                        HBufC *packagename = sisEntry.PackageNameL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2537
                        TBuf8<512> packagename8;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2538
                        packagename8.Copy(*packagename);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2539
                        delete packagename;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2540
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2541
                        compo.SetNameL(packagename8);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2542
                        compo.SetVersionL(pkgDes);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2543
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2544
                        Server().Storage()->UpdateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2545
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2546
                        RDEBUG( "CApplicationManagementSession::ActiveComponentsL ETrue" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2547
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2548
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2549
                    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2550
                        RDEBUG( "CApplicationManagementSession::ActiveComponentsL EFalse" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2551
                    CleanupStack::PopAndDestroy(2, &sisSession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2552
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2553
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2554
            if (!add) // go throug java suites
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2555
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2556
                for (TInt k(0); add == EFalse && k < juidc; k++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2557
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2558
                    if (juids[k] == uid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2559
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2560
                        add = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2561
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2562
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2563
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2564
            if (add)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2565
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2566
                aArr.Append(aArrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2567
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2568
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2569
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2570
                RDEBUG8_3( "ApplicationManagementServer: ActiveComponentCountL skipping 0x%x, %S",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2571
                        compo.Uid() ,&compo.ComponentId() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2572
                rem.Append(aArrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2573
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2574
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2575
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2576
    TInt rc(rem.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2577
    for (TInt t(0); t < rc; t++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2578
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2579
        RDEBUG_2( "ApplicationManagementServer: ActiveComponentCountL removing non existing %d", rem[t] );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2580
        CDeploymentComponent &compo = Server().Storage()->ComponentL(rem[t]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2581
        if (!compo.AppRemovable())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2582
            Server().RemoveInternalL(compo, EFalse);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2583
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2584
    CleanupStack::PopAndDestroy(&rem);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2585
    CleanupStack::PopAndDestroy(&juids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2586
    CleanupStack::PopAndDestroy(&uids);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2587
    CleanupStack::PopAndDestroy(&sisses);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2588
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2589
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2590
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2591
// CApplicationManagementSession::ComponentIdsL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2592
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2593
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2594
void CApplicationManagementSession::ComponentIdsL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2595
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2596
    RDEBUG( "CApplicationManagementSession: ComponentIdsL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2597
    TDeploymentComponentState st;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2598
    TPckg<TDeploymentComponentState> pk(st);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2599
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2600
    TInt read(aMessage.Read(1, pk));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2601
    RDEBUG_3( "CApplicationManagementSession: ComponentIdsL State is %d, read %d", st, read);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2602
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2603
    const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2604
    TInt buflen(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2605
    TUint32* buf = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2606
    if (st == EDCSNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2607
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2608
        buflen = arrt.Count();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2609
        buf = new (ELeave) TUint32[buflen];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2610
        CleanupArrayDeletePushL(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2611
        for (TInt i(0); i < buflen; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2612
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2613
            RDEBUG_2("ApplicationManagementSession: ComponentIdsL Adding %d!!", arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2614
            buf[i] = arrt[i];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2615
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2616
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2617
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2618
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2619
        RComponentIdArray arr;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2620
        if (st == EDCSActive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2621
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2622
            ActiveComponentsL(arrt, arr, st);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2623
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2624
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2625
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2626
            TInt artc(arrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2627
            for (TInt i(0); i < artc; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2628
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2629
                CDeploymentComponent &compo = Server().Storage()->ComponentL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2630
                        arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2631
                if (compo.State() == st)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2632
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2633
                    arr.Append(arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2634
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2635
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2636
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2637
        buflen = arr.Count();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2638
        buf = new (ELeave) TUint32[buflen];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2639
        CleanupArrayDeletePushL(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2640
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2641
        TUint32 len(aMessage.GetDesMaxLength(0) / 4);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2642
        if (buflen == len)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2643
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2644
            RDEBUG( "CApplicationManagementSession: ComponentIdsL Right count!!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2645
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2646
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2647
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2648
            RDEBUG_3( "CApplicationManagementSession: ComponentIdsL Wrong count (is %d, should be %d)!!", len, buflen);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2649
            if (len < buflen)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2650
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2651
                buflen = len;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2652
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2653
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2654
        for (TInt i(0); i < buflen; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2655
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2656
            RDEBUG_2( "CApplicationManagementSession: ComponentIdsL Adding %d!!",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2657
                    arr[i] );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2658
            buf[i] = arr[i];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2659
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2660
        arr.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2661
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2662
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2663
    TPtrC8 p((TUint8*) buf, buflen * sizeof(TUint32));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2664
    aMessage.WriteL(0, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2665
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2666
    CleanupStack::PopAndDestroy(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2667
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2668
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2669
#ifdef _DEBUG
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2670
HBufC* Des8to16LC(const TDesC8 &aDes)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2671
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2672
    HBufC *b = HBufC::NewLC(aDes.Length());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2673
    TPtr p(b->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2674
    p.Copy(aDes);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2675
    return b;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2676
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2677
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2678
HBufC* ToStringLC(TDeploymentComponent &aComp)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2679
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2680
    HBufC *b = HBufC::NewLC(aComp.iId.Length() + aComp.iName.Length()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2681
            + aComp.iVersion.Length() + 10 + 50);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2682
    TPtr p(b->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2683
    _LIT( KFormat, "Id: '%S', Name: '%S', Version: '%S', State: %d, OldState: %d");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2684
    p.Format(KFormat, &*Des8to16LC(aComp.iId), &*Des8to16LC(aComp.iName),
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2685
            &*Des8to16LC(aComp.iVersion), aComp.iState, aComp.iOldState);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2686
    CleanupStack::PopAndDestroy(3);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2687
    return b;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2688
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2689
#endif
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2690
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2691
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2692
// CApplicationManagementSession::Deliver2L()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2693
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2694
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2695
void CApplicationManagementSession::Deliver2L(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2696
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2697
    RDEBUG( "ApplicationManagementSession: Deliver2L" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2698
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2699
    TDeploymentComponentIPC comp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2700
    TPckg<TDeploymentComponentIPC> pcomp(comp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2701
    TInt read2(aMessage.Read(0, pcomp));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2702
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2703
    HBufC8 *data = HBufC8::NewLC(aMessage.GetDesLength(1));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2704
    TPtr8 pbuf(data->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2705
    TInt read(aMessage.Read(1, pbuf));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2706
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2707
    CDeploymentComponent *compo = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2708
    if (iTrustAdded)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2709
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2710
        compo = Server().Storage()->NewComponentL(EDCSDelivered,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2711
                comp.iUserId, &iCertInfo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2712
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2713
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2714
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2715
        compo
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2716
                = Server().Storage()->NewComponentL(EDCSDelivered,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2717
                        comp.iUserId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2718
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2719
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2720
    compo->Set(comp.iComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2721
    compo->Data().SetDataL(pbuf, comp.iMimeType);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2722
    Server().Storage()->UpdateL(*compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2723
    compo->CopyStateTo(comp.iComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2724
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2725
#ifdef _DEBUG
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2726
    RDEBUG_2( "Deliver2L: TDeploymentComponent is '%S'",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2727
            ToStringLC( comp.iComponent ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2728
    CleanupStack::PopAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2729
#endif
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2730
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2731
    TPckg<TDeploymentComponent> pcomp2(comp.iComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2732
    aMessage.Write(0, pcomp2);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2733
    CleanupStack::PopAndDestroy(data);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2734
    TInt n(compo->InternalId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2735
    TPckg<TUint32> p(n);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2736
    aMessage.WriteL(2, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2737
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2738
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2739
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2740
// CApplicationManagementSession::DeliverCompleteL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2741
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2742
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2743
void CApplicationManagementSession::DeliverCompleteL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2744
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2745
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2746
    RDEBUG( "ApplicationManagementSession: DeliverCompleteL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2747
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2748
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2749
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2750
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2751
    RDEBUG_2( "ApplicationManagementSession: DeliverCompleteL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2752
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2753
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2754
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2755
    HBufC8 *opts = HBufC8::NewLC(aMessage.GetDesLength(1));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2756
    TPtr8 popts(opts->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2757
    TInt read1(aMessage.Read(1, popts));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2758
    compo.SetInstallOptsL(*opts);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2759
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2760
    HBufC8 *meta = HBufC8::NewLC(aMessage.GetDesLength(2));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2761
    TPtr8 pmeta(meta->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2762
    TInt read2(aMessage.Read(2, pmeta));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2763
    compo.SetMetaDataL(*meta, KNullDesC8);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2764
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2765
    CleanupStack::PopAndDestroy(meta);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2766
    CleanupStack::PopAndDestroy(opts);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2767
    Server().Storage()->UpdateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2768
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2769
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2770
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2771
// CApplicationManagementSession::GetComponentL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2772
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2773
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2774
void CApplicationManagementSession::GetComponentL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2775
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2776
    RDEBUG( "ApplicationManagementSession: GetComponentL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2777
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2778
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2779
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2780
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2781
    RDEBUG_2( "ApplicationManagementSession: GetComponentL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2782
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2783
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2784
    TDeploymentComponent comp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2785
    compo.CopyStateTo(comp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2786
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2787
    TPckg<TDeploymentComponent> pcomp(comp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2788
    aMessage.Write(1, pcomp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2789
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2790
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2791
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2792
// CApplicationManagementSession::StartDownloadL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2793
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2794
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2795
void CApplicationManagementSession::StartDownloadL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2796
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2797
    RDEBUG( "ApplicationManagementSession: StartDownloadL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2798
    TUint32 id = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2799
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2800
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2801
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2802
    TPckgBuf<TDownloadTarget> target;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2803
    read = aMessage.Read(1, target);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2804
    RDEBUG_2( "ApplicationManagementSession: StartDownloadL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2805
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2806
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2807
    compo.SetDownloadTarget(target());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2808
    Server().AddDownloadL(&compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2809
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2810
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2811
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2812
// CApplicationManagementSession::DeactivateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2813
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2814
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2815
void CApplicationManagementSession::DeactivateL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2816
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2817
    RDEBUG( "ApplicationManagementSession: DeactivateL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2818
    TUint32 id = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2819
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2820
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2821
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2822
    RDEBUG_2( "ApplicationManagementSession: DeactivateL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2823
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2824
    Server().Storage()->DeactivateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2825
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2826
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2827
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2828
// CApplicationManagementSession::ActivateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2829
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2830
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2831
void CApplicationManagementSession::ActivateL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2832
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2833
    RDEBUG( "ApplicationManagementSession: ActivateL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2834
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2835
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2836
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2837
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2838
    RDEBUG_2( "ApplicationManagementSession: ActivateL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2839
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2840
    Server().Storage()->ActivateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2841
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2842
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2843
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2844
// CApplicationManagementSession::GetUserIdL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2845
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2846
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2847
void CApplicationManagementSession::GetUserIdL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2848
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2849
    RDEBUG( "ApplicationManagementSession: GetUserIdL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2850
    TUint32 id = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2851
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2852
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2853
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2854
    RDEBUG_2( "ApplicationManagementSession: GetUserIdL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2855
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2856
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2857
    aMessage.Write(1, compo.UserId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2858
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2859
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2860
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2861
// CApplicationManagementSession::GetTemporaryInstFileL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2862
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2863
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2864
void CApplicationManagementSession::GetTemporaryInstFileL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2865
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2866
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2867
    // TIpcArgs( &id, &itemid, &filehandle )
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2868
    RDEBUG( "ApplicationManagementSession: GetTemporaryInstFileL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2869
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2870
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2871
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2872
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2873
    TDeplCompAttrType item;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2874
    TPckg<TDeplCompAttrType> itemid(item);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2875
    read = aMessage.Read(1, itemid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2876
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2877
    RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2878
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2879
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2880
    TFileName fileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2881
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2882
    if (item == EDCData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2883
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2884
        fileName.Copy(compo.Data().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2885
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2886
    else if (item == EDCMetaData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2887
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2888
        fileName.Copy(compo.MetaData().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2889
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2890
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2891
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2892
        RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL: Not supported type: (%d)", item);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2893
        User::Leave(KErrNotSupported);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2894
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2895
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2896
    RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL: (%S)", &fileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2897
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2898
    RFs fs;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2899
    User::LeaveIfError(fs.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2900
    User::LeaveIfError(fs.ShareProtected());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2901
    CleanupClosePushL(fs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2902
    RFile file;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2903
    User::LeaveIfError(file.Open(fs, fileName, EFileWrite));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2904
    CleanupClosePushL(file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2905
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2906
    // Takes care of completing with session (RFs), 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2907
    // SendReceieve returns session handle at client side
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2908
    User::LeaveIfError(file.TransferToClient(aMessage, 2));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2909
    CleanupStack::PopAndDestroy(2, &fs); // fs , file	
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2910
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2911
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2912
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2913
// CApplicationManagementSession::PackageSizeL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2914
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2915
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2916
TInt CApplicationManagementSession::PackageSizeL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2917
        Swi::RSisRegistrySession& aSession, Swi::RSisRegistryEntry& aEntry)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2918
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2919
    RPointerArray<Swi::CSisRegistryPackage> listPackages;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2920
    TInt size(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2921
    TInt err(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2922
    CleanupClosePushL(listPackages);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2923
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2924
    aEntry.AugmentationsL(listPackages);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2925
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2926
    for (TInt index(0); index < listPackages.Count(); index++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2927
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2928
        TRAP(err, AugmentationSizeL( aSession, *listPackages[index]))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2929
        if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2930
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2931
            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2932
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2933
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2934
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2935
    if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2936
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2937
        size = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2938
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2939
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2940
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2941
        TRAP(err, size += aEntry.SizeL() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2942
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2943
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2944
    listPackages.ResetAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2945
    CleanupStack::PopAndDestroy(&listPackages);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2946
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2947
    if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2948
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2949
        //We leave if there was an error, 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2950
        // but we have to clean up the listPackages before the leave.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2951
        User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2952
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2953
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2954
    return size;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2955
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2956
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2957
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2958
// CAppMngrSisxInfo::AugmentationSizeL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2959
// Returns the Size of the package
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2960
// (other items were commented in a header).
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2961
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2962
//  
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2963
TInt CApplicationManagementSession::AugmentationSizeL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2964
        Swi::RSisRegistrySession& aSession,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2965
        const Swi::CSisRegistryPackage& aPackage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2966
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2967
    TInt size(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2968
    Swi::RSisRegistryEntry regEntry;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2969
    CleanupClosePushL(regEntry);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2970
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2971
    regEntry.OpenL(aSession, aPackage);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2972
    size += PackageSizeL(aSession, regEntry);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2973
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2974
    CleanupStack::PopAndDestroy(&regEntry);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2975
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2976
    return size;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2977
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2978
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2979
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2980
// CApplicationManagementSession::LookupSisRegistryL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2981
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2982
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2983
void CApplicationManagementSession::LookupSisRegistryL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2984
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2985
    Swi::RSisRegistrySession sisses;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2986
    TInt r(sisses.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2987
    RPointerArray<Swi::CSisRegistryPackage> pkgs(12);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2988
    sisses.InstalledPackagesL(pkgs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2989
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2990
    TInt count(pkgs.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2991
    for (TInt i(0); i < count; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2992
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2993
        Swi::CSisRegistryPackage* p = pkgs[i];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2994
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2995
        RDEBUG_5(" Found package: %d, '%S', uid: 0x%X, size: %d" ,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2996
                i, &p->Name(), p->Uid().iUid, AugmentationSizeL( sisses, *p ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2997
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2998
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  2999
    sisses.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3000
    pkgs.ResetAndDestroy();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3001
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3002
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3003
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3004
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3005
// CApplicationManagementSession::InstallL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3006
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3007
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3008
void CApplicationManagementSession::InstallL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3009
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3010
    RDEBUG( "ApplicationManagementSession: InstallL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3011
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3012
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3013
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3014
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3015
    TDeploymentComponentState targetst;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3016
    TPckg<TDeploymentComponentState> pk(targetst);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3017
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3018
    read = aMessage.Read(1, pk);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3019
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3020
    RDEBUG_3( "ApplicationManagementSession: InstallL id is %d, targetstate %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3021
            id, targetst );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3022
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3023
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3024
    if (compo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3025
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3026
        Server().DoTheInstallL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3027
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3028
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3029
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3030
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3031
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3032
    RDEBUG_2( "ApplicationManagementSession: InstallL success. New compo state (%d)", compo.State());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3033
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3034
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3035
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3036
// CApplicationManagementSession::UpdateDataL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3037
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3038
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3039
void CApplicationManagementSession::UpdateDataL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3040
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3041
    RDEBUG( "ApplicationManagementSession: UpdateDataL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3042
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3043
    TDeplCompDataIPC ipc;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3044
    TPckg<TDeplCompDataIPC> pipc(ipc);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3045
    TInt read(aMessage.Read(0, pipc));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3046
    RDEBUG_2( "ApplicationManagementSession: UpdateDataL id is %d", ipc.iInternalId );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3047
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3048
    HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLength(1));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3049
    TPtr8 pbuf(buf->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3050
    TInt read2(aMessage.Read(1, pbuf));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3051
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3052
    CDeploymentComponent &compo = Server().Storage()->ComponentL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3053
            ipc.iInternalId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3054
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3055
    if (Server().CheckB64Encode(pbuf))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3056
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3057
        RDEBUG( "ApplicationManagementSession: UpdateDataL data is base64 encoded");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3058
        // b64 encoded data, decode it 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3059
        HBufC8* tmp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3060
        tmp = Server().DecodeB64DataLC(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3061
        pbuf.Copy(*tmp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3062
        pbuf = buf->Des();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3063
        CleanupStack::PopAndDestroy(tmp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3064
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3065
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3066
    if (compo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3067
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3068
        if (ipc.iAttrType == EDCData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3069
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3070
            compo.SetDataL(pbuf, ipc.iDataMime);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3071
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3072
        else if (ipc.iAttrType == EDCMetaData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3073
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3074
            compo.SetMetaDataL(pbuf, ipc.iDataMime);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3075
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3076
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3077
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3078
            RDEBUG_2( "ApplicationManagementSession::UpdateDataL -  ERROR UpdateDataL called for illegal item: %d!", ipc.iAttrType );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3079
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3080
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3081
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3082
        Server().Storage()->UpdateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3083
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3084
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3085
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3086
        RDEBUG( "ApplicationManagementSession::UpdateDataL -  ERROR UpdateDataL called for illegal state message!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3087
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3088
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3089
    CleanupStack::PopAndDestroy(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3090
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3091
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3092
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3093
// CApplicationManagementSession::UpdateStreamedDataL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3094
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3095
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3096
void CApplicationManagementSession::UpdateStreamedDataL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3097
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3098
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3099
    RDEBUG( "ApplicationManagementSession: UpdateStreamedDataL() Start");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3100
    TDeplCompDataIPC ipc;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3101
    TPckg<TDeplCompDataIPC> pipc(ipc);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3102
    TInt read(aMessage.Read(0, pipc));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3103
    RDEBUG_2( "ApplicationManagementSession: UpdateStreamedDataL id is %d", ipc.iInternalId );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3104
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3105
    CDeploymentComponent &compo = Server().Storage()->ComponentL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3106
            ipc.iInternalId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3107
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3108
    if (compo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3109
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3110
        RFs fs;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3111
        User::LeaveIfError(fs.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3112
        CleanupClosePushL(fs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3113
        RFile file;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3114
        TFileName dataFileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3115
        TInt length(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3116
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3117
        if (ipc.iAttrType == EDCData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3118
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3119
            dataFileName.Copy(compo.Data().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3120
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3121
        else if (ipc.iAttrType == EDCMetaData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3122
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3123
            dataFileName.Copy(compo.MetaData().DataFileName());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3124
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3125
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3126
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3127
            RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL -  ERROR called for illegal item: %d!", ipc.iAttrType );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3128
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3129
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3130
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3131
        RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL(): using dataFile: (%S)", &dataFileName );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3132
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3133
        // EFileWrite So we can delete the original decoded data file
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3134
        User::LeaveIfError(file.Open(fs, dataFileName, EFileWrite));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3135
        CleanupClosePushL(file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3136
        if (Server().IsDataFileB64EncodedL(file, length))
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3137
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3138
            RDEBUG( "CApplicationManagementServer::UpdateStreamedDataL(): data is decoded" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3139
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3140
            TFileName tempFileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3141
            TBuf<30> privatePath;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3142
            fs.PrivatePath(privatePath);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3143
            RFile tempFile;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3144
            TInt err(KErrNone);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3145
            err = tempFile.Temp(fs, privatePath, tempFileName, EFileWrite);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3146
            if (err == KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3147
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3148
                RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL(): created tempFile: (%S)", &tempFileName );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3149
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3150
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3151
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3152
                User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3153
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3154
            CleanupClosePushL(tempFile);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3155
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3156
            TRAP( err, Server().DecodeB64DataFileL( file, tempFile ) );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3157
            if (err != KErrNone)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3158
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3159
                RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL -  failed to decode datafile: %d", err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3160
                CleanupStack::PopAndDestroy(2, &file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3161
                compo.ResetDataL(fs); // Remove both files if exists
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3162
                User::Leave(err);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3163
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3164
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3165
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3166
                // close both files, delete decode file and rename temp file to correct one
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3167
                CleanupStack::PopAndDestroy(2, &file);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3168
                fs.Delete(dataFileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3169
                err = fs.Rename(tempFileName, dataFileName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3170
                RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL -  successfully decoded datafile: %d", err );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3171
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3172
            CleanupStack::PopAndDestroy(&fs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3173
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3174
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3175
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3176
            RDEBUG( "ApplicationManagementSession::UpdateStreamedDataL(): data is NOT decoded" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3177
            CleanupStack::PopAndDestroy(2, &fs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3178
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3179
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3180
        if (ipc.iAttrType == EDCData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3181
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3182
            compo.SetDataL(ipc.iDataMime);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3183
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3184
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3185
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3186
            compo.SetMetaDataL(ipc.iDataMime);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3187
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3188
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3189
        Server().Storage()->UpdateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3190
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3191
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3192
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3193
        RDEBUG( "ApplicationManagementSession::UpdateStreamedDataL -  ERROR called for illegal state message!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3194
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3195
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3196
    RDEBUG( "ApplicationManagementSession: UpdateStreamedDataL() End");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3197
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3198
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3199
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3200
// CApplicationManagementSession::UpdateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3201
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3202
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3203
void CApplicationManagementSession::UpdateL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3204
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3205
    RDEBUG( "ApplicationManagementSession: UpdateL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3206
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3207
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3208
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3209
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3210
    RDEBUG_2("ApplicationManagementSession: UpdateL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3211
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3212
    TDeplCompAttrType item;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3213
    TPckg<TDeplCompAttrType> itemid(item);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3214
    TInt read1(aMessage.Read(1, itemid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3215
    HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLength(2));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3216
    TPtr8 pbuf(buf->Des());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3217
    TInt read2(aMessage.Read(2, pbuf));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3218
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3219
    CDeploymentComponent &c = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3220
    TDeploymentComponentState st(c.State());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3221
    if (st == EDCSDelivered || st == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3222
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3223
        switch (item)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3224
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3225
            case EDCId:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3226
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3227
                c.SetIdL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3228
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3229
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3230
            case EDCName:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3231
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3232
                c.SetNameL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3233
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3234
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3235
            case EDCVersion:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3236
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3237
                c.SetVersionL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3238
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3239
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3240
            case EDCDescriptionRef:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3241
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3242
                c.SetDescriptionL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3243
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3244
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3245
            case EDCInstallOptions:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3246
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3247
                c.SetInstallOptsL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3248
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3249
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3250
            case EDCMetaData:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3251
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3252
                c.SetMetaDataL(pbuf, KNullDesC8);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3253
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3254
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3255
            case EDCPkgID:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3256
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3257
                c.SetPkgIDL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3258
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3259
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3260
            case EDCPkgType:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3261
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3262
                c.SetPkgTypeL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3263
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3264
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3265
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3266
            default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3267
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3268
                if (st == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3269
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3270
                    switch (item)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3271
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3272
                        case EDCData:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3273
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3274
                            c.SetDataL(pbuf, KNullDesC8);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3275
                            if (c.State() == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3276
                                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3277
                                //	Server().StartDownload( *compo );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3278
                                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3279
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3280
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3281
                        default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3282
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3283
                            RDEBUG_2("ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3284
                            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3285
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3286
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3287
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3288
                else if (st == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3289
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3290
                    switch (item)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3291
                        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3292
                        case EDCId:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3293
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3294
                            c.SetIdL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3295
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3296
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3297
                        case EDCName:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3298
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3299
                            c.SetNameL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3300
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3301
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3302
                        case EDCVersion:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3303
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3304
                            c.SetVersionL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3305
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3306
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3307
                        case EDCDownloadURI:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3308
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3309
                            c.SetDownloadURIL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3310
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3311
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3312
                        case EDCConRef:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3313
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3314
                            TPckgBuf<TInt> aInt;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3315
                            aInt.Copy(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3316
                            c.SetIAPL(aInt());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3317
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3318
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3319
                        default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3320
                            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3321
                            RDEBUG_2( "ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3322
                            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3323
                            break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3324
                            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3325
                        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3326
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3327
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3328
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3329
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3330
        Server().Storage()->UpdateL(c);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3331
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3332
    else if (st == EDCSActive || st == EDCSInactive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3333
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3334
        switch (item)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3335
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3336
            case EDCName:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3337
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3338
                c.SetNameL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3339
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3340
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3341
            case EDCVersion:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3342
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3343
                c.SetVersionL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3344
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3345
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3346
            case EDCDescriptionRef:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3347
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3348
                c.SetDescriptionL(pbuf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3349
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3350
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3351
            default:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3352
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3353
                RDEBUG_2( "ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3354
                User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3355
                break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3356
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3357
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3358
        Server().Storage()->UpdateL(c);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3359
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3360
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3361
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3362
        RDEBUG( "ApplicationManagementSession: ERROR UpdateL called for illegal state message!" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3363
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3364
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3365
    CleanupStack::PopAndDestroy(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3366
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3367
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3368
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3369
// CApplicationManagementSession::GetDataLengthL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3370
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3371
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3372
void CApplicationManagementSession::GetDataLengthL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3373
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3374
    RDEBUG( "ApplicationManagementSession: GetDataLengthL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3375
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3376
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3377
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3378
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3379
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3380
    TInt length(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3381
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3382
    TDeplCompAttrType dt;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3383
    TPckg<TDeplCompAttrType> pdt(dt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3384
    read = aMessage.Read(1, pdt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3385
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3386
    if (compo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3387
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3388
        if (dt == EDCInstallOptions)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3389
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3390
            if (compo.InstallOptsSet())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3391
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3392
                length = sizeof(TAMInstallOptions);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3393
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3394
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3395
        else if (dt == EDCData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3396
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3397
            length = compo.Data().DataLengthL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3398
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3399
        else if (dt == EDCDataMime)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3400
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3401
            length = compo.Data().MimeType().Length();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3402
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3403
        else if (dt == EDCMetaData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3404
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3405
            length = compo.MetaData().DataLengthL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3406
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3407
        else if (dt == EDCMetaDataMime)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3408
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3409
            length = compo.MetaData().MimeType().Length();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3410
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3411
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3412
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3413
            RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR called with illegal type %d", dt );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3414
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3415
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3416
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3417
    else if (compo.State() == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3418
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3419
        if (dt == EDCDownloadURI)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3420
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3421
            length = compo.DownloadURI().Length();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3422
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3423
        else if (dt == EDCInstallOptions)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3424
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3425
            if (compo.InstallOptsSet())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3426
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3427
                length = sizeof(TAMInstallOptions);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3428
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3429
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3430
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3431
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3432
            RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR Download / called with illegal state component id %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3433
                    compo.State() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3434
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3435
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3436
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3437
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3438
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3439
        RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR called with illegal state component id %d",
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3440
                compo.State() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3441
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3442
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3443
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3444
    TPckg<TInt> pcomp(length);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3445
    aMessage.Write(2, pcomp);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3446
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3447
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3448
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3449
// CApplicationManagementSession::GetDataL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3450
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3451
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3452
void CApplicationManagementSession::GetDataL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3453
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3454
    RDEBUG( "ApplicationManagementSession: GetDataL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3455
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3456
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3457
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3458
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3459
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3460
    TDeplCompAttrType dt;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3461
    TPckg<TDeplCompAttrType> pdt(dt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3462
    read = aMessage.Read(1, pdt);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3463
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3464
    RDEBUG_3( "ApplicationManagementSession: GetDataL id is %d, and attribute %d", id, dt );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3465
    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3466
    if (dt == EDCStatus)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3467
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3468
        TPckg<TInt> p(compo.Status());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3469
        aMessage.Write(2, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3470
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3471
    else if (compo.State() == EDCSDelivered)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3472
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3473
        if (dt == EDCInstallOptions)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3474
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3475
            if (compo.InstallOptsSet())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3476
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3477
                TAMInstallOptionsPckgBuf pckg(compo.InstallOpts());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3478
                aMessage.Write(2, pckg);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3479
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3480
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3481
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3482
                aMessage.Write(2, KNullDesC8);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3483
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3484
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3485
        else if (dt == EDCData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3486
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3487
            aMessage.Write(2, compo.Data().Data());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3488
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3489
        else if (dt == EDCDataMime)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3490
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3491
            aMessage.Write(2, compo.Data().MimeType());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3492
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3493
        else if (dt == EDCMetaData)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3494
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3495
            aMessage.Write(2, compo.MetaData().Data());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3496
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3497
        else if (dt == EDCMetaDataMime)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3498
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3499
            aMessage.Write(2, compo.MetaData().MimeType());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3500
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3501
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3502
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3503
            RDEBUG_2( "ApplicationManagementSession: GetDataL ERROR called with illegal type %d", dt );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3504
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3505
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3506
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3507
    else if (compo.State() == EDCSDownload)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3508
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3509
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3510
        if (dt == EDCDownloadURI)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3511
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3512
            aMessage.Write(2, compo.DownloadURI());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3513
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3514
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3515
        else if (dt == EDCInstallOptions)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3516
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3517
            if (compo.InstallOptsSet())
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3518
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3519
                TAMInstallOptionsPckgBuf pckg(compo.InstallOpts());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3520
                aMessage.Write(2, pckg);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3521
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3522
            else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3523
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3524
                aMessage.Write(2, KNullDesC8);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3525
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3526
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3527
        else if (dt == EDCConRef)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3528
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3529
            TPckg<TInt> p(compo.GetIAP());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3530
            aMessage.Write(2, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3531
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3532
        else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3533
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3534
            RDEBUG_2( "ApplicationManagementSession:GetDataL ERROR called with illegal type %d", dt );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3535
            User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3536
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3537
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3538
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3539
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3540
        RDEBUG_2("ApplicationManagementSession: GetDataL ERROR called with illegal state component id %d", compo.State() );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3541
        User::Leave(KErrArgument);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3542
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3543
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3544
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3545
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3546
// CApplicationManagementSession::RemoveL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3547
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3548
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3549
void CApplicationManagementSession::RemoveL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3550
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3551
    RDEBUG( "ApplicationManagementSession: RemoveL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3552
    TUint32 id;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3553
    TPckg<TUint32> pid(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3554
    TInt read(aMessage.Read(0, pid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3555
    RDEBUG_2( "ApplicationManagementSession: RemoveL id is %d", id );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3556
    RemoveInternalL(id);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3557
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3558
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3559
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3560
// CApplicationManagementSession::RemoveInternalL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3561
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3562
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3563
void CApplicationManagementSession::RemoveInternalL(const TUint32 &aId) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3564
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3565
    CDeploymentComponent &compo = Server().Storage()->ComponentL(aId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3566
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3567
    Server().RemoveInternalL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3568
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3569
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3570
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3571
// CApplicationManagementSession::DownloadL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3572
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3573
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3574
void CApplicationManagementSession::DownloadL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3575
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3576
    RDEBUG( "ApplicationManagementSession: DownloadL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3577
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3578
    TDCUserId userId;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3579
    aMessage.ReadL(1, userId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3580
    CDeploymentComponent *compo = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3581
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3582
    if (iTrustAdded)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3583
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3584
        compo = Server().Storage()->NewComponentL(EDCSDownload, userId,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3585
                &iCertInfo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3586
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3587
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3588
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3589
        compo = Server().Storage()->NewComponentL(EDCSDownload, userId);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3590
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3591
    TUint32 i(compo->InternalId());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3592
    TPckg<TUint32> p(i);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3593
    aMessage.WriteL(0, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3594
    RDEBUG( "ApplicationManagementSession: DownloadL end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3595
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3596
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3597
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3598
// CApplicationManagementSession::FullUpdateL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3599
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3600
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3601
void CApplicationManagementSession::FullUpdateL(const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3602
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3603
    RDEBUG( "ApplicationManagementSession: FullUpdateL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3604
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3605
    TUint32 sid;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3606
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3607
    TPckg<TUint32> psid(sid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3608
    TInt read(aMessage.Read(0, psid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3609
    TUint32 tid;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3610
    TPckg<TUint32> ptid(tid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3611
    TInt read2(aMessage.Read(1, ptid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3612
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3613
    RDEBUG_3( "ApplicationManagementSession: FullUpdateL sid is %d, tid is %d", sid, tid );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3614
    CApplicationManagementServer &server = Server();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3615
    server.FullUpdateL(sid, tid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3616
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3617
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3618
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3619
// CApplicationManagementSession::ServiceError()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3620
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3621
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3622
void CApplicationManagementSession::ServiceError(const RMessage2& aMessage,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3623
        TInt aError)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3624
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3625
    RDEBUG_2( "ApplicationManagementSession: CApplicationManagementSession::ServiceError %d", aError);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3626
    CSession2::ServiceError(aMessage, aError);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3627
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3628
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3629
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3630
// CApplicationManagementSession::AddTrustL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3631
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3632
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3633
void CApplicationManagementSession::AddTrustL(const RMessage2 &aMessage)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3634
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3635
    TPckg<TCertInfo> pkg(iCertInfo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3636
    aMessage.ReadL(0, pkg);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3637
    iTrustAdded = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3638
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3639
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3640
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3641
// CApplicationManagementSession::StateChangeComponentIdsL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3642
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3643
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3644
void CApplicationManagementSession::StateChangeComponentIdsL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3645
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3646
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3647
    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3648
    RComponentIdArray arr;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3649
    Server().Storage()->GetStateChangeComponentIdsL(arr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3650
    TInt buflen(arr.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3651
    TUint32* buf = new (ELeave) TUint32[buflen];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3652
    CleanupArrayDeletePushL(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3653
    for (TInt i(0); i < buflen; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3654
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3655
        RDEBUG_2( "ApplicationManagementSession:ComponentIdsL Adding %d!!", arr[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3656
        buf[i] = arr[i];
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3657
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3658
    TPtrC8 p((TUint8*) buf, buflen * sizeof(TUint32));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3659
    aMessage.WriteL(0, p);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3660
    arr.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3661
    CleanupStack::PopAndDestroy(buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3662
    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsL end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3663
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3664
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3665
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3666
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3667
// CApplicationManagementSession::StateChangeComponentIdsCountL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3668
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3669
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3670
void CApplicationManagementSession::StateChangeComponentIdsCountL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3671
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3672
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3673
    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3674
    RPointerArray<TPreInstalledAppParams> preInstalledAppParams;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3675
    CAMPreInstallApp* preInstallApp = CAMPreInstallApp::NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3676
    preInstallApp->GetPreInstalledAppsL(preInstalledAppParams);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3677
    TInt count = 0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3678
    for (count = 0; count < preInstalledAppParams.Count(); count++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3679
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3680
        RDEBUG8_2("CApplicationManagementSession::DownloadL: Installed App Name is: %S",&(preInstalledAppParams[count]->iPreInstalledAppame));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3681
        RDEBUG8_2("CApplicationManagementSession::DownloadL: Installed App Vendor is: %S",&(preInstalledAppParams[count]->iPreInstalledAppVendorName));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3682
        RDEBUG_2("CApplicationManagementSession::DownloadL: Installed App UID is : '0x%X'",preInstalledAppParams[count]->iPreInstalledAppUid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3683
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3684
        TBool found = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3685
        const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3686
        TInt countval(arrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3687
        for (TInt i(0); i < countval; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3688
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3689
            CDeploymentComponent &compo = Server().Storage()->ComponentL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3690
                    arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3691
            if (compo.Uid()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3692
                    == preInstalledAppParams[count]->iPreInstalledAppUid)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3693
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3694
                RDEBUG( "CApplicationManagementSession: ActiveComponentsL found= TRUE" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3695
                found = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3696
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3697
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3698
        if (!found)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3699
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3700
            RDEBUG( "CApplicationManagementSession: Adding Pre-installed app" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3701
            TDCUserId preInstalledAppName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3702
            preInstalledAppName.Copy(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3703
                    preInstalledAppParams[count]->iPreInstalledAppame);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3704
            CDeploymentComponent *preInstallCompo = NULL;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3705
            RDEBUG8_2("CApplicationManagementSession: Installed App Name is: %S",&preInstalledAppName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3706
            preInstallCompo = Server().Storage()->NewComponentL(EDCSActive,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3707
                    preInstalledAppName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3708
            preInstallCompo->SetUid(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3709
                    preInstalledAppParams[count]->iPreInstalledAppUid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3710
            preInstallCompo->SetNameL(preInstalledAppName);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3711
            preInstallCompo->SetVersionL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3712
                    preInstalledAppParams[count]->iVersion);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3713
            preInstallCompo->SetMimeTypeL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3714
                    preInstalledAppParams[count]->iMimeType);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3715
            preInstallCompo->SetAppRemovableStatus(ETrue);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3716
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3717
            Server().Storage()->UpdateL(*preInstallCompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3718
            Server().Storage()->CheckForDuplicateNodesInDeployedL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3719
                    *preInstallCompo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3720
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3721
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3722
    delete preInstallApp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3723
    RComponentIdArray arr;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3724
    Server().Storage()->GetStateChangeComponentIdsL(arr);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3725
    TPckgBuf<TInt> buflen(arr.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3726
    aMessage.WriteL(0, buflen);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3727
    arr.Close();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3728
    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL end" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3729
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3730
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3731
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3732
// CApplicationManagementSession::StateChangeCompleteL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3733
// -------------------------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3734
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3735
void CApplicationManagementSession::StateChangeCompleteL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3736
        const RMessage2& aMessage) const
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3737
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3738
    RDEBUG( "CApplicationManagementSession: StateChangeCompleteL" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3739
    TUint32 tid;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3740
    TPckg<TUint32> ptid(tid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3741
    TInt read2(aMessage.Read(0, ptid));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3742
    Server().Storage()->StateChangedL(tid);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3743
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3744
void CApplicationManagementSession::CheckStatusNodesValuesL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3745
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3746
    const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3747
    TInt cont(arrt.Count());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3748
    TBool isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3749
    for (TInt i(0); i < cont; i++)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3750
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3751
        CDeploymentComponent &compo = Server().Storage()->ComponentL(arrt[i]);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3752
        isUpdateRequired = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3753
        if (compo.Status() == EDownload_DownloadProgress)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3754
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3755
            compo.SetStatusNode(EDownload_DownloadFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3756
            isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3757
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3758
        else if (compo.Status() == EDelivered_InstallProgress)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3759
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3760
            compo.SetStatusNode(EDelivered_InstalledFailedWithData);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3761
            isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3762
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3763
        else if (compo.Status() == EDelivered_RemoveProgress)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3764
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3765
            compo.SetStatusNode(EDelivered_RemoveFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3766
            isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3767
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3768
        else if (compo.Status() == EDeployed_RemoveProgress)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3769
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3770
            compo.SetStatusNode(EDeployed_RemoveFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3771
            isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3772
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3773
        else if (compo.Status() == EDeployed_ActivateProgress)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3774
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3775
            compo.SetStatusNode(EDeployed_ActivateFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3776
            isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3777
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3778
        else if (compo.Status() == EDeployed_DeactivateProgress)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3779
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3780
            compo.SetStatusNode(EDeployed_DeactivateFailed);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3781
            isUpdateRequired = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3782
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3783
        if (isUpdateRequired)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3784
            Server().Storage()->UpdateL(compo);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3785
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3786
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3787
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3788
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3789
void CApplicationManagementServer::SetSisAppVersionAndDriveL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3790
        CDeploymentComponent &aCompo)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3791
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3792
    RDEBUG( "CApplicationManagementSession: SetSisAppVersionAndDriveL: Begin" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3793
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3794
    Swi::RSisRegistrySession sisSession;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3795
    User::LeaveIfError(sisSession.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3796
    CleanupClosePushL(sisSession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3797
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3798
    Swi::RSisRegistryEntry sisEntry;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3799
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3800
    //Opens the base package entry by specifying a UID. 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3801
    User::LeaveIfError(sisEntry.Open(sisSession, aCompo.Uid()));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3802
    CleanupClosePushL(sisEntry);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3803
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3804
    TUint drivesMask = sisEntry.InstalledDrivesL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3805
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3806
    TInt drive = EDriveA;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3807
    TDriveNumber installedDrive = EDriveC;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3808
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3809
    if (drivesMask)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3810
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3811
        // Select the highest drive as location drive. That's the case when 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3812
        // all installation is not in same drive
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3813
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3814
        while (drivesMask >>= 1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3815
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3816
            drive++;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3817
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3818
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3819
        RDEBUG_2( "drive -> SetSisAppVersionAndDriveL %d", drive);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3820
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3821
        installedDrive = (TDriveNumber) drive;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3822
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3823
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3824
    TBool status = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3825
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3826
    //Since "C" drive is not removable
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3827
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3828
    if (installedDrive != EDriveC)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3829
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3830
        status = IsInstalledAppRemovableL(installedDrive);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3831
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3832
    if (status)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3833
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3834
        RDEBUG( "IsInstalledAppRemovableL(SetSisAppVersionAndDriveL); True");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3835
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3836
    else
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3837
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3838
        RDEBUG( "IsInstalledAppRemovableL(SetSisAppVersionAndDriveL); False");
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3839
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3840
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3841
    //check for status drive
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3842
    aCompo.SetAppRemovableStatus(status);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3843
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3844
    TVersion version = sisEntry.VersionL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3845
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3846
    if (aCompo.ComponentVersion() == KNullDesC8)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3847
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3848
        TBuf8<KVersionLength> pkgDes;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3849
        pkgDes.AppendNum(version.iMajor);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3850
        pkgDes.Append(KLiteralPeriod);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3851
        pkgDes.AppendNum(version.iMinor);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3852
        aCompo.SetVersionL(pkgDes);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3853
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3854
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3855
    CleanupStack::PopAndDestroy(2, &sisSession);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3856
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3857
    RDEBUG( "CApplicationManagementSession: SetSisAppVersionAndDriveL: End" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3858
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3859
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3860
TBool CApplicationManagementServer::IsInstalledAppRemovableL(
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3861
        TDriveNumber &iDrive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3862
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3863
    RDEBUG( "IsInstalledAppRemovableL: Step1" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3864
    TBool removable = EFalse;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3865
    RFs rfs;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3866
    User::LeaveIfError(rfs.Connect());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3867
    CleanupClosePushL(rfs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3868
    TDriveList driveList;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3869
    TInt driveCount;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3870
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3871
    //Get all removeable drive, both physically and logically
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3872
    User::LeaveIfError(DriveInfo::GetUserVisibleDrives(rfs, driveList,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3873
            driveCount, KDriveAttRemovable));
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3874
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3875
    TInt max(driveList.Length());
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3876
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3877
    RDEBUG_2( "driveList.Length() %d", max);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3878
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3879
    RDEBUG_2( "driveCount %d", driveCount);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3880
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3881
    TBuf<26> buf;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3882
    buf.Copy(driveList);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3883
    RDEBUG_2( "Drive Info (%S)", &buf);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3884
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3885
    for (TInt i = 0; i < max; ++i)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3886
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3887
        if (driveList[i])
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3888
            {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3889
            TUint status;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3890
            RDEBUG( "IsInstalledAppRemovableL: Step3" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3891
            DriveInfo::GetDriveStatus(rfs, i, status);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3892
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3893
            RDEBUG( "IsInstalledAppRemovableL: Step4" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3894
            //To make sure the drive is physically removeable not logically removeable  
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3895
            if (status & DriveInfo::EDriveRemovable)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3896
                {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3897
                RDEBUG( "IsInstalledAppRemovableL: Drive removable" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3898
                RDEBUG_2( "IsInstalledAppRemovableL: Drive removable Drive ID %d", i);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3899
                if (i == iDrive)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3900
                    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3901
                    RDEBUG( "IsInstalledAppRemovableL: Step5" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3902
                    removable = ETrue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3903
                    break;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3904
                    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3905
                }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3906
            }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3907
        }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3908
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3909
    CleanupStack::PopAndDestroy(&rfs);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3910
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3911
    return removable;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3912
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3913
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3914
// -----------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3915
// CShutDown::CShutdown()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3916
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3917
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3918
inline CShutdown::CShutdown() :
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3919
    CTimer(-1)
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3920
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3921
    CActiveScheduler::Add(this);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3922
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3923
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3924
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3925
// CShutDown::ConstructL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3926
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3927
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3928
inline void CShutdown::ConstructL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3929
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3930
    CTimer::ConstructL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3931
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3932
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3933
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3934
// CShutDown::Start()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3935
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3936
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3937
inline void CShutdown::Start()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3938
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3939
    RDEBUG( "ApplicationManagementServer: starting shutdown timeout" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3940
    After(KApplicationManagementShutdownDelay);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3941
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3942
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3943
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3944
// CShutDown::RunL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3945
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3946
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3947
void CShutdown::RunL()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3948
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3949
    RDEBUG( "ApplicationManagementServer timeout ... closing" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3950
    HbApplication::exit(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3951
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3952
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3953
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3954
// CShutDown::Start()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3955
// ------------------------------------------------------------------------------------------------
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3956
inline void CShutdown::Stop()
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3957
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3958
    RDEBUG( "ApplicationManagementServer: Stop" );
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3959
    HbApplication::exit(0);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3960
    }
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3961
d316aecb87fd 201025_02
hgs
parents:
diff changeset
  3962
//  End of File