usbengines/usbwatcher/src/cusbwatcher.cpp
branchRCL_3
changeset 5 7068aba64af5
parent 4 7e15987c4500
child 6 a15c582fbf97
--- a/usbengines/usbwatcher/src/cusbwatcher.cpp	Tue Feb 02 00:52:37 2010 +0200
+++ b/usbengines/usbwatcher/src/cusbwatcher.cpp	Fri Feb 19 23:50:33 2010 +0200
@@ -251,7 +251,7 @@
                     aStateOld);
                 break;
                 }
-			LOG1( "Starting USB personality in device state: %d", aStateNew );
+            LOG1( "Starting USB personality in device state: %d", aStateNew );
             iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew );
             // Check AskOnConnection setting every time
             if( ( iSupportedPersonalities.Count() > 1 ) &&
@@ -1032,4 +1032,38 @@
     return iOtgWatcher ? iOtgWatcher->IsDeviceA() : EFalse;
     }
 
+// ----------------------------------------------------------------------------
+// Write new personality to central repository.
+// ----------------------------------------------------------------------------
+//
+TInt CUsbWatcher::WritePersonalityId( TInt aPersonalityId )
+    {
+    LOG_FUNC
+    
+    // Save as the default personality only if it is not hidden
+    TUint32 property(0);
+    TInt ret =  iUsbMan.GetPersonalityProperty( aPersonalityId, property );
+    if ( ret == KErrNone )
+        {
+        LOG2( "Personality %d property: 0x%x", aPersonalityId, property );
+        }
+    else
+        {
+        //Not fatal, treat as non-hidden
+        LOG1( "ERROR: GetPersonalityProperty = %d", ret );
+        property = 0;
+        }
+    if ( property & KUsbPersonalityPropertyHidden ) //Bitwise AND
+        {
+        LOG( "Hidden personality not saved to central repository" );
+        ret = KErrNone;
+        }
+    else
+        {
+        ret =  iPersonalityRepository->Set( KUsbWatcherPersonality,
+            aPersonalityId );
+        }
+    return ret;
+    }
+
 // End of file