javamanager/debugapi/src.s60/appremover.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     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: AppRemover uninstalls Java application
       
    15 *
       
    16 */
       
    17 
       
    18 #include "appremover.h"
       
    19 
       
    20 #include "logger.h"
       
    21 #include "commsmessage.h"
       
    22 
       
    23 using namespace java::debug;
       
    24 using namespace java::comms;
       
    25 
       
    26 AppRemover::AppRemover(const Uid& aSuiteUid):
       
    27         mSuiteUid(aSuiteUid), mUninstallDone(false), mUninstallResult(-1)
       
    28 {
       
    29 }
       
    30 
       
    31 AppRemover::~AppRemover()
       
    32 {
       
    33 }
       
    34 
       
    35 int AppRemover::uninstall()
       
    36 {
       
    37     JELOG2(EDebugApi);
       
    38 
       
    39     runJavaInstaller();
       
    40     LOG2(EDebugApi, EInfo, "InstallOperation::uninstallApp(): uid=%S, result=%d",
       
    41          mSuiteUid.toString().c_str(), mUninstallResult);
       
    42     return mUninstallResult;
       
    43 }
       
    44 
       
    45 CommsMessage AppRemover::getNextOperation()
       
    46 {
       
    47     if (mUninstallDone)
       
    48     {
       
    49         return InstallOperation::getNextOperation();
       
    50     }
       
    51 
       
    52     CommsMessage msg;
       
    53     msg << UNINSTALL_OPERATION << mSuiteUid;
       
    54     LOG1(EDebugApi, EInfo, "next operation is UNINSTALL(%d)",
       
    55          mSuiteUid.toString().c_str());
       
    56     return msg;
       
    57 }
       
    58 
       
    59 void AppRemover::handleOperationResult(CommsMessage& aMessage)
       
    60 {
       
    61     if (mUninstallDone)
       
    62     {
       
    63         InstallOperation::handleOperationResult(aMessage);
       
    64         return;
       
    65     }
       
    66 
       
    67     int operation = 0;
       
    68     aMessage >> operation >> mUninstallResult;
       
    69 
       
    70     LOG1(EDebugApi, EInfo, "UNINSTALL result: result=%d", mUninstallResult);
       
    71     mUninstallDone = true;
       
    72 }
       
    73 
       
    74