javauis/mmapi_qt/baseline/src/cmmaoutputstreamevent.cpp
changeset 23 98ccebc37403
child 26 dc7c549001d5
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2002 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:  This class is used to post events to the java.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <logger.h>
       
    20 
       
    21 #include "cmmaoutputstreamevent.h"
       
    22 
       
    23 
       
    24 CMMAOutputStreamEvent::CMMAOutputStreamEvent(jmethodID aHandleEventMethod,
       
    25         jobject aNotifyObject)
       
    26         : CMMAEvent(EReusableEvent),
       
    27         iHandleEventMethod(aHandleEventMethod),
       
    28         iListenerObject(aNotifyObject)
       
    29 {
       
    30     iState = EMMAEventNotActive;
       
    31 }
       
    32 
       
    33 void CMMAOutputStreamEvent::SetLength(TInt aLength)
       
    34 {
       
    35     iLength = aLength;
       
    36     iState = EMMAEventActive;
       
    37 }
       
    38 
       
    39 
       
    40 void CMMAOutputStreamEvent::SetStatus(TInt aStatus)
       
    41 {
       
    42     iStatus = aStatus;
       
    43     iState = EMMAEventActive;
       
    44 }
       
    45 
       
    46 void CMMAOutputStreamEvent::SetState(CMMAOutputStreamEvent::TMMAOutputStreamState aState)
       
    47 {
       
    48     iState = aState;
       
    49 }
       
    50 
       
    51 CMMAOutputStreamEvent::TMMAOutputStreamState CMMAOutputStreamEvent::State()
       
    52 {
       
    53     return iState;
       
    54 }
       
    55 
       
    56 void CMMAOutputStreamEvent::Dispatch(JNIEnv& aJni)
       
    57 {
       
    58     LOG2( EJavaMMAPI, EInfo, "CMMAOutputStreamEvent::Dispatch, len=%d status=%d-",
       
    59                iLength, iStatus);
       
    60 
       
    61     if (iState == EMMAEventActive)
       
    62     {
       
    63         aJni.CallVoidMethod(iListenerObject,
       
    64                             iHandleEventMethod,
       
    65                             iLength,
       
    66                             iStatus);
       
    67         iState = EMMAEventNotActive;
       
    68     }
       
    69     else if (iState == EMMADeleteEvent)
       
    70     {
       
    71         // This is done because some
       
    72         // event may still exist in the event server when
       
    73         // the sender has been deleted.
       
    74 
       
    75         delete this;
       
    76     }
       
    77     // else event is not active
       
    78 }
       
    79 
       
    80 //  END OF FILE