usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp
changeset 3 47c263f7e521
parent 1 705ec7b86991
child 13 7068aba64af5
child 25 8c311f9acc5e
--- a/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp	Mon Jan 18 21:13:23 2010 +0200
+++ b/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp	Tue Jan 26 12:55:41 2010 +0200
@@ -56,10 +56,18 @@
     delete iIconBlinkingTimer;
     
     // Unsubscribe from VBus change notifications
-    iOtgWatcher->VBusObserver()->UnsubscribeL(this);
-    
-    // Unsubscribe from otg watcher states change notifications
-    iOtgWatcher->UnsubscribeL(this);
+    if(iOtgWatcher)
+        {
+        if(iOtgWatcher->VBusObserver())
+            {
+            TRAPD(err, iOtgWatcher->VBusObserver()->UnsubscribeL(this));
+            err=err; // to avoid warning;
+            }
+        
+        // Unsubscribe from otg watcher states change notifications
+        TRAPD(err, iOtgWatcher->UnsubscribeL(this));
+        err=err; // to avoid warning; 
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -235,6 +243,14 @@
 void CUsbIndicatorNotifier::SetIndicatorL()
     {
     FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::SetIndicatorL" ) );
+    
+    if (!(iOtgWatcher->IsDeviceA()))
+        {
+        // if B, than other party (usbwatcher) takes care of usb indicator
+        // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator 
+        return;
+        }
+    
     // if VBus Up and we are host -> show indicator
     if ((iOtgWatcher->VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) &&
             (iOtgWatcher->CurrentHostState()->Id() == EUsbStateHostAHost))