ImagePrint/ImagePrintUI/imgpprintdll/src/cuiprotocolcontroller.cpp
branchGCC_SURGE
changeset 25 59ea2209bb67
parent 23 08cc4cc059d4
parent 15 a92d00fca574
equal deleted inserted replaced
23:08cc4cc059d4 25:59ea2209bb67
     1 /*
       
     2 * Copyright (c) 2004-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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <StringLoader.h>
       
    20 #include <AknQueryDialog.h>
       
    21 #include <imageprintapp.rsg>
       
    22 
       
    23 #include "cuiprotocolcontroller.h"
       
    24 #include "muimodeobserver.h"
       
    25 #include "ciffactory.h"
       
    26 #include "midleprinteventregisterif.h"
       
    27 #include "mdiscovery.h"
       
    28 #include "mprintjob.h"
       
    29 #include "mprintsettings.h"
       
    30 #include "mdiscoveryobserver.h"
       
    31 #include "tprinter.h"
       
    32 #include "imgpprintapputil.h"
       
    33 #include "ccustomnotedialog.h"
       
    34 #include "clog.h"
       
    35 
       
    36 const TInt KMMCID( 1 );
       
    37 
       
    38 // CONSTRUCTOR
       
    39 EXPORT_C CUIProtocolController* CUIProtocolController::NewL(
       
    40                        MProtocolObserver* aProtocolObserver,
       
    41                        CIFFactory& aIFFactory )
       
    42     {
       
    43     CUIProtocolController* self = NewLC( aProtocolObserver,
       
    44                                          aIFFactory );
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 CUIProtocolController* CUIProtocolController::NewLC(
       
    50                        MProtocolObserver* aProtocolObserver,
       
    51                        CIFFactory& aIFFactory )
       
    52     {
       
    53     CUIProtocolController* self = new ( ELeave ) CUIProtocolController(
       
    54                                                  aProtocolObserver,
       
    55                                                  aIFFactory );
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL( aIFFactory );
       
    58     return self;
       
    59     }
       
    60 
       
    61 // Default constructor
       
    62 CUIProtocolController::CUIProtocolController(
       
    63                        MProtocolObserver* aProtocolObserver,
       
    64                        CIFFactory& aIFFactory ) :
       
    65                        iProtocolObserver(aProtocolObserver)
       
    66     {
       
    67     iIFFactory = &aIFFactory;
       
    68     iClassState = ENormalState;
       
    69     iDiscoveryDlgManager = NULL;
       
    70     iStartUsb = EFalse;
       
    71     iWasUsbDisconnected = EFalse;
       
    72     }
       
    73 
       
    74 // 2nd phase constructor
       
    75 void CUIProtocolController::ConstructL( CIFFactory& aIFFactory )
       
    76     {
       
    77     iIdleEventRegister = aIFFactory.IdlePrintEventRegisterIF();
       
    78 
       
    79     // Register to receive idle event from engine
       
    80     iIdleEventRegister->RegisterObserver( this );
       
    81 
       
    82     iSettings = aIFFactory.SettingsIF();
       
    83     iDiscovery = aIFFactory.DiscoveryIF();
       
    84     }
       
    85 
       
    86 // Destructor
       
    87 CUIProtocolController::~CUIProtocolController()
       
    88     {
       
    89     if(iUSBConnectionWaitNote)
       
    90     {
       
    91       delete iUSBConnectionWaitNote;	
       
    92       iUSBConnectionWaitNote = NULL;
       
    93     }
       
    94     
       
    95     // Unregister from engine
       
    96     if ( iIdleEventRegister )
       
    97     	{
       
    98     	iIdleEventRegister->UnRegisterObserver( this );  	
       
    99     	}
       
   100 	}
       
   101 
       
   102 
       
   103 EXPORT_C TBool CUIProtocolController::SearchDefaultPrinterL()
       
   104     {
       
   105     LOG("CUIProtocolController::SearchDefaultPrinterL START");
       
   106     TBool retValue = EFalse;
       
   107     TInt defaultProtocol = -1;
       
   108 	TBool usbOnlyMode = EFalse;
       
   109 	
       
   110     // Get supported protocols from the engine
       
   111 	TInt supportedProtocols = iIFFactory->DiscoveryIF()->SupportedProtocols();
       
   112 
       
   113 	// If PictBridge is only supported protocol, set it as default
       
   114 	if( !(supportedProtocols & KImagePrint_PrinterProtocol_BPP)  && 
       
   115     	!(supportedProtocols & KImagePrint_PrinterProtocol_DPOF) && 
       
   116     	!(supportedProtocols & KImagePrint_PrinterProtocol_UPnP) && 
       
   117      	(supportedProtocols & KImagePrint_PrinterProtocol_PictBridge) )
       
   118 		{
       
   119 		LOG("CUIProtocolController::SearchDefaultPrinterL: USB only mode detected");
       
   120 		defaultProtocol = MDiscoveryObserver::EUSB;
       
   121 		usbOnlyMode = ETrue;
       
   122 		}
       
   123     // If usb is connected and PictBridge selected it will be used
       
   124     else if( iDiscovery->IsPictBridgeMode() > 0 )
       
   125         {
       
   126         defaultProtocol = MDiscoveryObserver::EUSB;
       
   127         }
       
   128     else // check default printer.
       
   129         {
       
   130         LOG("iSettings->GetDefaultPrinterProtocol()");
       
   131         defaultProtocol = iSettings->GetDefaultPrinterProtocol();
       
   132         LOG1("defaultProtocol = %d",defaultProtocol);
       
   133         }
       
   134 
       
   135    retValue = SetDefaultPrinterL( defaultProtocol );
       
   136     
       
   137    // If there is no default printer or default printer not available
       
   138    // start settings view with no printer information (but not in usb only mode)
       
   139    if( retValue == EFalse && usbOnlyMode == EFalse )
       
   140         {
       
   141         retValue = ETrue;
       
   142         iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::ENOPRINTER );
       
   143         iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::ENOPRINTER );
       
   144         HBufC* noPrinterText = StringLoader::LoadLC( R_PRINT_NO_PRINTER ); 
       
   145         iSettings->SetCurrentPrinterName( *noPrinterText );
       
   146         iSettings->SetDefaultPrinterNameL( *noPrinterText );
       
   147         CleanupStack::PopAndDestroy ( noPrinterText ); //noPrinterText        
       
   148         }
       
   149 
       
   150    if( iStartUsb )
       
   151         {
       
   152         iStartUsb = EFalse;
       
   153         defaultProtocol = MDiscoveryObserver::EUSB;
       
   154         retValue = SearchUSBPrinterL();
       
   155         if( retValue )
       
   156             {
       
   157             iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EUSB );
       
   158                
       
   159             // In USB case it also must be checked whether default printer is
       
   160             // set at this point, and if not, set USB as default. This is because
       
   161             // in normal cases usb overrides the default protocol without 
       
   162             // changing itself to default.
       
   163             TInt realDefault = iSettings->GetDefaultPrinterProtocol();
       
   164             if ( realDefault == KErrNotFound )
       
   165                 {
       
   166                 iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::EUSB );
       
   167                 iSettings->SetDefaultPrinterNameL( *iSettings->GetCurrentPrinterName() );                	
       
   168                 }
       
   169             }
       
   170         }
       
   171 
       
   172     LOG("CUIProtocolController::SearchDefaultPrinterL END");
       
   173     return retValue;
       
   174     }
       
   175 
       
   176 TBool CUIProtocolController::SetDefaultPrinterL( TInt aDefaultProtocol )
       
   177 	{
       
   178 	 TBool retValue = EFalse;
       
   179 	 switch( aDefaultProtocol )
       
   180 	        {
       
   181 	        case MDiscoveryObserver::EUSB:
       
   182 	            {
       
   183 	            retValue = SearchUSBPrinterL();
       
   184 	            if( retValue )
       
   185 	                {
       
   186 	                iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EUSB );
       
   187 	                iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::EUSB );			
       
   188 	                iSettings->SetDefaultPrinterNameL( *iSettings->GetCurrentPrinterName() );    
       
   189 	                }
       
   190 	            return retValue;
       
   191 	            }
       
   192 	        case MDiscoveryObserver::EBPP:
       
   193 	            {
       
   194 	            retValue = SearchDefaultBTPrinterL();
       
   195 	            if( retValue )
       
   196 	                {
       
   197 	                iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EBPP );
       
   198 	                }
       
   199 	            return retValue;
       
   200 	            }
       
   201 	        case MDiscoveryObserver::EOPP:            
       
   202 	            {
       
   203 	            retValue = SearchDefaultBTPrinterL();
       
   204 	            if( retValue )
       
   205 	                {
       
   206 	                iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EOPP );
       
   207 	                }
       
   208 	            return retValue;
       
   209 	            }
       
   210 	        case MDiscoveryObserver::EMMC:
       
   211 	            {
       
   212 	           retValue = SearchMMCPrinterL();
       
   213 	            if( retValue )
       
   214 	                {
       
   215 	                iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EMMC );
       
   216 	                }
       
   217 	            return retValue;
       
   218 	            }
       
   219 	        case MDiscoveryObserver::EWLAN:
       
   220 	            {
       
   221 	            retValue = SearchDefaultUPnPPrinterL();
       
   222 	            if( retValue )
       
   223 	                {
       
   224 	                iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EWLAN );
       
   225 	                }
       
   226 	            return retValue;
       
   227 	            }
       
   228 
       
   229 	        default:
       
   230 	            {
       
   231 	            return retValue;
       
   232 	            }
       
   233 	        }
       
   234 	}
       
   235 
       
   236 // Changes default printer
       
   237 EXPORT_C TBool CUIProtocolController::ChangeDefaultPrinterL( TInt aProtocol )
       
   238     {
       
   239     LOG("CUIProtocolController::ChangeDefaultPrinterL START");
       
   240     TBool retValue;
       
   241 	TInt previousDefaultProtocol = iSettings->GetDefaultPrinterProtocol();
       
   242 	iSettings->SetDefaultPrinterProtocol( KErrNotFound );
       
   243 	iClassState = EDiscoveryOngoing;
       
   244 	
       
   245     switch( aProtocol )
       
   246         {
       
   247         case MDiscoveryObserver::EUSB:
       
   248             {
       
   249             retValue = SearchUSBPrinterL();
       
   250             if( retValue )
       
   251                 {
       
   252                 iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::EUSB );
       
   253                 iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EUSB );
       
   254                 iSettings->SetDefaultPrinterNameL( *iSettings->GetCurrentPrinterName() );
       
   255                 }
       
   256             break;
       
   257             }
       
   258 
       
   259         case MDiscoveryObserver::EBPP:
       
   260             {
       
   261             retValue = SearchBTPrinterL();
       
   262             if( retValue )
       
   263                 {
       
   264                 iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::EBPP );
       
   265                 iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EBPP );
       
   266                 }
       
   267             break;
       
   268             }
       
   269 
       
   270         case MDiscoveryObserver::EMMC:
       
   271             {
       
   272             retValue = SearchMMCPrinterL();
       
   273             if( retValue )
       
   274                 {
       
   275                 iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::EMMC );
       
   276                 iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EMMC );
       
   277                 }
       
   278             break;
       
   279             }
       
   280 
       
   281         case MDiscoveryObserver::EWLAN:
       
   282             {
       
   283             retValue = SearchUPnPPrinterL();
       
   284             if( retValue )
       
   285                 {
       
   286                 iSettings->SetDefaultPrinterProtocol( MDiscoveryObserver::EWLAN );
       
   287                 iSettings->SetCurrentPrinterProtocol( MDiscoveryObserver::EWLAN );
       
   288                 }
       
   289 
       
   290             break;
       
   291             }
       
   292 
       
   293         default:
       
   294             {
       
   295             // protocol not supported
       
   296             retValue = EFalse;
       
   297             break;
       
   298             }
       
   299         }
       
   300 
       
   301 	if ( retValue == EFalse )
       
   302 		{
       
   303 		iSettings->SetDefaultPrinterProtocol( previousDefaultProtocol );
       
   304 	    LOG1("CUIProtocolController::ChangeDefaultPrinterL iClassState == %d", iClassState);
       
   305 		if ( iClassState == EUSBDisconnectedDuringDiscovery )
       
   306 			{
       
   307 			iClassState = ENormalState;
       
   308 			UsbPrinterDisconnected();
       
   309 			}
       
   310 		else if( MDiscoveryObserver::EUSB == previousDefaultProtocol && iWasUsbDisconnected )
       
   311 			{
       
   312 		    LOG("CUIProtocolController::ChangeDefaultPrinterL nothing selected, but usb previously disconnected, discoverying");
       
   313 			SearchDefaultPrinterL();
       
   314 			}
       
   315 		}
       
   316 	iClassState = ENormalState;
       
   317     LOG("CUIProtocolController::ChangeDefaultPrinterL END");
       
   318     return retValue;
       
   319     }
       
   320 
       
   321 TBool CUIProtocolController::SearchUSBPrinterL()
       
   322     {
       
   323     LOG("CUIProtocolController::SearchUSBPrinterL START");
       
   324     TBool retValue = EFalse;
       
   325 
       
   326     // if the cable is not physically connected, show connect usb cable note
       
   327     if( !IsUsbCableConnected() )
       
   328         {
       
   329         ShowConnectUsbCableNoteL();
       
   330         
       
   331         // Active scheduler is used here to make this method synchronous
       
   332         CActiveScheduler::Start();
       
   333         }
       
   334     // If usb cable is connected and pictbridge mode
       
   335     if( iDiscovery->IsPictBridgeMode() > 0 )
       
   336         {
       
   337         CDiscoveryDlgManager* discoveryDlgManager =
       
   338                               CDiscoveryDlgManager::NewLC( *iIFFactory );
       
   339         retValue = discoveryDlgManager->StartDlgManagerL(
       
   340                             KImagePrint_PrinterProtocol_PictBridge, ETrue );
       
   341         CleanupStack::PopAndDestroy( discoveryDlgManager );
       
   342         discoveryDlgManager = NULL;
       
   343         }
       
   344 	LOG("CUIProtocolController::SearchUSBPrinterL END");
       
   345     return retValue;
       
   346     }
       
   347 
       
   348 // Takes BT printer in use
       
   349 TBool CUIProtocolController::SearchDefaultBTPrinterL()
       
   350     {
       
   351     LOG("CUIProtocolController::SearchDefaultBTPrinterL START");
       
   352     TBool retValue = EFalse;
       
   353 
       
   354     CDiscoveryDlgManager* discoveryDlgManager =
       
   355                           CDiscoveryDlgManager::NewLC( *iIFFactory );
       
   356     retValue = discoveryDlgManager->StartDlgManagerL( KAllBTProtocols, ETrue );
       
   357     CleanupStack::PopAndDestroy( discoveryDlgManager );
       
   358     discoveryDlgManager = NULL;
       
   359 	LOG("CUIProtocolController::SearchDefaultBTPrinterL END");
       
   360     return retValue;
       
   361     }
       
   362 
       
   363 // Takes mmc in use
       
   364 TBool CUIProtocolController::SearchMMCPrinterL()
       
   365     {
       
   366     LOG("CUIProtocolController::SearchMMCPrinterL START");
       
   367     TBool retValue = EFalse;
       
   368 
       
   369     TInt err = iDiscovery->ChoosePrinterL( KMMCID );
       
   370     if( err == KErrNone)
       
   371         {
       
   372         LOG("Print job done succesfully with MMC DEFAULT PRINTER");
       
   373         // Set current printer name to be mmc
       
   374         HBufC* mmcText = StringLoader::LoadLC
       
   375                                   ( R_QTN_PRINT_MEMORY_CARD );
       
   376         iSettings->SetCurrentPrinterName( *mmcText );
       
   377         // Set vendor to none
       
   378         iSettings->SetCurrentPrinterVendor( TPrinter::EVendorNone );
       
   379 
       
   380         CleanupStack::PopAndDestroy(); //mmmcText
       
   381         retValue = ETrue;
       
   382         }
       
   383     LOG("CUIProtocolController::SearchMMCPrinterL END");
       
   384     return retValue;
       
   385     }
       
   386 
       
   387 // Searches WLAN printers
       
   388 TBool CUIProtocolController::SearchUPnPPrinterL()
       
   389     {
       
   390     LOG("CUIProtocolController::SearchUPnPPrinterL START");
       
   391     TBool retValue = EFalse;
       
   392     CDiscoveryDlgManager* discoveryDlgManager =
       
   393                           CDiscoveryDlgManager::NewLC( *iIFFactory );
       
   394     retValue = discoveryDlgManager->StartDlgManagerL( KImagePrint_PrinterProtocol_UPnP );
       
   395     CleanupStack::PopAndDestroy( discoveryDlgManager );
       
   396     discoveryDlgManager = NULL;
       
   397     LOG("CUIProtocolController::SearchUPnPPrinterL END");
       
   398     return retValue;
       
   399     }
       
   400 
       
   401 // Takes WLAN printer in use
       
   402 TBool CUIProtocolController::SearchDefaultUPnPPrinterL()
       
   403     {
       
   404     LOG("CUIProtocolController::SearchDefaultUPnPPrinterL START");
       
   405     TBool retValue = EFalse;
       
   406 
       
   407     CDiscoveryDlgManager* discoveryDlgManager =
       
   408                           CDiscoveryDlgManager::NewLC( *iIFFactory );
       
   409     retValue = discoveryDlgManager->StartDlgManagerL( KImagePrint_PrinterProtocol_UPnP, ETrue );
       
   410     CleanupStack::PopAndDestroy( discoveryDlgManager );
       
   411     discoveryDlgManager = NULL;
       
   412 	LOG("CUIProtocolController::SearchDefaultUPnPPrinterL END");
       
   413     return retValue;
       
   414     }
       
   415 
       
   416 TBool CUIProtocolController::SearchBTPrinterL()
       
   417     {
       
   418     LOG("CUIProtocolController::SearchBTPrinterL START");
       
   419     TBool retValue = EFalse;
       
   420     CDiscoveryDlgManager* discoveryDlgManager =
       
   421                           CDiscoveryDlgManager::NewLC( *iIFFactory );
       
   422     retValue = discoveryDlgManager->StartDlgManagerL( KAllBTProtocols );
       
   423     CleanupStack::PopAndDestroy( discoveryDlgManager );
       
   424     discoveryDlgManager = NULL;
       
   425     LOG("CUIProtocolController::SearchBTPrinterL END");
       
   426     return retValue;
       
   427     }
       
   428 
       
   429 // Searches all supported protocols
       
   430 TBool CUIProtocolController::FullSearchL()
       
   431     {
       
   432     LOG("CUIProtocolController::FullSearchL START");
       
   433     TBool retValue = EFalse;
       
   434     iDiscoveryDlgManager = CDiscoveryDlgManager::NewL( *iIFFactory );
       
   435     LOG("CUIProtocolController::FullSearchL before Fullsearch");
       
   436     retValue = iDiscoveryDlgManager->StartDlgManagerL();
       
   437     LOG("CUIProtocolController::FullSearchL after FullSearch");
       
   438     delete iDiscoveryDlgManager;
       
   439     iDiscoveryDlgManager = NULL;
       
   440     LOG("CUIProtocolController::FullSearchL END");
       
   441     return retValue;
       
   442     }
       
   443 
       
   444 // Is the usb cable connected to phone or not
       
   445 TBool CUIProtocolController::IsUsbCableConnected()
       
   446     {
       
   447     LOG("CUIProtocolController::IsUsbCableConnected START");
       
   448     TInt err = iUsbManager.Connect();
       
   449     if ( err == KErrNone )
       
   450     	{
       
   451 	    iUsbManager.GetDeviceState( iDeviceState );
       
   452 	    iUsbManager.Close();	
       
   453     	}
       
   454     else
       
   455     	{
       
   456 	    LOG("CUIProtocolController::IsUsbCableConnected iUsbManager.Connect() FAIL");	
       
   457     	}
       
   458     LOG("CUIProtocolController::IsUsbCableConnected END");
       
   459     return ( iDeviceState != EUsbDeviceStateUndefined );
       
   460     }
       
   461 
       
   462 void CUIProtocolController::ShowConnectUsbCableNoteL()
       
   463     {
       
   464     LOG("CUIProtocolController::ShowConnectUsbCableNote START");
       
   465     iUSBConnectionWaitNote = new (ELeave) CCustomNoteDialog(
       
   466 	    reinterpret_cast< CEikDialog** > (&iUSBConnectionWaitNote) );
       
   467     iUSBConnectionWaitNote->SetCallback( this );
       
   468     iUSBConnectionWaitNote->ExecuteLD(R_CONNECT_USB);
       
   469     LOG("CUIProtocolController::ShowConnectUsbCableNote END");
       
   470     }
       
   471 
       
   472 // MProgressDialogCallback method
       
   473 void CUIProtocolController::DialogDismissedL(TInt /*aButtonId*/ )
       
   474     {
       
   475     LOG("CUIProtocolController::DialogDismissedL START");
       
   476     CActiveScheduler::Stop();
       
   477     LOG("CUIProtocolController::DialogDismissedL END");
       
   478     }
       
   479 
       
   480 //Idle observer method
       
   481 void CUIProtocolController::UsbPrinterDisconnected()
       
   482     {
       
   483     LOG("CUIProtocolController::UsbPrinterDisconnected START");
       
   484     if( iSettings->GetCurrentPrinterProtocol() == MDiscoveryObserver::EUSB )
       
   485         {
       
   486         LOG1("CUIProtocolController::UsbPrinterConnected iClassState is %d", iClassState);
       
   487         if ( iClassState == EDiscoveryOngoing || iClassState == EUSBDisconnectedDuringDiscovery )
       
   488         	{
       
   489         	iClassState = EUSBDisconnectedDuringDiscovery;
       
   490         	iWasUsbDisconnected = ETrue;
       
   491             LOG("CUIProtocolController::UsbPrinterConnected iClassState is now EUSBDisconnectedDuringDiscovery");
       
   492         	}
       
   493         else
       
   494         	{
       
   495 	        iProtocolObserver->UsbCableDisconnected();        	
       
   496         	}
       
   497         }
       
   498     LOG("CUIProtocolController::UsbPrinterDisconnected END");
       
   499     }
       
   500 
       
   501 //Idle observer method
       
   502 void CUIProtocolController::UsbPrinterConnected()
       
   503     {
       
   504     LOG("CUIProtocolController::UsbPrinterConnected START");
       
   505     if( EUSBDisconnectedDuringDiscovery == iClassState )
       
   506     	{
       
   507     	iClassState = EDiscoveryOngoing;
       
   508         LOG("CUIProtocolController::UsbPrinterConnected iClassState is now EDiscoveryOngoing");
       
   509     	}
       
   510 
       
   511     if( iUSBConnectionWaitNote )    // Remove wait note and start discovery
       
   512         {
       
   513         delete iUSBConnectionWaitNote;
       
   514         iUSBConnectionWaitNote = NULL;
       
   515         }
       
   516     else
       
   517         {
       
   518         if(iDiscoveryDlgManager)
       
   519             {
       
   520             iStartUsb = ETrue;
       
   521             iDiscoveryDlgManager->CancelDiscovery();
       
   522             }
       
   523         }
       
   524     LOG("CUIProtocolController::UsbPrinterConnected END");
       
   525     }
       
   526 
       
   527 //Idle observer method
       
   528 void CUIProtocolController::UsbStateChanged( TImgPrintUSBState aState, TInt aError )
       
   529     {
       
   530     LOG("CUIProtocolController::UsbStateChanged START");
       
   531     if ( aState == ENOUSBEvent )
       
   532     	{
       
   533 	    TRAP_IGNORE( IMGPPrintAppUtil::ShowErrorMsgL( aError ) );	
       
   534     	}
       
   535     LOG("CUIProtocolController::UsbStateChanged END");
       
   536     }
       
   537 
       
   538 //Idle observer method
       
   539 void CUIProtocolController::ReadyToContinue()
       
   540     {
       
   541     LOG("CUIProtocolController::ReadyToContinue START");
       
   542     LOG("CUIProtocolController::ReadyToContinue END");
       
   543     }
       
   544 
       
   545 void CUIProtocolController::AsynchronousServerLeave( TInt /*aError*/ )
       
   546 	{
       
   547 	LOG("CUIProtocolController::AsynchronousServerLeave START");
       
   548 
       
   549 	// Cancel discovery in case of server leave. No can do if Cancel leaves.
       
   550 	LOG("CUIProtocolController::AsynchronousServerLeave CancelDeviceDiscoveryL()");
       
   551 	TRAP_IGNORE( iIFFactory->DiscoveryIF()->CancelDeviceDiscoveryL() );
       
   552 
       
   553 	// Cancel printing in case of server leave. No can do if Cancel leaves.
       
   554 	TRAP_IGNORE( iIFFactory->PrintJobIF()->CancelL() );
       
   555     LOG("CUIProtocolController::AsynchronousServerLeave END");
       
   556 	}
       
   557 
       
   558 //  End of File