idlefw/plugins/devicestatus/src/aioperatornamepublisher.cpp
branchRCL_3
changeset 14 15e4dd19031c
parent 8 d0529222e3f0
child 15 a0713522ab97
--- a/idlefw/plugins/devicestatus/src/aioperatornamepublisher.cpp	Mon Mar 15 12:41:53 2010 +0200
+++ b/idlefw/plugins/devicestatus/src/aioperatornamepublisher.cpp	Wed Mar 31 22:04:35 2010 +0300
@@ -20,6 +20,11 @@
 #include <centralrepository.h>
 #include <avkondomainpskeys.h>
 #include <e32property.h>
+#include <ProEngFactory.h>
+#include <MProfileEngine.h>
+#include <MProfile.h>
+#include <MProfilename.h>
+#include <MProEngNotifyHandler.h>
 
 #include <aidevstaplgres.rsg>
 #include "aioperatornamepublisher.h"
@@ -36,6 +41,7 @@
 const TInt KBitShiftByFour = 4;
 const TInt KIsDigitLowLimit = 0;
 const TInt KIsDigitHighLimit = 10;
+const TInt KOfflineProfileId =  5;
 
 LOCAL_C void AppendDigit( TDes& aCode, TInt aValue )
     {
@@ -75,6 +81,9 @@
     {
     iListener = CAiNetworkInfoListener::InstanceL();
     iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
+    iProfileEngine = CreateProfileEngineL();
+    iProfileNotifier = ProEngFactory::NewNotifyHandlerL();
+    iProfileNotifier->RequestProfileActivationNotificationsL( *this );
     }
 
 
@@ -100,6 +109,15 @@
         iPeriodic->Cancel();
         delete iPeriodic;
         }
+    if ( iProfileNotifier )
+        {
+        iProfileNotifier->CancelAll();
+        delete iProfileNotifier;
+        }
+    if( iProfileEngine )
+        {
+        iProfileEngine->Release();
+        }
     }
 
 
@@ -125,10 +143,13 @@
         }
     else
         {
-        TRAP_IGNORE (
-            iPrioritizer->TryToCleanL( *iBroadcaster,
-                                    EAiDeviceStatusContentNetworkIdentity,
-                                    iPriority ));
+        if ( iProfileEngine->ActiveProfileId() != KOfflineProfileId )
+            {
+            TRAP_IGNORE (
+                iPrioritizer->TryToCleanL( *iBroadcaster,
+                                        EAiDeviceStatusContentNetworkIdentity,
+                                        iPriority ));
+            }
         }    
     }
 
@@ -153,6 +174,19 @@
         return;
         }
     
+    if ( iProfileEngine->ActiveProfileId() == KOfflineProfileId )
+        {
+        MProfile* profile = iProfileEngine->ActiveProfileLC();
+        const MProfileName& name = profile->ProfileName();
+        iPrioritizer->TryToPublishL( *iBroadcaster,
+                                      EAiDeviceStatusContentNetworkIdentity,
+                                      name.Name(),
+                                      iPriority );
+        iSuccess = ETrue;
+        CleanupStack::PopAndDestroy();//profile
+        return;
+        }
+    
     if( aClean )
         {
         iPrioritizer->TryToCleanL( *iBroadcaster,
@@ -732,3 +766,8 @@
        	}
   	}
 
+void CAiOperatorNamePublisher::HandleProfileActivatedL( TInt /*aProfileId*/ )
+    {
+    RefreshL( EFalse );
+    }
+