javamanager/debugapi/src.s60/appinstaller.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: AppInstaller takes care of installing Java application
       
    15 *
       
    16 */
       
    17 
       
    18 #include "appinstaller.h"
       
    19 
       
    20 #include "logger.h"
       
    21 #include "commsmessage.h"
       
    22 
       
    23 using namespace java::debug;
       
    24 using namespace java::comms;
       
    25 
       
    26 AppInstaller::AppInstaller(const std::wstring& aFilename) : mFilename(aFilename),
       
    27         mInstallDone(false), mInstallResult(-1)
       
    28 {
       
    29 }
       
    30 
       
    31 AppInstaller::~AppInstaller()
       
    32 {
       
    33 }
       
    34 
       
    35 int AppInstaller::install()
       
    36 {
       
    37     JELOG2(EDebugApi);
       
    38 
       
    39     runJavaInstaller();
       
    40     LOG3(EDebugApi, EInfo, "AppInstaller::installApp(): file=%S, result=%d, suiteUid=%S",
       
    41          mFilename.c_str(), mInstallResult, mSuiteUid.toString().c_str());
       
    42     return mInstallResult;
       
    43 }
       
    44 
       
    45 Uid AppInstaller::getSuiteUid() const
       
    46 {
       
    47     return mSuiteUid;
       
    48 }
       
    49 
       
    50 std::list<Uid> AppInstaller::getAppUids() const
       
    51 {
       
    52     return mAppUids;
       
    53 }
       
    54 
       
    55 
       
    56 CommsMessage AppInstaller::getNextOperation()
       
    57 {
       
    58     if (mInstallDone)
       
    59     {
       
    60         return InstallOperation::getNextOperation();
       
    61     }
       
    62 
       
    63     CommsMessage msg;
       
    64     msg << INSTALL_OPERATION << mFilename;
       
    65     LOG1(EDebugApi, EInfo, "next operation is INSTALL(%S)", mFilename.c_str());
       
    66     return msg;
       
    67 }
       
    68 
       
    69 void AppInstaller::handleOperationResult(CommsMessage& aMessage)
       
    70 {
       
    71     if (mInstallDone)
       
    72     {
       
    73         InstallOperation::handleOperationResult(aMessage);
       
    74         return;
       
    75     }
       
    76 
       
    77     int operation = 0;
       
    78     aMessage >> operation >> mInstallResult;
       
    79 
       
    80     if (!mInstallResult)
       
    81     {
       
    82         int uidCount = 0;
       
    83         aMessage >> uidCount;
       
    84         for (int i = 0; i < uidCount; i++)
       
    85         {
       
    86             Uid appUid;
       
    87             aMessage >> appUid;
       
    88             mAppUids.push_back(appUid);
       
    89         }
       
    90         aMessage >> mSuiteUid;
       
    91     }
       
    92 
       
    93     LOG3(EDebugApi, EInfo, "INSTALL result: result=%d, suiteUid=%S, appUid count=%d",
       
    94          mInstallResult, mSuiteUid.toString().c_str(), mAppUids.size());
       
    95 
       
    96     mInstallDone = true;
       
    97 }