cmmanager/cmmgr/Framework/Src/cmsettingsuiimpl.cpp
branchRCL_3
changeset 55 fc7b30ed2058
parent 0 5a93021fdf25
--- a/cmmanager/cmmgr/Framework/Src/cmsettingsuiimpl.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/cmsettingsuiimpl.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -20,7 +20,11 @@
 #include "cmsettingsuiimpl.h"
 #include "cmmanagerimpl.h"
 #include "destdlg.h"
+#include <cmcommonui.h>
+#include <cmpluginbase.h>
+#include <cmmanagerdef.h>
 #include <cmcommonconstants.h>
+#include <cmpluginwlandef.h>
 #include "selectdestinationdlg.h"
 #include <data_caging_path_literals.hrh>
 
@@ -122,3 +126,102 @@
                                                               
     return dlg->ExecuteLD( R_CMMANAGER_LIST_QUERY_WITH_MSGBOX );    
     }
+//-----------------------------------------------------------------------------
+//  CCmSettingsUiImpl::AddCmL
+//-----------------------------------------------------------------------------
+//
+TUint32 CCmSettingsUiImpl::AddCmL( TUint32& aDestUid, TUint32 aBearerType )
+    {
+    // Add new connection method
+    TUint32 addedIapId(0);
+
+    CCmDestinationImpl* destImpl = iCmManagerImpl->DestinationL( aDestUid );
+    CleanupStack::PushL(destImpl);
+    
+    // Check first if parent destination is protected
+    if ( destImpl->ProtectionLevel() == CMManager::EProtLevel1 )
+        {
+        TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED,
+                                TCmCommonUi::ECmErrorNote );
+        }
+    else
+        {
+        // Automatically check for available conn methods?
+    
+        TBool manualConfigure = ETrue;    
+        if (aBearerType == KUidWlanBearerType)
+            {
+            TInt retval =
+                    TCmCommonUi::ShowConfirmationQueryL( R_CMWIZARD_AUTOMATIC_CHECK );
+    
+            manualConfigure = ( retval == EAknSoftkeyYes || retval == EAknSoftkeyOk )
+                                      ?  EFalse : ETrue;
+            }
+            
+        CCmPluginBase* plugin = destImpl->CreateConnectionMethodL( aBearerType );
+        CleanupStack::PushL( plugin );
+       
+        // Bearer-specific UI-supported initialization is done by plug-ins
+        if ( plugin->InitializeWithUiL( manualConfigure ) )
+            {
+            destImpl->UpdateL();  // commit changes
+
+            RArray<TUint32> additionalCms;
+            CleanupClosePushL (additionalCms);
+            plugin->GetAdditionalUids( additionalCms );
+            //if there are additional cms created, move them to the target destination as well
+            for ( TInt i = 0; i<additionalCms.Count(); i++)
+                {
+                CCmPluginBase* cm = iCmManagerImpl->GetConnectionMethodL( additionalCms[i] );
+                CleanupStack::PushL(cm);
+                iCmManagerImpl->CopyConnectionMethodL( *destImpl, *cm );
+                CleanupStack::PopAndDestroy( cm );
+                }
+            CleanupStack::PopAndDestroy( &additionalCms );   
+            addedIapId = plugin->GetIntAttributeL( CMManager::ECmIapId );
+            }
+        CleanupStack::PopAndDestroy(plugin);
+        }    
+    CleanupStack::PopAndDestroy(destImpl);
+    
+    return addedIapId;
+    }
+
+//-----------------------------------------------------------------------------
+//  CCmSettingsUiImpl::EditCmL
+//-----------------------------------------------------------------------------
+//
+TInt CCmSettingsUiImpl::EditCmL( TUint32 aCmId )
+    {
+    // Edit connection method  
+    TInt ret( KDialogUserBack );
+    
+    CCmPluginBase* cm = iCmManagerImpl->GetConnectionMethodL( aCmId );
+    CleanupStack::PushL( cm );
+    
+    cm->ReLoadL();
+    if ( cm->GetBoolAttributeL( CMManager::ECmProtected ) ||
+         cm->GetBoolAttributeL( CMManager::ECmDestination ) )
+        {
+        TCmCommonUi::ShowNoteL( R_CMMANAGERUI_INFO_PROTECTED_CANNOT_EDIT,
+                                            TCmCommonUi::ECmErrorNote );
+        }
+   else if ( cm->GetBoolAttributeL( CMManager::ECmBearerHasUi ) )
+        {
+        // check if the cm is in use
+        if ( cm->GetBoolAttributeL( CMManager::ECmConnected ) )
+            {
+            TCmCommonUi::ShowNoteL( R_QTN_SET_NOTE_AP_IN_USE_EDIT,
+                                    TCmCommonUi::ECmErrorNote );
+            }
+        else
+            {
+            //Makes sure that the commsdat notifier is initialized.           
+            cm->CmMgr().StartCommsDatNotifierL();
+            ret = cm->RunSettingsL();
+            }
+        }
+    CleanupStack::PopAndDestroy(cm);
+    return ret;
+    }
+