javamanager/javainstaller/javasifplugin/src/asyncwaitcallback.cpp
author hgs
Fri, 09 Jul 2010 16:35:45 +0300
changeset 50 023eef975703
permissions -rw-r--r--
v2.2.4_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     1
/*
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     3
* All rights reserved.
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     8
*
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    11
*
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    12
* Contributors:
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    13
*
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    14
* Description:  This class implements general wait object for calling a desired
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    15
 *                callback function after asynchronous notification
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    16
 *
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    17
*/
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    18
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    19
#include "asyncwaitcallback.h"
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    20
#include "logger.h"
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    21
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    22
using namespace java::installer;
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    23
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    24
// ============================ MEMBER FUNCTIONS ===============================
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    25
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    26
CAsyncWaitCallBack* CAsyncWaitCallBack::NewL(TCallBack aCallBack)
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    27
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    28
    CAsyncWaitCallBack* self = new(ELeave) CAsyncWaitCallBack();
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    29
    CleanupStack::PushL(self);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    30
    self->ConstructL(aCallBack);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    31
    CleanupStack::Pop(self);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    32
    return self;
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    33
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    34
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    35
CAsyncWaitCallBack::CAsyncWaitCallBack():
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    36
        CActive(CActive::EPriorityStandard), iActivatingReasonCode(0)
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    37
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    38
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    39
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    40
CAsyncWaitCallBack::~CAsyncWaitCallBack()
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    41
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    42
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    43
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    44
void CAsyncWaitCallBack::ConstructL(TCallBack aCallBack)
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    45
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    46
    iCallBack = aCallBack;
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    47
    CActiveScheduler::Add(this);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    48
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    49
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    50
void CAsyncWaitCallBack::RunL()
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    51
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    52
    // Execute callback only if the request completed with correct
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    53
    // status code
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    54
    if (iStatus == iActivatingReasonCode)
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    55
    {
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    56
        ILOG1(EJavaInstaller,
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    57
              "CAsyncWaitCallBack called with notif code %d",
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    58
              iStatus.Int());
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    59
        iCallBack.CallBack();
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    60
    }
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    61
    else
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    62
    {
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    63
        WLOG1(EJavaInstaller,
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    64
              "CAsyncWaitCallBack was called with unexpected notif code %d, reactivate",
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    65
              iStatus.Int());
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    66
        // Reactivate wait
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    67
        iProcessToListen.Rendezvous(iStatus);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    68
        SetActive();
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    69
    }
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    70
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    71
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    72
void CAsyncWaitCallBack::DoCancel()
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    73
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    74
    iProcessToListen.RendezvousCancel(iStatus);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    75
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    76
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    77
void CAsyncWaitCallBack::Wait(RProcess aProcessToListen, TInt aActivatingReasonCode)
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    78
{
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    79
    iActivatingReasonCode = aActivatingReasonCode;
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    80
    iProcessToListen = aProcessToListen;
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    81
    iProcessToListen.Rendezvous(iStatus);
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    82
    SetActive();
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    83
}
023eef975703 v2.2.4_1
hgs
parents:
diff changeset
    84