voipplugins/voipadapters/cpvoipadapter/src/CWPVoIPItem.cpp
branchRCL_3
changeset 20 65a3ef1d5bd0
parent 6 fc8c25e5a2e8
--- a/voipplugins/voipadapters/cpvoipadapter/src/CWPVoIPItem.cpp	Mon Jun 21 15:29:21 2010 +0300
+++ b/voipplugins/voipadapters/cpvoipadapter/src/CWPVoIPItem.cpp	Thu Aug 19 09:45:22 2010 +0300
@@ -18,7 +18,7 @@
 
 // INCLUDE FILES
 #include <e32std.h>
-#include    <WPVoIPAdapter.rsg>
+#include    <wpvoipadapter.rsg>
 #include    <charconv.h>
 #include    <in_sock.h>                // TInetAddr, TSockAddr
 #include    <crcseprofileentry.h>
@@ -73,6 +73,11 @@
 const TUint32 KIMLaunchUid          = 0x200255D0;
 const TInt    KIMSettingsId         = 1;
 
+// Bearer related constants
+const TUint32 KBearerNotSpecified = 0;
+const TUint32 KBearerWlanOnly = 1;
+const TUint32 KBearerCellularOnly = 2;
+
 // Following lines are for enabling debug prints.
 #ifdef _DEBUG
 #define DBG_PRINT(p) RDebug::Print(_L(p))
@@ -877,9 +882,22 @@
             priorityArray.Append( iCodecs[codecIndex]->iPriorityIndex );
             }
         priorityArray.Sort();
+        
+        //delete possible duplicate priority index
+        for ( TInt index = 0; index < priorityArray.Count()-1; ++index )
+            {
+            TInt tmpIndex = index + 1; 
+            while ( tmpIndex < priorityArray.Count() &&
+                    priorityArray[tmpIndex] == priorityArray[index] )
+                {
+                priorityArray.Remove( tmpIndex );
+                }
+            }
+
         RPointerArray<CWPVoIPCodec> tmpArray;
 
-        for ( TInt priorityIndex = 0; priorityIndex < numberOfCodecs; 
+        TInt numberOfPriority = priorityArray.Count();
+        for ( TInt priorityIndex = 0; priorityIndex < numberOfPriority; 
             priorityIndex++ )
             {
             for ( TInt codecIndex = 0; codecIndex < numberOfCodecs; 
@@ -992,13 +1010,6 @@
         cRCSEProfileEntry->iVoIPPluginUID = iVoIPPluginUid;
         }
 
-    // AllowVoIPOverWCDMA
-    if ( KNotSet != iAllowVoIPOverWCDMA )
-        {
-        cRCSEProfileEntry->iAllowVoIPoverWCDMA = 
-            static_cast<VoIPProfileEntry::TOnOff>( iAllowVoIPOverWCDMA );
-        }
-
     // VoIPDigits
     if ( KNotSet != iVoIPDigits )
         {
@@ -1569,6 +1580,7 @@
         CleanupStack::PushL( sipManagedProf ); // CS:4
         sipManagedProf->SetParameter( KSIPSnapId, iSnapId );
         sipManagedProf->SetParameter( KSIPAccessPointId, (TUint32)0 );
+        DBG_PRINT2( "CWPVoIPItem::SavingFinalizedL - SNAP ID (1): %d", iSnapId );
         sipReg->SaveL( *sipManagedProf );
         CleanupStack::PopAndDestroy( sipManagedProf ); // CS:3
         CleanupStack::Pop( sipProf ); // CS:2
@@ -1718,6 +1730,7 @@
                 // Update sip profile to use default snap
                 sipManagedProf->SetParameter( KSIPAccessPointId, (TUint32)0 );
                 sipManagedProf->SetParameter( KSIPSnapId, iSnapId );
+                DBG_PRINT2( "CWPVoIPItem::SavingFinalizedL - SNAP ID (2): %d", iSnapId );
                 sipReg->SaveL( *sipManagedProf );
                 }
             }
@@ -1727,6 +1740,7 @@
         sipProf = NULL;
         // sipReg, sipObs
         CleanupStack::PopAndDestroy( 2, sipObs ); // CS:0
+        sipReg = NULL;
         }
 
     if ( iSnapIdSet )
@@ -1772,6 +1786,51 @@
     DBG_PRINT( "CWPVoIPItem::SavingFinalizedL - \
         Service provider entry updated" );
 
+    DBG_PRINT2( "CWPVoIPItem::SavingFinalizedL - \
+        set allow VoIP over wcdma iAlowVoIPOverWCDMA=%d", iAllowVoIPOverWCDMA );
+    
+    //***********************
+    // Allow VoIP over WCDMA
+    //***********************
+    CSIPProfileRegistryObserver* sipObs = 
+        CSIPProfileRegistryObserver::NewLC(); // CS:1
+    CSIPManagedProfileRegistry* sipReg =
+        CSIPManagedProfileRegistry::NewLC( *sipObs ); // CS:2
+    CSIPProfile* sipProf = NULL;
+    sipProf = sipReg->ProfileL( iSipId );
+    CleanupStack::PushL( sipProf ); // CS:3
+    CSIPManagedProfile* sipManagedProf = 
+        static_cast<CSIPManagedProfile*>( sipProf );
+    CleanupStack::PushL( sipManagedProf ); // CS:4
+        
+    if ( iAllowVoIPOverWCDMA == 1 )
+        {
+        DBG_PRINT( "CWPVoIPItem::SavingFinalizedL - \
+          set bearer not specified" );
+    
+        // If VoIP is allowed over wcdma set bearer type to sip as 
+        // not specified.
+        sipManagedProf->SetParameter( KBearerType, KBearerNotSpecified );
+        }
+    else
+        {
+        DBG_PRINT( "CWPVoIPItem::SavingFinalizedL - \
+            set bearer setting wlan only" );
+    
+        // If not allowed set bearer type to sip as wlan only
+        sipManagedProf->SetParameter( KBearerType, KBearerWlanOnly );
+        }
+    
+    sipReg->SaveL( *sipManagedProf );   
+    CleanupStack::PopAndDestroy( sipManagedProf ); // CS:3
+    CleanupStack::Pop( sipProf ); // CS:2
+    sipProf = NULL;
+    // sipReg, sipObs
+    CleanupStack::PopAndDestroy( 2, sipObs ); // CS:0
+    
+    DBG_PRINT( "CWPVoIPItem::SavingFinalizedL - \
+      bearer settings set" );
+
     // property, spEntry spSettings, cRCSEProfileEntry, cRCSEProfileRegistry
     CleanupStack::PopAndDestroy( 5, cRCSEProfileRegistry ); // CS:0
     iSipIdSet = EFalse;