ImagePrint/ImagePrintEngine/DeviceProtocols/pictbridge2/src/cpbconnect.cpp
branchRCL_3
changeset 27 159fc2f68139
parent 21 26673e532f65
child 28 d59c248c9d36
equal deleted inserted replaced
21:26673e532f65 27:159fc2f68139
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Contains the CPBConnect class definition.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <pictbridge.h>
       
    21 
       
    22 #include "cpbconnect.h"
       
    23 #include "mpbobserver.h"
       
    24 #include "cpbevent.h"
       
    25 #include "clog.h"
       
    26 
       
    27 CPBConnect* CPBConnect::NewL( CDpsEngine& aEngine, MPBObserver& aObserver )
       
    28     {
       
    29     LOG("CPBConnect::NewL begin");
       
    30     CPBConnect* self = new (ELeave) CPBConnect( aEngine, aObserver );
       
    31     CleanupStack::PushL( self );
       
    32     self->ConstructL();
       
    33     CleanupStack::Pop();	// self
       
    34     LOG("CPBConnect::NewL end");
       
    35     return self;
       
    36     }    
       
    37     
       
    38 CPBConnect::CPBConnect(CDpsEngine& aEngine, MPBObserver& aObserver) :
       
    39 CActive( CActive::EPriorityStandard ), iDpsEngine(aEngine), iObserver( aObserver )
       
    40     {
       
    41     LOG("CPBConnect::CPBConnect begin");
       
    42     CActiveScheduler::Add( this );
       
    43     LOG("CPBConnect::CPBConnect end");
       
    44     }    
       
    45     
       
    46 CPBConnect::~CPBConnect()
       
    47     {
       
    48     LOG("CPBConnect::~CPBConnect begin");
       
    49     Cancel();
       
    50     delete iEvent;
       
    51     LOG("CPBConnect::~CPBConnect end");
       
    52     }    
       
    53     
       
    54 void CPBConnect::ConstructL()
       
    55     {
       
    56     LOG("CPBConnect::ConstructL begin");
       
    57     iEvent = CPBEvent::NewL( iDpsEngine, iObserver );
       
    58     iDpsEngine.SetPrintMode( iStatus );
       
    59     SetActive(); 
       
    60     LOG("CPBConnect::ConstructL end");
       
    61     }
       
    62     
       
    63     
       
    64 void CPBConnect::RunL()        
       
    65     {
       
    66     LOG1("CPBConnect::RunL begin, status %d", iStatus.Int() );
       
    67     switch ( iStatus.Int() )
       
    68         {
       
    69          case CDpsEngine::ENotConnected:
       
    70     		iObserver.ConnectionNotifyL( iStatus.Int() );
       
    71             iDpsEngine.ConnectStateNotify( iStatus );
       
    72             SetActive();
       
    73         	break;        
       
    74         case CDpsEngine::EPrinterConnected:
       
    75         	iObserver.ConnectionNotifyL( iStatus.Int() );
       
    76             iDpsEngine.ConnectStateNotify( iStatus );
       
    77             SetActive();            
       
    78             iEvent->Listen();
       
    79         	break;        
       
    80         case CDpsEngine::EPrinterDisconnected:
       
    81             iEvent->Cancel();
       
    82             iObserver.ConnectionNotifyL( iStatus.Int() );
       
    83             iDpsEngine.SetPrintMode( iStatus );
       
    84             SetActive();    
       
    85 	        break;        
       
    86         case CDpsEngine::EOtherConnected:
       
    87         	iObserver.ConnectionNotifyL( iStatus.Int() );
       
    88             iDpsEngine.ConnectStateNotify( iStatus );
       
    89             SetActive();
       
    90         	break;                
       
    91         case CDpsEngine::EWrongPrintModeConnected:   
       
    92             iObserver.ConnectionNotifyL( iStatus.Int() );
       
    93             iDpsEngine.ConnectStateNotify( iStatus );
       
    94             SetActive();
       
    95             iEvent->Listen();
       
    96 	        break;
       
    97         default:
       
    98 	        break;
       
    99         }
       
   100     LOG("CPBConnect::RunL end");
       
   101     }
       
   102     
       
   103 void CPBConnect::DoCancel()
       
   104     {
       
   105     LOG("CPBConnect::DoCancel begin");
       
   106     iDpsEngine.CancelPrintMode();
       
   107     LOG("CPBConnect::DoCancel end");
       
   108     }    
       
   109 
       
   110 //  End of File