javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/NotifyJsrPlugins.java
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 12:05:25 +0300
branchRCL_3
changeset 77 7cee158cb8cd
parent 24 0fd27995241b
child 83 26b2b12093af
permissions -rw-r--r--
Revision: v2.2.13 Kit: 201036

/*
* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/


package com.nokia.mj.impl.installer.midp2.install.steps;

import com.nokia.mj.impl.installer.exetable.ExeBall;
import com.nokia.mj.impl.installer.exetable.ExeStep;
import com.nokia.mj.impl.installer.jsrpluginnotifier.InstallerExtensionInfo;
import com.nokia.mj.impl.installer.jsrpluginnotifier.JsrPluginNotifier;
import com.nokia.mj.impl.utils.Uid;

/**
 * MIDP installation step NotifyJsrPlugins.
 * Added to MIDP2 Install table in com.nokia.mj.impl.installer.Installer
 */
public class NotifyJsrPlugins extends ExeStep
{
    public void execute(ExeBall aBall)
    {
        InstallBall ball = (InstallBall)aBall;

        // If any Jsr plugins, notify plugins.
        if (ball.iJsrPluginNotifier.anyJsrPlugins())
        {
            ball.iJsrPluginNotifier.notifyInstallation(
                createInstallerExtensionInfo(ball));
        }
    }

    public void cancel(ExeBall aBall)
    {
        InstallBall ball = (InstallBall)aBall;

        // Notify possible plugins that installation has been cancelled.
        if (ball.iJsrPluginNotifier.anyJsrPlugins())
        {
            ball.iJsrPluginNotifier.notifyRollbackInstall(
                createInstallerExtensionInfo(ball));
        }
    }

    private InstallerExtensionInfo createInstallerExtensionInfo(InstallBall aBall)
    {
        InstallerExtensionInfo info = new InstallerExtensionInfo();
        // Beware, it is possible that aBall has not been fully initialized.
        if (aBall.iSuite != null)
        {
            info.iUid = aBall.iSuite.getUid();
            info.iAppUids = aBall.iSuite.getApplicationUids();
            info.iRootPath = aBall.iSuite.getRootDir();
        }
        info.iUpgrade = (aBall.iOldSuite != null);
        info.iSilent = aBall.isSilent();
        info.iAttributes = aBall.iCombinedAttributes;
        if (aBall.iStorageHandler != null)
        {
            info.iStorageSession = aBall.iStorageHandler.getSession();
        }
        return info;
    }
}