usbengines/usbotgwatcher/src/cusbservicecontrol.cpp
branchRCL_3
changeset 65 a44cdf4b4bf0
parent 64 8ecef05bbada
child 21 ff9df6630274
equal deleted inserted replaced
64:8ecef05bbada 65:a44cdf4b4bf0
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2008-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:  Implementation
       
    15  *
     8  *
    16 */
     9  * Initial Contributors:
    17 
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Implementation
       
    15  *
       
    16  */
    18 
    17 
    19 #include <usbman.h>
    18 #include <usbman.h>
    20 
    19 
    21 #include "cusbservicecontrol.h"
    20 #include "cusbservicecontrol.h"
    22 #include "debug.h"
    21 #include "debug.h"
    24 
    23 
    25 // ---------------------------------------------------------------------------
    24 // ---------------------------------------------------------------------------
    26 // 
    25 // 
    27 // ---------------------------------------------------------------------------
    26 // ---------------------------------------------------------------------------
    28 //
    27 //
    29 CUsbServiceControl::CUsbServiceControl(MUsbServiceControlObserver* aObserver,
    28 CUsbServiceControl::CUsbServiceControl(MUsbServiceControlObserver& aObserver,
    30         RUsb& aUsb) :
    29         RUsb& aUsb) :
    31     CActive(CActive::EPriorityStandard), iObserver(aObserver), iUsb(aUsb),
    30     CActive(CActive::EPriorityStandard), iObserver(aObserver), iUsb(aUsb),
    32             iPersonalityId(0)
    31             iPersonalityId(0)
    33     {
    32     {
    34     CActiveScheduler::Add(this);
    33     CActiveScheduler::Add(this);
    38 // 
    37 // 
    39 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    40 //
    39 //
    41 CUsbServiceControl::~CUsbServiceControl()
    40 CUsbServiceControl::~CUsbServiceControl()
    42     {
    41     {
    43         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::~CUsbServiceControl" ) );
    42     LOG_FUNC
       
    43 
    44     Cancel();
    44     Cancel();
    45     }
    45     }
    46 
    46 
    47 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    48 // 
    48 // 
    49 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    50 //
    50 //
    51 void CUsbServiceControl::ConstructL()
    51 void CUsbServiceControl::ConstructL()
    52     {
    52     {
    53         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::ConstructL" ) );
    53     LOG_FUNC
    54     }
    54     }
    55 
    55 
    56 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    57 // 
    57 // 
    58 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    59 //
    59 //
    60 CUsbServiceControl* CUsbServiceControl::NewL(
    60 CUsbServiceControl* CUsbServiceControl::NewL(
    61         MUsbServiceControlObserver* aObserver, RUsb& aUsb)
    61         MUsbServiceControlObserver& aObserver, RUsb& aUsb)
    62     {
    62     {
    63         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::NewL" ) );
    63     LOG_FUNC
    64 
    64 
    65     CUsbServiceControl* self = new (ELeave) CUsbServiceControl(aObserver,
    65     CUsbServiceControl* self = new (ELeave) CUsbServiceControl(aObserver,
    66             aUsb);
    66             aUsb);
    67     CleanupStack::PushL(self);
    67     CleanupStack::PushL(self);
    68     self->ConstructL();
    68     self->ConstructL();
    74 // 
    74 // 
    75 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    76 //
    76 //
    77 TInt CUsbServiceControl::StartL(TInt aPersonalityId)
    77 TInt CUsbServiceControl::StartL(TInt aPersonalityId)
    78     {
    78     {
    79         FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::Start aPersonalityId = %d" ), aPersonalityId));
    79     LOG_FUNC
       
    80 
       
    81     LOG1( "aPersonalityId = %d" , aPersonalityId);
    80 
    82 
    81     TUsbServiceState serviceState;
    83     TUsbServiceState serviceState;
    82     TInt err = iUsb.GetServiceState(serviceState);
    84     TInt err = iUsb.GetServiceState(serviceState);
    83 
    85 
    84     if (KErrNone != err)
    86     if (KErrNone != err)
    88 
    90 
    89     switch (serviceState)
    91     switch (serviceState)
    90         {
    92         {
    91         case EUsbServiceIdle:
    93         case EUsbServiceIdle:
    92             {
    94             {
    93                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceIdle" ) );
    95             LOG( "UsbServiceState == EUsbServiceIdle" );
    94 
    96 
    95             iPersonalityId = aPersonalityId; // when request completed, this will indicate that we started what we wanted
    97             iPersonalityId = aPersonalityId; // when request completed, this will indicate that we started what we wanted
    96             if (IsActive())
    98             if (IsActive())
    97                 {
    99                 {
    98                     FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Request is outstanding, cancelling first." ) );
   100                 LOG("Request is outstanding, cancelling first" );
    99                 Cancel();
   101                 Cancel();
   100                 }
   102                 }
   101             iUsb.TryStart(aPersonalityId, iStatus);
   103             iUsb.TryStart(aPersonalityId, iStatus);
   102             SetActive();
   104             SetActive();
   103             break;
   105             break;
   104             }
   106             }
   105 
   107 
   106         case EUsbServiceStarted:
   108         case EUsbServiceStarted:
   107             {
   109             {
   108                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarted" ) );
   110             LOG("UsbServiceState == EUsbServiceStarted");
   109 
   111 
   110             TInt currentPersonality(0);
   112             TInt currentPersonality(0);
   111             err = iUsb.GetCurrentPersonalityId(currentPersonality);
   113             err = iUsb.GetCurrentPersonalityId(currentPersonality);
   112             if (KErrNone != err)
   114             if (KErrNone != err)
   113                 {
   115                 {
   114                     FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Error getting current personality err = %d" ), err));
   116                 LOG1( "Error getting current personality err = %d" , err);
   115                 return err;
   117                 return err;
   116                 }
   118                 }
   117 
   119 
   118             if (aPersonalityId == currentPersonality) // already started
   120             if (aPersonalityId == currentPersonality) // already started
   119                 {
   121                 {
   120                     FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Personality already started" ) );
   122                 LOG("Personality already started" );
   121                 iObserver->UsbServiceControlReqCompletedL(KErrInUse);
   123                 iObserver.UsbServiceControlReqCompletedL(KErrInUse);
   122                 return KErrNone;
   124                 return KErrNone;
   123                 }
   125                 }
   124 
   126 
   125             // we need to stop current personality and start service with new personailty id
   127             // we need to stop current personality and start service with new personailty id
   126             iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality after
   128             iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality after
   131 
   133 
   132             break;
   134             break;
   133             }
   135             }
   134         case EUsbServiceStarting:
   136         case EUsbServiceStarting:
   135             {
   137             {
   136                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarting" ) );
   138             LOG("UsbServiceState == EUsbServiceStarting" );
   137             // do exactly the same as in case of EUsbServiceStopping;
   139             // do exactly the same as in case of EUsbServiceStopping;
   138             // break statement is not required here
   140             // break statement is not required here
   139             }
   141             }
   140         case EUsbServiceStopping:
   142         case EUsbServiceStopping:
   141             {
   143             {
   142                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStopping" ) );
   144             LOG( "UsbServiceState == EUsbServiceStopping" );
   143 
   145 
   144             // subscribe for usb service state change, and start new usb service once current one started/stopped
   146             // subscribe for usb service state change, and start new usb service once current one started/stopped
   145             iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality
   147             iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality
   146 
   148 
   147             // this check is needed due to usb service might be stopping by other client  
   149             // this check is needed due to usb service might be stopping by other client  
   148             if (IsActive())
   150             if (IsActive())
   149                 {
   151                 {
   150                     FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Request outstanding. Waiting for completion." ) );
   152                 LOG( "Request outstanding. Waiting for completion" );
   151                 return KErrNone; // when the outstanding request get completed, we start usb services with iPersonalityId
   153                 return KErrNone; // when the outstanding request get completed, we start usb services with iPersonalityId
   152                 }
   154                 }
   153 
   155 
   154             // otherwise, monitor usb service state
   156             // otherwise, monitor usb service state
   155             iUsb.ServiceStateNotification(iServiceState, iStatus);
   157             iUsb.ServiceStateNotification(iServiceState, iStatus);
   157 
   159 
   158             break;
   160             break;
   159             }
   161             }
   160         case EUsbServiceFatalError:
   162         case EUsbServiceFatalError:
   161             {
   163             {
   162                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) );
   164             LOG( "UsbServiceState == EUsbServiceFatalError" );
   163             return KErrGeneral;
   165             return KErrGeneral;
   164             }
   166             }
   165         default:
   167         default:
   166             {
   168             {
   167             Panic(EUnknownUsbServiceState);
   169             Panic( EUnknownUsbServiceState);
   168             }
   170             }
   169         }
   171         }
   170 
   172 
   171     return KErrNone;
   173     return KErrNone;
   172 
   174 
   176 // 
   178 // 
   177 // ---------------------------------------------------------------------------
   179 // ---------------------------------------------------------------------------
   178 //
   180 //
   179 TInt CUsbServiceControl::StopL()
   181 TInt CUsbServiceControl::StopL()
   180     {
   182     {
   181         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop" ) );
   183     LOG_FUNC
   182 
   184 
   183     TUsbServiceState serviceState;
   185     TUsbServiceState serviceState;
   184     TInt err = iUsb.GetServiceState(serviceState);
   186     TInt err = iUsb.GetServiceState(serviceState);
   185     FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::StopL = %d; Usb service state = %d" ), err, serviceState));
   187 
       
   188     LOG2("err = %d; serviceState = %d" , err, serviceState);
   186 
   189 
   187     if (KErrNone != err)
   190     if (KErrNone != err)
   188         {
   191         {
   189         return err;
   192         return err;
   190         }
   193         }
   191 
   194 
   192     switch (serviceState)
   195     switch (serviceState)
   193         {
   196         {
   194         case EUsbServiceIdle:
   197         case EUsbServiceIdle:
   195             {
   198             {
   196                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceIdle" ) );
   199             LOG("UsbServiceState == EUsbServiceIdle" );
   197 
   200 
   198             return KErrNone;
   201             return KErrNone;
   199             }
   202             }
   200 
   203 
   201         case EUsbServiceStarted:
   204         case EUsbServiceStarted:
   202             {
   205             {
   203                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStarted" ) );
   206             LOG("UsbServiceState == EUsbServiceStarted" );
   204 
   207 
   205             if (IsActive())
   208             if (IsActive())
   206                 {
   209                 {
   207                     FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop Request is outstanding, cancelling it." ) );
   210                 LOG("Request is outstanding, cancelling it" );
   208                 Cancel();
   211                 Cancel();
   209                 }
   212                 }
   210             iUsb.TryStop(iStatus);
   213             iUsb.TryStop(iStatus);
   211             SetActive();
   214             SetActive();
   212 
   215 
   213             break;
   216             break;
   214             }
   217             }
   215         case EUsbServiceStopping:
   218         case EUsbServiceStopping:
   216             {
   219             {
   217                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStopping" ) );
   220             LOG( "UsbServiceState == EUsbServiceStopping" );
   218             // do exactly the same as in case of EUsbServiceStarting;
   221             // do exactly the same as in case of EUsbServiceStarting;
   219             // break statement is not required here
   222             // break statement is not required here
   220             }
   223             }
   221         case EUsbServiceStarting:
   224         case EUsbServiceStarting:
   222             {
   225             {
   223                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStarting" ) );
   226             LOG("UsbServiceState == EUsbServiceStarting" );
   224 
   227 
   225             // subscribe for usb service state change, and stop usb service once current one started
   228             // subscribe for usb service state change, and stop usb service once current one started
   226             iPersonalityId = 0; // this will indicate that we do not want to start this personality
   229             iPersonalityId = 0; // this will indicate that we do not want to start this personality
   227 
   230 
   228             // this check is needed due to usb service might be starting by other client  
   231             // this check is needed due to usb service might be starting by other client  
   229             if (IsActive())
   232             if (IsActive())
   230                 {
   233                 {
   231                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop Request is outstanding, waiting for completion. " ) );
   234                 LOG("Request is outstanding, waiting for completion" );
   232                 return KErrNone; // when this request get completed, we request to stop usb services
   235                 return KErrNone; // when this request get completed, we request to stop usb services
   233                 }
   236                 }
   234 
   237 
   235             // otherwise, monitor usb service state
   238             // otherwise, monitor usb service state
   236             iUsb.ServiceStateNotification(iServiceState, iStatus);
   239             iUsb.ServiceStateNotification(iServiceState, iStatus);
   238 
   241 
   239             break;
   242             break;
   240             }
   243             }
   241         case EUsbServiceFatalError:
   244         case EUsbServiceFatalError:
   242             {
   245             {
   243                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) );
   246             LOG("UsbServiceState == EUsbServiceFatalError" );
   244             return KErrGeneral;
   247             return KErrGeneral;
   245             }
   248             }
   246         default:
   249         default:
   247             {
   250             {
   248             Panic(EUnknownUsbServiceState);
   251             Panic( EUnknownUsbServiceState);
   249             }
   252             }
   250         }
   253         }
   251     return KErrNone;
   254     return KErrNone;
   252     }
   255     }
   253 
   256 
   255 // 
   258 // 
   256 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   257 //
   260 //
   258 void CUsbServiceControl::RunL()
   261 void CUsbServiceControl::RunL()
   259     {
   262     {
   260     FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL iStatus %d" ), iStatus.Int()));
   263     LOG_FUNC
       
   264 
       
   265     LOG1("iStatus = %d" , iStatus.Int());
       
   266 
   261     if (KErrNone != iStatus.Int())
   267     if (KErrNone != iStatus.Int())
   262         {
   268         {
   263         iObserver->UsbServiceControlReqCompletedL(iStatus.Int());
   269         iObserver.UsbServiceControlReqCompletedL(iStatus.Int());
   264         return;
   270         return;
   265         }
   271         }
   266 
   272 
   267     TUsbServiceState serviceState;
   273     TUsbServiceState serviceState;
   268     TInt err = iUsb.GetServiceState(serviceState);
   274     TInt err = iUsb.GetServiceState(serviceState);
   269 
   275 
   270     if (KErrNone != err)
   276     if (KErrNone != err)
   271         {
   277         {
   272             FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while getting service state %d" ), err));
   278         LOG1("Error while getting service state %d" , err);
   273         iObserver->UsbServiceControlReqCompletedL(err);
   279         iObserver.UsbServiceControlReqCompletedL(err);
   274         return;            
   280         return;
   275         }
   281         }
   276 
   282 
   277     switch (serviceState)
   283     switch (serviceState)
   278         {
   284         {
   279         case EUsbServiceIdle: // usb service stopped
   285         case EUsbServiceIdle: // usb service stopped
   280             {
   286             {
   281                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL UsbServiceState == EUsbServiceIdle" ) );
   287             LOG("UsbServiceState == EUsbServiceIdle" );
   282 
   288 
   283             if (iPersonalityId != 0) // during service stopping, requested to start it
   289             if (iPersonalityId != 0) // during service stopping, requested to start it
   284                 {
   290                 {
   285                     FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL Requested to start personality %d. Starting it." ), iPersonalityId));
   291                 LOG1("Requested to start personality %d. Starting it." , iPersonalityId);
   286                 TInt personalityId = iPersonalityId;
   292                 TInt personalityId = iPersonalityId;
   287                 iPersonalityId = 0; // reset
   293                 iPersonalityId = 0; // reset
   288                 err = StartL(personalityId);
   294                 err = StartL(personalityId);
   289                 if(KErrNone != err)
   295                 if (KErrNone != err)
   290                     {
   296                     {
   291                     iObserver->UsbServiceControlReqCompletedL(err);
   297                     iObserver.UsbServiceControlReqCompletedL(err);
   292                     }
   298                     }
   293                 return;
   299                 return;
   294                 }
   300                 }
   295 
   301 
   296             // otherwise, we've done, notify
   302             // otherwise, we've done, notify
   297             iObserver->UsbServiceControlReqCompletedL(KErrNone);
   303             iObserver.UsbServiceControlReqCompletedL(KErrNone);
   298             break;
   304             break;
   299             }
   305             }
   300 
   306 
   301         case EUsbServiceStarted:
   307         case EUsbServiceStarted:
   302             {
   308             {
   303                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarted" ) );
   309             LOG("UsbServiceState == EUsbServiceStarted" );
   304 
   310 
   305             TInt currentPersonality(0);
   311             TInt currentPersonality(0);
   306             err = iUsb.GetCurrentPersonalityId(currentPersonality);
   312             err = iUsb.GetCurrentPersonalityId(currentPersonality);
   307             if (KErrNone != err)
   313             if (KErrNone != err)
   308                 {
   314                 {
   309                 FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while getting PersonalityId err = %d" ), err));
   315                 LOG1("Error while getting PersonalityId err = %d" , err);
   310                 iObserver->UsbServiceControlReqCompletedL(err);
   316                 iObserver.UsbServiceControlReqCompletedL(err);
   311                 return;                    
   317                 return;
   312                 }
   318                 }
   313 
   319 
   314             if (iPersonalityId == currentPersonality) // already done
   320             if (iPersonalityId == currentPersonality) // already done
   315                 {
   321                 {
   316                     FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Personality already started." ) );
   322                 LOG("Personality already started" );
   317                 iPersonalityId = 0;
   323                 iPersonalityId = 0;
   318                 iObserver->UsbServiceControlReqCompletedL(KErrNone);
   324                 iObserver.UsbServiceControlReqCompletedL(KErrNone);
   319                 return;
   325                 return;
   320                 }
   326                 }
   321 
   327 
   322             if (iPersonalityId == 0) // during service start requested to stop it
   328             if (iPersonalityId == 0) // during service start requested to stop it
   323                 {
   329                 {
   324                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Requested to stop personality. Stopping." ) );
   330                 LOG("Requested to stop personality. Stopping." );
   325                 err = StopL();
   331                 err = StopL();
   326                 if(KErrNone != err)
   332                 if (KErrNone != err)
   327                     {
   333                     {
   328                     FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while stopping personality err = %d" ), err));
   334                     LOG1("Error while stopping personality err = %d" , err);
   329                     iObserver->UsbServiceControlReqCompletedL(err);
   335                     iObserver.UsbServiceControlReqCompletedL(err);
   330                     }
   336                     }
   331                 return;
   337                 return;
   332                 }
   338                 }
   333 
   339 
   334             // otherwise, during service start, requested to start it with another personality
   340             // otherwise, during service start, requested to start it with another personality
   335             FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL Requested to start personality %d. Starting it." ), iPersonalityId));
   341             LOG1( "Requested to start personality %d. Starting it.", iPersonalityId);
   336             TInt personalityId = iPersonalityId;
   342             TInt personalityId = iPersonalityId;
   337             iPersonalityId = 0; // reset
   343             iPersonalityId = 0; // reset
   338             err = StartL(personalityId);
   344             err = StartL(personalityId);
   339             if(KErrNone != err)
   345             if (KErrNone != err)
   340                 {
   346                 {
   341                 FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while starting personality err = %d" ), err));
   347                 LOG1("Error while starting personality err = %d" , err);
   342                 iObserver->UsbServiceControlReqCompletedL(err);
   348                 iObserver.UsbServiceControlReqCompletedL(err);
   343                 }
   349                 }
   344             break;
   350             break;
   345             }
   351             }
   346 
   352 
   347         case EUsbServiceStarting:
   353         case EUsbServiceStarting:
   348             {
   354             {
   349                 // do exactly same as in EUsbServiceStopping
   355             // do exactly same as in EUsbServiceStopping
   350                 // break statement is not required here
   356             // break statement is not required here
   351                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start State == EUsbServiceStarting. Continue." ) );
   357             LOG("State == EUsbServiceStarting. Continue." );
   352             }
   358             }
   353         case EUsbServiceStopping:
   359         case EUsbServiceStopping:
   354             {
   360             {
   355                 // we are not interested in these states, just continue monitoring
   361             // we are not interested in these states, just continue monitoring
   356                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start State == EUsbServiceStopping. Continue." ) );
   362             LOG("State == EUsbServiceStopping. Continue." );
   357             iUsb.ServiceStateNotification(iServiceState, iStatus);
   363             iUsb.ServiceStateNotification(iServiceState, iStatus);
   358             SetActive();
   364             SetActive();
   359             break;
   365             break;
   360             }
   366             }
   361         case EUsbServiceFatalError:
   367         case EUsbServiceFatalError:
   362             {
   368             {
   363                 FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) );
   369             LOG("UsbServiceState == EUsbServiceFatalError" );
   364             iObserver->UsbServiceControlReqCompletedL(KErrGeneral);    
   370             iObserver.UsbServiceControlReqCompletedL(KErrGeneral);
   365             break;
   371             break;
   366             }
   372             }
   367         default:
   373         default:
   368             {
   374             {
   369             Panic(EUnknownUsbServiceState);
   375             Panic( EUnknownUsbServiceState);
   370             }
   376             }
   371         }
   377         }
   372 
   378 
   373     }
   379     }
   374 
   380 
   376 // 
   382 // 
   377 // ---------------------------------------------------------------------------
   383 // ---------------------------------------------------------------------------
   378 //
   384 //
   379 TInt CUsbServiceControl::RunError(TInt aError)
   385 TInt CUsbServiceControl::RunError(TInt aError)
   380     {
   386     {
   381         FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunError aError %d" ), aError ));
   387     LOG_FUNC
   382         TRAP_IGNORE(iObserver->UsbServiceControlReqCompletedL(aError));
   388     LOG1("aError = %d", aError );
       
   389     TRAP_IGNORE(iObserver.UsbServiceControlReqCompletedL(aError));
   383 
   390 
   384     return KErrNone;
   391     return KErrNone;
   385     }
   392     }
   386 
   393 
   387 // ---------------------------------------------------------------------------
   394 // ---------------------------------------------------------------------------
   388 // 
   395 // 
   389 // ---------------------------------------------------------------------------
   396 // ---------------------------------------------------------------------------
   390 //
   397 //
   391 void CUsbServiceControl::DoCancel()
   398 void CUsbServiceControl::DoCancel()
   392     {
   399     {
   393         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to Usb TryStart."))
   400     LOG( "Cancelling interest to Usb TryStart.")
   394     iUsb.CancelInterest(RUsb::ETryStart);
   401     iUsb.CancelInterest(RUsb::ETryStart);
   395         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to Usb TrySop."))
   402     LOG( "Cancelling interest to Usb TrySop.")
   396     iUsb.CancelInterest(RUsb::ETryStop);
   403     iUsb.CancelInterest(RUsb::ETryStop);
   397         FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to usb states notifications."))
   404     LOG("Cancelling interest to usb states notifications.")
   398     iUsb.ServiceStateNotificationCancel();
   405     iUsb.ServiceStateNotificationCancel();
   399     }
   406     }