usbengines/usbotgwatcher/src/cusbnotenotifier.cpp
branchRCL_3
changeset 65 a44cdf4b4bf0
parent 0 1e05558e2206
child 21 ff9df6630274
equal deleted inserted replaced
64:8ecef05bbada 65:a44cdf4b4bf0
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     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:  Base classes for Usb notifier wrapper
       
    15  *
     8  *
    16 */
     9  * Initial Contributors:
    17 
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Base classes for Usb notifier wrapper
       
    15  *
       
    16  */
    18 
    17 
    19 #include "cusbnotifmanager.h"
    18 #include "cusbnotifmanager.h"
    20 #include "cusbnotenotifier.h"
    19 #include "cusbnotenotifier.h"
    21 
    20 
    22 #include "debug.h"
    21 #include "debug.h"
    27 // ---------------------------------------------------------------------------
    26 // ---------------------------------------------------------------------------
    28 // C++ constructor
    27 // C++ constructor
    29 // ---------------------------------------------------------------------------
    28 // ---------------------------------------------------------------------------
    30 //
    29 //
    31 CUsbNoteNotifier::CUsbNoteNotifier(RNotifier& aNotifier,
    30 CUsbNoteNotifier::CUsbNoteNotifier(RNotifier& aNotifier,
    32         CUsbNotifManager* aNotifManager, TUid aCat, TUint aNotifId) :
    31         CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId) :
    33     CUsbNotifier(aNotifManager, aCat, aNotifId),
    32     CUsbNotifier(aNotifManager, aCat, aNotifId), iNotifier(aNotifier)
    34     iNotifier(aNotifier)
       
    35     {
    33     {
    36     FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CUsbNoteNotifier" ) );
       
    37     
       
    38     }
    34     }
    39 
    35 
    40 // ---------------------------------------------------------------------------
    36 // ---------------------------------------------------------------------------
    41 // Second-phase constructor
    37 // Second-phase constructor
    42 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    43 //
    39 //
    44 void CUsbNoteNotifier::ConstructL()
    40 void CUsbNoteNotifier::ConstructL()
    45     {
    41     {
    46     FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ConstructL" ) );
    42     LOG_FUNC
    47 
    43 
    48     iNotifierActive = new(ELeave)CUsbNoteNotifier::CNotifierActive(iNotifier, this);
    44     iNotifierActive = new (ELeave) CUsbNoteNotifier::CNotifierActive(
       
    45             iNotifier, *this);
    49     }
    46     }
    50 
    47 
    51 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    52 // Destructor
    49 // Destructor
    53 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    54 //
    51 //
    55 CUsbNoteNotifier::~CUsbNoteNotifier()
    52 CUsbNoteNotifier::~CUsbNoteNotifier()
    56     {
    53     {
    57     FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::~CUsbNoteNotifier" ) );
    54     LOG_FUNC
    58     
    55 
    59     delete iNotifierActive;
    56     delete iNotifierActive;
    60     }
    57     }
    61 
    58 
    62 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    63 // From base class CUsbNotifier
    60 // From base class CUsbNotifier
    64 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    65 //
    62 //
    66 void CUsbNoteNotifier::ShowL()
    63 void CUsbNoteNotifier::ShowL()
    67     {
    64     {
    68     FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ShowL aCat = 0x%X aNotifId = 0x%X" ), iCat, iNotifId));
    65     LOG_FUNC
       
    66 
       
    67     LOG2( "aCat = 0x%X aNotifId = 0x%X" , iCat, iNotifId);
    69 
    68 
    70     iNotifierActive->StartL();
    69     iNotifierActive->StartL();
    71     }
    70     }
    72 
    71 
    73 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    74 // From base class CUsbNotifier
    73 // From base class CUsbNotifier
    75 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    76 //
    75 //
    77 void CUsbNoteNotifier::Close()
    76 void CUsbNoteNotifier::Close()
    78     {
    77     {
    79     FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::Close" ) );
       
    80     }
    78     }
    81 
       
    82 
    79 
    83 // ======== MEMBER FUNCTIONS ========
    80 // ======== MEMBER FUNCTIONS ========
    84 
    81 
    85 // ---------------------------------------------------------------------------
    82 // ---------------------------------------------------------------------------
    86 // C++ default constructor
    83 // C++ default constructor
    87 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    88 //
    85 //
    89 CUsbNoteNotifier::CNotifierActive::CNotifierActive(RNotifier& aNotifier, 
    86 CUsbNoteNotifier::CNotifierActive::CNotifierActive(RNotifier& aNotifier,
    90         CUsbNoteNotifier* aUsbNoteNotifier) :
    87         CUsbNoteNotifier& aUsbNoteNotifier) :
    91         CUsbNoteNotifier::CNotifierActive::CActive(EPriorityStandard), 
    88     CUsbNoteNotifier::CNotifierActive::CActive(EPriorityStandard),
    92         iUsbNoteNotifier(aUsbNoteNotifier), 
    89             iUsbNoteNotifier(aUsbNoteNotifier), iNotifier(aNotifier), iRes(0)
    93         iNotifier(aNotifier), 
       
    94         iRes(0)
       
    95     {
    90     {
    96     CActiveScheduler::Add(this);
    91     CActiveScheduler::Add(this);
    97     }
    92     }
    98 
    93 
    99 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
   109 // Start to show the notifier
   104 // Start to show the notifier
   110 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
   111 //
   106 //
   112 void CUsbNoteNotifier::CNotifierActive::StartL()
   107 void CUsbNoteNotifier::CNotifierActive::StartL()
   113     {
   108     {
   114     FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::ShowL aCat = 0x%X aNotifId = 0x%X" ), 
   109     LOG_FUNC
   115             iUsbNoteNotifier->iCat, iUsbNoteNotifier->iNotifId));
       
   116 
   110 
   117     if (IsActive())
   111     if (IsActive())
   118         {
   112         {
   119         Panic(ENotifierIsActiveAlready);
   113         Panic( ENotifierIsActiveAlready);
   120         return;
   114         return;
   121         }
   115         }    
   122 
   116 		
   123     TPckgBuf<TInt> pckg;
   117     iNotifIdPckg() = iUsbNoteNotifier.iNotifId;
   124     pckg() = iUsbNoteNotifier->iNotifId;
   118     iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier.iCat, iNotifIdPckg, iRes);
   125 
       
   126     iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier->iCat, pckg, iRes);
       
   127     SetActive();
   119     SetActive();
   128     }
   120     }
   129 
   121 
   130 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   131 // From base class CActive
   123 // From base class CActive
   132 // ---------------------------------------------------------------------------
   124 // ---------------------------------------------------------------------------
   133 //
   125 //
   134 void CUsbNoteNotifier::CNotifierActive::RunL()
   126 void CUsbNoteNotifier::CNotifierActive::RunL()
   135     {
   127     {
   136     FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCCUsbNoteNotifier::CNotifierActive::RunL iStatus = %d" ), iStatus.Int()));
   128     LOG_FUNC
       
   129 
       
   130     LOG1( "iStatus = %d" , iStatus.Int());
   137 
   131 
   138     // if error occured, deal with it in RunError
   132     // if error occured, deal with it in RunError
   139     User::LeaveIfError(iStatus.Int());
   133     User::LeaveIfError(iStatus.Int());
   140 
   134 
   141     iNotifier.CancelNotifier(iUsbNoteNotifier->iCat);
   135     iNotifier.CancelNotifier(iUsbNoteNotifier.iCat);
   142 
   136 
   143     // report to owner that show is over
   137     // report to owner that show is over
   144     iUsbNoteNotifier->iNotifManager->NotifierShowCompletedL(iUsbNoteNotifier, KErrNone, iRes());
   138     iUsbNoteNotifier.iNotifManager.NotifierShowCompletedL(iUsbNoteNotifier,
       
   139             KErrNone, iRes());
   145     }
   140     }
   146 
   141 
   147 // ---------------------------------------------------------------------------
   142 // ---------------------------------------------------------------------------
   148 // From base class CActive
   143 // From base class CActive
   149 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   150 //
   145 //
   151 void CUsbNoteNotifier::CNotifierActive::DoCancel()
   146 void CUsbNoteNotifier::CNotifierActive::DoCancel()
   152     {
   147     {
   153     FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::DoCancel" ) );
   148     iNotifier.CancelNotifier(iUsbNoteNotifier.iCat);
   154 
       
   155     iNotifier.CancelNotifier(iUsbNoteNotifier->iCat);
       
   156     }
   149     }
   157 
   150 
   158 // ---------------------------------------------------------------------------
   151 // ---------------------------------------------------------------------------
   159 // From base class CActive
   152 // From base class CActive
   160 // ---------------------------------------------------------------------------
   153 // ---------------------------------------------------------------------------
   161 //
   154 //
   162 TInt CUsbNoteNotifier::CNotifierActive::RunError(TInt aError)
   155 TInt CUsbNoteNotifier::CNotifierActive::RunError(TInt aError)
   163     {
   156     {
   164     FTRACE( FPrint(_L("[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::RunError aError = %d" ), aError));
   157     LOG_FUNC
   165 
   158 
   166     iNotifier.CancelNotifier(iUsbNoteNotifier->iCat);
   159     LOG1("aError = %d" , aError);
       
   160 
       
   161     iNotifier.CancelNotifier(iUsbNoteNotifier.iCat);
   167 
   162 
   168     // try to continue  
   163     // try to continue  
   169     return KErrNone;
   164     return KErrNone;
   170     }
   165     }
   171 
   166