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