hti/HtiCommPlugins/HtiIPCommPlugin/src/HtiSocketMonitor.cpp
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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:  ECOM plugin for communication over IP port
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "HtiSocketMonitor.h"
       
    21 #include "HtiIPCommLogging.h"
       
    22 
       
    23 
       
    24 CHtiSocketMonitor* CHtiSocketMonitor::NewL( MHtiSocketObserver::TRequestType aType, MHtiSocketObserver* aObserver )
       
    25     {
       
    26     CHtiSocketMonitor* self = new (ELeave) CHtiSocketMonitor( aType, aObserver );
       
    27     CleanupStack::PushL( self );
       
    28     self->ConstructL();
       
    29     CleanupStack::Pop( self );
       
    30     return self;
       
    31     }
       
    32 
       
    33 CHtiSocketMonitor::CHtiSocketMonitor( MHtiSocketObserver::TRequestType aType, MHtiSocketObserver* aObserver ):
       
    34     CActive( EPriorityStandard ),
       
    35     iType( aType ),
       
    36     iObserver( aObserver )
       
    37     {
       
    38     }
       
    39 
       
    40 CHtiSocketMonitor::~CHtiSocketMonitor()
       
    41     {
       
    42     Cancel();
       
    43     }
       
    44 
       
    45 void CHtiSocketMonitor::ConstructL()
       
    46     {
       
    47     CActiveScheduler::Add(this);
       
    48     }
       
    49 
       
    50 void CHtiSocketMonitor::RunL()
       
    51     {
       
    52     iObserver->ReportComplete( iType, iStatus.Int() );
       
    53     }
       
    54 
       
    55 void CHtiSocketMonitor::DoCancel()
       
    56     {
       
    57     HTI_LOG_TEXT( "CHtiSocketMonitor::DoCancel called" );
       
    58     }
       
    59 
       
    60 TInt CHtiSocketMonitor::RunError( TInt aError )
       
    61     {
       
    62     HTI_LOG_FORMAT( "CHtiSocketMonitor::RunError %d", aError );
       
    63     aError = aError;
       
    64     return KErrNone;
       
    65     }
       
    66 
       
    67 void CHtiSocketMonitor::Activate()
       
    68     {
       
    69     HTI_LOG_FUNC_IN( "CHtiSocketMonitor::Activate" );
       
    70 
       
    71     if ( !IsAdded() )
       
    72         {
       
    73         HTI_LOG_TEXT( "Panic! HtiSocketMonitor not added" );
       
    74         User::Panic( _L("HtiSocketMonitor not added"), 1 );
       
    75         }
       
    76 
       
    77     if ( IsActive() )
       
    78         {
       
    79         HTI_LOG_TEXT( "Panic! HtiSocketMonitor cannot handle more than one request" );
       
    80         User::Panic( _L("HtiSocketMonitor cannot handle more than one request"), 1 );
       
    81         }
       
    82 
       
    83     SetActive();
       
    84     HTI_LOG_FUNC_OUT( "CHtiSocketMonitor::Activate" );
       
    85     }