javamanager/javaupgradeapp/src.s60/javaupgradeapp.cpp
author hgs
Thu, 05 Aug 2010 16:07:57 +0300
changeset 57 59b3b4473dc8
parent 49 35baca0e7a2e
permissions -rw-r--r--
v2.2.9_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:  Helper application for uninstalling a java application and
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*    then installing new application (java or native)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <apgcli.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <apacmdln.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <apmstd.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <bacline.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <e32cmn.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <s32mem.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <unistd.h>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "exceptionbase.h"
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "javaoslayer.h"
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    29
#include "javacommonutils.h"
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "javaprocessconstants.h"
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "javasymbianoslayer.h"
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "javauids.h"
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "logger.h"
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
using namespace java::util;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    39
_LIT8(KHexValueStart, "0x");
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    40
_LIT8(KSemiColon, ";");
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    41
_LIT8(KUidArg, "uid=");
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    42
_LIT8(KFileArg, "file=");
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
const TInt KExtraLenForLogging = 2;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
const TInt KArgumentValueMaxLen = 1568;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
// Wait for 0.5 sec if ArcApp has not yet initialized
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
const TInt KDelayWhenWaitingAppArc = 500000;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
 * Set the value of the argument specified by aArgName to aArgValue
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
 * @param aCmdLine command line to be parsed
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
 * @param aArgName the name of the argument
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
 * @param aArgValue the value parsed from command line will be returned here
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
 */
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    57
static void getArgValueL(const TPtrC8 &aCmdLine, const TDesC8 &aArgName, HBufC **aArgValue)
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
{
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    59
    TBuf8<KArgumentValueMaxLen> valueBuf;
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    TInt argPos = aCmdLine.FindF(aArgName);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    if (argPos >= 0)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
        TInt semicolonPos = aCmdLine.Mid(argPos).Find(KSemiColon);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
        if (KErrNotFound == semicolonPos)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
            semicolonPos = aCmdLine.Mid(argPos).Length();
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
        TInt argLen = semicolonPos - aArgName.Length();
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
        if (argLen >= KArgumentValueMaxLen)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
            // Protect from buffer overflow.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
            WLOG2(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
                  "javaupgradeapp: argument value len too long (%d), cutting it to %d",
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
                  argLen, (KArgumentValueMaxLen - 1));
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
            argLen = KArgumentValueMaxLen - 1;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
        else if (argLen == 0)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
            User::Leave(KErrArgument);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
        valueBuf = aCmdLine.Mid(argPos + aArgName.Length(),  argLen);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    85
    // Allocate new HBufC
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    HBufC *pBufValue = HBufC::NewL(valueBuf.Length() + 2);
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    87
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    88
    // Convert argument from UTF8 to UCS-2 (UTF16)
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    89
    std::wstring tmp = JavaCommonUtils::utf8ToWstring((const char *)valueBuf.PtrZ());
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    90
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    91
    // Return the argument inside the new HBufC
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
    92
    *pBufValue = (const TUint16 *)(tmp.c_str());
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    *aArgValue = pBufValue;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
 * Parse the name from the value of 'file' parameter in
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
 * command line given in aCmdLine
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
 * @param aCmdLine  command line to be parsed, the format is
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
 *  <other_args>;file=YYY;<other_args>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
 * @param aFileName will contain the name parsed from command line
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
 */
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   105
static void getNameFromCommandLineL(const TPtrC8 &aCmdLine, HBufC **aFileName)
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
{
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    TInt err = aCmdLine.FindF(KFileArg);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    User::LeaveIfError(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    getArgValueL(aCmdLine, KFileArg, aFileName);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
 * Parse the Uid from the value of 'uid' parameter in
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
 * command line given in aCmdLine
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
 * @param aCmdLine  command line to be parsed, the format is
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
 *  uid=YYY;<other_args>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
 * @param aUid will contain the Uid parsed from command line
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
 */
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   122
static void getUidFromCommandLineL(const TPtrC8 &aCmdLine, TInt32 &aUid)
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
{
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    TInt err(KErrNone);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
    TInt argPos = aCmdLine.FindF(KUidArg);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
    if (KErrNotFound != argPos)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    {
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   128
        TPtrC8 uidToParse = aCmdLine.Mid(argPos + KUidArg.iTypeLength);
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   129
        TLex8 parseUid(uidToParse);
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
        if (uidToParse.FindF(KHexValueStart) == 0)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
            parseUid.Inc(2); // skip hex prefix
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
            TUint32 tmpValue;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
            err = parseUid.Val(tmpValue, EHex);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
            aUid = tmpValue;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
        else
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
            err = parseUid.Val(aUid);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
        if (KErrNone != err)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
            ELOG1(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
                  "javaupgradeapp failed parsing app Uid from cmdline uid param. Error %d",
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
                  err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    else
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
        ELOG(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
             "javaupgradeapp cannot uninstall app because uid parameter is not given");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    User::LeaveIfError(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
 * Parse the process command line.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
 * Determine the uid of the Java application to be uninstalled and
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
 * the name of the application package to be installed.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
 * Leaves if argument 'file' exist but file name cannot be found,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
 * leaves if argument 'uid' exist but uid cannot be parsed from command line,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
 * does NOT leave if only one of the arguments is present
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
 * @param aFileName returns value of argument 'file'
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
 * @param aUid returns Uid of the Java application to be uninstalled
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
 */
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
void getFileAndUidL(HBufC **aFileName, TInt32 *aUid)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
{
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   172
    CApaCommandLine* commandLine;
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   173
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   174
    // CApaCommandLine command line is used when this application has been
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   175
    // launched using AppArc APIs.
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   176
    TInt err = CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine);
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   177
    if (KErrNone != err)
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   178
    {
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   179
        ELOG1(EUtils, "javaupgradeapp: Getting CApaCommandLine failed, err %d", err);
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   180
        User::Leave(err);
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   181
    }
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   182
    CleanupStack::PushL(commandLine);
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   184
    // Get the value of _application-args_
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   185
    TPtrC8 args = commandLine->TailEnd();
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   186
    HBufC8 *pBufCmdLine =
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   187
        HBufC8::NewLC(args.Length() + KExtraLenForLogging);
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   188
    if (args.Length() > 0)
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    {
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   190
        // Copy the arguments to the new HBufC8
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   191
        TPtr8 cmdLineBuf = pBufCmdLine->Des();
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   192
        cmdLineBuf = args;
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   193
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   194
        LOG1(EUtils, EInfo,
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   195
            "javaupgradeapp: full cmd line is : %s",
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   196
            cmdLineBuf.PtrZ());
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
        // Get the midlet uid from the commandline
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
        TRAPD(err, getUidFromCommandLineL(cmdLineBuf, *aUid));
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
        // It is enough that either midlet uid OR installation package name
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
        // have been given in commandline
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
        if ((err != KErrNone) && (err != KErrNotFound))
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
            User::Leave(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
        // Get the name of the installation package from the commandline
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
        TRAPD(err2, getNameFromCommandLineL(cmdLineBuf, aFileName))
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
        if (err2 != KErrNone)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
            if (err2 == KErrNotFound)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
            {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
                if (err == KErrNotFound)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
                {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
                    // Both arguments missing
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
                    User::Leave(KErrArgument);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
                }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
            }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
            else
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
            {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
                User::Leave(err2);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
            }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    else
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        ELOG(EUtils, "javaupgradeapp: empty command line");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
        User::Leave(KErrArgument);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    CleanupStack::PopAndDestroy(pBufCmdLine);
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   232
    CleanupStack::PopAndDestroy(commandLine);
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
 * Uninstall the java application specified by aUid parameter.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
 * @param aUid the Uid of the java application to be uninstalled
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
 */
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
void uninstallJavaAppL(TInt32 aUid)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
{
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    RProcess rJavaInstaller;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
    TFileName fileName;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    // Max one path name and some options -> 1536 is enough
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    TBuf<1536> commandLine;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    // Build command line used to pass all necessary info to Java Installer
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    TInt len = strlen(java::runtime::JAVA_INSTALLER_STARTER_DLL);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    TPtr8 ptr8InstallerDll((TUint8 *)java::runtime::JAVA_INSTALLER_STARTER_DLL, len, len);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    commandLine.Copy(ptr8InstallerDll);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
    // Use command line options that make sure that uninstallation is done
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    // always, silently and so that the uninstalled java application will
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    // be preinstalled again if the user uninstalls it
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    commandLine.Append(_L(" uninstall -uid="));
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    commandLine.AppendNum(aUid);
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   258
    commandLine.Append(_L(" -forceuninstall -silent -resetpreinstall"));
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    LOG1WSTR(EUtils, EInfo,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
        "javaupgradeapp:uninstallJavaAppL Java Installer command line is %s",
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
        (wchar_t *)(commandLine.PtrZ()));
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    // start JavaInstaller
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
    TBuf<64> installerProcess;  // Actual len of the process name is 9
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    len = strlen(java::runtime::JAVA_PROCESS);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    installerProcess.Copy(ptr8Process);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
    TRequestStatus status;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    TInt err = rJavaInstaller.Create(installerProcess, commandLine);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    if (KErrNone == err)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
        LOG(EUtils, EInfo, "javaupgradeapp:uninstallJavaAppL calling Logon");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
        // Get notification when Java Installer exits (or panics)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
        rJavaInstaller.Logon(status);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
        LOG(EUtils, EInfo, "javaupgradeapp:uninstallJavaAppL calling Resume");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
        rJavaInstaller.Resume();
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
    else
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
        ELOG1(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
              "javaupgradeapp:uninstallJavaAppL Cannot start Java Installer, error %d",
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
              err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
        User::Leave(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    // now wait until Java Installer exits
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    User::WaitForRequest(status);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
    LOG(EUtils, EInfo, "javaupgradeapp:uninstallJavaAppL calling RProcess::Close");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
    // free resources before returning
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
    rJavaInstaller.Close();
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
 */
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
void installAppPackageL(HBufC *aBufFileName)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
{
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    // Open file using default handler,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    // if the file is an installation package, it will be installed
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    RApaLsSession apaSession;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    TInt err = apaSession.Connect();
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    if (KErrNone != err)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
        ELOG(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
             "javaupgradeapp:installAppPackageL: Cannot connect to AppArc server");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
        User::Leave(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    CleanupClosePushL(apaSession);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
    TInt      retryCounter(10);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
    TThreadId handlerTreadId;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
    do
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
        err = apaSession.StartDocument(*aBufFileName, handlerTreadId);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
        if (RApaLsSession::EAppListInvalid == err)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
            // Application list has not yet been populated,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
            // try again after a short delay
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
            retryCounter--;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
            if (retryCounter > 0)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
            {
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   329
                User::After(KDelayWhenWaitingAppArc); // codescanner::userafter
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
                continue;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
            }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
            else
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
            {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
                ELOG(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
                     "javaupgradeapp:installAppPackageL: RApaLsSession "
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
                     "StartDocument returned EAppListInvalid for 10 times, exiting");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
                User::Leave(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
            }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
        else if (KErrNone != err)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
        {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
            ELOG1(EUtils,
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
                "javaupgradeapp:installAppPackageL: RApaLsSession "
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
                     "StartDocument returned error %d", err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
            User::Leave(err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
        }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
    } while (RApaLsSession::EAppListInvalid == err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
    CleanupStack::PopAndDestroy(); // apaSession
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
 * Get the uid of the Java application to be uninstaller and
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
 * start Java Installer to uninstall the application.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
 * Then install the new application package given in cmdline
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
 */
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
void handleUpgradeL(void)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
{
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    HBufC *pBufFileName = NULL;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    TInt32 uid(0);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    getFileAndUidL(&pBufFileName, &uid);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    if (uid != 0)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    {
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   369
        PLOG1(EUtils, "javaupgradeapp uninstalling app uid %x", uid);
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
        uninstallJavaAppL(uid);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    }
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   372
    else
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   373
    {
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   374
        WLOG(EUtils, "javaupgradeapp: uid argument was not given");
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   375
    }
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
    if (pBufFileName != NULL)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    {
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   379
        PLOG1WSTR(EUtils,
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
            "javaupgradeapp: installing new app package %s",
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
            (wchar_t *)(pBufFileName->Des().PtrZ()));
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
        installAppPackageL(pBufFileName);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
        delete pBufFileName;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    }
49
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   386
    else
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   387
    {
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   388
        WLOG(EUtils, "javaupgradeapp: file argument was not given");
35baca0e7a2e v2.2.3_1
hgs
parents: 35
diff changeset
   389
    }
35
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
/**
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
 * Main function of executable javaupgradeapp.exe.
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
 * "installer app" created by Services team starts this executable when
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
 * the "installer app" must be replaced with the real application (java/native or wrt)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
 * The command line format is
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
 * uid=<Uid>;file=<full_path_to_installation_file>
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
 * for example
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
 * uid=0x10137c4d;file=D:\\temp\\upgrade\\package.sis
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
 * Sample code for starting this application from the "installer app" MIDlet
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
 * @code
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
    MIDlet.platformRequest(
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
        “nativeapp://application-exe=javaupgradeapp.exe;application-args=uid=0x10137c4d;file=D:\\temp\\upgrade\\package.sis”);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
 * @endcode
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
 *
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
 */
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
TInt E32Main(void)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
{
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
    // TODO: check that only MIDP runtime process can start this in final version
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
    // that goes to ROM
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    CTrapCleanup *pCleanupStack = CTrapCleanup::New();
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
    if (NULL == pCleanupStack)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
        ELOG(EUtils, "Cannot create CleanupStack in javaupgradeapp.exe main()");
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
        return KErrNoMemory;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    TRAPD(err, handleUpgradeL());
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    if (KErrNone != err)
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    {
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
        ELOG1(EUtils, "javaupgradeapp.exe: handleUpgradeL leaved with err %d", err);
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    }
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    delete pCleanupStack;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    return err;
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
}
85266cc22c7f Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434