Catchup to latest Symbian^4 GCC_SURGE
authorWilliam Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:37:38 +0100
branchGCC_SURGE
changeset 49 faa5ef4f80da
parent 39 f10336de0cd6 (current diff)
parent 47 cb7afde124a3 (diff)
Catchup to latest Symbian^4
accesspointcontrol/apcontrollistplugin/data/10281BB4.rss
accesspointcontrol/apcontrollistplugin/data/apcontrollistpluginrsc.rss
accesspointcontrol/apcontrollistplugin/group/apcontrollistplugin.mmp
accesspointcontrol/apcontrollistplugin/group/apcontrollistpluginicons_dc.mk
accesspointcontrol/apcontrollistplugin/group/bld.inf
accesspointcontrol/apcontrollistplugin/inc/apcontrollistapiwrapper.h
accesspointcontrol/apcontrollistplugin/inc/apcontrollistbox.h
accesspointcontrol/apcontrollistplugin/inc/apcontrollistboxmodel.h
accesspointcontrol/apcontrollistplugin/inc/apcontrollistcapschange.h
accesspointcontrol/apcontrollistplugin/inc/apcontrollistplugin.h
accesspointcontrol/apcontrollistplugin/inc/apcontrollistplugin.hrh
accesspointcontrol/apcontrollistplugin/inc/apcontrollistplugincontainer.h
accesspointcontrol/apcontrollistplugin/inc/apcontrollistpluginlogger.h
accesspointcontrol/apcontrollistplugin/loc/apcontrollistplugin.loc
accesspointcontrol/apcontrollistplugin/rom/APControlListPlugin.iby
accesspointcontrol/apcontrollistplugin/rom/APControlListPluginResources.iby
accesspointcontrol/apcontrollistplugin/src/apcontrollistapiwrapper.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistbox.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistboxmodel.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistcapschange.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistplugin.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistplugincontainer.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistpluginimplementationtable.cpp
accesspointcontrol/apcontrollistplugin/src/apcontrollistpluginlogger.cpp
bearermanagement/mpm/bwins/mpmdefaultconnectionu.def
bearermanagement/mpm/eabi/mpmdefaultconnectionu.def
bearermanagement/mpm/group/mpmdefaultconnectionclient.mmp
bearermanagement/mpm/inc/mpmdefaultconnection.h
bearermanagement/mpm/inc/mpmdefaultconnserver.h
bearermanagement/mpm/inc/mpmdefaultconnserversession.h
bearermanagement/mpm/inc/mpmdisconnectdlg.h
bearermanagement/mpm/inc/mpmofflinewatcher.h
bearermanagement/mpm/inc/mpmwlanquerydialog.h
bearermanagement/mpm/src/mpmdefaultconnection.cpp
bearermanagement/mpm/src/mpmdefaultconnserver.cpp
bearermanagement/mpm/src/mpmdefaultconnserversession.cpp
bearermanagement/mpm/src/mpmdisconnectdlg.cpp
bearermanagement/mpm/src/mpmofflinewatcher.cpp
bearermanagement/mpm/src/mpmwlanquerydialog.cpp
bearermanagement/mpm/src/rmpmdefaultconnection.cpp
cmmanager/cmapplsettingsui/res/cmradiodialog.docml
cmmanager/cmmgr/cmmapi/group/cmmapi.mmp
cmmanager/cmmgr/cmmpluginbase/group/cmmpluginbase.mmp
cmmanager/cmmgr/database/group/cmmanagerdatabase.mmp
connectionutilities/ConnectionDialogs/group/ConnUiUtilsNotif.mmp
connectionutilities/ConnectionDialogs/group/ConnectionUiUtilities.mmp
connectionutilities/ConnectionDialogs/rom/cconndlgResources.iby
dbcreator/commsdatcreator/Src/cdcreaderxml.cpp
dbcreator/commsdatstartup/cenrep/keys_commsdatcreator.xls
dbcreator/conf/commsdatcreator_10281BC8.crml
dbcreator/inc/cdccommsdatcreatorcrkeys.h
ipcm_plat/mpm_default_connection_api/group/bld.inf
ipcm_plat/mpm_default_connection_api/inc/rmpmdefaultconnection.h
ipcm_plat/mpm_default_connection_api/mpm_default_connection_api.metaxml
--- a/accesspointcontrol/apcontrollistplugin/data/10281BB4.rss	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        ECOM plugin resource file for VPN Settings plugin.
-*
-*/
-
-#include <ecom/registryinfo.rh>
-
-RESOURCE REGISTRY_INFO theInfo
-    {
-    dll_uid     = 0x10281BB4; // Plugin dll UID
-    interfaces  = 
-        {
-        INTERFACE_INFO
-            {
-            interface_uid   = 0x10207236; // UID for CGSPluginInterface
-            implementations = 
-                {
-                IMPLEMENTATION_INFO
-                    {
-                    implementation_uid  = 0x10281BB5; // Plugin UID
-                    version_no          = 1;
-                    display_name        = "AP Control List Plugin"; // Plugin debug name
-#ifdef RD_CONTROL_PANEL
-                    default_data        = "0x200255B9"; // Parent UID (gsconnsettingsplugin)
-                    opaque_data         = "70"; // Order number
-#else //RD_CONTROL_PANEL
-                    default_data        = "0x10207250"; // Parent UID (Connection View)
-                    opaque_data         = "210"; // Order number
-#endif //RD_CONTROL_PANEL
-                    }
-                };
-            }
-        };
-    }
-
--- a/accesspointcontrol/apcontrollistplugin/data/apcontrollistpluginrsc.rss	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        Resource file for APControlListPlugin
-*
-*/
-
-
-//  RESOURCE IDENTIFIER
-NAME    APCL
-
-//  INCLUDES
-#include <eikon.rh>
-#include <eikon.rsg>
-#include <avkon.rh>
-#include <avkon.rsg>
-#include <avkon.loc>
-
-#include "apcontrollistplugin.hrh"
-#include <apcontrollistplugin.loc>
-
-
-
-
-//  MACROS
-
-//  RESOURCE DEFINITIONS
-RESOURCE RSS_SIGNATURE
-    {
-    }
-
-RESOURCE TBUF
-    {
-    buf = "apnlist";
-    }
-
-//----------------------------------------------------
-//
-//    r_apclplugin_title
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_apclplugin_title                         
-    { 
-    buf = qtn_acl_title; 
-    }
-
-//----------------------------------------------------
-//
-//    r_qtn_acl_navi_active
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_navi_active                          
-    { 
-    buf = qtn_acl_navi_active ; 
-    }
-    
-//----------------------------------------------------
-//
-//    r_qtn_acl_navi_not_active
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_navi_not_active                          
-    { 
-    buf = qtn_acl_navi_not_active ; 
-    }
-    
-//----------------------------------------------------
-//
-//    r_qtn_acl_empty_view_primary
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_empty_view_primary                          
-    { 
-    buf = qtn_acl_empty_view_primary ; 
-    }
-    
-//----------------------------------------------------
-//
-//    qtn_acl_empty_view_secondary
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_empty_view_secondary                          
-    { 
-    buf = qtn_acl_empty_view_secondary ; 
-    }
-
-//----------------------------------------------------
-//
-//    r_qtn_acl_wait_reading_sim
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_wait_reading_sim                         
-    { 
-    buf = qtn_acl_wait_reading_sim; 
-    }
-
-//----------------------------------------------------
-//
-//    r_qtn_acl_network_provided_apn
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_network_provided_apn                         
-    { 
-    buf = qtn_acl_network_provided_apn; 
-    }
-
-//----------------------------------------------------
-//
-//    r_qtn_acl_conf_nwp_apn_added
-//
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_conf_nwp_apn_added                         
-    { 
-    buf = qtn_acl_conf_nw_provided_apn_added; 
-    }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_conf_apn_added 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_conf_apn_added { buf = qtn_acl_conf_apn_added ; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_conf_apn_removed 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_conf_apn_removed { buf = qtn_acl_conf_apn_removed ; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_conf_control_activated 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_conf_control_activated { buf = qtn_acl_conf_control_activated ; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_conf_control_deactivated 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_conf_control_deactivated { buf = qtn_acl_conf_control_deactivated ; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_info_active 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_info_active { buf = qtn_acl_info_active ; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_info_not_active 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_info_not_active { buf = qtn_acl_info_not_active ; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_err_invalid_input 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_err_invalid_input { buf = qtn_acl_err_invalid_input; }
-
-//----------------------------------------------------
-//   
-//    r_qtn_acl_err_sim_card 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_err_sim_card { buf = text_fdn_card_error; }
-
-//----------------------------------------------------
-//   
-//    r_two_string_for_empty_view 
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_two_string_for_empty_view { buf = "%0U\n%1U"; }
-
-//----------------------------------------------------
-//
-//    r_apclplugin_main_menubar
-//
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_BAR r_apclplugin_main_menubar
-    {
-    titles =
-        {
-        MENU_TITLE 
-            { 
-            menu_pane = r_apclplugin_main_menu; 
-            }
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_apclplugin_main_menu
-//
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_PANE r_apclplugin_main_menu
-    {
-    items =
-        {
-        MENU_ITEM 
-            { 
-            command = EAPControlListCmdActivate; 
-            txt = qtn_acl_options_activate_control; 
-            },
-        MENU_ITEM 
-            { 
-            command = EAPControlListCmdDeactivate; 
-            txt = qtn_acl_options_deactivate_control; 
-            },
-        MENU_ITEM 
-            { 
-            command = EAPControlListCmdAdd; 
-            txt = qtn_acl_options_add_apn_manually; 
-            },
-        MENU_ITEM 
-            { 
-            command = EAPControlListCmdRemove; 
-            txt = qtn_acl_options_remove;
-            flags = EEikMenuItemSpecific;
-            },
-        MENU_ITEM 
-            { 
-            command = EAknCmdHelp; 
-            txt = qtn_options_help; 
-            },
-        MENU_ITEM 
-            { 
-            command = EEikCmdExit; 
-            txt = qtn_options_exit; 
-            }
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_apclplugin_softkeys_options_back
-//
-//
-//----------------------------------------------------
-//
-RESOURCE CBA r_apclplugin_softkeys_options_back
-    {
-    buttons =
-        {
-        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
-        CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back;},
-        CBA_BUTTON {id=EAknSoftkeyEmpty; txt = text_softkey_empty;}
-        };
-    }
-
-//----------------------------------------------------
-//   
-//    r_apclplugin_main_view
-//    Main view.
-//
-//----------------------------------------------------
-//
-RESOURCE AVKON_VIEW    r_apclplugin_main_view    
-    {
-    menubar=r_apclplugin_main_menubar;  
-    cba=r_apclplugin_softkeys_options_back;   
-    }
-
-RESOURCE LISTBOX r_apcontrol_listbox
-{
-   flags = EAknListBoxSelectionList;
-}
-//----------------------------------------------------
-//
-//    r_apn_name_query
-//
-//
-//----------------------------------------------------
-//
-RESOURCE DIALOG r_apn_name_query
-   {
-   flags = EGeneralQueryFlags;
-   buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
-   items =
-       {
-       DLG_LINE
-             {
-             type = EAknCtQuery;
-             id = EGeneralQuery;
-             control = AVKON_DATA_QUERY
-                    {
-                    layout = EDataLayoutAllowEmptyInput;
-                    label = qtn_acl_prmpt_apn_to_add;
-                    control = EDWIN
-                        {
-                        maxlength = KMaxApnNameWitoutLabelLength;
-                        default_case = EAknEditorLowerCase;
-                        // accepts only ASCII
-                        flags = EEikEdwinNoWrap;
-                        avkon_flags = EAknEditorFlagLatinInputModesOnly;
-                        };
-                    };
-             }
-        };
-    }
-    
-//----------------------------------------------------
-//   
-//    r_qtn_vpn_main 
-//    Caption for Plugin.
-//
-//----------------------------------------------------
-//
-RESOURCE TBUF r_qtn_acl_menu_item { buf = qtn_acl_menu_item ; }
-
-
-//End of File
--- a/accesspointcontrol/apcontrollistplugin/group/apcontrollistplugin.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
-* Copyright (c) 2005 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*     This is project specification file for the apcontrollistplugin.
-*
-*
-*/
-
-#include <data_caging_paths.hrh>    //this is needed for RESOURCE_FILES_DIR
-#include <platform_paths.hrh>
-
-CAPABILITY          CAP_ECOM_PLUGIN
-TARGET              apcontrollistplugin.dll
-TARGETTYPE          PLUGIN
-UID                 0x10009D8D 0x10281BB4
-VENDORID            VID_DEFAULT
-
-SOURCEPATH          ../src
-SOURCE				apcontrollistapiwrapper.cpp
-SOURCE              apcontrollistbox.cpp
-SOURCE              apcontrollistboxmodel.cpp
-SOURCE              apcontrollistcapschange.cpp
-SOURCE              apcontrollistplugin.cpp
-SOURCE              apcontrollistplugincontainer.cpp 
-SOURCE              apcontrollistpluginimplementationtable.cpp
-SOURCE              apcontrollistpluginlogger.cpp
-
-USERINCLUDE         ../data
-
-// Component specific internal headers 
-USERINCLUDE			../inc
-
-// ADO specific internal headers 
-SYSTEMINCLUDE		../../../inc
-
-//Macro to /epoc32 headers
-MW_LAYER_SYSTEMINCLUDE
-
-#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
-APP_LAYER_SYSTEMINCLUDE
-#endif
-
-SOURCEPATH          ../data
-
-//ECOM resource definition
-START RESOURCE      10281BB4.rss
-TARGET              apcontrollistplugin.rsc
-END 
-// ECOM resource definition
-
-//apcontrollistplugin resources
-START RESOURCE      apcontrollistpluginrsc.rss
-HEADER
-TARGETPATH          RESOURCE_FILES_DIR
-LANGUAGE_IDS
-END
-
-LIBRARY             hlplch.lib      // for "Help" options menu
-LIBRARY             euser.lib
-LIBRARY             ecom.lib
-LIBRARY             efsrv.lib
-LIBRARY             avkon.lib
-LIBRARY             bafl.lib 
-LIBRARY             cone.lib 
-LIBRARY             eikcoctl.lib 
-LIBRARY             eikcore.lib
-LIBRARY             eikctl.lib
-LIBRARY             commonengine.lib//For RConeResourceLoader
-LIBRARY             GSFramework.lib
-LIBRARY             egul.lib        // CGulIcon
-LIBRARY             aknskins.lib    // AknsUtils.h
-LIBRARY             flogger.lib
-LIBRARY             GSEcomPlugin.lib
-LIBRARY             commonui.lib 
-LIBRARY 			aknnotify.lib 
-LIBRARY             centralrepository.lib
-LIBRARY 			etel.lib 
-LIBRARY 			etelmm.lib 
-LIBRARY 			customapi.lib 
-LIBRARY 			ws32.lib 
-LIBRARY 			FeatMgr.lib 
-
-
-// This is optional - used only by Codewarrior for convenience.
-DOCUMENT            10281BB4.rss
--- a/accesspointcontrol/apcontrollistplugin/group/apcontrollistpluginicons_dc.mk	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#
-# Copyright (c) 2003 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description:  Makefile for icons of APControlListPlugin
-#
-
-ifeq (WINS,$(findstring WINS, $(PLATFORM)))
-ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
-else
-ZDIR=\epoc32\data\z
-endif
-
-
-TARGETDIR=$(ZDIR)\resource\apps
-ICONTARGETFILENAME=$(TARGETDIR)\apcontrollistplugin.mif
-
-HEADERDIR=\epoc32\include
-HEADERFILENAME=$(HEADERDIR)\apcontrollistplugin.mbg
-
-do_nothing :
-	@rem do_nothing
-
-MAKMAKE : do_nothing
-
-BLD : do_nothing
-
-CLEAN : do_nothing
-
-LIB : do_nothing
-
-CLEANLIB : do_nothing
-
-# ----------------------------------------------------------------------------
-# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
-# MifConv if the mask detph is defined.
-#
-# NOTE 2: Usually, source paths should not be included in the bitmap
-# definitions. MifConv searches for the icons in all icon directories in a
-# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
-# The directory \s60\icons is included in the search only if the feature flag
-# __SCALABLE_ICONS is defined.
-# ----------------------------------------------------------------------------
-
-RESOURCE :
-	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
-		/c16,8 qgn_prop_set_conn_acl.bmp 
-
-FREEZE : do_nothing
-
-SAVESPACE : do_nothing
-
-RELEASABLES :
-	@echo $(HEADERFILENAME)&& \
-	@echo $(ICONTARGETFILENAME)
-
-FINAL : do_nothing
--- a/accesspointcontrol/apcontrollistplugin/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2005 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Build information for the APControlListsPlugin
-*
-*/
-
-
-#ifdef RD_GS_RENOVATION // This is the GS_RENOVATION
-	
-#include <platform_paths.hrh>
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-// export iby files
-../rom/APControlListPlugin.iby		CORE_MW_LAYER_IBY_EXPORT_PATH(APControlListPlugin.iby)
-../rom/APControlListPluginResources.iby	LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(APControlListPluginResources.iby)
-
-// export localised loc file
-../loc/apcontrollistplugin.loc	MW_LAYER_LOC_EXPORT_PATH(apcontrollistplugin.loc)
-
-PRJ_MMPFILES
-// gnumakefile apcontrollistpluginicons_dc.mk
-
-./apcontrollistplugin.mmp
-
-PRJ_EXTENSIONS
-
-START EXTENSION s60/mifconv
-OPTION TARGETFILE apcontrollistplugin.mif
-OPTION HEADERFILE apcontrollistplugin.mbg
-OPTION SOURCES -c16,8 qgn_prop_set_conn_acl
-END
-
-#endif
-
-// End of File
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistapiwrapper.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,240 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-* 		 Wrapper class for asyncron calls in RMyPhone and RMyCustomAPI.
-*
-*/
-
-#ifndef APCONTROLLISTAPIWRAPPER_H
-#define APCONTROLLISTAPIWRAPPER_H
-
-// INCLUDES
-#include <e32base.h>
-#include <rmmcustomapi.h>
-
-// FORWARD DECLARATIONS
-class CAPControlListPlugin;
-
-// CLASS DECLARATION
-/**
-*  Wrapper class for asyncron calls in RMyPhone and RMyCustomAPI.
-*/
-class CAPControlListAPIWrapper : public CActive
-	{
-	private: 
-		// Enum for the states checked in RunL()
-		enum TRequestType { EGetACLStatus, EAddAPN, EAddAPNSecurity, 
-		                    ERemoveAPN, ERemoveAPNSecurity, EActivateACL, 
-							EActivateACLSecurity, EDeactivateACL, 
-							EDeactivateACLSecurity, EReadData, 
-							EEnumerateAPN, ENoRequest};
-
-    public:  
-    	// Constructor and destructor
-    	    			
-        /**
-        * Constructor.
-        * @param aPlugin reference to the view
-        * @param aPriority priority for CActive
-        */
-		CAPControlListAPIWrapper(CAPControlListPlugin& aPlugin,
-									TInt aPriority = EPriorityStandard );
-        /**
-        * Destructor.
-        */
-		~CAPControlListAPIWrapper();
-		
-        // New functions     
-          
-        /**
-        * Initialises iPhone and iCustomAPI members. 
-        * Uses User::WaitForRequest
-        * because we need to know the ACL status before Visible() is called.
-        */
-		void ConstructL();
-		
-		// Primary functions for the API calls
-		// These are the functions for which security check is necessary.
-		// If the security was already checked they call the correspondig
-		// secondary function. If the security wasn't already checked they
-		// call the asyncron security check and let RunL call the correspondig
-		// secondary function when the security check is finished.
-        /**
-        * Add APN to the ACL list
-        */
-		void AddAPNL();		
-        /**
-        * Remove APN from the ACL list which is currently selected in the
-        * listbox.
-        */
-		void RemoveAPN();		
-        /**
-        * Activates the ACL list
-        */
-		void ActivateACL();
-        /**
-        * Deactivates the ACL list
-        */
-		void DeActivateACL();
-				
-        /**
-        * Gets the ACL status then reads the ACL list.
-        * If this call is succesfull then RunL calls EnumerateAPN 
-        * then it calls DoReadData
-        */
-		void ReadData();
-		
-        /**
-        * Method for checking if plugin should be visible and used in 
-        * the Connection settings.
-        * @return ETrue if plugin should be visible.
-        * @return EFalse if plugin should not be visible.
-        */
-		TBool Visible() const;
-		
-        /**
-        * Method for checking if the ACL list is enabled or not. 
-        * @return ETrue if the ACL list is enabled.
-        * @return EFalse if the ACL list is not enabled.
-        */
-		TBool Enabled() const;
-		
-        /**
-      	* Calls RMyPhone::NotifyIccAccessCapsChange
-        * Used by CAPControlListCapsChange class. This function is nescessary
-        * since iPhone is a private member.
-        */
-		void NotifyIccAccessCapsChange(TRequestStatus& aReqStatus, 
-														TUint32& aCaps);				
-        /**
-      	* Calls RTelSubSessionBase::CancelAsyncRequest
-        * Used by CAPControlListCapsChange class. This function is nescessary
-        * since iPhone is a private member.
-        */
-        void CancelNotify(); 
-				
-        // Functions from CActive
-        /**
-        * Closes API in case of Cancel() 
-        */
-		void DoCancel();		
-        /**
-        * Handles asynchronous function completion 
-        */
-		void RunL(); 
-		
-	private:
-        // New functions
-        
-        /**
-		* Called from one of the primary functions for the API calls
-        * Calls RMmCustomAPI::CheckSecurityCode asyncron call. This functon is
-        * called only once.
-        * @param aRequest We need this to set the state so we'll know in RunL
-        * which primary function called it.
-        */
-		void SecurityCheck( TRequestType aRequest ); 
-		
-		// Secondary functions for the API calls		
-        /**
-        * Secondary function for AddAPNL().Makes the asyncron call to 
-        * add an APN to the ACL list.
-        * If the security was already checked it is called from AddAPNL.
-        * If the security was not checked it is called from the RunL()
-        * when RunL() is called for RMmCustomAPI::CheckSecurityCode()
-        */
-		void DoAddAPNL();		
-        /**
-        * Secondary function for RemoveAPN().Makes the asyncron call to 
-        * remove an APN from the ACL list.
-        * If the security was already checked it is called from AddAPNL.
-        * If the security was not checked it is called from the RunL()
-        * when RunL() is called for RMmCustomAPI::CheckSecurityCode()
-        */
-		void DoRemoveAPN();
-        /**
-        * Secondary function for ActivateACL() and DeActivateACL().Makes the 
-        * asyncron call to SetACLStatus either EAclStatusEnabled or
-        * EAclStatusDisabled.
-        * If the security was already checked it is called from ActivateACL()
-        * or DeActivateACL().
-        * If the security was not checked it is called from the RunL()
-        * when RunL() is called for RMmCustomAPI::CheckSecurityCode()
-        * @param aAclStatus the status we want to set.
-        */
-		void SetACLStatus( const RMobilePhone::TAPNControlListServiceStatus 
-		                                        aAPNControlListServiceStatus );
-		
-        /**
-        * Reads the ACL list. 
-        * Gets the number of items with an asyncron call. The actual reading
-        * of the APNs happens in DoReadData()
-        */
-		void EnumerateAPN();
-		
-        /**
-        * Reads an APN entry from the ACL list and puts it in the listbox. 
-        * Called from RunL() when RunL() after ReadData() was called. It is
-        * called iSize times. 
-        */
-		void DoReadData();
-
-        /**
-        * Case EReadData in RunL 
-        * Code removed from RunL to make it's size smaller
-        */
-		void FinishReadDataL();
-		
-	private: // Data
-		
-        //@var reference to the view
-		CAPControlListPlugin&			iPlugin;
-	
-		// API objects
-        //@var RTelServer object for the ACL API
-		RTelServer 						iServer;	
-        //@var RMobilePhone object for the ACL API
-		RMobilePhone 					iPhone;
-        //@var RMmCustomAPI object for the ACL API
-		RMmCustomAPI 					iCustomAPI;
-
-        //@var state to store which is the current request
-		TRequestType iRequest;
-		
-        //@var  ACL status
-		RMobilePhone::TAPNControlListServiceStatus		iAclStatus;   
-		
-        //@var phone is online
-		TBool 							iConnAllowed;
-		
-        //@var security checked
-		TBool 							iSecurityChecked;
-		
-        //@var AP Name from the user input ( AddAPN2L() )
-		HBufC* 							iAPN;
-
-		//members for reading data ( ReadData() ReadData2() )
-        //@var AP Name in the form expected by the API
-		RMobilePhone::TAPNEntryV3 		iApn;
-        //@var iApn packaged
-		RMobilePhone::TAPNEntryV3Pckg 	iApnPKG;
-        //@var size of the ACL list
-		TUint32 						iSize;
-        //@var index of item currently read from the ACL list 
-		TUint32 						iIndex;
-	} ;
-
-#endif
-
-// End of file
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistbox.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Declaration of class CApControlListbox.
-*
-*/
-
-
-#ifndef APSELECTOR_LISTBOX_H
-#define APSELECTOR_LISTBOX_H
-
-// INCLUDE FILES
-#include <aknlists.h>
-class CAPControlListPluginContainer;
-
-
-// CLASS DECLARATION
-
-/**
-* Listbox to display the list of access points.
-* 
-*/
-NONSHARABLE_CLASS(CApControlListbox): public CAknSingleStyleListBox
-    {
-    public:     // Construct / destruct
-
-        /**
-        * Destructor.
-        */
-        virtual ~CApControlListbox();
-
-
-        /**
-        * Constructor.
-        */
-        CApControlListbox();
-
-    public :
-        /**
-        * Handle key event.
-        * @param aKeyEvent The key event.
-        * @param aType Key event type.
-        * @return Response (was the key event consumed?).
-        */
-        TKeyResponse OfferKeyEventL
-            ( const TKeyEvent& aKeyEvent, TEventCode aType );
-
-        /**
-        * Handle focus change.
-        * @param aDrawNow Draw now?
-        */
-        void FocusChanged( TDrawNow aDrawNow );
-
-
-        /**
-        * From CCoeControl. Handles a change to the control's resources.
-        * The types of resources handled are those which are shared across 
-        * the environment, e.g. colours or fonts.
-        * Called if Skinning is changed.
-        * @param aType A message UID value.
-        */
-        virtual void HandleResourceChange(TInt aType); 
-
-        /**
-        * Set EmptyText in the listbox
-        */
-        void SetListEmptyTextL();
-    };
-
-
-#endif
-
-// End of file
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistboxmodel.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Declaration of class CApControlListboxModel.
-*
-*/
-
-
-#ifndef APCONTROL_LISTBOX_MODEL_H
-#define APCONTROL_LISTBOX_MODEL_H
-
-// INCLUDES
-#include <aknlists.h>
-
-// CLASS DECLARATION
-
-/**
-* Data model for the access point listbox. It is an array of CApListItem
-* pointers; items are owned.
-*/
-NONSHARABLE_CLASS( CApControlListboxModel ):
-        public CTextListBoxModel,
-        public MDesCArray
-    {
-    public:     // Construct / destruct
-
-        /**
-        * Constructor.
-        * @param aGraphicType Graphic type
-        */
-        CApControlListboxModel( );
-
-        /**
-        * Destructor.
-        */
-        virtual ~CApControlListboxModel();
-
-    public:     // from MDesCArray
-
-        /**
-        * Get number of items in the model.
-        * @return Number of items.
-        */
-        TInt MdcaCount() const;
-
-        /**
-        * Text to be displayed for this item.
-        * @param aIndex Index of item.
-        * @return TPtrC for this item text (text owned by the model).
-        */
-        TPtrC MdcaPoint( TInt aIndex ) const;
-
-    };
-
-
-#endif
-
-// End of file
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistcapschange.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Class for asyncron API call NotifyIccAccessCapsChange.
-*
-*/
-
-#ifndef APCONTROLLISTCAPSCHANGE_H
-#define APCONTROLLISTCAPSCHANGE_H
-
-// INCLUDES
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class CAPControlListPlugin;
-
-// CLASS DECLARATION
-/**
-*  Wrapper class for asyncron syncron API call NotifyIccAccessCapsChange.
-*/
-class CAPControlListCapsChange : public CActive
-	{
-	public: 
-    	// Constructor and destructor
-    	    			
-        /**
-        * Constructor.
-        * @param aPlugin reference to the view
-        * @param aPriority priority for CActive
-        */
-		CAPControlListCapsChange(CAPControlListPlugin& aPlugin,
-									TInt aPriority = EPriorityStandard );
-        /**
-        * Destructor.
-        */
-		~CAPControlListCapsChange();
-		
-        // New functions     
-        /**
-        * Makes asyncron API call RMobilePhone::NotifyIccAccessCapsChange
-        */
-		void NotifyCapsChange();
-		 
-				
-        // Functions from CActive
-        /**
-        * Called by Cancel() 
-        */
-		void DoCancel();		
-        /**
-        * Handles asynchronous function completion 
-        */
-		void RunL();
-		
-	private:
-        //@var reference to the view
-		CAPControlListPlugin&	iPlugin;
-		
-        //@var Caps set by NotifyIccAccessCapsChange
-		TUint32 				iCaps;
-	} ;
-
-#endif
-
-// End of file
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,256 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        Header file for CAPControlListPlugin class.
-*
-*/
-
-#ifndef APCONTROLLIST_PLUGIN_H__
-#define APCONTROLLIST_PLUGIN_H__
-
-// System includes
-#include <eikclb.h>
-#include <gsplugininterface.h>
-#include <ConeResLoader.h>
-
-// This UID is used for both the view UID and the ECOM plugin implementation UID.
-const TUid KAPControlListPluginUid = { 0x10281BB5 };
-
-
-// Forward declarations
-class CAPControlListPluginContainer;
-class CAPControlListAPIWrapper;
-class MUiRunnerObserver;
-class MEikListBoxObserver;
-class CAPControlListCapsChange;
-
-/**
-* Interface class for AP Settings Handler UI. 
-*/
-class CAPControlListPlugin : public CGSPluginInterface,
-                           public MEikListBoxObserver
-    {
-    public://Constructors & destructors
-
-        /**
-        * First phase constructor
-        * Creates new Plugin and Launches CAPControlListPlugin
-        * with default parameters
-        * @param aAppUi pointer to the application Ui
-        */ 
-        static CAPControlListPlugin* NewL( TAny* aInitParams );
-                        
-        /**
-        * Destructor
-        */
-        inline ~CAPControlListPlugin();
-        
-    public: // Functions from base class
-        
-        /**
-        * From CAknView
-        */
-        TUid Id() const;
-        
-        /**
-        * From CAknView
-        */
-        void HandleCommandL( TInt aCommand );
-          
-        /**
-        * From CAknView
-        */    
-        void DoActivateL( const TVwsViewId& aPrevViewId, 
-                          TUid aCustomMessageId, 
-                          const TDesC8& aCustomMessage );
-        
-        /**
-        * From CAknView
-        */    
-        void DoDeactivate();
-        
-        /**
-        * Exit plugin
-        */    
-        void ExitOnUSIMRemovalL();
-        
-
-    public:
-    
-        /**
-        * from CGSPluginInterface
-        */
-        
-        /**
-        * Method for checking plugin's Uid. Uid identifies this GS plugin. Use
-        * same Uid as the ECOM plugin implementation Uid.
-        *
-        * @return PluginUid
-        */
-        TUid PluginUid() const;
-
-        /**
-        * Method for getting caption of this plugin. This should be the 
-        * localized name of the settings view to be shown in parent view.
-        *
-        * @param aCaption pointer to Caption variable
-        */
-        void GetCaptionL( TDes& aCaption ) const;
-
-        /**
-        * Method for checking, if item has bitmap icon to be shown in list
-        *
-        * @return ETrue if plugin has icon bitmap
-        * @return EFalse if plugin does not have a bitmap
-        */
-        TBool HasBitmap() const;
-
-        /**
-        * Method for reading bitmap icon.
-        *
-        * @param aBitmap plugin bitmap
-        * @param aMask plugin icon bitmap mask
-        */
-        void GetBitmapL( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) const;
-
-        /**
-        * Method for reading the ID of the plugin provider category. See 
-        *
-        * @return Plugin provider category ID defined by 
-        *         
-        */
-        TInt PluginProviderCategory() const;
-        
-        /**
-        * Creates a new icon of desired type. Override this to provide custom
-        * icons. Othervise default icon is used. Ownership of the created icon
-        * is transferred to the caller.
-        *
-        * Icon type UIDs (use these defined constants):
-        * KGSIconTypeLbxItem  -   ListBox item icon.
-        * KGSIconTypeTab      -   Tab icon.
-        *
-        * @param aIconType UID Icon type UID of the icon to be created.
-        * @return Pointer of the icon. NOTE: Ownership of this icon is
-        *         transferred to the caller.
-        */
-        CGulIcon* CreateIconL( const TUid aIconType );
-        
-        /**
-        * Method for checking, if plugin should be visible and used in GS FW.
-        * (for example shown in listbox of the parent view).
-        *
-        * On default plugin is visible. Overwrite this function to enable or
-        * disable your plugin dynamically.
-        *
-        * @return ETrue if plugin should be visible in GS.
-        * @return EFalse if plugin should not be visible in GS.
-        */
-        virtual TBool Visible() const;
-                
-        /**
-        * From MUiRunnerObserver
-        */                    
-        void UiComplete( TInt aUirEvent );
-        
-        /**
-        * From MEikListBoxObserver
-        */
-        void HandleListBoxEventL( CEikListBox* aListBox,
-                                  TListBoxEvent aEventType );
-                                          
-        /**
-        * Shows a information note.
-        * @param aResourceId Resource id of the showed text .
-        */
-        void ShowInfoNoteL( TInt aResourceId );
-
-        /**
-        * Shows a confirmation note.
-        * @param aResourceId Resource id of the showed text .
-        */
-        void ShowConfirmNoteL( TInt aResourceId );
-
-        /**
-        * Shows a confirmation note.
-        * @param aResourceId Resource id of the showed text .
-        */
-        void ShowConfirmNoteAPNL( TInt aResourceId, TPtrC& aAPN  );
-   
-      /**
-        * Init menu pane
-        */
-        virtual void DynInitMenuPaneL( TInt aResourceId, 
-                                       CEikMenuPane* aMenuPane );
-		
-        /**
-        * Method for getting the container 
-        *
-        * @return the container 
-        *         
-        */
-        CAPControlListPluginContainer* Container();
-                
-        /**
-        * Method for getting the APIWrapper 
-        *
-        * @return the APIWrapper 
-        *         
-        */
-        CAPControlListAPIWrapper* APIWrapper();
-
-    protected:
-    
-        /**
-        * Constructor
-        */
-        CAPControlListPlugin();
-
-    private:
-    
-        /**
-        * Second phase constructor
-        */
-        TAny ConstructL();
-                                                     
-                    
-    private: //data
-        
-        //@var pointer to the container - owned
-        CAPControlListPluginContainer* 	iContainer; 
-        
-        //@var Previous view.
-        TVwsViewId 						iPrevViewId; 
-        
-        //@var resource loader
-        RConeResourceLoader 			iResources;
-
-        //@var should the plugin should be visible and used in 
-        // the Connection settings.        
-        TBool 							iVisible;
-        
-        //@var class for wrapping asyncron API calls - owned
-        CAPControlListAPIWrapper* 		iAPIWrapper;
-        
-		//@var Wrapper class for asyncron syncron API call 
-		//NotifyIccAccessCapsChange - owned        
-        CAPControlListCapsChange* 		iChangeNotifier;
-        
-        // for the FeatureManager
-        TBool                           iHelp;
-	};
-
-#endif //APCONTROLLIST_PLUGIN_H__
-
-//End of file
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistplugin.hrh	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*     This file contains declarations for resources of APControl List Plugin.
-*     The file can be included in C++ or resource file.
-*
-*/
-
-
-#ifndef APCONTROLLISTUI_HRH
-#define APCONTROLLISTUI_HRH
-
-//Menu commands.
-enum TAPControlListMenuCommands
-    {
-    EAPControlListCmdActivate = 7777,
-    EAPControlListCmdDeactivate,
-    EAPControlListCmdAdd,
-    EAPControlListCmdRemove,
-    EAPControlListCmdExit
-    };
-    
-enum { KMaxApnNameWitoutLabelLength = 99 }; //MaxApnName - 1
-    
-#endif      //  APCONTROLLISTUI_HRH
-
-// End of File
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistplugincontainer.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*     Container class for APControl list plugin.
-*
-*/
-
-
-#ifndef APCONTROLLIST_PLUGIN_CONTAINER_H
-#define APCONTROLLIST_PLUGIN_CONTAINER_H
-
-// INCLUDES
-#include <coeccntx.h>
-#include <eikclb.h>
-
-// FORWARD DECLARATIONS
-class CApControlListbox;
-class CAknNavigationDecorator;
-class CAknNavigationControlContainer;
-class CAPControlListPlugin;
-class MEikListBoxObserver;
-class CApControlListboxModel;
-
-// UID of general settings app, in which help texts are included
-const   TUid    KHelpUidAPControlList = { 0x100058EC };
-
-
-// CLASS DECLARATION
-
-/**
-*  CAPControlListPluginContainer container class
-*  container class for APControl list plugin 
-*/
-class CAPControlListPluginContainer : public CCoeControl
-    {
-    
-    public: 
-        
-        /**
-        * Symbian OS constructor.
-        *
-        * @param aRect Listbox's rect.
-        * @param aListObserver pointer to the list observer
-        */
-        void ConstructL( const TRect& aRect, 
-                         MEikListBoxObserver* aListObserver );
-
-        /**
-        * Destructor.
-        */
-        ~CAPControlListPluginContainer();
-    
-    public: // From CCoeControl
-    
-        /**
-        * From CCoeControl, gives back the count of contained controls.
-        */
-        virtual TInt CountComponentControls() const;
-
-        /**
-        * From CCoeControl, gives back the given indexed 
-        * from contained controls.
-		* @param aIndex index
-        */        
-        CCoeControl* ComponentControl( TInt aIndex ) const;
-
-        /**
-        * From CCoeControl, resizes the contained controls.
-        */
-        virtual void SizeChanged();
-        
-        /**
-        * From CCoeControl, processes the given key event.
-	    * @param aKeyEvent The key event that occured.
-		* @param aType The type of key event that occured.
-	    * @return @c EKeyWasConsumed if the event was processed,
-        */
-        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
-                                     TEventCode aType );
-    
-        /** 
-        * From CCoeControl, gets the control's help context.
-     	* @param aContext help context.
-        */
-        virtual void GetHelpContext( TCoeHelpContext& aContext ) const;
-        
-        /**
-        * From CCoeControl, used for sclable ui and landscape support.
-     	* @param aType A message UID value.
-        */        
-        void HandleResourceChange( TInt aType );
-          
-        /**
-        * From CoeControl,SizeChanged.
-        * @param aDrawNow Contains the value that was passed to it by 
-        *        @c SetFocus(). 
-        */        
-        virtual void FocusChanged(TDrawNow aDrawNow);  
-        
-        /**
-        * Adds to the ListBox
-        * @param newItem new item.
-        */        
-        void AddToListBoxL(TPtrC& newItem);              
-        
-        /**
-        * Sets Current Item Index in the ListBox
-        * @param index Current item index.
-        */        
-		void SetCurrentItemIndex(TInt index);
-		
-        /**
-        * Gets current item index
-        * @return Current item index in the ListBox
-        */        
-		TInt CurrentItemIndex();
-		
-        /**
-        * Removes current item from ListBox
-        */        
-		void RemoveFromListBoxL();
-		
-        /**
-        * Gets the number of items in the list
-        * @return the number of items in the list
-        */
-        TInt NumberOfItems() const;
-		
-        /**
-        * Writes text with ID to the NaviPane
-        */
-        void WriteToNaviPaneL( TInt aResourceId );
-        
-    private:
-
-        /**
-        * Sets the title pane to the appropriate text.
-        * @param aResourceId Resource id of the showed text .
-        */
-        void TitlePaneTextsL( TInt aResourceId );
-
-    public:
-        
-        //@var Listbox  - owned
-        CApControlListbox* 				iListBox;
-        //@var Model for the listbox  - owned
-        CApControlListboxModel*     	iModel;
-
-    private:
-    
-        //@var For NaviPane. - owned
-        CAknNavigationDecorator* 		iNaviDecorator;
-
-        //@var For NaviPane. - owned
-        CAknNavigationControlContainer* iNaviPane;
-        
-    };
-
-#endif //APCONTROLLIST_PLUGIN_CONTAINER_H   
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistpluginlogger.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*      Logging macros for APControl List Plugin
-*
-*/
-
-
-#ifndef APCONROL_LIST_PLUGIN_LOGGER_H
-#define APCONROL_LIST_PLUGIN_LOGGER_H
-
-// INCLUDES
-
-#ifdef _DEBUG
-    #include <e32std.h>
-    #include <e32def.h>
-    #include <flogger.h>
-
-    // TYPES
-
-    enum TAPControlListPluginLogMask             ///< Log mask bits.
-        {
-        ELogOff         = 0x00000000,   ///< Don't log.
-        EApUi           = 0x00000001,   ///< Log transaction activity.
-        ESelector       = 0x00000002,   ///< Log Selection activity.
-        EEditing        = 0x00000004,   ///< Log editing activity.
-        EModel          = 0x00000008,   ///< Log model activity.
-
-        EProtection     = 0x00000020,   ///< Log protection activity.
-        EApItem         = 0x00000040,   ///< Log ApItem activity.
-        ECommons        = 0x00000080,   ///< Log transaction activity.
-        EActiveDb       = 0x000000F0,   ///< Log active db&notific. activity.
-        ELogAll         = 0xFFFFFFFF    ///< Log all.
-        };
-
-    // MACROS
-
-    /// Determines what to log. Construct this from TApEngineLogMask values.
-    #define APCONTROL_LIST_LOG_MASK ELogAll
-    /// Determines log detail (0==basic level).
-    #define APCONTROL_LIST_LOG_LEVEL 4
-
-    // CLASS DECLARATION
-
-    /**
-    * Logger class.
-    */
-NONSHARABLE_CLASS( APControlListPluginLogger )
-        {
-        public:     // new methods
-
-        /**
-        * Write formatted log.
-        * @param aMask Log mask.
-        * @param aLevel Log level.
-        * @param aFmt Format string.
-        */
-        static void Write
-            ( TInt32 aMask, TInt aLevel, 
-              TRefByValue<const TDesC16> aFmt, ... );
-
-        /**
-        * Write formatted log.
-        * @param aMask Log mask.
-        * @param aLevel Log level.
-        * @param aFmt Format string.
-        * @param aList Variable argument list.
-        */
-        static void Write
-            (
-            TInt32 aMask,
-            TInt aLevel,
-            TRefByValue<const TDesC16> aFmt,
-            VA_LIST& aList
-            );
-
-        /**
-        * Write formatted log.
-        * @param aMask Log mask.
-        * @param aLevel Log level.
-        * @param aFmt Format string.
-        */
-        static void Write
-            ( TInt32 aMask, TInt aLevel, 
-              TRefByValue<const TDesC8> aFmt, ... );
-
-        /**
-        * Write formatted log.
-        * @param aMask Log mask.
-        * @param aLevel Log level.
-        * @param aFmt Format string.
-        * @param aList Variable argument list.
-        */
-        static void Write
-            (
-            TInt32 aMask,
-            TInt aLevel,
-            TRefByValue<const TDesC8> aFmt,
-            VA_LIST& aList
-            );
-
-        /**
-        * Write hex dump.
-        * @param aMask Log mask.
-        * @param aLevel Log level.
-        * @param aHeader Header string.
-        * @param aMargin Margin.
-        * @param aPtr Data.
-        * @param aLen Data length.
-        */
-        static void HexDump
-            (
-            TInt32 aMask,
-            TInt aLevel, 
-            const TText* aHeader,
-            const TText* aMargin,
-            const TUint8* aPtr,
-            TInt aLen
-            );
-
-        /**
-        * Create log dir.
-        */
-		static void FCreate();
-        };
-
-
-	#define CLOG_CREATE()  {APControlListPluginLogger::FCreate();}
-    /// Write formatted to log.
-    #define CLOG( body ) APControlListPluginLogger::Write body
-    /// Write hex dump.
-    #define CDUMP( body ) APControlListPluginLogger::HexDump body
-
-#else /* not defined _DEBUG */
-
-    /// Do nothing (log disabled).
-    #define CLOG( body )
-    /// Do nothing (log disabled).
-    #define CDUMP( body )
-	#define CLOG_CREATE()
-
-#endif /* def _DEBUG */
-
-#endif /* def APCONROL_LIST_PLUGIN_LOGGER_H */
--- a/accesspointcontrol/apcontrollistplugin/loc/apcontrollistplugin.loc	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        Localization strings for Plugin
-*
-*/
-
-
-//  LOCALISATION STRINGS
-
-//d:Text of a list item in Connection view's list
-//d:Item opens APN control list view
-//l:list_single_large_graphic_pane_t1 
-//r:3.1
-//
-#define qtn_acl_menu_item "Access point name (APN) control list"
-
-
-//d:Title pane text of the APN control list view
-//l:title_pane_t2/opt12
-//r:3.1
-//
-#define qtn_acl_title "APN control list"
-
-//d:Text of the wait window while the program reads the info from the SIM card
-//l:popup_note_wait_window
-//r:3.1
-//
-#define qtn_acl_wait_reading_sim "Reading info from SIM card"
-
-//d:Text in a note window
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_info_not_active "APN control list not active"
-
-//d:Text in a note window
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_info_active "APN control list is activated"
-
-//d:Text in the navi text pane pane when the control is not active
-//l:navi_text_pane_t1   
-//r:3.1
-//
-#define qtn_acl_navi_not_active "Control not active"
-
-//d:Text in the navi text pane pane when the control is active
-//l:navi_text_pane_t1   
-//r:3.1
-//
-#define qtn_acl_navi_active "Control active"
-
-//d:This is the text in the ABC column when when the list is empty
-//l:main_pane_empty_t1/opt2
-//r:3.1
-//
-#define qtn_acl_empty_view_primary "(no APNs)"
-
-//d:This is the secondary text in the ABC column when when the list is empty
-//l:main_list_empty_pane/opt2
-//r:3.1
-//
-#define qtn_acl_empty_view_secondary "Select Add APN from Options menu to add it to control list" 
-
-//d:Command in options menu.
-//d:Activates the currently selected list item.
-//l:list_single_pane_t1_cp2
-//r:3.1
-//
-#define qtn_acl_options_activate_control "Activate control"
-
-//d:Command in options menu.
-//d:Deactivates the currently selected list item.
-//l:list_single_pane_t1_cp2
-//r:3.1
-//
-#define qtn_acl_options_deactivate_control "Deactivate control"
-
-//d:If the APN control list is activated
-//d:this note is displayed.
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_conf_control_activated "APN control list activated"
-
-//d:If the APN control list is deactivated
-//d:this note is displayed.
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_conf_control_deactivated "APN control list deactivated"
-
-//d:Command in options menu.
-//d:Adds an APN manually
-//l:list_single_pane_t1_cp2
-//r:3.1
-//
-#define qtn_acl_options_add_apn_manually "Add APN manually"
-
-//d:Text in data query window
-//d:text of the data query window with wich is possible to add APN manually
-//l:popup_query_data_window
-//r:3.1
-//
-#define qtn_acl_prmpt_apn_to_add "APN to add:"
-
-//d:Text in the popup window whics comes up when the APN is
-//d:added to the control list
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_conf_apn_added "APN '%U' added to control list"
-
-//d:Text in the popup window whics comes up when a Network-provided APN is
-//d:added to the control list
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_conf_nw_provided_apn_added "Network-provided APN added to control list"
-
-//d:Command in options menu.
-//d:Removes currently selected list item from the list.
-//l:list_single_pane_t1_cp2
-//r:3.1
-//
-#define qtn_acl_options_remove "Remove"
-
-//d:Text in the popup window whics comes up when
-//d:the APN is removed from list
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_conf_apn_removed "APN removed from list"
-
-//d:APN name for network-provided APN in the list
-//l:list_single_pane_t1
-//r:3.1
-//
-#define qtn_acl_network_provided_apn "Network-provided APN"
-
-//d:Text in a note window
-//l:popup_note_window
-//r:3.1
-//
-#define qtn_acl_err_invalid_input "Invalid input value"
-
-// End of File
-
-
--- a/accesspointcontrol/apcontrollistplugin/rom/APControlListPlugin.iby	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Image description file for project APControlListPlugin
-*
-*/
-
-
-#ifndef __APControlListPLUGIN_IBY__
-#define __APControlListPLUGIN_IBY__
-
-#ifdef __PROTOCOL_WCDMA
-#ifdef _DEBUG
-ECOM_PLUGIN_UDEB(APControlListPlugin.DLL,10281BB4.rsc)
-SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,APControlListplugin)
-#else
-ECOM_PLUGIN(APControlListPlugin.DLL,10281BB4.rsc)
-SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,APControlListplugin)
-#endif
-#endif //__PROTOCOL_WCDMA
-
-#endif __APControlListPLUGIN_IBY__
\ No newline at end of file
--- a/accesspointcontrol/apcontrollistplugin/rom/APControlListPluginResources.iby	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Image description file for project APControlListPlugin
-*
-*/
-
-
-#ifndef __APControlListPLUGIN_RESOURCES_IBY__
-#define __APControlListPLUGIN_RESOURCES_IBY__
-
-#ifdef __PROTOCOL_WCDMA
-data=DATAZ_\RESOURCE_FILES_DIR\APControlListPluginRsc.rsc RESOURCE_FILES_DIR\APControlListPluginRsc.rsc
-#endif //__PROTOCOL_WCDMA
-
-#endif __APControlListPLUGIN_RESOURCES_IBY__
\ No newline at end of file
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistapiwrapper.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,709 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Class for asyncron calls.
-*
-*/
-
-// INCLUDE FILES
-#include <AknQueryDialog.h>
-#include <rmmcustomapi.h>
-#include <etelmm.h>
-#include <apcontrollistpluginrsc.rsg>
-#include <errorres.rsg>
-#include <StringLoader.h>
-#include <aknnotewrappers.h> 
-
-#include "apcontrollistapiwrapper.h"
-#include "apcontrollistpluginlogger.h"
-#include "apcontrollistplugincontainer.h"
-#include "apcontrollistplugin.h"
-#include "apcontrollistbox.h"
-#include "centralrepository.h"
-#include "CoreApplicationUIsSDKCRKeys.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// ----------------------------------------------------------------------------- 
-// CAPControlListAPIWrapper::CAPControlListAPIWrapper
-// Description: CAPControlListAPIWrapper constructer 
-// ----------------------------------------------------------------------------- 
-//
-CAPControlListAPIWrapper::CAPControlListAPIWrapper(
-							CAPControlListPlugin& aPlugin, TInt aPriority ) : 
-											CActive( aPriority ), 
-											iPlugin(aPlugin),
-											iApnPKG(iApn)
-	{
-	CActiveScheduler::Add( this ); 
-	}
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListAPIWrapper:: CAPControlListAPIWrapper
-// Description: CAPControlListAPIWrapper Destructer
-// ----------------------------------------------------------------------------- 
-// 
-CAPControlListAPIWrapper::~CAPControlListAPIWrapper()
-	{
-    CLOG( ( ESelector, 0, _L( 
-    			"-> CAPControlListAPIWrapper::~CAPControlListAPIWrapper" ) ) );
-	Cancel();
-	iCustomAPI.Close();
-	iPhone.Close();
-	iServer.Close();
-	delete iAPN;
-    CLOG( ( ESelector, 0, _L( 
-    			"<- CAPControlListAPIWrapper::~CAPControlListAPIWrapper" ) ) );
-	}
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListAPIWrapper::RequestFunction
-// Description: Request Function for CAPControlListAPIWrapper 
-// ---------------------------------------------------------------------------- 
-//
-void CAPControlListAPIWrapper::SecurityCheck(TRequestType aRequest) 
-	{
-    CLOG( ( ESelector, 0, _L( 
-    			"-> CAPControlListAPIWrapper::SecurityCheck" ) ) );
-	if( !IsActive() )
-		{
-		iCustomAPI.CheckSecurityCode (iStatus, 
-								RMmCustomAPI::ESecurityCodePin2 ); 	 	
-		iRequest = aRequest;	
-		SetActive();
-		}
-    CLOG( ( ESelector, 0, _L( 
-    			"<- CAPControlListAPIWrapper::SecurityCheck" ) ) );
-	}
-
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListAPIWrapper::DoCancel
-// Description: This is called from CActive's Cancel 
-//----------------------------------------------------------------------------- 
-//
-void CAPControlListAPIWrapper::DoCancel()
-	{
-    CLOG( ( ESelector, 0, _L( 
-    			"-> CAPControlListAPIWrapper::DoCancel" ) ) );
-	CLOG( ( ESelector, 0, _L( "Current request: %d" ), iRequest ) );
-	switch(iRequest)
-	{
-	case EEnumerateAPN: 
-        iPhone.CancelAsyncRequest(EMobilePhoneEnumerateAPNEntries);
-	    break; 
-	case EReadData: 
-        iPhone.CancelAsyncRequest(EMobilePhoneGetAPNname);
-	    break;
-	    
-	// Since there are no enums for these, can't cancel  
-	case EAddAPNSecurity:
-	case EAddAPN:
-	case ERemoveAPNSecurity:
-	case ERemoveAPN: 
-	case EActivateACLSecurity:
-	case EActivateACL: 
-	case EDeactivateACLSecurity:
-	case EDeactivateACL:
-	    break; 	
-	 
-	case ENoRequest: // no active request
-	    break; 	
-	default:
-		// This could be only in case of programming error
-		CLOG( ( ESelector, 0, _L( "State Error: %d" ), iRequest ) );
-	    break;
-	}
-    CLOG( ( ESelector, 0, _L( 
-    			"<- CAPControlListAPIWrapper::DoCancel" ) ) );
-	}
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListAPIWrapper::FinishReadDataL
-// Description: Case EReadData in RunL  
-//----------------------------------------------------------------------------- 
-//
-void CAPControlListAPIWrapper::FinishReadDataL()
-	{
-    CLOG( ( ESelector, 0, _L( 
-    			"-> CAPControlListAPIWrapper::FinishReadDataL" ) ) );
-	if (iIndex > 0)
-		{
-		iApn = iApnPKG();
-		// lablel lengthes must be replaced with dots and  
-	    // removed from the beginnig
-	    if ( iApn.iApn.Length() )
-    	    {
-    	    TUint8 lablelLength	= (TUint8)(iApn.iApn[0]);
-    	    TUint8 wholeLength	= lablelLength;
-    	    iApn.iApn.Delete(0,1);
-    	    while (iApn.iApn.Length() > wholeLength)
-    	        {
-    	        wholeLength = wholeLength + 
-    	            (TUint8)(iApn.iApn[lablelLength]) + 1;
-    	        iApn.iApn[lablelLength] = '.';
-    	        lablelLength = wholeLength;//place of next dot
-    	        }	        
-		    HBufC* buf = HBufC::NewLC( RMobilePhone::KMaxApnName );
-		    buf->Des().Copy( iApn.iApn );
-		    TPtrC itemPtr(buf->Des());
-			iPlugin.Container()->AddToListBoxL(itemPtr);			
-		    CleanupStack::PopAndDestroy( buf );
-    	    }
-	    else
-	        {
-			// Empty APN means network provided APN
-    		HBufC* buf = StringLoader::LoadLC ( 
-    							R_QTN_ACL_NETWORK_PROVIDED_APN );
-    		TPtrC nPtr(buf->Des());
-			iPlugin.Container()->AddToListBoxL(nPtr);			
-		    CleanupStack::PopAndDestroy( buf );
-	        }
-		}
-	if (iIndex < iSize)
-		{
-		DoReadData();
-		iIndex++;
-		}
-	else
-		{
-		iRequest = ENoRequest;			
-		if ( iSize > 0 )
-			{
-			iPlugin.Container()->SetCurrentItemIndex(0);    		
-			}				
-		}
-    CLOG( ( ESelector, 0, _L( 
-    			"<- CAPControlListAPIWrapper::FinishReadDataL" ) ) );
-	}
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListAPIWrapper::RunL 
-// Description: CActive::RunL implementation which will either stop the
-// Scheduler or increment the count
-//----------------------------------------------------------------------------- 
-//
-void CAPControlListAPIWrapper::RunL()
-	{
-	if ( iStatus != KErrNone )
-		{
-		CLOG( ( ESelector, 0, _L( "Bad RequestStatus: %d for request: %d" ), 
-													iStatus.Int(), iRequest) );	    
-
-		// KErrOverflow can occur during APN adding process, if the APN list is full
-		// or there is no space for an additional entry in SIM card.
-	    if( iStatus.Int() == KErrOverflow && iRequest == EAddAPN)
-	        {
-            HBufC* text = StringLoader::LoadLC ( 
-                R_QTN_ACL_ERR_SIM_CARD );
-            CAknErrorNote* note = new ( ELeave ) CAknErrorNote(
-                 ETrue );
-            note->ExecuteLD( *text );
-
-            CleanupStack::PopAndDestroy( text );
-	        }
-	    
-	    iRequest = ENoRequest;  
-
-		return;
-		}
-	switch(iRequest)
-	{
-	case EGetACLStatus:
-	    {
-		CLOG( ( ESelector, 0, _L( "EGetACLStatus OK" ) ) );
-#ifdef _DEBUG
-    	if (iAclStatus == RMobilePhone::EAPNControlListServiceEnabled)
-    		{		
-        	CLOG( ( ESelector, 0, _L( "iAclStatus == EAclStatusEnabled" ) ) );
-    		}
-    	else if (iAclStatus == RMobilePhone::EAPNControlListServiceDisabled)
-    		{		
-        	CLOG( ( ESelector, 0, _L( "iAclStatus == EAclStatusDisabled" ) ) );
-    		}
-    	else
-    		{		
-        	CLOG( ( ESelector, 0, _L( "iAclStatus is bad!!!" ) ) );
-    		}
-#endif 		    
-		if ( Enabled() )
-			{
-		    iPlugin.ShowInfoNoteL(R_QTN_ACL_INFO_ACTIVE);
-		    iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_ACTIVE);
-			}
-		else
-			{
-		    iPlugin.ShowInfoNoteL(R_QTN_ACL_INFO_NOT_ACTIVE);
-		    iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_NOT_ACTIVE);
-			}
-        EnumerateAPN();
-	    break; 	        
-	    }
-	case EAddAPNSecurity:
-		CLOG( ( ESelector, 0, _L( "EAddAPNSecurity OK" ) ) );
-		iSecurityChecked = ETrue;
-		DoAddAPNL();
-	    break; 
-	case EAddAPN:
-	    {
-		iRequest = ENoRequest;	
-		CLOG( ( ESelector, 0, _L( "EAddAPN OK" ) ) );
-        TPtrC tptrc(iAPN->Des());
-		if (tptrc.Length())
-			{
-	    	iPlugin.Container()->AddToListBoxL(tptrc);        
-			iPlugin.ShowConfirmNoteAPNL(R_QTN_ACL_CONF_APN_ADDED, tptrc);
-			}
-		else
-			{
-			HBufC* buf = StringLoader::LoadLC ( 
-						R_QTN_ACL_NETWORK_PROVIDED_APN );
-			TPtrC itemPtr(buf->Des());
-			iPlugin.Container()->AddToListBoxL(itemPtr);			
-			CleanupStack::PopAndDestroy( buf );
-			iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_NWP_APN_ADDED);
-			}
-	    break; 	        
-	    } 
-	case ERemoveAPNSecurity:
-		CLOG( ( ESelector, 0, _L( "ERemoveAPNSecurity OK" ) ) );
-		iSecurityChecked = ETrue;
-		DoRemoveAPN();
-	    break; 
-	case ERemoveAPN: 
-		iRequest = ENoRequest;	
-		CLOG( ( ESelector, 0, _L( "ERemoveAPN OK" ) ) );
-		iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_APN_REMOVED);	
-		iPlugin.Container()->RemoveFromListBoxL();    			
-	    break; 
-	case EActivateACLSecurity:
-		CLOG( ( ESelector, 0, _L( "EActivateACLSecurity OK" ) ) );
-		iSecurityChecked = ETrue;
-		SetACLStatus( RMobilePhone::EAPNControlListServiceEnabled );
-	    break; 
-	case EActivateACL: 
-		iRequest = ENoRequest;	
-		CLOG( ( ESelector, 0, _L( "EActivateACL OK" ) ) );
-		iAclStatus = RMobilePhone::EAPNControlListServiceEnabled;
-		iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_CONTROL_ACTIVATED);	
-		iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_ACTIVE);
-	    break; 
-	case EDeactivateACLSecurity:
-		CLOG( ( ESelector, 0, _L( "EDeactivateACLSecurity OK" ) ) );
-		iSecurityChecked = ETrue;
-		SetACLStatus( RMobilePhone::EAPNControlListServiceDisabled );
-	    break; 
-	case EDeactivateACL: 
-		iRequest = ENoRequest;	
-		CLOG( ( ESelector, 0, _L( "EDeactivateACL OK" ) ) );
-		iAclStatus = RMobilePhone::EAPNControlListServiceDisabled;
-		iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_CONTROL_DEACTIVATED);	
-		iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_NOT_ACTIVE);
-	    break; 
-	case EEnumerateAPN: 
-		CLOG( ( ESelector, 0, _L( "EEnumerateAPN OK" ) ) );
-		iRequest = EReadData;	
-		FinishReadDataL();
-	    break; 
-	case EReadData: 
-		CLOG( ( ESelector, 0, _L( "EReadData OK" ) ) );
-		FinishReadDataL();
-	    break; 
-	default:
-		{
-		// This could be only in case of programming error
-		CLOG( ( ESelector, 0, _L( "State Error: %d" ), iRequest ) );
-		User::Leave(KErrGeneral);			
-		}
-	    break;
-	}
-	}
-	
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::DoReadData
-// ---------------------------------------------------------
-void CAPControlListAPIWrapper::DoReadData() 
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData2" ) ) );
-	if( !IsActive() )
-		{
-		iRequest = EReadData;			
-		iApn.iApn.Zero();
-		iApn.iApn.SetMax();
-		iPhone.GetAPNname(iStatus, iIndex, iApnPKG);
-		SetActive();
-		}    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData2" ) ) );
-    }
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::ReadData
-// ---------------------------------------------------------
-void CAPControlListAPIWrapper::ReadData() 
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData" ) ) );
-	if( !IsActive() )
-		{
-		iRequest = EGetACLStatus;			
-	    iPhone.GetAPNControlListServiceStatus( iStatus, iAclStatus );
-		SetActive();
-		}    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData" ) ) );
-    }
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::ReadData
-// ---------------------------------------------------------
-void CAPControlListAPIWrapper::EnumerateAPN() 
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData" ) ) );
-	if( !IsActive() )
-		{
-		iRequest = EEnumerateAPN;			
-		iIndex = 0;
-		iPhone.EnumerateAPNEntries(iStatus, iSize);
-		SetActive();
-		}    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::DeActivateACLL()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::DeActivateACL()
-    {   	
-    CLOG( ( ESelector, 0, _L( 
-    			"-> CAPControlListAPIWrapper::DeActivateACLL" ) ) );
-	if (iSecurityChecked)
-		{
-		SetACLStatus( RMobilePhone::EAPNControlListServiceDisabled );
-		}
-	else
-		{
-		SecurityCheck(EDeactivateACLSecurity);
-		}
-    
-    CLOG( ( ESelector, 0, _L( 
-    			"<- CAPControlListAPIWrapper::DeActivateACLL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::ActivateACLL()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::ActivateACL()
-    {   	
-    CLOG( ( ESelector, 0, _L( 
-    			"-> CAPControlListAPIWrapper::ActivateACLL" ) ) );
-	if (iSecurityChecked)
-		{
-		SetACLStatus( RMobilePhone::EAPNControlListServiceEnabled );
-		}
-	else
-		{
-		SecurityCheck(EActivateACLSecurity);
-		}
-    
-    CLOG( ( ESelector, 0, _L( 
-    			"<- CAPControlListAPIWrapper::ActivateACLL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::SetACLStatus()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::SetACLStatus( const 
-    RMobilePhone::TAPNControlListServiceStatus aAPNControlListServiceStatus )
-    {   	
-    CLOG( ( ESelector, 0, 
-    				_L( "-> CAPControlListAPIWrapper::SetACLStatus" ) ) );
-	if( !IsActive() )
-		{
-   		iPhone.SetAPNControlListServiceStatus( iStatus, 
-   		                    aAPNControlListServiceStatus );
-		if ( aAPNControlListServiceStatus == 
-		        RMobilePhone::EAPNControlListServiceEnabled )
-			{
-			iRequest = EActivateACL;			
-			}
-		else
-			{
-			iRequest = EDeactivateACL;			
-			}
-		SetActive();
-		}    
-    CLOG( ( ESelector, 0, _L( 
-    					"<- CAPControlListAPIWrapper::SetACLStatus" ) ) );
-    }
-
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::RemoveAPN()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::RemoveAPN()
-    {   	
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::RemoveAPNL" ) ) );
-    if( iPlugin.Container()->NumberOfItems() > 0)
-        {
-    	if (iSecurityChecked)
-    		{
-    		DoRemoveAPN();
-    		}
-    	else
-    		{
-    		SecurityCheck(ERemoveAPNSecurity);
-    		}
-        }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::RemoveAPNL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::DoRemoveAPN()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::DoRemoveAPN()
-    {   	
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::RemoveAPN2L" ) ) );
-	if( !IsActive() )
-		{
-		TInt index = iPlugin.Container()->CurrentItemIndex();
-		iPhone.DeleteAPNName( iStatus, index );
-		iRequest = ERemoveAPN;
-		SetActive();
-		}    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::RemoveAPN2L" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::AddAPNL()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::AddAPNL()
-    {   	
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::AddAPNL" ) ) );
-	if (iSecurityChecked)
-		{
-		DoAddAPNL();
-		}
-	else
-		{
-		SecurityCheck(EAddAPNSecurity);
-		}
-    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::AddAPNL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::DoAddAPNL()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::DoAddAPNL()
-    {   	
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::DoAddAPNL" ) ) );
-	if( !IsActive() )
-		{
-		delete iAPN;
-		iAPN = NULL;
-		iAPN = HBufC::NewL( RMobilePhone::KMaxApnName );
-	    TPtr16 ptr( iAPN->Des() );		    
-	    CAknQueryDialog* dlg = 
-	                CAknQueryDialog::NewL( ptr, CAknQueryDialog::ENoTone );
-	       
-	    TBool notCanceled = EFalse;
-	    
-	    // Ask the user until either the input is valid or canceled
-	    while ( dlg->ExecuteLD( R_APN_NAME_QUERY ) )
-	        {
-	        
-	        TBool validInput = ETrue;
-	        
-            for (TInt index = 0; index < ptr.Length(); index++)
-                {
-                TChar inputchar = ptr[index];
-                // For ACL only 0-9, A-Z, a-z, '-' and '.' are valid
-                if (! ( ('0' <= inputchar && inputchar <= '9') ||
-                        ('A' <= inputchar && inputchar <= 'Z') ||
-                        ('a' <= inputchar && inputchar <= 'z') ||
-                        inputchar == '-' || inputchar == '.' ) )
-                    {
-                    validInput = EFalse;
-                    break;
-                    }
-                }
-            
-	        if ( validInput )
-		        {
-		        notCanceled =  ETrue;
-		        break;
-		        }
-		    else
-    		    {
-                HBufC* text = StringLoader::LoadLC ( 
-                    R_QTN_ACL_ERR_INVALID_INPUT );
-                CAknErrorNote* note = new ( ELeave ) CAknErrorNote(
-                     ETrue );
-                note->ExecuteLD( *text );
-
-                CleanupStack::PopAndDestroy( text );
-                
-                dlg = 
-	                CAknQueryDialog::NewL( ptr, CAknQueryDialog::ENoTone );
-	            
-    		    }
-	        }
-	        
-	    if ( notCanceled )
-		    {
-		   
-		    // lablel lengthes must be added in place of dots and at the 
-		    // beginnig
-            _LIT8(KFormat,"%c%S"); 
-		    iApn.iApn.SetMax();
-		    iApn.iApn.Zero();		    
-            if ( iAPN->Length() )
-                {
-    	    	TBufC8<RMobilePhone::KMaxApnName> buffer;
-    	    	TBufC8<RMobilePhone::KMaxApnName> buffer2;
-    	    	buffer.Des().Copy( iAPN->Des() );
-    	    	TInt index = buffer.Des().Find(_L8("."));
-    	    	
-    	    	while (index != KErrNotFound)
-        	    	{
-       	    	    buffer2.Des().Copy( buffer.Des().Left( index ) );
-                    TPtr8 tmp = buffer2.Des();
-    			    iApn.iApn.AppendFormat(KFormat, index, &tmp);
-    			    buffer.Des().Delete(0,index+1);
-    			    index = buffer.Des().Find(_L8("."));
-        	    	}
-       	        TPtr8 tmp = buffer.Des();
-    			iApn.iApn.AppendFormat(KFormat, buffer.Length(), &tmp);               
-                }
-            else
-                {
-		        _LIT8(KEmpty8,""); 
-		        iApn.iApn.Copy(KEmpty8);                    
-                }
-            
-	        CLOG( ( ESelector, 0, _L( "Size: %d" ), iApn.iApn.Size() ) );
-	    	iPhone.AppendAPNName( iStatus, iApnPKG );
-	    	
-			iRequest = EAddAPN;
-			SetActive();
-		    }		
-		}    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::DoAddAPNL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::Visible
-// ---------------------------------------------------------
-TBool CAPControlListAPIWrapper::Visible() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::Visible" ) ) );    
-    if (!iConnAllowed)
-        {
-		return EFalse; // phone is in off-line mode            
-        }
-	TUint32 aCaps;	  
-	iPhone.GetIccAccessCaps(aCaps);
-	CLOG( ( ESelector, 0, _L( "%d" ),  aCaps) );
-	if (aCaps & RMobilePhone::KCapsUSimAccessSupported)
-		{		
-		CLOG( ( ESelector, 0, _L( 
-						"<- CAPControlListAPIWrapper::Visible 2" ) ) );
-		return ETrue;
-		}
-	else
-		{			
-		CLOG( ( ESelector, 0, _L( 
-						"<- CAPControlListAPIWrapper::Visible 3" ) ) );
-		return EFalse;
-		}
-    }
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::Enabled
-// ---------------------------------------------------------
-TBool CAPControlListAPIWrapper::Enabled() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::Enabled" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::Enabled" ) ) );
-	if ( iAclStatus == RMobilePhone::EAPNControlListServiceEnabled )
-		{
-		return ETrue;		
-		}
-	else
-		{
-		return EFalse;
-		}		
-    }
-	
-// ---------------------------------------------------------
-// CAPControlListAPIWrapper::ConstructL()
-// ---------------------------------------------------------
-//
-void CAPControlListAPIWrapper::ConstructL()
-    {   	
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ConstructL" ) ) );
-    // init RMobilePhone and RMmCustomAPI
-	_LIT (KTsyName,"phonetsy.tsy");
-	RTelServer::TPhoneInfo info;
-	RPhone::TLineInfo lineInfo;
-	User::LeaveIfError( iServer.Connect() );
-	User::LeaveIfError( iServer.LoadPhoneModule( KTsyName ) );
-	User::LeaveIfError( iServer.GetPhoneInfo( 0, info ) );
-	User::LeaveIfError( iPhone.Open(iServer, info.iName) );	  
-	User::LeaveIfError( iPhone.Initialise() );
-	User::LeaveIfError( iCustomAPI.Open(iPhone) );
-	           		
-	CRepository* aRepository = CRepository::NewL( KCRUidCoreApplicationUIs );
-    aRepository->Get( KCoreAppUIsNetworkConnectionAllowed, iConnAllowed);
-    delete aRepository;
-
-    if (!iAPN)
-		{
-		iAPN = HBufC::NewL( RMobilePhone::KMaxApnName );
-		}
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ConstructL" ) ) );
-    }
-    
-// ----------------------------------------------------------
-// CAPControlListPlugin::NotifyIccAccessCapsChange()
-// ----------------------------------------------------------
-//
-void CAPControlListAPIWrapper::NotifyIccAccessCapsChange(
-							TRequestStatus& aReqStatus, TUint32& aCaps)
-    {
-    CLOG( ( ESelector, 0, 
-        _L( "-> CAPControlListAPIWrapper::NotifyIccAccessCapsChange" ) ) );
-    iPhone.NotifyIccAccessCapsChange( aReqStatus, aCaps );
-    CLOG( ( ESelector, 0, 
-        _L( "<- CAPControlListAPIWrapper::NotifyIccAccessCapsChange" ) ) );
-    }
-// ----------------------------------------------------------
-// CAPControlListPlugin::CancelNotify()
-// ----------------------------------------------------------
-//
-void CAPControlListAPIWrapper::CancelNotify()
-    {
-    CLOG( ( ESelector, 0, 
-        _L( "-> CAPControlListAPIWrapper::CancelNotify" ) ) );
-    iPhone.CancelAsyncRequest(EMobilePhoneNotifyIccAccessCapsChange);
-    CLOG( ( ESelector, 0, 
-        _L( "<- CAPControlListAPIWrapper::CancelNotify" ) ) );
-    }
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistbox.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of ApControlListbox.
-*
-*/
-
-
-// INCLUDE FILES
-
-#include <eikclbd.h>
-#include <avkon.mbg>
-#include <aknkeys.h>
-#include <apcontrollistpluginrsc.rsg>
-#include <AknsUtils.h>
-#include <data_caging_path_literals.hrh>
-#include <StringLoader.h>
-
-#include "apcontrollistbox.h"
-#include "apcontrollistboxmodel.h"
-#include "apcontrollistpluginlogger.h"
-#include "apcontrollistplugin.h"
-#include "apcontrollistapiwrapper.h"
-
-// ================= MEMBER FUNCTIONS =======================
-
-
-// ---------------------------------------------------------
-// CApControlListbox::CApControlListbox
-// ---------------------------------------------------------
-//
-CApControlListbox::CApControlListbox() 
-    {
-    CLOG( ( ESelector, 0, 
-        _L( "<-> CApControlListbox::CApControlListbox" ) ) );
-    }
-
-
-// ---------------------------------------------------------
-// CApControlListbox::~CApControlListbox
-// ---------------------------------------------------------
-//
-CApControlListbox::~CApControlListbox()
-    {
-    CLOG( ( ESelector, 0, 
-        _L( "<-> CApControlListbox::~CApControlListbox" ) ) );
-    }
-
-
-// ---------------------------------------------------------
-// CApControlListbox::OfferKeyEventL
-// ---------------------------------------------------------
-//
-TKeyResponse CApControlListbox::OfferKeyEventL
-( const TKeyEvent& aKeyEvent, TEventCode aType )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CApControlListbox::OfferKeyEventL" ) ) );
-
-    TKeyResponse retval ( EKeyWasConsumed );
-
-    if (    aKeyEvent.iCode == EKeyOK &&
-            !( aKeyEvent.iModifiers & EModifierShift )
-       )
-        {
-        // Enter pressed (not Shift-Enter). This will report an
-        // EEnterKeyPressed event sent to the observer (the view), which may
-        // delete this listbox. The code which processes keypresses by
-        // default, will continue (on the already deleted listbox), and
-        // will crash. So we grab this keypress here, and generate the
-        // same event, but after that, quit immediately.
-        ReportListBoxEventL( MEikListBoxObserver::EEventEnterKeyPressed );
-        // By now the listbox may have been deleted.
-        // Do not access it after this point.
-        }
-    else if (    aKeyEvent.iCode == EKeyBackspace )
-        {
-        static_cast<CAPControlListPlugin*>(iListBoxObserver)->APIWrapper()->
-            RemoveAPN();
-        }
-    else
-        {
-        retval = CAknSingleStyleListBox::OfferKeyEventL
-                            ( aKeyEvent, aType );
-        }
-
-    CLOG( ( ESelector, 0, _L( "<- CApControlListbox::OfferKeyEventL" ) ) );
-
-    return retval;
-    }
-
-
-
-// ---------------------------------------------------------
-// CApControlListbox::FocusChanged
-// ---------------------------------------------------------
-//
-void CApControlListbox::FocusChanged( TDrawNow aDrawNow )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CApControlListbox::FocusChanged" ) ) );
-
-    // Do nothing until the listbox is fully constructed
-    // The dialogpage sets the focus before calling ConstructL
-    if ( iView )
-        {
-        CAknSingleStyleListBox::FocusChanged( aDrawNow );
-        }
-
-    CLOG( ( ESelector, 0, _L( "<- CApControlListbox::FocusChanged" ) ) );
-    }
-
-
-// ---------------------------------------------------------
-// CApControlListbox::HandleResourceChange
-// ---------------------------------------------------------
-//
-void CApControlListbox::HandleResourceChange(TInt aType)
-    {
-    CLOG( ( ESelector, 0, _L( 
-    				"-> CApControlListbox::HandleResourceChange" ) ) );
-    if ( aType == KAknsMessageSkinChange )
-        {        CAknSingleStyleListBox::HandleResourceChange( aType );
-        SizeChanged();
-        }    
-        
-    CAknSingleStyleListBox::HandleResourceChange( aType );
-    CLOG( ( ESelector, 0, _L( 
-    				"<- CApControlListbox::HandleResourceChange" ) ) );
-    }
-// ---------------------------------------------------------
-// CApControlListbox::AddToListBoxL
-// ---------------------------------------------------------
-//
-void CApControlListbox::SetListEmptyTextL()
-    {
-    CLOG( ( ESelector, 0, _L( 
-        "-> CApControlListbox::SetListEmptyTextL" ) ) );
-    HBufC* primary = 
-              iEikonEnv->AllocReadResourceLC( R_QTN_ACL_EMPTY_VIEW_PRIMARY );
-//    _LIT( KCmNewLine, "\n" );    
-//    primary->Des().Append( KCmNewLine );    
-    HBufC* secondary = 
-              iEikonEnv->AllocReadResourceLC( R_QTN_ACL_EMPTY_VIEW_SECONDARY );
-    CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat(2);
-    CleanupStack::PushL(items);
-    items->AppendL(primary->Des()); 
-    items->AppendL(secondary->Des());      
-    HBufC* emptyText = 
-          StringLoader::LoadLC( R_TWO_STRING_FOR_EMPTY_VIEW , *items);              
-    View()->SetListEmptyTextL( *emptyText );    
-    CleanupStack::PopAndDestroy( emptyText );
-    CleanupStack::PopAndDestroy( items );
-    CleanupStack::PopAndDestroy( secondary );
-    CleanupStack::PopAndDestroy( primary );
-    
-    CLOG( ( ESelector, 0, _L( 
-        "<- CApControlListbox::SetListEmptyTextL" ) ) );
-    }
-
-// End of File
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistboxmodel.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of ApControlListboxModel.
-*
-*/
-
-
-// INCLUDE FILES
-#include <aknlists.h>
-#include <apcontrollistpluginrsc.rsg>
-
-#include "apcontrollistboxmodel.h"
-#include "apcontrollistpluginlogger.h"
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CApControlListboxModel::CApControlListboxModel
-// ---------------------------------------------------------
-//
-CApControlListboxModel::CApControlListboxModel()
-:CTextListBoxModel()
-    {
-    CLOG( ( ESelector, 0, _L( 
-    	"-> CApControlListboxModel::CApControlListboxModel" ) ) );
-    CLOG( ( ESelector, 0, _L( 
-    	"<- CApControlListboxModel::CApControlListboxModel" ) ) );
-    }
-
-
-// ---------------------------------------------------------
-// CApControlListboxModel::~CApControlListboxModel
-// ---------------------------------------------------------
-//
-CApControlListboxModel::~CApControlListboxModel()
-    {
-    CLOG( ( ESelector, 0, _L( 
-    	"-> CApControlListboxModel::~CApControlListboxModel" ) ) );
-    CLOG( ( ESelector, 0, _L( 
-    	"<- CApControlListboxModel::~CApControlListboxModel" ) ) );
-    }
-
-
-
-// ---------------------------------------------------------
-// CApControlListboxModel::MdcaCount
-// ---------------------------------------------------------
-//
-TInt CApControlListboxModel::MdcaCount() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CApControlListboxModel::MdcaCount" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CApControlListboxModel::MdcaCount" ) ) );
-    return NumberOfItems();
-    }
-
-
-// ---------------------------------------------------------
-// CApControlListboxModel::MdcaPoint
-// ---------------------------------------------------------
-//
-
-TPtrC CApControlListboxModel::MdcaPoint( TInt aIndex ) const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CApControlListboxModel::MdcaPoint" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CApControlListboxModel::MdcaPoint" ) ) );
-    return ItemText(aIndex);
-    }
-
-
-
-
-// End of File
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistcapschange.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Class for asyncron calls.
-*
-*/
-
-
-// INCLUDE FILES
-#include <rmmcustomapi.h>
-
-#include "apcontrollistcapschange.h"
-#include "apcontrollistplugin.h"
-#include "apcontrollistapiwrapper.h"
-#include "apcontrollistpluginlogger.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// ----------------------------------------------------------------------------- 
-// CAPControlListCapsChange::CAPControlListCapsChange
-// Description: CAPControlListCapsChange constructer 
-// ----------------------------------------------------------------------------- 
-//
-CAPControlListCapsChange::CAPControlListCapsChange(
-					CAPControlListPlugin& aPlugin, TInt aPriority ) : 
-													CActive( aPriority ), 
-													iPlugin(aPlugin) 
-	{
-	CActiveScheduler::Add( this ); 
-	}
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListCapsChange:: CAPControlListCapsChange
-// Description: CAPControlListCapsChange Destructer
-// ----------------------------------------------------------------------------- 
-// 
-CAPControlListCapsChange::~CAPControlListCapsChange()
-	{
-	Cancel();
-	}
-
-
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListCapsChange::DoCancel
-// Description: This calls CActive's Cancel 
-//----------------------------------------------------------------------------- 
-//
-void CAPControlListCapsChange::DoCancel()
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListCapsChange::DoCancel" ) ) );
-    iPlugin.APIWrapper()->CancelNotify();   
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListCapsChange::DoCancel" ) ) );
-    }
-
-//
-//----------------------------------------------------------------------------- 
-// CAPControlListCapsChange::RunL 
-// Description: CActive::RunL implementation which will either stop the
-// Scheduler or increment the count
-//----------------------------------------------------------------------------- 
-//
-void CAPControlListCapsChange::RunL()
-	{
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListCapsChange::RunL" ) ) );
-    CLOG( ( ESelector, 0, _L( "iStatus.Int(): %d"), iStatus.Int() ) );
-    CLOG( ( ESelector, 0, _L( "iCaps: %d"), iCaps ) );
-	if ( !(iCaps & RMobilePhone::KCapsUSimAccessSupported) )
-		{
-		iPlugin.ExitOnUSIMRemovalL();
-		}
-	else
-		{
-    	iPlugin.APIWrapper()->NotifyIccAccessCapsChange( iStatus, iCaps );
-		SetActive();			
-		}
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListCapsChange::RunL" ) ) );
-	}
-	
-
-
-// ---------------------------------------------------------
-// CAPControlListCapsChange::NotifyCapsChange()
-// ---------------------------------------------------------
-//
-void CAPControlListCapsChange::NotifyCapsChange()
-    {   	
-    CLOG( ( ESelector, 0, _L( 
-    	"-> CAPControlListCapsChange::NotifyCapsChange" ) ) );
-	if( !IsActive() )
-		{
-    	iPlugin.APIWrapper()->NotifyIccAccessCapsChange( iStatus, iCaps );
-		SetActive();	
-		}
-    CLOG( ( ESelector, 0, _L( 
-    	"<- CAPControlListCapsChange::NotifyCapsChange" ) ) );
-    }
-
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,506 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  APControlListPlugin class.
-*
-*/
-
-
-// INCLUDE FILES
-
-// System includes
-#include <hlplch.h>
-
-#include <aknlists.h>        //for CListBox
-#include <f32file.h>
-#include <aknnotewrappers.h> //for CAknInformationNote
-#include <AknQueryDialog.h>
-#include <StringLoader.h>
-#include <apcontrollistpluginrsc.rsg>
-#include <data_caging_path_literals.hrh>
-#include <apcontrollistplugin.mbg>
-#include <featmgr.h>
-
-// User includes
-#include "apcontrollistplugin.hrh"
-#include "apcontrollistplugin.h"
-#include "apcontrollistplugincontainer.h"
-#include "apcontrollistpluginlogger.h"
-#include "apcontrollistapiwrapper.h"
-#include "apcontrollistcapschange.h"
-
-// CONSTANTS
-// Resource file location constant
-_LIT( KResourceFileName, "APControlListPluginRsc.rsc" );
-
-// ROM folder
-_LIT( KDriveZ, "z:" );
-
-// Name of the MBM file containing icons
-_LIT( KFileIcons, "apcontrollistplugin.mbm");
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::NewL
-// First phase constructor
-// ---------------------------------------------------------
-CAPControlListPlugin* CAPControlListPlugin::NewL( TAny* /*aInitParams*/ )
-    {
-	CLOG_CREATE()
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::NewL" ) ) );
-    CAPControlListPlugin* self = new ( ELeave ) CAPControlListPlugin();
-    CleanupStack::PushL( self );
-    
-    self->ConstructL( );
-                      
-    CleanupStack::Pop( self );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::NewL" ) ) );
-    return self;     
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::NewL
-// Destructor
-// ---------------------------------------------------------
-CAPControlListPlugin::~CAPControlListPlugin()
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::~CAPControlListPlugin" ) ) );
-    if( iContainer )
-    {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        delete iContainer;
-    }
-    if (iAPIWrapper)
-    {
-    	delete iAPIWrapper;
-    }
-    if (iChangeNotifier)
-    {
-    	delete iChangeNotifier;
-    }
-    iResources.Close();
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::~CAPControlListPlugin" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::Id
-// ---------------------------------------------------------
-TUid CAPControlListPlugin::Id() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::Id" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::Id" ) ) );
-    return KAPControlListPluginUid;
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::HandleCommandL( TInt aCommand )
-// ---------------------------------------------------------
-//
-void CAPControlListPlugin::HandleCommandL( TInt aCommand )
-    {   
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::HandleCommandL" ) ) );
-    switch ( aCommand )
-        {
-        case EAknSoftkeyBack :
-            {
-            // Activate the view ( from GS ) that we
-            // are supposed to return to
-            AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid );
-            break;
-            }
-        case EAPControlListCmdActivate :
-            {
-            iAPIWrapper->ActivateACL();
-            break;
-            }
-        case EAPControlListCmdDeactivate :
-            {
-            iAPIWrapper->DeActivateACL();
-            break;
-            }
-        case EAPControlListCmdAdd :
-            {
-            iAPIWrapper->AddAPNL();
-            break;
-            }
-        case EAPControlListCmdRemove :
-            {
-            iAPIWrapper->RemoveAPN();
-            break;
-            }
-        case EAknCmdHelp : 
-            {
-            HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
-                                                 AppUi()->AppHelpContextL() );
-            break;
-            }
-        case EEikCmdExit :
-        default :
-            {            
-            AppUi()->HandleCommandL( aCommand );
-            break;
-            }
-        }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::HandleCommandL" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::ExitOnUSIMRemovalL
-// ---------------------------------------------------------
-void CAPControlListPlugin::ExitOnUSIMRemovalL() 
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ExitOnUSIMRemovalL" ) ) );
-    iVisible = EFalse;
-	AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ExitOnUSIMRemovalL" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::DoActivateL
-// ---------------------------------------------------------
-void CAPControlListPlugin::DoActivateL( const TVwsViewId& aPrevViewId, 
-                                      TUid /*aCustomMessageId*/, 
-                                      const TDesC8& /*aCustomMessage*/ )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::DoActivateL" ) ) );
-    if ( iPrevViewId.iViewUid.iUid == 0 )
-        {
-        //must be prepared to application switch, so it stores
-        //only the parent view (General Settings Main View)
-        iPrevViewId = aPrevViewId;
-        }
-
-    if ( !iContainer )
-        {
-        iContainer = new( ELeave ) CAPControlListPluginContainer;
-        iContainer->SetMopParent( this );
-        
-        TRAPD( error, iContainer->ConstructL( ClientRect(), this ) );
-        if ( error )
-            {
-            delete iContainer;
-            iContainer = NULL;
-            User::Leave( error );
-            }
-        
-	    if (!iAPIWrapper)  
-		    {
-	    	iAPIWrapper = new( ELeave ) CAPControlListAPIWrapper(*this);
-	    	iAPIWrapper->ConstructL();
-	    	}
-	    if (!iChangeNotifier)  
-		    {
-	    	iChangeNotifier = new( ELeave ) CAPControlListCapsChange(*this);
-            iChangeNotifier->NotifyCapsChange();
-	    	}
-	    				
-		    ShowInfoNoteL(R_QTN_ACL_WAIT_READING_SIM);
-    	  iAPIWrapper->ReadData();  
-        iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
-    	  		
-	    
-        AppUi()->AddToViewStackL( *this, iContainer );
-        }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::DoActivateL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::PluginUid
-// ---------------------------------------------------------
-TUid CAPControlListPlugin::PluginUid() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::PluginUid" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::PluginUid" ) ) );
-    return KAPControlListPluginUid;
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::GetCaption
-// ---------------------------------------------------------
-void CAPControlListPlugin::GetCaptionL( TDes& aCaption ) const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::GetCaptionL" ) ) );
-    StringLoader::Load( aCaption, R_QTN_ACL_MENU_ITEM );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::GetCaptionL" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::HasBitmap
-// ---------------------------------------------------------
-TBool CAPControlListPlugin::HasBitmap() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::HasBitmap" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::HasBitmap" ) ) );
-    return EFalse;
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::GetBitmapL
-// ---------------------------------------------------------
-void CAPControlListPlugin::GetBitmapL( CFbsBitmap* /*aBitmap*/, 
-                                     CFbsBitmap* /*aMask*/ ) const
-    {
-    //no bitmap
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::GetBitmapL" ) ) );
-    User::Leave( KErrNotFound );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::GetBitmapL" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::PluginProviderCategory
-// ---------------------------------------------------------
-TInt CAPControlListPlugin::PluginProviderCategory() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::PluginProviderCategory" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::PluginProviderCategory" ) ) );
-    return EGSPluginProviderOEM;
-    }
-
-// ---------------------------------------------------------
-// CApSettingsPlugin::CreateIconL
-// ---------------------------------------------------------    
-CGulIcon* CAPControlListPlugin::CreateIconL( const TUid aIconType )
-    {
-    TFileName iconsFileName;
-
-    iconsFileName.Append( KDriveZ );
-    iconsFileName.Append( KDC_APP_BITMAP_DIR );
-    iconsFileName.Append( KFileIcons );
-    
-	CGulIcon* icon;
-       
-    if( aIconType == KGSIconTypeLbxItem )
-        {
-        icon = AknsUtils::CreateGulIconL(
-        AknsUtils::SkinInstance(), 
-        KAknsIIDQgnPropSetConnAccp, 
-        iconsFileName,
-        EMbmApcontrollistpluginQgn_prop_set_conn_acl,
-        EMbmApcontrollistpluginQgn_prop_set_conn_acl_mask );
-        }
-     else
-        {
-        icon = CGSPluginInterface::CreateIconL( aIconType );
-        }
-	
-	return icon;
-    }    
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::Visible
-// ---------------------------------------------------------
-TBool CAPControlListPlugin::Visible() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::Visible" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::Visible" ) ) );
-    return iVisible;
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::CAPControlListPlugin
-// ---------------------------------------------------------
-CAPControlListPlugin::CAPControlListPlugin():
-    iPrevViewId(),
-    iResources( *CCoeEnv::Static() ),
-    iVisible(EFalse)
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::CAPControlListPlugin" ) ) );
-    // no implementation required
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::CAPControlListPlugin" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPlugin::ConstructL
-// ---------------------------------------------------------
-TAny CAPControlListPlugin::ConstructL()
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ConstructL" ) ) );
-   
-    TFileName fileName;
-    TDriveUnit drive( EDriveZ );
-    
-    fileName.Append( drive.Name() );
-    fileName.Append( KDC_RESOURCE_FILES_DIR );
-    fileName.Append( KResourceFileName );    
-    iResources.OpenL( fileName );
-
-    BaseConstructL( R_APCLPLUGIN_MAIN_VIEW );
-     
-	// get Visible   
-    iAPIWrapper = new( ELeave ) CAPControlListAPIWrapper(*this);
-    iAPIWrapper->ConstructL();
-    iVisible = iAPIWrapper->Visible();
-    iAPIWrapper->Cancel();
-    delete iAPIWrapper;
-    iAPIWrapper = NULL;
-        
-    FeatureManager::InitializeLibL();
-    iHelp = FeatureManager::FeatureSupported( KFeatureIdHelp ); 
-    FeatureManager::UnInitializeLib();
-    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ConstructL" ) ) );
-    }
-    
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::DynInitMenuPaneL
-// ---------------------------------------------------------
-void CAPControlListPlugin::DynInitMenuPaneL( TInt aResourceId,
-                                         CEikMenuPane* aMenuPane )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::DynInitMenuPaneL" ) ) );
-    CAknView::DynInitMenuPaneL( aResourceId, aMenuPane );
-    if ( aResourceId == R_APCLPLUGIN_MAIN_MENU )
-    {    
-		if ( iAPIWrapper->Enabled() )
-		{
-    		aMenuPane->DeleteMenuItem( EAPControlListCmdActivate );
-		}
-		else
-		{
-    		aMenuPane->DeleteMenuItem( EAPControlListCmdDeactivate );
-		}
-		if ( !iContainer->NumberOfItems() )
-		{
-    		aMenuPane->DeleteMenuItem( EAPControlListCmdRemove );
-		}
-		if (!iHelp)
-		{
-    		aMenuPane->DeleteMenuItem( EAknCmdHelp );		    
-		}
-    }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::DynInitMenuPaneL" ) ) );
-    }
-        
-// ---------------------------------------------------------
-// CAPControlListPlugin::DoDeactivate
-// ---------------------------------------------------------
-void CAPControlListPlugin::DoDeactivate()
-    {        
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::DoDeactivate" ) ) );
-    if ( iContainer )
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        }
-
-    delete iContainer;
-    iContainer = NULL; 
-    if (iChangeNotifier)
-    {
-    	delete iChangeNotifier;
-		iChangeNotifier = NULL; 
-    }
-    if (iAPIWrapper)  
-	    {
-	    delete iAPIWrapper;
-	    iAPIWrapper = NULL;    	
-	    }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::DoDeactivate" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPlugin::UiComplete( TInt aUirEvent )
-// ---------------------------------------------------------
-//
-void CAPControlListPlugin::UiComplete( TInt /*aUirEvent*/ )
-    {    
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::UiComplete" ) ) );
-    // Activate this view as we are coming back
-    // from some other view in the UI
-    TRAP_IGNORE( 
-        AppUi()->ActivateLocalViewL( KAPControlListPluginUid ) )
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::UiComplete" ) ) );
-    }
-    
-// ---------------------------------------------------------
-//  CAPControlListPlugin::HandleListBoxEventL
-// ---------------------------------------------------------
-void CAPControlListPlugin::HandleListBoxEventL( CEikListBox* /*aListBox*/,
-                                              TListBoxEvent aEventType )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::HandleListBoxEventL" ) ) );
-    switch ( aEventType )
-        {
-        case EEventEnterKeyPressed :
-        case EEventItemClicked :
-            {
-            break;
-            }
-        default :
-           break;
-        }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::HandleListBoxEventL" ) ) );
-    }
-    
-// ----------------------------------------------------------
-// CAPControlListPlugin::ShowInfoNoteL( TInt aResourceId )
-// ----------------------------------------------------------
-//
-void CAPControlListPlugin::ShowInfoNoteL( TInt aResourceId )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ShowInfoNoteL" ) ) );
-    HBufC* text = iCoeEnv->AllocReadResourceLC( aResourceId );
-    CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
-    note->ExecuteLD( *text );
-    CleanupStack::PopAndDestroy( text );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ShowInfoNoteL" ) ) );
-    }
-    
-// ----------------------------------------------------------
-// CAPControlListPlugin::ShowConfirmNoteL( TInt aResourceId )
-// ----------------------------------------------------------
-//
-
-void CAPControlListPlugin::ShowConfirmNoteL( TInt aResourceId )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ShowConfirmNoteL" ) ) );
-    HBufC* text = iCoeEnv->AllocReadResourceLC( aResourceId );
-    CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
-    note->ExecuteLD( *text );
-    CleanupStack::PopAndDestroy( text );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ShowConfirmNoteL" ) ) );
-    }
-    
-// ----------------------------------------------------------
-// CAPControlListPlugin::ShowConfirmNoteL( TInt aResourceId )
-// ----------------------------------------------------------
-//
-void CAPControlListPlugin::ShowConfirmNoteAPNL( TInt aResourceId, TPtrC& aAPN )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ShowConfirmNoteL" ) ) );
-    HBufC* text = StringLoader::LoadLC ( aResourceId, aAPN);
-    CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
-    note->ExecuteLD( *text );
-    CleanupStack::PopAndDestroy( text );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ShowConfirmNoteL" ) ) );
-    }
-    
-// ----------------------------------------------------------
-// CAPControlListPlugin::Container()
-// ----------------------------------------------------------
-//
-CAPControlListPluginContainer* CAPControlListPlugin::Container()
-    {
-    return iContainer;
-    }
-    
-// ----------------------------------------------------------
-// CAPControlListPlugin::APIWrapper()
-// ----------------------------------------------------------
-//
-CAPControlListAPIWrapper* CAPControlListPlugin::APIWrapper()
-    {
-    	return iAPIWrapper;
-    }
-//End of file
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistplugincontainer.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,344 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  APControl list Plugin container
-*
-*/
-
-
-// INCLUDE FILES
-#include <hlplch.h>          //for help
-#include <csxhelp/cp.hlp.hrh>
-
-
-#include <akntitle.h>        //for CAknTitlePane
-#include <barsread.h>        //for TResourceReader
-#include <aknlists.h>        //for CListBox
-#include <aknnavi.h>         //for CNaviPane
-#include <aknnavide.h>       //for CAknNavigationDecorator
-#include <apcontrollistpluginrsc.rsg>
-#include <etelmm.h>
-
-#include "apcontrollistplugincontainer.h"
-#include "apcontrollistplugin.h"
-#include "apcontrollistplugin.hrh"
-#include "apcontrollistbox.h"
-#include "apcontrollistboxmodel.h"
-#include "apcontrollistpluginlogger.h"
-
-// CONSTANTS
-_LIT( KEmpty, "");
-
-// ================= MEMBER FUNCTIONS =======================
-// ---------------------------------------------------------
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::ConstructL
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::ConstructL( const TRect& aRect, 
-                                              MEikListBoxObserver* aListObserver )
-    {       
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::ConstructL" ) ) );
-    if ( !iListBox )
-        {
-
-        TResourceReader rr;
-
-        //creates resource reader. reader is pushed to cleaup stack
-        ControlEnv()->CreateResourceReaderLC( rr, R_APCONTROL_LISTBOX );
-
-        CreateWindowL();
-
-        iListBox = new( ELeave ) CApControlListbox;
-        iListBox->SetContainerWindowL( *this );
-
-        iListBox->CreateScrollBarFrameL( ETrue );
-        iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
-                                        CEikScrollBarFrame::EOff, 
-                                        CEikScrollBarFrame::EAuto );
-
-        iListBox->ConstructFromResourceL( rr );
-	    
-	    //Put in empty text thing
-	    iListBox->SetListEmptyTextL();
-        iListBox->SetListBoxObserver( aListObserver );
-
-    	iModel = new( ELeave )CApControlListboxModel;
-    	iModel->ConstructL();
-    	iListBox->Model()->SetItemTextArray( iModel );//give ownership of
-    	// iModel to iListBox
-        
-        CleanupStack::PopAndDestroy(); //resource reader
-        
-        SetRect( aRect );
-                                                           
-        HandleResourceChange( KEikDynamicLayoutVariantSwitch );
-        }      
-        
-
-    TitlePaneTextsL( R_APCLPLUGIN_TITLE );
-    ActivateL();
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::ConstructL" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::AddToListBoxL
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::AddToListBoxL(TPtrC& newItem)
-    {
-    CLOG( ( ESelector, 0, _L( 
-        "-> CAPControlListPluginContainer::AddToListBoxL" ) ) );
-	MDesCArray* textArray = iModel->ItemTextArray();
-	CDesCArray* listBoxItems = static_cast<CDesCArray*>(textArray);
-
-	TBuf<RMobilePhone::KMaxApnName> item;
-	// RMobilePhone::KMaxApnName - label length + TAB = 
-	// RMobilePhone::KMaxApnName 
-	item.Format(_L("\t%S"), &newItem); 
-	listBoxItems->AppendL(item);
-
-	iListBox->HandleItemAdditionL(); // Update listbox
-	iListBox->SetCurrentItemIndexAndDraw(
-	    listBoxItems->Count() - 1); // select new item
-    CLOG( ( ESelector, 0, _L( 
-        "<- CAPControlListPluginContainer::AddToListBoxL" ) ) );
-    }
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::CurrentItemIndex
-// ---------------------------------------------------------
-//
-TInt CAPControlListPluginContainer::CurrentItemIndex()
-    {
-    CLOG( ( ESelector, 0, _L( 
-        "-> CAPControlListPluginContainer::CurrentItemIndex" ) ) );
-    CLOG( ( ESelector, 0, _L( 
-        "<- CAPControlListPluginContainer::CurrentItemIndex" ) ) );
-	return iListBox->CurrentItemIndex(); 
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::SetCurrentItemIndex
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::SetCurrentItemIndex(TInt index)
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::SetCurrentItemIndex" ) ) );
-	iListBox->SetCurrentItemIndexAndDraw(index); 
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::SetCurrentItemIndex" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::RemoveFromListBoxL
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::RemoveFromListBoxL()
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::RemoveFromListBoxL" ) ) );
-	TInt currentItem = iListBox->CurrentItemIndex();
-
-	MDesCArray* textArray = iModel->ItemTextArray();
-	CDesCArray* listBoxItems = static_cast<CDesCArray*>(textArray);
-	listBoxItems->Delete(currentItem, 1); // 1 = how many items to delete
-	AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(iListBox, currentItem, ETrue);
-	iListBox->DrawNow(); // Update listbox    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::RemoveFromListBoxL" ) ) );
-	}
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::~CAPControlListPluginContainer
-// ---------------------------------------------------------
-//
-CAPControlListPluginContainer::~CAPControlListPluginContainer()
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::~CAPControlListPluginContainer" ) ) );
-    delete iListBox;
-    if (iNaviPane)
-        {
-        iNaviPane->Pop(iNaviDecorator);        
-        }
-    delete iNaviDecorator;    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::~CAPControlListPluginContainer" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::CountComponentControls
-// ---------------------------------------------------------
-//
-TInt CAPControlListPluginContainer::CountComponentControls() const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::CountComponentControls" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::CountComponentControls" ) ) );
-    return 1;
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::ComponentControl
-// ---------------------------------------------------------
-//
-CCoeControl* CAPControlListPluginContainer::ComponentControl( TInt aIndex ) const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::ComponentControl" ) ) );
-    switch( aIndex )
-        {
-        case 0 :
-            {
-    		CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::ComponentControl 1" ) ) );
-            return iListBox;
-            }
-        default:
-            {
-    		CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::ComponentControl 2" ) ) );
-            return 0;
-            } 
-        }
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::OfferKeyEventL
-// ---------------------------------------------------------
-//
-TKeyResponse CAPControlListPluginContainer::OfferKeyEventL( 
-                                            const TKeyEvent& aKeyEvent, 
-                                            TEventCode aType )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::OfferKeyEventL" ) ) );
-    TKeyResponse response = EKeyWasNotConsumed;
-    if ( aType == EEventKey )
-        {
-        response = iListBox->OfferKeyEventL( aKeyEvent, aType );
-        }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::OfferKeyEventL" ) ) );
-    return response;
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::SizeChanged
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::SizeChanged()
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::SizeChanged" ) ) );
-    iListBox->SetRect( Rect() );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::SizeChanged" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::GetHelpContext()
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::GetHelpContext( TCoeHelpContext& aContext) const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::GetHelpContext" ) ) );
-    aContext.iMajor = KHelpUidAPControlList;
-    aContext.iContext = KACL_HLP_MAIN;
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::GetHelpContext" ) ) );
-    }
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::TitlePaneTextsL
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::TitlePaneTextsL( TInt aResourceId )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::TitlePaneTextsL" ) ) );
-    CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
-    CAknTitlePane* titlePane =
-        ( CAknTitlePane* )statusPane->ControlL(
-                            TUid::Uid( EEikStatusPaneUidTitle ) );
-
-    //creates and sets title. title is pushed to cleanup stack
-    HBufC* title = iEikonEnv->AllocReadResourceLC( aResourceId );
-    titlePane->SetTextL( *title );
-
-    iNaviPane = STATIC_CAST( CAknNavigationControlContainer*, 
-                 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
-    
-    iNaviDecorator = iNaviPane->CreateNavigationLabelL( KEmpty );
-    iNaviPane->PushL( *iNaviDecorator );
-
-    CleanupStack::PopAndDestroy(title);
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::TitlePaneTextsL" ) ) );
-    }
-
-
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::HandleResourceChange
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::HandleResourceChange( TInt aType )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::HandleResourceChange" ) ) );
-    CCoeControl::HandleResourceChange( aType );
-    if( aType == KEikDynamicLayoutVariantSwitch )
-        {
-        TRect mainPaneRect;
-        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, 
-                                           mainPaneRect );
-        SetRect( mainPaneRect );
-        DrawNow();
-        }
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::HandleResourceChange" ) ) );
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::FocusChanged
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::FocusChanged( TDrawNow aDrawNow )
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::FocusChanged" ) ) );
-    CCoeControl::FocusChanged( aDrawNow );
-    if( iListBox )
-        {
-        iListBox->SetFocus( IsFocused() );
-        }        
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::FocusChanged" ) ) );
-    }
-           
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::CurrentItemNameL
-// ---------------------------------------------------------
-//
-TInt CAPControlListPluginContainer::NumberOfItems()  const
-    {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListPluginContainer::NumberOfItems" ) ) );
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListPluginContainer::NumberOfItems" ) ) );
-    return iListBox->Model()->ItemTextArray()->MdcaCount();
-    }
-    
-// ---------------------------------------------------------
-// CAPControlListPluginContainer::WriteToNaviPaneL
-// ---------------------------------------------------------
-//
-void CAPControlListPluginContainer::WriteToNaviPaneL( TInt aResourceId )
-    {
-    CLOG( ( ESelector, 0, 
-        _L( "-> CAPControlListPluginContainer::WriteToNaviPaneL" ) ) );
-    HBufC* text = iCoeEnv->AllocReadResourceLC( aResourceId );
-    if ( iNaviDecorator )
-        {
-        iNaviPane->Pop(iNaviDecorator);
-        delete iNaviDecorator;
-        iNaviDecorator = NULL;// CodeScanner needs this line
-        }
-    iNaviDecorator = iNaviPane->CreateNavigationLabelL( *text );
-    iNaviPane->PushL( *iNaviDecorator );
-    
-    CleanupStack::PopAndDestroy( text );
-    CLOG( ( ESelector, 0, 
-        _L( "<- CAPControlListPluginContainer::WriteToNaviPaneL" ) ) );
-    }
-    
-// End of File  
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistpluginimplementationtable.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        ECOM proxy table for this plugin
-*
-*/
-
-
-// System includes
-#include <e32std.h>
-#include <ecom/implementationproxy.h>
-
-// User includes
-#include "apcontrollistplugin.h"
-
-// Constants
-const TImplementationProxy KAPControlListPluginImplementationTable[] = 
-    {
-    IMPLEMENTATION_PROXY_ENTRY( 0x10281BB5,    CAPControlListPlugin::NewL )
-    };
-
-
-// ---------------------------------------------------------------------------
-// ImplementationGroupProxy
-// Gate/factory function
-//
-// ---------------------------------------------------------------------------
-//
-EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
-    {
-    aTableCount = sizeof( KAPControlListPluginImplementationTable ) 
-        / sizeof( TImplementationProxy );
-    return KAPControlListPluginImplementationTable;
-    }
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistpluginlogger.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*      Implementation of class APControlListPluginLogger.   
-*
-*/
-
-
-// INCLUDE FILES
-
-#ifdef _DEBUG
-
-    #include "apcontrollistpluginlogger.h"
-    #include <flogger.h>
-	#include <eikenv.h>
-
-    // ================= CONSTANTS =======================
-
-    /// apcontrollistplugin logging directory.
-    _LIT( KapcontrollistpluginLogDir, "apcontrollistplugin" );
-    /// apcontrollistplugin log file name.
-    _LIT( KapcontrollistpluginLogFile, "apcontrollistplugin.txt" );
-
-
-    // ================= MEMBER FUNCTIONS =======================
-
-    // ---------------------------------------------------------
-    // APControlListPluginLogger::Write()
-    // ---------------------------------------------------------
-    //
-    void APControlListPluginLogger::Write
-    ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC16> aFmt, ... )
-        {
-        if( (aMask & APCONTROL_LIST_LOG_MASK) && (aLevel <= APCONTROL_LIST_LOG_LEVEL) )
-            {
-            VA_LIST list;
-            VA_START( list, aFmt );
-            RFileLogger::WriteFormat
-                (
-                KapcontrollistpluginLogDir,
-                KapcontrollistpluginLogFile,
-                EFileLoggingModeAppend,
-                aFmt,
-                list
-                );
-            VA_END( list );
-            }
-        }
-
-
-    // ---------------------------------------------------------
-    // APControlListPluginLogger::Write()
-    // ---------------------------------------------------------
-    //
-    void APControlListPluginLogger::Write
-    ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC16> aFmt, 
-      VA_LIST& aList )
-        {
-        if( (aMask & APCONTROL_LIST_LOG_MASK) && (aLevel <= APCONTROL_LIST_LOG_LEVEL) )
-            {
-            RFileLogger::WriteFormat
-                (
-                KapcontrollistpluginLogDir,
-                KapcontrollistpluginLogFile,
-                EFileLoggingModeAppend,
-                aFmt,
-                aList
-                );
-            }
-        }
-
-
-    // ---------------------------------------------------------
-    // APControlListPluginLogger::Write()
-    // ---------------------------------------------------------
-    //
-    void APControlListPluginLogger::Write
-    ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC8> aFmt, ... )
-        {
-        if( (aMask & APCONTROL_LIST_LOG_MASK) && (aLevel <= APCONTROL_LIST_LOG_LEVEL) )
-            {
-            VA_LIST list;
-            VA_START( list, aFmt );
-            RFileLogger::WriteFormat
-                (
-                KapcontrollistpluginLogDir,
-                KapcontrollistpluginLogFile,
-                EFileLoggingModeAppend,
-                aFmt,
-                list
-                );
-            VA_END( list );
-            }
-        }
-
-
-    // ---------------------------------------------------------
-    // APControlListPluginLogger::Write()
-    // ---------------------------------------------------------
-    //
-    void APControlListPluginLogger::Write
-    ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC8> aFmt, 
-      VA_LIST& aList )
-        {
-        if( (aMask & APCONTROL_LIST_LOG_MASK) && (aLevel <= APCONTROL_LIST_LOG_LEVEL) )
-            {
-            RFileLogger::WriteFormat
-                (
-                KapcontrollistpluginLogDir,
-                KapcontrollistpluginLogFile,
-                EFileLoggingModeAppend,
-                aFmt,
-                aList
-                );
-            }
-        }
-
-
-    // ---------------------------------------------------------
-    // APControlListPluginLogger::HexDump()
-    // ---------------------------------------------------------
-    //
-    void APControlListPluginLogger::HexDump
-            (
-            TInt32 aMask,
-            TInt aLevel, 
-            const TText* aHeader,
-            const TText* aMargin,
-            const TUint8* aPtr,
-            TInt aLen
-            )
-        {
-        if( (aMask & APCONTROL_LIST_LOG_MASK) && (aLevel <= APCONTROL_LIST_LOG_LEVEL) )
-            {
-            RFileLogger::HexDump
-                (
-                KapcontrollistpluginLogDir,
-                KapcontrollistpluginLogFile,
-                EFileLoggingModeAppend,
-                aHeader,
-                aMargin,
-                aPtr,
-                aLen
-                );
-            }
-        }
-                
-    // ---------------------------------------------------------
-    // APControlListPluginLogger::FCreate()
-    // ---------------------------------------------------------
-    //
-	void APControlListPluginLogger::FCreate()
-	    {
-	    TFileName path(_L("c:\\logs\\"));
-	    path.Append(KapcontrollistpluginLogDir);
-	    path.Append(_L("\\"));
-	    RFs& fs = CEikonEnv::Static()->FsSession();
-	    fs.MkDirAll(path);
-	    }
-#endif // _DEBUG
-
Binary file alwayson_net_plugin/pdpcontextmanager2/conf/pdpcontextmanager2.confml has changed
--- a/alwayson_net_plugin/pdpcontextmanager2/src/10281f41.rss	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/10281f41.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-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"
@@ -15,9 +15,7 @@
 *
 */
 
-
-
-#include <Ecom/RegistryInfo.rh>
+#include <ecom/registryinfo.rh>
 
 RESOURCE REGISTRY_INFO theInfo
 	{
--- a/alwayson_net_plugin/pdpcontextmanager2/src/alwaysonlinepdpplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/alwaysonlinepdpplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -67,7 +67,8 @@
 // ---------------------------------------------------------------------------
 //
 CAlwaysOnlinePDPPlugin::CAlwaysOnlinePDPPlugin():
-    CAlwaysOnlineEComInterface()
+    CAlwaysOnlineEComInterface(),
+    iAlwaysOnServer( NULL )
     {
     }
 
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caoconnection.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caoconnection.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -114,7 +114,8 @@
 // Constructor
 // ---------------------------------------------------------------------------
 //
-CAOConnection::CAOConnection()
+CAOConnection::CAOConnection():
+    iConnectionImpl( NULL )
     {
     LOG_1( _L("CAOConnection::CAOConnection") );
     }
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionmanager.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionmanager.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -208,7 +208,9 @@
                                         MAOConnectionManagerObserver& aObserver,
                                         MAOSettings& aSettings ):
     iObserver( aObserver ),
-    iSettings( aSettings )
+    iSettings( aSettings ),
+    iConnection( NULL ),
+    iConnectionMonitor( NULL ) 
     {
     LOG_1( _L("CAOConnectionManager::CAOConnectionManager") );
     }
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionmonitor.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionmonitor.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -79,9 +79,11 @@
 // Constructor
 // ---------------------------------------------------------------------------
 //
-CAOConnectionMonitor::CAOConnectionMonitor()
+CAOConnectionMonitor::CAOConnectionMonitor():
+    iConnectionMonitorImpl( NULL )
     {
     LOG_1( _L("CAOConnectionMonitor::CAOConnectionMonitor") );
+
     }
 
 // ---------------------------------------------------------------------------
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionmonitorimpl.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionmonitorimpl.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -127,10 +127,16 @@
     MAOConnectionMonitorObserver& aObserver, MAOSettings& aSettings ):
     iObserver( aObserver ),
     iSettings( aSettings ),
+    iTelephony( NULL ),
     iWNRegPckg( iWNReg ),
     iWNRegChangePckg( iWNChangeReg ),
+    iNWRegistrationStatus( NULL ),
+    iNWRegistrationStatusChange( NULL ),
+    iBearer( NULL ), 
+    iMyConnectionId( 0 ),
     iConnectionAlive( EFalse ),
-    iBearerValue( KBearerNotSearched )
+    iBearerValue( KBearerNotSearched ),
+    iCounter( 0 )
     {
     LOG_1( _L("CAOConnectionMonitorImpl::CAOConnectionMonitorImpl") );
     }
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caoraumanager.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caoraumanager.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -80,7 +80,8 @@
 // CAORAUManager::CAORAUManager
 // ---------------------------------------------------------------------------
 //
-CAORAUManager::CAORAUManager()
+CAORAUManager::CAORAUManager():
+    iRAUManagerImpl( NULL )
     {
     LOG_1( _L("CAORAUManager::CAORAUManager") );
     }
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caoserver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caoserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -197,7 +197,20 @@
 // CAOServer::CAOServer
 // ---------------------------------------------------------------------------
 //
-CAOServer::CAOServer()
+CAOServer::CAOServer():
+    iConnectionManager( NULL ),
+    iTimer( NULL ),
+    iRAUManager( NULL ),
+    iSettings( NULL ),
+    iGpds( NULL ),
+    iPointerStatePool( NULL ),
+    iAsyncReactivation( NULL ),
+    iFailure( MAOConnectionManager::EDisconnected ),
+    iActivationFailure( ETrue),
+    iCurrentState( NULL ),
+    iPDPPropertySubscriber( NULL ), 
+    iAsyncSetup( NULL ),
+    iCenRepObserver( NULL )
     {
     LOG_1( _L("CAOServer::CAOServer") );
     }
@@ -950,15 +963,16 @@
         &StateToDesC( CurrentState()->StateName() ) );
     
     if ( aValue != ECmCellularDataUsageDisabled )
-        {
-        TAOState* newState = NULL;
+       {
         	
         if ( CurrentState()->StateName() == TAOState::EStateDisabled )
             {
-            newState = iCurrentState->HandleEnableAlwaysOnL();
+              iCurrentState->HandleEnableAlwaysOnL();
             }
         else
             {
+            TAOState* newState = NULL;
+            
             // Behaviour is the same as if unconnect timer had expired
             iTimer->StopUnconnectTimer();
             newState = iCurrentState->HandleUnconnectTimerExpiredL();
--- a/alwayson_net_plugin/pdpcontextmanager2/src/caotimer.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/caotimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -228,7 +228,12 @@
 //
 CAOTimer::CAOTimer( MAOTimerObserver& aObserver, MAOSettings& aSettings ):
     iObserver( aObserver ),
-    iSettings( aSettings )
+    iSettings( aSettings ),
+    iRetryTimer( NULL ),
+    iRetryTimerCount( 0 ),
+    iCurrentRetryTimerInterval( 0 ), 
+    iConnectionTimer( NULL ),
+    iUnconnectTimer( NULL )
     {
     LOG_1( _L("CAOTimer::CAOTimer") );
     }
--- a/alwayson_net_plugin/pdpcontextmanager2/src/cenrepobserver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/cenrepobserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -65,7 +65,10 @@
 CAOCenRepObserver::CAOCenRepObserver( MAOCenRepObserver& aObserver )
         :
         CActive( CActive::EPriorityStandard ),
-        iObserver( aObserver )
+        iObserver( aObserver ),
+        iRepository( NULL ), 
+        iErrorCounter( 0 )
+                
     {
     }
 
--- a/alwayson_net_plugin/pdpcontextmanager2/src/linger.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/alwayson_net_plugin/pdpcontextmanager2/src/linger.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -46,7 +46,11 @@
     iDlData( 0 ),
     iPckgDlData( iDlData ),
     iUlData( 0 ),
-    iPckgUlData( iUlData )
+    iPckgUlData( iUlData ),
+    iTimer( NULL ), 
+    iLingerInterval( 0 ), 
+    iLingerTimerCount( 0 ),
+    iCurrentTimerInterval( 0 ) 
     {
     }
 
--- a/apengine/apeng/src/APAccessPointItem.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apeng/src/APAccessPointItem.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 #include    <f32file.h>
 #include    <bautils.h>
 #include    <barsc.h>
-#include    <ApEngine.rsg>
+#include    <apengine.rsg>
 #include    "ApAccessPointItem.h"
 #include    "ApEngineConsts.h"
 #include    "ApEngineCommons.h"
--- a/apengine/apeng/src/VpnApItem.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apeng/src/VpnApItem.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,7 +21,7 @@
 #include    <f32file.h>
 #include    <bautils.h>
 #include    <barsc.h>
-#include    <ApEngine.rsg>
+#include    <apengine.rsg>
 #include    <txtetext.h>
 #include    <data_caging_path_literals.hrh>
 
--- a/apengine/apsettingshandlerui/inc/ApSettingsLookups.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/inc/ApSettingsLookups.h	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 
 // INCLUDE FILES
 #include <ApAccessPointItem.h>
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 
 #include <ApSettingsHandlerCommons.h>
 
--- a/apengine/apsettingshandlerui/src/ApNetSelPopupList.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApNetSelPopupList.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,6 @@
 // INCLUDE FILES
 
 #include <ApNetworkItem.h>
-#include <csxhelp/cp.hlp.hrh>
 #include <featmgr.h>
 
 #include "ApSettingsHandlerUI.hrh"
@@ -29,7 +28,7 @@
 #include "ApNetSelPopupList.h"
 #include "ApNetSelectorListBoxModel.h"
 #include "ApSettingsModel.h"
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include "ApsettingshandleruiImpl.h"
 
 
@@ -183,8 +182,6 @@
     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::GetHelpContext")
     
     aContext.iMajor = iHandler->iHelpMajor;
-    // help no longer available for user, use dummy ID
-    aContext.iContext = KSET_HLP_AP_SETTING_GPRS;
     
     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::GetHelpContext")
     }
--- a/apengine/apsettingshandlerui/src/ApSelPopupList.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSelPopupList.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,12 +21,9 @@
 #include "APSettingsHandlerUIVariant.hrh"
 
 #include <ApListItem.h>
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include <featmgr.h>
 
-#include <csxhelp/cp.hlp.hrh>
-
-
 #include "ApSelectorListBoxModel.h"
 #include "ApSettingsModel.h"
 #include "ApSettingsHandlerUI.hrh"
@@ -316,8 +313,6 @@
     APSETUILOGGER_ENTERFN( EListbox,"SelPopupList::GetHelpContext")
     
     aContext.iMajor = iHandler->iHelpMajor;
-    // help no longer available for user, use dummy ID
-    aContext.iContext = KSET_HLP_AP_SETTING_GPRS;
     
     APSETUILOGGER_LEAVEFN( EListbox,"SelPopupList::GetHelpContext")
     }
--- a/apengine/apsettingshandlerui/src/ApSelQueryDialog.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSelQueryDialog.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,7 @@
 #include <AknIconArray.h>
 #include <AknsUtils.h>
 
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include <apsettings.mbg>
 
 #include <featmgr.h>
--- a/apengine/apsettingshandlerui/src/ApSelectorDialog.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSelectorDialog.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -25,12 +25,10 @@
 #include <eikmenup.h>
 
 #include <ApListItem.h>
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 
 #include <featmgr.h>
 
-#include <csxhelp/cp.hlp.hrh>
-
 #include "ApSelectorDialog.h"
 #include "ApSelectorListBoxModel.h"
 #include "ApSelectorListbox.h"
@@ -435,14 +433,12 @@
     APSETUILOGGER_ENTERFN( EDialog,"SelDIalog::GetHelpContext<->")
     
     aContext.iMajor = iHandler->iHelpMajor;
-    // help no longer available for user, use dummy ID
-    aContext.iContext = KSET_HLP_AP_SETTING_GPRS;
     }
 
 
 
 // ---------------------------------------------------------
-// CApSelectorDialog::HandleApDbEventL
+// CApSelectorDialog::HandleApDbEventLw
 // called by the active access point framework
 // ---------------------------------------------------------
 //
--- a/apengine/apsettingshandlerui/src/ApSelectorListBox.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSelectorListBox.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,7 @@
 //#include <EIKON.mbg>
 #include <avkon.mbg>
 #include <aknkeys.h>
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include <featmgr.h>
 
 #include "ApSelectorListbox.h"
--- a/apengine/apsettingshandlerui/src/ApSettingsCommons.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSettingsCommons.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 #include <eikenv.h>
 #include <ApSettingsHandlerCommons.h>
 #include "ApSettingsHandlerUI.hrh"
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include <AknQueryDialog.h>
 #include <aknnotedialog.h>
 #include <StringLoader.h>
--- a/apengine/apsettingshandlerui/src/ApSettingsDlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSettingsDlg.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -41,9 +41,7 @@
 #include "ApSettingsLookups.h"
 #include "ApSettingsDlg.h"
 #include "ApSettingsModel.h"
-#include <ApSetUI.rsg>
-
-#include <csxhelp/cp.hlp.hrh>
+#include <apsetui.rsg>
 
 #include "ApSettingsHandlerUI.hrh"
 #include "ApsettingshandleruiImpl.h"
@@ -775,90 +773,6 @@
     APSETUILOGGER_ENTERFN( ESettings,"Settings::GetHelpContext")
     
     aContext.iMajor = iHandler->iHelpMajor;
-    switch ( iBearerType )
-        {
-        case EApBearerTypeCSD:
-        case EApBearerTypeHSCSD:
-            {
-            switch ( iLevel )
-                {
-                case 2:
-                    {
-                    if ( iL2Ipv4 )
-                        {
-                        aContext.iContext = KSET_HLP_AP_DATA_AS_IPV4;
-                        }
-                    else
-                        {
-                        aContext.iContext = KSET_HLP_AP_DATA_AS_IPV6;
-                        }
-                    break;
-                    }
-                case 1:
-                    {
-                    aContext.iContext = KSET_HLP_AP_SETTING_DATA_AS;
-                    break;
-                    }
-                case 0:
-                default:
-                    {
-                    aContext.iContext = KSET_HLP_AP_SETTING_DATA;
-                    break;
-                    }
-                }
-            break;
-            }
-        case EApBearerTypeGPRS:
-            {
-            if ( iLevel )
-                {
-                aContext.iContext = KSET_HLP_AP_SETTING_GPRS_AS;
-                }
-            else
-                {
-                aContext.iContext = KSET_HLP_AP_SETTING_GPRS;
-                }
-            break;
-            }
-        case EApBearerTypeWLAN: 
-            {
-            switch ( iLevel )
-                {
-                case 2:
-                    {
-                    if ( iL2Ipv4 )
-                        {
-                        aContext.iContext = KSET_HLP_AP_WLAN_AS_IPV4;
-                        }
-                    else
-                        {
-                        aContext.iContext = KSET_HLP_AP_WLAN_AS_IPV6;
-                        }
-                    break;
-                    }
-                case 1:
-                    {
-                    aContext.iContext = KSET_HLP_AP_SETTING_WLAN_AS;
-                    break;
-                    }
-                case 0:
-                    {
-                    aContext.iContext = KSET_HLP_AP_SETTING_WLAN;
-                    break;
-                    }
-                default:
-                    {
-                    break;
-                    }
-                }
-            break;
-            }
-        default:
-            {
-            __ASSERT_DEBUG( EFalse, Panic( EInvalidBearerType ) );
-            break;
-            }
-        }
     
     APSETUILOGGER_LEAVEFN( ESettings,"Settings::GetHelpContext")
     }
--- a/apengine/apsettingshandlerui/src/ApSettingsModel.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/ApSettingsModel.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,7 @@
 #include <ApListItemList.h>
 #include <ApListItem.h>
 #include <ApSelect.h>
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include <VpnApEngine.h>
 #include <hlplch.h>
 #include <eikenv.h>
--- a/apengine/apsettingshandlerui/src/apsettingsdeleteoperation.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/apsettingsdeleteoperation.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -40,7 +40,7 @@
 #include "ApSelectorListBoxModel.h"
 #include "ApSettingsHandlerLogger.h"
 
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 //  TEST ENDS
 
 
--- a/apengine/apsettingshandlerui/src/apsettingshandleruiImpl.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/apengine/apsettingshandlerui/src/apsettingshandleruiImpl.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,7 @@
 
 #include <bautils.h>
 #include <StringLoader.h>
-#include <ApSetUI.rsg>
+#include <apsetui.rsg>
 #include <ActiveApDb.h>
 
 #include "ApsettingshandleruiImpl.h"
--- a/bearermanagement/S60MCPR/inc/s60extendedtmselector.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/inc/s60extendedtmselector.h	Thu Jul 22 16:37:38 2010 +0100
@@ -25,9 +25,6 @@
 
 #include <comms-infras/simpleselectorbase.h>
 
-// Forward declaration
-class ESock::CMetaConnectionProviderBase;
-
 /**
  * TS60ProviderSelectorFactory
  */
--- a/bearermanagement/S60MCPR/inc/s60mcpr.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/inc/s60mcpr.h	Thu Jul 22 16:37:38 2010 +0100
@@ -253,11 +253,11 @@
      * Used to filter out extra notifications because MPM only needs one 
      * started/stopped event. Implement as simple FlipFlop -flag.
      */
-    TBool                   iDataClientStatusStarted : 1;
+    TBool                   iDataClientStatusStarted;
     /**
      * Synchronisation flags, private by design, can be modified only by CMobilityActivity
      */
-    TBool                   iIsHandshakingNow : 1; 
+    TBool                   iIsHandshakingNow; 
     
     /**
      * Connection preference list
--- a/bearermanagement/S60MCPR/inc/s60mpmpolicyinterfaces.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/inc/s60mpmpolicyinterfaces.h	Thu Jul 22 16:37:38 2010 +0100
@@ -65,6 +65,7 @@
     {
     enum TPolicyServerOperations
         {
+        EPolicyRequestInvalid,
         EPolicyRequestChooseBestIAP = EMPMChooseBestIAP,
         EPolicyRequestReselectBestIAP = EMPMReselectBestIAP,
         EPolicyRequestProcessError = EMPMProcessError,
@@ -94,12 +95,14 @@
          * c++ constructor 
          */
         PolicyRequest()
-            :   iConnPref(NULL),
+            :   iRequestType( S60MCPRMPMOperations::EPolicyRequestInvalid ),
+                iConnPref(NULL),
                 iIapId(0),
                 iConnId(0),
                 iAppUid(KNullUid),
                 iError(KErrNone),
                 iPolicyPref(NULL),
+                iNeededAction( EIgnoreError ),
                 iStatus(KErrNone),
                 iUser(NULL)
             {}
--- a/bearermanagement/S60MCPR/inc/s60tiermanagerselector.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/inc/s60tiermanagerselector.h	Thu Jul 22 16:37:38 2010 +0100
@@ -25,9 +25,6 @@
 
 #include <comms-infras/simpleselectorbase.h>
 
-// Forward declaration
-class ESock::CMetaConnectionProviderBase;
-
 /**
  * TS60ProviderSelectorFactory
  */
--- a/bearermanagement/S60MCPR/src/s60extendedtmselector.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/src/s60extendedtmselector.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -56,10 +56,12 @@
 // -----------------------------------------------------------------------------
 //
 CExtendedS60SelectorBase::CExtendedS60SelectorBase(  TUid aTierId, const ESock::RConnPrefList& aConnPrefList )
-    :    ASimpleSelectorBase( )
+    :    ASimpleSelectorBase( ),
+         iDefaultAp( 0 ),
+         iConnPrefList( aConnPrefList ),
+         iTierId( aTierId ),
+         iSubSessionUniqueId( 0 )
     {
-    iTierId = aTierId;
-    iConnPrefList = aConnPrefList;
     }
 
 // -----------------------------------------------------------------------------
--- a/bearermanagement/S60MCPR/src/s60mcprerrorrecoveryactivity.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/src/s60mcprerrorrecoveryactivity.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -174,7 +174,6 @@
     DEFINE_SMELEMENT(TRetryConnectionOrProcessErrorTagBackward, NetStateMachine::MStateFork, TContext)
     TInt TRetryConnectionOrProcessErrorTagBackward::TransitionTag()
         {
-        CS60MetaConnectionProvider& node = (CS60MetaConnectionProvider&)iContext.Node();
         TCFMcpr::TReConnectComplete* msg = NULL;
         if ( iContext.iMessage.IsMessage<TCFMcpr::TReConnectComplete>() )
             {
@@ -185,9 +184,8 @@
             {
             S60MCPRLOGSTRING1("S60MCPR<%x>::TRetryConnectionOrProcessErrorTagBackward::TransitionTag() KProcessError",(TInt*)&iContext.Node());
             return S60MCprStates::KProcessError | NetStateMachine::EBackward;
-            //return KErrorTag | NetStateMachine::EForward;
             }
-        else// if ( node.ServiceProvider()->ProviderInfo().APId() == node.PolicyPrefs().IapId() )
+        else
             {
             S60MCPRLOGSTRING1("S60MCPR<%x>::TRetryConnectionOrProcessErrorTagBackward::TransitionTag() KRetryConnection",(TInt*)&iContext.Node());
             return S60MCprStates::KRetryConnection | NetStateMachine::EForward;
--- a/bearermanagement/S60MCPR/src/s60mcprmobilityactivity.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/src/s60mcprmobilityactivity.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -325,7 +325,11 @@
     //
     CS60MobilityActivity::CS60MobilityActivity( const MeshMachine::TNodeActivity& aActivitySig, 
                                                 MeshMachine::AMMNodeBase& aNode )
-        :   S60MCprStates::CS60ErrorRecoveryActivity( aActivitySig, aNode )
+        :   S60MCprStates::CS60ErrorRecoveryActivity( aActivitySig, aNode ),
+            iCurrentAssumedAPId( 0 ),
+            iPreferredAPId( 0 ),
+            iIsUpgrade( EFalse ),
+            iIsSeamless( EFalse )
         {}
 
 
--- a/bearermanagement/S60MCPR/src/s60mcprstates.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/src/s60mcprstates.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -368,10 +368,10 @@
 
         // Only EIntSetting is supported 
         // 
-        if ( ( TMCprGetConnectionSetting::TConnectionSettingType)msg->iSettingType == 
-               TMCprGetConnectionSetting::EIntSetting
-               && node.PolicyPrefs().ServiceId() != 0 
-               && field.Compare( KIapProxyServiceSetting ) == 0  )
+        if ( msg
+             && msg->iSettingType == TMCprGetConnectionSetting::EIntSetting
+             && node.PolicyPrefs().ServiceId() != 0 
+             && field.Compare( KIapProxyServiceSetting ) == 0  )
             {
             S60MCPRLOGSTRING1("S60MCPR<%x>::TAwaitingServiceIdRequest::Accept() TMCprGetConnectionSetting EIntSetting", 
                 (TInt*)&iContext.Node())
--- a/bearermanagement/S60MCPR/src/s60tiermanagerselector.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/S60MCPR/src/s60tiermanagerselector.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -67,7 +67,9 @@
 // -----------------------------------------------------------------------------
 //
 CSimpleS60SelectorBase::CSimpleS60SelectorBase( const Meta::SMetaData& aSelectionPreferences )
-    :    ASimpleSelectorBase( aSelectionPreferences )
+    :    ASimpleSelectorBase( aSelectionPreferences ),
+         iDefaultAp( 0 ),
+         iSubSessionUniqueId( 0 )
     {
     }
 
--- a/bearermanagement/mpm/bwins/mpmdefaultconnectionu.def	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-EXPORTS
-	?ClearDefaultIAP@RMPMDefaultConnection@@QAEHXZ @ 1 NONAME ; int RMPMDefaultConnection::ClearDefaultIAP(void)
-	?Close@RMPMDefaultConnection@@QAEXXZ @ 2 NONAME ; void RMPMDefaultConnection::Close(void)
-	?Connect@RMPMDefaultConnection@@QAEHXZ @ 3 NONAME ; int RMPMDefaultConnection::Connect(void)
-	?SetDefaultIAP@RMPMDefaultConnection@@QAEHH@Z @ 4 NONAME ; int RMPMDefaultConnection::SetDefaultIAP(int)
-	?Version@RMPMDefaultConnection@@QBE?AVTVersion@@XZ @ 5 NONAME ; class TVersion RMPMDefaultConnection::Version(void) const
-
Binary file bearermanagement/mpm/conf/mpmvpntoggleapi.confml has changed
Binary file bearermanagement/mpm/conf/mpmvpntoggleapi_20016a88.crml has changed
--- a/bearermanagement/mpm/eabi/mpmdefaultconnectionu.def	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-EXPORTS
-	_ZN21RMPMDefaultConnection13SetDefaultIAPEi @ 1 NONAME
-	_ZN21RMPMDefaultConnection15ClearDefaultIAPEv @ 2 NONAME
-	_ZN21RMPMDefaultConnection5CloseEv @ 3 NONAME
-	_ZN21RMPMDefaultConnection7ConnectEv @ 4 NONAME
-	_ZNK21RMPMDefaultConnection7VersionEv @ 5 NONAME
-
--- a/bearermanagement/mpm/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -21,19 +21,19 @@
 DEFAULT
 
 PRJ_EXPORTS
-../inc/rmpm.h                   |../../../inc/rmpm.h
-../inc/rmpm.inl                 |../../../inc/rmpm.inl
-../rom/mpm.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(mpm.iby)
-../rom/mpmdefaultconnection.iby CORE_MW_LAYER_IBY_EXPORT_PATH(mpmdefaultconnection.iby)
-../rom/mpmserver.iby            CORE_MW_LAYER_IBY_EXPORT_PATH(mpmserver.iby)
-../conf/mpm.confml              MW_LAYER_CONFML(mpm.confml)
-../conf/mpm_101f6d12.crml       MW_LAYER_CRML(mpm_101f6d12.crml)
-../conf/mpm_101f6d50.crml       MW_LAYER_CRML(mpm_101f6d50.crml)
+../inc/rmpm.h                           |../../../inc/rmpm.h
+../inc/rmpm.inl                         |../../../inc/rmpm.inl
+../rom/mpm.iby                          CORE_MW_LAYER_IBY_EXPORT_PATH(mpm.iby)
+../rom/mpmserver.iby                    CORE_MW_LAYER_IBY_EXPORT_PATH(mpmserver.iby)
+../conf/mpm.confml                      MW_LAYER_CONFML(mpm.confml)
+../conf/mpm_101f6d12.crml               MW_LAYER_CRML(mpm_101f6d12.crml)
+../conf/mpm_101f6d50.crml               MW_LAYER_CRML(mpm_101f6d50.crml)
+../conf/mpmvpntoggleapi.confml          MW_LAYER_CONFML(mpmvpntoggleapi.confml)
+../conf/mpmvpntoggleapi_20016a88.crml   MW_LAYER_CRML(mpmvpntoggleapi_20016a88.crml)
 
 PRJ_MMPFILES
 mpmclient.mmp
 mpmserver.mmp
-mpmdefaultconnectionclient.mmp
 mpmserver_platsim.mmp // mpmserver-variant for Platsim
 
 PRJ_TESTMMPFILES
--- a/bearermanagement/mpm/group/mpmdefaultconnectionclient.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2004-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MPM server client interface library
-*
-*/
-
-#include <platform_paths.hrh>
-
-TARGET            mpmdefaultconnection.dll
-TARGETTYPE        dll
-
-UID               0x1000008d 0x101F6D33
-
-VENDORID          VID_DEFAULT
-CAPABILITY        CAP_CLIENT_DLL
-
-SOURCEPATH        ../src
-SOURCE            rmpmdefaultconnection.cpp
-
-USERINCLUDE       ../inc
-MW_LAYER_SYSTEMINCLUDE 
-
-LIBRARY           euser.lib
-DEBUGLIBRARY      flogger.lib
--- a/bearermanagement/mpm/group/mpmserver.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/group/mpmserver.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -39,22 +39,17 @@
 SOURCE            mpmserversession.cpp
 SOURCE            mpmserver.cpp
 SOURCE            mpmstarter.cpp
-SOURCE            mpmdisconnectdlg.cpp
 SOURCE            mpmdtmwatcher.cpp
 SOURCE            mpmroamingwatcher.cpp 
 SOURCE            mpmconfirmdlg.cpp
 SOURCE            mpmconfirmdlgstarting.cpp
 SOURCE            mpmconfirmdlgroaming.cpp
-SOURCE            mpmdefaultconnection.cpp
-SOURCE            mpmdefaultconnserver.cpp
-SOURCE            mpmdefaultconnserversession.cpp
 SOURCE            mpmcommsdataccess.cpp
-SOURCE            mpmwlanquerydialog.cpp
 SOURCE            mpmiapselection.cpp
 SOURCE            mpmcsidwatcher.cpp
 SOURCE            mpmdialogbase.cpp
 SOURCE            mpmdatausagewatcher.cpp
-SOURCE            mpmofflinewatcher.cpp
+SOURCE            mpmvpntogglewatcher.cpp
 
 USERINCLUDE       ../inc
 
@@ -65,12 +60,10 @@
 SYSTEMINCLUDE     ../../../inc
 
 LIBRARY           euser.lib
-LIBRARY           agentdialog.lib
 LIBRARY           commdb.lib
 LIBRARY           commsdat.lib
 LIBRARY           esock.lib
 LIBRARY           connmon.lib
-LIBRARY           disconnectdlgclient.lib
 LIBRARY           commonengine.lib
 LIBRARY           featmgr.lib
 LIBRARY           centralrepository.lib
--- a/bearermanagement/mpm/inc/mpmcommsdataccess.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmcommsdataccess.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007-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"
@@ -264,7 +264,14 @@
         */
         TBool IsInternetSnapL( TUint32 aIapId, TUint32 aSnapId );
 
-       /**
+        /**
+         * Returns true if destination is intranet.
+         * @param aSnapId Snap id
+         * @return True or false depending on destination type.
+         */
+         TBool IsIntranetSnapL( TUint32 aSnapId );
+
+        /**
         * Used to get bearer type of the iap.
         *
         * @since 5.0
@@ -358,6 +365,14 @@
         * @return Snap id.
         */
         TUint32 DestinationIdL( CMManager::TSnapPurpose aSnapPurpose );
+        
+        /**
+        * Returns the default connection values
+        * @since symbian^4
+        * @param aType The type of the id
+        * @param aId The id of the snap or the iap
+        */
+        void GetDefaultConnectionL( TCmDefConnType& aType, TUint32& aId );
         	
         /**
         * Finds the real IAP behind the virtual IAP.
--- a/bearermanagement/mpm/inc/mpmconnmonevents.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmconnmonevents.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-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"
@@ -96,8 +96,7 @@
         /**
         * Two-phased constructor.
         */
-        static CMPMConnMonEvents* NewL( CMPMServer& aServer, 
-                                        CMPMServerSession& aSession );
+        static CMPMConnMonEvents* NewL( CMPMServer& aServer );
 
         /**
         * Destructor.
@@ -243,7 +242,7 @@
         * @param aSession Pointer to session
         * @since 3.1
         */
-        void CancelScanL( CMPMServerSession& aSession );
+        void CancelScanL( CMPMServerSession* aSession );
 
         /**
         * Gets the presumed Iap Id of Connection Id.
@@ -319,7 +318,7 @@
         /**
         * 2nd phase constructor.
         */
-        void ConstructL( CMPMServerSession& aSession );
+        void ConstructL();
 
     private: // Data
         // Handle to connection monitor
--- a/bearermanagement/mpm/inc/mpmconnmonreqs.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmconnmonreqs.h	Thu Jul 22 16:37:38 2010 +0100
@@ -46,7 +46,7 @@
         static CMPMConnMonReqs* NewL( CMPMConnMonEvents& aParent,
                                       RConnectionMonitor& aConnMon,
                                       TUint aConnId,
-                                      CMPMServerSession& aSession );
+                                      CMPMServerSession* aSession );
 
         /**
         * Destructor.
@@ -132,7 +132,7 @@
         CMPMConnMonReqs( CMPMConnMonEvents&  aParent,
                          RConnectionMonitor& aConnMon,
                          TUint aConnId, 
-                         CMPMServerSession&  aSession );
+                         CMPMServerSession* aSession );
 
         /**
         * 2nd phase constructor.
@@ -170,9 +170,8 @@
         TConnMonIapInfoBuf iIapBuf;
 
         // MPM server session which requested the service
-        // After service completes callback function is called through 
-        // the reference.
-        CMPMServerSession& iSession;
+        // After service completes callback function is called
+        CMPMServerSession* iSession;
 
         // Used for first session start to wait until necessary data available
         CActiveSchedulerWait iActiveSchedulerWait;        
--- a/bearermanagement/mpm/inc/mpmdefaultconnection.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Handles logic of selecting default connection, 
-*              stores selected default connection when necessary.
-*
-*/
-
-#ifndef C_DEFAULTCONNECTION_H
-#define C_DEFAULTCONNECTION_H
-
-#include <e32base.h>
-#include <cmdefconnvalues.h>
-
-const TCmDefConnType KDefaultMode = ECmDefConnAlwaysAsk;
-const TUint32 KDefaultConnectionId = 0;
-
-class CMPMServer;
-/**
- *  Class handling default connection
- *  The class handles logic of selecting default connection
- *  based on the registered Default connections, user selection 
- *  stored in CommsDat and values queried from user.
- *
- *  The default connection can be queried from the class by 
- *  MPM Server session starting a connection. Following 
- *  example describes the behaviour expected from the session.
- *
- *  @code
- *  TCmDefConnType mode(0);
- *  TUint id(0);
- *  iMyServer.DefaultConnection().GetDefaultConnection( mode, id );
- *  if( mode == ECmDefConnAlwaysAsk )
- *      {
- *      //implicit connection start
- *      }
- *  else if (mode == ECmDefConnAskOnce)
- *      {
- *      if( id == 0 )
- *          {
- *          // Implicit connection start
- *          //
- *          // User selection must be registered by the session 
- *          // with call:
- *          MyServer().DefaultConnection().
- *                 SetAskOnceDefaultConnection( aId );
- *
- *          // When BM connection is added under the MPM server object
- *          // the parameter aUsingAskOnce must be set to ETrue in call
- *          MyServer().CMAppendBMConnection( connId, snap, iapId, 
- *                                           state, ETrue );
- *          }
- *      else  
- *          {
- *          // Explicit connection start using SNAP or IAP from
- *          // parameters.    
- *          //
- *          // When BM connection is added under the MPM server object
- *          // the parameter aUsingAskOnce must be set to ETrue in call
- *          MyServer().CMAppendBMConnection( connId, snap, iapId, 
- *                                           state, ETrue );
- *          }
- *      }
- *      else // snap or iap
- *          {
- *          // Explicit connection start using SNAP or IAP from
- *          //parameters
- *          }
- *      } 
- *  @endcode
- *
- *  @lib mpmserver.exe
- *  @since S60 v3.2
- */
-class CMPMDefaultConnection : public CBase
-    {
-
-public:
-
-    /**
-     * Two-phased constructor.
-     * @param aServer Reference to MPM Server
-     */
-    static CMPMDefaultConnection* NewL( const CMPMServer* aServer );
-    
-
-    /**
-    * Destructor.
-    */
-    virtual ~CMPMDefaultConnection();
-
-    /**
-     * Sets IAP to be used as default connection
-     *
-     * @since S60 v3.2
-     * @param aIapId The IAP to be set as default connection
-     * return KErrNone if succesful, KErrArgument if id was not accepted
-     */
-    TInt SetDefaultIAP( TInt aIapId );
-
-    /**
-     * Clear IAP from being used as default connection,
-     * if one is set
-     *
-     * @since S60 v3.2
-     */
-    void ClearDefaultIAP();
-
-    /**
-     * Get the current default connection value 
-     *
-     * @since S60 v3.2
-     * @param aMode Points to snap or specific iap.
-     * @param aConnection CommsDat elementId of the IAP or SNAP to be used. 
-     * 0 if not defined.
-     *
-     */
-    void GetDefaultConnectionL( TCmDefConnType& aMode, 
-                                TUint32& aConnection );
-    
-private:
-
-    /**
-     * Converts int value to TCmDefaultConnection
-     * Leaves with KErrArgument is value no in the range
-     *
-     * @since S60 v3.2
-     * @param aInt Int value
-     * @return TCmDefConn value
-     */    
-    TCmDefConnType IntToCmDefConnTypeL( const TUint& aInt );
-
-    /**
-     * Reads default connection setting from commsdat.
-     * If no entry is found default values are returned.
-     *
-     * @since S60 v3.2
-     * @param aType Default connection setting type
-     * @param aId Default connection id
-     */    
-    void ReadDefConnSettingL( TCmDefConnType& aType,
-                              TUint32&          aId );
-    /**
-     * C++ default constructor.
-     */
-    CMPMDefaultConnection( const CMPMServer* aServer );
-    
-    /**
-     * 2nd phase constructor.
-     */
-    void ConstructL();
-    
-
-private: // data
-
-    /**
-     * CommsDat element id of IAP registered by Wlan active idle plugin, 
-     * 0 if not defined
-     */
-    TUint32 iDefaultIapId;
-
-    /**
-     * Pointer to the MPM Server object
-     * Not own
-     */
-    const CMPMServer* iServer;
-
-    };
-
-#endif // CMPMDEFAULTCONNECTION
--- a/bearermanagement/mpm/inc/mpmdefaultconnserver.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Server allows registering IAP to be used as default connection
-*
-*/
-
-#ifndef CMPMDEFAULTCONNSERVER_H
-#define CMPMDEFAULTCONNSERVER_H
-
-#include <e32base.h>
-
-#include "mpmserver.h"
-
-class CMPMServer;
-
-/**
- *  Server allows registering IAP to be used as default connection.
- *  Server allows WLAN Active Idle plug-in to register the started 
- *  WLAN IAP as default connection. Only one client is served at the time.
- *
- *
- *  @lib MPMServer.exe
- *  @since S60 v3.2
- */
-class CMPMDefaultConnServer : public CPolicyServer
-    {
-
-public:
-
-    /**
-     * Two-phased constructor.
-     */
-    static CMPMDefaultConnServer* NewL( CMPMServer* aMPMServer );
-
-    /**
-    * Destructor.
-    */
-    virtual ~CMPMDefaultConnServer();
-
-    /**
-     * Creates new session
-     *
-     * @since S60 v3.2
-     * @return MPMServer object
-     */
-    CMPMServer* MPMServer();
-
-// from base class CServer2
-
-
-    /**
-     * From CServer2
-     * Creates new session
-     *
-     * @since S60 v3.2
-     * @param aVersion Version information
-     * @param aMessage Message, not used here
-     */
-    CSession2* NewSessionL( const TVersion& aVersion,
-                            const RMessage2& aMessage) const;
-
-private:
-
-    CMPMDefaultConnServer( CMPMServer* aMPMServer );
-
-    void ConstructL();
-
-
-private: // data
-
-    /**
-     * Reference to MPM Server for storing the default IAP. 
-     * Not own.
-     */
-    CMPMServer* iMPMServer;
-
-    };
-
-#endif // CMPMDEFAULTCONNSERVER_H
--- a/bearermanagement/mpm/inc/mpmdefaultconnserversession.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Session to MPM Default Connection server
-*
-*/
-
-#ifndef CMPMDEFAULTCONNSERVERSESSION_H
-#define CMPMDEFAULTCONNSERVERSESSION_H
-
-#include <e32base.h>
-#include "mpmdefaultconnserver.h"
-
-
-/**
- *  Session to MPM Default Connection server
- *
- *  @lib MPMServer.exe
- *  @since S60 v3.2
- */
-class CMPMDefaultConnServerSession : public CSession2
-    {
-
-public:
-
-    /**
-     * Two-phased constructor.
-     */
-    static CMPMDefaultConnServerSession* NewL( CMPMDefaultConnServer* aServer );
-    
-
-    /**
-    * Destructor.
-    */
-    virtual ~CMPMDefaultConnServerSession();
-
-   /**
-     * Returns the default connection server object
-     *
-     * @since S60 v3.2
-     * @return Default Connection server pointer
-     */
-     CMPMDefaultConnServer* DefaultConnServer();
-
-
-// from base class CSession2
-
-      /**
-       * From CSession2.
-       * Serves client request
-       *
-       * @since S60 v3.2
-       * @param aMessage Message from client
-       */
-       void ServiceL( const RMessage2& aMessage );
-
-
-private:
-
-    CMPMDefaultConnServerSession( CMPMDefaultConnServer* aServer );
-
-    void ConstructL();
-    
-    /**
-     * Store IAP to be used as default connection in MPM Server
-     *
-     * @since S60 v3.2
-     * @param aMessage Client message containing the IAP
-     */
-    void SetDefaultIAP( const RMessage2& aMessage );
-
-    /**
-     * Clear IAP from being used as default connection in MPM Server
-     *
-     * @since S60 v3.2
-     */
-    void ClearDefaultIAP( const RMessage2& aMessage );
-
-
-private: // data
-
-    
-    /**
-     * Poiter to DefaultConnServer object. Not own
-     */
-    CMPMDefaultConnServer* iDefaultConnServer;
-
-    };
-
-#endif // CMPMDEFAULTCONNSERVERSESSION_H
--- a/bearermanagement/mpm/inc/mpmdisconnectdlg.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MPM class used for disconnect dialog initiation
-*
-*/
-
-/**
-@file mpmdisconnectdlg.h
-Mobility Policy Manager disconnect dialog initiation class.
-*/
-
-#ifndef MPMDISCONNECTDLG_H
-#define MPMDISCONNECTDLG_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <DisconnectDlgClient.h>
-#include "mpmserversession.h"
-#include "mpmdialogbase.h"
-
-// CLASS DECLARATION
-/**
-*  MPM disconnect dialog initiation class definition.
-*
-*  @lib MPMServer.exe
-*  @since 3.1
-*/
-class CMPMDisconnectDlg : protected CMPMDialogBase
-    {
-    public:    // Constructors and destructor
-        /**
-        * Two-phased constructor.
-        */
-        static CMPMDisconnectDlg* NewL(
-		    CMPMServerSession&                aSession,
-            TInt                              aOrigError,
-            CArrayPtrFlat<CMPMDisconnectDlg>& aDisconnectQueue );
-
-        /**
-        * Destructor.
-        */
-        virtual ~CMPMDisconnectDlg();
-
-    protected: // New functions
-
-        /**
-         * Start Dlg.
-         * @param aDlg previous same type of dlg in case its response could
-		 *             be utilized.
-         */
-        virtual void Start( CMPMDialogBase* aDlg );
-
-        /**
-        * User selected Ok in Disconnect Dialog.
-        * @since 3.2
-        * @param aError Error code from dialog
-        * @param aIapId Id of the Iap from terminated connection
-        */
-        void UserSelectedOk( TInt aError );
-
-        /**
-        * User selected Cancel in Disconnect Dialog.
-        * @since 3.2
-        * @param aError Error code from dialog
-        */
-        void UserSelectedCancel( TInt aError );
-
-    protected: // Functions from base classes
-
-        /**
-        * From CActive. Cancels UI dialog.
-        * @since 3.1
-        */        
-        void DoCancel();
-
-        /**
-        * From CActive. Run when UI dialog finished.
-        * @since 3.1
-        */               
-        void RunL();
-
-        /**
-        * From CActive. Run if RunL leaves.
-        * @since 3.1
-        * @param aError Error that caused leave.
-        * @return KErrNone
-        */
-        TInt RunError (TInt aError);
-
-    private: // New methods
-
-        /**
-        * C++ default constructor.
-        */
-        CMPMDisconnectDlg(
-		    CMPMServerSession&                aSession,
-            TInt                              aOrigError,
-            CArrayPtrFlat<CMPMDisconnectDlg>& aDisconnectQueue );
-
-        /**
-        * 2nd phase constructor.
-        */
-        void ConstructL();
-    protected:
-        TInt        iUserStatus;
-        TInt        iUserIap;
-        
-    private: // Data
-        // Disconnect Dialog Server
-        RDisconnectDlgServer        iDlgServ;
-
-        // Session object reference
-        CMPMServerSession&          iSession;
-
-        // IAP of the closed connection
-        TUint32                     iIapId;
-
-        // Original error code reported by Bearer Manager
-        TInt                        iOrigError;
-    };
-
-
-#endif // MPMDISCONNECTDLG_H
-
-// End of file
--- a/bearermanagement/mpm/inc/mpmiapselection.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmiapselection.h	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,6 @@
 #include "mpmserversession.h"
 #include "mpmcommsdataccess.h"
 
-class CMPMWlanQueryDialog;
 class CMPMConfirmDlgStarting;
 class TMpmConnPref;
 
@@ -91,16 +90,13 @@
 
 public:
     /**
-     * Starts Wlan query if Iap is wlan iap.
+     * Returns true if given iap is a wlan iap.
      *
      * @param aIapId Id of Iap
-     * @param aIsRoaming True if wlan query is for roaming
-     * @return ETrue if wlan query was started
-     * @since S60 v3.2
+     * @return ETrue if iap aIap is wlan
+     * @since symbian^4
      */
-    TBool StartWlanQueryIfNeededL(
-        TUint32 aIapId,
-        TBool aIsRoaming = EFalse );
+    TBool IsIapWlanL( TUint32 aIapId );
 
     /**
      * Part of selecting best IAP at connection start. Called when WLAN scan
@@ -123,18 +119,6 @@
     void ChooseIapComplete( TInt aError, const TMpmConnPref* aPolicyPref );
 
     /**
-     * Callback function used after Wlan network has been selected. 
-     * Uses HandleUserIapSelectionL to complete IAP selection.
-     *
-     * @since 3.2
-     * @param aError Error code from selection
-     * @param aIapId Element id of IAP record if different than reported before. 
-     * May be 0, when error occurred in selection or when no new Iap id is set.
-     *
-     */
-    void UserWlanSelectionDoneL( TInt aError, TUint32 aIapId );
-
-    /**
      * Stops displaying the starting dialog.
      *
      * @since 3.2
@@ -305,9 +289,6 @@
     // Pointer to Confirmation dialog.
     CMPMConfirmDlgStarting* iConfirmDlgStarting;
 
-    // Pointer to Wlan query dialog.
-    CMPMWlanQueryDialog* iWlanDialog;
-
     // Stores the boolean value whether next best iaps 
     // exists in explicit connection start.
     TBool iNextBestExists;
--- a/bearermanagement/mpm/inc/mpmofflinewatcher.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
-* Copyright (c) 2008-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Listens for offline mode changes in central repository.
-*
-*/
-
-#ifndef MPMOFFLINEWATCHER_H
-#define MPMOFFLINEWATCHER_H
-
-//  INCLUDES
-#include <e32base.h>
-
-class CRepository;
-class CMPMServer;
-
-// Stop after this many consecutive central repository errors.
-const TInt KMpmOfflineWatcherCenRepErrorThreshold = 80;
-
-/**
- *  Class for accessing central repository.
- *  Follows KCoreAppUIsNetworkConnectionAllowed key in central repository.
- *  @since 5.2
- */
-class CMpmOfflineWatcher : public CActive
-    {
-
-public:
-
-    /**
-    * New for calling the two-phased constructor.
-    */
-    static CMpmOfflineWatcher* NewL( CMPMServer* aServer );
-
-    /**
-    * Destructor.
-    */
-    virtual ~CMpmOfflineWatcher();
-
-    /**
-     * Start to listen for events.
-     */
-    void StartL();
-    
-    /**
-    * Active object's RunL.
-    */
-    void RunL();
-
-    /**
-    * Active object's DoCancel.
-    */
-    void DoCancel();
-
-private:
-
-    /**
-    * C++ default constructor.
-    */
-    CMpmOfflineWatcher( CMPMServer* aServer );
-
-    /**
-    * Symbian 2nd phase constructor.
-    */
-    void ConstructL();
-    
-    /**
-    * Request for notifications.
-    */
-    TInt RequestNotifications();
-    
-    /**
-    * Get current offline mode value.
-    */
-    TInt GetCurrentOfflineValue();
-
-
-private: // data
-
-    /**
-     * Is offline feature supported.
-     */
-    TBool iOfflineFeatureSupported;
-
-    /**
-     * Central repository handle.
-     * Own.
-     */
-    CRepository* iRepository;
-
-    /**
-     * Offline mode activity value.
-     */
-    TInt iOfflineMode;     // type: TCoreAppUIsNetworkConnectionAllowed
-
-    /**
-     * Pointer to the MPM Server object.
-     * Not own.
-     */
-    CMPMServer* iServer;
-
-    /**
-     * Error counter.
-     */
-    TUint iErrorCounter;
-
-    };
-
-#endif // MPMOFFLINEWATCHER_H
--- a/bearermanagement/mpm/inc/mpmserver.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmserver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -34,12 +34,13 @@
 #include "mpmcommon.h"
 #include "rmpm.h"
 #include "mpmroamingwatcher.h"
+#include "mpmvpntogglewatcher.h"
 
 
 class CMPMCommsDatAccess;
 class CMpmCsIdWatcher;
 class CMpmDataUsageWatcher;
-class CMpmOfflineWatcher;
+class CMpmVpnToggleWatcher;
 
 // CONSTANTS
 _LIT( KMPMPanicCategory, "Mobility Policy Manager Server" );
@@ -49,15 +50,18 @@
 //
 const TInt    KPhoneRetryTimeout = 100000;
 
-// The granularity with which iDisconnectQueue will allocate memory chunks. 
-// If set to two there will be space for two instances of CMPMDisconnectDlg
-// before new memory will be allocated.
+// The granularity with which roaming and starting dialogs will allocate memory chunks. 
+// If set to two there will be space for two instances before new memory will be allocated.
 const TInt    KGranularity       = 2;
 
 // Security policy definitions
 
 //Total number of ranges
 const TUint KMPMPolicyRangeCount = 2;
+
+// roaming to connected wlan wait interval
+// in micro seconds (10 sec)
+const TInt KRoamingToWlanUpdateInterval = 10000000; 
  
 //Definition of the ranges of IPC numbers
 const TInt KMPMPolicyRanges[KMPMPolicyRangeCount] = 
@@ -183,11 +187,9 @@
 class CMPMConnMonEvents;
 class CMPMServerSession;
 class CMPMDtmWatcher;
-class CMPMDisconnectDlg;
 class CMPMConfirmDlgRoaming;
 class CMPMConfirmDlgStarting;
 class CMPMDefaultConnection;
-class CMPMWlanQueryDialog;
 
 // CLASS DECLARATION
 /**
@@ -264,7 +266,8 @@
 *  @lib MPMServer.exe
 *  @since 3.0
 */
-class CMPMServer : public CPolicyServer
+class CMPMServer : public CPolicyServer,
+                   public MMpmVpnToggleWatcherNotify
     {
     public: // Constructors and destructor
 
@@ -585,13 +588,6 @@
         inline TBool IsWLANScanRequired() const;
 
         /**
-        * Get the DisconnectQueue.
-        * @since 3.2
-        * @return Pointer to the DisconnectQueue.
-        */
-        inline CArrayPtrFlat<CMPMDisconnectDlg>* DisconnectQueue();
-
-        /**
         * Get the RoamingQueue.
         * @since 3.2
         * @return Pointer to the RoamingQueue.
@@ -606,40 +602,6 @@
         inline CArrayPtrFlat<CMPMConfirmDlgStarting>* StartingQueue();
 
         /**
-        * Appends aDlg to the iWlanQueryQueue.
-        * @since 3.2
-        * @param aDlg Pointer to the CMPMConfirmDlgWlanQuery object.
-        */
-        void AppendWlanQueryQueueL( CMPMWlanQueryDialog* aDlg );
-
-        /**
-        * Removes the first item from the iWlanQueryQueue.
-        * @since 3.2
-        */
-        inline void RemoveFromWlanQueryQueue( CMPMWlanQueryDialog* aDlg );
-
-        /**
-        * Get the WlanQueryQueue.
-        * @since 3.2
-        * @return Pointer to the WlanQueryQueue.
-        */
-        inline CArrayPtrFlat<CMPMWlanQueryDialog>* WlanQueryQueue();
-
-        /**
-        * Get the first item in iWlanQueryQueue.
-        * @since 3.2
-        * @return Pointer to the first item in iWlanQueryQueue.
-        */
-        inline CMPMWlanQueryDialog* FirstInWlanQueryQueue();
-
-        /**
-        * Get the Default Connection object.
-        * @since 3.2
-        * @return Pointer to the Default Connection object.
-        */
-        CMPMDefaultConnection* DefaultConnection(); 
-
-        /**
         * Returns true if there is a started connection
         * 
         * @since 3.2
@@ -699,6 +661,14 @@
         void StartForcedRoamingToWlanL( const TConnMonIapInfo& aIapInfo );
         
         /**
+        * Starts forced roaming sequence to connected wlan
+        *
+        * @param aIapInfo Info about available IAPs
+        * @since 5.2
+        */
+        static TInt StartForcedRoamingToConnectedWlanL( TAny* aUpdater );
+        
+        /**
         * Starts forced roaming sequence from WLAN if necessary
         *
         * @param aIapInfo Info about available IAPs
@@ -725,6 +695,20 @@
     public: // Functions from base classes
 
         /**
+         * From MMpmVpnToggleWatcherNotify. Sets values for VPN toggle after
+         * VPN toggle key changes in central repository.
+         * @param aVpnPreferred Informs if VPN connection is preferred
+         *                      connection
+         * @param aVpnIapId VPN IAP Id, which is used for VPN connection, when
+         *                  VPN connection is preferred                           
+         * @param aSnapId SNAP Id SNAP Id, which is used for VPN connection,
+         *                when VPN connection is preferred
+         */
+         void SetVpnToggleValuesL( const TBool aVpnPreferred,
+                                   const TUint32 aVpnIapId,
+                                   const TUint32 aSnapId );
+
+        /**
         * From CServer2. Creates a new session for a client.
         * @since 3.0
         * @param aVersion Version information
@@ -736,7 +720,7 @@
 
         // Stops connection of certain IAP, zero for all connections
         void StopConnections( TInt aIapId = 0 );
-
+                
     public:
 
         /**
@@ -778,6 +762,34 @@
          * @return ETrue if user connection is in internet snap
          */
         TBool UserConnectionInInternet() const;
+
+        /**
+         * Mark that there is an active VPN user connection.
+         */
+        void AddVpnUserConnectionSession();
+        
+        /**
+         * Mark that VPN user connection is not active
+         */
+        void RemoveVpnUserConnectionSession();
+        
+        /**
+         * Informs if VPN user connection is used with given MPM preferences
+         * and application.
+         * @param aMpmConnPref MPM connection preferences.
+         * @param aAppUid Application UID
+         * @return Informs if VPN connection is preferred
+         */        
+        TBool UseVpnUserConnection( const TMpmConnPref aMpmConnPref,
+                                    const TUint32 aAppUid ) const;
+        
+        /**
+         * Prepares VPN user connection.
+         * @param aMpmConnPref Connection preferences, which are modified
+         *                     for VPN user connection (returned)
+         * @return Informs if preparation was successful.                                         
+         */
+        TBool PrepareVpnUserConnection( TMpmConnPref& aMpmConnPref );
                 
         /**
          * Handle to central repository watcher
@@ -787,6 +799,12 @@
         inline CMpmCsIdWatcher* CsIdWatcher();
 
         /**
+         * Handle to VPN toggle central repository watcher
+         * @return Pointer to watcher object.
+         */
+        inline CMpmVpnToggleWatcher* VpnToggleWatcher();
+
+        /**
         * Returns server session instance that corresponds to given
         * connection id.
         * @since 5.2
@@ -903,21 +921,12 @@
         // Is WLAN scan required or not before displaying Connection Dialog
         TBool iWLANScanRequired;
 
-        // Solves problem with overlapping Disconnect Dialogs
-        CArrayPtrFlat<CMPMDisconnectDlg>* iDisconnectQueue;
-
         // Solves problem with overlapping Roaming Dialogs
         CArrayPtrFlat<CMPMConfirmDlgRoaming>* iRoamingQueue;
 
         // Solves problem with overlapping Starting Dialogs
         CArrayPtrFlat<CMPMConfirmDlgStarting>* iStartingQueue;
 
-        // Solves problem with overlapping Wlan Queries
-        CArrayPtrFlat<CMPMWlanQueryDialog>* iWlanQueryQueue;
-        
-        // Handles Default Connection selection
-        CMPMDefaultConnection* iDefaultConnection;
-
         // Keeps track of the number of connections
         TUint iConnectionCounter;
 
@@ -930,6 +939,10 @@
         // Set when user connection in internet snap
         TBool iUserConnectionInInternet;
         
+        // Count of sessions using VPN user connection
+        //
+        TInt iVpnUserConnectionSessionCount;        
+        
         /**
          * Handle to central repository watcher
          * Own.
@@ -937,14 +950,15 @@
         CMpmCsIdWatcher* iMpmCsIdWatcher;
 
         /**
-         * Handle to central repository watcher
+         * Handle to VPN toggle central repository watcher.
+         * Own.
          */
-        CMpmDataUsageWatcher* iMpmDataUsageWatcher;
+        CMpmVpnToggleWatcher* iMpmVpnToggleWatcher;
 
         /**
          * Handle to central repository watcher
          */
-        CMpmOfflineWatcher* iMpmOfflineWatcher;
+        CMpmDataUsageWatcher* iMpmDataUsageWatcher;
 
         // Dedicated clients
         RArray<TUint32> iDedicatedClients;
@@ -961,6 +975,12 @@
         
         // Is WLAN usage already accepted in this offline session.
         TOfflineWlanQueryResponse iOfflineWlanQueryResponse;
+        
+        // Timer to start roaming to connected WLAN network 
+        CPeriodic* iRoamingToWlanPeriodic;
+
+        // TConnMonIapInfo Info about available IAPs
+        TConnMonIapInfo iConnMonIapInfo;
     };
 
 #include "mpmserver.inl"
--- a/bearermanagement/mpm/inc/mpmserver.inl	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmserver.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007-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"
@@ -72,15 +72,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// CMPMServer::DisconnectQueue
-// -----------------------------------------------------------------------------
-//
-inline CArrayPtrFlat<CMPMDisconnectDlg>* CMPMServer::DisconnectQueue()
-    {
-    return iDisconnectQueue;
-    }
-
-// -----------------------------------------------------------------------------
 // CMPMServer::RoamingQueue
 // -----------------------------------------------------------------------------
 //
@@ -99,43 +90,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// CMPMServer::RemoveFromWlanQueryQueue
-// -----------------------------------------------------------------------------
-//
-inline void CMPMServer::RemoveFromWlanQueryQueue( CMPMWlanQueryDialog* aDlg )
-    {
-    for ( TInt i = 0; i < iWlanQueryQueue->Count(); i++ )
-        {
-        if ( iWlanQueryQueue->At( i ) == aDlg )
-            {
-            iWlanQueryQueue->Delete( i );
-            break;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CMPMServer::WlanQueryQueue
-// -----------------------------------------------------------------------------
-//
-inline CArrayPtrFlat<CMPMWlanQueryDialog>* CMPMServer::WlanQueryQueue()
-    {
-    return iWlanQueryQueue;
-    }
-
-// -----------------------------------------------------------------------------
-// CMPMServer::FirstInWlanQueryQueue
-// -----------------------------------------------------------------------------
-//
-inline CMPMWlanQueryDialog* CMPMServer::FirstInWlanQueryQueue()
-    {
-    if ( iWlanQueryQueue->Count() == 0 )
-        return NULL;
-    else
-        return iWlanQueryQueue->At( 0 );
-    }
-
-// -----------------------------------------------------------------------------
 // CMPMServer::IncrementConnections
 // -----------------------------------------------------------------------------
 //
@@ -232,6 +186,15 @@
     }
 
 // -----------------------------------------------------------------------------
+// CMPMServer::VpnToggleWatcher
+// -----------------------------------------------------------------------------
+//
+inline CMpmVpnToggleWatcher* CMPMServer::VpnToggleWatcher()
+    {
+    return iMpmVpnToggleWatcher;
+    }
+
+// -----------------------------------------------------------------------------
 // CMPMServer::DedicatedClients
 // -----------------------------------------------------------------------------
 //
--- a/bearermanagement/mpm/inc/mpmserversession.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmserversession.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -53,7 +53,6 @@
 _LIT( KIapProxyServiceSetting, "IAP\\IAPService" );
 
 // FORWARD DECLARATIONS
-class CMPMDisconnectDlg;
 class CMPMConfirmDlgRoaming;
 class CMPMCommsDatAccess;
 class CMPMIapSelection;
@@ -414,6 +413,18 @@
         TBool UseUserConnPref();
         
         /**
+         * Returns VPN user connection usage status.
+         * @return ETrue if VPN user connection is used in this session.
+         */
+        inline TBool VpnUserConnectionUsed() const;
+
+        /**
+         * Sets VPN user connection usage status.
+         * @param aEnabled Informs if VPN user connection is used.
+         */
+        void SetVpnUserConnectionUsed( const TBool aEnabled );
+        
+        /**
         * Returns id of the client.
         *
         * @since 5.0
@@ -592,7 +603,7 @@
         * @param aMessage message from client
         */
         void HandleServerProcessErrorL(const RMessage2& aMessage);
-
+        
         /**
         * Handling of prefered IAP notification registration.
         * @since 3.1
@@ -822,7 +833,7 @@
         * @param aUid Application Uid
         */
         TBool IsBackgroundApplication( TUint32 aUid ) const;
-
+        
         /**
         * Checks if disconnect dialog should be displayed for this error
         * @since 3.2
@@ -874,9 +885,6 @@
         // Server class reference
         CMPMServer& iMyServer;
 
-        // Pointer to the disconnect dialog active object
-        CMPMDisconnectDlg* iDisconnectDlg;
-
         // Pointer to the roaming confirmation dialog active object
         CMPMConfirmDlgRoaming* iConfirmDlgRoaming;
 
@@ -930,26 +938,26 @@
         //    
         CMPMIapSelection* iIapSelection;
 
-				// Stored state of migrating to carrier
-				// 
-				TMigrateToCarrierState iMigrateState;
+        // Stored state of migrating to carrier
+        // 
+        TMigrateToCarrierState iMigrateState;
 
-				// Last Iap notified using PreferredIap-notification
-				//
-				TUint32 iLastNotifiedIap;
-		
-		    // Iap to which connection is migrating
+        // Last Iap notified using PreferredIap-notification
+        //
+        TUint32 iLastNotifiedIap;
+    
+        // Iap to which connection is migrating
         //
         TUint32 iMigrateIap;
 
         // Set when this session is user connection
-		    //
+        //
         TBool iUserConnection;
-        
-        // Set when disconnect dialog is shown to avoid 
-        // showing duplicate cellulara data usage dialog
+
+        // Set when this session uses VPN user connection
         //
-        TBool iDisconnectDialogShown;
+        TBool iVpnUserConnectionUsed;        
+
     };
 
 #include "mpmserversession.inl"
--- a/bearermanagement/mpm/inc/mpmserversession.inl	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmserversession.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007-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"
@@ -16,15 +16,6 @@
 */
 
 // -----------------------------------------------------------------------------
-// CMPMServerSession::SetDisconnectDlgPtrNull
-// -----------------------------------------------------------------------------
-//
-inline void CMPMServerSession::SetDisconnectDlgPtrNull()
-    {
-    iDisconnectDlg = NULL;
-    }
-
-// -----------------------------------------------------------------------------
 // CMPMServerSession::SetConfirmDlgRoamingPtrNull
 // -----------------------------------------------------------------------------
 //
@@ -89,6 +80,15 @@
     }
 
 // -----------------------------------------------------------------------------
+// CMPMServerSession::VpnUserConnectionUsed
+// -----------------------------------------------------------------------------
+//
+inline TBool CMPMServerSession::VpnUserConnectionUsed() const
+    {
+    return iVpnUserConnectionUsed;
+    }
+
+// -----------------------------------------------------------------------------
 // CMPMServerSession::AppUid
 // -----------------------------------------------------------------------------
 //
--- a/bearermanagement/mpm/inc/mpmstarter.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/mpmstarter.h	Thu Jul 22 16:37:38 2010 +0100
@@ -44,13 +44,6 @@
         static CServer2* CreateAndStartServerL();
 
         /**
-        * Creates and starts server Default connection server.
-        * @since 3.2
-        * @return Pointer to the server object.
-        */
-        static CServer2* CreateDefaultConnServerL( CMPMServer* aMPMServer );
-
-        /**
         * Gets server name.
         * @since 3.0
         * @return Descriptor of the server name.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/inc/mpmvpntogglewatcher.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Listen VPN toggle key changes in central repository.
+*
+*/
+
+#ifndef MPMVPNTOGGLEWATCHER_H
+#define MPMVPNTOGGLEWATCHER_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CRepository;
+
+// Stop after this many consecutive central repository errors.
+const TInt KMpmVpnToggleWatcherCenRepErrorThreshold = 80;
+
+/**
+* Class that specifies the functions for handling notify messages about
+* VPN toggle key changes in central repository.
+*/
+class MMpmVpnToggleWatcherNotify
+{
+public:
+    
+    /**
+     * Sets values for VPN toggle after VPN toggle key changes in central
+     * repository.
+     * @param aVpnPreferred Informs if VPN connection is preferred
+     *                      connection
+     * @param aVpnIapId VPN IAP Id, which is used for VPN connection, when
+     *                  VPN connection is preferred                           
+     * @param aSnapId SNAP Id SNAP Id, which is used for VPN connection,
+     *                when VPN connection is preferred
+     */
+     virtual void SetVpnToggleValuesL( const TBool aVpnPreferred,
+                                       const TUint32 aVpnIapId,
+                                       const TUint32 aSnapId ) = 0;
+};
+
+
+/**
+ *  Class for monitoring VPN toggle key changes in central repository.
+ *  Follows KMpmVpnToggleCenRepUid key in central repository.
+ */
+class CMpmVpnToggleWatcher : public CActive
+    {
+public:
+
+    /**
+    * Two-phased constructor.
+    * @param aNotify Handler for notify messages.
+    */    
+    static CMpmVpnToggleWatcher* NewL( MMpmVpnToggleWatcherNotify& aNotify );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CMpmVpnToggleWatcher();
+    
+    /**
+     * Call this when you want to start listen event.
+     */
+    void StartL();    
+        
+    /**
+     * Informs if VPN connection is preferred.
+     * @return True if VPN connection is preferred.
+     */
+    TBool IsVpnConnectionPreferred() const;
+    
+    /**
+     * Returns VPN IAP Id, which is used for VPN connection, when VPN
+     * connection is preferred.
+     * @return VPN IAP Id
+     */
+    TUint32 VpnIapId() const;
+    
+    /**
+     * Returns SNAP Id, which is used for VPN connection, when VPN
+     * connection is preferred.
+     * @return SNAP Id
+     */
+    TUint32 SnapId() const;    
+    
+    /**
+     * Resets VPN toggle values.
+     */    
+    void ResetVpnToggleValues();
+    
+private:
+
+    CMpmVpnToggleWatcher( MMpmVpnToggleWatcherNotify& aNotify );
+
+    void ConstructL();
+    
+    /**
+     * Request for notifications.
+     * @return Error value
+     */
+    TInt RequestNotifications();
+    
+    /**
+     * Gets VPN toggle values.
+     * @return Error value
+     */
+    TInt GetVpnToggleValues();
+
+// from base class CActive
+
+    void RunL();
+
+    void DoCancel();
+    
+private: // data
+    
+    /**
+     * Central repository handle
+     * Own.
+     */
+    CRepository* iRepository;    
+    
+    /**
+     * Informs if VPN connection is preferred connection
+     * Own.
+     */
+    TBool iVpnConnectionPreferred;
+    
+    /**
+     * VPN IAP Id which is used, when VPN connection is preferred
+     * Own.
+     */
+    TUint32 iVpnIapId;
+    
+    /**
+     * SNAP Id which is used, when VPN connection is preferred
+     * Own.
+     */
+    TUint32 iSnapId;
+    
+    /**
+     * Error counter.
+     */
+    TUint iErrorCounter;
+
+    /**
+     * Handler for notify messages.
+     * Not own.
+     */
+    MMpmVpnToggleWatcherNotify& iNotify;
+    
+    };
+
+#endif // MPMVPNTOGGLEWATCHER_H
--- a/bearermanagement/mpm/inc/mpmwlanquerydialog.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
-* Copyright (c) 2008-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Handles displaying wlan related dialogs
-*
-*/
-
-
-#ifndef MPMWLANQUERYDIALOG_H
-#define MPMWLANQUERYDIALOG_H
-
-#include <e32std.h>
-#include <wdbifwlansettings.h> //for struct
-#include <ConnectionUiUtilities.h>
-
-#include "mpmcommsdataccess.h"
-
-// ID of OfflineWlanNote dialog
-const TUid KUidCOfflineWlanNoteDlg = { 0x101FD671 };
-
-/**
- * This structure is copied from ConnectionUiUtilitiesCommon.h,
- * but given here a different name.
- * Defines preferences of the Wlan Network
- */
-class TMpmWlanNetworkPrefs
-    {
-public:
-    TWlanSsid                           iSsId;        ///< Ssid of Wlan network
-    TWlanConnectionMode                 iNetworkMode; ///< mode of Wlan network
-    TWlanConnectionSecurityMode         iSecMode;     ///< Security mode of Wlan network
-    TBool                               iProtectedSetupSupported; 
-                                        ///< Wlan network supports Protected Setup
-    };
-
-class CMPMIapSelection;
-
-/**
- *  Handles displaying wlan related dialogs
- *
- *  @lib mpmserver.exe
- *  @since S60 v3.2
- */
-class CMPMWlanQueryDialog : public CActive
-    {
-
-enum TWlanQueryState
-    {
-    EOffline
-    };
-
-public:
-
-    static CMPMWlanQueryDialog* NewL( CMPMIapSelection&  aSession,
-                                      TUint32            aSelectedWlanIap );
-
-    /**
-    * Destructor.
-    */
-    virtual ~CMPMWlanQueryDialog();
-
-public: // Functions from base classes
-
-        /**
-        * From CActive. Cancels UI dialogs.
-        * @since 3.2
-        */        
-        void DoCancel();
-        
-        /**
-        * From CActive. Run when UI dialog finished.
-        * @since 3.2
-        */               
-        void RunL();
-        
-        /**
-        * From CActive. Run if RunL leaves.
-        * @since 3.2
-        * @param aError Error that caused leave.
-        * @return KErrNone
-        */
-        TInt RunError( TInt aError );
-
-public:
-
-        /**
-        * Starts displaying wlan dialogs if necessary
-        * @since 3.2
-        */
-        void StartWlanQueryL();
-
-private:
-
-        /**
-         * Propagates wlan network selection as an initial value for the dialog,
-         * Used if there are several dialogs queued.
-         *
-         * @param aDialogStatus  Status of the dialog when destroyed.
-         * @since 3.2
-         */
-        void OfferInformation( TInt aDialogStatus );
-
-        CMPMWlanQueryDialog( CMPMIapSelection&  aIapSelection,
-                             TUint32            aSelectedWlanIap );
-
-        void ConstructL();
-
-private: // data
-
-        // Reference to iap selection object
-        CMPMIapSelection& iIapSelection;
-
-        // Stores data for offline note
-        TPckgBuf<TBool> iOfflineReply;
-        
-        // Stores data for wlan network guery
-        TPckgBuf<TMpmWlanNetworkPrefs> iNetworkPrefs;
-        
-        //Interfce to Notifier
-        RNotifier iNotifier;
-
-        //State of querying Wlan settings
-        TWlanQueryState iWlanQueryState;
-            
-        // Connection Ui Utilities pointer
-        CConnectionUiUtilities* iConnUiUtils;
-        
-        // Wlan iap
-        TUint32 iWlanIapId;
-        
-        // Flag that can be used to cancel the dialog startup based on earlier dialog
-        TInt iOverrideStatus;
-    };
-
-#endif // MPMWLANQUERYDIALOG_H
--- a/bearermanagement/mpm/inc/rmpm.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/rmpm.h	Thu Jul 22 16:37:38 2010 +0100
@@ -117,7 +117,7 @@
     public:
         // Zero values 
         inline void Reset();    
-        inline const TInt Count() const;
+        inline TInt Count() const;
 
     public:
         TUint   iCount;
@@ -275,7 +275,7 @@
     
 public:
     enum { EConnS60PolicyPref = 0x0f }; // TConnPref has defined up to 0x07.
-    inline TPolicyConnPref::TPolicyConnPref()
+    inline TPolicyConnPref()
     : TConnPref( TPolicyConnPref::EConnS60PolicyPref )
         {
         SetIapId( 0 );
@@ -391,7 +391,7 @@
         EConnTypeExplicit
     };
     
-    inline TMpmConnPref::TMpmConnPref()
+    inline TMpmConnPref()
     : TConnPref( TMpmConnPref::EConnPrefMpm )
         {
         SetSnapPurpose( CMManager::ESnapPurposeUnknown );
--- a/bearermanagement/mpm/inc/rmpm.inl	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/inc/rmpm.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -33,7 +33,7 @@
 // TMpmSnapBuffer::Count
 // -----------------------------------------------------------------------------
 //
-inline const TInt TMpmSnapBuffer::Count() const
+inline TInt TMpmSnapBuffer::Count() const
     {
     return iCount;
     }
--- a/bearermanagement/mpm/src/mpmcommsdataccess.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmcommsdataccess.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007-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"
@@ -2153,6 +2153,31 @@
     }
 
 // -----------------------------------------------------------------------------
+// CMPMCommsDatAccess::IsIntranetSnapL
+// -----------------------------------------------------------------------------
+//
+TBool CMPMCommsDatAccess::IsIntranetSnapL( TUint32 aSnapId )
+    {
+    MPMLOGSTRING( "CMPMCommsDatAccess::IsIntranetSnapL" )
+
+    RCmManager rCmManager;
+    rCmManager.OpenLC();
+
+    RCmDestination dest = rCmManager.DestinationL( aSnapId );
+    CleanupClosePushL(dest);
+    TInt snapMetadata = dest.MetadataL( CMManager::ESnapMetadataPurpose );
+    CleanupStack::PopAndDestroy( &dest );
+    CleanupStack::PopAndDestroy( &rCmManager );
+    
+    if ( snapMetadata == CMManager::ESnapPurposeIntranet )
+        {
+        return ETrue;
+        }
+    
+    return EFalse;            
+    }
+
+// -----------------------------------------------------------------------------
 // CMPMCommsDatAccess::GetBearerTypeL
 // -----------------------------------------------------------------------------
 //
@@ -2500,4 +2525,26 @@
     return destinationId;
     }
 
+// -----------------------------------------------------------------------------
+// CMPMCommsDatAccess::GetDefaultConnectionL
+// -----------------------------------------------------------------------------
+//
+void CMPMCommsDatAccess::GetDefaultConnectionL( TCmDefConnType& aType, TUint32& aId )
+    {
+    MPMLOGSTRING( "CMPMCommsDatAccess::GetDefaultConnectionL" )
+
+    RCmManager rCmManager;
+    CleanupClosePushL( rCmManager ); 
+    rCmManager.CreateTablesAndOpenL();
+    
+    TCmDefConnValue defConnValue;
+    rCmManager.ReadDefConnL( defConnValue );
+    
+    aType = defConnValue.iType;
+    aId = defConnValue.iId;
+    
+    CleanupStack::PopAndDestroy( &rCmManager );
+    
+    }
+
 //  End of File
--- a/bearermanagement/mpm/src/mpmconfirmdlgroaming.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmconfirmdlgroaming.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -67,6 +67,8 @@
       iIAP( aIAP ),
       iDialogType( aDialogType ),
       iConfirmDlg( NULL ),
+      iMsgQuery( EMsgQueryCancelled ),
+      iError( 0 ),
       iReconnect( aReconnect )
     {
     }
--- a/bearermanagement/mpm/src/mpmconfirmdlgstarting.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmconfirmdlgstarting.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -81,9 +81,11 @@
       iIAP( aIAP ),
       iDialogType( aDialogType ),
       iConfirmDlg( NULL ),
+      iMsgQuery( EMsgQueryCancelled ),
       iPref( aPref ),
       iServer( aServer ),
       iSession ( aSession ),
+      iError( 0 ),
       iIapState( aIapState )
     {
     }
@@ -203,11 +205,11 @@
     {
     MPMLOGSTRING2( "CMPMConfirmDlgStarting<0x%x>::UserSelectedConnectThisTime", iConnId )
     
-    TBool wlanNeeded( EFalse );
-    TRAPD( err, wlanNeeded = iIapSelection.StartWlanQueryIfNeededL( iIAP ) )
+    TBool isWlan( EFalse );
+    TRAPD( err, isWlan = iIapSelection.IsIapWlanL( iIAP ) )
     if( err == KErrNone )
         {
-        if( !wlanNeeded )
+        if( !isWlan )
             {
             if ( iIapState == CMPMIapSelection::EImplicitConnection )
                 {
@@ -228,9 +230,6 @@
                                             EStarting,
                                             iSession );
 
-                // Complete the ChooseBestIAP message with 
-                // KErrNone if user selected yes.
-                // 
                 MPMLOGSTRING2( "CMPMConfirmDlgStarting<0x%x>::UserSelectedConnectThisTime:\
 Complete KErrNone", iConnId )
                 iIapSelection.ChooseIapComplete( KErrNone, &iPref );                        
@@ -265,11 +264,11 @@
             }
         } 
     
-    TBool wlanNeeded( EFalse );
-    TRAPD( err, wlanNeeded = iIapSelection.StartWlanQueryIfNeededL( iIAP ) )
+    TBool isWlan( EFalse );
+    TRAPD( err, isWlan = iIapSelection.IsIapWlanL( iIAP ) )
     if( err == KErrNone )
         {
-        if( !wlanNeeded )
+        if( !isWlan )
             {
             if ( iIapState == CMPMIapSelection::EImplicitConnection )
                 {
@@ -290,8 +289,6 @@
                                             EStarting,
                                             iSession );
 
-                 // Complete the ChooseBestIAP message with 
-                 // KErrNone if user selected yes.
                  // 
                  MPMLOGSTRING2( "CMPMConfirmDlgStarting<0x%x>::UserSelectedConnectAutomatically:\
 Complete KErrNone", iConnId )
--- a/bearermanagement/mpm/src/mpmconnmonevents.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmconnmonevents.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-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"
@@ -35,12 +35,11 @@
 // CMPMConnMonEvents::NewL
 // -----------------------------------------------------------------------------
 //             
-CMPMConnMonEvents* CMPMConnMonEvents::NewL( CMPMServer& aServer, 
-                                            CMPMServerSession& aSession )
+CMPMConnMonEvents* CMPMConnMonEvents::NewL( CMPMServer& aServer )
     {
     CMPMConnMonEvents* self = new ( ELeave ) CMPMConnMonEvents( aServer );
     CleanupStack::PushL( self );
-    self->ConstructL( aSession );
+    self->ConstructL();
     CleanupStack::Pop( self );
     return self;
     }
@@ -74,7 +73,7 @@
 // CMPMConnMonEvents::ConstructL
 // -----------------------------------------------------------------------------
 // 
-void CMPMConnMonEvents::ConstructL( CMPMServerSession& aSession )
+void CMPMConnMonEvents::ConstructL()
     {
     MPMLOGSTRING( "CMPMConnMonEvents::ConstructL" )
     // Connect to Connection Monitor
@@ -93,7 +92,8 @@
     CMPMConnMonReqs* req = CMPMConnMonReqs::NewL( 
                                 *const_cast<CMPMConnMonEvents*>( this ),
                                 iConnMon,
-                                aSession.ConnectionId(), aSession );
+                                0,
+                                NULL );
     CleanupStack::PushL( req );
     iReqPtrs.AppendL( req ); 
     req->AvailableIapsSync();
@@ -566,7 +566,7 @@
                                 *const_cast<CMPMConnMonEvents*>( this ),
                                 iConnMon,
                                 aId, 
-                                *aSession );
+                                aSession );
     CleanupStack::PushL( req );
     iReqPtrs.AppendL( req ); 
     req->RefreshAvailableIAPs( aCallback, aForceRefreshIntervalSeconds );
@@ -578,7 +578,7 @@
 // CMPMConnMonEvents::CancelScanL
 // -----------------------------------------------------------------------------
 // 
-void CMPMConnMonEvents::CancelScanL( CMPMServerSession& aSession )
+void CMPMConnMonEvents::CancelScanL( CMPMServerSession* aSession )
     {
     MPMLOGSTRING( "CMPMConnMonEvents::CancelScanL" )
 
@@ -589,7 +589,7 @@
     CMPMConnMonReqs* req = CMPMConnMonReqs::NewL( 
                                 *const_cast<CMPMConnMonEvents*>( this ),
                                 iConnMon,
-                                aSession.ConnectionId(), 
+                                aSession->ConnectionId(), 
                                 aSession );
     // Delete ongoing req, if found
     TInt index = iReqPtrs.Find(req, CMPMConnMonReqs::CompareConnIds);
--- a/bearermanagement/mpm/src/mpmconnmonreqs.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmconnmonreqs.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -37,7 +37,7 @@
 CMPMConnMonReqs* CMPMConnMonReqs::NewL(CMPMConnMonEvents& aParent,
                                        RConnectionMonitor& aConnMon,
                                        TUint aConnId, 
-                                       CMPMServerSession& aSession )
+                                       CMPMServerSession* aSession )
     {
     CMPMConnMonReqs* self = new (ELeave) CMPMConnMonReqs(
                                 aParent, aConnMon, aConnId, aSession );
@@ -55,8 +55,10 @@
 CMPMConnMonReqs::CMPMConnMonReqs(CMPMConnMonEvents& aParent,
                                  RConnectionMonitor& aConnMon,
                                  TUint aConnId, 
-                                 CMPMServerSession& aSession )
-    : CActive(CActive::EPriorityStandard), 
+                                 CMPMServerSession* aSession )
+    : CActive(CActive::EPriorityStandard),
+      iNextState( EGetIapAvailState ),
+      iLastCancelCode( 0 ),
       iParent(aParent), 
       iConnMon(aConnMon), 
       iConnId(aConnId), 
@@ -227,6 +229,7 @@
         case EScanWLANNetworksStateCached:
             {
             MPMLOGSTRING( "CMPMConnMonReqs::ErrorCallbackL: EScanWLANNetworksState failed" )
+            ASSERT( iSession );
 
             // Disable discarding availability notifications from Connection Monitor.
             // 
@@ -237,23 +240,23 @@
             // 
             if( iWlanScanCallback == EWlanScanCallbackChooseIap )
                 {
-                iSession.IapSelectionL()->ChooseIapWLANScanCompletedL( aStatus );
+                iSession->IapSelectionL()->ChooseIapWLANScanCompletedL( aStatus );
                 }
             else if( iWlanScanCallback == EWlanScanCallbackProcessErr )
                 {
-                iSession.ProcessErrorWlanScanCompletedL();
+                iSession->ProcessErrorWlanScanCompletedL();
                 }
             else if( iWlanScanCallback == EWlanScanCallbackCarrierRejected )
                 {
                 // No fresh IAP info available but try to select new IAP
                 // based on whatever existing info there is
                 // 
-                iSession.CompleteCarrierRejected();
+                iSession->CompleteCarrierRejected();
                 }
             else if( iWlanScanCallback == EWlanScanCallbackSortSnap )
                 {
                 // SortSnap was called with old availability information.
-                iSession.CompleteServerSortSNAP();
+                iSession->CompleteServerSortSNAP();
                 }
             else
                 {
@@ -326,6 +329,8 @@
             case EScanWLANNetworksStateCached:
                 {
                 MPMLOGSTRING( "CMPMConnMonReqs::RunL: EScanWLANNetworksState and EScanWLANNetworksStateCached" )
+                ASSERT( iSession );
+
                 if ( iNextState == EScanWLANNetworksState )
                     {
                     MPMLOGSTRING( "CMPMConnMonReqs::RunL: EScanWLANNetworksState fresh data available from ConnMon" )
@@ -349,19 +354,19 @@
                 // 
                 if( iWlanScanCallback == EWlanScanCallbackChooseIap )
                     {
-                    iSession.IapSelectionL()->ChooseIapWLANScanCompletedL( iStatus.Int() );
+                    iSession->IapSelectionL()->ChooseIapWLANScanCompletedL( iStatus.Int() );
                     }
                 else if( iWlanScanCallback == EWlanScanCallbackProcessErr )
                     {
-                    iSession.ProcessErrorWlanScanCompletedL();
+                    iSession->ProcessErrorWlanScanCompletedL();
                     }
                 else if( iWlanScanCallback == EWlanScanCallbackCarrierRejected )
                     {
-                    iSession.CompleteCarrierRejected();
+                    iSession->CompleteCarrierRejected();
                     }
                 else if( iWlanScanCallback == EWlanScanCallbackSortSnap )
                     {
-                    iSession.CompleteServerSortSNAP();
+                    iSession->CompleteServerSortSNAP();
                     }
                 else
                     {
@@ -398,9 +403,7 @@
 
 TInt CMPMConnMonReqs::RunError( TInt aError )
     {
-    MPMLOGSTRING2(
-        "CMPMConnMonReqs::RunError: RunL made a leave with error = %i", 
-        aError )
+    MPMLOGSTRING2( "CMPMConnMonReqs::RunError: RunL made a leave with error = %i", aError )
 
     // Disable discarding availability notifications from Connection Monitor.
     // 
@@ -410,12 +413,14 @@
     // 
     if( iWlanScanCallback == EWlanScanCallbackChooseIap )
         {
-        iSession.ChooseIapComplete( aError, NULL );
+        ASSERT( iSession );
+        iSession->ChooseIapComplete( aError, NULL );
         }
     else if( iWlanScanCallback == EWlanScanCallbackProcessErr )
         {
         TBMNeededAction neededAction( EPropagateError );
-        iSession.ProcessErrorComplete( KErrNone, &aError, &neededAction );
+        ASSERT( iSession );
+        iSession->ProcessErrorComplete( KErrNone, &aError, &neededAction );
         }
     else
         {
--- a/bearermanagement/mpm/src/mpmdefaultconnection.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Handles defualt connection logic
-*
-*/
-
-#include <metadatabase.h>
-#include <datamobilitycommsdattypes.h>
-#include <cmdefconnvalues.h>
-#include "mpmdefaultconnection.h"
-#include "mpmserversession.h" //KShift8
-#include "mpmserver.h" 
-#include "mpmlogger.h"
-#include "mpmcommsdataccess.h"
-
-using namespace CommsDat;
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::NewL
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnection* CMPMDefaultConnection::NewL( const CMPMServer* aServer)
-    {
-    CMPMDefaultConnection * self = new (ELeave) 
-    CMPMDefaultConnection( aServer );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-    
-
-// ---------------------------------------------------------------------------
-// 
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnection::~CMPMDefaultConnection()
-    {
-    }
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::SetDefaultIAP
-// ---------------------------------------------------------------------------
-//
-TInt CMPMDefaultConnection::SetDefaultIAP( TInt aIapId )
-    {
-    TInt err( KErrNone );
-    //check validity
-    if( ( aIapId ) > 0 && ( aIapId <= KCDMaxRecords ) )
-        {
-        iDefaultIapId = aIapId;
-        MPMLOGSTRING2(
-            "CMPMDefaultConnection::SetDefaultIAP Set default connection iap: %d", 
-            aIapId)
-        }
-    else
-        {
-        err = KErrArgument;
-        MPMLOGSTRING2(
-            "CMPMDefaultConnection::SetDefaultIAP Invalid iap: %d", 
-            aIapId)
-        }    
-    return err;
-    }
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::ClearDefaultIAP
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnection::ClearDefaultIAP()
-    {
-    iDefaultIapId = 0;
-    MPMLOGSTRING( "CMPMDefaultConnection::ClearDefaultIAP:\
- cleared default iap" )
-    }
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::GetDefaultConnectionL
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnection::GetDefaultConnectionL( TCmDefConnType& aMode, 
-                                                   TUint32& aConnection )
-    {
-    // first option is registered default iap
-    if( iDefaultIapId )
-        {
-        MPMLOGSTRING2( "CMPMDefaultConnection::GetDefaultConnectionL:\
- default iap set as id %d", iDefaultIapId )
-        aMode = ECmDefConnConnectionMethod;
-        aConnection = iDefaultIapId;
-        }
-    else
-        {
-        MPMLOGSTRING( "CMPMDefaultConnection::GetDefaultConnectionL:\
- getting value from commsdat" )
-
-        // read global commsdat setting     
-        //
-        TRAPD( err, ReadDefConnSettingL( aMode, aConnection ) )
-
-        if( err != KErrNone )
-            {
-            //use default values
-            //
-            aMode = KDefaultMode;
-            aConnection = KDefaultConnectionId;
-            }
-
-        MPMLOGSTRING3( "CMPMDefaultConnection::GetDefaultConnectionL: \
-found type %d, id %d", aMode, aConnection )                
-          
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// Constructor
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnection::CMPMDefaultConnection( const CMPMServer* aServer ) : 
-    iServer( aServer )
-    {
-    
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::ConstructL
-// ---------------------------------------------------------------------------
-//    
-void CMPMDefaultConnection::ConstructL()
-    {
-    
-    }
-    
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::IntToCmDefConnType
-// ---------------------------------------------------------------------------
-//
-TCmDefConnType CMPMDefaultConnection::IntToCmDefConnTypeL( const TUint& aInt )
-    {
-    TCmDefConnType type( TCmDefConnType ( 0 ) );
-
-    if( aInt == ECmDefConnDestination )
-        {
-        type = ECmDefConnDestination;
-        }
-    else if( aInt == ECmDefConnConnectionMethod )
-        {
-        type = ECmDefConnConnectionMethod;
-        }
-    else
-        {
-        MPMLOGSTRING2( "CMPMDefaultConnection::IntToCmDefConnType:\
- incorrect value %d", aInt )
-        User::Leave( KErrArgument );
-        }
-    
-    return type;    
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnection::ReadDefConnSetting
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnection::ReadDefConnSettingL( TCmDefConnType& aType,
-                                                 TUint32&        aId )
-    {
-    MPMLOGSTRING( "CMPMDefaultConnection::ReadDefConnSettingL " )
-    CMDBSession* db = CMDBSession::NewLC( CMDBSession::LatestVersion() ); 
-    TMDBElementId tableId = CCDDefConnRecord::TableIdL( *db );     
-
-    // fetch value from commsdat using record set to be able 
-    // to load any and all records in the table.
-    // we don't want to make assumptions on id
-    //
-    CMDBRecordSet<CMDBGenericRecord> * recordSet = new ( ELeave )
-    CMDBRecordSet<CMDBGenericRecord>( tableId );
-    CleanupStack::PushL( recordSet );
-    recordSet->LoadL( *db );
-    
-    CCDDefConnRecord* dconn = new (ELeave) CCDDefConnRecord( tableId );
-    CleanupStack::PushL( dconn );
-    if( recordSet->iRecords.Count() )
-        {
-        // load the first entry found
-        dconn->SetElementId( CMPMCommsDatAccess::GetRealElementId( recordSet->iRecords[0] ) );
-        dconn->LoadL( *db );
-        aType = IntToCmDefConnTypeL( dconn->iDefConnType );
-        aId = dconn->iDefConnUid;
-        }
-    else
-        {
-        // nothing found, use default value
-        // 
-        MPMLOGSTRING( "CMPMDefaultConnection::ReadDefConnSettingL \
-no entry found" )
-        aType = KDefaultMode;
-        aId = KDefaultConnectionId;
-        }
-    db->Close();
-    CleanupStack::PopAndDestroy( dconn );
-    CleanupStack::PopAndDestroy( recordSet );
-    CleanupStack::PopAndDestroy( db );
-    }
--- a/bearermanagement/mpm/src/mpmdefaultconnserver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Default connection server implementation
-*
-*/
-
-#include "mpmdefaultconnserver.h"
-#include "mpmdefaultconnserversession.h"
-#include "mpmlogger.h"
-#include "mpmserver.h"
-
-// ---------------------------------------------------------------------------
-// Constructor
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServer::CMPMDefaultConnServer( CMPMServer* aMPMServer )
-    : CPolicyServer( CPolicyServer::EPriorityStandard, KMPMPolicy ),
-    iMPMServer( aMPMServer )
-    {        
-    }
-
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServer::ConstructL
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnServer::ConstructL()
-    {
-    MPMLOGSTRING( "MPMDefConnServer starting" )
-    StartL(KMPMDefaultConnectionServerName);
-    }
-
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServer::NewL
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServer* CMPMDefaultConnServer::NewL( CMPMServer* aMPMServer )
-    {
-    CMPMDefaultConnServer* self = new ( ELeave ) CMPMDefaultConnServer( aMPMServer );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-
-// ---------------------------------------------------------------------------
-// Destructor
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServer::~CMPMDefaultConnServer()
-    {
-
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServer::MPMServer
-// ---------------------------------------------------------------------------
-//
-CMPMServer* CMPMDefaultConnServer::MPMServer()
-    {
-    return iMPMServer;
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServer::NewSessionL
-// From class CServer2.
-// ---------------------------------------------------------------------------
-//
-CSession2* CMPMDefaultConnServer::NewSessionL( const TVersion& /*aVersion*/,
-                                               const RMessage2& /*aMessage*/) const
-    {
-    //create session
-    return CMPMDefaultConnServerSession::NewL( 
-        const_cast<CMPMDefaultConnServer*> ( this ) );
-    }
-
-
--- a/bearermanagement/mpm/src/mpmdefaultconnserversession.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Session to MPM Default Connection server
-*
-*/
-
-#include <featmgr.h>
-
-#include "mpmdefaultconnserversession.h"
-#include "mpmdefaultconnserver.h"
-#include "mpmdefaultconnection.h"
-#include "mpmcommon.h"
-#include "mpmserver.h"
-#include "mpmlogger.h"
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServerSession::NewL
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServerSession* CMPMDefaultConnServerSession::NewL( 
-    CMPMDefaultConnServer* aServer )
-    {
-    MPMLOGSTRING( "CMPMDefaultConnServerSession::NewL" )
-    CMPMDefaultConnServerSession* self = new ( ELeave ) CMPMDefaultConnServerSession( aServer );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// Destructor
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServerSession::~CMPMDefaultConnServerSession()
-    {
-    MPMLOGSTRING( "CMPMDefaultConnServerSession::~CMPMDefaultConnServerSession" )
-    DefaultConnServer()->MPMServer()->DefaultConnection()->ClearDefaultIAP();
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServerSession::DefaultConnServer
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServer* CMPMDefaultConnServerSession::DefaultConnServer()
-    {
-    MPMLOGSTRING( "CMPMDefaultConnServerSession::DefaultConnServer" )
-    return iDefaultConnServer; 
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServerSession::ServiceL
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnServerSession::ServiceL( const RMessage2& aMessage )
-    {
-    MPMLOGSTRING2( "CMPMDefaultConnServerSession::ServiceL %d ", 
-                   aMessage.Function() )
-    switch ( aMessage.Function() )
-        {
-        case EMPMDefaultConnectionSetDefaultIap:
-            {
-            SetDefaultIAP( aMessage );
-            break;
-            }
-        case EMPMDefaultConnectionClearDefaultIap:
-            {
-            ClearDefaultIAP( aMessage);
-            break;
-            }
-        default:
-            {
-            aMessage.Complete( KErrNotSupported );
-			MPMLOGSTRING( 
-			    "CMPMDefaultConnServerSession::ServiceL: Unsupported message type" )
-            }                   
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// Constructor
-// ---------------------------------------------------------------------------
-//
-CMPMDefaultConnServerSession::CMPMDefaultConnServerSession( 
-CMPMDefaultConnServer* aServer )
-    : CSession2(), 
-      iDefaultConnServer( aServer ) 
-    {
-    MPMLOGSTRING( "CMPMDefaultConnServerSession::CMPMDefaultConnServerSession" )
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServerSession::ConstructL
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnServerSession::ConstructL()
-    {
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServerSession::SetDefaultIAP
-// Store IAP to be used as default connection in MPM Server
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnServerSession::SetDefaultIAP( const RMessage2& aMessage )
-    {
-    MPMLOGSTRING( "CMPMDefaultConnServerSession::SetDefaultIAP" )
-    TInt iap( 0 ), err( KErrNone );
-    iap = aMessage.Int0();
-    err = DefaultConnServer()->MPMServer()->DefaultConnection()->SetDefaultIAP( iap );
-    aMessage.Complete( err );
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMDefaultConnServerSession::ClearDefaultIAP
-// Clear IAP from being used as default connection in MPM Server
-// ---------------------------------------------------------------------------
-//
-void CMPMDefaultConnServerSession::ClearDefaultIAP( const RMessage2& aMessage )
-    {
-    MPMLOGSTRING( "CMPMDefaultConnServerSession::ClearDefaultIAP" )
-    DefaultConnServer()->MPMServer()->DefaultConnection()->ClearDefaultIAP();
-    aMessage.Complete( KErrNone );
-    }
--- a/bearermanagement/mpm/src/mpmdisconnectdlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,282 +0,0 @@
-/*
-* Copyright (c) 2005-2008 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: MPM disconnect dialog handling
-*
-*/
-
-/**
-@file mpmdisconnectdlg.cpp
-Mobility Policy Manager disconnect dialog initiation.
-*/
-
-// INCLUDE FILES
-#include "mpmdisconnectdlg.h"
-#include "mpmconnmonevents.h"
-#include "mpmlogger.h"
-
-// ============================= LOCAL FUNCTIONS ===============================
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::NewL
-// -----------------------------------------------------------------------------
-//
-CMPMDisconnectDlg* CMPMDisconnectDlg::NewL(
-    CMPMServerSession&                aSession,
-    TInt                              aOrigError,
-    CArrayPtrFlat<CMPMDisconnectDlg>& aDisconnectQueue )
-    {
-    CMPMDisconnectDlg* self = new (ELeave) CMPMDisconnectDlg( aSession,
-                                                              aOrigError,
-                                                              aDisconnectQueue );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::CMPMDisconnectDlg
-// -----------------------------------------------------------------------------
-//
-CMPMDisconnectDlg::CMPMDisconnectDlg(
-    CMPMServerSession&                aSession,
-    TInt                              aOrigError,
-    CArrayPtrFlat<CMPMDisconnectDlg>& aDisconnectQueue )
-    :   CMPMDialogBase( *(CArrayPtrFlat<CMPMDialogBase>*)&aDisconnectQueue ), 
-        iSession( aSession ),
-        iOrigError( aOrigError )
-    {
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::~CMPMDisconnectDlg
-// -----------------------------------------------------------------------------
-//
-CMPMDisconnectDlg::~CMPMDisconnectDlg()
-    {
-    MPMLOGSTRING( "CMPMDisconnectDlg::~CMPMDisconnectDlg" )
-    Cancel();
-    iDlgServ.Close();
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::ConstructL
-// -----------------------------------------------------------------------------
-//
-void CMPMDisconnectDlg::ConstructL()
-    {
-    User::LeaveIfError( iDlgServ.Connect() );
-    CMPMDialogBase::ConstructL();
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::RunL
-// -----------------------------------------------------------------------------
-//
-void CMPMDisconnectDlg::RunL()
-    {
-    MPMLOGSTRING2( "CMPMDisconnectDlg::RunL status %d", iStatus.Int() )
-
-    TInt error = iStatus.Int();
-    if ( error == KErrNone )
-        {
-        UserSelectedOk( iStatus.Int() );
-        }
-    else
-        {
-        UserSelectedCancel( iStatus.Int() );
-        }
-    // Store selection
-    iUserStatus = iStatus.Int();
-    iUserIap = iIapId;
-    }
-
-    
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::UserSelectedOk
-// -----------------------------------------------------------------------------
-//
-void CMPMDisconnectDlg::UserSelectedOk( TInt aError )
-    {
-    MPMLOGSTRING( "CMPMDisconnectDlg::UserSelectedOk: \
-Tell BM to ignore error and do reselection" )
-
-    TBMNeededAction neededAction( EDoReselection );
-    TInt error = aError;
-
-    iSession.ProcessErrorComplete( KErrNone,
-                                   &error,
-                                   &neededAction );
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::UserSelectedCancel
-// -----------------------------------------------------------------------------
-//
-void CMPMDisconnectDlg::UserSelectedCancel( TInt aError )
-    {
-    // User has selected Cancel
-    // 
-    // Read the Connection Id of the application
-    // 
-    TConnectionId connId = iSession.ConnectionId();
-
-    TBMNeededAction neededAction( EDoReselection );
-
-    TInt error = aError;
-    TInt* errorPtr( NULL );
-    
-    if ( error == KErrNotFound )
-        {
-        MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \
-Use original error code %i", iOrigError )
-
-        error = iOrigError;
-        }
-
-    // Get the state of the connection for this Iap Id.
-    // 
-    TConnectionState state;
-    iSession.MyServer().GetConnectionState( connId, state );
-
-    if ( state == EStarting )
-        {
-        MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \
-Tell BM to end the client connection with error code %i", error )
-
-        neededAction = EPropagateError;
-        errorPtr = &error;
-        }
-    else if ( state == ERoaming )
-        {
-        // New notification will be attempted with latest
-        // available IAPs
-        //
-        iSession.StoredIapInfo().ResetStoredIapInfo();
-        neededAction = EIgnoreError;
-
-        // Get the current connection IapId for this connId 
-        //
-        TUint32 currentIap = iSession.MyServer().GetBMIap( connId );
-
-        TConnMonIapInfo availableIAPs;
-        availableIAPs = iSession.GetAvailableIAPs();
-
-        iSession.MyServer().HandleServerBlackListIap( connId, 
-                                                      currentIap, 
-                                                      ETemporary );
-        TRAP( error, iSession.PrefIAPNotificationL( availableIAPs, 
-                                                    EBearerMan ) );
-        if ( error == KErrNotFound )
-            {
-            neededAction = EPropagateError;
-
-            errorPtr = &error;
-            TRAP_IGNORE( iSession.MobilityErrorNotificationL( KErrNotFound ) )
-            MPMLOGSTRING2(
-                "CMPMDisconnectDlg::UserSelectedCancelL: \
-Tell BM to end the client connection with error code %i", error )
-            }
-        else
-            {
-            MPMLOGSTRING(
-                "CMPMDisconnectDlg::UserSelectedCancelL: \
-Tell BM to ignore error and let MPM notify application about preferred IAP" )
-            }
-        }
-    else
-        {
-        MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \
-Unsupported state %d", state )
-        }
-
-    iSession.ProcessErrorComplete( KErrNone,
-                                   errorPtr,
-                                   &neededAction );
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::RunError
-// -----------------------------------------------------------------------------
-//
-TInt CMPMDisconnectDlg::RunError(TInt aError)
-    {
-    // Handles a leave occurring in the request completion event handler 
-    // RunL(). The active scheduler calls this function if this active 
-    // object's RunL() function leaves. This gives this active object 
-    // the opportunity to perform any necessary cleanup.
-    // 
-    MPMLOGSTRING2(
-        "CMPMDisconnectDlg::RunError: RunL made a leave with error = %i", 
-        aError )
-
-    iSession.ProcessErrorComplete( aError, NULL, NULL );
-
-    // Return KErrNone to prevent panic 
-    // 
-    return KErrNone;
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::DoCancel
-// -----------------------------------------------------------------------------
-//
-void CMPMDisconnectDlg::DoCancel()
-    {
-    MPMLOGSTRING( "CMPMDisconnectDlg::DoCancel" )
-    iDlgServ.CancelDisconnectDlg();
-    }
-
-
-// -----------------------------------------------------------------------------
-// CMPMDisconnectDlg::Start
-// -----------------------------------------------------------------------------
-//
-void CMPMDisconnectDlg::Start( CMPMDialogBase* aDlg )
-    {
-    // If there are no outstanding CMPMDisconnectDlg, then 
-    // start CMPMDisconnectDlg immediately.
-    //
-    if ( aDlg )
-        {
-        CMPMDisconnectDlg* dlg = (CMPMDisconnectDlg*) aDlg;
-        iUserStatus = dlg->iUserStatus;
-        iUserIap = dlg->iUserIap;
-        }
-    if ( iUserStatus == KErrNone && iUserIap != 0 )
-        {
-        UserSelectedOk( iUserStatus );
-        }
-    else if ( iUserStatus != KErrNone )
-        {
-        UserSelectedCancel( iUserStatus );
-        }
-    else
-        {
-        iDlgServ.DisconnectDlg( iStatus, iIapId, ETrue );
-        SetActive();
-        }
-    }
-
-
-//  End of File
--- a/bearermanagement/mpm/src/mpmiapselection.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmiapselection.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,8 +21,6 @@
 #include "mpmcommsdataccess.h"
 #include "mpmconnmonevents.h"
 #include "mpmconfirmdlgstarting.h"
-#include "mpmdefaultconnection.h"
-#include "mpmwlanquerydialog.h"
 #include "extendedconnpref.h"
 
 // ---------------------------------------------------------------------------
@@ -38,7 +36,6 @@
       iStoredIapInfo(),
       iSession( aSession ),
       iConfirmDlgStarting( NULL ),
-      iWlanDialog( NULL ),
       iNextBestExists( EFalse ),
       iUserSelectionIapId( 0 ),
       iUserSelectionSnapId( 0 ),
@@ -86,7 +83,6 @@
     StopDisplayingStartingDlg();
     
     delete iConfirmDlgStarting;
-    delete iWlanDialog;
     }
 
 // -----------------------------------------------------------------------------
@@ -185,7 +181,7 @@
         // Default connection is requested.
 
         MPMLOGSTRING( "CMPMIapSelection::ChooseIapL:\
- Default Connection" )
+            Default Connection" )
 
         if ( iSession->UseUserConnPref() )
             {
@@ -201,39 +197,17 @@
             return;
             }
 
+        // Read the default connection values
         TCmDefConnType type( TCmDefConnType( 0 ) );
         TUint32 id( 0 );
-        iSession->MyServer().DefaultConnection()->GetDefaultConnectionL( type, id );
+        iCommsDatAccess->GetDefaultConnectionL( type, id );
         
         MPMLOGSTRING3( "CMPMIapSelection::ChooseIapL:\
- default connection type %d id %d", type, id )
-       
-        if( type == ECmDefConnConnectionMethod )
-            {
-            iChooseIapPref.SetIapId( id );
-            iChooseIapPref.SetSnapId( 0 );
-            ExplicitConnectionL();
-            }
-        else if( type == ECmDefConnDestination )
-            { 
-            iChooseIapPref.SetSnapId( id );
-            ExplicitConnectionL();
-            }
-        else
-            {
-            if( iCommsDatAccess->IsSnapEmptyL( id ) )
-                {
-                // start implicit connection
-                ImplicitConnectionL();
-                return;
-                }
-
-            iChooseIapPref.SetSnapId( id );
-
-            // start connection as if explicitly defined 
-            // by application
-            ExplicitConnectionL();
-            }       
+            default connection type %d id %d", type, id )
+        
+        // set the received snap id and open the connection
+        iChooseIapPref.SetSnapId( id );
+        ExplicitConnectionL();
         }
     else if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit )
         {
@@ -350,13 +324,8 @@
         iChooseIapPref.SetIapId( validateIapId );
         iChooseIapPref.SetNetId( retNetId );
 
-        // In case offline mode is enabled, only LAN or WLAN is allowed.
-        // If some other bearer has been requested, then error code 
-        // KErrGprsOfflineMode should be returned instead of KErrNone.
-        // 
-        
-        if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() ||                 
-             iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) )
+        if ( !iapTypeLanOrWlan &&                  
+             iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown )
             {
             ChooseIapComplete( KErrGprsOfflineMode, &iChooseIapPref );
             }
@@ -365,9 +334,13 @@
             TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( validateIapId );
             if( wlanType != ENotWlanIap )
                 {
-                iChooseIapState = EExplicitConnection;
-                iWlanDialog = CMPMWlanQueryDialog::NewL( *this, validateIapId );
-                iWlanDialog->StartWlanQueryL();
+                // Add info into the BM connections
+                iSession->MyServer().AppendBMConnection( iSession->ConnectionId(), 
+                                    iChooseIapPref.SnapId(),
+                                    validateIapId,
+                                    EStarting,
+                                    *iSession );
+                ChooseIapComplete( KErrNone, &iChooseIapPref );
                 return;                
                 }
 
@@ -377,34 +350,39 @@
             if ( iSession->IsConfirmFirstL( validateIapId ) &&
                  !( iSession->MyServer().CommsDatAccess()->IsVirtualIapL( validateIapId ) ))
                 {
-                // Check if we are roaming and cellular data usage query has not yet been presented
-                // to the user in this country
-                if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
+            
+                // Check whether queries are enabled
+                if ( !( iChooseIapPref.NoteBehaviour()
+                        & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
                     {
-                    // Check whether queries are enabled
-                    if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
-                        {
-                        TConnectionId connId = iSession->ConnectionId();
-                                                            
-                        // International roaming
-                        iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
-                            *this, 
-                            connId,
-                            snap, 
-                            validateIapId, 
-                            CMPMConfirmDlg::EConfirmDlgVisitorNetwork,
-                            iChooseIapPref,
-                            iSession->MyServer(),
-                            *iSession,
-                            EExplicitConnection );
-                        return;    
-                        }
-                    else
-                        {
-                        // Queries disabled, connection must fail
-                        ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref );
-                        return;
-                        }
+                
+                    TConnectionId connId = iSession->ConnectionId();
+
+                    // Set confirmation type based on roaming status
+                    CMPMConfirmDlg::TDialogType type = 
+                            CMPMConfirmDlg::EConfirmDlgHomeNetwork;
+                    if ( iSession->MyServer().RoamingWatcher()->RoamingStatus()
+                            == EMPMInternationalRoaming ) {
+                        type = CMPMConfirmDlg::EConfirmDlgVisitorNetwork;
+                    }
+                    
+                    iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
+                        *this, 
+                        connId,
+                        snap, 
+                        validateIapId, 
+                        type,
+                        iChooseIapPref,
+                        iSession->MyServer(),
+                        *iSession,
+                        EExplicitConnection );
+                    return;    
+                    }
+                else
+                    {
+                    // Queries disabled, connection must fail
+                    ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref );
+                    return;
                     }
                 }
                            
@@ -482,10 +460,10 @@
     // Check if any suitable IAP's were found, if not then complete selection with error code
     if ( validateIapId == 0 )
         {
-        if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault ||
+        if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
+                ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault ||
                 ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit &&
-                !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
-                iCommsDatAccess->IsInternetSnapL( 0, snap ) ) )
+                  iCommsDatAccess->IsInternetSnapL( 0, snap ) ) ) )
             {
             ImplicitConnectionL();
             }
@@ -514,8 +492,8 @@
         {
         ChooseIapComplete( KErrGprsServicesNotAllowed, NULL );
         }
-    else if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() ||                 
-               iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) )
+    else if ( !iapTypeLanOrWlan &&                 
+               iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown )
         {
         // In case offline mode is enabled, only LAN or WLAN is allowed.
         // If some other bearer has been requested, then error code 
@@ -572,19 +550,14 @@
             }
         else
             {
-            if ( !StartWlanQueryIfNeededL( validateIapId ) )
-                {
-                // Add info into the BM connections
-                //
-                iSession->MyServer().AppendBMConnection( connId, 
+            // Add info into the BM connections
+            //
+            iSession->MyServer().AppendBMConnection( connId, 
                         snap, 
                         validateIapId, 
                         EStarting,
                         *iSession );
-                ChooseIapComplete( KErrNone, &iChooseIapPref );
-
-                }
-
+            ChooseIapComplete( KErrNone, &iChooseIapPref );
             }
         }
 
@@ -623,26 +596,18 @@
     }
 
 // -----------------------------------------------------------------------------
-// CMPMIapSelection::StartWlanQueryIfNeededL
+// CMPMIapSelection::IsIapWlanL
 // -----------------------------------------------------------------------------
 //
-TBool CMPMIapSelection::StartWlanQueryIfNeededL( TUint32 aIapId, TBool aIsRoaming )
+TBool CMPMIapSelection::IsIapWlanL( TUint32 aIapId )
     {
-    MPMLOGSTRING3( "CMPMIapSelection::StartWlanQueryIfNeededL iap %d, isRoaming %d ", 
-                   aIapId,
-                   aIsRoaming )
-    TBool wlanQueryNeeded( EFalse );
-    // If wlan iap check if offline note needed
+    MPMLOGSTRING2( "CMPMIapSelection::StartWlanQueryIfNeededL iap %d, ", aIapId)
     TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( aIapId );
-    if( wlanType != ENotWlanIap )
+    if( wlanType != EWlanIap )
         {
-        iIsRoaming = aIsRoaming;
-        iChooseIapState = EExplicitConnection;
-        iWlanDialog = CMPMWlanQueryDialog::NewL( *this, aIapId );
-        iWlanDialog->StartWlanQueryL();
-        wlanQueryNeeded = ETrue;
+        return EFalse;
         }
-    return wlanQueryNeeded;
+    return ETrue;
     }
 
 // -----------------------------------------------------------------------------
@@ -719,12 +684,6 @@
     const TMpmConnPref* aPolicyPref )
     {
     MPMLOGSTRING2( "CMPMIapSelection::ChooseIapComplete aError = %d", aError )
-        
-    if( iWlanDialog )
-        {
-        delete iWlanDialog;
-        iWlanDialog = NULL;
-        }
 
     iSession->ChooseIapComplete( aError, aPolicyPref );
     // Set choose iap state to none
@@ -735,62 +694,6 @@
     iImplicitState = EImplicitStart;
     }
 
-
-// -----------------------------------------------------------------------------
-// CMPMIapSelection::UserWlanSelectionDoneL
-// -----------------------------------------------------------------------------
-//
-void CMPMIapSelection::UserWlanSelectionDoneL( TInt aError, TUint32 aIapId )
-    {
-    MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL" )
-
-    if( iIsRoaming )
-        {
-        iIsRoaming = EFalse;
-        iSession->MigrateCallbackL( aError );
-        delete iWlanDialog;
-        iWlanDialog = NULL;
-        }
-    else
-        {
-        if( aError != KErrNone )
-            {
-            MPMLOGSTRING2( "CMPMIapSelection::UserWlanSelectionDoneL - Error = %d, completing", aError ) 
-            ChooseIapComplete( aError, NULL );        
-            }
-        else
-            {
-            if( iChooseIapState == EImplicitConnection )
-                {
-                iUserSelectionIapId = aIapId;
-                ImplicitConnectionL();    
-                }
-            else if( iChooseIapState == EExplicitConnection )
-                {
-                MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL completing explicit iap connection" ) 
-                iChooseIapPref.SetIapId( aIapId );
-                // Add info into the BM connections
-                //
-                iSession->MyServer().AppendBMConnection( iSession->ConnectionId(), 
-                                                         iChooseIapPref.SnapId(),
-                                                         aIapId,
-                                                         EStarting,
-                                                         *iSession );
-                delete iWlanDialog;
-                iWlanDialog = NULL;
-
-                ChooseIapComplete( KErrNone, &iChooseIapPref );
-                }
-            else
-                {
-                MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL - error, no connection state" ) 
-                }
-            
-            }
-        
-        }
-    }
-
 // -----------------------------------------------------------------------------
 // CMPMIapSelection::HandleUserSelectionError
 // -----------------------------------------------------------------------------
@@ -867,15 +770,10 @@
     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionWlanNoteL" )
     
     TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( iUserSelectionIapId );
-    // In case offline mode is enabled, only LAN or WLAN is allowed.
-    // If some other bearer has been requested, then error code 
-    // KErrGprsOfflineMode should be returned instead of KErrNone.
-    // 
+
     if( wlanType != ENotWlanIap )
         {
-        iChooseIapState = EImplicitConnection;
-        iWlanDialog = CMPMWlanQueryDialog::NewL( *this, iUserSelectionIapId );
-        iWlanDialog->StartWlanQueryL();
+        ImplicitConnectionL();
         return;                
         }
     else
@@ -936,8 +834,8 @@
                                    iapTypeLanOrWlan,
                                    *iSession );
                                    
-    if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() ||            
-            iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) )
+    if ( !iapTypeLanOrWlan &&            
+            iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown )
         {
         MPMLOGSTRING2( "CMPMIapSelection::CompleteImplicitConnectionL: Completing with code = %i",
                 KErrGprsOfflineMode )
@@ -959,13 +857,6 @@
         iChooseIapPref.SetIapId( iUserSelectionIapId );
         iChooseIapPref.SetNetId( retNetId );
             
-        
-        if( iWlanDialog )
-            {
-            delete iWlanDialog;
-            iWlanDialog = NULL;
-            }
-        
         ChooseIapComplete( KErrNone, &iChooseIapPref );
         }
     
--- a/bearermanagement/mpm/src/mpmofflinewatcher.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2008-2009 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"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- *
- * Description: Listens central repository for offline mode changes.
- *
- */
-
-#include <e32base.h>
-#include <centralrepository.h>
-#include <CoreApplicationUIsSDKCRKeys.h>
-#include <featmgr.h>
-
-#include "mpmlogger.h"
-#include "mpmserver.h"
-#include "mpmofflinewatcher.h"
-
-// ---------------------------------------------------------------------------
-// Default C++ constructor.
-// ---------------------------------------------------------------------------
-//
-CMpmOfflineWatcher::CMpmOfflineWatcher( CMPMServer* aServer ) :
-    CActive( EPriorityStandard ), iServer( aServer )
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::CMpmOfflineWatcher" )
-
-    CActiveScheduler::Add( this );
-    }
-
-// ---------------------------------------------------------------------------
-// Symbian 2nd phase constructor. Creates a central repository object.
-// ---------------------------------------------------------------------------
-//
-void CMpmOfflineWatcher::ConstructL()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::ConstructL" )
-
-    FeatureManager::InitializeLibL();
-    // If feature isn't supported, then no watching, but return in StartL().
-    iOfflineFeatureSupported = FeatureManager::FeatureSupported( 
-                               KFeatureIdOfflineMode );
-    FeatureManager::UnInitializeLib();
-
-        
-    iRepository = CRepository::NewL( KCRUidCoreApplicationUIs );
-    }
-
-// ---------------------------------------------------------------------------
-// Creates a new object by calling the two-phased constructor.
-// ---------------------------------------------------------------------------
-//
-CMpmOfflineWatcher* CMpmOfflineWatcher::NewL( CMPMServer* aServer )
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::NewL" )
-
-    CMpmOfflineWatcher* self = new( ELeave ) CMpmOfflineWatcher( aServer );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// Destructor.
-// ---------------------------------------------------------------------------
-//
-CMpmOfflineWatcher::~CMpmOfflineWatcher()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::~CMpmOfflineWatcher" )
-
-    Cancel();
-    delete iRepository;
-    }
-
-// ---------------------------------------------------------------------------
-// Order notification from changes.
-// ---------------------------------------------------------------------------
-//
-void CMpmOfflineWatcher::StartL()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::StartL" )
-            
-    if ( !iOfflineFeatureSupported )
-        {
-        return;
-        }
-
-    // Get the initial data usage value from repository.
-    User::LeaveIfError( GetCurrentOfflineValue() );
-    iServer->UpdateOfflineMode( iOfflineMode );
-    
-    // Request notifications.
-    User::LeaveIfError( RequestNotifications() );
-    }
-
-// ---------------------------------------------------------------------------
-// From class CActive.
-// Event is received when there is a change in central repository key.
-// ---------------------------------------------------------------------------
-//
-void CMpmOfflineWatcher::RunL()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::RunL" )
-
-    if ( iStatus.Int() < KErrNone )
-        {
-        MPMLOGSTRING2("Status: 0x%08X", iStatus.Int())
-        iErrorCounter++;
-        if ( iErrorCounter > KMpmOfflineWatcherCenRepErrorThreshold )
-            {
-            MPMLOGSTRING2("Over %d consecutive errors, stopping notifications permanently.",
-                    KMpmOfflineWatcherCenRepErrorThreshold)
-            return;
-            }
-        // Else: Error occured but counter not expired. Proceed.
-        }
-    else
-        {
-        // Notification is received ok => Reset the counter.
-        iErrorCounter = 0;
-
-        // Check if mode has changed (it should).
-        TInt oldMode = iOfflineMode;
-        
-        TInt err = GetCurrentOfflineValue();
-        if ( err == KErrNone && oldMode != iOfflineMode )
-            {
-            iServer->UpdateOfflineMode( iOfflineMode );
-            }
-        }
-    
-    RequestNotifications();
-    }
-
-// ---------------------------------------------------------------------------
-// From class CActive.
-// Cancel the outstanding request.
-// ---------------------------------------------------------------------------
-//
-void CMpmOfflineWatcher::DoCancel()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::DoCancel" )
-
-    iRepository->NotifyCancel( KCoreAppUIsNetworkConnectionAllowed );
-    }
-
-// ---------------------------------------------------------------------------
-// Request for notifications.
-// ---------------------------------------------------------------------------
-//
-TInt CMpmOfflineWatcher::RequestNotifications()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::RequestNotifications" )
-
-    TInt err = iRepository->NotifyRequest( KCoreAppUIsNetworkConnectionAllowed, iStatus );
-        
-    if ( err == KErrNone )
-        {
-        SetActive();
-        }
-    else
-        {
-        // MPM's offline mode watching wouldn't recover... 
-        MPMLOGSTRING2( "CMpmOfflineWatcher::RequestNotifications, ERROR: %d", err )
-        }
-    return err;
-    }
-
-// ---------------------------------------------------------------------------
-// Get the current repository key value.
-// ---------------------------------------------------------------------------
-//
-TInt CMpmOfflineWatcher::GetCurrentOfflineValue()
-    {
-    MPMLOGSTRING( "CMpmOfflineWatcher::GetCurrentOfflineValue" )
-
-    TInt err = iRepository->Get( KCoreAppUIsNetworkConnectionAllowed, iOfflineMode );
-        
-    if ( err != KErrNone )
-        {
-        MPMLOGSTRING2( "CMpmOfflineWatcher::GetCurrentOfflineValue, ERROR: %d", err )
-        }
-    return err;
-    }
--- a/bearermanagement/mpm/src/mpmserver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -34,18 +34,17 @@
 #include "mpmlogger.h"
 #include "mpmdtmwatcher.h"
 #include "mpmroamingwatcher.h"
-#include "mpmdisconnectdlg.h"
 #include "mpmconfirmdlgroaming.h"
 #include "mpmconfirmdlgstarting.h"
-#include "mpmdefaultconnection.h"
 #include "mpmcommsdataccess.h"
-#include "mpmwlanquerydialog.h"
 #include "mpmprivatecrkeys.h"
 #include "mpmcsidwatcher.h"
+#include "mpmvpntogglewatcher.h"
 #include "mpmdatausagewatcher.h"
 #include "mpmpropertydef.h"
-#include "mpmofflinewatcher.h"
 
+static const TUint32 KUidKmdServer = 0x1000088A;
+    
 // ============================= LOCAL FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -85,14 +84,22 @@
       iTSYLoaded( EFalse ),
       iPacketServLoaded( EFalse ), 
       iDtmWatcher( NULL ), 
+      iRoamingWatcher( NULL ),
       iWLANScanRequired( EFalse ), 
-      iDisconnectQueue( NULL ), 
       iRoamingQueue( NULL ), 
       iStartingQueue( NULL ),
-      iWlanQueryQueue( NULL ),
-      iDefaultConnection( NULL ), 
       iConnectionCounter( 0 ),
-      iOfflineMode( ECoreAppUIsNetworkConnectionAllowed )
+      iUserConnection( EFalse ),
+      iUserConnectionInInternet( EFalse ),
+      iVpnUserConnectionSessionCount( 0 ),
+      iMpmCsIdWatcher( NULL ),
+      iMpmVpnToggleWatcher( NULL ),
+      iMpmDataUsageWatcher( NULL ),
+      iCommsDatAccess( NULL ),
+      iConnUiUtils( NULL ),
+      iOfflineMode( ECoreAppUIsNetworkConnectionAllowed ),
+      iOfflineWlanQueryResponse( EOfflineResponseUndefined ),      
+      iRoamingToWlanPeriodic( NULL )
     {
     }
 
@@ -153,9 +160,6 @@
     iRoamingWatcher = CMPMRoamingWatcher::NewL(iMobilePhone);
 
     iCommsDatAccess = CMPMCommsDatAccess::NewL( );
-    
-    iDisconnectQueue = new ( ELeave ) CArrayPtrFlat<CMPMDisconnectDlg>( KGranularity );
-    iDisconnectQueue->Reset();
 
     iRoamingQueue = new ( ELeave ) CArrayPtrFlat<CMPMConfirmDlgRoaming>( KGranularity );
     iRoamingQueue->Reset();
@@ -163,14 +167,12 @@
     iStartingQueue = new ( ELeave ) CArrayPtrFlat<CMPMConfirmDlgStarting>( KGranularity ); 
     iStartingQueue->Reset();
 
-    iWlanQueryQueue = new ( ELeave ) CArrayPtrFlat<CMPMWlanQueryDialog>( KGranularity );
-    iWlanQueryQueue->Reset();
-    
-    iDefaultConnection = CMPMDefaultConnection::NewL( this );    
-
     // Create central repository watcher and start it
     iMpmCsIdWatcher = CMpmCsIdWatcher::NewL();
     iMpmCsIdWatcher->StartL();
+    
+    // Create VPN toggle central repository watcher and start it
+    iMpmVpnToggleWatcher = CMpmVpnToggleWatcher::NewL( *this );
 
     // Create another central repository watcher and start it
     TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) );
@@ -184,18 +186,6 @@
         MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" )
         }
 
-    // Create another central repository watcher and start it
-    TRAPD( owErr, iMpmOfflineWatcher = CMpmOfflineWatcher::NewL( this ) );
-    if (owErr == KErrNone)
-        {
-        iMpmOfflineWatcher->StartL();
-        }
-    else
-        {
-        iMpmOfflineWatcher = NULL;
-        MPMLOGSTRING( "CMPMServer::ConstructL: CMpmOfflineWatcher::NewL() failed!" )
-        }
-
     // Read dedicated clients from the central repository
     CRepository* repository = CRepository::NewL( KCRUidMPM );
     
@@ -230,12 +220,11 @@
 //
 CMPMServer::~CMPMServer()
     {
-    if ( iDisconnectQueue )
+	if ( iRoamingToWlanPeriodic )
         {
-        iDisconnectQueue->ResetAndDestroy();
+        iRoamingToWlanPeriodic->Cancel();
+		delete iRoamingToWlanPeriodic;
         }
-    delete iDisconnectQueue;
-
     if ( iRoamingQueue )
         {
         iRoamingQueue->ResetAndDestroy();
@@ -248,12 +237,6 @@
         }
     delete iStartingQueue;
 
-    while ( iWlanQueryQueue && iWlanQueryQueue->Count() > 0 )
-        {
-        iWlanQueryQueue->Delete( 0 );
-        }
-    delete iWlanQueryQueue;
-
     delete iEvents;
 
     for ( TInt i = 0; i < iBlackListIdList.Count(); i++ )
@@ -276,14 +259,12 @@
     iMobilePhone.Close();
     iTelServer.Close();
     
-    delete iDefaultConnection;
-    
     delete iMpmCsIdWatcher;    
-    
+       
+    delete iMpmVpnToggleWatcher;
+ 
     delete iMpmDataUsageWatcher;    
 
-    delete iMpmOfflineWatcher;    
-
     iDedicatedClients.Close();
 
     delete iCommsDatAccess;
@@ -291,6 +272,57 @@
     delete iConnUiUtils;
     }
 
+// -----------------------------------------------------------------------------
+// CMPMServer::SetVpnToggleValuesL
+// -----------------------------------------------------------------------------
+//
+void CMPMServer::SetVpnToggleValuesL( const TBool aVpnPreferred,
+                                      const TUint32 /*aVpnIapId*/,
+                                      const TUint32 /*aSnapId*/ )
+    {
+    MPMLOGSTRING2("CMPMServer::SetVpnToggleValues, VPN connection preferred: %d",
+            aVpnPreferred)
+    if ( aVpnPreferred )
+        {
+        // Stop Internet connections, except if VPN user connection
+        // would not be made with current preferences when reconnecting.
+        for (TInt index = 0; index < iSessions.Count(); index++)
+            {
+            CMPMServerSession* session = iSessions[index];
+            TUint32 iapId = GetBMIap( session->ConnectionId() );
+            TUint32 snapId = GetBMSnap( session->ConnectionId() );
+            
+            if ( (session->ChooseBestIapCalled()) &&
+                 (!session->IapSelectionL()->MpmConnPref().MandateIap()) &&
+                 (session->AppUid() != KUidKmdServer) &&                 
+                 (!session->UserConnection()) &&                 
+                 iCommsDatAccess->IsInternetSnapL(iapId, snapId) )
+                {
+                // Stop connection.
+                MPMLOGSTRING2( "CMPMServer::SetVpnToggleValuesL: \
+ Disconnected Connection Id = 0x%x", session->ConnectionId() )            
+                session->ClientErrorNotificationL(KErrForceDisconnected);
+                }
+            }        
+        }
+    else
+        {
+        // Stop connections, which use VPN user connection.
+        for (TInt index = 0; index < iSessions.Count(); index++)
+            {
+            CMPMServerSession* session = iSessions[index];
+            if ( session->VpnUserConnectionUsed() )
+                {
+                session->SetVpnUserConnectionUsed( EFalse );                    
+                // Stop connection.
+                MPMLOGSTRING2( "CMPMServer::SetVpnToggleValuesL: \
+ Disconnected Connection Id = 0x%x", session->ConnectionId() )            
+                session->ClientErrorNotificationL(KErrForceDisconnected);
+                }
+            }
+        ASSERT( iVpnUserConnectionSessionCount == 0 );
+        }    
+    }
 
 // -----------------------------------------------------------------------------
 // CMPMServer::NewSessionL
@@ -854,6 +886,11 @@
     TInt index = iSessions.Find( aSession );
     if ( index != KErrNotFound )
         {
+        if ( Events() )
+            {
+            // Cancel WLAN scan request if one exists
+            TRAP_IGNORE( Events()->CancelScanL( iSessions[index] ) )
+            }
         iSessions.Remove( index );
         }
     }
@@ -881,7 +918,32 @@
     TCmUsageOfWlan usageOfWlan = CommsDatAccess()->ForcedRoamingL();
     if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew )
         {
-        StartForcedRoamingToWlanL( iapInfo );
+        if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
+            {
+            iConnMonIapInfo = aIapInfo;
+                
+            if ( iRoamingToWlanPeriodic )
+                {
+                iRoamingToWlanPeriodic->Cancel();
+                }
+            else
+                {
+                iRoamingToWlanPeriodic = CPeriodic::NewL( 
+                                                   CActive::EPriorityStandard );
+                }
+            // start periodic object that calls StartForcedRoamingToWlanL after 10s. 
+            // this handles the case when new wlan connection is 
+            // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP 
+            iRoamingToWlanPeriodic->Start( 
+                   TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
+                   TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
+                   TCallBack( StartForcedRoamingToConnectedWlanL, this ) );
+            }
+        else
+            {
+            StartForcedRoamingToWlanL( iapInfo );
+            }
+
         StartForcedRoamingFromWlanL( iapInfo );
         }
     
@@ -1336,18 +1398,6 @@
 #endif // _DEBUG
     }
 
-
-// -----------------------------------------------------------------------------
-// CMPMServer::DefaultConnection
-// -----------------------------------------------------------------------------
-//
-CMPMDefaultConnection* CMPMServer::DefaultConnection()
-    {
-    MPMLOGSTRING( "CMPMServer::DefaultConnection:\
- Default Connection" )
-    return iDefaultConnection;
-    }
-
 // -----------------------------------------------------------------------------
 // CMPMServer::StartedConnectionExists
 // -----------------------------------------------------------------------------
@@ -1382,22 +1432,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// CMPMServer::AppendWlanQueryQueueL
-// -----------------------------------------------------------------------------
-//
-void CMPMServer::AppendWlanQueryQueueL( CMPMWlanQueryDialog* aDlg )
-    {
-    if( aDlg )
-        {
-        iWlanQueryQueue->AppendL( aDlg );
-        }
-    else
-        {
-        MPMLOGSTRING( "CMPMServer::AppendWlanQueryQueueL argument NULL, Error" )
-        }
-    }
-
-// -----------------------------------------------------------------------------
 // CMPMServer::StopConnections
 // -----------------------------------------------------------------------------
 //
@@ -1446,12 +1480,11 @@
 void CMPMServer::StartForcedRoamingToWlanL( const TConnMonIapInfo& aIapInfo )
     {
     MPMLOGSTRING( "CMPMServer::StartForcedRoamingToWlan" )
-
-    // First check that there is no active wlan connection
-    if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
+    
+    // cancel the periodic object
+    if ( iRoamingToWlanPeriodic != NULL )
         {
-        // Wlan already active can't roam to it
-        return;
+        iRoamingToWlanPeriodic->Cancel();
         }
 
     // Copy all available wlan iap ids to own array
@@ -1511,6 +1544,20 @@
     CleanupStack::PopAndDestroy( &wlanIapIds );
     }
 
+
+// ---------------------------------------------------------------------------
+// CMPMServer::StartForcedRoamingToConnectedWlanL
+// ---------------------------------------------------------------------------
+//    
+TInt CMPMServer::StartForcedRoamingToConnectedWlanL( TAny* aUpdater )
+    {
+    MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedWlanL" );
+    static_cast<CMPMServer*>( aUpdater )->StartForcedRoamingToWlanL( 
+            static_cast<CMPMServer*>( aUpdater )->iConnMonIapInfo );
+    return 0;
+    }
+
+
 // -----------------------------------------------------------------------------
 // CMPMServer::StartForcedRoamingFromWlanL
 // -----------------------------------------------------------------------------
@@ -1782,6 +1829,126 @@
     stoppedIaps.Close();
     }
 
+// -----------------------------------------------------------------------------
+// CMPMServer::AddVpnUserConnectionSession
+// -----------------------------------------------------------------------------
+//
+void CMPMServer::AddVpnUserConnectionSession()
+    {
+    iVpnUserConnectionSessionCount++;
+    }
+
+// -----------------------------------------------------------------------------
+// CMPMServer::RemoveVpnUserConnectionSession
+// -----------------------------------------------------------------------------
+//
+void CMPMServer::RemoveVpnUserConnectionSession()
+    {    
+    ASSERT( iVpnUserConnectionSessionCount > 0 );
+    iVpnUserConnectionSessionCount--;
+    }
+
+// ---------------------------------------------------------------------------
+// CMPMServer::UseVpnUserConnection
+// Informs if VPN user connection is used with given MPM preferences and
+// application.
+// ---------------------------------------------------------------------------
+//
+TBool CMPMServer::UseVpnUserConnection( const TMpmConnPref aMpmConnPref,
+                                        const TUint32 aAppUid ) const
+    {    
+    if ( iMpmVpnToggleWatcher->IsVpnConnectionPreferred() &&
+         !aMpmConnPref.MandateIap() &&
+         aAppUid != KUidKmdServer &&
+         aAppUid != iMpmCsIdWatcher->ConnectScreenId() )
+        {
+        // VPN connection is preferred connection, connection preferences are
+        // not mandatet and client is not KMD server or Connect Screen.            
+        if ( aMpmConnPref.ConnType() == TMpmConnPref::EConnTypeDefault ||
+             aMpmConnPref.ConnType() == TMpmConnPref::EConnTypeImplicit )
+            {
+            // Default or implicit connection is requested.
+            // VPN user connection is used.
+            return ETrue;
+            }
+        else
+            {
+            // Explicit connection is requested.
+            TBool internetSnap(EFalse);    
+            TRAPD( err, internetSnap = iCommsDatAccess->IsInternetSnapL( aMpmConnPref.IapId(),
+                                                                         aMpmConnPref.SnapId() ) );
+            if ( err == KErrNone &&
+                 internetSnap )
+                {
+                // Connection belongs to Internet SNAP.
+                // VPN user connection is used.
+                return ETrue;
+                }
+            }
+        }
+    
+    // VPN user connection is not used.
+    return EFalse;    
+    }
+
+// -----------------------------------------------------------------------------
+// CMPMServer::PrepareVpnUserConnection
+// -----------------------------------------------------------------------------
+//
+TBool CMPMServer::PrepareVpnUserConnection( TMpmConnPref& aMpmConnPref )
+    {
+    // Get VPN IAP Id or SNAP Id, which is used for VPN user connection. 
+    TUint32 vpnIapId = iMpmVpnToggleWatcher->VpnIapId();
+    TUint32 snapId = iMpmVpnToggleWatcher->SnapId();
+
+    // Check first if SNAP Id is set, in which case VPN IAP Id is ignored.
+    if ( snapId != 0 )
+        {
+        TBool intranetSnap( EFalse );   
+        TRAPD( err , intranetSnap = 
+            iCommsDatAccess->IsIntranetSnapL( snapId ) );
+        if ( (err != KErrNone) ||
+             (!intranetSnap) )
+            {
+            // SNAP is not intranet SNAP.
+            // Reset VPN toggle values and continue without using VPN user
+            // connection.
+            MPMLOGSTRING3( "CMPMServer::PrepareVpnUserConnection failed, \
+SNAP Id=%d, err=%d", snapId, err );
+        
+            iMpmVpnToggleWatcher->ResetVpnToggleValues();        
+            return EFalse;
+            }        
+        aMpmConnPref.SetIapId( 0 );
+        aMpmConnPref.SetSnapId( snapId );               
+        }
+    else
+        {
+        // Validate that IAP is VPN IAP. 
+        TMPMBearerType bearerType = EMPMBearerTypeNone;
+        TRAPD( err, bearerType = iCommsDatAccess->GetBearerTypeL( vpnIapId ) );        
+        if ( (err != KErrNone) ||
+             (bearerType != EMPMBearerTypeVpn) )
+            {        
+            // IAP is not valid VPN IAP.
+            // Reset VPN toggle values and continue without using VPN user
+            // connection.
+            MPMLOGSTRING4( "CMPMServer::PrepareVpnUserConnection failed, \
+IAP Id=%d, err=%d, bearerType=%d", vpnIapId, err, bearerType );
+        
+            iMpmVpnToggleWatcher->ResetVpnToggleValues();
+            return EFalse;
+            }
+        aMpmConnPref.SetIapId( vpnIapId );
+        aMpmConnPref.SetSnapId( 0 );            
+        }
+   
+    aMpmConnPref.SetConnType( TMpmConnPref::EConnTypeExplicit );
+    
+    // VPN user connection will be activated.
+    return ETrue;        
+    }
+
 // ---------------------------------------------------------------------------
 // CMPMServer::UpdateOfflineMode
 // Offline watcher listens the offline mode and calls this when it's changed.
--- a/bearermanagement/mpm/src/mpmserversession.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmserversession.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -38,12 +38,10 @@
 #include "mpmcommsdataccess.h"
 #include "mpmserversession.h"
 #include "mpmconnmonevents.h"
-#include "mpmdisconnectdlg.h"
 #include "mpmconfirmdlgstarting.h"
 #include "mpmconfirmdlgroaming.h"
 #include "mpmlogger.h"
 #include "mpmpropertydef.h"
-#include "mpmdefaultconnection.h"
 #include "mpmiapselection.h"
 #include "mpmcsidwatcher.h"
 
@@ -70,12 +68,20 @@
 CMPMServerSession::CMPMServerSession(CMPMServer& aServer)
     : CSession2(), 
       iMyServer( aServer ),
-      iDisconnectDlg( NULL ),
       iConfirmDlgRoaming( NULL ),
+      iConnId( 0 ),
+      iNotifRequested( EFalse ),
+      iPreferredIAPRequested( EFalse ),
+      iOfflineFeatureSupported( EFalse ),
+      iEasyWlanIap( 0 ),
+      iAppUid( 0 ),
       iStoredIapInfo(),
       iIapSelection( NULL ),
       iMigrateState( EMigrateNone ),
-      iDisconnectDialogShown( EFalse )
+      iLastNotifiedIap( 0 ),
+      iMigrateIap( 0 ),
+      iUserConnection( 0 ),
+      iVpnUserConnectionUsed( EFalse )
     {
     }
 
@@ -90,7 +96,7 @@
     if ( !iMyServer.Events() )
         {
         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
-            *const_cast<CMPMServer*>( &iMyServer ), *this ));
+            *const_cast<CMPMServer*>( &iMyServer ) ) );
         }
 
     // Append session pointer to server
@@ -105,7 +111,6 @@
 //
 CMPMServerSession::~CMPMServerSession()
     {
-    delete iDisconnectDlg;
     delete iConfirmDlgRoaming;
     delete iIapSelection;
 
@@ -113,12 +118,19 @@
     // 
     iMyServer.RemoveSession( this );
 
-    if (UserConnection())
+    if (VpnUserConnectionUsed())
+        {
+        SetVpnUserConnectionUsed( EFalse );
+    
+    MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession -\
+ VPN user connection usage ended" )    
+        }
+    else if (UserConnection())
         {
         iMyServer.ClearUserConnection();
         ClearUserConnection();
         
-        MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
+        MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession -\
 User connection deactivated" )
         }   
 
@@ -421,8 +433,7 @@
         }
 
     // Store the Uid of the application to the member variable so 
-    // that it can be used to avoid DisconnectDialog popping up when 
-    // AlwaysOnline connection is being established.
+    // that it can be used when AlwaysOnline connection is being established.
     // 
     iAppUid = aMessage.Int2();
 
@@ -436,6 +447,20 @@
     MPMLOGSTRING3( "CMPMServerSession::HandleServerChooseIapL - iap %d \
 connType %d", mpmConnPref.IapId(), mpmConnPref.ConnType() )
 
+
+    if ( iMyServer.UseVpnUserConnection(mpmConnPref,
+                                        AppUid()) )
+        {
+        // VPN user connection needs to be used.
+        TBool prepareOk = iMyServer.PrepareVpnUserConnection( mpmConnPref );
+        if ( prepareOk )
+            {
+            SetVpnUserConnectionUsed( ETrue );
+            MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
+ VPN user connection used" )                    
+            }
+        }
+            
     iIapSelection->ChooseIapL( mpmConnPref );
 
     if ( iAppUid == iMyServer.CsIdWatcher()->ConnectScreenId() )
@@ -479,7 +504,7 @@
             
             // Cancel WLAN scan request if one exists
             //
-            TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ) )
+            TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
             
             if ( iIapSelection )
                 {
@@ -501,15 +526,8 @@
 
             // Cancel WLAN scan request if one exists
             //
-            TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ) )
-
-            if ( iDisconnectDlg )
-                {
-                MPMLOGSTRING( "CMPMServerSession::HandleServerCancelRequest: \
-removing dconn dlg" )
-                delete iDisconnectDlg;
-                iDisconnectDlg = NULL;
-                }
+            TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
+
             return;
             }
         case EMPMWaitNotification:
@@ -528,7 +546,7 @@
                 // TODO Change CancelScanL to non-leaving.
                 // Otherwise, nothing clever can be done here.
                 // And OOM may risk MPM stability.
-                TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ))
+                TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ))
                 iServerSortSNAPMessage.Complete( KErrCancel );
                 }
             break;
@@ -721,7 +739,14 @@
     //
     TConnectionId endId = aMessage.Int0();
 
-    if (UserConnection())
+    if (VpnUserConnectionUsed())
+        {
+        SetVpnUserConnectionUsed( EFalse );
+
+        MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
+ VPN user connection usage ended" )    
+        }
+    else if (UserConnection())
         {
         iMyServer.ClearUserConnection();
         ClearUserConnection();
@@ -810,21 +835,6 @@
         {
         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
         isConfirmFirst = ETrue;
-        
-        // iDisconnectDialogShown is set when disconnect dialog is shown.
-        // Before the disconnect dialog is shown, data usage confirmation
-        // dialog is already shown for the new PDP context. If you choose
-        // to disconnect the active PDP context then data usage dialog is
-        // shown again for the new context. So, set isConfirmFirst to
-        // False to avoid duplicate cellular confirm dialog
-        //
-        if ( iDisconnectDialogShown )
-            {
-            MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL  - False; Data \
-confirmation dialog already shown for this IAP" )
-            isConfirmFirst = EFalse;
-            iDisconnectDialogShown = EFalse;
-            }
         }
     else 
         {
@@ -963,10 +973,6 @@
 	    if( aError == KErrNone )
 	        {
 	        iMigrateState = EMigrateOfflineConfirmation;
-    	    if( IapSelectionL()->StartWlanQueryIfNeededL( iMigrateIap, ETrue ) )
-	            {
-	            return;
-                }
 	        }
 	    }
 	else if( iMigrateState == EMigrateOfflineConfirmation )
@@ -1390,20 +1396,7 @@
         ProcessErrorComplete( KErrNone, &error, &neededAction );
         return;
         }
-
-    // Show error popup if it's allowed per client request
-    // Don't show the pop up if error code is for disconnect dialog
-    //
-    if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
-            TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
-         !DisconnectDlgErrorCode( error ) )
-        {
-        // Note: Below function shows the discreet popup only if the error code
-        // belongs to the set of errors that are shown to the user.
-        // Otherwise the popup is not shown.
-        iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
-        }
-
+    
     // Read the Connection Id of the application
     // 
     TConnectionId connId = iProcessErrorMessage.Int1();
@@ -1419,6 +1412,25 @@
     //
     TUint32 snapId = iMyServer.GetBMSnap( connId );
 
+    // The popup is shown if the connection is not silent and the
+    // error is something else than a disconnect dialog error code.
+    // The popup is also shown if the connection is silent and the
+    // error is a disconnect dlg error, a background application 
+    // is not in question, a MMS IAP is not
+    // in question, and a started connection does not exist.
+    TBool silent = iIapSelection->MpmConnPref().NoteBehaviour() &
+                TExtendedConnPref::ENoteBehaviourConnDisableNotes;
+    if ( !silent && ( !DisconnectDlgErrorCode( error ) ||
+            ( !IsBackgroundApplication( iAppUid ) &&
+            !IsMMSIap( currentIap ) && 
+            iMyServer.StartedConnectionExists() != KErrNotFound ) ) )
+        {
+        // Note: Below function shows the discreet popup only if the error code
+        // belongs to the set of errors that are shown to the user.
+        // Otherwise the popup is not shown.
+        iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
+        }  
+
     TConnMonIapInfo availableIAPs;
     availableIAPs = GetAvailableIAPs();
 
@@ -1430,6 +1442,8 @@
     // 
     TConnectionState state;
     iMyServer.GetConnectionState( connId, state );
+    MPMLOGSTRING2(
+        "CMPMServerSession::HandleServerProcessErrorL - state %d", state )
 
     // We need to blacklist the presumed IAP too
     // 
@@ -1440,248 +1454,213 @@
     // 
     iMyServer.Events()->ResetIapConnInfo( currentIap );
 
-    // Check if IAP is reported by MMS
-    //
-    TBool isMMSIap = IsMMSIap( currentIap );
-    if ( isMMSIap )
-        {
-        MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
-        - DisconnectDialog is not started because of MMS reported IAP" )
-        }
-
     TInt* returnError( NULL );
-    if ( ( state == EStarting ) || ( state == ERoaming ) )
+    switch ( state )
         {
-        // Process error according to the fact that the connection 
-        // has not yet been started.
-        // 
-        if ( DisconnectDlgErrorCode( error ) &&
-             !IsBackgroundApplication( iAppUid ) &&
-             !isMMSIap && 
-             iIapSelection->MpmConnPref().DisconnectDialog() &&
-             iMyServer.StartedConnectionExists() != KErrNotFound )
-            {
-            // Start the Disconnect dialog
-            // 
-            MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
- - Start Disconnect dialog" )
-            iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this),
-                                                      error,
-                                                      *MyServer().DisconnectQueue() );
-            iDisconnectDialogShown = ETrue;
-            return;
-            }
-        else
-            {
-            MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
-Error not handled with disconnect dialog" )
-
-            if ( state == EStarting ) 
+        case EStarting: 
+            if ( ( snapId == 0 ) || ( error == KErrCancel ) )
                 {
-                if ( ( snapId == 0 ) || ( error == KErrCancel ) )
-                    {
-                    neededAction = EPropagateError;
-
-                    MPMLOGSTRING(
-                        "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to end the client connection with appropriate error code" )
-                    }
-                else
-                    {
-                    neededAction = EDoReselection;
-
-                    MPMLOGSTRING(
-                        "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to ignore error and do reselection" )
-
-                    iMyServer.HandleServerBlackListIap( connId, 
-                                                        currentIap, 
-                                                        ETemporary );
-                    if ( ( presumedIap != 0 ) && 
-                         ( presumedIap != currentIap ) )
-                        {
-                        iMyServer.HandleServerBlackListIap( connId, 
-                                                            presumedIap, 
-                                                            ETemporary );
-                        }
-                    }
+                neededAction = EPropagateError;
+
+                MPMLOGSTRING(
+                    "CMPMServerSession::HandleServerProcessErrorL - \
+                Tell BM to end the client connection with appropriate error code" )
                 }
-            else if ( state == ERoaming ) 
+            else
                 {
-                // ERoaming means commsfw stack is moving to new IAP and failed.
-                // Hence, MPM should mark to current iap as zero. 
-                //
-                iMyServer.ResetBMConnection( iConnId, currentIap, *this );
-                
-                // Notification will be sent with latest 
-                // availability info
-                //
-                iStoredIapInfo.ResetStoredIapInfo();
-
-                neededAction = EIgnoreError;
+                neededAction = EDoReselection;
+
+                MPMLOGSTRING(
+                    "CMPMServerSession::HandleServerProcessErrorL - \
+                Tell BM to ignore error and do reselection" )
 
                 iMyServer.HandleServerBlackListIap( connId, 
                                                     currentIap, 
                                                     ETemporary );
                 if ( ( presumedIap != 0 ) && 
-                     ( presumedIap != currentIap ) )
+                    ( presumedIap != currentIap ) )
                     {
                     iMyServer.HandleServerBlackListIap( connId, 
                                                         presumedIap, 
                                                         ETemporary );
                     }
-                TRAP( error, PrefIAPNotificationL( availableIAPs, 
+                }
+            // Error might be different from KErrNone if there 
+            // is no preferred IAP among the available IAPs.
+            // 
+            ProcessErrorComplete( KErrNone,
+                                  returnError,
+                                  &neededAction );
+            break;
+            
+        case ERoaming: 
+            // ERoaming means commsfw stack is moving to new IAP and failed.
+            // Hence, MPM should mark to current iap as zero. 
+            //
+            iMyServer.ResetBMConnection( iConnId, currentIap, *this );
+                
+            // Notification will be sent with latest 
+            // availability info
+            //
+            iStoredIapInfo.ResetStoredIapInfo();
+            
+            neededAction = EIgnoreError;
+
+            iMyServer.HandleServerBlackListIap( connId, 
+                                                currentIap, 
+                                                ETemporary );
+            if ( ( presumedIap != 0 ) && 
+                ( presumedIap != currentIap ) )
+                {
+                iMyServer.HandleServerBlackListIap( connId, 
+                                                    presumedIap, 
+                                                    ETemporary );
+                }
+            TRAP( error, PrefIAPNotificationL( availableIAPs, 
                                                    EBearerMan ) );
-                if ( error == KErrNotFound )
-                    {
-                    neededAction = EPropagateError;
-
-                    returnError = &error;
-
-                    TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
-                                                     EMPMMobilityErrorNotification ) );
-                    MPMLOGSTRING(
-                        "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to end the client connection with appropriate error code" )
-                    }
-                else
-                    {
-                    MPMLOGSTRING(
-                        "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to ignore error and let MPM notify application about preferred IAP" )
-                    }
+            if ( error == KErrNotFound )
+                {
+                neededAction = EPropagateError;
+
+                returnError = &error;
+
+                TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
+                                                EMPMMobilityErrorNotification ) );
+                MPMLOGSTRING(
+                    "CMPMServerSession::HandleServerProcessErrorL - \
+                Tell BM to end the client connection with appropriate error code" )
                 }
             else
                 {
-                MPMLOGSTRING2(
+                MPMLOGSTRING(
                     "CMPMServerSession::HandleServerProcessErrorL - \
-Unknown state %d", state )
+                Tell BM to ignore error and let MPM notify application about preferred IAP" )
                 }
-
+            
             // Error might be different from KErrNone if there 
             // is no preferred IAP among the available IAPs.
             // 
             ProcessErrorComplete( KErrNone,
                                   returnError,
                                   &neededAction );
-            return;
-            }
-        }
-    else if ( state == EStarted )
-        {
-        // Process error according to the fact that the connection 
-        // has already been started.
-        //         
-        if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) )
-            {
-            neededAction = EPropagateError;
-
-            MPMLOGSTRING(
-                "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to end the client connection with appropriate error code" )
-
-            // Send error notification. 
-            // Not sent if connection not registered
-            // 
-            TRAP_IGNORE( ErrorNotificationL( error,
-                                             EMPMMobilityErrorNotification ) )
-            }
-        else if ( iPreferredIAPRequested )
-            {
-            // IAP connection
-            //
-            if( snapId == 0 )
+            break;
+      
+        case EStarted:
+            // Process error according to the fact that the connection 
+            // has already been started.
+            // KErrConnectionTerminated is received when user disconnects
+            // connection from Settings/Connection mgr.
+            //         
+            if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated ) )
                 {
                 neededAction = EPropagateError;
-    
+
                 MPMLOGSTRING(
                     "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to end the client connection with appropriate error code" )
-
-                TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
-                                                 EMPMMobilityErrorNotification ) )
+                    Tell BM to end the client connection with appropriate error code" )
+
+                // Send error notification. 
+                // Not sent if connection not registered
+                // 
+                TRAP_IGNORE( ErrorNotificationL( error,
+                                             EMPMMobilityErrorNotification ) )
                 }
-            // SNAP connection
-            //
-            else
+            else if ( iPreferredIAPRequested )
                 {
-                // If this has been WLAN IAP and the SNAP contains 
-                // other WLAN IAPs, we need to perform WLAN scan before
-                // knowing the availability of those
+                // IAP connection
                 //
-                RArray<TUint> iapPath;
-                CleanupClosePushL( iapPath );
-
-                iMyServer.HandleServerBlackListIap( connId, 
-                                                    currentIap, 
-                                                    ETemporary );
-                if ( ( presumedIap != 0 ) && 
-                     ( presumedIap != currentIap ) )
+                if( snapId == 0 )
                     {
-                    iMyServer.HandleServerBlackListIap( connId, 
-                                                        presumedIap, 
-                                                        ETemporary );
-                    }
-
-                // current iap is WLAN
-                // 
-                if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
-                      iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
-                    {
-                    // perform WLAN scan 
-                    // message is completed in callback function 
-                    // ProcessErrorWlanScanCompletedL
-                    // 
-                    iMyServer.Events()->ScanWLANNetworksL( this, 
-                                                           ConnectionId(), 
-                                                           EWlanScanCallbackProcessErr );
-                    CleanupStack::PopAndDestroy( &iapPath );
-                    return;
-                    }
-
-                CleanupStack::PopAndDestroy( &iapPath );
-                neededAction = EIgnoreError;
-
-                TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
-                if ( err2 == KErrNotFound )
-                    {
-                    error = err2;
                     neededAction = EPropagateError;
+    
+                    MPMLOGSTRING(
+                        "CMPMServerSession::HandleServerProcessErrorL - \
+                        Tell BM to end the client connection with appropriate error code" )
 
                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
                                                      EMPMMobilityErrorNotification ) )
-                    MPMLOGSTRING(
-                        "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to end the client connection with appropriate error code" )   
                     }
+                // SNAP connection
+                //
                 else
                     {
-                    MPMLOGSTRING(
-                        "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to ignore error and let MPM notify application about preferred IAP" )
+                    // If this has been WLAN IAP and the SNAP contains 
+                    // other WLAN IAPs, we need to perform WLAN scan before
+                    // knowing the availability of those
+                    //
+                    RArray<TUint> iapPath;
+                    CleanupClosePushL( iapPath );
+
+                    iMyServer.HandleServerBlackListIap( connId, 
+                                                    currentIap, 
+                                                    ETemporary );
+                    if ( ( presumedIap != 0 ) && 
+                        ( presumedIap != currentIap ) )
+                        {
+                        iMyServer.HandleServerBlackListIap( connId, 
+                                                        presumedIap, 
+                                                        ETemporary );
+                        }
+
+                    // current iap is WLAN
+                    // 
+                    if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
+                        iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
+                        {
+                        // perform WLAN scan 
+                        // message is completed in callback function 
+                        // ProcessErrorWlanScanCompletedL
+                        // 
+                        iMyServer.Events()->ScanWLANNetworksL( this, 
+                                                           ConnectionId(), 
+                                                           EWlanScanCallbackProcessErr );
+                        CleanupStack::PopAndDestroy( &iapPath );
+                        return;
+                        }
+
+                    CleanupStack::PopAndDestroy( &iapPath );
+                    neededAction = EIgnoreError;
+
+                    TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
+                    if ( err2 == KErrNotFound )
+                        {
+                        error = err2;
+                        neededAction = EPropagateError;
+
+                        TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
+                                                         EMPMMobilityErrorNotification ) )
+                        MPMLOGSTRING(
+                            "CMPMServerSession::HandleServerProcessErrorL - \
+                            Tell BM to end the client connection with appropriate error code" )   
+                        }
+                    else
+                        {
+                        MPMLOGSTRING(
+                            "CMPMServerSession::HandleServerProcessErrorL - \
+                            Tell BM to ignore error and let MPM notify application about preferred IAP" )
+                        }
                     }
                 }
-            }
-        else
-            {
-            neededAction = EPropagateError;
-
-            MPMLOGSTRING(
-                "CMPMServerSession::HandleServerProcessErrorL - \
-Tell BM to end the client connection with appropriate error code" )
-
-            }
-        ProcessErrorComplete( KErrNone, &error, &neededAction );
-        
-        }
-    else
-        {
-        MPMLOGSTRING2(
-            "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
-            state )
-        ProcessErrorComplete( KErrCorrupt,
-                              NULL,
-                              NULL );
+            else
+                {
+                neededAction = EPropagateError;
+
+                MPMLOGSTRING(
+                    "CMPMServerSession::HandleServerProcessErrorL - \
+                    Tell BM to end the client connection with appropriate error code" )
+
+                }
+            ProcessErrorComplete( KErrNone, &error, &neededAction );
+            break;
+            
+        default:
+            MPMLOGSTRING2(
+                "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
+                state )
+            ProcessErrorComplete( KErrCorrupt,
+                                  NULL,
+                                  NULL );
+            break;
         }
     }
 
@@ -3314,17 +3293,19 @@
     // Show error popup if it's allowed per client request
     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
-            && ( aError != KErrNone ) )
+            && ( aError != KErrNone ) 
+			&& ( iIapSelection->MpmConnPref().SnapId() == 0 ) )
         {
         // Note: Below function shows the discreet popup only if the error code
         // belongs to the set of errors that are shown to the user.
         // Otherwise the popup is not shown.
         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( aError );
         }
-    else
+    else if ( aError == KErrNone )
         {
         if (!( iIapSelection->MpmConnPref().NoteBehaviour() &
-            TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
+            TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
+            ( IsMMSIap( aPolicyPref->IapId() ) == EFalse ) )
             {
             TBool connectionAlreadyActive =
                 MyServer().CheckIfStarted( aPolicyPref->IapId(), iConnId );
@@ -3345,9 +3326,6 @@
                                               TBMNeededAction* aNeededAction )
     {
     MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete aError = %d", aError )
-
-    delete iDisconnectDlg;
-    iDisconnectDlg = NULL;
     
     if ( !iProcessErrorMessage.IsNull() )
         {
@@ -3487,6 +3465,24 @@
     }
 
 // -----------------------------------------------------------------------------
+// CMPMServerSession::SetVpnUserConnectionUsed
+// -----------------------------------------------------------------------------
+//
+void CMPMServerSession::SetVpnUserConnectionUsed( const TBool aUseVpnUserConnection )
+    {
+    if ( aUseVpnUserConnection )
+        {
+        iVpnUserConnectionUsed = ETrue;
+        iMyServer.AddVpnUserConnectionSession();        
+        }
+    else 
+        {
+        iVpnUserConnectionUsed = EFalse;
+        iMyServer.RemoveVpnUserConnectionSession();        
+        }
+    }
+
+// -----------------------------------------------------------------------------
 // CMPMServerSession::IsWlanOnlyL
 // -----------------------------------------------------------------------------
 //
--- a/bearermanagement/mpm/src/mpmstarter.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/bearermanagement/mpm/src/mpmstarter.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -26,7 +26,6 @@
 #include "mpmstarter.h"
 #include "mpmserver.h"
 #include "mpmlogger.h"
-#include "mpmdefaultconnserver.h"
 
 // ============================= LOCAL FUNCTIONS ===============================
 
@@ -46,11 +45,6 @@
     // create the server
     CServer2* server = MPMStarter::CreateAndStartServerL();
     CleanupStack::PushL( server );
-       
-    // create default connection server
-    CServer2* server2 = MPMStarter::CreateDefaultConnServerL( 
-    static_cast<CMPMServer*> ( server ) );
-    CleanupStack::PushL( server2 );
 
     User::LeaveIfError( RThread::RenameMe( MPMStarter::ServerName() ) );
 
@@ -61,7 +55,6 @@
     CActiveScheduler::Start();
     //
     // Cleanup the server and scheduler
-    CleanupStack::PopAndDestroy( server2 );
     CleanupStack::PopAndDestroy( server );
     CleanupStack::PopAndDestroy( s );
     }
@@ -113,17 +106,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// MPMStarter::CreateDefaultConnServerL
-// create default connection server object
-// -----------------------------------------------------------------------------
-//
-CServer2* MPMStarter::CreateDefaultConnServerL( CMPMServer* aMPMServer )
-    {
-    MPMLOGSTRING( "MPMStarter::CreateDefaultConnServerL" )
-    return CMPMDefaultConnServer::NewL( aMPMServer );
-    }
-
-// -----------------------------------------------------------------------------
 // MPMStarter::ServerName
 // return server name
 // -----------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/src/mpmvpntogglewatcher.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,242 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Listen VPN toggle key changes in central repository.
+*
+*/
+
+#include <centralrepository.h>
+#include <mpmvpntoggleapi.h>
+#include "mpmlogger.h"
+#include "mpmvpntogglewatcher.h"
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CMpmVpnToggleWatcher::CMpmVpnToggleWatcher( MMpmVpnToggleWatcherNotify& aNotify )
+    : CActive( EPriorityStandard ),
+      iNotify( aNotify )
+    {
+    CActiveScheduler::Add( this );    
+    }
+
+
+// ---------------------------------------------------------------------------
+// Creates central repositor object
+// ---------------------------------------------------------------------------
+//
+void CMpmVpnToggleWatcher::ConstructL()
+    {
+    TRAPD(err, iRepository = CRepository::NewL( KMpmVpnToggleCenRepUid ));
+    if ( err == KErrNone )
+        {
+        StartL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Creates new object
+// ---------------------------------------------------------------------------
+//
+CMpmVpnToggleWatcher* CMpmVpnToggleWatcher::NewL( MMpmVpnToggleWatcherNotify& aNotify )
+    {
+    CMpmVpnToggleWatcher* self = new( ELeave ) CMpmVpnToggleWatcher(aNotify);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CMpmVpnToggleWatcher::~CMpmVpnToggleWatcher()
+    {    
+    Cancel();
+    delete iRepository;
+    }
+
+// ---------------------------------------------------------------------------
+// Order notification from changes
+// ---------------------------------------------------------------------------
+//
+void CMpmVpnToggleWatcher::StartL()
+    {
+    MPMLOGSTRING( "CMpmVpnToggleWatcher::StartL" )
+            
+    // Get the initial Connect screen ID from repository.
+    User::LeaveIfError( GetVpnToggleValues() );
+
+    // Request for notifications.
+    User::LeaveIfError( RequestNotifications() );
+    }
+
+// ---------------------------------------------------------------------------
+// Request notifications.
+// ---------------------------------------------------------------------------
+//
+TInt CMpmVpnToggleWatcher::RequestNotifications()
+    {
+    MPMLOGSTRING( "CMpmVpnToggleWatcher::RequestNotifications" )
+
+    TInt err = iRepository->NotifyRequest( KMpmVpnTogglePreferVpn, iStatus );
+        
+    if ( err == KErrNone )
+        {
+        SetActive();
+        }
+    else
+        {
+        MPMLOGSTRING2( "CMpmVpnToggleWatcher::RequestNotifications, ERROR: %d", err )
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// Get VPN toggle values.
+// ---------------------------------------------------------------------------
+//
+TInt CMpmVpnToggleWatcher::GetVpnToggleValues()
+    {
+    MPMLOGSTRING( "CMpmVpnToggleWatcher::GetVpnToggleValues" )
+            
+    // Get values from central repository    
+    TInt err = iRepository->Get( KMpmVpnTogglePreferVpn, iVpnConnectionPreferred );
+    if ( err != KErrNone )
+        {
+        MPMLOGSTRING2( "CMpmVpnToggleWatcher::GetVpnToggleValues, preferred value, ERROR: %d", err )    
+        return err;
+        }    
+    TInt value(0);    
+    err = iRepository->Get( KMpmVpnToggleIapId, value );
+    if ( err != KErrNone )
+        {
+        MPMLOGSTRING2( "CMpmVpnToggleWatcher::GetVpnToggleValues, IAP Id value, ERROR: %d", err )
+        return err;
+        }    
+    iVpnIapId = value;   
+    err = iRepository->Get( KMpmVpnToggleSnapId, value );
+    if ( err != KErrNone )
+        {
+        MPMLOGSTRING2( "CMpmVpnToggleWatcher::GetVpnToggleValues, SNAP Id value, ERROR: %d", err )
+        return err;
+        }
+    iSnapId = value;        
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Return VPN toggle value.
+// ---------------------------------------------------------------------------
+//
+TBool CMpmVpnToggleWatcher::IsVpnConnectionPreferred() const
+    {
+    return iVpnConnectionPreferred;
+    }
+
+// ---------------------------------------------------------------------------
+// Return VPN IAP Id.
+// ---------------------------------------------------------------------------
+//
+TUint32 CMpmVpnToggleWatcher::VpnIapId() const
+    {
+    return iVpnIapId;
+    }
+
+// ---------------------------------------------------------------------------
+// Return SNAP Id.
+// ---------------------------------------------------------------------------
+//
+TUint32 CMpmVpnToggleWatcher::SnapId() const
+    {
+    return iSnapId;
+    }
+
+// ---------------------------------------------------------------------------
+// Resets VPN toggle values.
+// ---------------------------------------------------------------------------
+//
+void CMpmVpnToggleWatcher::ResetVpnToggleValues()
+    {
+    // Cancel listening VPN toggle value change
+    Cancel();
+
+    // Reset values.
+    iVpnConnectionPreferred = EFalse;
+    iVpnIapId = 0;
+    iSnapId = 0;
+    
+    TInt err = iRepository->Set( KMpmVpnTogglePreferVpn, 0 );
+    if ( err == KErrNone ) 
+        {
+        err = iRepository->Set( KMpmVpnToggleIapId, 0 );
+        }
+    if ( err == KErrNone )
+        {
+        err = iRepository->Set( KMpmVpnToggleSnapId, 0 );
+        }
+    
+    MPMLOGSTRING2( "CMpmVpnToggleWatcher::ResetVpnToggleValues, ERROR: %d", err )
+    
+    // Restart listening VPN toggle value change
+    RequestNotifications();
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// When there is a change in VPN toggle key value, event is received in here
+// ---------------------------------------------------------------------------
+//
+void CMpmVpnToggleWatcher::RunL()
+    {            
+    if ( iStatus.Int() < KErrNone )
+        {
+        MPMLOGSTRING2("CMpmVpnToggleWatcher::RunL, status: 0x%08X", iStatus.Int())
+        iErrorCounter++;
+        if ( iErrorCounter > KMpmVpnToggleWatcherCenRepErrorThreshold )
+            {
+            MPMLOGSTRING2("Over %d consecutive errors, stopping notifications permanently.",
+                    KMpmVpnToggleWatcherCenRepErrorThreshold)
+            return;
+            }
+        // Else: Error occured but counter not expired. Proceed.
+        RequestNotifications();
+        }
+    else
+        {
+        // Notification is received ok => Reset the counter.
+        iErrorCounter = 0;
+    
+        RequestNotifications();
+        
+        // Get values from central repository
+        GetVpnToggleValues();
+        
+        // Notify values.
+        TRAP_IGNORE( iNotify.SetVpnToggleValuesL( iVpnConnectionPreferred,
+                                                  iVpnIapId,
+                                                  iSnapId ) );        
+        }    
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Cancel outstanding request
+// ---------------------------------------------------------------------------
+//
+void CMpmVpnToggleWatcher::DoCancel()
+    {
+    iRepository->NotifyCancel( KMpmVpnTogglePreferVpn );
+    }
--- a/bearermanagement/mpm/src/mpmwlanquerydialog.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,271 +0,0 @@
-/*
-* Copyright (c) 2008 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Handles displaying wlan dialogs
-*
-*/
-
-
-#include <wlanmgmtcommon.h>
-#include <e32std.h>
-#include <utf.h>
-#include <cmpluginwlandef.h>
-#include <ctsydomainpskeys.h>
-
-#include "mpmwlanquerydialog.h"
-#include "mpmiapselection.h"
-#include "mpmconnmonevents.h"
-#include "mpmlogger.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::CMPMWlanQueryDialog
-// ---------------------------------------------------------------------------
-//
-CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection&  aIapSelection,
-                                          TUint32            aWlanIapId )
-  : CActive( CActive::EPriorityStandard ),
-    iIapSelection( aIapSelection ),
-    iWlanQueryState( EOffline ),
-    iWlanIapId( aWlanIapId ),
-    iOverrideStatus( KErrNone )    
-    {
-    CActiveScheduler::Add( this );
-    }
-    
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::ConstructL
-// ---------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::ConstructL()
-    {
-    User::LeaveIfError(iNotifier.Connect());
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::NewL
-// ---------------------------------------------------------------------------
-//
-CMPMWlanQueryDialog* CMPMWlanQueryDialog::NewL( CMPMIapSelection&  aSession,
-                                                TUint32            aWlanIapElementId )
-    {
-    CMPMWlanQueryDialog* self = new( ELeave ) CMPMWlanQueryDialog( aSession,
-                                                                   aWlanIapElementId );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::~CMPMWlanQueryDialog
-// ---------------------------------------------------------------------------
-//
-CMPMWlanQueryDialog::~CMPMWlanQueryDialog()
-    {
-    MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog enters" )
-
-    // Check if this dialog instance was not started but only added to the queue
-    if ( iIapSelection.Session()->MyServer().FirstInWlanQueryQueue() != this )
-        {
-        MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog, not a active delete" )
-
-        // Close notifier
-        iNotifier.Close();
-        
-        // We're not first in the queue, thus we can just delete.
-        // But remember the pointer in the array.
-        iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this );
-        MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog exits (break)" )
-        return;
-        }
-
-    // Cancel previous dialogs if any.
-    Cancel();
-
-    // Close notifier
-    iNotifier.Close();
-
-    // Remove self from the queue
-    iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this );
-
-    // Start the next query
-    CMPMWlanQueryDialog* dlg = iIapSelection.Session()->MyServer().FirstInWlanQueryQueue();
-    if ( dlg )
-        {
-        MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog starts new dialog" )
-        dlg->OfferInformation( iStatus.Int() );
-        // In destructor we cannot let the query leave
-        TRAPD( err, dlg->StartWlanQueryL(); )
-        if ( err != KErrNone )
-            {
-            MPMLOGSTRING2( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog caught Leave %d, executing RunError()", err )
-            dlg->RunError( err );
-            }
-        }
-
-    MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog exits" )
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::DoCancel
-// ---------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::DoCancel()
-    {
-    MPMLOGSTRING2( "CMPMWlanQueryDialog::DoCancel state %d", iWlanQueryState )
-    if ( iWlanQueryState == EOffline )
-        {
-        iNotifier.CancelNotifier( KUidCOfflineWlanNoteDlg );
-        }
-    }
-    
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::RunL
-// ---------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::RunL()
-    {
-    MPMLOGSTRING3( "CMPMWlanQueryDialog::RunL status %d state %d", 
-                   iStatus.Int(), 
-                   iWlanQueryState )
-
-    if( iWlanQueryState == EOffline )
-        {
-        if( iStatus.Int() == KErrNone )
-            {
-            iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse(
-                    EOfflineResponseYes );
-            }
-        else if ( iStatus.Int() == KErrCancel )
-            {
-            iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse(
-                    EOfflineResponseNo );
-            MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", 
-                           iStatus.Int() )
-            }
-        else
-            {
-            MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", 
-                           iStatus.Int() )
-            }
-        }
-    // if an error was given through OfferInformation() -call we abort the execution.
-    //
-    else if ( iOverrideStatus != KErrNone )
-        {
-        MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus )
-        iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId );
-        }
-    else
-        {
-		MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL, unknown state: %d", iWlanQueryState )
-        User::Leave( KErrCancel );
-        }
-        
-    iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId );
-    
-    iWlanIapId = 0;
-    }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::RunError
-// ---------------------------------------------------------------------------
-//
-TInt CMPMWlanQueryDialog::RunError( TInt aError )
-    {
-    MPMLOGSTRING2( "CMPMWlanQueryDialog::RunError failed with %d", aError )
-    iIapSelection.ChooseIapComplete( aError, NULL );    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CMPMWlanQueryDialog::StartWlanQueryL
-// -----------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::StartWlanQueryL()
-    {
-    MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery" )
-    
-    TUint32 activeWlanIap = iIapSelection.Session()->MyServer().IsWlanConnectionStartedL( 
-        iIapSelection.Session()->MyServer().CommsDatAccess() );
-
-    // Get EmergencyCallInfo via Publish & Subscribe
-    // 
-    TInt emergencyCallEstablished( 0 );
-    RProperty::Get( KPSUidCtsyEmergencyCallInfo, 
-                    KCTSYEmergencyCallInfo, 
-                    emergencyCallEstablished );  
-    MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery KCTSYEmergencyCallInfo = %d", 
-                   emergencyCallEstablished )
-
-    // Get note behaviour setting
-    TUint32 noteBehaviour( 0 );
-    noteBehaviour = iIapSelection.MpmConnPref().NoteBehaviour();
-    MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery noteBehaviour = %d", noteBehaviour )
-    
-    if( !emergencyCallEstablished && 
-        iIapSelection.Session()->MyServer().IsPhoneOffline() && 
-        !activeWlanIap && 
-        iIapSelection.Session()->MyServer().OfflineWlanQueryResponse() != EOfflineResponseYes &&
-        iOverrideStatus == KErrNone )
-        {
-        if ( noteBehaviour & TExtendedConnPref::ENoteBehaviourConnDisableQueries )
-            {
-            MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery offline note query not shown due to disabled queries" )
-            iIapSelection.UserWlanSelectionDoneL( KErrPermissionDenied, iWlanIapId );
-            }
-        else
-            {
-            MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery, starting offline note" )            
-            iWlanQueryState = EOffline;
-            iNotifier.StartNotifierAndGetResponse( iStatus, 
-                                                   KUidCOfflineWlanNoteDlg, 
-                                                   KNullDesC8(), 
-                                                   iOfflineReply );
-            SetActive();
-            }
-        }
-    else
-        {
-        MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery no wlan dialog to show" )
-        iIapSelection.UserWlanSelectionDoneL( KErrNone, iWlanIapId );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CMPMWlanQueryDialog::OfferInformation
-// -----------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::OfferInformation( TInt aDialogStatus )
-    {
-    TOfflineWlanQueryResponse offlineResponse =
-            iIapSelection.Session()->MyServer().OfflineWlanQueryResponse();
-    if ( offlineResponse != EOfflineResponseUndefined )
-        {
-        MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: offline response %d",
-                       iIapSelection.Session()->ConnectionId(),
-                       offlineResponse )
-        iOverrideStatus = aDialogStatus;
-        }
-
-#ifdef _LOG
-    else
-        {
-        MPMLOGSTRING( "CMPMWlanQueryDialog::OfferInformation, information not taken." ) 
-        }
-#endif 
-    }
-
--- a/bearermanagement/mpm/src/rmpmdefaultconnection.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Client interface to MPM Default Connection server
-*
-*/
-
-#include "rmpmdefaultconnection.h"
-#include "mpmcommon.h"
-#include "mpmlogger.h"
-
-_LIT( KPanicCategory, "MPM Default Connection Client" );
-
-// ---------------------------------------------------------------------------
-// RMPMDefaultConnection::Connect
-// Creates connection to server
-// ---------------------------------------------------------------------------
-//
-EXPORT_C TInt RMPMDefaultConnection::Connect()
-    {
-    MPMLOGSTRING("RMPMDefaultConnection::Connect" )
-    TInt r( KErrNone );
-    if( !iClientConnected ) 
-        {
-        MPMLOGSTRING("RMPMDefaultConnection::Connect: Connecting to server")
-        r = CreateSession( KMPMDefaultConnectionServerName, Version(), KNumDefConnMessageSlots );
-        if(r == KErrNone)
-            {
-            iClientConnected = ETrue;
-            }
-        else
-            {
-            MPMLOGSTRING2("RMPMDefaultConnection::Connect: \
-Error occurred %d", r )
-            Close();
-            }
-        }
-    return r;
-    }
-
-// ---------------------------------------------------------------------------
-// RMPMDefaultConnection::Close
-// Closes connection to server
-// ---------------------------------------------------------------------------
-//
-EXPORT_C void RMPMDefaultConnection::Close()
-    {
-    MPMLOGSTRING("RMPMDefaultConnection::Close" )
-    RSessionBase::Close();
-    iClientConnected = EFalse;
-    }
-
-// ---------------------------------------------------------------------------
-// RMPMDefaultConnection::SetDefaultIAP
-// Sets IAP to be used as default connection
-// ---------------------------------------------------------------------------
-//
-EXPORT_C TInt RMPMDefaultConnection::SetDefaultIAP( TInt aIapId )
-    {
-    __ASSERT_ALWAYS( iClientConnected, 
-                     User::Panic( KPanicCategory, 
-                                  ERMPMPanicClientNotConnected ) );
-    MPMLOGSTRING("RMPMDefaultConnection::SetDefaultIAP" )
-    return SendReceive( EMPMDefaultConnectionSetDefaultIap, TIpcArgs( aIapId ) );
-    }
-
-// ---------------------------------------------------------------------------
-//RMPMDefaultConnection::ClearDefaultIAP
-// Clears IAP from being used as default connection
-// ---------------------------------------------------------------------------
-//
-EXPORT_C TInt RMPMDefaultConnection::ClearDefaultIAP()
-    {
-    __ASSERT_ALWAYS( iClientConnected, 
-                     User::Panic( KPanicCategory, 
-                                  ERMPMPanicClientNotConnected ) );
-    MPMLOGSTRING("RMPMDefaultConnection::ClearDefaultIAP" )
-    return SendReceive( EMPMDefaultConnectionClearDefaultIap );
-    }
-
-// -----------------------------------------------------------------------------
-// RMPMDefaultConnection::Version
-// Returns version number
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TVersion RMPMDefaultConnection::Version() const
-    {
-    MPMLOGSTRING("RMPMDefaultConnection::Version" )
-    return TVersion(KMPMServerMajorVersionNumber,
-                    KMPMServerMinorVersionNumber,
-                    KMPMServerBuildVersionNumber);
-    }
--- a/cmmanager/cmapplsettingsui/res/cmradiodialog.docml	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmapplsettingsui/res/cmradiodialog.docml	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
+<hbdocument version="1.1">
     <object name="okAction" type="HbAction">
         <string name="role" value="HbDialog:primaryAction"/>
         <string locid="txt_common_button_ok" name="text"/>
@@ -14,10 +14,10 @@
         <bool name="backgroundFaded" value="TRUE"/>
         <integer name="timeout" value="0"/>
         <enums name="dismissPolicy" value="NoDismiss"/>
-        <ref object="okAction" role="HbDialog:primaryAction"/>
-        <ref object="cancelAction" role="HbDialog:secondaryAction"/>
+        <ref object="okAction" role="HbWidget:addAction"/>
+        <ref object="cancelAction" role="HbWidget:addAction"/>
     </widget>
-    <metadata activeUIState="Common ui state" display="QHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
     </metadata>
 </hbdocument>
--- a/cmmanager/cmmgr/cmmapi/group/cmmapi.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/group/cmmapi.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,6 @@
 */
 
 
-#include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
 
 TARGET          cmmanager.dll
@@ -26,10 +25,10 @@
 CAPABILITY      CAP_GENERAL_DLL
 VENDORID VID_DEFAULT
 
-SOURCEPATH      ../../cmmcommon/Src
+SOURCEPATH      ../../cmmcommon/src
 SOURCE          cmmclistatic.cpp
 
-SOURCEPATH      ../Src
+SOURCEPATH      ../src
 SOURCE          cmmanager.cpp
 SOURCE          cmmanagerapi.cpp
 SOURCE          cmdestination.cpp
@@ -56,12 +55,10 @@
 
 LIBRARY         euser.lib
 
-DEBUGLIBRARY    flogger.lib
-
 #if defined(EABI)
 DEFFILE ../EABI/CmManager_prot_setup.def
 #elif defined( WINSCW )
-DEFFILE ../BWinsCw/CmManager_prot_setup.def
+DEFFILE ../BWinsCw/CmManager_prot_setup.DEF
 #elif defined( WINS )
 DEFFILE ../BWins/CmManager_prot_setup.def
 #else
--- a/cmmanager/cmmgr/cmmapi/inc/cmdestinationapi.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/inc/cmdestinationapi.h	Thu Jul 22 16:37:38 2010 +0100
@@ -85,6 +85,8 @@
     TInt IsConnected( TBool& aResult );
     TInt IsHidden( TBool& aResult );
     TInt IsEqual( const TInt aHandle, TBool& aResult );
+    TInt GetIcon( HBufC* aBuffer );
+    TInt SetIcon( const TDesC& aValue );
 
 private:
     // True when a subsession is established to the server.
--- a/cmmanager/cmmgr/cmmapi/inc/cmdestinationwrapper.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/inc/cmdestinationwrapper.h	Thu Jul 22 16:37:38 2010 +0100
@@ -90,6 +90,8 @@
     TInt IsConnected( TBool& aResult );
     TInt IsHidden( TBool& aResult );
     TInt IsEqual( const TInt aHandle, TBool& aResult );
+    TInt GetIcon( HBufC* aBuffer );
+    TInt SetIcon( const TDesC& aValue);
 
     TBool SessionConnected();
     void CloseSession();
--- a/cmmanager/cmmgr/cmmapi/inc/cmmanagerapi.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/inc/cmmanagerapi.h	Thu Jul 22 16:37:38 2010 +0100
@@ -56,13 +56,13 @@
             CCmDestinationWrapper* aDestinationWrapper );
     TInt RemoveDestinationWrapper(
             CCmDestinationWrapper* aDestinationWrapper );
-    CCmDestinationWrapper* GetDestinationWrapperL( const TInt& aHandle );
+    CCmDestinationWrapper* GetDestinationWrapperL( const TInt aHandle );
 
     TInt StoreConnMethodWrapper(
             CCmConnectionMethodWrapper* aConnMethodWrapper );
     TInt RemoveConnMethodWrapper(
             CCmConnectionMethodWrapper* aConnMethodWrapper );
-    CCmConnectionMethodWrapper* GetConnMethodWrapperL( const TInt& aHandle );
+    CCmConnectionMethodWrapper* GetConnMethodWrapperL( const TInt aHandle );
 
     TInt GetBearerInfoInt(
             const TUint32 aBearerType,
@@ -132,6 +132,7 @@
             const TInt aConnMethodHandle );
     TInt RemoveAllReferences(
             const TInt aConnMethodHandle );
+    TInt GetUncategorizedIcon( HBufC* aBuffer );
 
 private:
     // Array of destination handles opened through this session.
--- a/cmmanager/cmmgr/cmmapi/src/cmconnectionmethod.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmconnectionmethod.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -178,7 +178,6 @@
     else
         {
         CleanupStack::PopAndDestroy( buffer );
-        buffer = NULL;
         buffer = KNullDesC().AllocL();
         }
 
@@ -211,7 +210,6 @@
     else
         {
         CleanupStack::PopAndDestroy( buffer8 );
-        buffer8 = NULL;
         buffer8 = KNullDesC8().AllocL();
         }
 
@@ -495,21 +493,44 @@
     {
     OstTraceFunctionEntry0( RCMCONNECTIONMETHOD_GETICONL_ENTRY );
 
-    User::Leave( KErrNotSupported );
+    if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() )
+        {
+        User::Leave( KErrBadHandle );
+        }
+
+    HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
+    TInt err = iCmConnectionMethodWrapper->GetStringAttribute( CMManager::ECmBearerIcon, buffer );
+    User::LeaveIfError( err );
+
+    if ( buffer->Length() > 0 )
+        {
+        CleanupStack::Pop( buffer );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( buffer );
+        buffer = KNullDesC().AllocL();
+        }
 
     OstTraceFunctionExit0( RCMCONNECTIONMETHOD_GETICONL_EXIT );
-    return NULL;
+    return buffer;
     }
 
 //-----------------------------------------------------------------------------
 //  RCmConnectionMethod::SetIconL()
 //-----------------------------------------------------------------------------
 //
-EXPORT_C void RCmConnectionMethod::SetIconL( const TDesC& /*aIcon*/ )
+EXPORT_C void RCmConnectionMethod::SetIconL( const TDesC& aIcon )
     {
     OstTraceFunctionEntry0( RCMCONNECTIONMETHOD_SETICONL_ENTRY );
 
-    User::Leave( KErrNotSupported );
+    if ( !iCmConnectionMethodWrapper || !iCmConnectionMethodWrapper->SessionConnected() )
+        {
+        User::Leave( KErrBadHandle );
+        }
+
+    TInt err = iCmConnectionMethodWrapper->SetStringAttribute( CMManager::ECmBearerIcon, aIcon );
+    User::LeaveIfError( err );
 
     OstTraceFunctionExit0( RCMCONNECTIONMETHOD_SETICONL_EXIT );
     }
--- a/cmmanager/cmmgr/cmmapi/src/cmconnectionmethodwrapper.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmconnectionmethodwrapper.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -87,7 +87,10 @@
         }
 
     iCmManagerApi = aCmManagerApi;
-    iCmConnectionMethodApi.ConnectAndGetConnMethodWithIdL( *aCmManagerApi, aIapId, aExistingHandle );
+    iCmConnectionMethodApi.ConnectAndGetConnMethodWithIdL(
+            *aCmManagerApi,
+            aIapId,
+            aExistingHandle );
     if ( !aExistingHandle )
         {
         iCmManagerApi->StoreConnMethodWrapper( this );
--- a/cmmanager/cmmgr/cmmapi/src/cmdestination.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmdestination.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -151,7 +151,8 @@
     if ( existingHandle )
         {
         CleanupStack::PopAndDestroy( cmWrapper );
-        cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL( existingHandle );
+        cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL(
+                existingHandle );
         cmWrapper->IncreaseReferenceCounter();
         }
     else
@@ -796,21 +797,44 @@
     {
     OstTraceFunctionEntry0( RCMDESTINATION_GETICONL_ENTRY );
 
-    User::Leave( KErrNotSupported );
+    if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
+        {
+        User::Leave( KErrBadHandle );
+        }
+
+    HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
+    TInt err = iCmDestinationWrapper->GetIcon( buffer );
+    User::LeaveIfError( err );
+
+    if ( buffer->Length() > 0 )
+        {
+        CleanupStack::Pop( buffer );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( buffer );
+        buffer = KNullDesC().AllocL();
+        }
 
     OstTraceFunctionExit0( RCMDESTINATION_GETICONL_EXIT );
-    return NULL;
+    return buffer;
     }
 
 //-----------------------------------------------------------------------------
 //  RCmDestination::SetIconL()
 //-----------------------------------------------------------------------------
 //
-EXPORT_C void RCmDestination::SetIconL( const TDesC& /*aIcon*/ )
+EXPORT_C void RCmDestination::SetIconL( const TDesC& aIcon )
     {
     OstTraceFunctionEntry0( RCMDESTINATION_SETICONL_ENTRY );
 
-    User::Leave( KErrNotSupported );
+    if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
+        {
+        User::Leave( KErrBadHandle );
+        }
+
+    TInt err = iCmDestinationWrapper->SetIcon( aIcon );
+    User::LeaveIfError( err );
 
     OstTraceFunctionExit0( RCMDESTINATION_SETICONL_EXIT );
     }
--- a/cmmanager/cmmgr/cmmapi/src/cmdestinationapi.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmdestinationapi.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -413,4 +413,27 @@
     return err;
     }
 
+TInt RCmDestinationApi::GetIcon( HBufC* aBuffer )
+    {
+    OstTraceFunctionEntry0( RCMDESTINATIONAPI_GETICON_ENTRY );
+
+    TPtr descriptor( aBuffer->Des() );
+    TIpcArgs args( &descriptor );
+    TInt err = SendReceive( EDestGetIcon, args );
+
+    OstTraceFunctionExit0( RCMDESTINATIONAPI_GETICON_EXIT );
+    return err;
+    }
+
+TInt RCmDestinationApi::SetIcon( const TDesC& aValue )
+    {
+    OstTraceFunctionEntry0( RCMDESTINATIONAPI_SETICON_ENTRY );
+
+    TIpcArgs args( &aValue );
+    TInt err = SendReceive( EDestSetIcon, args );
+
+    OstTraceFunctionExit0( RCMDESTINATIONAPI_SETICON_EXIT );
+    return err;
+    }
+
 // End of file
--- a/cmmanager/cmmgr/cmmapi/src/cmdestinationext.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmdestinationext.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -151,7 +151,8 @@
     if ( existingHandle )
         {
         CleanupStack::PopAndDestroy( cmWrapper );
-        cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL( existingHandle );
+        cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL(
+                existingHandle );
         cmWrapper->IncreaseReferenceCounter();
         }
     else
@@ -191,7 +192,8 @@
     if ( existingHandle )
         {
         CleanupStack::PopAndDestroy( cmWrapper );
-        cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL( existingHandle );
+        cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL(
+                existingHandle );
         cmWrapper->IncreaseReferenceCounter();
         }
     else
--- a/cmmanager/cmmgr/cmmapi/src/cmdestinationwrapper.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmdestinationwrapper.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -145,7 +145,10 @@
         }
 
     iCmManagerApi = aCmManagerApi;
-    iCmDestinationApi.ConnectAndGetConnMethodAsEmbeddedDestL( *aCmManagerApi, aConnMethodHandle, aExistingHandle );
+    iCmDestinationApi.ConnectAndGetConnMethodAsEmbeddedDestL(
+            *aCmManagerApi,
+            aConnMethodHandle,
+            aExistingHandle );
     if ( !aExistingHandle )
         {
         iCmManagerApi->StoreDestinationWrapper( this );
@@ -386,6 +389,26 @@
     return err;
     }
 
+TInt CCmDestinationWrapper::GetIcon( HBufC* aBuffer )
+    {
+    OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETICON_ENTRY );
+
+    TInt err = iCmDestinationApi.GetIcon( aBuffer );
+
+    OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETICON_EXIT );
+    return err;
+    }
+
+TInt CCmDestinationWrapper::SetIcon( const TDesC& aValue)
+    {
+    OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_SETICON_ENTRY );
+
+    TInt err = iCmDestinationApi.SetIcon( aValue );
+
+    OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_SETICON_EXIT );
+    return err;
+    }
+
 TBool CCmDestinationWrapper::SessionConnected()
     {
     return iCmDestinationApi.SessionConnected();
--- a/cmmanager/cmmgr/cmmapi/src/cmmanager.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmmanager.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -210,7 +210,6 @@
     else
         {
         CleanupStack::PopAndDestroy( buffer );
-        buffer = NULL;
         buffer = KNullDesC().AllocL();
         }
 
@@ -244,7 +243,6 @@
     else
         {
         CleanupStack::PopAndDestroy( buffer8 );
-        buffer8 = NULL;
         buffer8 = KNullDesC8().AllocL();
         }
 
@@ -324,7 +322,6 @@
     else
         {
         CleanupStack::PopAndDestroy( buffer );
-        buffer = NULL;
         buffer = KNullDesC().AllocL();
         }
 
@@ -358,7 +355,6 @@
     else
         {
         CleanupStack::PopAndDestroy( buffer8 );
-        buffer8 = NULL;
         buffer8 = KNullDesC8().AllocL();
         }
 
@@ -909,10 +905,27 @@
     {
     OstTraceFunctionEntry0( RCMMANAGER_GETUNCATEGORIZEDICONL_ENTRY );
 
-    User::Leave( KErrNotSupported );
+    if ( !iCmManagerApi )
+        {
+        User::Leave( KErrBadHandle );
+        }
+
+    HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
+    TInt err = iCmManagerApi->GetUncategorizedIcon( buffer );
+    User::LeaveIfError( err );
+
+    if ( buffer->Length() > 0 )
+        {
+        CleanupStack::Pop( buffer );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( buffer );
+        buffer = KNullDesC().AllocL();
+        }
 
     OstTraceFunctionExit0( RCMMANAGER_GETUNCATEGORIZEDICONL_EXIT );
-    return NULL;
+    return buffer;
     }
 
 // End of file
--- a/cmmanager/cmmgr/cmmapi/src/cmmanagerapi.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/src/cmmanagerapi.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -73,12 +73,8 @@
                 return err;
                 }
             err = TCmManagerLauncher::LaunchServer(
-                    KCmmServer,
                     KCmmServerFile,
-                    KCmmUid3,
-                    KCmmServerInitHeapSize,
-                    KCmmServerMaxHeapSize,
-                    KCmmServerStackSize );
+                    KCmmUid3 );
 
             if ( err != KErrNone && err != KErrAlreadyExists )
                 {
@@ -165,7 +161,7 @@
 // RCmManagerApi::GetDestinationWrapperL()
 //-----------------------------------------------------------------------------
 //
-CCmDestinationWrapper* RCmManagerApi::GetDestinationWrapperL( const TInt& aHandle )
+CCmDestinationWrapper* RCmManagerApi::GetDestinationWrapperL( const TInt aHandle )
     {
     OstTraceFunctionEntry0( RCMMANAGERAPI_GETDESTINATIONWRAPPER_ENTRY );
 
@@ -229,7 +225,7 @@
 // RCmManagerApi::GetConnMethodWrapperL()
 //-----------------------------------------------------------------------------
 //
-CCmConnectionMethodWrapper* RCmManagerApi::GetConnMethodWrapperL( const TInt& aHandle )
+CCmConnectionMethodWrapper* RCmManagerApi::GetConnMethodWrapperL( const TInt aHandle )
     {
     OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNMETHODWRAPPER_ENTRY );
 
@@ -954,4 +950,20 @@
     return err;
     }
 
+//-----------------------------------------------------------------------------
+// RCmManagerApi::GetUncategorizedIcon()
+//-----------------------------------------------------------------------------
+//
+TInt RCmManagerApi::GetUncategorizedIcon( HBufC* aBuffer )
+    {
+    OstTraceFunctionEntry0( RCMMANAGERAPI_GETUNCATEGORIZEDICON_ENTRY );
+
+    TPtr descriptor( aBuffer->Des() );
+    TIpcArgs args( &descriptor );
+    TInt err = SendReceive( ECmmGetUncategorizedIcon, args );
+
+    OstTraceFunctionExit0( RCMMANAGERAPI_GETUNCATEGORIZEDICON_EXIT );
+    return err;
+    }
+
 // End of file
--- a/cmmanager/cmmgr/cmmapi/traces/OstTraceDefinitions.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmapi/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef __OSTTRACEDEFINITIONS_H__
 #define __OSTTRACEDEFINITIONS_H__
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
--- a/cmmanager/cmmgr/cmmcommon/inc/cmmclistatic.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmcommon/inc/cmmclistatic.h	Thu Jul 22 16:37:38 2010 +0100
@@ -22,9 +22,6 @@
 
 #include <e32std.h>
 
-const TUint KCmmDefaultMinHeapSize =  0x1000;  //  4K
-const TUint KCmmDefaultMaxHeapSize = 0x10000;  // 64K
-
 const TInt KCmmDefaultMessageSlots = 2;
 
 _LIT( KCmManagerStartupMutex, "CmManagerStartupMutex" );
@@ -37,12 +34,8 @@
     {
 public:
     static TInt LaunchServer(
-            const TDesC& aServerName,
             const TDesC& aServerFileName,
-            const TUid& aServerUid3,
-            const TUint aWinsMinHeapSize = KCmmDefaultMinHeapSize,
-            const TUint aWinsMaxHeapSize = KCmmDefaultMaxHeapSize,
-            const TUint aWinsStackSize = KDefaultStackSize );
+            const TUid& aServerUid3 );
 
 private:
     static TBool ServerStartupLock( RMutex& mutex, TInt& err );
--- a/cmmanager/cmmgr/cmmcommon/inc/cmmserverdefs.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmcommon/inc/cmmserverdefs.h	Thu Jul 22 16:37:38 2010 +0100
@@ -35,23 +35,11 @@
  */
 _LIT( KCmmServerFile, "cmmserver" );
 
-const TInt KCmmServerStackSize    = 0x5000; //TODO, check if really used (in common code).
-const TInt KCmmServerInitHeapSize = 0x1000; //TODO, check if really used (in common code).
-const TInt KCmmServerMaxHeapSize  = 0x1000000; //TODO, check if really used (in common code).
-
 const TInt KBitsInOneByte = 8;
 const TInt KBitsInTwoBytes = 16;
 const TInt KBitsInThreeBytes = 24;
 
 /**
- * The server version. A version must be specified when creating a session with
- * the server.
- */
-const TUint KCmmServerMajorVersionNumber = 0; //TODO, check if really used (in common code).
-const TUint KCmmServerMinorVersionNumber = 1; //TODO, check if really used (in common code).
-const TUint KCmmServerBuildVersionNumber = 1; //TODO, check if really used (in common code).
-
-/**
  * Amount of time in microseconds that the server will wait before shutting
  * down, after last client has gone.
  */
@@ -73,7 +61,7 @@
 const TUint32 KCmmDestIdIntervalMin = 0x1000;
 const TUint32 KCmmDestIdIntervalMax = 0x1100;
 
-const TInt KCmmStringLengthMax = 1024; //TODO, need to find out correct value here
+const TInt KCmmStringLengthMax = 1024; //TODO, need to find out correct value here. 1024 is correct, but can that be received from commsdat?
 
 const TUint32 KTemporaryIdCounterStart = 32768;
 
@@ -81,20 +69,20 @@
 const TInt KBitsToShiftDestProtectionLevel = 28;
 
 
-// Buffer size for initial connection method query
+// Buffer size for initial connection method query.
 const TInt KCmmConnMethodAmountNormal = 64; //TODO, Check value
-// Maximum theoretical amount of connection methods
+// Maximum theoretical amount of connection methods.
 const TInt KCmmConnMethodAmountMax = 256;
 
-// Buffer size for initial destination query
+// Buffer size for initial destination query.
 const TInt KCmmDestAmountNormal = 32;
-// Maximum theoretical amount of connection methods
+// Maximum theoretical amount of connection methods.
 const TInt KCmmDestAmountMax = 256;
 
-// Buffer size for supported bearers query
+// Buffer size for supported bearers query.
 const TInt KCmmBearerAmountNormal = 10;
 
-// Buffer size for bearer priority array query, first attempt
+// Buffer size for bearer priority array query, first attempt.
 const TInt KCmmDefaultBearerPriorityArraySize = 256;
 
 // iPriority:           2 16-bit values,
@@ -102,8 +90,14 @@
 // iServiceType length: 1 16-bit value.
 const TInt KCmmBearerPriorityHeaderLength = 5;
 
+// Name of the icon for the 'uncategorized' group. This group is a UI-construct
+// that is used to group all uncategorized IAPs together.
+_LIT( KCmmUncategorizedIconName, "qtg_small_favorite" );
 
-// Opcodes used in message passing between client and server
+// Minimum disk space required for writing operations.
+const TInt KMinimumDiskSpace = 8192;
+
+// Opcodes used in message passing between client and server.
 enum TCmmRequests
     {
     ECmmGetBearerInfoInt                     = 0,
@@ -117,19 +111,20 @@
     ECmmReadDefaultConnection                = 8,
     ECmmReadGeneralConnectionSettings        = 9,
     ECmmGetSupportedBearers                  = 10,
+    ECmmGetUncategorizedIcon                 = 11,
 
-    ECmmGetConnMethodInfoInt                 = 11,
-    ECmmGetConnMethodInfoBool                = 12,
-    ECmmGetConnMethodInfoString              = 13,
-    ECmmGetConnMethodInfoString8             = 14,
+    ECmmGetConnMethodInfoInt                 = 12,
+    ECmmGetConnMethodInfoBool                = 13,
+    ECmmGetConnMethodInfoString              = 14,
+    ECmmGetConnMethodInfoString8             = 15,
 
-    ECmmUpdateBearerPriorityArray            = 15,
-    ECmmWriteDefaultConnection               = 16,
-    ECmmWriteGeneralConnectionSettings       = 17,
-    ECmmCopyConnMethod                       = 18,
-    ECmmMoveConnMethod                       = 19,
-    ECmmRemoveConnMethod                     = 20,
-    ECmmRemoveAllReferences                  = 21, // Connection method becomes uncategorized.
+    ECmmUpdateBearerPriorityArray            = 16,
+    ECmmWriteDefaultConnection               = 17,
+    ECmmWriteGeneralConnectionSettings       = 18,
+    ECmmCopyConnMethod                       = 19,
+    ECmmMoveConnMethod                       = 20,
+    ECmmRemoveConnMethod                     = 21,
+    ECmmRemoveAllReferences                  = 22, // Connection method becomes uncategorized.
 
     // RCmDestination starts from 100
     EDestGetDestination                      = 100,
@@ -145,21 +140,23 @@
     EDestIsHidden                            = 110,
     EDestIsEqual                             = 111,
     EDestGetEmbeddedDestination              = 112,
+    EDestGetIcon                             = 113,
 
-    EDestCreateDestinationWithName           = 113,
-    EDestCreateDestinationWithNameAndId      = 114,
-    EDestIsConnected                         = 115,
-    EDestAddConnMethod                       = 116,
-    EDestAddEmbeddedDestination              = 117,
-    EDestDeleteConnMethod                    = 118,
-    EDestRemoveConnMethod                    = 119,
-    EDestModifyPriority                      = 120,
-    EDestSetName                             = 121,
-    EDestSetMetadata                         = 122,
-    EDestSetProtection                       = 123,
-    EDestSetHidden                           = 124,
-    EDestUpdate                              = 125,
-    EDestDelete                              = 126,
+    EDestCreateDestinationWithName           = 114,
+    EDestCreateDestinationWithNameAndId      = 115,
+    EDestIsConnected                         = 116,
+    EDestAddConnMethod                       = 117,
+    EDestAddEmbeddedDestination              = 118,
+    EDestDeleteConnMethod                    = 119,
+    EDestRemoveConnMethod                    = 120,
+    EDestModifyPriority                      = 121,
+    EDestSetName                             = 122,
+    EDestSetMetadata                         = 123,
+    EDestSetProtection                       = 124,
+    EDestSetHidden                           = 125,
+    EDestUpdate                              = 126,
+    EDestDelete                              = 127,
+    EDestSetIcon                             = 128,
 
     //RCmConnectionMethod starts from 200
     ECMGetConnMethodWithId                   = 200,
--- a/cmmanager/cmmgr/cmmcommon/src/cmmclistatic.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmcommon/src/cmmclistatic.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -28,12 +28,8 @@
  * otherwise one of the system wide error codes.
  */
 TInt TCmManagerLauncher::LaunchServer(
-        const TDesC& aServerName,
         const TDesC& aServerFileName,
-        const TUid& aServerUid3,
-        const TUint aWinsMinHeapSize,
-        const TUint aWinsMaxHeapSize,
-        const TUint aWinsStackSize )
+        const TUid& aServerUid3 )
     {
     RMutex mutex;
     TInt err( KErrNone );
@@ -55,10 +51,6 @@
 
     RProcess server;
     err = server.Create( aServerFileName, KNullDesC, serverUid );
-    (void)aServerName;
-    (void)aWinsMinHeapSize;
-    (void)aWinsMaxHeapSize;
-    (void)aWinsStackSize;
 
     if ( err != KErrNone )
         {
--- a/cmmanager/cmmgr/cmmpluginbase/BWinsCw/cmmpluginbaseu.def	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/BWinsCw/cmmpluginbaseu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -24,4 +24,5 @@
 	?UpdateL@CCmPluginBaseEng@@UAEXPAVCCmClientPluginInstance@@@Z @ 23 NONAME ; void CCmPluginBaseEng::UpdateL(class CCmClientPluginInstance *)
 	?GetStringAttributeL@CCmPluginBaseEng@@QAEPAVHBufC16@@KPAVCCmClientPluginInstance@@@Z @ 24 NONAME ; class HBufC16 * CCmPluginBaseEng::GetStringAttributeL(unsigned long, class CCmClientPluginInstance *)
 	??1CCmClientPluginInstance@@UAE@XZ @ 25 NONAME ; CCmClientPluginInstance::~CCmClientPluginInstance(void)
+	?CopyRecordFieldsL@CCmPluginBaseEng@@IAEXAAVCMDBRecordBase@CommsDat@@0@Z @ 26 NONAME ; void CCmPluginBaseEng::CopyRecordFieldsL(class CommsDat::CMDBRecordBase &, class CommsDat::CMDBRecordBase &)
 
--- a/cmmanager/cmmgr/cmmpluginbase/EABI/cmmpluginbaseu.def	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/EABI/cmmpluginbaseu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -31,4 +31,5 @@
 	_ZNK16CCmPluginBaseEng30GetGenericTableIdsToBeObservedER6RArrayImE @ 30 NONAME
 	_ZTI16CCmPluginBaseEng @ 31 NONAME
 	_ZTV16CCmPluginBaseEng @ 32 NONAME
+	_ZN16CCmPluginBaseEng17CopyRecordFieldsLERN8CommsDat14CMDBRecordBaseES2_ @ 33 NONAME
 
--- a/cmmanager/cmmgr/cmmpluginbase/group/cmmpluginbase.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/group/cmmpluginbase.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,6 @@
 *
 */
 
-#include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
 
 TARGET          cmmpluginbase.dll
@@ -33,6 +32,7 @@
 // Component specific internal headers
 USERINCLUDE     ../inc
 USERINCLUDE     ../../cmmserver/inc
+USERINCLUDE     ../../cmmcommon/inc
 USERINCLUDE     ../traces
 
 // ADO specific internal headers
--- a/cmmanager/cmmgr/cmmpluginbase/inc/ccmpluginbaseengtextresolver.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/inc/ccmpluginbaseengtextresolver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -22,7 +22,7 @@
 /**
  *  Utility class for resolving localised text.
  */
-class CCmPluginBaseEngTextResolver
+NONSHARABLE_CLASS( CCmPluginBaseEngTextResolver ) : public CBase
     {
 public:    
     /**
--- a/cmmanager/cmmgr/cmmpluginbase/src/ccmpluginbaseeng.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/src/ccmpluginbaseeng.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,8 +20,10 @@
 #include <datamobilitycommsdattypes.h>
 #include <cmpluginbaseeng.h>
 #include <cmpsettingsconsts.h>
-#include <FeatMgr.h>
-
+#include <featmgr.h>
+#include <cmpluginembdestinationdef.h>
+
+#include "cmmserverdefs.h"
 #include "ccmpluginbaseengtextresolver.h"
 
 #include "OstTraceDefinitions.h"
@@ -33,7 +35,7 @@
 using namespace CMManager;
 using namespace CommsDat;
 
-const TInt KApMaxConnNameLength = 30;
+const TInt KApMaxConnNameLength = 50;
 _LIT( KFormatPostfix, "%02d" );
 _LIT( KFormatLargePostfix, "%d" );
 _LIT( KFormatNameWithPostfix, "%S(%S)" );
@@ -94,8 +96,6 @@
 //
 void CCmClientPluginInstance::ConstructL()
     {
-    OstTraceFunctionEntry0( CCMCLIENTPLUGININSTANCE_CONSTRUCTL_ENTRY );
-    OstTraceFunctionExit0( CCMCLIENTPLUGININSTANCE_CONSTRUCTL_EXIT );
     }
 
 
@@ -138,7 +138,7 @@
     iWapIPBearerRecord = NULL;
     iMetaDataRecord = NULL;
 
-    iIapId = 0;
+    iCmId = 0;
     iMetadataTableId = 0;
     iLocationEnabled = EFalse;
 
@@ -153,7 +153,7 @@
     {
     OstTraceFunctionEntry0( DUP1_CCMPLUGINBASEENG_CCMPLUGINBASEENG_ENTRY );
 
-    iIapId = 0;
+    iCmId = 0;
     delete iIapRecord; iIapRecord = NULL;
     delete iProxyRecord; iProxyRecord = NULL;
     delete iServiceRecord; iServiceRecord = NULL;
@@ -299,7 +299,7 @@
 
     ResetBearerRecords();
 
-    LoadL( iIapId );
+    LoadL( iCmId );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_RELOAD_EXIT );
     }
@@ -312,6 +312,13 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_LOADL_ENTRY );
 
+    // Embedded destination must be handled separately first.
+    if ( aIapId > KCmDefaultDestinationAPTagId )
+        {
+        iCmId = aIapId;
+        return;
+        }
+
     DoLoadL( aIapId );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_LOADL_EXIT );
@@ -325,37 +332,37 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_CREATENEWL_ENTRY );
 
-    if ( iIapId )
+    if ( iCmId )
         // we already have IAP id ->
         {
         User::Leave( KErrAlreadyExists );
         }
 
-    // optional record is disabled in default
+    // Optional record, disabled by default.
     iLocationEnabled = EFalse;
 
-    // create mandatory records
-    iIapRecord = static_cast<CCDIAPRecord *>
-                          (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
-    iNetworkRecord = static_cast<CCDNetworkRecord *>
-                          (CCDRecordBase::RecordFactoryL(KCDTIdNetworkRecord));
-    iProxyRecord = static_cast<CCDProxiesRecord *>
-                  (CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord));
+    // Create mandatory records.
+    iIapRecord = static_cast<CCDIAPRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+    iNetworkRecord = static_cast<CCDNetworkRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdNetworkRecord ) );
+    iProxyRecord = static_cast<CCDProxiesRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
     NewWapRecordL();
     iWapIPBearerRecord->iWAPGatewayAddress.SetL( KDefWapGatewayIpAddress );
 
     iMetaDataRecord = NewMetadataRecordL( ETrue );
 
-    // call plugin to create its own records
+    // Call plugin to create its own records.
     CreateServiceRecordL();
 
-    // Update iaprecord servicetype name
+    // Update iaprecord servicetype name.
     HBufC* servicetypeName( NULL );
     ServiceRecordNameLC( servicetypeName );
     iIapRecord->iServiceType.SetL( *servicetypeName );
     CleanupStack::PopAndDestroy( servicetypeName );
 
-    // Update iaprecord bearertype name
+    // Update iaprecord bearertype name.
     HBufC* bearerTypeName( NULL );
     BearerRecordNameLC( bearerTypeName );
     iIapRecord->iBearerType.SetL( *bearerTypeName );
@@ -365,10 +372,10 @@
 
     EnableProxyL( EFalse );
 
-    _LIT(KDefaultConnNameTextId, "txt_occ_setlabel_connection_name_val_connection");
+    _LIT( KDefaultConnNameTextId, "txt_occ_setlabel_connection_name_val_connection" );
     HBufC* resolvedText( NULL );
     resolvedText = CCmPluginBaseEngTextResolver::ResolveTextL( KDefaultConnNameTextId );
-    if ( resolvedText != NULL )
+    if ( resolvedText )
         {
         SetDefaultNameL( *resolvedText );
         }
@@ -385,7 +392,7 @@
     if ( aCmId != 0 )
         {
         iIapRecord->SetRecordId( aCmId );
-        iIapId = 0;
+        iCmId = 0;
         }
     else
         {
@@ -400,23 +407,19 @@
 // ---------------------------------------------------------------------------
 //
 EXPORT_C CCmPluginBaseEng* CCmPluginBaseEng::CreateCopyL(
-    CCmClientPluginInstance* /*aClientPluginInstance*/ )
+        CCmClientPluginInstance* /*aClientPluginInstance*/ )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_CREATECOPYL_ENTRY );
 
     TCmPluginInitParam params( iSession );
-
     CCmPluginBaseEng* copyInst = CreateInstanceL( params );
     CleanupStack::PushL( copyInst );
 
     PrepareToCopyDataL( copyInst );
-
     CopyDataL( copyInst );
-
     CleanupStack::Pop( copyInst );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_CREATECOPYL_EXIT );
-
     return copyInst;
     }
 
@@ -427,7 +430,7 @@
 EXPORT_C void CCmPluginBaseEng::GetGenericTableIdsToBeObserved(
         RArray<TUint32>& aTableIdArray ) const
     {
-    // Service and bearer records should be added by plugins
+    // Service and bearer records should be added by plugins.
 
     aTableIdArray.Append( KCDTIdIAPRecord );
     aTableIdArray.Append( KCDTIdWAPAccessPointRecord );
@@ -460,17 +463,17 @@
 
     CopyRecordDataL( KIapRecordIndex, aCopyInstance );
 
-    // Ensure that iap's name is set by the rules(Naming Method)
-    SetNameL( iIapRecord->iRecordName.GetL(),
-              aCopyInstance->iIapRecord,
-              aCopyInstance->iNamingMethod );
+    // Ensure that IAP's name is set by the rules (Naming Method).
+    SetNameL(
+            iIapRecord->iRecordName.GetL(),
+            aCopyInstance->iIapRecord,
+            aCopyInstance->iNamingMethod );
 
     CopyRecordDataL( KServiceRecordIndex, aCopyInstance );
     CopyRecordDataL( KNetworkRecordIndex, aCopyInstance );
     CopyRecordDataL( KWAPAPRecordIndex, aCopyInstance );
     CopyRecordDataL( KWAPBearerRecordIndex, aCopyInstance );
     CopyRecordDataL( KMetaDataRecordIndex, aCopyInstance );
-    CopyRecordDataL( KLocationRecordIndex, aCopyInstance );
     CopyRecordDataL( KProxyRecordIndex, aCopyInstance );
 
     CopyBearerRecordsL( aCopyInstance );
@@ -492,55 +495,63 @@
         {
         case KIapRecordIndex:
             {
-            aCopyInstance->iIapRecord = static_cast<CCDIAPRecord*>(
-                    CCDRecordBase::CreateCopyRecordL( *iIapRecord ) );
+            CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+                    CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+            CleanupStack::PushL( iapRecord );
+            CopyRecordFieldsL( *iIapRecord, *iapRecord );
+            CleanupStack::Pop( iapRecord );
+            aCopyInstance->iIapRecord = iapRecord;
             }
             break;
         case KServiceRecordIndex:
             {
             aCopyInstance->iServiceRecord = CopyServiceRecordL();
+            // The name of the service record copy is changed during update
+            // process, in PrepareToUpdateRecordsL()-method.
             }
             break;
         case KNetworkRecordIndex:
             {
-            aCopyInstance->iNetworkRecord = static_cast<CCDNetworkRecord*>(
-                    CCDRecordBase::CreateCopyRecordL( *iNetworkRecord ) );
+            CCDNetworkRecord* networkRecord = static_cast<CCDNetworkRecord*>(
+                    CCDRecordBase::RecordFactoryL( KCDTIdNetworkRecord ) );
+            CleanupStack::PushL( networkRecord );
+            CopyRecordFieldsL( *iNetworkRecord, *networkRecord );
+            CleanupStack::Pop( networkRecord );
+            aCopyInstance->iNetworkRecord = networkRecord;
             }
             break;
         case KWAPAPRecordIndex:
             {
             aCopyInstance->iWapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
-                    CCDRecordBase::CreateCopyRecordL( *iWapAPRecord ) );
+                    CCDRecordBase::CreateCopyRecordL( *iWapAPRecord ) );//TODO, convert to generic copy
             }
             break;
         case KWAPBearerRecordIndex:
             {
             aCopyInstance->iWapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
-                    CCDRecordBase::CreateCopyRecordL( *iWapIPBearerRecord ) );
+                    CCDRecordBase::CreateCopyRecordL( *iWapIPBearerRecord ) );//TODO, convert to generic copy
             }
             break;
         case KMetaDataRecordIndex:
             {
-            aCopyInstance->iMetaDataRecord =
+            CCDIAPMetadataRecord* metadataRecord =
                     new( ELeave ) CCDIAPMetadataRecord( iMetadataTableId );
-            aCopyInstance->iMetaDataRecord->iIAP = IAPRecordElementId();
-            aCopyInstance->iMetaDataRecord->iMetadata.SetL( iMetaDataRecord->iMetadata );
-            aCopyInstance->iMetaDataRecord->iSeamlessness.SetL( iMetaDataRecord->iSeamlessness );
-            }
-            break;
-        case KLocationRecordIndex:
-            {
-            aCopyInstance->iWapIPBearerRecord =
-                    static_cast<CCDWAPIPBearerRecord*>
-                        ( CCDRecordBase::CreateCopyRecordL( *iWapIPBearerRecord ) );
+            CleanupStack::PushL( metadataRecord );
+            CopyRecordFieldsL( *iMetaDataRecord, *metadataRecord );
+            CleanupStack::Pop( metadataRecord );
+            aCopyInstance->iMetaDataRecord = metadataRecord;
             }
             break;
         case KProxyRecordIndex:
             {
             if ( iProxyRecord )
                 {
-                aCopyInstance->iProxyRecord = static_cast<CCDProxiesRecord*>(
-                        CCDRecordBase::CreateCopyRecordL( *iProxyRecord ) );
+                CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
+                CleanupStack::PushL( proxyRecord );
+                CopyRecordFieldsL( *iProxyRecord, *proxyRecord );
+                CleanupStack::Pop( proxyRecord );
+                aCopyInstance->iProxyRecord = proxyRecord;
                 }
             }
             break;
@@ -555,6 +566,89 @@
     }
 
 // ---------------------------------------------------------------------------
+// Copies the values and attributes of all fields from aSource-record into
+// aDestination record. Does not copy the record element ID. Also, does not
+// touch any field in aDestination-record that is NULL in aSource-record.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CCmPluginBaseEng::CopyRecordFieldsL(
+        CommsDat::CMDBRecordBase& aSource,
+        CommsDat::CMDBRecordBase& aDestination )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINBASEENG_COPYRECORDFIELDSL_ENTRY );
+
+    const SRecordTypeInfo* recordInfo = aSource.GetRecordInfo();
+    if ( !recordInfo )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    CMDBElement* ptrSource( NULL );
+    CMDBElement* ptrDest( NULL );
+
+    while ( recordInfo && recordInfo->iTypeId != 0 )
+        {
+        ptrSource = aSource.GetFieldByIdL( recordInfo->iTypeId );
+        ptrDest = aDestination.GetFieldByIdL( recordInfo->iTypeId );
+
+        // Make sure we see only basic type info. Masks out any additional info
+        // on links (CommsDat internal stuff).
+        switch ( recordInfo->iValType & 0x000000ff )
+            {
+            case CommsDat::EInt:
+            case CommsDat::EBool:
+                {
+                if ( !( ptrSource->IsNull() ) )
+                    {
+                    static_cast<CMDBField<TInt>&>( *ptrDest ).SetL(
+                            static_cast<CMDBField<TInt>&>( *ptrSource ) );
+                    }
+                }
+                break;
+            case CommsDat::EUint32:
+            case CommsDat::ELink:
+                {
+                if ( !( ptrSource->IsNull() ) )
+                    {
+                    static_cast<CMDBField<TUint32>&>( *ptrDest ).SetL(
+                            static_cast<CMDBField<TUint32>&>( *ptrSource ) );
+                    }
+                }
+                break;
+            case CommsDat::EDesC8:
+                {
+                if ( !( ptrSource->IsNull() ) )
+                    {
+                    static_cast<CMDBField<TDesC8>&>( *ptrDest ).SetL(
+                            static_cast<CMDBField<TDesC8>&>( *ptrSource ) );
+                    }
+                }
+                break;
+            case CommsDat::EText:
+            case CommsDat::EMedText:
+            case CommsDat::ELongText:
+                {
+                if ( !( ptrSource->IsNull() ) )
+                    {
+                    static_cast<CMDBField<TDesC>&>( *ptrDest ).SetL(
+                            static_cast<CMDBField<TDesC>&>( *ptrSource ) );
+                    }
+                }
+                break;
+            default:
+                {
+                User::Leave( KErrCorrupt );
+                }
+                break;
+            }
+        ptrDest->SetAttributes( ptrSource->Attributes() );
+        recordInfo++;
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINBASEENG_COPYRECORDFIELDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
 // CCmPluginBaseEng::DoLoadL
 // ---------------------------------------------------------------------------
 //
@@ -568,7 +662,6 @@
     LoadWapRecordL();
     LoadMetadataRecordL();
     LoadNetworkRecordL();
-    LoadLocationRecordL();
 
     // This is a connectionmethodinfo instance, that has no
     // service and proxy setting.
@@ -605,15 +698,15 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_LOADIAPRECORDL_ENTRY );
 
-    iIapId = aIapId;
-
-    // Load IAP record
-    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>(
+    iCmId = aIapId;
+
+    // Load IAP record.
+    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord*>(
             CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
 
     CleanupStack::PushL( iapRecord );
 
-    iapRecord->SetRecordId( iIapId );
+    iapRecord->SetRecordId( iCmId );
     iapRecord->LoadL( iSession );
 
     CleanupStack::Pop( iapRecord );
@@ -630,19 +723,18 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_LOADPROXYSETTINGL_ENTRY );
 
-    // Load Proxy record
+    // Load Proxy record.
     CMDBRecordSet<CCDProxiesRecord>* proxieRS =
             new( ELeave ) CMDBRecordSet<CCDProxiesRecord>( KCDTIdProxiesRecord );
     CleanupStack::PushL(proxieRS);
 
-    // Now try to find the linked proxy record
-    // create new record
-    CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord *>(
+    // Now try to find the linked proxy record.
+    // Create new record.
+    CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
             CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
-
     CleanupStack::PushL( proxyRecord );
 
-    // Prime record
+    // Prime record.
     TPtrC serviceType( iIapRecord->iServiceType );
     proxyRecord->iServiceType.SetL( serviceType );
     proxieRS->iRecords.AppendL( proxyRecord ); // Ownership transfered.
@@ -653,18 +745,18 @@
     if ( proxieRS->FindL(iSession) )
         {
         TInt i( 0 );
-        while( i < proxieRS->iRecords.Count() )
+        while ( i < proxieRS->iRecords.Count() )
             // Now that we have a list of services with the proper service type
             // search for our proxy record and remove it from the array,
             // then destroy the array.
             {
             CCDProxiesRecord* proxyRecord = (*proxieRS)[i];
 
-            // Compare the record id of these 2 services
+            // Compare the record id of these 2 services.
             if ( TUint32( proxyRecord->iService ) == TUint32( iIapRecord->iService ) )
                 {
                 iProxyRecord = proxyRecord;
-                // Take ownership of this record
+                // Take ownership of this record.
                 proxieRS->iRecords.Remove( i );
                 break;
                 }
@@ -726,27 +818,6 @@
 void CCmPluginBaseEng::LoadLocationRecordL()
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_LOADLOCATIONSETTINGL_ENTRY );
-
-    CCDLocationRecord* locationRecord = static_cast<CCDLocationRecord*>
-                         (CCDRecordBase::RecordFactoryL(KCDTIdLocationRecord));
-
-    CleanupStack::PushL( locationRecord );
-
-    locationRecord->SetRecordId( iIapRecord->iLocation );
-    if ( locationRecord->FindL(iSession) )
-        {
-        iLocationEnabled = ETrue;
-
-        iLocationRecord = locationRecord;
-
-        CleanupStack::Pop( locationRecord );
-        }
-    else
-        {
-        iLocationEnabled = EFalse;
-
-        CleanupStack::PopAndDestroy( locationRecord );
-        }
     OstTraceFunctionExit0( CCMPLUGINBASEENG_LOADLOCATIONSETTINGL_EXIT );
     }
 
@@ -755,24 +826,28 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginBaseEng::PrepareToUpdateRecordsL(
-    CCmClientPluginInstance* aClientPluginInstance )
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_PREPARETOUPDATERECORDSL_ENTRY );
 
-    // Set the record attributes to bearer specific records
-    CCDIAPRecord* iapRecord =
-       static_cast<CCDIAPRecord*>( aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+    //TODO, Add null checks for mandatory generic record pointers.
+    //
+
+    // Set the record attributes to bearer specific records.
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
 
     for ( TInt i = 0; i < aClientPluginInstance->iBearerSpecRecordArray.Count(); i++ )
         {
-        CCDRecordBase* record =
-                static_cast<CCDRecordBase*>( aClientPluginInstance->iBearerSpecRecordArray[i] );
+        CCDRecordBase* record = static_cast<CCDRecordBase*>(
+                aClientPluginInstance->iBearerSpecRecordArray[i] );
 
         CopyAttributes( iapRecord, record );
         }
 
-    PreparePluginToUpdateRecordsL( aClientPluginInstance->iGenRecordArray,
-                                   aClientPluginInstance->iBearerSpecRecordArray );
+    PreparePluginToUpdateRecordsL(
+            aClientPluginInstance->iGenRecordArray,
+            aClientPluginInstance->iBearerSpecRecordArray );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_PREPARETOUPDATERECORDSL_EXIT );
     }
@@ -782,16 +857,16 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginBaseEng::UpdateIAPRecordL(
-    CCmClientPluginInstance* aClientPluginInstance )
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_UPDATEIAPRECORDL_ENTRY );
 
-    CCDIAPRecord* iapRecord =
-       static_cast<CCDIAPRecord*>( aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
-
-    if ( iIapId == 0 )
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+
+    if ( iCmId == 0 )
         {
-        // Otherwise predefined iapid
+        // Otherwise predefined iapid.
         if ( !iIapRecord->RecordId() )
             {
             iIapRecord->SetRecordId( KCDNewRecordRequest );
@@ -814,50 +889,44 @@
 
         iIapRecord->iNetwork = iNetworkRecord->RecordId();
 
-        if ( iLocationRecord )
-            {
-            iIapRecord->iLocation = iLocationRecord->RecordId();
-            }
-        else
-            {
-            iIapRecord->iLocation = GetLocationIdL();
-            }
+        iIapRecord->iLocation = GetLocationIdL();
 
         CopyAttributes( iapRecord, iIapRecord );
         CheckIfNameModifiedL( iapRecord, iIapRecord );
 
         iIapRecord->StoreL( iSession );
 
-        iIapId = iIapRecord->RecordId();
-        aClientPluginInstance->iIapId = iIapId;
+        iCmId = iIapRecord->RecordId();
+        aClientPluginInstance->iIapId = iCmId;
 
         CCDIAPRecord* tempIapRecord = static_cast<CCDIAPRecord*>(
-                CCDRecordBase::CreateCopyRecordL( *iIapRecord ) );
+                CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
         CleanupStack::PushL( tempIapRecord );
+        CopyRecordFieldsL( *iIapRecord, *tempIapRecord );
         tempIapRecord->SetElementId( iIapRecord->ElementId() );
 
         aClientPluginInstance->iGenRecordArray.Remove( KIapRecordIndex );
-        CleanupStack::PushL( iapRecord );
+        delete iapRecord;
+        iapRecord = NULL;
 
         aClientPluginInstance->iGenRecordArray.InsertL(
-                static_cast<CommsDat::CCDRecordBase*>( tempIapRecord ), KIapRecordIndex );
-
-        CleanupStack::PopAndDestroy( iapRecord );
+                static_cast<CommsDat::CCDRecordBase*>( tempIapRecord ),
+                KIapRecordIndex );
+
         CleanupStack::Pop( tempIapRecord );
-
         }
     else
         {
         delete iIapRecord;
         iIapRecord = NULL;
-
-        iIapRecord = static_cast<CCDIAPRecord*>
-                            ( CCDRecordBase::CreateCopyRecordL( *iapRecord ) );
+        iIapRecord = static_cast<CCDIAPRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+        CopyRecordFieldsL( *iapRecord, *iIapRecord );
 
         iIapRecord->SetElementId( iapRecord->ElementId() );
-
         iIapRecord->ModifyL( iSession );
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_UPDATEIAPRECORDL_EXIT );
     }
 
@@ -876,49 +945,44 @@
     CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
             aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
 
+    if ( !iapRecord || !proxyRecord )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
     CopyAttributes( iapRecord, proxyRecord );
     CheckIfNameModifiedL( iapRecord, proxyRecord );
 
-    if ( proxyRecord->iUseProxyServer )
+    delete iProxyRecord;
+    iProxyRecord = NULL;
+    iProxyRecord = static_cast<CCDProxiesRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
+    CopyRecordFieldsL( *proxyRecord, *iProxyRecord );
+    iProxyRecord->SetElementId( proxyRecord->ElementId() );
+
+    if ( !iProxyRecord->RecordId() )
         {
-        delete iProxyRecord;
-        iProxyRecord = NULL;
-
-        iProxyRecord = static_cast<CCDProxiesRecord*>
-                            ( CCDRecordBase::CreateCopyRecordL( *proxyRecord ) );
-        iProxyRecord->SetElementId( proxyRecord->ElementId() );
-
-        if ( !iProxyRecord->RecordId() )
-            // new proxy setting -> create new record
+        // New proxy setting -> create new record.
+        iProxyRecord->iService = iServiceRecord->RecordId();
+        iProxyRecord->iServiceType.SetL( iIapRecord->iServiceType );
+
+        // By default protocol is set to "http".
+        if ( TPtrC( proxyRecord->iProtocolName ).Length() == 0 )
             {
-            iProxyRecord->iService = iServiceRecord->RecordId();
-            iProxyRecord->iServiceType.SetL( iIapRecord->iServiceType );
-
-            // By default protocol is set to "http"
-            if ( TPtrC( proxyRecord->iProtocolName ).Length() == 0 )
-                {
-                iProxyRecord->iProtocolName.SetL( KDefProxyProtocolName );
-                }
-
-            iProxyRecord->SetRecordId( KCDNewRecordRequest );
-            iProxyRecord->StoreL( iSession );
-            proxyRecord->SetElementId( iProxyRecord->ElementId() );
-            proxyRecord->iService = iServiceRecord->RecordId();
-            proxyRecord->iServiceType.SetL( iIapRecord->iServiceType );
+            iProxyRecord->iProtocolName.SetL( KDefProxyProtocolName );
             }
-        else
-            // already existing record -> update only
-            {
-            iProxyRecord->ModifyL( iSession );
-            }
+
+        iProxyRecord->SetRecordId( KCDNewRecordRequest );
+        iProxyRecord->StoreL( iSession );
+        CopyRecordFieldsL( *iProxyRecord, *proxyRecord );
+        proxyRecord->SetElementId( iProxyRecord->ElementId() );
         }
     else
+        // Already existing record -> update only.
         {
-        if ( iProxyRecord->RecordId() )
-            {
-            iProxyRecord->DeleteL( iSession );
-            }
+        iProxyRecord->ModifyL( iSession );
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_UPDATEPROXYRECORDL_EXIT );
     }
 
@@ -931,32 +995,29 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_UPDATEMETADATARECORDL_ENTRY );
 
-    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+    CCDIAPRecord* clientIapRecord = static_cast<CCDIAPRecord*>(
             aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
 
-    CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
+    CCDIAPMetadataRecord* clientMetadataRecord = static_cast<CCDIAPMetadataRecord*>(
             aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
 
-    CopyAttributes( iapRecord, metadataRecord );
-    CheckIfNameModifiedL( iapRecord, metadataRecord );
-
+    // Adjust client side metadata record attributes and name if needed.
+    CopyAttributes( clientIapRecord, clientMetadataRecord );
+    CheckIfNameModifiedL( clientIapRecord, clientMetadataRecord );
+
+    // Make a copy of client's metadata record and save to database.
     delete iMetaDataRecord;
     iMetaDataRecord = NULL;
-
-    // Get a new blank IAP metadata record.
-    iMetaDataRecord = NewMetadataRecordL( EFalse );
-
-    iMetaDataRecord->SetElementId( metadataRecord->ElementId() );
-    iMetaDataRecord->iRecordName.SetL( metadataRecord->iRecordName );
-    iMetaDataRecord->iMetadata.SetL( metadataRecord->iMetadata );
-    iMetaDataRecord->iSeamlessness.SetL( metadataRecord->iSeamlessness );
+    iMetaDataRecord = new( ELeave ) CCDIAPMetadataRecord( iMetadataTableId );
+    CopyRecordFieldsL( *clientMetadataRecord, *iMetaDataRecord );
+    iMetaDataRecord->SetElementId( clientMetadataRecord->ElementId() );
 
     if ( !iMetaDataRecord->RecordId() )
         {
         iMetaDataRecord->iIAP = IAPRecordElementId();
         iMetaDataRecord->SetRecordId( KCDNewRecordRequest );
         iMetaDataRecord->StoreL( iSession );
-        metadataRecord->SetElementId( iMetaDataRecord->ElementId() );
+        clientMetadataRecord->SetElementId( iMetaDataRecord->ElementId() );
         }
     else
         {
@@ -975,16 +1036,17 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_UPDATESERVICERECORDL_ENTRY );
 
-    CCDIAPRecord* iapRecord =
-                static_cast<CCDIAPRecord*>( aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
-
-    CCDRecordBase* serviceRecord =
-                static_cast<CCDRecordBase*>( aClientPluginInstance->iGenRecordArray[KServiceRecordIndex] );
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+
+    CCDRecordBase* serviceRecord = static_cast<CCDRecordBase*>(
+            aClientPluginInstance->iGenRecordArray[KServiceRecordIndex] );
 
     CopyAttributes( iapRecord, serviceRecord );
 
-    UpdateServiceRecordL( aClientPluginInstance->iGenRecordArray,
-                          aClientPluginInstance->iBearerSpecRecordArray );
+    UpdateServiceRecordL(
+            aClientPluginInstance->iGenRecordArray,
+            aClientPluginInstance->iBearerSpecRecordArray );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_UPDATESERVICERECORDL_EXIT );
     }
@@ -994,15 +1056,15 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginBaseEng::UpdateNetworkRecordL(
-    CCmClientPluginInstance* aClientPluginInstance )
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_UPDATENETWORKRECORDL_ENTRY );
 
-    CCDIAPRecord* iapRecord =
-                static_cast<CCDIAPRecord*>( aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
-
-    CCDNetworkRecord* networkRecord =
-                static_cast<CCDNetworkRecord*>( aClientPluginInstance->iGenRecordArray[KNetworkRecordIndex] );
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+
+    CCDNetworkRecord* networkRecord = static_cast<CCDNetworkRecord*>(
+            aClientPluginInstance->iGenRecordArray[KNetworkRecordIndex] );
 
     CopyAttributes( iapRecord, networkRecord );
 
@@ -1011,8 +1073,9 @@
 
     CheckIfNameModifiedL( iapRecord, networkRecord );
 
-    iNetworkRecord = static_cast<CCDNetworkRecord*>
-                        ( CCDRecordBase::CreateCopyRecordL( *networkRecord ) );
+    iNetworkRecord = static_cast<CCDNetworkRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdNetworkRecord ) );
+    CopyRecordFieldsL( *networkRecord, *iNetworkRecord );
 
     iNetworkRecord->SetElementId( networkRecord->ElementId() );
 
@@ -1026,6 +1089,7 @@
         {
         iNetworkRecord->ModifyL( iSession );
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_UPDATENETWORKRECORDL_EXIT );
     }
 
@@ -1034,49 +1098,9 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginBaseEng::UpdateLocationRecordL(
-    CCmClientPluginInstance* aClientPluginInstance )
+        CCmClientPluginInstance* /*aClientPluginInstance*/ )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_UPDATELOCATIONRECORDL_ENTRY );
-
-    if ( iLocationEnabled )
-        {
-        CCDIAPRecord* iapRecord =
-                    static_cast<CCDIAPRecord*>( aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
-
-        CCDLocationRecord* locationRecord =
-                    static_cast<CCDLocationRecord*>( aClientPluginInstance->iGenRecordArray[KLocationRecordIndex] );
-
-        // location record is not set as hidden because it can be shared between iaps
-        CopyAttributes( iapRecord, locationRecord );
-        locationRecord->ClearAttributes( ECDHidden );
-
-        delete iLocationRecord;
-        iLocationRecord = NULL;
-
-        iLocationRecord = static_cast<CCDLocationRecord*>
-                            ( CCDRecordBase::CreateCopyRecordL( *locationRecord ) );
-
-        iLocationRecord->SetElementId( locationRecord->ElementId() );
-
-        CheckIfNameModifiedL( iapRecord, locationRecord );
-
-        if ( !iLocationRecord->RecordId() )
-            {
-            iLocationRecord->SetRecordId( KCDNewRecordRequest );
-            iLocationRecord->StoreL( iSession );
-            }
-        else
-            {
-            iLocationRecord->ModifyL( iSession );
-            }
-        }
-    else
-        {
-        if ( iLocationRecord )
-            {
-            iLocationRecord->DeleteL( iSession );
-            }
-        }
     OstTraceFunctionExit0( CCMPLUGINBASEENG_UPDATELOCATIONRECORDL_EXIT );
     }
 
@@ -1105,8 +1129,8 @@
 
     if ( !iProxyRecord )
         {
-        iProxyRecord = static_cast<CCDProxiesRecord *>
-                      (CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord));
+        iProxyRecord = static_cast<CCDProxiesRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
         }
 
     iProxyRecord->iUseProxyServer = aEnable;
@@ -1122,15 +1146,7 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_ENABLELOCATIONL_ENTRY );
 
-    if ( aEnable )
-        {
-        if ( !iLocationRecord )
-            {
-            iLocationRecord = static_cast<CCDLocationRecord *>
-                         (CCDRecordBase::RecordFactoryL(KCDTIdLocationRecord));
-            }
-        }
-
+    // Not supported anymore
     iLocationEnabled = aEnable;
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_ENABLELOCATIONL_EXIT );
@@ -1147,8 +1163,8 @@
     iWapIPBearerRecord = FindWAPRecordL();
     if ( iWapIPBearerRecord )
         {
-        CCDWAPAccessPointRecord *wapApRecord = static_cast<CCDWAPAccessPointRecord *>
-                   (CCDRecordBase::RecordFactoryL(KCDTIdWAPAccessPointRecord));
+        CCDWAPAccessPointRecord *wapApRecord = static_cast<CCDWAPAccessPointRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdWAPAccessPointRecord ) );
 
         CleanupStack::PushL( wapApRecord );
 
@@ -1158,8 +1174,8 @@
             {
             CleanupStack::PopAndDestroy( wapApRecord );
 
-            wapApRecord = static_cast<CCDWAPAccessPointRecord *>
-                   (CCDRecordBase::RecordFactoryL(KCDTIdWAPAccessPointRecord));
+            wapApRecord = static_cast<CCDWAPAccessPointRecord*>(
+                    CCDRecordBase::RecordFactoryL( KCDTIdWAPAccessPointRecord ) );
             }
         else
             {
@@ -1175,6 +1191,7 @@
         {
         NewWapRecordL();
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_LOADWAPRECORDL_EXIT );
     }
 
@@ -1196,7 +1213,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginBaseEng::UpdateWapRecordL(
-    CCmClientPluginInstance* aClientPluginInstance )
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_UPDATEWAPRECORDL_ENTRY );
 
@@ -1206,14 +1223,14 @@
     delete iWapIPBearerRecord;
     iWapIPBearerRecord = NULL;
 
-    CCDIAPRecord* iapRecord =
-        static_cast<CCDIAPRecord*>( aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
-
-    CCDWAPAccessPointRecord* wapAPRecord =
-        static_cast<CCDWAPAccessPointRecord*>( aClientPluginInstance->iGenRecordArray[KWAPAPRecordIndex] );
-
-    CCDWAPIPBearerRecord* wapIPBearerRecord =
-        static_cast<CCDWAPIPBearerRecord*>( aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+
+    CCDWAPAccessPointRecord* wapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
+            aClientPluginInstance->iGenRecordArray[KWAPAPRecordIndex] );
+
+    CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
+            aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
     CopyAttributes( iapRecord, wapAPRecord );
     CopyAttributes( iapRecord, wapIPBearerRecord );
@@ -1221,12 +1238,12 @@
     CheckIfNameModifiedL( iapRecord, wapAPRecord );
     CheckIfNameModifiedL( iapRecord, wapIPBearerRecord );
 
-    iWapAPRecord = static_cast<CCDWAPAccessPointRecord*>
-                            ( CCDRecordBase::CreateCopyRecordL( *wapAPRecord ) );
+    iWapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
+            CCDRecordBase::CreateCopyRecordL( *wapAPRecord ) );//TODO, convert to generic copy
     iWapAPRecord->SetElementId( wapAPRecord->ElementId() );
 
-    iWapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>
-                        ( CCDRecordBase::CreateCopyRecordL( *wapIPBearerRecord ) );
+    iWapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
+            CCDRecordBase::CreateCopyRecordL( *wapIPBearerRecord ) );//TODO, convert to generic copy
     iWapIPBearerRecord->SetElementId( wapIPBearerRecord->ElementId() );
 
     if ( !iWapAPRecord->RecordId() )
@@ -1256,6 +1273,7 @@
         {
         iWapIPBearerRecord->ModifyL( iSession );
         }
+
     OstTraceFunctionExit0( DUP1_CCMPLUGINBASEENG_UPDATEWAPRECORDL_EXIT );
     }
 
@@ -1269,8 +1287,8 @@
 
     if ( !iWapIPBearerRecord )
         {
-        iWapIPBearerRecord = static_cast<CCDWAPIPBearerRecord *>
-                      ( CCDRecordBase::RecordFactoryL( KCDTIdWAPIPBearerRecord ) );
+        iWapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdWAPIPBearerRecord ) );
         iWapIPBearerRecord->iWAPProxyPort = 0;
         iWapIPBearerRecord->iWAPWSPOption = ECmWapWspOptionConnectionOriented;
         iWapIPBearerRecord->iWAPSecurity = EFalse;
@@ -1278,11 +1296,12 @@
 
     if ( !iWapAPRecord )
         {
-        iWapAPRecord = static_cast<CCDWAPAccessPointRecord *>
-                   ( CCDRecordBase::RecordFactoryL( KCDTIdWAPAccessPointRecord ) );
-        // SMS bearer is not supported by this version
+        iWapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdWAPAccessPointRecord ) );
+        // SMS bearer is not supported by this version.
         iWapAPRecord->iWAPCurrentBearer.SetL( TPtrC( KCDTypeNameWAPIPBearer ) );
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_NEWWAPRECORDL_EXIT );
     }
 
@@ -1313,9 +1332,10 @@
 // CCmPluginBaseEng::SetAttribute
 // ---------------------------------------------------------------------------
 //
-void CCmPluginBaseEng::SetAttribute( CCDRecordBase* aRecord,
-                                     TUint32 aAttribute,
-                                     TBool aSet )
+void CCmPluginBaseEng::SetAttribute(
+        CCDRecordBase* aRecord,
+        TUint32 aAttribute,
+        TBool aSet )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_SETATTRIBUTE_ENTRY );
 
@@ -1335,22 +1355,23 @@
 // CCmPluginBaseEng::CopyAttributes
 // ---------------------------------------------------------------------------
 //
-void CCmPluginBaseEng::CopyAttributes( CCDRecordBase* aSrcRecord,
-                                       CCDRecordBase* aDstRecord )
+void CCmPluginBaseEng::CopyAttributes(
+        CCDRecordBase* aSrcRecord,
+        CCDRecordBase* aDstRecord )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_COPYATTRIBUTES_ENTRY );
 
-    if ( aSrcRecord == NULL || aDstRecord == NULL )
+    if ( !aSrcRecord || !aDstRecord )
         {
+        OstTraceFunctionExit0( CCMPLUGINBASEENG_COPYATTRIBUTES_EXIT );
         return;
         }
 
-    // clear the target record attributes first
+    // Clear the target record attributes first.
     aDstRecord->ClearAttributes( aDstRecord->Attributes() );
-
     aDstRecord->SetAttributes( aSrcRecord->Attributes() );
 
-    OstTraceFunctionExit0( CCMPLUGINBASEENG_COPYATTRIBUTES_EXIT );
+    OstTraceFunctionExit0( DUP1_CCMPLUGINBASEENG_COPYATTRIBUTES_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1362,34 +1383,31 @@
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_FINDWAPRECORDL_ENTRY );
 
     CMDBRecordSet<CCDWAPIPBearerRecord>* wapRS =
-            new(ELeave)
-                   CMDBRecordSet<CCDWAPIPBearerRecord>(KCDTIdWAPIPBearerRecord);
+            new( ELeave ) CMDBRecordSet<CCDWAPIPBearerRecord>( KCDTIdWAPIPBearerRecord );
     CleanupStack::PushL( wapRS );
 
-    CCDWAPIPBearerRecord* wapBearerRecord = static_cast<CCDWAPIPBearerRecord *>
-                      (CCDRecordBase::RecordFactoryL(KCDTIdWAPIPBearerRecord));
+    CCDWAPIPBearerRecord* wapBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdWAPIPBearerRecord ) );
 
     CleanupStack::PushL( wapBearerRecord );
 
-    wapBearerRecord->iWAPIAP = iIapId;
+    wapBearerRecord->iWAPIAP = iCmId;
     wapRS->iRecords.AppendL( wapBearerRecord );
 
     CleanupStack::Pop( wapBearerRecord );
     wapBearerRecord = NULL;
 
-    if ( wapRS->FindL(iSession) )
+    if ( wapRS->FindL( iSession ) )
         {
-        wapBearerRecord =
-                        static_cast<CCDWAPIPBearerRecord *>(wapRS->iRecords[0]);
-
-        // we take over the ownership of this record
+        wapBearerRecord = static_cast<CCDWAPIPBearerRecord*>( wapRS->iRecords[0] );
+
+        // Take over the ownership of this record.
         wapRS->iRecords.Remove( 0 );
         }
 
     CleanupStack::PopAndDestroy( wapRS );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_FINDWAPRECORDL_EXIT );
-
     return wapBearerRecord;
     }
 
@@ -1402,12 +1420,11 @@
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_FINDSEAMLESSNESSRECORDL_ENTRY );
 
     CMDBRecordSet<CCDIAPMetadataRecord>* metadataRecordSet =
-          new(ELeave) CMDBRecordSet<CCDIAPMetadataRecord>( iMetadataTableId );
+            new( ELeave ) CMDBRecordSet<CCDIAPMetadataRecord>( iMetadataTableId );
     CleanupStack::PushL( metadataRecordSet );
 
     CCDIAPMetadataRecord* metadataRecord =
-            new (ELeave) CCDIAPMetadataRecord( iMetadataTableId );
-
+            new( ELeave ) CCDIAPMetadataRecord( iMetadataTableId );
     CleanupStack::PushL( metadataRecord );
 
     metadataRecord->iIAP = IAPRecordElementId();
@@ -1434,7 +1451,6 @@
     CleanupStack::PopAndDestroy( metadataRecordSet );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_FINDSEAMLESSNESSRECORDL_EXIT );
-
     return metadataRecord;
     }
 
@@ -1442,11 +1458,13 @@
 // CCmPluginBaseEng::DoMakeValidNameL
 // ---------------------------------------------------------------------------
 //
-HBufC* CCmPluginBaseEng::DoMakeValidNameL( const TDesC& aName,
-                                           const TUint32& aIapId  )
+HBufC* CCmPluginBaseEng::DoMakeValidNameL(
+        const TDesC& aName,
+        const TUint32& aIapId )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_DOMAKEVALIDNAMEL_ENTRY );
 
+    const TInt decimalBase = 10;
     TBool changed( EFalse );
     HBufC* temp = HBufC::NewLC( KApMaxConnNameLength );
     HBufC* temp2 = HBufC::NewLC( KApMaxConnNameLength );
@@ -1469,11 +1487,11 @@
             {
             changed = ETrue;
             postfix++;
-            // check the length of postfix, check text length accordingly
+            // Check the length of postfix, check text length accordingly.
             pf = postfix;
-            for (i=1; i<10; i++)
+            for ( i = 1; i < decimalBase; i++ )
                 {
-                pf /= 10;
+                pf /= decimalBase;
                 if ( !pf )
                     break;
                 }
@@ -1481,7 +1499,7 @@
             TPtr sgdptr2( temp2->Des() );
             if ( postfix )
                 {
-                if ( postfix < 10 )
+                if ( postfix < decimalBase )
                     {
                     sgdptr2 = prefix.Left( KApMaxConnNameLength - i - 3 );
                     }
@@ -1496,8 +1514,8 @@
                 }
             if ( postfix )
                 {
-                TBuf< KMaxPostfixLength > postfixString;
-                if ( postfix > 9 )
+                TBuf<KMaxPostfixLength> postfixString;
+                if ( postfix >= decimalBase )
                     {
                     postfixString.Format( KFormatLargePostfix, postfix );
 //     TODO:               AknTextUtils::LanguageSpecificNumberConversion( postfixString );
@@ -1507,8 +1525,7 @@
                     postfixString.Format( KFormatPostfix, postfix );
 //     TODO:               AknTextUtils::LanguageSpecificNumberConversion( postfixString );
                     }
-                sgdptr.Format( KFormatNameWithPostfix, &sgdptr2,
-                                   &postfixString );
+                sgdptr.Format( KFormatNameWithPostfix, &sgdptr2, &postfixString );
                 }
             else
                 {
@@ -1531,7 +1548,6 @@
         }
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_DOMAKEVALIDNAMEL_EXIT );
-
     return temp;
     }
 
@@ -1539,8 +1555,9 @@
 // CCmPluginBaseEng::EnsureMaxLengthLC
 // ---------------------------------------------------------------------------
 //
-HBufC* CCmPluginBaseEng::EnsureMaxLengthLC( const TDesC& aName,
-                                            TBool& aChanged )
+HBufC* CCmPluginBaseEng::EnsureMaxLengthLC(
+        const TDesC& aName,
+        TBool& aChanged )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_ENSUREMAXLENGTHLC_ENTRY );
 
@@ -1556,7 +1573,8 @@
 
     HBufC* corrname;
     if ( KApMaxConnNameLength < length )
-        { // name too long, truncate.
+        {
+        // Name too long, truncate.
         corrname = aName.Left( KApMaxConnNameLength ).AllocLC();
         aChanged = ETrue;
         }
@@ -1568,7 +1586,7 @@
             {
             User::Leave( KErrArgument );
             }
-        // comes here only if name is valid
+        // Comes here only if name is valid.
         if ( corrname->Length() != aName.Length() )
             {
             aChanged = ETrue;
@@ -1576,7 +1594,6 @@
         }
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_ENSUREMAXLENGTHLC_EXIT );
-
     return corrname;
     }
 
@@ -1613,8 +1630,8 @@
             prefix.Set( aName.Left( lastBrace ) );
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_GETPREFIX_EXIT );
-
     return prefix;
     }
 
@@ -1682,8 +1699,8 @@
                 }
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_GETPOSTFIX_EXIT );
-
     return postfix;
     }
 
@@ -1691,49 +1708,46 @@
 // CCmPluginBaseEng::IsValidNameL
 // ---------------------------------------------------------------------------
 //
-TBool CCmPluginBaseEng::IsValidNameL( const TDesC& aNameText,
-                                      const TUint32& aIapId )
+TBool CCmPluginBaseEng::IsValidNameL(
+        const TDesC& aNameText,
+        const TUint32& aIapId )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_ISVALIDNAMEL_ENTRY );
 
     TBool retVal( ETrue );
 
     CMDBRecordSet<CCDIAPRecord>* iapRS =
-                      new(ELeave) CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);
+            new( ELeave ) CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);
     CleanupStack::PushL(iapRS);
 
-    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord *>
-                            (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
-
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
     CleanupStack::PushL( iapRecord );
 
-    // Prime record
+    // Prime record.
     iapRecord->iRecordName.SetL( aNameText );
-
     iapRS->iRecords.AppendL( iapRecord );
-
     CleanupStack::Pop( iapRecord );
-
     iapRecord = NULL;
 
-    if ( iapRS->FindL(iSession) )
+    if ( iapRS->FindL( iSession ) )
         {
-        if ( iIapId )
-            // this is not a new CM
+        if ( iCmId )
             {
+            // This is not a new CM.
             for ( TInt i = 0; i < iapRS->iRecords.Count(); ++i )
                 {
                 if ( iapRS->iRecords[i]->RecordId() != aIapId )
-                    // duplication because it's not our name
                     {
+                    // Duplication because it's not our name.
                     retVal = EFalse;
                     break;
                     }
                 }
             }
         else
-            // new CM -> any occurence is a duplication
             {
+            // New CM -> any occurence is a duplication.
             retVal = EFalse;
             }
         }
@@ -1741,7 +1755,6 @@
     CleanupStack::PopAndDestroy( iapRS );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_ISVALIDNAMEL_EXIT );
-
     return retVal;
     }
 
@@ -1760,7 +1773,7 @@
     TUint quote( '\'' );  // TChar gives warnings in THUMB & ARMI
     TInt i( 0 );
 
-    for ( i=0; i<l; i++ )
+    for ( i = 0; i < l; i++ )
         {
         ret.Append( aLiteral[i] );
         if ( aLiteral[i] == quote )
@@ -1769,8 +1782,8 @@
             ret.Append( quote );
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_ESCAPETEXTLC_EXIT );
-
     return retbuf;
     }
 
@@ -1788,10 +1801,10 @@
         }
     else if ( iNamingMethod == ENamingUnique )
         {
-        HBufC* newName = DoMakeValidNameL( aName, iIapId );
+        HBufC* newName = DoMakeValidNameL( aName, iCmId );
 
         if ( newName )
-            // name converted to unique
+            // Name converted to unique.
             {
             CleanupStack::PushL( newName );
             iIapRecord->iRecordName.SetL( *newName );
@@ -1804,7 +1817,7 @@
         }
     else if ( iNamingMethod == ENamingNotAccept )
         {
-        if ( IsValidNameL( aName, iIapId ) )
+        if ( IsValidNameL( aName, iCmId ) )
             {
             iIapRecord->iRecordName.SetL( aName );
             }
@@ -1817,6 +1830,7 @@
         {
         User::Leave( KErrCorrupt );
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_SETDEFAULTNAMEL_EXIT );
     }
 
@@ -1841,7 +1855,7 @@
         HBufC* newName = DoMakeValidNameL( aName, iapid );
 
         if ( newName )
-            // name converted to unique
+            // Name converted to unique.
             {
             CleanupStack::PushL( newName );
             aIapRecord->iRecordName.SetL( *newName );
@@ -1880,9 +1894,14 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_CHECKIFNAMEMODIFIEDL_ENTRY );
 
+    if ( !aSrcRecord || !aDestRecord )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
     if ( !TPtrC( aSrcRecord->iRecordName ).CompareF( TPtrC( aDestRecord->iRecordName ) ) )
-        // names matche
         {
+        // Names match.
         OstTraceFunctionExit0( CCMPLUGINBASEENG_CHECKIFNAMEMODIFIEDL_EXIT );
         return;
         }
@@ -1897,8 +1916,6 @@
 // ---------------------------------------------------------------------------
 TMDBElementId CCmPluginBaseEng::IAPRecordElementId() const
     {
-    OstTraceFunctionEntry0( CCMPLUGINBASEENG_IAPRECORDELEMENTID_ENTRY );
-
     return ( KCDMaskShowField & iIapRecord->ElementId() );
     }
 
@@ -1921,50 +1938,47 @@
 
     TUint32 locId( 0 );
     CMDBRecordSet<CCDLocationRecord>* locRS =
-            new(ELeave) CMDBRecordSet<CCDLocationRecord>(KCDTIdLocationRecord);
+            new( ELeave ) CMDBRecordSet<CCDLocationRecord>( KCDTIdLocationRecord );
     CleanupStack::PushL( locRS );
 
-    CCDLocationRecord* locRecord = static_cast<CCDLocationRecord *>
-                         (CCDRecordBase::RecordFactoryL(KCDTIdLocationRecord));
-
+    CCDLocationRecord* locRecord = static_cast<CCDLocationRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdLocationRecord ) );
     CleanupStack::PushL( locRecord );
+
     locRecord->iRecordName.SetL( KLocationName );
     locRS->iRecords.AppendL( locRecord );
     CleanupStack::Pop( locRecord );
 
     if ( locRS->FindL(iSession) )
         {
-        locRecord = static_cast<CCDLocationRecord *>(locRS->iRecords[0]);
-
+        locRecord = static_cast<CCDLocationRecord*>( locRS->iRecords[0] );
         locId = locRecord->RecordId();
         }
     else
         {
-        User::Leave( KErrNotFound );
+        User::Leave( KErrNotFound ); //TODO, what to do if not found. Can we create it? need study.
         }
 
     CleanupStack::PopAndDestroy( locRS );
 
     OstTraceFunctionExit0( CCMPLUGINBASEENG_GETLOCATIONIDL_EXIT );
-
     return locId;
     }
 
 // ---------------------------------------------------------------------------
 // CCmPluginBaseEng::SetProxyServerNameL
 // ---------------------------------------------------------------------------
- void CCmPluginBaseEng::SetProxyServerNameL( const TDesC& aProxyServer,
-                                             CCDRecordBase* aProxyRecord )
+ void CCmPluginBaseEng::SetProxyServerNameL(
+         const TDesC& aProxyServer,
+         CCDRecordBase* aProxyRecord )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_SETPROXYSERVERNAMEL_ENTRY );
 
-    CCDProxiesRecord* proxyRecord =
-                    static_cast<CCDProxiesRecord*>( aProxyRecord );
+    CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>( aProxyRecord );
 
     proxyRecord->iServerName.SetL( aProxyServer );
     if ( !aProxyServer.Length() )
         {
-        proxyRecord->iPortNumber = 0;
         proxyRecord->iUseProxyServer = EFalse;
         }
     else
@@ -1979,10 +1993,11 @@
 // CCmPluginBaseEng::CheckDNSServerAddressL
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CCmPluginBaseEng::CheckDNSServerAddressL( TBool aIPv6,
-                                                        CMDBField<TDesC>& aDNS1,
-                                                        CMDBField<TDesC>& aDNS2,
-                                                        CMDBField<TBool>& aDNSFromServer )
+EXPORT_C void CCmPluginBaseEng::CheckDNSServerAddressL(
+        TBool aIPv6,
+        CMDBField<TDesC>& aDNS1,
+        CMDBField<TDesC>& aDNS2,
+        CMDBField<TBool>& aDNSFromServer )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_CHECKDNSSERVERADDRESSL_ENTRY );
 
@@ -1999,7 +2014,7 @@
                     }
                 else
                     {
-                    // Both are unspecified
+                    // Both are unspecified.
                     aDNSFromServer = ETrue;
                     }
                 }
@@ -2015,7 +2030,7 @@
                     }
                 else
                     {
-                    // Both are unspecified
+                    // Both are unspecified.
                     aDNSFromServer = ETrue;
                     }
                 }
@@ -2046,11 +2061,13 @@
 
     if ( iIapRecord )
         {
-        CCDIAPRecord* iapRecord =
-                static_cast<CCDIAPRecord*>( CCDRecordBase::CreateCopyRecordL( *iIapRecord ) );
+        CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
         CleanupStack::PushL( iapRecord );
+        CopyRecordFieldsL( *iIapRecord, *iapRecord );
         iapRecord->SetElementId( iIapRecord->ElementId() );
-        aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( iapRecord ) );
+        aClientPluginInstance->iGenRecordArray.AppendL(
+                static_cast<CommsDat::CCDRecordBase*>( iapRecord ) );
         CleanupStack::Pop( iapRecord );
         }
     else
@@ -2073,11 +2090,13 @@
 
     if ( iNetworkRecord )
         {
-        CCDNetworkRecord* networkRecord =
-                static_cast<CCDNetworkRecord*>( CCDRecordBase::CreateCopyRecordL( *iNetworkRecord ) );
+        CCDNetworkRecord* networkRecord = static_cast<CCDNetworkRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdNetworkRecord ) );
         CleanupStack::PushL( networkRecord );
+        CopyRecordFieldsL( *iNetworkRecord, *networkRecord );
         networkRecord->SetElementId( iNetworkRecord->ElementId() );
-        aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( networkRecord ) );
+        aClientPluginInstance->iGenRecordArray.AppendL(
+                static_cast<CommsDat::CCDRecordBase*>( networkRecord ) );
         CleanupStack::Pop( networkRecord );
         }
     else
@@ -2087,11 +2106,12 @@
 
     if ( iWapAPRecord )
         {
-        CCDWAPAccessPointRecord* wapAPRecord =
-                static_cast<CCDWAPAccessPointRecord*>( CCDRecordBase::CreateCopyRecordL( *iWapAPRecord ) );
+        CCDWAPAccessPointRecord* wapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
+                CCDRecordBase::CreateCopyRecordL( *iWapAPRecord ) );//TODO, convert to generic copy
+        wapAPRecord->SetElementId( iWapAPRecord->ElementId() );
         CleanupStack::PushL( wapAPRecord );
-        wapAPRecord->SetElementId( iWapAPRecord->ElementId() );
-        aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( wapAPRecord ) );
+        aClientPluginInstance->iGenRecordArray.AppendL(
+                static_cast<CommsDat::CCDRecordBase*>( wapAPRecord ) );
         CleanupStack::Pop( wapAPRecord );
         }
     else
@@ -2101,11 +2121,12 @@
 
     if ( iWapIPBearerRecord )
         {
-        CCDWAPIPBearerRecord* wapIPBearerRecord =
-                static_cast<CCDWAPIPBearerRecord*>( CCDRecordBase::CreateCopyRecordL( *iWapIPBearerRecord ) );
+        CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
+                CCDRecordBase::CreateCopyRecordL( *iWapIPBearerRecord ) );//TODO, convert to generic copy
+        wapIPBearerRecord->SetElementId( iWapIPBearerRecord->ElementId() );
         CleanupStack::PushL( wapIPBearerRecord );
-        wapIPBearerRecord->SetElementId( iWapIPBearerRecord->ElementId() );
-        aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( wapIPBearerRecord ) );
+        aClientPluginInstance->iGenRecordArray.AppendL(
+                static_cast<CommsDat::CCDRecordBase*>( wapIPBearerRecord ) );
         CleanupStack::Pop( wapIPBearerRecord );
         }
     else
@@ -2115,45 +2136,34 @@
 
     if ( iMetaDataRecord )
         {
-        CCDIAPMetadataRecord* metaDataRecord =
+        CCDIAPMetadataRecord* metadataRecord =
                 new( ELeave ) CCDIAPMetadataRecord( iMetadataTableId );
-        CleanupStack::PushL( metaDataRecord );
-        metaDataRecord->iIAP = IAPRecordElementId();
-        metaDataRecord->iMetadata.SetL( iMetaDataRecord->iMetadata );
-        metaDataRecord->iSeamlessness.SetL( iMetaDataRecord->iSeamlessness );
-        metaDataRecord->SetElementId( iMetaDataRecord->ElementId() );
-        // Record name is set during update.
+        CleanupStack::PushL( metadataRecord );
+        CopyRecordFieldsL( *iMetaDataRecord, *metadataRecord );
+        metadataRecord->SetElementId( iMetaDataRecord->ElementId() );
+        // Record name is set/changed during update.
 
         aClientPluginInstance->iGenRecordArray.AppendL(
-                static_cast<CommsDat::CCDRecordBase*>( metaDataRecord ) );
-        CleanupStack::Pop( metaDataRecord );
+                static_cast<CommsDat::CCDRecordBase*>( metadataRecord ) );
+        CleanupStack::Pop( metadataRecord );
         }
     else
         {
         aClientPluginInstance->iGenRecordArray.AppendL( NULL );
         }
 
-    if ( iLocationRecord )
-        {
-        CCDLocationRecord* locationRecord =
-                static_cast<CCDLocationRecord*>( CCDRecordBase::CreateCopyRecordL( *iLocationRecord ) );
-        CleanupStack::PushL( locationRecord );
-        locationRecord->SetElementId( iLocationRecord->ElementId() );
-        aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( locationRecord ) );
-        CleanupStack::Pop( locationRecord );
-        }
-    else
-        {
-        aClientPluginInstance->iGenRecordArray.AppendL( NULL );
-        }
+    // Location record does not need to be loaded
+    aClientPluginInstance->iGenRecordArray.AppendL( NULL );
 
     if ( iProxyRecord )
         {
-        CCDProxiesRecord* proxyRecord =
-                static_cast<CCDProxiesRecord*>( CCDRecordBase::CreateCopyRecordL( *iProxyRecord ) );
+        CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
         CleanupStack::PushL( proxyRecord );
+        CopyRecordFieldsL( *iProxyRecord, *proxyRecord );
         proxyRecord->SetElementId( iProxyRecord->ElementId() );
-        aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( proxyRecord ) );
+        aClientPluginInstance->iGenRecordArray.AppendL(
+                static_cast<CommsDat::CCDRecordBase*>( proxyRecord ) );
         CleanupStack::Pop( proxyRecord );
         }
     else
@@ -2182,14 +2192,25 @@
         case ECmIapId: // If the CM has an ECmIapId then the ECmIapId is the ECmId.
         case ECmId:
             {
-            retVal = static_cast<CCDIAPRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KIapRecordIndex] )->RecordId();
+            if ( iBearerType == KUidEmbeddedDestination )
+                {
+                retVal = GetBearerIntAttributeL(
+                        aAttribute,
+                        aClientPluginInstance->iGenRecordArray,
+                        aClientPluginInstance->iBearerSpecRecordArray );
+                }
+            else
+                {
+                retVal = static_cast<CCDIAPRecord*>(
+                        aClientPluginInstance->iGenRecordArray[KIapRecordIndex] )->RecordId();
+                }
             }
             break;
         case ECmWapId:
             {
             retVal = static_cast<CCDWAPIPBearerRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )->iWAPAccessPointId;
+                    aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )
+                    ->iWAPAccessPointId;
             }
             break;
         case ECmIapServiceId:
@@ -2223,7 +2244,8 @@
             if ( iMetaDataRecord )
                 {
                 retVal = static_cast<CCDIAPMetadataRecord*>(
-                        aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] )->iSeamlessness;
+                        aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] )
+                        ->iSeamlessness;
                 }
             else
                 {
@@ -2245,7 +2267,8 @@
 
         case ECmLoadResult:
             {
-            retVal = KErrNone;
+            // This attribute has been deprecated since Symbian^4.
+            User::Leave( KErrNotSupported ); //TODO, update attribute definition comments.
             }
             break;
 
@@ -2307,14 +2330,34 @@
         {
         case ECmProtected:
             {
-            retVal = IsProtected();
+            if ( iBearerType == KUidEmbeddedDestination )
+                {
+                retVal = GetBearerBoolAttributeL(
+                        aAttribute,
+                        aClientPluginInstance->iGenRecordArray,
+                        aClientPluginInstance->iBearerSpecRecordArray );
+                }
+            else
+                {
+                retVal = IsProtected();
+                }
             }
             break;
         case ECmHidden:
             {
-            CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
-            retVal = iapRecord->Attributes() & ECDHidden;
+            if ( iBearerType == KUidEmbeddedDestination )
+                {
+                retVal = GetBearerBoolAttributeL(
+                        aAttribute,
+                        aClientPluginInstance->iGenRecordArray,
+                        aClientPluginInstance->iBearerSpecRecordArray );
+                }
+            else
+                {
+                CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+                        aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+                retVal = iapRecord->Attributes() & ECDHidden;
+                }
             }
             break;
         case ECmProxyUsageEnabled:
@@ -2323,26 +2366,23 @@
                 {
                 retVal = EFalse;
                 }
-
-            retVal = static_cast<CCDProxiesRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->iUseProxyServer;
+            else
+                {
+                retVal = static_cast<CCDProxiesRecord*>(
+                        aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
+                        ->iUseProxyServer;
+                }
             }
             break;
         case ECmDestination:
             {
-            TRAPD( err, retVal = GetBearerBoolAttributeL( aAttribute,
-                                                          aClientPluginInstance->iGenRecordArray,
-                                                          aClientPluginInstance->iBearerSpecRecordArray ) );
+            TRAPD( err, retVal = GetBearerBoolAttributeL(
+                    aAttribute,
+                    aClientPluginInstance->iGenRecordArray,
+                    aClientPluginInstance->iBearerSpecRecordArray ) );
             if ( err )
                 {
-                if ( err == KErrNotFound )
-                    {
-                    retVal = EFalse;
-                    }
-                else
-                    {
-                    User::Leave( err );
-                    }
+                retVal = EFalse;
                 }
             }
             break;
@@ -2351,12 +2391,18 @@
             retVal = EFalse;
             }
             break;
+        case ECmLocationUsageEnabled:
+            {
+            retVal = iLocationEnabled;
+            }
+            break;
         case ECmCoverage:
             // By default the plugin has no network coverage.
             {
-            TRAPD( err, retVal = GetBearerBoolAttributeL( aAttribute,
-                                                          aClientPluginInstance->iGenRecordArray,
-                                                          aClientPluginInstance->iBearerSpecRecordArray ) );
+            TRAPD( err, retVal = GetBearerBoolAttributeL(
+                    aAttribute,
+                    aClientPluginInstance->iGenRecordArray,
+                    aClientPluginInstance->iBearerSpecRecordArray ) );
             if ( err )
                 {
                 if ( err == KErrNotFound )
@@ -2372,23 +2418,33 @@
             break;
         case ECmMetaHighlight:
             {
-            CCDIAPMetadataRecord* metadataRecord =
-                static_cast<CCDIAPMetadataRecord*>(
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
                     aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
             retVal = metadataRecord->iMetadata & EMetaHighlight;
             }
             break;
         case ECmMetaHiddenAgent:
             {
-            CCDIAPMetadataRecord* metadataRecord =
-                static_cast<CCDIAPMetadataRecord*>(
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
                     aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
             retVal = metadataRecord->iMetadata & EMetaHiddenAgent;
             }
             break;
+        case ECmMetaHotSpot:
+            {
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
+            retVal = metadataRecord->iMetadata & EMetaHotSpot;
+            }
+            break;
         case ECmVirtual:
             {
-            retVal = EFalse;
+            // This is bearer specific attribute.
+            TRAPD( err, retVal = GetBearerInfoBoolL( aAttribute ) );
+            if ( err )
+                {
+                retVal = EFalse;
+                }
             }
             break;
         case ECmWapIPSecurity:
@@ -2420,16 +2476,38 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_GETSTRINGATTRIBUTEL_ENTRY );
 
+    if ( !aClientPluginInstance )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
     HBufC* retVal = NULL;
 
     switch ( aAttribute )
         {
+        case ECmBearerIcon:
+            {
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
+
+            if ( !metadataRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
+            retVal = TPtrC( metadataRecord->iIconFileName ).AllocL();
+            }
+            break;
         case ECmStartPage:
             {
-            CCDWAPAccessPointRecord* wapAPRecord =
-                static_cast<CCDWAPAccessPointRecord*>(
+            CCDWAPAccessPointRecord* wapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPAPRecordIndex] );
 
+            if ( !wapAPRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( wapAPRecord->iWAPStartPage ).AllocL();
             }
             break;
@@ -2438,84 +2516,89 @@
             CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
                     aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
 
+            if ( !iapRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( iapRecord->iRecordName ).AllocL();
             }
             break;
         case ECmProxyServerName:
             {
-            if ( !aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
-                {
-                User::Leave( KErrNotFound );
-                }
-
             CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
                     aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
 
+            if ( !proxyRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( proxyRecord->iServerName ).AllocL();
             }
             break;
         case ECmProxyProtocolName:
             {
-            if ( !aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
-                {
-                User::Leave( KErrNotFound );
-                }
-
             CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
                     aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
 
+            if ( !proxyRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( proxyRecord->iExceptions ).AllocL();
             }
             break;
         case ECmProxyExceptions:
             {
-            if ( !aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
-                {
-                User::Leave( KErrNotFound );
-                }
-
             CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
                     aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
 
+            if ( !proxyRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( proxyRecord->iProtocolName ).AllocL();
             }
             break;
         case ECmWapIPGatewayAddress:
             {
-            if ( !aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )
-                {
-                User::Leave( KErrNotFound );
-                }
-
             CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
+            if ( !wapIPBearerRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( wapIPBearerRecord->iWAPGatewayAddress ).AllocL();
             }
             break;
         case ECmWapIPProxyLoginName:
             {
-            if ( !aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )
-                {
-                User::Leave( KErrNotFound );
-                }
-
             CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
+            if ( !wapIPBearerRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( wapIPBearerRecord->iWAPProxyLoginName ).AllocL();
             }
             break;
         case ECmWapIPProxyLoginPass:
             {
-            if ( !aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )
-                {
-                User::Leave( KErrNotFound );
-                }
-
             CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
+            if ( !wapIPBearerRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+
             retVal = TPtrC( wapIPBearerRecord->iWAPProxyLoginPass ).AllocL();
             }
             break;
@@ -2560,13 +2643,13 @@
     return retVal;
     }
 
-//-----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // CCmPluginBaseEng::GetIntAttributeL
 // -----------------------------------------------------------------------------
 EXPORT_C void CCmPluginBaseEng::SetIntAttributeL(
-    TUint32 aAttribute,
-    TUint32 aValue,
-    CCmClientPluginInstance* aClientPluginInstance )
+        TUint32 aAttribute,
+        TUint32 aValue,
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_SETINTATTRIBUTEL_ENTRY );
 
@@ -2593,7 +2676,7 @@
                 {
                 static_cast<CCDIAPMetadataRecord*>(
                         aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] )->
-                                iSeamlessness.SetL( aValue );
+                        iSeamlessness.SetL( aValue );
                 }
             else
                 {
@@ -2611,17 +2694,20 @@
             {
             if ( !aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
                 {
-                CCDProxiesRecord* proxyRecord =
-                        static_cast<CCDProxiesRecord*>( CCDRecordBase::CreateCopyRecordL( *iProxyRecord ) );
+                CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
                 CleanupStack::PushL( proxyRecord );
+                CopyRecordFieldsL( *iProxyRecord, *proxyRecord );
                 proxyRecord->SetElementId( iProxyRecord->ElementId() );
-                aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( proxyRecord ) );
+                aClientPluginInstance->iGenRecordArray.InsertL(
+                        static_cast<CommsDat::CCDRecordBase*>( proxyRecord ),
+                        KProxyRecordIndex );
                 CleanupStack::Pop( proxyRecord );
                 }
 
             static_cast<CCDProxiesRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
-                        ->iPortNumber = aValue;
+                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->
+                    iPortNumber = aValue;
             }
             break;
         case ECmWapIPWSPOption:
@@ -2633,39 +2719,43 @@
             else
                 {
                 static_cast<CCDWAPIPBearerRecord*>(
-                        aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )->iWAPWSPOption.SetL( aValue );
+                        aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )->
+                        iWAPWSPOption.SetL( aValue );
                 }
             }
             break;
         case ECmWapIPProxyPort:
             {
             static_cast<CCDWAPIPBearerRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )->iWAPProxyPort.SetL( aValue );
+                    aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )->
+                    iWAPProxyPort.SetL( aValue );
             }
             break;
         default:
             {
-            SetBearerIntAttributeL( aAttribute,
-                                    aValue,
-                                    aClientPluginInstance->iGenRecordArray,
-                                    aClientPluginInstance->iBearerSpecRecordArray );
+            SetBearerIntAttributeL(
+                    aAttribute,
+                    aValue,
+                    aClientPluginInstance->iGenRecordArray,
+                    aClientPluginInstance->iBearerSpecRecordArray );
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_SETINTATTRIBUTEL_EXIT );
     }
 
-//-----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // CCmPluginBaseEng::SetBoolAttributeL
 // -----------------------------------------------------------------------------
 EXPORT_C void CCmPluginBaseEng::SetBoolAttributeL(
-    TUint32 aAttribute,
-    TBool aValue,
-    CCmClientPluginInstance* aClientPluginInstance )
+        TUint32 aAttribute,
+        TBool aValue,
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_SETBOOLATTRIBUTEL_ENTRY );
 
     CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
-                        aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
+            aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
 
     switch ( aAttribute )
         {
@@ -2707,17 +2797,20 @@
             {
             if ( !aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
                 {
-                CCDProxiesRecord* proxyRecord =
-                        static_cast<CCDProxiesRecord*>( CCDRecordBase::CreateCopyRecordL( *iProxyRecord ) );
+                CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
                 CleanupStack::PushL( proxyRecord );
+                CopyRecordFieldsL( *iProxyRecord, *proxyRecord );
                 proxyRecord->SetElementId( iProxyRecord->ElementId() );
-                aClientPluginInstance->iGenRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( proxyRecord ) );
+                aClientPluginInstance->iGenRecordArray.InsertL(
+                        static_cast<CommsDat::CCDRecordBase*>( proxyRecord ),
+                        KProxyRecordIndex );
                 CleanupStack::Pop( proxyRecord );
                 }
 
             static_cast<CCDProxiesRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )
-                        ->iUseProxyServer = aValue;
+                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->iUseProxyServer =
+                            aValue;
             }
             break;
         case ECmChargeCardUsageEnabled:
@@ -2732,9 +2825,8 @@
             break;
         case ECmMetaHighlight:
             {
-            CCDIAPMetadataRecord* metadataRecord =
-                static_cast<CCDIAPMetadataRecord*>(
-                        aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
             if ( aValue )
                 {
                 metadataRecord->iMetadata = EMetaHighlight | metadataRecord->iMetadata;
@@ -2759,41 +2851,73 @@
                 }
             }
             break;
+        case ECmMetaHotSpot:
+            {
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
+            if ( aValue )
+                {
+                metadataRecord->iMetadata = EMetaHotSpot | metadataRecord->iMetadata;
+                }
+            else
+                {
+                metadataRecord->iMetadata = ~EMetaHotSpot & metadataRecord->iMetadata;
+                }
+            }
+            break;
         case ECmWapIPSecurity:
             {
             static_cast<CCDWAPIPBearerRecord*>(
-                    aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )->iWAPSecurity.SetL( aValue );
+                    aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] )
+                    ->iWAPSecurity.SetL( aValue );
             }
             break;
         default:
             {
-            SetBearerBoolAttributeL( aAttribute,
-                                     aValue,
-                                     aClientPluginInstance->iGenRecordArray,
-                                     aClientPluginInstance->iBearerSpecRecordArray );
+            SetBearerBoolAttributeL(
+                    aAttribute,
+                    aValue,
+                    aClientPluginInstance->iGenRecordArray,
+                    aClientPluginInstance->iBearerSpecRecordArray );
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_SETBOOLATTRIBUTEL_EXIT );
     }
 
-//-----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // CCmPluginBaseEng::SetStringAttributeL
 // -----------------------------------------------------------------------------
 EXPORT_C void CCmPluginBaseEng::SetStringAttributeL(
-    TUint32 aAttribute,
-    const TDesC16& aValue,
-    CCmClientPluginInstance* aClientPluginInstance )
+        TUint32 aAttribute,
+        const TDesC16& aValue,
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_SETSTRINGATTRIBUTEL_ENTRY );
 
     switch ( aAttribute )
         {
+        case ECmBearerIcon:
+            {
+            CCDIAPMetadataRecord* metadataRecord = static_cast<CCDIAPMetadataRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KMetaDataRecordIndex] );
+
+            if ( !metadataRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            metadataRecord->iIconFileName.SetL( aValue );
+            }
+            break;
         case ECmStartPage:
             {
-            CCDWAPAccessPointRecord* wapAPRecord =
-                static_cast<CCDWAPAccessPointRecord*>(
-                        aClientPluginInstance->iGenRecordArray[KWAPAPRecordIndex] );
-
+            CCDWAPAccessPointRecord* wapAPRecord = static_cast<CCDWAPAccessPointRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KWAPAPRecordIndex] );
+
+            if ( !wapAPRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
             wapAPRecord->iWAPStartPage.SetL( aValue );
             }
             break;
@@ -2802,23 +2926,25 @@
             CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
                     aClientPluginInstance->iGenRecordArray[KIapRecordIndex] );
 
+            if ( !iapRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
             SetNameL( aValue, iapRecord, aClientPluginInstance->iNamingMethod );
             }
             break;
         case ECmProxyServerName:
             {
-            CCDProxiesRecord* proxyRecord =
-                    static_cast<CCDProxiesRecord*>(
-                            aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
+            CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
             if ( !proxyRecord )
                 {
-                proxyRecord = static_cast<CCDProxiesRecord *>
-                              ( CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord ) );
-
-                // map proxy record to this iap.
-                proxyRecord->iService =
-                        static_cast<CCDProxiesRecord*>(
-                                aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->RecordId();
+                proxyRecord = static_cast<CCDProxiesRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
+
+                // Map proxy record to this iap.
+                proxyRecord->iService = static_cast<CCDProxiesRecord*>(
+                        aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->RecordId();
 
                 aClientPluginInstance->iGenRecordArray.Insert( proxyRecord, KProxyRecordIndex );
                 }
@@ -2828,18 +2954,16 @@
             break;
         case ECmProxyProtocolName:
             {
-            CCDProxiesRecord* proxyRecord =
-                    static_cast<CCDProxiesRecord*>(
-                            aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
+            CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
             if ( !proxyRecord )
                 {
-                proxyRecord = static_cast<CCDProxiesRecord *>
-                              ( CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord ) );
-
-                // map proxy record to this iap.
-                proxyRecord->iService =
-                        static_cast<CCDProxiesRecord*>(
-                                aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->RecordId();
+                proxyRecord = static_cast<CCDProxiesRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
+
+                // Map proxy record to this iap.
+                proxyRecord->iService = static_cast<CCDProxiesRecord*>(
+                        aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->RecordId();
 
                 aClientPluginInstance->iGenRecordArray.Insert( proxyRecord, KProxyRecordIndex );
                 }
@@ -2849,18 +2973,16 @@
             break;
         case ECmProxyExceptions:
             {
-            CCDProxiesRecord* proxyRecord =
-                    static_cast<CCDProxiesRecord*>(
-                            aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
+            CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(
+                    aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] );
             if ( !proxyRecord )
                 {
-                proxyRecord = static_cast<CCDProxiesRecord *>
-                              ( CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord ) );
-
-                // map proxy record to this iap.
-                proxyRecord->iService =
-                        static_cast<CCDProxiesRecord*>(
-                                aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->RecordId();
+                proxyRecord = static_cast<CCDProxiesRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdProxiesRecord ) );
+
+                // Map proxy record to this iap.
+                proxyRecord->iService = static_cast<CCDProxiesRecord*>(
+                        aClientPluginInstance->iGenRecordArray[KProxyRecordIndex] )->RecordId();
 
                 aClientPluginInstance->iGenRecordArray.Insert( proxyRecord, KProxyRecordIndex );
                 }
@@ -2873,6 +2995,10 @@
             CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
+            if ( !wapIPBearerRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
             wapIPBearerRecord->iWAPGatewayAddress.SetL( aValue );
             }
             break;
@@ -2881,6 +3007,10 @@
             CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
+            if ( !wapIPBearerRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
             wapIPBearerRecord->iWAPProxyLoginName.SetL( aValue );
             }
             break;
@@ -2889,27 +3019,33 @@
             CCDWAPIPBearerRecord* wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(
                     aClientPluginInstance->iGenRecordArray[KWAPBearerRecordIndex] );
 
+            if ( !wapIPBearerRecord )
+                {
+                User::Leave( KErrCorrupt );
+                }
             wapIPBearerRecord->iWAPProxyLoginPass.SetL( aValue );
             }
             break;
         default:
             {
-            SetBearerStringAttributeL( aAttribute,
-                                       aValue,
-                                       aClientPluginInstance->iGenRecordArray,
-                                       aClientPluginInstance->iBearerSpecRecordArray );
+            SetBearerStringAttributeL(
+                    aAttribute,
+                    aValue,
+                    aClientPluginInstance->iGenRecordArray,
+                    aClientPluginInstance->iBearerSpecRecordArray );
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_SETSTRINGATTRIBUTEL_EXIT );
     }
 
-//-----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // CCmPluginBaseEng::SetString8AttributeL
 // -----------------------------------------------------------------------------
 EXPORT_C void CCmPluginBaseEng::SetString8AttributeL(
-    TUint32 aAttribute,
-    const TDesC8& aValue,
-    CCmClientPluginInstance* aClientPluginInstance )
+        TUint32 aAttribute,
+        const TDesC8& aValue,
+        CCmClientPluginInstance* aClientPluginInstance )
     {
     OstTraceFunctionEntry0( CCMPLUGINBASEENG_SETSTRING8ATTRIBUTEL_ENTRY );
 
@@ -2917,12 +3053,14 @@
         {
         default:
             {
-            SetBearerString8AttributeL( aAttribute,
-                                        aValue,
-                                        aClientPluginInstance->iGenRecordArray,
-                                        aClientPluginInstance->iBearerSpecRecordArray );
+            SetBearerString8AttributeL(
+                    aAttribute,
+                    aValue,
+                    aClientPluginInstance->iGenRecordArray,
+                    aClientPluginInstance->iBearerSpecRecordArray );
             }
         }
+
     OstTraceFunctionExit0( CCMPLUGINBASEENG_SETSTRING8ATTRIBUTEL_EXIT );
     }
 
@@ -2941,7 +3079,6 @@
         }
 
     OstTraceFunctionExit0( DUP1__ISUNSPECIFIEDIPV4ADDRESS_EXIT );
-
     return EFalse;
     }
 
@@ -2968,7 +3105,6 @@
         }
 
     OstTraceFunctionExit0( DUP2__CLASSIFYIPV6ADDRESS_EXIT );
-
     return EIPv6UserDefined;
     }
 
--- a/cmmanager/cmmgr/cmmpluginbase/src/ccmpluginbaseengtextresolver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/src/ccmpluginbaseengtextresolver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -27,15 +27,16 @@
     {
     _LIT(KCMManagerTranslationFile, "cmmanager_");
     _LIT(KTranslationPath, "\\resource\\qt\\translations");
-    
-    TBool result = HbTextResolverSymbian::Init( KCMManagerTranslationFile,
-                                                KTranslationPath );
+
+    TBool result = HbTextResolverSymbian::Init(
+            KCMManagerTranslationFile,
+            KTranslationPath );
     if ( result )
         {
         OstTrace0( TRACE_ERROR, CCMPLUGINBASEENGTEXTRESOLVER_RESOLVETEXTL, "CCmPluginBaseEngTextResolver::ResolveTextL" );
         }
-    
-    return HbTextResolverSymbian::LoadL( aTextId );        
+
+    return HbTextResolverSymbian::LoadL( aTextId );
     }
 
-    
+// End of file
--- a/cmmanager/cmmgr/cmmpluginbase/traces/OstTraceDefinitions.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmpluginbase/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef __OSTTRACEDEFINITIONS_H__
 #define __OSTTRACEDEFINITIONS_H__
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/data/1020737D.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*        Resource definitions for project cmpluginembdestination.
+*
+*/
+
+#include "ecom/registryinfo.rh"
+
+// Because attribute enums had to be added to namespace CMManager
+// it's not possible to included cmpluginembdestination.hrh.
+// Thus bearer type id had to be redefine here.
+#define KEmbeddedDestination  0x10207379
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x1020737D;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10207377; // = KCMPluginInterfaceUid
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = KEmbeddedDestination;
+					version_no = 1;
+					display_name = "Embedded Destination";
+					default_data = "EmbeddedDestination";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*        Build information file for project cmpluginembdestination
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+// export iby files
+
+PRJ_MMPFILES
+cmpluginembdestination.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/group/cmpluginembdestination.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*        Project definition file for project cmpluginebmdestination
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET      cmpluginembdestination.dll
+UID         0x10009D8D 0x1020737D
+
+TARGETTYPE		PLUGIN
+
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH  ../src
+
+SOURCE      cmpluginembdestinationproxy.cpp
+SOURCE      cmpluginembdestination.cpp
+
+SOURCEPATH  ../data
+
+START RESOURCE 1020737D.rss
+TARGET cmpluginembdestination.rsc
+END
+
+USERINCLUDE     ../data
+
+// Component specific internal headers
+USERINCLUDE			../inc
+USERINCLUDE     ../../../cmmcommon/inc ../traces
+
+// ADO specific internal headers
+SYSTEMINCLUDE		../../../../../inc
+
+//Macro to /epoc32 headers
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY euser.lib
+LIBRARY	ecom.lib
+LIBRARY commsdat.lib
+LIBRARY cmmpluginbase.lib
+LIBRARY cmmanagerdatabase.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/inc/cmpluginembdestination.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,250 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*       Declaration of embedded destination interface implementation
+*       for "Embedded Destination" plugin
+*
+*/
+
+#ifndef EMBEDDEDDESTINATION_PLUGIN_H
+#define EMBEDDEDDESTINATION_PLUGIN_H
+
+#include <cmpluginbaseeng.h>
+#include <cmpluginembdestinationdef.h>
+
+/**
+*  CCmPluginEmbDestination defines the functionality of Embedded Destination(ED)
+*  bearer support.
+*  Most of the API is inherited from CCmPluginBaseEng class.
+*/
+NONSHARABLE_CLASS( CCmPluginEmbDestination ) : public CCmPluginBaseEng
+    {
+    public: // Constructors and destructor
+        /**
+         * Two phased constructor.
+         * @return Returns the ED plugin object.
+         */
+        static CCmPluginEmbDestination* NewL( TCmPluginInitParam* aInitParam );
+
+        /**
+         * Destructor.
+         */
+        virtual ~CCmPluginEmbDestination();
+
+    public: // From CCmPluginBaseEng
+        /**
+         * Creates a new instance of ED bearer plugin. The instance
+         * created represents a bearer, not a particular ED.
+         * @param aInitParam Initialization data.
+         * @return Returns CCmPluginBaseEng type pointer which represents pure
+         * bearer instance for the cmm server.
+         */
+        virtual CCmPluginBaseEng* CreateInstanceL(
+                TCmPluginInitParam& aInitParam ) const;
+
+        /**
+         * Following GetBearerInfoXXXL methods return the values of the
+         * requested attributes. These values are ED specific
+         * so they don't vary between EDs.
+         * @param aAttribute An attribute identifier.
+         * @return Returns the value requested. If not found leaves with
+         * KErrNotFound error code.
+         */
+
+        virtual TUint32 GetBearerInfoIntL( TUint32 aAttribute ) const;
+
+        virtual TBool GetBearerInfoBoolL( TUint32 aAttribute ) const;
+
+        virtual HBufC* GetBearerInfoStringL( TUint32 aAttribute ) const;
+
+        virtual HBufC8* GetBearerInfoString8L( TUint32 aAttribute ) const;
+
+        /**
+         * Does not do anything. Embedded destination does not support this
+         * functionality.
+         * @return Returns always EFalse.
+         */
+        virtual TBool CanHandleIapIdL( TUint32 aIapId ) const;
+
+        /**
+         * Does not do anything. Embedded destination does not support this
+         * functionality.
+         * @return Returns always EFalse.
+         */
+        virtual TBool CanHandleIapIdL(
+                CommsDat::CCDIAPRecord* aIapRecord ) const;
+
+    public: // From CCmPluginBaseEng
+        /**
+         * Following methods do not do anything. Embedded destination does not
+         * support these functionalities.
+         */
+        virtual void PreparePluginToLoadRecordsL();
+
+        virtual void PreparePluginToUpdateRecordsL(
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual void CreateServiceRecordL();
+
+        void LoadServiceRecordL();
+
+        virtual TUint32 ServiceRecordId() const;
+
+        virtual void ServiceRecordNameLC( HBufC* &aServiceName );
+
+        virtual void UpdateServiceRecordL(
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual void CreateBearerRecordsL();
+
+        virtual void LoadBearerRecordsL();
+
+        virtual void BearerRecordIdL( TUint32& aRecordId );
+
+        virtual void BearerRecordNameLC( HBufC*& aBearerName );
+
+        virtual void UpdateBearerRecordsL(
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        void DeleteBearerRecordsL();
+
+        virtual void ResetBearerRecords();
+
+        virtual void GetBearerSpecificRecordsL(
+                RPointerArray<CommsDat::CCDRecordBase>& aRecordArray );
+
+        /**
+         * Following GetBearerXXXXAttribute methods get only the
+         * fields in records in pointer arrays(parameters).
+         * @param aAttribute Identifier of the requested value.
+         * @param aGenRecordArray An array containing pointers to generic
+         * records of the Connection Method.
+         * @param aBearerSpecRecordArray An array containing pointers to bearer
+         * specific records of the Connection Method. aAttribute
+         * parameter should identify one field(integer, boolean string)
+         * in one of these records.
+         * @return Returns the requested value. In error case leaves with
+         * system-wide error code.
+         */
+
+        virtual TUint32 GetBearerIntAttributeL(
+                TUint32 aAttribute,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual TBool GetBearerBoolAttributeL(
+                TUint32 aAttribute,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual HBufC* GetBearerStringAttributeL(
+                TUint32 aAttribute,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual HBufC8* GetBearerString8AttributeL(
+                TUint32 aAttribute,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Following SetBearerXXXXAttribute methods set only the
+         * fields in records in pointer arrays(parameters). They are not
+         * allowed to update the original records in plugins.
+         * @param aAttribute Identifier of the field to set.
+         * @param aValue The value to set.
+         * @param aGenRecordArray An array containing pointers to generic
+         * records of the Connection Method.
+         * @param aBearerSpecRecordArray An array containing pointers to bearer
+         * specific records of the Connection Method. aAttribute
+         * parameter should identify one field(integer, boolean string)
+         * in one of these records.
+         * @return None.
+         */
+
+        virtual void SetBearerIntAttributeL(
+                TUint32 aAttribute, TUint32 aValue,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual void SetBearerBoolAttributeL(
+                TUint32 aAttribute, TBool aValue,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual void SetBearerStringAttributeL(
+                TUint32 aAttribute, const TDesC16& aValue,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual void SetBearerString8AttributeL(
+                TUint32 aAttribute, const TDesC8& aValue,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Bearer is requested by the server if it uses CommsDat tables which
+         * should be observed for possible changes to be able to keep the
+         * data in memory in up to date.
+         * @param aTableIdArray A reference to an array where to add those
+         * table ids.
+         */
+        virtual void GetBearerTableIdsToBeObservedL(
+                RArray<TUint32>& aTableIdArray ) const;
+
+    private: // From CCmPluginBaseEng
+
+        /**
+         * Following methods do not do anything. Embedded destination does not
+         * support these functionalities.
+         */
+        virtual void PrepareToCopyDataL( CCmPluginBaseEng* aCopyInstance );
+
+        CommsDat::CCDRecordBase* CopyServiceRecordL();
+
+        virtual void CopyBearerRecordsL( CCmPluginBaseEng* aCopyInstance );
+
+    private: // Constructors
+        /**
+        * Constructor.
+        */
+        CCmPluginEmbDestination( TCmPluginInitParam* aInitParam );
+
+        /**
+        * Second phase constructor. Leaves on failure.
+        */
+        void ConstructL();
+
+        /**
+         * Gets the protection level of this destination.
+         * @param aProtLevel Parameter to return the protection level.
+         */
+        void ProtectionLevelL( TUint32& aProtLevel );
+
+        /**
+         * Gets the information if this destination is hidden or not.
+         */
+        void IsHiddenL( TBool& aHidden );
+
+    private:
+        /**
+         * Element id of SNAP metadata record
+         */
+        CommsDat::TMDBElementId iDestMetadataTableId;
+	};
+
+#endif // EMBEDDEDDESTINATION_PLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/rom/cmmpluginembdestination.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* cmpluginembdestination.dll to ROM.
+*
+*/
+#ifndef CMMPLUGINEMBDESTINATION_IBY__
+#define CMMPLUGINEMBDESTINATION_IBY__
+
+ECOM_PLUGIN(cmpluginembdestination.dll,1020737D.rsc)
+
+#endif CMMPLUGINEMBDESTINATION_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/src/cmpluginembdestination.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,642 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CCmPluginEmbDestination
+*
+*/
+
+#include <ecom/ecom.h>      // For REComSession
+#include <datamobilitycommsdattypes.h>
+
+#include "cmpluginembdestination.h"
+#include "cmmserverdefs.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cmpluginembdestinationTraces.h"
+#endif
+
+using namespace CMManager;
+using namespace CommsDat;
+
+// ---------------------------------------------------------
+// CCmPluginEmbDestination::NewL()
+// ---------------------------------------------------------
+//
+CCmPluginEmbDestination* CCmPluginEmbDestination::NewL(
+        TCmPluginInitParam* aInitParam )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_NEWL_ENTRY );
+
+    CCmPluginEmbDestination* self = new( ELeave ) CCmPluginEmbDestination( aInitParam );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_NEWL_EXIT );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CCmPluginEmbDestination::CreateInstanceL
+// ----------------------------------------------------------------------------
+//
+CCmPluginBaseEng* CCmPluginEmbDestination::CreateInstanceL(
+        TCmPluginInitParam& aInitParam ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_CREATEINSTANCEL_ENTRY );
+
+    CCmPluginEmbDestination* self = new( ELeave ) CCmPluginEmbDestination( &aInitParam );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_CREATEINSTANCEL_EXIT );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CCmPluginEmbDestination::~CCmPluginEmbDestination()
+// ---------------------------------------------------------
+//
+CCmPluginEmbDestination::~CCmPluginEmbDestination()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::CCmPluginEmbDestination()
+// ---------------------------------------------------------------------------
+//
+CCmPluginEmbDestination::CCmPluginEmbDestination(
+        TCmPluginInitParam* aInitParam )
+        :
+        CCmPluginBaseEng( aInitParam )
+	{
+	iBearerType = KUidEmbeddedDestination;
+	}
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::ConstructL()
+	{
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_CONSTRUCTL_ENTRY );
+
+    CCmPluginBaseEng::ConstructL();
+
+    TRAPD( err, iDestMetadataTableId = CCDSNAPMetadataRecord::TableIdL( iSession ) );
+    if ( err == KErrNotFound )
+        {
+        iDestMetadataTableId = CCDSNAPMetadataRecord::CreateTableL( iSession );
+        }
+    else
+        {
+        User::LeaveIfError( err );
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_CONSTRUCTL_EXIT );
+	}
+
+
+// ---------------------------------------------------------
+// CCmPluginEmbDestination::CanHandleIapIdL()
+// ---------------------------------------------------------
+//
+TBool CCmPluginEmbDestination::CanHandleIapIdL(
+        TUint32 /*aIapId*/ ) const
+    {
+    return EFalse;
+    }
+
+// ---------------------------------------------------------
+// CCmPluginEmbDestination::CanHandleIapIdL()
+// ---------------------------------------------------------
+//
+TBool CCmPluginEmbDestination::CanHandleIapIdL(
+        CCDIAPRecord* /*aIapRecord*/ ) const
+    {
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CCmPluginEmbDestination::PreparePluginToUpdateRecordsL()
+// ----------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::PreparePluginToLoadRecordsL()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CCmPluginEmbDestination::PreparePluginToUpdateRecordsL()
+// ----------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::PreparePluginToUpdateRecordsL(
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::CreateServiceRecordL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::CreateServiceRecordL()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::LoadServiceRecordL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::LoadServiceRecordL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::PrepareToCopyDataL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::PrepareToCopyDataL(
+        CCmPluginBaseEng* /*aCopyInstance*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::CopyServiceRecordL
+// ---------------------------------------------------------------------------
+//
+CommsDat::CCDRecordBase* CCmPluginEmbDestination::CopyServiceRecordL()
+    {
+    return NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CCmPluginEmbDestination::UpdateServiceRecordL()
+// ----------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::UpdateServiceRecordL(
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::CreateBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::CreateBearerRecordsL()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::LoadBearerRecordsL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::LoadBearerRecordsL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::ServiceRecordIdLC
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginEmbDestination::ServiceRecordId() const
+    {
+    return 0;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::ServiceRecordNameLC
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::ServiceRecordNameLC( HBufC*& /*aName*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::BearerRecordIdL()
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::BearerRecordIdL( TUint32& /*aRecordId*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::BearerRecordNameLC()
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::BearerRecordNameLC( HBufC*& /*aBearerName*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerSpecificRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::GetBearerSpecificRecordsL(
+        RPointerArray<CommsDat::CCDRecordBase>& /*aRecordArray*/ )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::DeleteBearerRecordsL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::DeleteBearerRecordsL()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CCmPluginEmbDestination::UpdateBearerRecordsL()
+// ----------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::UpdateBearerRecordsL(
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------
+// CCmPluginEmbDestination::ResetBearerRecords()
+// ---------------------------------------------------------
+//
+void CCmPluginEmbDestination::ResetBearerRecords()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerIntAttributeL
+// --------------------------------------------------------------------------
+//
+TUint32 CCmPluginEmbDestination::GetBearerIntAttributeL(
+        TUint32 aAttribute,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_GETBEARERINTATTRIBUTEL_ENTRY );
+
+    TUint32 retVal( 0 );
+    switch ( aAttribute )
+        {
+        case ECmBearerType:
+            {
+            retVal = iBearerType;
+            }
+            break;
+        case ECmId:
+            {
+            retVal = iCmId;
+            }
+            break;
+        case ECmExtensionLevel:
+            {
+            retVal = KExtensionBaseLevel;
+            }
+            break;
+        case ECmDefaultPriority:
+        case ECmDefaultUiPriority:
+            {
+            retVal = KDataMobilitySelectionPolicyPriorityWildCard;
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_GETBEARERINTATTRIBUTEL_EXIT );
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerBoolAttributeL
+// --------------------------------------------------------------------------
+//
+TBool CCmPluginEmbDestination::GetBearerBoolAttributeL(
+        TUint32 aAttribute,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_GETBEARERBOOLATTRIBUTEL_ENTRY );
+
+    TBool retVal( 0 );
+    switch ( aAttribute )
+        {
+        case ECmCoverage:
+            {
+            retVal = EFalse;
+            }
+            break;
+        case ECmDestination:
+            {
+            retVal = ETrue;
+            }
+            break;
+        case ECmProtected:
+            {
+            TUint32 protlevel( CMManager::EProtLevel0 );
+            ProtectionLevelL( protlevel );
+            if ( protlevel == CMManager::EProtLevel1 || protlevel == CMManager::EProtLevel2 )
+                {
+                retVal = ETrue;
+                }
+            else
+                {
+                retVal = EFalse;
+                }
+            }
+            break;
+        case ECmHidden:
+            {
+            IsHiddenL( retVal );
+            }
+            break;
+        case ECmBearerHasUi:
+            {
+            retVal = EFalse;
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_GETBEARERBOOLATTRIBUTEL_EXIT );
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::ProtectionLevelL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::ProtectionLevelL( TUint32& aProtLevel )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_PROTECTIONLEVELL_ENTRY );
+
+    CCDSNAPMetadataRecord* metadataRecord; // Owned.
+    metadataRecord = new( ELeave ) CCDSNAPMetadataRecord( iDestMetadataTableId );
+    CleanupStack::PushL( metadataRecord );
+
+    metadataRecord->iSNAP = iCmId;
+    metadataRecord->LoadL( iSession );
+
+    aProtLevel = ( metadataRecord->iMetadata & KDestProtectionLevelMask )
+            >> KBitsToShiftDestProtectionLevel;
+
+    CleanupStack::PopAndDestroy( metadataRecord );
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_PROTECTIONLEVELL_EXIT );
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::IsHiddenL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::IsHiddenL( TBool& aHidden )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_ISHIDDENL_ENTRY );
+
+    aHidden = EFalse;
+
+    CCDSNAPMetadataRecord* metadataRecord; // Owned.
+    metadataRecord = new( ELeave ) CCDSNAPMetadataRecord( iDestMetadataTableId );
+    CleanupStack::PushL( metadataRecord );
+
+    metadataRecord->iSNAP = iCmId;
+    metadataRecord->LoadL( iSession );
+
+    if( ( TUint32 )( metadataRecord->iMetadata ) & CMManager::ESnapMetadataHiddenAgent )
+        {
+        aHidden = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy( metadataRecord );
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_ISHIDDENL_EXIT );
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerStringAttributeL
+// --------------------------------------------------------------------------
+//
+HBufC* CCmPluginEmbDestination::GetBearerStringAttributeL(
+        TUint32 /*aAttribute*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    HBufC* retVal = NULL;
+
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerString8AttributeL
+// --------------------------------------------------------------------------
+//
+HBufC8* CCmPluginEmbDestination::GetBearerString8AttributeL(
+        TUint32 /*aAttribute*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    HBufC8* retVal( NULL );
+
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::SetBearerIntAttributeL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::SetBearerIntAttributeL(
+        TUint32 /*aAttribute*/,
+        TUint32 /*aValue*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::SetBearerBoolAttributeL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::SetBearerBoolAttributeL(
+        TUint32 /*aAttribute*/,
+        TBool /*aValue*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::SetBearerStringAttributeL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::SetBearerStringAttributeL(
+        TUint32 /*aAttribute*/,
+        const TDesC16& /*aValue*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// --------------------------------------------------------------------------
+// CCmPluginEmbDestination::SetBearerString8AttributeL
+// --------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::SetBearerString8AttributeL(
+        TUint32 /*aAttribute*/,
+        const TDesC8& /*aValue*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerInfoIntL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginEmbDestination::GetBearerInfoIntL(
+        TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_GETBEARERINFOINTL_ENTRY );
+
+    TUint32 retVal( 0 );
+    switch ( aAttribute )
+        {
+        case ECmBearerType:
+            {
+            retVal = iBearerType;
+            }
+            break;
+        case ECmDefaultUiPriority:
+        case ECmDefaultPriority:
+            {
+            retVal = KDataMobilitySelectionPolicyPriorityWildCard;
+            }
+            break;
+        case ECmExtensionLevel:
+            {
+            retVal = KExtensionBaseLevel;
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_GETBEARERINFOINTL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerInfoBoolL
+// ---------------------------------------------------------------------------
+//
+TBool CCmPluginEmbDestination::GetBearerInfoBoolL( TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINEMBDESTINATION_GETBEARERINFOBOOLL_ENTRY );
+
+    TBool retVal( EFalse );
+    switch ( aAttribute )
+        {
+        case ECmCoverage:
+            {
+            retVal = EFalse;
+            }
+            break;
+        case ECmDestination:
+            {
+            retVal = ETrue;
+            }
+            break;
+        case ECmBearerHasUi:
+            {
+            retVal = EFalse;
+            }
+            break;
+        case ECmVirtual:
+            {
+            retVal = EFalse;
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINEMBDESTINATION_GETBEARERINFOBOOLL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerInfoStringL
+// ---------------------------------------------------------------------------
+//
+HBufC* CCmPluginEmbDestination::GetBearerInfoStringL(
+        TUint32 /*aAttribute*/ ) const
+    {
+    HBufC* retVal( NULL );
+
+    User::Leave( KErrNotSupported );
+
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerInfoString8L
+// ---------------------------------------------------------------------------
+//
+HBufC8* CCmPluginEmbDestination::GetBearerInfoString8L(
+        TUint32 /*aAttribute*/ ) const
+    {
+    HBufC8* retVal( NULL );
+
+    User::Leave( KErrNotSupported );
+
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::CopyBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::CopyBearerRecordsL(
+        CCmPluginBaseEng* /*aCopyInstance*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginEmbDestination::GetBearerTableIdsToBeObserved
+// ---------------------------------------------------------------------------
+//
+void CCmPluginEmbDestination::GetBearerTableIdsToBeObservedL(
+        RArray<TUint32>& /*aTableIdArray*/ ) const
+    {
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/src/cmpluginembdestinationproxy.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*      Implementation of Embedded Destination Plugin proxy table
+*
+*
+*/
+
+#include "cmpluginembdestination.h"
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// Exported proxy for instantiation method resolution
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] =
+	{
+	IMPLEMENTATION_PROXY_ENTRY( KUidEmbeddedDestination,
+	                            CCmPluginEmbDestination::NewL)
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginembdestination/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,7 @@
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+// OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
+// REMOVE BEFORE CHECK-IN TO VERSION CONTROL
+// #define OST_TRACE_COMPILER_IN_USE
+#include <opensystemtrace.h>
+#endif
--- a/cmmanager/cmmgr/cmmplugins/cmpluginlan/data/1020737B.rss	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginlan/data/1020737B.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,7 @@
 *
 */
 
-#include "ecom/RegistryInfo.rh"
+#include "ecom/registryinfo.rh"
 
 // Because attribute enums had to be added to namespace CMManager
 // it's not possible to included cmpluginlanbasedef.h
--- a/cmmanager/cmmgr/cmmplugins/cmpluginlan/group/cmpluginlan.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginlan/group/cmpluginlan.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -49,7 +49,8 @@
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY euser.lib
-LIBRARY	ECOM.LIB
+LIBRARY	ecom.lib
+LIBRARY commsdat.lib
+LIBRARY featmgr.lib
+LIBRARY cmmanagerdatabase.lib
 LIBRARY	cmmpluginbase.lib
-LIBRARY COMMSDAT.lib
-LIBRARY featmgr.lib
\ No newline at end of file
--- a/cmmanager/cmmgr/cmmplugins/cmpluginlan/inc/cmpluginlan.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginlan/inc/cmpluginlan.h	Thu Jul 22 16:37:38 2010 +0100
@@ -324,12 +324,23 @@
         void GetDefaultLanBearerRecordL(
                 RPointerArray<CommsDat::CCDRecordBase>& aRecordArray );
 
+        /**
+         * Returns the default priority value identified with the parameter.
+         * @param aAttribute Indentifies the default priority value requested.
+         */
+        TUint32 GetDefPriorityL( const TUint32 aAttribute ) const;
+
     private: // Data
 
         /**
          * Pointer to LAN bearer record.
          */
         CommsDat::CCDLANBearerRecord* iBearerRecord;
+
+        /**
+         * Bearer priority table ID.
+         */
+        CommsDat::TMDBElementId iBearerPriorityTableId;
     };
 
 #endif // LAN_PLUGIN_H
--- a/cmmanager/cmmgr/cmmplugins/cmpluginlan/src/cmpluginlan.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginlan/src/cmpluginlan.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -57,8 +57,6 @@
 const TInt KLanLastSocketClosedTimeout = -1;
 const TInt KLanLastSessionClosedTimeout = -1;
 
-const TUint32 KDefaultPriorityLAN = 0;
-
 
 // ---------------------------------------------------------
 // CCmPluginLan::NewOutgoingL()
@@ -103,7 +101,6 @@
     OstTraceFunctionEntry0( CCMPLUGINLAN_CCMPLUGINLAN_ENTRY );
 
     ResetBearerRecords();
-    FeatureManager::UnInitializeLib();
 
     OstTraceFunctionExit0( CCMPLUGINLAN_CCMPLUGINLAN_EXIT );
     }
@@ -132,9 +129,19 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINLAN_CONSTRUCTL_ENTRY );
 
-    FeatureManager::InitializeLibL();
+    // Feature Manager is initialized by the CmmServer, so no need to do it here.
 
     CCmPluginBaseEng::ConstructL();
+    
+    // Get bearer priority table ID.
+    TRAP_IGNORE( iBearerPriorityTableId = 
+            CCDGlobalBearerTypePriorizationRecord::TableIdL( iSession ) );
+
+    if ( !iBearerPriorityTableId )
+        {
+        iBearerPriorityTableId = 
+                CCDGlobalBearerTypePriorizationRecord::CreateTableL( iSession );
+        }
 
     OstTraceFunctionExit0( CCMPLUGINLAN_CONSTRUCTL_EXIT );
     }
@@ -197,7 +204,6 @@
 void CCmPluginLan::PreparePluginToLoadRecordsL()
     {
     OstTraceFunctionEntry0( CCMPLUGINLAN_PREPAREPLUGINTOLOADRECORDSL_ENTRY );
-
     OstTraceFunctionExit0( CCMPLUGINLAN_PREPAREPLUGINTOLOADRECORDSL_EXIT );
     }
 
@@ -206,8 +212,8 @@
 // ----------------------------------------------------------------------------
 //
 void CCmPluginLan::PreparePluginToUpdateRecordsL(
-    RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
-    RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
     {
     OstTraceFunctionEntry0( CCMPLUGINLAN_PREPAREPLUGINTOUPDATERECORDSL_ENTRY );
 
@@ -245,11 +251,10 @@
     delete iServiceRecord;
     iServiceRecord = NULL;
 
-    iServiceRecord = static_cast<CCDLANServiceRecord*>
-                (CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
+    iServiceRecord = static_cast<CCDLANServiceRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
 
-    CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord *>( iServiceRecord );
-
+    CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord*>( iServiceRecord );
 
     if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
         {
@@ -283,6 +288,7 @@
         lanServiceRecord->iConfigDaemonManagerName.SetL( KEmpty );
         lanServiceRecord->iConfigDaemonName.SetL( KEmpty );
         }
+
     OstTraceFunctionExit0( CCMPLUGINLAN_CREATESERVICERECORDL_EXIT );
     }
 
@@ -475,83 +481,103 @@
 
     if ( !clientServiceRecordCopy->iRecordTag.IsNull() )
         {
-        origServiceRecord->iRecordTag.SetL( clientServiceRecordCopy->iRecordTag );
+        origServiceRecord->iRecordTag.SetL(
+                clientServiceRecordCopy->iRecordTag );
         }
     if ( !clientServiceRecordCopy->iRecordName.IsNull() )
         {
-        origServiceRecord->iRecordName.SetL( clientServiceRecordCopy->iRecordName );
+        origServiceRecord->iRecordName.SetL(
+                clientServiceRecordCopy->iRecordName );
         }
     if ( !clientServiceRecordCopy->iServiceEnableLlmnr.IsNull() )
         {
-        origServiceRecord->iServiceEnableLlmnr.SetL( clientServiceRecordCopy->iServiceEnableLlmnr );
+        origServiceRecord->iServiceEnableLlmnr.SetL(
+                clientServiceRecordCopy->iServiceEnableLlmnr );
         }
     if ( !clientServiceRecordCopy->iIfNetworks.IsNull() )
         {
-        origServiceRecord->iIfNetworks.SetL( clientServiceRecordCopy->iIfNetworks );
+        origServiceRecord->iIfNetworks.SetL(
+                clientServiceRecordCopy->iIfNetworks );
         }
     if ( !clientServiceRecordCopy->iIpNetmask.IsNull() )
         {
-        origServiceRecord->iIpNetmask.SetL( clientServiceRecordCopy->iIpNetmask );
+        origServiceRecord->iIpNetmask.SetL(
+                clientServiceRecordCopy->iIpNetmask );
         }
     if ( !clientServiceRecordCopy->iIpGateway.IsNull() )
         {
-        origServiceRecord->iIpGateway.SetL( clientServiceRecordCopy->iIpGateway );
+        origServiceRecord->iIpGateway.SetL(
+                clientServiceRecordCopy->iIpGateway );
         }
     if ( !clientServiceRecordCopy->iIpAddrFromServer.IsNull() )
         {
-        origServiceRecord->iIpAddrFromServer.SetL( clientServiceRecordCopy->iIpAddrFromServer );
+        origServiceRecord->iIpAddrFromServer.SetL(
+                clientServiceRecordCopy->iIpAddrFromServer );
         }
     if ( !clientServiceRecordCopy->iIpAddr.IsNull() )
         {
-        origServiceRecord->iIpAddr.SetL( clientServiceRecordCopy->iIpAddr );
+        origServiceRecord->iIpAddr.SetL(
+                clientServiceRecordCopy->iIpAddr );
         }
     if ( !clientServiceRecordCopy->iIpDnsAddrFromServer.IsNull() )
         {
-        origServiceRecord->iIpDnsAddrFromServer.SetL( clientServiceRecordCopy->iIpDnsAddrFromServer );
+        origServiceRecord->iIpDnsAddrFromServer.SetL(
+                clientServiceRecordCopy->iIpDnsAddrFromServer );
         }
     if ( !clientServiceRecordCopy->iIpNameServer1.IsNull() )
         {
-        origServiceRecord->iIpNameServer1.SetL( clientServiceRecordCopy->iIpNameServer1 );
+        origServiceRecord->iIpNameServer1.SetL(
+                clientServiceRecordCopy->iIpNameServer1 );
         }
     if ( !clientServiceRecordCopy->iIpNameServer2.IsNull() )
         {
-        origServiceRecord->iIpNameServer2.SetL( clientServiceRecordCopy->iIpNameServer2 );
+        origServiceRecord->iIpNameServer2.SetL(
+                clientServiceRecordCopy->iIpNameServer2 );
         }
     if ( !clientServiceRecordCopy->iIp6DnsAddrFromServer.IsNull() )
         {
-        origServiceRecord->iIp6DnsAddrFromServer.SetL( clientServiceRecordCopy->iIp6DnsAddrFromServer );
+        origServiceRecord->iIp6DnsAddrFromServer.SetL(
+                clientServiceRecordCopy->iIp6DnsAddrFromServer );
         }
     if ( !clientServiceRecordCopy->iIp6NameServer1.IsNull() )
         {
-        origServiceRecord->iIp6NameServer1.SetL( clientServiceRecordCopy->iIp6NameServer1 );
+        origServiceRecord->iIp6NameServer1.SetL(
+                clientServiceRecordCopy->iIp6NameServer1 );
         }
     if ( !clientServiceRecordCopy->iIp6NameServer2.IsNull() )
         {
-        origServiceRecord->iIp6NameServer2.SetL( clientServiceRecordCopy->iIp6NameServer2 );
+        origServiceRecord->iIp6NameServer2.SetL(
+                clientServiceRecordCopy->iIp6NameServer2 );
         }
     if ( !clientServiceRecordCopy->iIpAddrLeaseValidFrom.IsNull() )
         {
-        origServiceRecord->iIpAddrLeaseValidFrom.SetL( clientServiceRecordCopy->iIpAddrLeaseValidFrom );
+        origServiceRecord->iIpAddrLeaseValidFrom.SetL(
+                clientServiceRecordCopy->iIpAddrLeaseValidFrom );
         }
     if ( !clientServiceRecordCopy->iIpAddrLeaseValidTo.IsNull() )
         {
-        origServiceRecord->iIpAddrLeaseValidTo.SetL( clientServiceRecordCopy->iIpAddrLeaseValidTo );
+        origServiceRecord->iIpAddrLeaseValidTo.SetL(
+                clientServiceRecordCopy->iIpAddrLeaseValidTo );
         }
     if ( !clientServiceRecordCopy->iConfigDaemonManagerName.IsNull() )
         {
-        origServiceRecord->iConfigDaemonManagerName.SetL( clientServiceRecordCopy->iConfigDaemonManagerName );
+        origServiceRecord->iConfigDaemonManagerName.SetL(
+                clientServiceRecordCopy->iConfigDaemonManagerName );
         }
     if ( !clientServiceRecordCopy->iConfigDaemonName.IsNull() )
         {
-        origServiceRecord->iConfigDaemonName.SetL( clientServiceRecordCopy->iConfigDaemonName );
+        origServiceRecord->iConfigDaemonName.SetL(
+                clientServiceRecordCopy->iConfigDaemonName );
         }
     if ( !clientServiceRecordCopy->iServiceExtensionTableName.IsNull() )
         {
-        origServiceRecord->iServiceExtensionTableName.SetL( clientServiceRecordCopy->iServiceExtensionTableName );
+        origServiceRecord->iServiceExtensionTableName.SetL(
+                clientServiceRecordCopy->iServiceExtensionTableName );
         }
     if ( !clientServiceRecordCopy->iServiceExtensionTableRecordId.IsNull() )
         {
-        origServiceRecord->iServiceExtensionTableRecordId.SetL( clientServiceRecordCopy->iServiceExtensionTableRecordId ); //TODO, check this works ok.
+        origServiceRecord->iServiceExtensionTableRecordId.SetL(
+                clientServiceRecordCopy->iServiceExtensionTableRecordId ); //TODO, check this works ok.
         }
 
     origServiceRecord->SetElementId( clientServiceRecordCopy->ElementId() );
@@ -579,7 +605,6 @@
 void CCmPluginLan::CreateBearerRecordsL()
     {
     OstTraceFunctionEntry0( CCMPLUGINLAN_CREATEBEARERRECORDSL_ENTRY );
-
     OstTraceFunctionExit0( CCMPLUGINLAN_CREATEBEARERRECORDSL_EXIT );
     }
 
@@ -590,7 +615,6 @@
 void CCmPluginLan::LoadBearerRecordsL()
     {
     OstTraceFunctionEntry0( CCMPLUGINLAN_LOADBEARERRECORDSL_ENTRY );
-
     OstTraceFunctionExit0( CCMPLUGINLAN_LOADBEARERRECORDSL_EXIT );
     }
 
@@ -635,13 +659,13 @@
 //
 void CCmPluginLan::BearerRecordIdL( TUint32& aRecordId )
     {
-    CCDLANBearerRecord* lanBearerRecord = static_cast<CCDLANBearerRecord*>
-                        (CCDRecordBase::RecordFactoryL( KCDTIdLANBearerRecord ));
+    CCDLANBearerRecord* lanBearerRecord = static_cast<CCDLANBearerRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdLANBearerRecord ) );
     CleanupStack::PushL( lanBearerRecord );
 
     lanBearerRecord->iRecordName.SetL( TPtrC( KLanBearerName ) );
     if ( !lanBearerRecord->FindL( iSession ) )
-        { // bearer not found -> create dummy values
+        { // Bearer not found -> create dummy values.
         lanBearerRecord->SetRecordId( KCDNewRecordRequest );
         lanBearerRecord->iBearerAgent = KLanBearerAgent;
         lanBearerRecord->iRecordName = KLanBearerName;
@@ -652,12 +676,9 @@
         lanBearerRecord->iLanBearerPddFilename = KLanPDDFileName;
         lanBearerRecord->iLanBearerPddName = KLanPDDName;
         lanBearerRecord->iLanBearerPacketDriverName = KLanPacketDriverName;
-        lanBearerRecord->iLastSocketActivityTimeout =
-                                        (TUint32)KLanLastSocketActivityTimeout;
-        lanBearerRecord->iLastSessionClosedTimeout =
-                                        (TUint32)KLanLastSessionClosedTimeout;
-        lanBearerRecord->iLastSocketClosedTimeout =
-                                        (TUint32)KLanLastSocketClosedTimeout;
+        lanBearerRecord->iLastSocketActivityTimeout = (TUint32)KLanLastSocketActivityTimeout;
+        lanBearerRecord->iLastSessionClosedTimeout = (TUint32)KLanLastSessionClosedTimeout;
+        lanBearerRecord->iLastSocketClosedTimeout = (TUint32)KLanLastSocketClosedTimeout;
 
         lanBearerRecord->StoreL( iSession );
         }
@@ -728,17 +749,17 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginLan::SetDaemonNameL(
-    RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
-    RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
     {
     OstTraceFunctionEntry0( CCMPLUGINLAN_SETDAEMONNAMEL_ENTRY );
 
-    // we have to check first that these values has not been
-    // set(or changed) by any 3rd party sw to ensure that
-    // we don't break their settings
-    HBufC* daemonName = GetBearerStringAttributeL( ECmConfigDaemonManagerName,
-                                                   aGenRecordArray,
-                                                   aBearerSpecRecordArray );
+    // We have to check first that these values have not been set (or changed)
+    // by any 3rd party SW to ensure that we don't break their settings.
+    HBufC* daemonName = GetBearerStringAttributeL(
+            ECmConfigDaemonManagerName,
+            aGenRecordArray,
+            aBearerSpecRecordArray );
     if ( daemonName )
         {
         if ( daemonName->Compare( KDaemonManagerName ) != 0 )
@@ -751,50 +772,53 @@
         delete daemonName;
         }
 
-    // use DHCP if we can
-    TBool ipfromSrv = GetBearerBoolAttributeL( ECmIPAddFromServer,
-                                               aGenRecordArray,
-                                               aBearerSpecRecordArray );
+    // Use DHCP if we can.
+    TBool ipfromSrv = GetBearerBoolAttributeL(
+            ECmIPAddFromServer,
+            aGenRecordArray,
+            aBearerSpecRecordArray );
     if ( ipfromSrv )
         {
-        SetBearerStringAttributeL( ECmConfigDaemonManagerName,
-                                   KDaemonManagerName,
-                                   aGenRecordArray,
-                                   aBearerSpecRecordArray );
-
-        SetBearerStringAttributeL( ECmConfigDaemonName,
-                                   KConfigDaemonName,
-                                   aGenRecordArray,
-                                   aBearerSpecRecordArray );
-
+        SetBearerStringAttributeL(
+                ECmConfigDaemonManagerName,
+                KDaemonManagerName,
+                aGenRecordArray,
+                aBearerSpecRecordArray );
+        SetBearerStringAttributeL(ECmConfigDaemonName,
+                KConfigDaemonName,
+                aGenRecordArray,
+                aBearerSpecRecordArray );
         }
     else
         {
         if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
             {
-            SetBearerStringAttributeL( ECmConfigDaemonManagerName,
-                                       KDaemonManagerName,
-                                       aGenRecordArray,
-                                       aBearerSpecRecordArray );
-
-            SetBearerStringAttributeL( ECmConfigDaemonName,
-                                       KConfigDaemonName,
-                                       aGenRecordArray,
-                                       aBearerSpecRecordArray );
+            SetBearerStringAttributeL(
+                    ECmConfigDaemonManagerName,
+                    KDaemonManagerName,
+                    aGenRecordArray,
+                    aBearerSpecRecordArray );
+            SetBearerStringAttributeL(
+                    ECmConfigDaemonName,
+                    KConfigDaemonName,
+                    aGenRecordArray,
+                    aBearerSpecRecordArray );
             }
         else
             {
-            SetBearerStringAttributeL( ECmConfigDaemonManagerName,
-                                       KNullDesC(),
-                                       aGenRecordArray,
-                                       aBearerSpecRecordArray );
-
-            SetBearerStringAttributeL( ECmConfigDaemonName,
-                                       KNullDesC(),
-                                       aGenRecordArray,
-                                       aBearerSpecRecordArray );
+            SetBearerStringAttributeL(
+                    ECmConfigDaemonManagerName,
+                    KNullDesC(),
+                    aGenRecordArray,
+                    aBearerSpecRecordArray );
+            SetBearerStringAttributeL(
+                    ECmConfigDaemonName,
+                    KNullDesC(),
+                    aGenRecordArray,
+                    aBearerSpecRecordArray );
             }
         }
+
     OstTraceFunctionExit0( DUP1_CCMPLUGINLAN_SETDAEMONNAMEL_EXIT );
     }
 
@@ -818,7 +842,8 @@
         {
         case ECmInvalidAttribute:
             {
-            retVal = 0;
+            // This attribute has been deprecated since Symbian^4.
+            User::Leave( KErrNotSupported ); //TODO, update attribute definition comments.
             }
             break;
         case ECmExtensionLevel:
@@ -831,9 +856,14 @@
             retVal = KCommDbBearerLAN;
             }
             break;
+        case ECmDefaultUiPriority:
+            {
+            retVal = GetDefPriorityL( aAttribute );
+            }
+            break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityLAN;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ELanServiceExtensionTableRecordId:
@@ -1311,9 +1341,13 @@
             }
             break;
         case ECmDefaultUiPriority:
+            {
+            retVal = GetDefPriorityL( aAttribute );
+            }
+            break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityLAN;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ECmExtensionLevel:
@@ -1459,4 +1493,45 @@
     OstTraceFunctionExit0( CCMPLUGINLAN_GETBEARERTABLEIDSTOBEOBSERVED_EXIT );
     }
 
+// ---------------------------------------------------------------------------
+// CCmPluginLan::GetDefPriorityL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginLan::GetDefPriorityL( const TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINLAN_GETDEFPRIORITYL_ENTRY );
+
+    TUint32 retVal( KDataMobilitySelectionPolicyPriorityWildCard );
+
+    CCDGlobalBearerTypePriorizationRecord* priorityRecord =
+            new( ELeave ) CCDGlobalBearerTypePriorizationRecord( iBearerPriorityTableId );
+    CleanupStack::PushL( priorityRecord );
+
+    priorityRecord->iServiceType.SetL( TPtrC( KCDTypeNameLANService ) );
+
+    if ( priorityRecord->FindL( iSession ) )
+        {
+        priorityRecord->LoadL( iSession );
+        switch ( aAttribute )
+            {
+            case ECmDefaultPriority:
+                {
+                retVal = priorityRecord->iPriority;
+                }
+                break;
+            case ECmDefaultUiPriority:
+                {
+                retVal = priorityRecord->iUIPriority;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    CleanupStack::PopAndDestroy( priorityRecord );
+
+    OstTraceFunctionExit0( CCMPLUGINLAN_GETDEFPRIORITYL_EXIT );
+    return retVal;
+    }
+
 //  End of File
--- a/cmmanager/cmmgr/cmmplugins/cmpluginlan/src/cmpluginlanproxy.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginlan/src/cmpluginlanproxy.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 
 #include "cmpluginlan.h"
 #include <e32std.h>
-#include <ecom/ImplementationProxy.h>
+#include <ecom/implementationproxy.h>
 
 // Exported proxy for instantiation method resolution
 // Define the interface UIDs
--- a/cmmanager/cmmgr/cmmplugins/cmpluginlan/traces/OstTraceDefinitions.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginlan/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef __OSTTRACEDEFINITIONS_H__
 #define __OSTTRACEDEFINITIONS_H__
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/data/1020737C.rss	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/data/1020737C.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,7 @@
 *
 */
 
-#include "ecom/RegistryInfo.rh"
+#include "ecom/registryinfo.rh"
 
 // Because attribute enums had to be added to namespace CMManager
 // it's not possible to included cmpluginpacketdatadef.h.
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 
 PRJ_EXPORTS
 // export iby files
-../Rom/cmmpluginpacketdata.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(cmmpluginpacketdata.iby)
+../rom/cmmpluginpacketdata.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(cmmpluginpacketdata.iby)
 
 PRJ_MMPFILES
 cmpluginpacketdata.mmp
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/group/cmpluginpacketdata.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/group/cmpluginpacketdata.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,6 @@
 *
 */
 
-#include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
 
 TARGET      cmpluginpacketdata.dll
@@ -32,13 +31,12 @@
 SOURCE      cmpluginpacketdataproxy.cpp
 SOURCE      cmpluginpacketdata.cpp
 
-SOURCEPATH  ../Data
+SOURCEPATH  ../data
 
 START RESOURCE 1020737C.rss
 TARGET cmpluginpacketdata.rsc
 END
 
-//USERINCLUDE     ../../../Framework/SrcData
 USERINCLUDE     ../data
 
 // Component specific internal headers 
@@ -54,8 +52,9 @@
 LIBRARY euser.lib
 LIBRARY	ecom.lib
 LIBRARY cmmpluginbase.lib
-LIBRARY commsdat.lib
 LIBRARY etel.lib
 LIBRARY etelpckt.lib
 LIBRARY featmgr.lib
 LIBRARY centralrepository.lib 
+LIBRARY cmmanagerdatabase.lib
+LIBRARY commsdat.lib
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/inc/cmpluginpacketdata.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/inc/cmpluginpacketdata.h	Thu Jul 22 16:37:38 2010 +0100
@@ -396,8 +396,9 @@
         * @param aServiceRecord Pointer to the service record where to save the
         * pdp type.
         */
-        void SetPDPTypeL( RPacketContext::TProtocolType aPdpType,
-                          CommsDat::CCDWCDMAPacketServiceRecord* aServiceRecord );
+        void SetPDPTypeL(
+                RPacketContext::TProtocolType aPdpType,
+                CommsDat::CCDWCDMAPacketServiceRecord* aServiceRecord );
 
         /**
          * Sets the daemon name for the Connection Method.
@@ -407,8 +408,14 @@
          * specific records of the Connection Method.
          */
         void SetDaemonNameL(
-            RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
-            RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Returns the default priority value identified with the parameter.
+         * @param aAttribute Indentifies the default priority value requested.
+         */
+        TUint32 GetDefPriorityL( const TUint32 aAttribute ) const;
 
     private:
         /**
@@ -422,22 +429,27 @@
         /**
          * Boolean to define if this is outgoing or incoming packetdata cm.
          */
-        TBool   iOutgoing;
+        TBool iOutgoing;
 
         /**
-         * Id of the bearer record of the iap.
+         * ID of the bearer record of the IAP.
          */
         TUint32 iBearerRecordId;
 
         /**
-         * Name of the bearer record of the iap.
+         * Name of the bearer record of the IAP.
          */
-        HBufC*  iBearerRecordName;
+        HBufC* iBearerRecordName;
 
         /**
-         * pointer to the QoS record of the iap.
+         * Pointer to the QoS record of the IAP.
          */
         CommsDat::CCDUmtsR99QoSAndOnTableRecord* iPacketDataQoSRecord;
+
+        /**
+         * Bearer priority table ID.
+         */
+        CommsDat::TMDBElementId iBearerPriorityTableId;
     };
 
 #endif // PACKETDATA_PLUGIN_H
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/src/cmpluginpacketdata.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/src/cmpluginpacketdata.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,11 +17,12 @@
 */
 
 
-#include <stringloader.h>
-#include <FeatMgr.h>
+#include <StringLoader.h>
+#include <featmgr.h>
 #include <centralrepository.h>
 #include <CoreApplicationUIsSDKCRKeys.h>
 
+#include "datamobilitycommsdattypes.h"
 #include "cmpluginpacketdata.h"
 
 #include "OstTraceDefinitions.h"
@@ -34,9 +35,7 @@
 
 // ================= CONSTANTS =======================
 
-const TUint32 KDefaultPriorityPacketData = 1;
-
-/// Modem bearer names for GPRS/WCDMA Access Points
+/// Modem bearer names for GPRS/WCDMA access points.
 _LIT( KModemBearerPacketData, "GPRS Modem" );
 _LIT( KDefaultQosDataRecordName, "PRIMARY1" );
 _LIT( KDefaultQosDataRecordNamewithSpace, "PRIMARY1 " );
@@ -259,8 +258,6 @@
 
     ResetBearerRecords();
 
-    FeatureManager::UnInitializeLib();
-
     OstTraceFunctionExit1( CCMPLUGINPACKETDATA_CCMPLUGINPACKETDATA_EXIT, this );
     }
 
@@ -310,9 +307,20 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_CONSTRUCTL_ENTRY );
 
-    FeatureManager::InitializeLibL();
+    // Feature Manager is initialized by the CmmServer, so no need to do it here.
+
     CCmPluginBaseEng::ConstructL();
 
+    // Get bearer priority table ID.
+    TRAP_IGNORE( iBearerPriorityTableId =
+            CCDGlobalBearerTypePriorizationRecord::TableIdL( iSession ) );
+
+    if ( !iBearerPriorityTableId )
+        {
+        iBearerPriorityTableId =
+                CCDGlobalBearerTypePriorizationRecord::CreateTableL( iSession );
+        }
+
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_CONSTRUCTL_EXIT );
     }
 
@@ -326,7 +334,7 @@
 
     TBool retVal( EFalse );
 
-    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>(
+    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord*>(
             CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
 
     CleanupStack::PushL( iapRecord );
@@ -355,9 +363,9 @@
 
     TBool retVal( EFalse );
 
-    if ( (TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameOutgoingWCDMA) ||
-            TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameIncomingWCDMA)) &&
-            TPtrC(aIapRecord->iBearerType) == TPtrC(KCDTypeNameModemBearer) )
+    if ( ( TPtrC( aIapRecord->iServiceType ) == TPtrC( KCDTypeNameOutgoingWCDMA ) ||
+            TPtrC( aIapRecord->iServiceType ) == TPtrC( KCDTypeNameIncomingWCDMA )) &&
+            TPtrC( aIapRecord->iBearerType ) == TPtrC( KCDTypeNameModemBearer ) )
         {
         retVal = ETrue;
         }
@@ -385,11 +393,13 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_PREPAREPLUGINTOUPDATERECORDSL_ENTRY );
 
-    CCDIAPRecord* iapRecord =
-                static_cast<CCDIAPRecord*>( aGenRecordArray[KIapRecordIndex] );
-
-    CCDWCDMAPacketServiceRecord* serviceRecord =
-            static_cast<CCDWCDMAPacketServiceRecord*>( aGenRecordArray[KServiceRecordIndex] );
+    //TODO, Add null checks for mandatory specific record pointers.
+
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            aGenRecordArray[KIapRecordIndex] );
+
+    CCDWCDMAPacketServiceRecord* serviceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
+            aGenRecordArray[KServiceRecordIndex] );
 
     CheckIfNameModifiedL( iapRecord, serviceRecord );
 
@@ -418,7 +428,7 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_SETDAEMONNAMEL_ENTRY );
 
-    // use DHCP if we can
+    // Use DHCP if we can.
     TBool ipfromSrv = GetBearerBoolAttributeL( EPacketDataIPAddrFromServer,
                                                aGenRecordArray,
                                                aBearerSpecRecordArray );
@@ -472,7 +482,7 @@
 
     if ( ServiceRecord().iUmtsR99QoSAndOnTable )
         {
-        iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord *>(
+        iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
                 CCDRecordBase::RecordFactoryL( KCDTIdUmtsR99QoSAndOnTableRecord ) );
 
         iPacketDataQoSRecord->SetRecordId( ServiceRecord().iUmtsR99QoSAndOnTable );
@@ -492,13 +502,13 @@
 
     if ( TPtrC( KCDTypeNameOutgoingWCDMA ) == iIapRecord->iServiceType )
         {
-        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord *>(
+        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
                 CCDRecordBase::RecordFactoryL( KCDTIdOutgoingGprsRecord ) );
         iOutgoing = ETrue;
         }
     else if ( TPtrC( KCDTypeNameIncomingWCDMA ) == iIapRecord->iServiceType )
         {
-        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord *>(
+        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
                 CCDRecordBase::RecordFactoryL( KCDTIdIncomingGprsRecord ) );
         iOutgoing = EFalse;
         }
@@ -541,12 +551,12 @@
 
     if ( iOutgoing )
         {
-        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord *>(
+        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
                 CCDRecordBase::RecordFactoryL( KCDTIdOutgoingGprsRecord ) );
         }
     else
         {
-        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord *>(
+        iServiceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
                 CCDRecordBase::RecordFactoryL( KCDTIdIncomingGprsRecord ) );
         }
 
@@ -628,7 +638,7 @@
             new( ELeave ) CMDBRecordSet<CCDModemBearerRecord>( KCDTIdModemBearerRecord );
     CleanupStack::PushL( bearerRS );
 
-    CCDModemBearerRecord* bearerRecord = static_cast<CCDModemBearerRecord *>(
+    CCDModemBearerRecord* bearerRecord = static_cast<CCDModemBearerRecord*>(
             CCDRecordBase::RecordFactoryL( KCDTIdModemBearerRecord ) );
 
     CleanupStack::PushL( bearerRecord );
@@ -734,15 +744,17 @@
     delete iPacketDataQoSRecord;
     iPacketDataQoSRecord = NULL;
 
-    iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord *>(
+    iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
             CCDRecordBase::RecordFactoryL( KCDTIdUmtsR99QoSAndOnTableRecord ) );
 
     iPacketDataQoSRecord->iGPRSReqTrafficClass = RPacketQoS::ETrafficClassUnspecified;
     iPacketDataQoSRecord->iGPRSMinTrafficClass = RPacketQoS::ETrafficClassUnspecified;
     iPacketDataQoSRecord->iGPRSReqDeliveryOrder = RPacketQoS::EDeliveryOrderUnspecified;
     iPacketDataQoSRecord->iGPRSMinDeliveryOrder = RPacketQoS::EDeliveryOrderUnspecified;
-    iPacketDataQoSRecord->iGPRSReqDeliverErroneousSDU = RPacketQoS::EErroneousSDUDeliveryUnspecified;
-    iPacketDataQoSRecord->iGPRSMinDeliverErroneousSDU = RPacketQoS::EErroneousSDUDeliveryUnspecified;
+    iPacketDataQoSRecord->iGPRSReqDeliverErroneousSDU =
+            RPacketQoS::EErroneousSDUDeliveryUnspecified;
+    iPacketDataQoSRecord->iGPRSMinDeliverErroneousSDU =
+            RPacketQoS::EErroneousSDUDeliveryUnspecified;
     iPacketDataQoSRecord->iGPRSReqMaxSDUSize = 0;
     iPacketDataQoSRecord->iGPRSMinAcceptableMaxSDUSize = 0;
     iPacketDataQoSRecord->iGPRSReqMaxUplinkRate = 0;
@@ -753,8 +765,10 @@
     iPacketDataQoSRecord->iGPRSMaxBER = RPacketQoS::EBERUnspecified;
     iPacketDataQoSRecord->iGPRSReqSDUErrorRatio = RPacketQoS::ESDUErrorRatioUnspecified;
     iPacketDataQoSRecord->iGPRSMaxSDUErrorRatio = RPacketQoS::ESDUErrorRatioUnspecified;
-    iPacketDataQoSRecord->iGPRSReqTrafficHandlingPriority = RPacketQoS::ETrafficPriorityUnspecified;
-    iPacketDataQoSRecord->iGPRSMinTrafficHandlingPriority = RPacketQoS::ETrafficPriorityUnspecified;
+    iPacketDataQoSRecord->iGPRSReqTrafficHandlingPriority =
+            RPacketQoS::ETrafficPriorityUnspecified;
+    iPacketDataQoSRecord->iGPRSMinTrafficHandlingPriority =
+            RPacketQoS::ETrafficPriorityUnspecified;
     iPacketDataQoSRecord->iGPRSReqTransferDelay = 0;
     iPacketDataQoSRecord->iGPRSMaxTransferDelay = 0;
     iPacketDataQoSRecord->iGPRSReqGuaranteedUplinkRate = 0;
@@ -763,7 +777,8 @@
     iPacketDataQoSRecord->iGPRSMinGuaranteedDownlinkRate = 0;
     iPacketDataQoSRecord->iGPRSSignallingIndication = EFalse;
     iPacketDataQoSRecord->iGPRS_ImCnSignallingIndication = EFalse;
-    iPacketDataQoSRecord->iGPRSSourceStatisticsDescriptor = RPacketQoS::ESourceStatisticsDescriptorUnknown;
+    iPacketDataQoSRecord->iGPRSSourceStatisticsDescriptor =
+            RPacketQoS::ESourceStatisticsDescriptorUnknown;
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_CREATEBEARERRECORDSL_EXIT );
     }
@@ -802,197 +817,245 @@
 
     if ( !clientServiceRecordCopy->iRecordTag.IsNull() )
         {
-        origServiceRecord->iRecordTag.SetL( clientServiceRecordCopy->iRecordTag );
+        origServiceRecord->iRecordTag.SetL(
+                clientServiceRecordCopy->iRecordTag );
         }
     if ( !clientServiceRecordCopy->iRecordName.IsNull() )
         {
-        origServiceRecord->iRecordName.SetL( clientServiceRecordCopy->iRecordName );
+        origServiceRecord->iRecordName.SetL(
+                clientServiceRecordCopy->iRecordName );
         }
 
     if ( !clientServiceRecordCopy->iServiceEnableLlmnr.IsNull() )
         {
-        origServiceRecord->iServiceEnableLlmnr.SetL( clientServiceRecordCopy->iServiceEnableLlmnr );
+        origServiceRecord->iServiceEnableLlmnr.SetL(
+                clientServiceRecordCopy->iServiceEnableLlmnr );
         }
 
     if ( !clientServiceRecordCopy->iGPRSAPN.IsNull() )
         {
-        origServiceRecord->iGPRSAPN.SetL( clientServiceRecordCopy->iGPRSAPN );
+        origServiceRecord->iGPRSAPN.SetL(
+                clientServiceRecordCopy->iGPRSAPN );
         }
     if ( !clientServiceRecordCopy->iGPRSPDPType.IsNull() )
         {
-        origServiceRecord->iGPRSPDPType.SetL( clientServiceRecordCopy->iGPRSPDPType );
+        origServiceRecord->iGPRSPDPType.SetL(
+                clientServiceRecordCopy->iGPRSPDPType );
         }
     if ( !clientServiceRecordCopy->iGPRSPDPAddress.IsNull() )
         {
-        origServiceRecord->iGPRSPDPAddress.SetL( clientServiceRecordCopy->iGPRSPDPAddress );
+        origServiceRecord->iGPRSPDPAddress.SetL(
+                clientServiceRecordCopy->iGPRSPDPAddress );
         }
     if ( !clientServiceRecordCopy->iGPRSReqPrecedence.IsNull() )
         {
-        origServiceRecord->iGPRSReqPrecedence.SetL( clientServiceRecordCopy->iGPRSReqPrecedence );
+        origServiceRecord->iGPRSReqPrecedence.SetL(
+                clientServiceRecordCopy->iGPRSReqPrecedence );
         }
     if ( !clientServiceRecordCopy->iGPRSReqDelay.IsNull() )
         {
-        origServiceRecord->iGPRSReqDelay.SetL( clientServiceRecordCopy->iGPRSReqDelay );
+        origServiceRecord->iGPRSReqDelay.SetL(
+                clientServiceRecordCopy->iGPRSReqDelay );
         }
     if ( !clientServiceRecordCopy->iGPRSReqReliability.IsNull() )
         {
-        origServiceRecord->iGPRSReqReliability.SetL( clientServiceRecordCopy->iGPRSReqReliability );
+        origServiceRecord->iGPRSReqReliability.SetL(
+                clientServiceRecordCopy->iGPRSReqReliability );
         }
     if ( !clientServiceRecordCopy->iGPRSReqPeakThroughput.IsNull() )
         {
-        origServiceRecord->iGPRSReqPeakThroughput.SetL( clientServiceRecordCopy->iGPRSReqPeakThroughput );
+        origServiceRecord->iGPRSReqPeakThroughput.SetL(
+                clientServiceRecordCopy->iGPRSReqPeakThroughput );
         }
     if ( !clientServiceRecordCopy->iGPRSReqMeanThroughput.IsNull() )
         {
-        origServiceRecord->iGPRSReqMeanThroughput.SetL( clientServiceRecordCopy->iGPRSReqMeanThroughput );
+        origServiceRecord->iGPRSReqMeanThroughput.SetL(
+                clientServiceRecordCopy->iGPRSReqMeanThroughput );
         }
     if ( !clientServiceRecordCopy->iGPRSMinPrecedence.IsNull() )
         {
-        origServiceRecord->iGPRSMinPrecedence.SetL( clientServiceRecordCopy->iGPRSMinPrecedence );
+        origServiceRecord->iGPRSMinPrecedence.SetL(
+                clientServiceRecordCopy->iGPRSMinPrecedence );
         }
     if ( !clientServiceRecordCopy->iGPRSMinDelay.IsNull() )
         {
-        origServiceRecord->iGPRSMinDelay.SetL( clientServiceRecordCopy->iGPRSMinDelay );
+        origServiceRecord->iGPRSMinDelay.SetL(
+                clientServiceRecordCopy->iGPRSMinDelay );
         }
     if ( !clientServiceRecordCopy->iGPRSMinReliability.IsNull() )
         {
-        origServiceRecord->iGPRSMinReliability.SetL( clientServiceRecordCopy->iGPRSMinReliability );
+        origServiceRecord->iGPRSMinReliability.SetL(
+                clientServiceRecordCopy->iGPRSMinReliability );
         }
     if ( !clientServiceRecordCopy->iGPRSMinPeakThroughput.IsNull() )
         {
-        origServiceRecord->iGPRSMinPeakThroughput.SetL( clientServiceRecordCopy->iGPRSMinPeakThroughput );
+        origServiceRecord->iGPRSMinPeakThroughput.SetL(
+                clientServiceRecordCopy->iGPRSMinPeakThroughput );
         }
     if ( !clientServiceRecordCopy->iGPRSMinMeanThroughput.IsNull() )
         {
-        origServiceRecord->iGPRSMinMeanThroughput.SetL( clientServiceRecordCopy->iGPRSMinMeanThroughput );
+        origServiceRecord->iGPRSMinMeanThroughput.SetL(
+                clientServiceRecordCopy->iGPRSMinMeanThroughput );
         }
     if ( !clientServiceRecordCopy->iGPRSDataCompression.IsNull() )
         {
-        origServiceRecord->iGPRSDataCompression.SetL( clientServiceRecordCopy->iGPRSDataCompression );
+        origServiceRecord->iGPRSDataCompression.SetL(
+                clientServiceRecordCopy->iGPRSDataCompression );
         }
     if ( !clientServiceRecordCopy->iGPRSHeaderCompression.IsNull() )
         {
-        origServiceRecord->iGPRSHeaderCompression.SetL( clientServiceRecordCopy->iGPRSHeaderCompression );
+        origServiceRecord->iGPRSHeaderCompression.SetL(
+                clientServiceRecordCopy->iGPRSHeaderCompression );
         }
     if ( !clientServiceRecordCopy->iGPRSUseEdge.IsNull() )
         {
-        origServiceRecord->iGPRSUseEdge.SetL( clientServiceRecordCopy->iGPRSUseEdge );
+        origServiceRecord->iGPRSUseEdge.SetL(
+                clientServiceRecordCopy->iGPRSUseEdge );
         }
     if ( !clientServiceRecordCopy->iGPRSAnonymousAccess.IsNull() )
         {
-        origServiceRecord->iGPRSAnonymousAccess.SetL( clientServiceRecordCopy->iGPRSAnonymousAccess );
+        origServiceRecord->iGPRSAnonymousAccess.SetL(
+                clientServiceRecordCopy->iGPRSAnonymousAccess );
         }
     if ( !clientServiceRecordCopy->iGPRSIfParams.IsNull() )
         {
-        origServiceRecord->iGPRSIfParams.SetL( clientServiceRecordCopy->iGPRSIfParams );
+        origServiceRecord->iGPRSIfParams.SetL(
+                clientServiceRecordCopy->iGPRSIfParams );
         }
     if ( !clientServiceRecordCopy->iGPRSIfNetworks.IsNull() )
         {
-        origServiceRecord->iGPRSIfNetworks.SetL( clientServiceRecordCopy->iGPRSIfNetworks );
+        origServiceRecord->iGPRSIfNetworks.SetL(
+                clientServiceRecordCopy->iGPRSIfNetworks );
         }
     if ( !clientServiceRecordCopy->iGPRSIfPromptForAuth.IsNull() )
         {
-        origServiceRecord->iGPRSIfPromptForAuth.SetL( clientServiceRecordCopy->iGPRSIfPromptForAuth );
+        origServiceRecord->iGPRSIfPromptForAuth.SetL(
+                clientServiceRecordCopy->iGPRSIfPromptForAuth );
         }
     if ( !clientServiceRecordCopy->iGPRSIfAuthName.IsNull() )
         {
-        origServiceRecord->iGPRSIfAuthName.SetL( clientServiceRecordCopy->iGPRSIfAuthName );
+        origServiceRecord->iGPRSIfAuthName.SetL(
+                clientServiceRecordCopy->iGPRSIfAuthName );
         }
     if ( !clientServiceRecordCopy->iGPRSIfAuthPass.IsNull() )
         {
-        origServiceRecord->iGPRSIfAuthPass.SetL( clientServiceRecordCopy->iGPRSIfAuthPass );
+        origServiceRecord->iGPRSIfAuthPass.SetL(
+                clientServiceRecordCopy->iGPRSIfAuthPass );
         }
     if ( !clientServiceRecordCopy->iGPRSIfAuthRetries.IsNull() )
         {
-        origServiceRecord->iGPRSIfAuthRetries.SetL( clientServiceRecordCopy->iGPRSIfAuthRetries );
+        origServiceRecord->iGPRSIfAuthRetries.SetL(
+                clientServiceRecordCopy->iGPRSIfAuthRetries );
         }
     if ( !clientServiceRecordCopy->iGPRSIPNetMask.IsNull() )
         {
-        origServiceRecord->iGPRSIPNetMask.SetL( clientServiceRecordCopy->iGPRSIPNetMask );
+        origServiceRecord->iGPRSIPNetMask.SetL(
+                clientServiceRecordCopy->iGPRSIPNetMask );
         }
     if ( !clientServiceRecordCopy->iGPRSIPGateway.IsNull() )
         {
-        origServiceRecord->iGPRSIPGateway.SetL( clientServiceRecordCopy->iGPRSIPGateway );
+        origServiceRecord->iGPRSIPGateway.SetL(
+                clientServiceRecordCopy->iGPRSIPGateway );
         }
     if ( !clientServiceRecordCopy->iGPRSIPAddrFromServer.IsNull() )
         {
-        origServiceRecord->iGPRSIPAddrFromServer.SetL( clientServiceRecordCopy->iGPRSIPAddrFromServer );
+        origServiceRecord->iGPRSIPAddrFromServer.SetL(
+                clientServiceRecordCopy->iGPRSIPAddrFromServer );
         }
     if ( !clientServiceRecordCopy->iGPRSIPAddr.IsNull() )
         {
-        origServiceRecord->iGPRSIPAddr.SetL( clientServiceRecordCopy->iGPRSIPAddr );
+        origServiceRecord->iGPRSIPAddr.SetL(
+                clientServiceRecordCopy->iGPRSIPAddr );
         }
     if ( !clientServiceRecordCopy->iGPRSIPDNSAddrFromServer.IsNull() )
         {
-        origServiceRecord->iGPRSIPDNSAddrFromServer.SetL( clientServiceRecordCopy->iGPRSIPDNSAddrFromServer );
+        origServiceRecord->iGPRSIPDNSAddrFromServer.SetL(
+                clientServiceRecordCopy->iGPRSIPDNSAddrFromServer );
         }
     if ( !clientServiceRecordCopy->iGPRSIPNameServer1.IsNull() )
         {
-        origServiceRecord->iGPRSIPNameServer1.SetL( clientServiceRecordCopy->iGPRSIPNameServer1 );
+        origServiceRecord->iGPRSIPNameServer1.SetL(
+                clientServiceRecordCopy->iGPRSIPNameServer1 );
         }
     if ( !clientServiceRecordCopy->iGPRSIPNameServer2.IsNull() )
         {
-        origServiceRecord->iGPRSIPNameServer2.SetL( clientServiceRecordCopy->iGPRSIPNameServer2 );
+        origServiceRecord->iGPRSIPNameServer2.SetL(
+                clientServiceRecordCopy->iGPRSIPNameServer2 );
         }
     if ( !clientServiceRecordCopy->iGPRSIP6DNSAddrFromServer.IsNull() )
         {
-        origServiceRecord->iGPRSIP6DNSAddrFromServer.SetL( clientServiceRecordCopy->iGPRSIP6DNSAddrFromServer );
+        origServiceRecord->iGPRSIP6DNSAddrFromServer.SetL(
+                clientServiceRecordCopy->iGPRSIP6DNSAddrFromServer );
         }
     if ( !clientServiceRecordCopy->iGPRSIP6NameServer1.IsNull() )
         {
-        origServiceRecord->iGPRSIP6NameServer1.SetL( clientServiceRecordCopy->iGPRSIP6NameServer1 );
+        origServiceRecord->iGPRSIP6NameServer1.SetL(
+                clientServiceRecordCopy->iGPRSIP6NameServer1 );
         }
     if ( !clientServiceRecordCopy->iGPRSIP6NameServer2.IsNull() )
         {
-        origServiceRecord->iGPRSIP6NameServer2.SetL( clientServiceRecordCopy->iGPRSIP6NameServer2 );
+        origServiceRecord->iGPRSIP6NameServer2.SetL(
+                clientServiceRecordCopy->iGPRSIP6NameServer2 );
         }
     if ( !clientServiceRecordCopy->iGPRSIPAddrLeaseValidFrom.IsNull() )
         {
-        origServiceRecord->iGPRSIPAddrLeaseValidFrom.SetL( clientServiceRecordCopy->iGPRSIPAddrLeaseValidFrom );
+        origServiceRecord->iGPRSIPAddrLeaseValidFrom.SetL(
+                clientServiceRecordCopy->iGPRSIPAddrLeaseValidFrom );
         }
     if ( !clientServiceRecordCopy->iGPRSIPAddrLeaseValidTo.IsNull() )
         {
-        origServiceRecord->iGPRSIPAddrLeaseValidTo.SetL( clientServiceRecordCopy->iGPRSIPAddrLeaseValidTo );
+        origServiceRecord->iGPRSIPAddrLeaseValidTo.SetL(
+                clientServiceRecordCopy->iGPRSIPAddrLeaseValidTo );
         }
     if ( !clientServiceRecordCopy->iGPRSConfigDaemonManagerName.IsNull() )
         {
-        origServiceRecord->iGPRSConfigDaemonManagerName.SetL( clientServiceRecordCopy->iGPRSConfigDaemonManagerName );
+        origServiceRecord->iGPRSConfigDaemonManagerName.SetL(
+                clientServiceRecordCopy->iGPRSConfigDaemonManagerName );
         }
     if ( !clientServiceRecordCopy->iGPRSConfigDaemonName.IsNull() )
         {
-        origServiceRecord->iGPRSConfigDaemonName.SetL( clientServiceRecordCopy->iGPRSConfigDaemonName );
+        origServiceRecord->iGPRSConfigDaemonName.SetL(
+                clientServiceRecordCopy->iGPRSConfigDaemonName );
         }
     if ( !clientServiceRecordCopy->iGPRSEnableLCPExtension.IsNull() )
         {
-        origServiceRecord->iGPRSEnableLCPExtension.SetL( clientServiceRecordCopy->iGPRSEnableLCPExtension );
+        origServiceRecord->iGPRSEnableLCPExtension.SetL(
+                clientServiceRecordCopy->iGPRSEnableLCPExtension );
         }
     if ( !clientServiceRecordCopy->iGPRSDisablePlainTextAuth.IsNull() )
         {
-        origServiceRecord->iGPRSDisablePlainTextAuth.SetL( clientServiceRecordCopy->iGPRSDisablePlainTextAuth );
+        origServiceRecord->iGPRSDisablePlainTextAuth.SetL(
+                clientServiceRecordCopy->iGPRSDisablePlainTextAuth );
         }
     if ( !clientServiceRecordCopy->iGPRSAPType.IsNull() )
         {
-        origServiceRecord->iGPRSAPType.SetL( clientServiceRecordCopy->iGPRSAPType );
+        origServiceRecord->iGPRSAPType.SetL(
+                clientServiceRecordCopy->iGPRSAPType );
         }
     if ( !clientServiceRecordCopy->iGPRSQOSWarningTimeOut.IsNull() )
         {
-        origServiceRecord->iGPRSQOSWarningTimeOut.SetL( clientServiceRecordCopy->iGPRSQOSWarningTimeOut );
+        origServiceRecord->iGPRSQOSWarningTimeOut.SetL(
+                clientServiceRecordCopy->iGPRSQOSWarningTimeOut );
         }
     if ( !clientServiceRecordCopy->iGPRSR5DataCompression.IsNull() )
         {
-        origServiceRecord->iGPRSR5DataCompression.SetL( clientServiceRecordCopy->iGPRSR5DataCompression );
+        origServiceRecord->iGPRSR5DataCompression.SetL(
+                clientServiceRecordCopy->iGPRSR5DataCompression );
         }
     if ( !clientServiceRecordCopy->iGPRSR5HeaderCompression.IsNull() )
         {
-        origServiceRecord->iGPRSR5HeaderCompression.SetL( clientServiceRecordCopy->iGPRSR5HeaderCompression );
+        origServiceRecord->iGPRSR5HeaderCompression.SetL(
+                clientServiceRecordCopy->iGPRSR5HeaderCompression );
         }
     if ( !clientServiceRecordCopy->iGPRSPacketFlowIdentifier.IsNull() )
         {
-        origServiceRecord->iGPRSPacketFlowIdentifier.SetL( clientServiceRecordCopy->iGPRSPacketFlowIdentifier );
+        origServiceRecord->iGPRSPacketFlowIdentifier.SetL(
+                clientServiceRecordCopy->iGPRSPacketFlowIdentifier );
         }
     if ( !clientServiceRecordCopy->iGPRSUmtsGprsRelease.IsNull() )
         {
-        origServiceRecord->iGPRSUmtsGprsRelease.SetL( clientServiceRecordCopy->iGPRSUmtsGprsRelease );
+        origServiceRecord->iGPRSUmtsGprsRelease.SetL(
+                clientServiceRecordCopy->iGPRSUmtsGprsRelease );
         }
 
     if ( iPacketDataQoSRecord )
@@ -1028,15 +1091,14 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_UPDATEBEARERRECORDSL_ENTRY );
 
-    delete iPacketDataQoSRecord;
-    iPacketDataQoSRecord = NULL;
-
     CCDUmtsR99QoSAndOnTableRecord* packetDataQoSRecord =
             static_cast<CCDUmtsR99QoSAndOnTableRecord*>( aBearerSpecRecordArray[KQosRecordIndex] );
 
+    delete iPacketDataQoSRecord;
+    iPacketDataQoSRecord = NULL;
     iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
-            CCDRecordBase::CreateCopyRecordL( *packetDataQoSRecord ) );
-
+            CCDRecordBase::RecordFactoryL( KCDTIdUmtsR99QoSAndOnTableRecord ) );
+    CopyRecordFieldsL( *packetDataQoSRecord, *iPacketDataQoSRecord );
     iPacketDataQoSRecord->SetElementId( aBearerSpecRecordArray[KQosRecordIndex]->ElementId() );
 
     if ( !iPacketDataQoSRecord->RecordId() )
@@ -1072,14 +1134,15 @@
 
     if ( !iPacketDataQoSRecord )
         {
-        // IAP not yet in CommDat
+        // IAP not yet in CommDat.
         GetDefaultQosRecordL( aRecordArray );
         }
     else
         {
         CCDUmtsR99QoSAndOnTableRecord* qosRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
-                CCDRecordBase::CreateCopyRecordL( *iPacketDataQoSRecord ) );
+                CCDRecordBase::RecordFactoryL( KCDTIdUmtsR99QoSAndOnTableRecord ) );
         CleanupStack::PushL( qosRecord );
+        CopyRecordFieldsL( *iPacketDataQoSRecord, *qosRecord );
         qosRecord->SetElementId( iPacketDataQoSRecord->ElementId() );
         aRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( qosRecord ) );
         CleanupStack::Pop( qosRecord );
@@ -1160,7 +1223,7 @@
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_GETDEFAULTQOSRECORDL_ENTRY );
 
     CCDUmtsR99QoSAndOnTableRecord* packetDataQoSRecord =
-            static_cast<CCDUmtsR99QoSAndOnTableRecord *>(
+            static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
                     CCDRecordBase::RecordFactoryL( KCDTIdUmtsR99QoSAndOnTableRecord ) );
     CleanupStack::PushL( packetDataQoSRecord );
 
@@ -1168,8 +1231,10 @@
     packetDataQoSRecord->iGPRSMinTrafficClass = RPacketQoS::ETrafficClassUnspecified;
     packetDataQoSRecord->iGPRSReqDeliveryOrder = RPacketQoS::EDeliveryOrderUnspecified;
     packetDataQoSRecord->iGPRSMinDeliveryOrder = RPacketQoS::EDeliveryOrderUnspecified;
-    packetDataQoSRecord->iGPRSReqDeliverErroneousSDU = RPacketQoS::EErroneousSDUDeliveryUnspecified;
-    packetDataQoSRecord->iGPRSMinDeliverErroneousSDU = RPacketQoS::EErroneousSDUDeliveryUnspecified;
+    packetDataQoSRecord->iGPRSReqDeliverErroneousSDU =
+            RPacketQoS::EErroneousSDUDeliveryUnspecified;
+    packetDataQoSRecord->iGPRSMinDeliverErroneousSDU =
+            RPacketQoS::EErroneousSDUDeliveryUnspecified;
     packetDataQoSRecord->iGPRSReqMaxSDUSize = 0;
     packetDataQoSRecord->iGPRSMinAcceptableMaxSDUSize = 0;
     packetDataQoSRecord->iGPRSReqMaxUplinkRate = 0;
@@ -1180,8 +1245,10 @@
     packetDataQoSRecord->iGPRSMaxBER = RPacketQoS::EBERUnspecified;
     packetDataQoSRecord->iGPRSReqSDUErrorRatio = RPacketQoS::ESDUErrorRatioUnspecified;
     packetDataQoSRecord->iGPRSMaxSDUErrorRatio = RPacketQoS::ESDUErrorRatioUnspecified;
-    packetDataQoSRecord->iGPRSReqTrafficHandlingPriority = RPacketQoS::ETrafficPriorityUnspecified;
-    packetDataQoSRecord->iGPRSMinTrafficHandlingPriority = RPacketQoS::ETrafficPriorityUnspecified;
+    packetDataQoSRecord->iGPRSReqTrafficHandlingPriority =
+            RPacketQoS::ETrafficPriorityUnspecified;
+    packetDataQoSRecord->iGPRSMinTrafficHandlingPriority =
+            RPacketQoS::ETrafficPriorityUnspecified;
     packetDataQoSRecord->iGPRSReqTransferDelay = 0;
     packetDataQoSRecord->iGPRSMaxTransferDelay = 0;
     packetDataQoSRecord->iGPRSReqGuaranteedUplinkRate = 0;
@@ -1190,7 +1257,8 @@
     packetDataQoSRecord->iGPRSMinGuaranteedDownlinkRate = 0;
     packetDataQoSRecord->iGPRSSignallingIndication = EFalse;
     packetDataQoSRecord->iGPRS_ImCnSignallingIndication = EFalse;
-    packetDataQoSRecord->iGPRSSourceStatisticsDescriptor = RPacketQoS::ESourceStatisticsDescriptorUnknown;
+    packetDataQoSRecord->iGPRSSourceStatisticsDescriptor =
+            RPacketQoS::ESourceStatisticsDescriptorUnknown;
 
     aRecordArray.AppendL( static_cast<CommsDat::CCDRecordBase*>( packetDataQoSRecord ) );
     CleanupStack::Pop( packetDataQoSRecord );
@@ -1231,9 +1299,13 @@
                 }
                 break;
             case ECmDefaultUiPriority:
+                {
+                retVal = GetDefPriorityL( aAttribute );
+                }
+                break;
             case ECmDefaultPriority:
                 {
-                retVal = KDefaultPriorityPacketData;
+                retVal = GetDefPriorityL( aAttribute );
                 }
                 break;
             case ECmExtensionLevel:
@@ -1243,7 +1315,8 @@
                 break;
             case ECmInvalidAttribute:
                 {
-                retVal = 0;
+                // This attribute has been deprecated since Symbian^4.
+                User::Leave( KErrNotSupported );
                 }
                 break;
             case ECmIFAuthRetries:
@@ -1253,7 +1326,7 @@
                 break;
             default:
                 {
-                User::Leave( KErrNotFound );
+                User::Leave( KErrNotFound ); //TODO, check leave code, should it be KErrNotSupported ?
                 }
                 break;
             }
@@ -1285,8 +1358,9 @@
 // CCmPluginPacketData::GetServiceIntAttributeL
 // ---------------------------------------------------------------------------
 //
-TUint32 CCmPluginPacketData::GetServiceIntAttributeL( TUint32 aAttribute,
-                                                      RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray )
+TUint32 CCmPluginPacketData::GetServiceIntAttributeL(
+        TUint32 aAttribute,
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray )
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_GETSERVICEINTATTRIBUTEL_ENTRY );
 
@@ -1395,15 +1469,16 @@
 // CCmPluginPacketData::GetQosIntAttributeL
 // ---------------------------------------------------------------------------
 //
-TUint32 CCmPluginPacketData::GetQosIntAttributeL( TUint32 aAttribute,
-                                                  RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+TUint32 CCmPluginPacketData::GetQosIntAttributeL(
+        TUint32 aAttribute,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_GETQOSINTATTRIBUTEL_ENTRY );
 
     TUint32 retVal( 0 );
 
-    CCDUmtsR99QoSAndOnTableRecord* qosRecord =
-            static_cast<CCDUmtsR99QoSAndOnTableRecord*>( aBearerSpecRecordArray[KQosRecordIndex] );
+    CCDUmtsR99QoSAndOnTableRecord* qosRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
+            aBearerSpecRecordArray[KQosRecordIndex] );
 
     switch ( aAttribute )
         {
@@ -1562,7 +1637,6 @@
         }
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_GETQOSINTATTRIBUTEL_EXIT );
-
     return retVal;
     }
 
@@ -1918,8 +1992,8 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_SETSERVICEINTATTRIBUTEL_ENTRY );
 
-    CCDWCDMAPacketServiceRecord* serviceRecord =
-                static_cast<CCDWCDMAPacketServiceRecord*>( aGenRecordArray[KServiceRecordIndex] );
+    CCDWCDMAPacketServiceRecord* serviceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
+            aGenRecordArray[KServiceRecordIndex] );
 
     switch ( aAttribute )
         {
@@ -2020,48 +2094,54 @@
 // ---------------------------------------------------------------------------
 //
 void CCmPluginPacketData::SetQosIntAttributeL(
-    TUint32 aAttribute,
-    TUint32 aValue,
-    RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+        TUint32 aAttribute,
+        TUint32 aValue,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_SETQOSINTATTRIBUTEL_ENTRY );
 
-    CCDUmtsR99QoSAndOnTableRecord* qosRecord =
-                static_cast<CCDUmtsR99QoSAndOnTableRecord*>( aBearerSpecRecordArray[KQosRecordIndex] );
+    CCDUmtsR99QoSAndOnTableRecord* qosRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
+            aBearerSpecRecordArray[KQosRecordIndex] );
 
     switch ( aAttribute )
         {
         case EGPRSReqTrafficClass:
             {
-            qosRecord->iGPRSReqTrafficClass.SetL( static_cast<RPacketQoS::TTrafficClass>( aValue ) );
+            qosRecord->iGPRSReqTrafficClass.SetL(
+                    static_cast<RPacketQoS::TTrafficClass>( aValue ) );
             }
             break;
 
         case EGPRSMinTrafficClass:
             {
-            qosRecord->iGPRSMinTrafficClass.SetL( static_cast<RPacketQoS::TTrafficClass>( aValue ) );
+            qosRecord->iGPRSMinTrafficClass.SetL(
+                    static_cast<RPacketQoS::TTrafficClass>( aValue ) );
             }
             break;
 
         case EGPRSReqDeliveryOrder:
             {
-            qosRecord->iGPRSReqDeliveryOrder.SetL( static_cast<RPacketQoS::TDeliveryOrder>( aValue ) );
+            qosRecord->iGPRSReqDeliveryOrder.SetL(
+                    static_cast<RPacketQoS::TDeliveryOrder>( aValue ) );
             }
             break;
 
         case GPRSMinDeliveryOrder:
             {
-            qosRecord->iGPRSMinDeliveryOrder.SetL( static_cast<RPacketQoS::TDeliveryOrder>( aValue ) );
+            qosRecord->iGPRSMinDeliveryOrder.SetL(
+                    static_cast<RPacketQoS::TDeliveryOrder>( aValue ) );
             }
             break;
         case EGPRSReqDeliverErroneousSDU:
             {
-            qosRecord->iGPRSReqDeliverErroneousSDU.SetL( static_cast<RPacketQoS::TErroneousSDUDelivery>( aValue ) );
+            qosRecord->iGPRSReqDeliverErroneousSDU.SetL(
+                    static_cast<RPacketQoS::TErroneousSDUDelivery>( aValue ) );
             }
             break;
         case EGPRSMinDeliverErroneousSDU:
             {
-            qosRecord->iGPRSMinDeliverErroneousSDU.SetL( static_cast<RPacketQoS::TErroneousSDUDelivery>( aValue ) );
+            qosRecord->iGPRSMinDeliverErroneousSDU.SetL(
+                    static_cast<RPacketQoS::TErroneousSDUDelivery>( aValue ) );
             }
             break;
         case EGPRSReqMaxSDUSize:
@@ -2102,37 +2182,43 @@
 
         case EGPRSReqBER:
             {
-            qosRecord->iGPRSReqBER.SetL( static_cast<RPacketQoS::TBitErrorRatio>( aValue ) );
+            qosRecord->iGPRSReqBER.SetL(
+                    static_cast<RPacketQoS::TBitErrorRatio>( aValue ) );
             }
             break;
 
         case EGPRSMaxBER:
             {
-            qosRecord->iGPRSMaxBER.SetL( static_cast<RPacketQoS::TBitErrorRatio>( aValue ) );
+            qosRecord->iGPRSMaxBER.SetL(
+                    static_cast<RPacketQoS::TBitErrorRatio>( aValue ) );
             }
             break;
 
         case EGPRSReqSDUErrorRatio:
             {
-            qosRecord->iGPRSReqSDUErrorRatio.SetL( static_cast<RPacketQoS::TSDUErrorRatio>( aValue ) );
+            qosRecord->iGPRSReqSDUErrorRatio.SetL(
+                    static_cast<RPacketQoS::TSDUErrorRatio>( aValue ) );
             }
             break;
 
         case EGPRSMaxSDUErrorRatio:
             {
-            qosRecord->iGPRSMaxSDUErrorRatio.SetL( static_cast<RPacketQoS::TSDUErrorRatio>( aValue ) );
+            qosRecord->iGPRSMaxSDUErrorRatio.SetL(
+                    static_cast<RPacketQoS::TSDUErrorRatio>( aValue ) );
             }
             break;
 
         case EGPRSReqTrafficHandlingPriority:
             {
-            qosRecord->iGPRSReqTrafficHandlingPriority.SetL( static_cast<RPacketQoS::TTrafficHandlingPriority>( aValue ) );
+            qosRecord->iGPRSReqTrafficHandlingPriority.SetL(
+                    static_cast<RPacketQoS::TTrafficHandlingPriority>( aValue ) );
             }
             break;
 
         case EGPRSMinTrafficHandlingPriority:
             {
-            qosRecord->iGPRSMinTrafficHandlingPriority.SetL( static_cast<RPacketQoS::TTrafficHandlingPriority>( aValue ) );
+            qosRecord->iGPRSMinTrafficHandlingPriority.SetL(
+                    static_cast<RPacketQoS::TTrafficHandlingPriority>( aValue ) );
             }
             break;
 
@@ -2174,7 +2260,8 @@
 
         case EGPRSSourceStatisticsDescriptor:
             {
-            qosRecord->iGPRSSourceStatisticsDescriptor.SetL( static_cast<RPacketQoS::TSourceStatisticsDescriptor>( aValue ) );
+            qosRecord->iGPRSSourceStatisticsDescriptor.SetL(
+                    static_cast<RPacketQoS::TSourceStatisticsDescriptor>( aValue ) );
             }
             break;
 
@@ -2184,6 +2271,7 @@
             }
             break;
         }
+
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_SETQOSINTATTRIBUTEL_EXIT );
     }
 
@@ -2191,14 +2279,16 @@
 // CCmPluginPacketData::SetBearerBoolAttributeL
 // ---------------------------------------------------------------------------
 //
-void CCmPluginPacketData::SetBearerBoolAttributeL( TUint32 aAttribute, TBool aValue,
-                                        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
-                                        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+void CCmPluginPacketData::SetBearerBoolAttributeL(
+        TUint32 aAttribute,
+        TBool aValue,
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_SETBEARERBOOLATTRIBUTEL_ENTRY );
 
-    CCDWCDMAPacketServiceRecord* serviceRecord =
-                    static_cast<CCDWCDMAPacketServiceRecord*>( aGenRecordArray[KServiceRecordIndex] );
+    CCDWCDMAPacketServiceRecord* serviceRecord = static_cast<CCDWCDMAPacketServiceRecord*>(
+            aGenRecordArray[KServiceRecordIndex] );
 
     switch ( aAttribute )
         {
@@ -2265,14 +2355,16 @@
             break;
         case EGPRSSignallingIndication:
             {
-            static_cast<CCDUmtsR99QoSAndOnTableRecord*>
-                 ( aBearerSpecRecordArray[KQosRecordIndex] )->iGPRSSignallingIndication.SetL( aValue );
+            static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
+                    aBearerSpecRecordArray[KQosRecordIndex] )
+                    ->iGPRSSignallingIndication.SetL( aValue );
             }
             break;
         case EGPRS_ImCnSignallingIndication:
             {
             static_cast<CCDUmtsR99QoSAndOnTableRecord*>
-                 ( aBearerSpecRecordArray[KQosRecordIndex] )->iGPRS_ImCnSignallingIndication.SetL( aValue );
+                 ( aBearerSpecRecordArray[KQosRecordIndex] )
+                 ->iGPRS_ImCnSignallingIndication.SetL( aValue );
             }
             break;
         case EPacketDataServiceEnableLLMNR:
@@ -2286,6 +2378,7 @@
             }
             break;
         }
+
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_SETBEARERBOOLATTRIBUTEL_EXIT );
     }
 
@@ -2457,16 +2550,17 @@
 // CCmPluginPacketData::SetBearerString8AttributeL
 // ---------------------------------------------------------------------------
 //
-void CCmPluginPacketData::SetBearerString8AttributeL( TUint32 /*aAttribute*/, const TDesC8& /*aValue*/,
-                                           RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
-                                           RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+void CCmPluginPacketData::SetBearerString8AttributeL(
+        TUint32 /*aAttribute*/,
+        const TDesC8& /*aValue*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
     {
     OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_SETBEARERSTRING8ATTRIBUTEL_ENTRY );
 
     User::Leave( KErrNotSupported );
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_SETBEARERSTRING8ATTRIBUTEL_EXIT );
-
     return;
     }
 
@@ -2492,11 +2586,14 @@
             retVal = KCommDbBearerWcdma;
             }
             break;
-
         case ECmDefaultUiPriority:
+            {
+            retVal = GetDefPriorityL( aAttribute );
+            }
+            break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityPacketData;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ECmExtensionLevel:
@@ -2513,7 +2610,6 @@
         }
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_GETBEARERINFOINTL_EXIT );
-
     return retVal;
     }
 
@@ -2571,7 +2667,6 @@
         }
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_GETBEARERINFOBOOLL_EXIT );
-
     return retVal;
     }
 
@@ -2595,7 +2690,6 @@
         }
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_GETBEARERINFOSTRINGL_EXIT );
-
     return retVal;
     }
 
@@ -2962,9 +3056,12 @@
 
     CCmPluginPacketData* plugin = static_cast<CCmPluginPacketData*>( aCopyInstance );
 
-    plugin->iPacketDataQoSRecord =
-        static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
-                CCDRecordBase::CreateCopyRecordL( *iPacketDataQoSRecord ) );
+    CCDUmtsR99QoSAndOnTableRecord* qosRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdUmtsR99QoSAndOnTableRecord ) );
+    CleanupStack::PushL( qosRecord );
+    CopyRecordFieldsL( *iPacketDataQoSRecord, *qosRecord );
+    CleanupStack::Pop( qosRecord );
+    plugin->iPacketDataQoSRecord = qosRecord;
 
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_COPYBEARERRECORDSL_EXIT );
     }
@@ -2984,4 +3081,46 @@
     OstTraceFunctionExit0( CCMPLUGINPACKETDATA_GETBEARERTABLEIDSTOBEOBSERVEDL_EXIT );
     }
 
+// ---------------------------------------------------------------------------
+// CCmPluginPacketData::GetDefPriorityL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginPacketData::GetDefPriorityL( const TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINPACKETDATA_GETDEFPRIORITYL_ENTRY );
+
+    TUint32 retVal( KDataMobilitySelectionPolicyPriorityWildCard );
+
+    CCDGlobalBearerTypePriorizationRecord* priorityRecord =
+            new( ELeave ) CCDGlobalBearerTypePriorizationRecord( iBearerPriorityTableId );
+    CleanupStack::PushL( priorityRecord );
+
+    priorityRecord->iServiceType.SetL( TPtrC( KCDTypeNameOutgoingWCDMA ) );
+
+    if ( priorityRecord->FindL( iSession ) )
+        {
+        priorityRecord->LoadL( iSession );
+
+        switch ( aAttribute )
+            {
+            case ECmDefaultPriority:
+                {
+                retVal = priorityRecord->iPriority;
+                }
+                break;
+            case ECmDefaultUiPriority:
+                {
+                retVal = priorityRecord->iUIPriority;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    CleanupStack::PopAndDestroy( priorityRecord );
+
+    OstTraceFunctionExit0( CCMPLUGINPACKETDATA_GETDEFPRIORITYL_EXIT );
+    return retVal;
+    }
+
 // End of file
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/src/cmpluginpacketdataproxy.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/src/cmpluginpacketdataproxy.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 
 #include <e32std.h>
-#include <ecom/ImplementationProxy.h>
+#include <ecom/implementationproxy.h>
 
 #include "cmpluginpacketdata.h"
 
@@ -29,9 +29,9 @@
     IMPLEMENTATION_PROXY_ENTRY( KUidPacketDataBearerType, CCmPluginPacketData::NewL)
     };
 
-EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
     {
-    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
 
     return ImplementationTable;
     }
--- a/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/traces/OstTraceDefinitions.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginpacketdata/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef __OSTTRACEDEFINITIONS_H__
 #define __OSTTRACEDEFINITIONS_H__
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/data/10281BBE.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+* ECom resource descriptor for VPN plug-in 
+*/
+
+#include "ecom/registryinfo.rh"
+
+// Because attribute enums had to be added to namespace CMManager
+// it's not possible to included cmpluginvpndef.h.
+// Thus bearer type id had to be redefined here.
+#define KPluginVPNBearerTypeUid   0x10281BBD
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = 0x10281BBE;
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x10207377; // = KCMPluginInterfaceUid. Do NOT modify it!!!
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KPluginVPNBearerTypeUid;
+                    version_no = 1;
+                    display_name = "VPN";
+                    default_data = "VPN";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*      Build information for the VPN plugin.   
+*      
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+// export iby files
+../rom/cmmpluginvpn.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(cmmpluginvpn.iby)
+
+PRJ_MMPFILES
+cmpluginvpn.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/group/cmpluginvpn.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*      Project specification for LAN Plugin.   
+*      
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET      cmpluginvpn.dll
+UID         0x10009D8D 0x10281BBE
+
+TARGETTYPE		PLUGIN
+
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH  ../src
+
+SOURCE      cmpluginvpnproxy.cpp
+SOURCE      cmpluginvpn.cpp
+
+SOURCEPATH  ../data
+
+START RESOURCE 10281BBE.rss
+TARGET cmpluginvpn.rsc
+END
+
+// Component specific internal headers 
+USERINCLUDE         ../inc 
+USERINCLUDE         ../../../cmmcommon/inc
+USERINCLUDE         ../traces
+
+
+// ADO specific internal headers 
+SYSTEMINCLUDE		../../../database/inc
+
+//Macro to /epoc32 headers
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY euser.lib
+LIBRARY	ecom.lib
+LIBRARY featmgr.lib
+LIBRARY commsdat.lib
+LIBRARY	cmmpluginbase.lib
+LIBRARY cmmanagerdatabase.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/inc/cmpluginvpn.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,354 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*      Declaration of VPN CmManager plugin interface implementation 
+*      
+*
+*/
+
+#ifndef CMPLUGINVPN_H
+#define CMPLUGINVPN_H
+
+// INCLUDES
+#include <cmpluginbaseeng.h>
+#include <cmpluginvpndef.h>
+
+// FORWARD DECLARATION
+class CCDVirtualIAPNextLayerRecord;
+
+/**
+*  CCmPluginVpn defines the functionality of vpn bearer support.
+*  Most of the API is inherited from CCmPluginBaseEng class.
+*/
+NONSHARABLE_CLASS( CCmPluginVpn ) : public CCmPluginBaseEng
+    {
+    public: // Constructors and destructor
+        /**
+         * Two phased constructor.
+         * @return Returns the VPN plugin object.
+         */      
+		static CCmPluginVpn* NewL( TCmPluginInitParam* aInitParam );
+
+        /**
+         * Destructor.
+         */      
+        virtual ~CCmPluginVpn();
+
+    public: // From CCmPluginBaseEng
+        /**
+         * Creates a new instance of VPN bearer plugin. The instance
+         * created represents a bearer, not a connection method.
+         * @param aInitParam Initialization data.
+         * @return Returns CCmPluginBaseEng type pointer which represents pure
+         * bearer instance for the cmm server.
+         */
+        virtual CCmPluginBaseEng* CreateInstanceL( 
+                TCmPluginInitParam& aInitParam ) const;
+                
+        /**
+         * Following GetBearerInfoXXXL methods return the values of the 
+         * requested attributes. These values are bearerspecific so they
+         * don't vary between CMs with same bearer type.
+         * @param aAttribute An attribute identifier.
+         * @return Returns the value requested. If not found leaves with
+         * KErrNotFound error code. 
+         */
+        virtual TUint32 GetBearerInfoIntL( TUint32 aAttribute ) const;
+        
+        virtual TBool GetBearerInfoBoolL( TUint32 aAttribute ) const;
+
+        virtual HBufC* GetBearerInfoStringL( TUint32 aAttribute ) const;
+        
+        virtual HBufC8* GetBearerInfoString8L( TUint32 aAttribute ) const;
+
+        /**
+         * Checks if the plug-in can handle the Connection Method identified
+         * with parameter aIapId.
+         * @param aIapId IAPId of the AP to be checked
+         * @return ETrue if plug-in can handle the IAP, otherwise EFalse.
+         */
+        TBool CanHandleIapIdL( TUint32 aIapId ) const;
+         
+        /**
+         * Checks if the plug-in can handle the given IAP record.
+         * @param aIapRecord IAP record to be checked
+         * @return ETrue if plug-in can handle the IAP, otherwise EFalse.
+         */
+        TBool CanHandleIapIdL( CommsDat::CCDIAPRecord* aIapRecord ) const;
+
+        /**
+         * Requests CommsDat table ids to be observed for changes by the cmm
+         * server. If a table used is not mentioned to be modified a bearer
+         * shouldn't return this. Bearers do not reset the array before adding
+         * ids.
+         * @param aTableIdArray A reference to an array where plugin must add
+         * the ids of the tables it want's to be observed.
+         */
+        void GetBearerTableIdsToBeObservedL( RArray<TUint32>& aTableIdArray ) const;
+
+        
+        /**
+         * Creates a copy of all bearer specific CommsDat data for the client.
+         * Called as result of GetPluginDataL().
+         * @param aRecordArray An array where the copy the records. Only 
+         * the bearer specific implementation knows the amount and order
+         * of these records in the array.
+         */
+        virtual void GetBearerSpecificRecordsL( 
+                RPointerArray<CommsDat::CCDRecordBase>& aRecordArray );
+
+        /**
+         * Following GetBearerXXXXAttribute methods get only the
+         * fields in records in pointer arrays(parameters).
+         * @param aAttribute Identifier of the requested value.
+         * @param aGenRecordArray An array containing pointers to generic 
+         * records of the Connection Method.
+         * @param aBearerSpecRecordArray An array containing pointers to bearer
+         * specific records of the Connection Method. aAttribute
+         * parameter should identify one field(integer, boolean string)
+         * in one of these records. 
+         * @return Returns the requested value. In error case leaves with 
+         * system-wide error code.
+         */
+
+        virtual TUint32 GetBearerIntAttributeL( 
+                TUint32 aAttribute, 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+        
+        virtual TBool GetBearerBoolAttributeL( 
+                TUint32 aAttribute, 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+                                         
+        virtual HBufC* GetBearerStringAttributeL( 
+                TUint32 aAttribute, 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+        
+        virtual HBufC8* GetBearerString8AttributeL( 
+                TUint32 aAttribute, 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Following SetBearerXXXXAttribute methods set only the
+         * fields in records in pointer arrays(parameters). They are not 
+         * allowed to update the original records in plugins.
+         * @param aAttribute Identifier of the field to set.
+         * @param aValue The value to set.
+         * @param aGenRecordArray An array containing pointers to generic 
+         * records of the Connection Method.
+         * @param aBearerSpecRecordArray An array containing pointers to bearer
+         * specific records of the Connection Method. aAttribute
+         * parameter should identify one field(integer, boolean string)
+         * in one of these records. 
+         * @return None.
+         */
+
+        virtual void SetBearerIntAttributeL( 
+                TUint32 aAttribute, 
+                TUint32 aValue, 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+        
+        virtual void SetBearerBoolAttributeL( 
+                TUint32 aAttribute, 
+                TBool aValue,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+                                         
+        virtual void SetBearerStringAttributeL( 
+                TUint32 aAttribute, 
+                const TDesC16& aValue,
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        virtual void SetBearerString8AttributeL( 
+                TUint32 aAttribute, 
+                const TDesC8& aValue,                                                    
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Inherited from CCmPluginBaseEng. 
+         * Implementation is empty.
+         */
+        virtual void PreparePluginToLoadRecordsL();
+        
+        /**
+         * Inherited from CCmPluginBaseEng. 
+         * Implementation is empty.
+         * @param aCopyInstance Client side data instance.
+         */
+        virtual void PrepareToCopyDataL( CCmPluginBaseEng* aCopyInstance );
+
+        /**
+         * Inherited from CCmPluginBaseEng. 
+         * Implementation is empty.
+         * @param aGenRecordArray Reference to generic records pointer array.
+         * @param aBearerSpecRecordArray Reference to bearer specific records 
+         * pointer array.
+         */
+        virtual void PreparePluginToUpdateRecordsL(
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Plugin can prepare to delete the Connection Method with this 
+         * function. Called from DeleteL() before any record would be 
+         * deleted. No records are deleted here.
+         */
+        virtual void PrepareToDeleteRecordsL();
+
+        /**
+         * Loads the service record. Service record type is known and loaded by 
+         * plugin(bearer specific) part of the implementation even if the record
+         * is saved to the generic side. Service record is linked to IAP record.
+         */
+        virtual void LoadServiceRecordL();
+
+        /**
+         * Creates the service records.
+         */
+        virtual void CreateServiceRecordL();
+
+        /**
+         * Update service record.
+         * @param aGenRecordArray Reference to generic records pointer array.
+         * @param aBearerSpecRecordArray Reference to bearer specific records 
+         * pointer array.
+         */
+        virtual void UpdateServiceRecordL( 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Copies the service record. Bearer specific part knows the type of it's
+         * service record.
+         * @return Returns the service record pointer. 
+         */
+        virtual CommsDat::CCDRecordBase* CopyServiceRecordL();
+
+        /**
+         * Returns the service record id of the Connection Method.
+         * @return Returns the id of the service record id of the Connection Method.
+         */
+        virtual TUint32 ServiceRecordId() const;
+
+        /**
+         * Returns the service record name of the Connection Method.
+         * @param aServiceName Name of the service record the CM's iap record 
+         * points to.
+         */
+        virtual void ServiceRecordNameLC( HBufC* &aServiceName );
+
+        /**
+         * Inherited class loads all the bearer specific records after 
+         * loading generic records. Called from LoadL(). 
+         */
+        virtual void LoadBearerRecordsL();
+
+        /**
+         * Creates bearer specific records.
+         */
+        virtual void CreateBearerRecordsL();
+
+        /**
+         * Update bearer specific records.
+         * @param aGenRecordArray Reference to generic records pointer array.
+         * @param aBearerSpecRecordArray Reference to bearer specific records 
+         */
+        virtual void UpdateBearerRecordsL( 
+                RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+                RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray );
+
+        /**
+         * Plugin(generic part) can delete bearer specific records
+         * with this function. Called from DeleteL().
+         */
+        virtual void DeleteBearerRecordsL();
+
+         /** 
+          * Resets the bearer specific records. 
+          */
+         virtual void ResetBearerRecords();
+
+        /**
+         * Copies the bearer specific records to copy instance given as 
+         * parameter. 
+         * @param aCopyInstance Pointer to instance where to copy.
+         */
+        virtual void CopyBearerRecordsL( CCmPluginBaseEng* aCopyInstance );
+
+        /**
+         * Returns the bearer record id of the Connection Method.
+         * @param aRecordId Id of the bearer record this CM's iap record 
+         * points to.
+         */
+        virtual void BearerRecordIdL( TUint32& aRecordId );
+
+        /**
+         * Returns the bearer record name of the Connection Method.
+         * @param aBearerName Name of the bearer record this CM's iap record 
+         * points to.
+         */
+        virtual void BearerRecordNameLC( HBufC* &aBearerName );
+
+        
+    private: // Constructors
+        /**
+        * Constructor.
+        */      
+		CCmPluginVpn( TCmPluginInitParam* aInitParam );
+
+        /**
+        * Second phase constructor. Leaves on failure.
+        */      
+		void ConstructL();   
+		
+		/**
+		 * Gets the default priority and default UI priority 
+		 * from the CommsDat.
+		 */
+		TUint32 GetDefPriorityL( const TUint32 aAttribute ) const;
+		
+		/**
+		 * Gets the virtual bearer record from the CommsDat.
+		 */
+		CommsDat::CCDVirtualBearerRecord* GetVirtualBearerRecordLC() const;
+		
+		/**
+		 * Type casts the service record in the base class to 
+		 * CommsDat::CCDVPNServiceRecord type. 
+		 */
+		CommsDat::CCDVPNServiceRecord& ServiceRecord() const;
+		
+		/**
+		 * Virtual table Id
+		 */
+		CommsDat::TMDBElementId                 iVirtualTableId;
+		
+		/**
+		 * Bearer priority table id
+		 */
+		CommsDat::TMDBElementId                 iBearerPriorityTableId;
+		
+		/**
+		 * Virtual IAP next layer record
+		 */
+		CCDVirtualIAPNextLayerRecord*           iVirtualIapNextLayerRecord;
+    };
+    
+#endif //CMPLUGINVPN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/rom/cmmpluginvpn.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+* cmpluginvpn.dll to ROM.
+*
+*/
+#ifndef CMMPLUGINVPN_IBY__
+#define CMMPLUGINVPN_IBY__
+
+ECOM_PLUGIN(cmpluginvpn.dll,10281BBE.rsc)
+
+
+#endif // CMMPLUGINVPN_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/src/cmpluginvpn.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,1182 @@
+/*
+* Copyright (c) 2009-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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*      Implementation of VPN CmManager Plugin interface implementation 
+*      
+*
+*/
+
+ 
+// INCLUDE FILES
+#include <commsdattypesv1_1.h>
+#include <datamobilitycommsdattypes.h>
+#include <cmconnectionmethoddef.h>
+#include <cmpluginvpndef.h>
+#include <featmgr.h>
+#include <publicruntimeids.hrh>
+
+#include "cmpluginvpn.h"
+#include "cmmserverdefs.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cmpluginvpnTraces.h"
+#endif
+
+using namespace CommsDat;
+using namespace CMManager;
+
+
+
+_LIT( KVpnVirtualBearerName, "vpnbearer" );
+_LIT( KVpnVirtualBearerAgent, "vpnconnagt.agt" );
+_LIT( KVpnVirtualBearerNif, "tunnelnif" );
+
+static const TInt KVirtualIAPNextLayerRecordIndex = 0;
+
+// constants needed for the virtualbearer table
+static const TInt KNoTimeout = -1;
+static const TUint32 KLastSessionTimeout = 3;
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::NewL
+// ---------------------------------------------------------------------------
+//
+CCmPluginVpn* CCmPluginVpn::NewL( TCmPluginInitParam* aInitParam )
+	{	
+    OstTraceFunctionEntry0( CCMPLUGINVPN_NEWL_ENTRY );
+    
+	CCmPluginVpn* self = new( ELeave ) CCmPluginVpn( aInitParam );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	
+	OstTraceFunctionExit0( CCMPLUGINVPN_NEWL_EXIT );
+	return self;		
+	}
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CreateInstanceL
+// ---------------------------------------------------------------------------
+//
+CCmPluginBaseEng* CCmPluginVpn::CreateInstanceL( TCmPluginInitParam& aInitParam ) const
+	{
+    OstTraceFunctionEntry0( CCMPLUGINVPN_CREATEINSTANCEL_ENTRY );
+
+    CCmPluginVpn* self = new( ELeave ) CCmPluginVpn( &aInitParam );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+
+	OstTraceFunctionExit0( CCMPLUGINVPN_CREATEINSTANCEL_EXIT );
+	return self;				
+	}
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::~CCmPluginVpn
+// ---------------------------------------------------------------------------
+//
+CCmPluginVpn::~CCmPluginVpn()
+	{
+    OstTraceFunctionEntry0( CCMPLUGINVPN_CCMPLUGINVPN_ENTRY );
+    
+    ResetBearerRecords();
+    
+	OstTraceFunctionExit0( CCMPLUGINVPN_CCMPLUGINVPN_EXIT );
+	}
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CCmPluginVpn
+// ---------------------------------------------------------------------------
+//
+CCmPluginVpn::CCmPluginVpn( TCmPluginInitParam* aInitParam )
+	: CCmPluginBaseEng( aInitParam ), iVirtualTableId(0), 
+	  iBearerPriorityTableId(0), iVirtualIapNextLayerRecord(NULL)
+	{
+    OstTraceFunctionEntry0( DUP1_CCMPLUGINVPN_CCMPLUGINVPN_ENTRY );
+    
+    iBearerType = KPluginVPNBearerTypeUid;
+	
+    OstTraceFunctionExit0( DUP1_CCMPLUGINVPN_CCMPLUGINVPN_EXIT );
+	}
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::ConstructL()
+	{    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_CONSTRUCTL_ENTRY );
+    
+    if (!FeatureManager::FeatureSupported( KFeatureIdFfVpnClient ) )
+        {   
+        User::Leave( KErrNotSupported );
+        }
+    
+    TRAP_IGNORE( iVirtualTableId = 
+                        CCDVirtualIAPNextLayerRecord::TableIdL( iSession ) );       
+    
+    if( !iVirtualTableId )
+        {
+        iVirtualTableId = CCDVirtualIAPNextLayerRecord::CreateTableL( iSession );
+        }
+            
+    TRAP_IGNORE( iBearerPriorityTableId =
+            CCDGlobalBearerTypePriorizationRecord::TableIdL( iSession ) );
+
+    if ( !iBearerPriorityTableId )
+        {
+        iBearerPriorityTableId =
+                CCDGlobalBearerTypePriorizationRecord::CreateTableL( iSession );
+        }
+    
+	CCmPluginBaseEng::ConstructL();
+	    
+	OstTraceFunctionExit0( CCMPLUGINVPN_CONSTRUCTL_EXIT );
+	}
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerInfoIntL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginVpn::GetBearerInfoIntL( TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERINFOINTL_ENTRY );
+
+    TUint32 retVal( 0 );
+    switch ( aAttribute )
+        {
+        case ECmSeamlessnessLevel:
+            {
+            retVal = ESeamlessnessShowprogress;
+            }
+            break;
+        case ECmBearerType:
+            {             
+            retVal = iBearerType;
+            }
+            break;
+        case ECmCommsDBBearerType:
+            {                         
+            retVal = KCommDbBearerVirtual;
+            }
+            break;
+        case ECmExtensionLevel:
+            {
+            retVal = KExtensionBaseLevel;
+            }
+            break;
+        case ECmDefaultUiPriority: //falls through
+        case ECmDefaultPriority:
+            {
+            retVal = GetDefPriorityL( aAttribute );
+            }
+            break;
+            
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERINFOINTL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerInfoBoolL
+// ---------------------------------------------------------------------------
+//
+TBool CCmPluginVpn::GetBearerInfoBoolL( TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERINFOBOOLL_ENTRY );
+    
+    TBool retVal( EFalse );
+
+    switch ( aAttribute )
+        {
+        case ECmCoverage:
+            {
+            //This parameter is not actually in use for the VPN.
+            //ConnMon component can make a proper coverage discovery for the VPN,
+            //but CmManager just returns the default value.
+            retVal = EFalse;
+            }
+            break;
+        case ECmDestination:
+            {
+            retVal = EFalse;
+            }
+            break;
+        case ECmBearerHasUi:
+            {                
+            retVal = EFalse;
+            }
+            break;
+        case ECmIPv6Supported:
+            {            
+            retVal = EFalse;
+            }
+            break;
+        case ECmVirtual:
+            {
+            retVal = ETrue;
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }    
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERINFOBOOLL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerInfoStringL
+// ---------------------------------------------------------------------------
+//
+HBufC* CCmPluginVpn::GetBearerInfoStringL( TUint32 /*aAttribute*/ ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERINFOSTRINGL_ENTRY );
+    
+    User::Leave( KErrNotSupported );
+     
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERINFOSTRINGL_EXIT );
+    
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerInfoString8L
+// ---------------------------------------------------------------------------
+//
+HBufC8* CCmPluginVpn::GetBearerInfoString8L( TUint32 /*aAttribute*/ ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERINFOSTRING8L_ENTRY );
+
+    User::Leave( KErrNotSupported );
+
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERINFOSTRING8L_EXIT );
+ 
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CanHandleIapIdL
+// ---------------------------------------------------------------------------
+//
+TBool CCmPluginVpn::CanHandleIapIdL( TUint32 aIapId ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_CANHANDLEIAPIDL_ENTRY );
+
+    TBool retVal( EFalse );
+    
+    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
+                            ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+        
+    CleanupStack::PushL( iapRecord );
+    iapRecord->SetRecordId( aIapId );
+    
+    iapRecord->LoadL( iSession );
+    retVal = CanHandleIapIdL( iapRecord );
+    
+    CleanupStack::PopAndDestroy( iapRecord );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_CANHANDLEIAPIDL_EXIT );
+    return retVal;
+    }
+ 
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CanHandleIapIdL
+// ---------------------------------------------------------------------------
+//
+TBool CCmPluginVpn::CanHandleIapIdL( CommsDat::CCDIAPRecord* aIapRecord ) const
+    {
+    OstTraceFunctionEntry0( DUP1_CCMPLUGINVPN_CANHANDLEIAPIDL_ENTRY );
+    TBool retVal( EFalse );
+        
+    if( TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameVPNService) ||
+        TPtrC(aIapRecord->iBearerType) == TPtrC(KCDTypeNameVirtualBearer) )
+        {
+        // Further comparision is to find exact info that the IAP can handle by this plugin
+        CMDBRecordSet<CCDVirtualBearerRecord>* bearersRS = 
+                new(ELeave) CMDBRecordSet<CCDVirtualBearerRecord>
+                                                   (KCDTIdVirtualBearerRecord);
+        CleanupStack::PushL( bearersRS );
+
+        CCDVirtualBearerRecord* bearerRecord = 
+                static_cast<CCDVirtualBearerRecord *>
+                    (CCDRecordBase::RecordFactoryL(KCDTIdVirtualBearerRecord));
+
+        CleanupStack::PushL( bearerRecord );
+    
+        // Find entries used "vpnconnagt.agt" as agent from Table VirtualBearer
+        bearerRecord->iBearerAgent.SetL( KVpnVirtualBearerAgent );
+    
+        bearersRS->iRecords.AppendL( bearerRecord );
+
+        CleanupStack::Pop( bearerRecord );
+        bearerRecord = NULL;
+        
+        if ( bearersRS->FindL( iSession ) )
+            {
+            TUint32 recordId = (*bearersRS)[0]->RecordId();
+            TPtrC bearerName( (*bearersRS)[0]->iRecordName.GetL() );
+        
+            // Further comparing record ID referred to by this VPN IAP with entry ID in table VirtualBearer
+            // And also comparing bear name with our expected one "vpnbearer"
+            if( recordId == aIapRecord->iBearer && 
+                bearerName == TPtrC( KVpnVirtualBearerName ) )
+                {
+                retVal = ETrue;
+                }
+            }        
+        CleanupStack::PopAndDestroy( bearersRS );
+        }
+    
+    OstTraceFunctionExit0( DUP1_CCMPLUGINVPN_CANHANDLEIAPIDL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerTableIdsToBeObservedL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::GetBearerTableIdsToBeObservedL( RArray<TUint32>& aTableIdArray ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERTABLEIDSTOBEOBSERVEDL_ENTRY );
+    
+    aTableIdArray.AppendL( KCDTIdVirtualBearerRecord );
+    aTableIdArray.AppendL( iVirtualTableId );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERTABLEIDSTOBEOBSERVEDL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerSpecificRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::GetBearerSpecificRecordsL(RPointerArray<CommsDat::CCDRecordBase>& aRecordArray )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERSPECIFICRECORDSL_ENTRY );
+       
+    __ASSERT_DEBUG( iVirtualIapNextLayerRecord != NULL, User::Invariant() );  
+            
+    CCDVirtualIAPNextLayerRecord* virtualIapNextLayerRecordCopy = 
+                new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId );
+    CleanupStack::PushL( virtualIapNextLayerRecordCopy );
+    
+    TUint value = iVirtualIapNextLayerRecord->iIAP;
+    virtualIapNextLayerRecordCopy->iIAP = value;
+    
+    value = iVirtualIapNextLayerRecord->iNextLayerSNAP;
+    virtualIapNextLayerRecordCopy->iNextLayerSNAP = value;
+    
+    value = iVirtualIapNextLayerRecord->iNextLayerIAP;
+    virtualIapNextLayerRecordCopy->iNextLayerIAP = value;
+    
+    virtualIapNextLayerRecordCopy->SetElementId( iVirtualIapNextLayerRecord->ElementId() );
+    User::LeaveIfError( aRecordArray.Append( virtualIapNextLayerRecordCopy ) );
+    CleanupStack::Pop( virtualIapNextLayerRecordCopy );    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERSPECIFICRECORDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerIntAttributeL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginVpn::GetBearerIntAttributeL( 
+        TUint32 aAttribute, 
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERINTATTRIBUTEL_ENTRY );
+    
+    CCDVPNServiceRecord* serviceRecord = static_cast<CCDVPNServiceRecord *>                
+                                                        ( aGenRecordArray[KServiceRecordIndex] );
+        
+    TUint32 retVal( 0 );
+    switch( aAttribute )
+        {
+        case ECmExtensionLevel:   
+            {
+            retVal = KExtensionBaseLevel;
+            }
+            break;
+        case ECmCommsDBBearerType:
+            {
+            TCommsDBBearerTechnology bearer = KCommDbBearerVirtual; 
+            retVal = bearer;
+            }
+            break;
+        case ECmNextLayerIapId:
+        case EVpnIapId:
+            {            
+            TUint recordId = serviceRecord->iServiceIAP;//TODO, can't use this straight? link containd the ID.
+            if (recordId != 0)
+                {
+                CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
+                                        ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+                
+                CleanupStack::PushL( iapRecord );
+                iapRecord->SetRecordId( recordId );
+                iapRecord->LoadL( iSession );
+                retVal = iapRecord->RecordId();
+                CleanupStack::PopAndDestroy( iapRecord );                             
+                }
+            }
+            break;
+        case EVpnNetworkId:
+        case ECmNextLayerSNAPId:
+            {
+            TUint recordId = serviceRecord->iServiceSNAP;
+            if ( recordId != 0 )
+                {
+                CCDAccessPointRecord* accessPointRecord = static_cast<CCDAccessPointRecord*>(
+                        CCDRecordBase::RecordFactoryL( KCDTIdAccessPointRecord ) );
+                CleanupStack::PushL( accessPointRecord );
+                accessPointRecord->SetRecordId( recordId );
+                accessPointRecord->LoadL( iSession );
+                retVal = accessPointRecord->iRecordTag;
+                CleanupStack::PopAndDestroy( accessPointRecord );
+
+                if ( aAttribute == EVpnNetworkId )
+                    {
+                    __ASSERT_DEBUG( retVal >= KCmmDestIdIntervalMin, User::Invariant() );//TODO, replace with iCustomSelectionPolicy
+                    retVal -= KCmmDestIdIntervalMin;
+                    }
+                }
+            }
+            break;
+        default:
+            {
+            retVal = GetBearerInfoIntL( aAttribute );
+            }
+            break;
+        }
+    
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERINTATTRIBUTEL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerBoolAttributeL
+// ---------------------------------------------------------------------------
+//
+TBool CCmPluginVpn::GetBearerBoolAttributeL( 
+        TUint32 aAttribute, 
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERBOOLATTRIBUTEL_ENTRY );
+    //We don't have IAP specific bool attributes, but the bearer specific
+    //attributes may also be asked this way...
+    TBool retVal = GetBearerInfoBoolL( aAttribute );              
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERBOOLATTRIBUTEL_EXIT );
+    return retVal;
+    }
+  
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerStringAttributeL
+// ---------------------------------------------------------------------------
+//
+HBufC* CCmPluginVpn::GetBearerStringAttributeL( 
+        TUint32 aAttribute, 
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERSTRINGATTRIBUTEL_ENTRY );
+    
+    CCDVPNServiceRecord* serviceRecord = static_cast<CCDVPNServiceRecord *>                
+                                                        ( aGenRecordArray[KServiceRecordIndex] );
+
+    HBufC* retVal =  NULL;
+    switch( aAttribute )
+        {
+        case EVpnServicePolicy:
+            {
+            retVal = TPtrC( serviceRecord->iServicePolicy ).AllocL();
+            }
+            break;
+        default:
+            {
+            retVal = GetBearerInfoStringL( aAttribute );
+            }
+            break;
+        }
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERSTRINGATTRIBUTEL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetBearerString8AttributeL
+// ---------------------------------------------------------------------------
+//
+HBufC8* CCmPluginVpn::GetBearerString8AttributeL( 
+        TUint32 aAttribute, 
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETBEARERSTRING8ATTRIBUTEL_ENTRY );
+    
+    HBufC8* retVal = GetBearerInfoString8L( aAttribute );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETBEARERSTRING8ATTRIBUTEL_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::SetBearerIntAttributeL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::SetBearerIntAttributeL( 
+        TUint32 aAttribute, 
+        TUint32 aValue, 
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+    {    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SETBEARERINTATTRIBUTEL_ENTRY );
+
+    CCDVPNServiceRecord* serviceRecord = static_cast<CCDVPNServiceRecord *>                
+                                                    (aGenRecordArray[KServiceRecordIndex]);
+
+    CCDVirtualIAPNextLayerRecord* virtualIapNextLayerRecord = static_cast<CCDVirtualIAPNextLayerRecord*>
+                                                        (aBearerSpecRecordArray[KVirtualIAPNextLayerRecordIndex]);
+
+    
+    switch(aAttribute)
+        {
+        case ECmNextLayerIapId: //falls through
+        case EVpnIapId:
+            {
+            if( aValue == 0 || aValue >= (KCmmConnMethodIdIntervalMax - 2) )
+                {
+                User::Leave( KErrArgument );
+                }            
+            
+            //Tries to find corresponding IAP record.
+            CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
+                                    ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+                
+            CleanupStack::PushL( iapRecord );
+            iapRecord->SetRecordId( aValue );            
+            TRAPD(err, iapRecord->LoadL( iSession ));
+            if ( err == KErrNotFound )
+                {
+                User::Leave( KErrArgument );
+                }
+            User::LeaveIfError( err );
+            
+            serviceRecord->iServiceIAP = iapRecord->RecordId();
+            serviceRecord->iServiceNetwork = 0;
+            serviceRecord->iServiceSNAP = 0;
+            virtualIapNextLayerRecord->iNextLayerIAP.SetL( aValue );
+            virtualIapNextLayerRecord->iNextLayerSNAP = 0;
+            CleanupStack::PopAndDestroy( iapRecord );
+            }
+            break;
+        case EVpnNetworkId: //falls through
+            {
+            if ( aValue == 0 || aValue > (KCmmDestIdIntervalLegacyMax - 2) )
+                {
+                User::Leave( KErrArgument );
+                }
+            }
+            // Fallthrough intended.
+        case ECmNextLayerSNAPId:
+            {
+            if ( aValue <= ( KCmmDestIdIntervalLegacyMax - 2 ) )
+                {
+                aValue += KCmmDestIdIntervalMin;
+                }
+
+            if ( aValue <= KCmmDestIdIntervalMin ||
+                    aValue > KCmmDestIdIntervalMax - 2 )
+                {
+                User::Leave( KErrArgument );
+                }
+
+            CCDAccessPointRecord* accessPointRecord = static_cast<CCDAccessPointRecord*>(
+                    CCDRecordBase::RecordFactoryL( KCDTIdAccessPointRecord ) );
+            CleanupStack::PushL( accessPointRecord );
+            accessPointRecord->iRecordTag = aValue;
+            if ( accessPointRecord->FindL( iSession ) )
+                {
+                serviceRecord->iServiceIAP = 0;
+                serviceRecord->iServiceNetwork = 0;
+                serviceRecord->iServiceSNAP = accessPointRecord->RecordId();
+                virtualIapNextLayerRecord->iNextLayerIAP = 0;
+                virtualIapNextLayerRecord->iNextLayerSNAP.SetL( aValue );
+                }
+            else
+                {
+                User::Leave( KErrArgument );
+                }
+            CleanupStack::PopAndDestroy( accessPointRecord );
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_SETBEARERINTATTRIBUTEL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::SetBearerBoolAttributeL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::SetBearerBoolAttributeL( 
+        TUint32 /*aAttribute*/, 
+        TBool /*aValue*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SETBEARERBOOLATTRIBUTEL_ENTRY );
+    
+    User::Leave( KErrNotSupported );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_SETBEARERBOOLATTRIBUTEL_EXIT );
+    }
+  
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::SetBearerStringAttributeL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::SetBearerStringAttributeL( 
+        TUint32 aAttribute, 
+        const TDesC16& aValue,
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SETBEARERSTRINGATTRIBUTEL_ENTRY );
+
+    CCDVPNServiceRecord* serviceRecord = static_cast<CCDVPNServiceRecord *>                
+                                                    ( aGenRecordArray[KServiceRecordIndex] );
+
+    switch(aAttribute)
+        {
+        case EVpnServicePolicyName:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        case EVpnServicePolicy:
+            {
+            serviceRecord->iServicePolicy.SetL( aValue );
+            }
+            break;
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+            break;
+        }    
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_SETBEARERSTRINGATTRIBUTEL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::SetBearerString8AttributeL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::SetBearerString8AttributeL( 
+        TUint32 /*aAttribute*/, 
+        const TDesC8& /*aValue*/,                                                    
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SETBEARERSTRING8ATTRIBUTEL_ENTRY );
+
+    User::Leave( KErrNotSupported );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_SETBEARERSTRING8ATTRIBUTEL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::PreparePluginToLoadRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::PreparePluginToLoadRecordsL()
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::PrepareToCopyDataL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::PrepareToCopyDataL( CCmPluginBaseEng* /*aCopyInstance*/ )
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::PreparePluginToUpdateRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::PreparePluginToUpdateRecordsL(
+        RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::PrepareToDeleteRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::PrepareToDeleteRecordsL()
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::LoadServiceRecordL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::LoadServiceRecordL()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_LOADSERVICERECORDL_ENTRY );
+    
+    __ASSERT_DEBUG( iServiceRecord == NULL, User::Invariant() );
+    
+    if( TPtrC( KCDTypeNameVPNService ) == iIapRecord->iServiceType )
+        {
+        iServiceRecord = static_cast<CCDVPNServiceRecord *>
+                    ( CCDRecordBase::RecordFactoryL(KCDTIdVPNServiceRecord) );
+        iServiceRecord->SetRecordId( iIapRecord->iService );
+        iServiceRecord->LoadL( iSession );        
+        }
+    else
+        // this IAP service is not supported by this plugin.
+        {
+        User::Leave( KErrNotSupported );
+        }    
+    OstTraceFunctionExit0( CCMPLUGINVPN_LOADSERVICERECORDL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CreateServiceRecordL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::CreateServiceRecordL()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_CREATESERVICERECORDL_ENTRY );
+    
+    delete iServiceRecord; 
+    iServiceRecord = NULL;
+    
+    iServiceRecord = static_cast<CCDVPNServiceRecord *>
+                    ( CCDRecordBase::RecordFactoryL( KCDTIdVPNServiceRecord ) );
+    
+    ServiceRecord().iServicePolicy.SetL( KNullDesC );
+    ServiceRecord().iServiceIAP = 0;
+    ServiceRecord().iServiceNetwork = 0;
+    ServiceRecord().iServiceSNAP = 0;
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_CREATESERVICERECORDL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::UpdateServiceRecordL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::UpdateServiceRecordL( 
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& /*aBearerSpecRecordArray*/ )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_UPDATESERVICERECORDL_ENTRY );
+        
+    // Delete the original record and create a copy from the parameter
+    delete iServiceRecord;
+    iServiceRecord = NULL;
+
+    CCDVPNServiceRecord* vpnServiceRecordFrom =
+            static_cast<CCDVPNServiceRecord *>( aGenRecordArray[KServiceRecordIndex] );
+
+    
+    iServiceRecord = static_cast<CCDVPNServiceRecord*>
+                                  ( CCDRecordBase::CreateCopyRecordL( *vpnServiceRecordFrom ) );
+    iServiceRecord->SetElementId( vpnServiceRecordFrom->ElementId() );
+    
+    if ( !iServiceRecord->RecordId() )
+        {
+        iServiceRecord->SetRecordId( KCDNewRecordRequest );
+        iServiceRecord->StoreL( iSession );
+        
+        vpnServiceRecordFrom->SetElementId( ServiceRecord().ElementId() );
+        }
+    else
+        {
+        iServiceRecord->ModifyL( iSession );
+        }    
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_UPDATESERVICERECORDL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CopyServiceRecordL
+// ---------------------------------------------------------------------------
+//
+CommsDat::CCDRecordBase* CCmPluginVpn::CopyServiceRecordL()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_COPYSERVICERECORDL_ENTRY );
+    
+    __ASSERT_DEBUG( iServiceRecord != NULL, User::Invariant());    
+    CCDRecordBase* serviceRecord = static_cast<CCDVPNServiceRecord*>
+                                  ( CCDRecordBase::CreateCopyRecordL( *iServiceRecord ) );     
+    OstTraceFunctionExit0( CCMPLUGINVPN_COPYSERVICERECORDL_EXIT );
+    return serviceRecord;    
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::ServiceRecordId
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginVpn::ServiceRecordId() const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SERVICERECORDID_ENTRY );
+    
+    TUint32 retVal = ServiceRecord().RecordId();
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_SERVICERECORDID_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::ServiceRecordNameLC
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::ServiceRecordNameLC( HBufC* &aServiceName )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SERVICERECORDNAMELC_ENTRY );    
+    aServiceName = TPtrC( KCDTypeNameVPNService ).AllocLC();      
+    OstTraceFunctionExit0( CCMPLUGINVPN_SERVICERECORDNAMELC_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::LoadBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::LoadBearerRecordsL()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_LOADBEARERRECORDSL_ENTRY );
+    
+    delete iVirtualIapNextLayerRecord;
+    iVirtualIapNextLayerRecord = NULL;
+            
+    CMDBRecordSet<CCDVirtualIAPNextLayerRecord>* virtualRS = 
+              new(ELeave) CMDBRecordSet<CCDVirtualIAPNextLayerRecord>( iVirtualTableId );
+    CleanupStack::PushL( virtualRS );
+    
+    CCDVirtualIAPNextLayerRecord* record = 
+                            new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId );
+    
+    record->iIAP = iIapRecord->RecordId();
+    CleanupStack::PushL( record );
+    virtualRS->iRecords.AppendL( record );
+    CleanupStack::Pop( record );
+    record = NULL;
+    
+    if( virtualRS->FindL( iSession ) )
+        {
+        iVirtualIapNextLayerRecord = new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId );
+        iVirtualIapNextLayerRecord->SetRecordId( (*virtualRS)[0]->RecordId() );        
+        iVirtualIapNextLayerRecord->LoadL( iSession );        
+        }
+    else
+        {        
+        User::Leave( KErrNotFound );
+        }
+    
+    CleanupStack::PopAndDestroy( virtualRS );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_LOADBEARERRECORDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CreateBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::CreateBearerRecordsL()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_CREATEBEARERRECORDSL_ENTRY );
+
+    delete iVirtualIapNextLayerRecord;
+    iVirtualIapNextLayerRecord = NULL;
+    
+    iVirtualIapNextLayerRecord = new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId );
+
+    OstTraceFunctionExit0( CCMPLUGINVPN_CREATEBEARERRECORDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::UpdateBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::UpdateBearerRecordsL( 
+        RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
+        RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_UPDATEBEARERRECORDSL_ENTRY );
+        
+    delete iVirtualIapNextLayerRecord;
+    iVirtualIapNextLayerRecord = NULL;
+    
+    iVirtualIapNextLayerRecord = new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId );
+    
+    CCDVirtualIAPNextLayerRecord* virtualIAPNextLayerRecordFrom = 
+            static_cast<CCDVirtualIAPNextLayerRecord*>(aBearerSpecRecordArray[KVirtualIAPNextLayerRecordIndex]);
+    
+    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
+                            ( aGenRecordArray[KIapRecordIndex] );
+
+    
+    TUint value = iapRecord->RecordId();
+    iVirtualIapNextLayerRecord->iIAP = value;
+    value = virtualIAPNextLayerRecordFrom->iNextLayerSNAP;
+    iVirtualIapNextLayerRecord->iNextLayerSNAP = value;
+    value = virtualIAPNextLayerRecordFrom->iNextLayerIAP;
+    iVirtualIapNextLayerRecord->iNextLayerIAP = value;    
+    iVirtualIapNextLayerRecord->SetElementId(virtualIAPNextLayerRecordFrom->ElementId());
+    
+    if ( !iVirtualIapNextLayerRecord->RecordId() )
+        {
+        iVirtualIapNextLayerRecord->SetRecordId( KCDNewRecordRequest );
+        iVirtualIapNextLayerRecord->StoreL( iSession );
+        virtualIAPNextLayerRecordFrom->SetElementId( iVirtualIapNextLayerRecord->ElementId() );
+        }
+    else
+        {
+        iVirtualIapNextLayerRecord->ModifyL( iSession );
+        }
+
+    OstTraceFunctionExit0( CCMPLUGINVPN_UPDATEBEARERRECORDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::DeleteBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::DeleteBearerRecordsL()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_DELETEBEARERRECORDSL_ENTRY );    
+    iVirtualIapNextLayerRecord->DeleteL( iSession );
+    OstTraceFunctionExit0( CCMPLUGINVPN_DELETEBEARERRECORDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::ResetBearerRecords
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::ResetBearerRecords()
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_RESETBEARERRECORDS_ENTRY );
+    
+    delete iVirtualIapNextLayerRecord;
+    iVirtualIapNextLayerRecord = NULL;    
+    OstTraceFunctionExit0( CCMPLUGINVPN_RESETBEARERRECORDS_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::CopyBearerRecordsL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::CopyBearerRecordsL( CCmPluginBaseEng* aCopyInstance ) 
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_COPYBEARERRECORDSL_ENTRY );
+    
+    __ASSERT_DEBUG(iVirtualIapNextLayerRecord != NULL, User::Invariant());
+           
+    CCmPluginVpn* plugin = static_cast<CCmPluginVpn*>( aCopyInstance );
+
+    __ASSERT_DEBUG(plugin->iVirtualIapNextLayerRecord == NULL, User::Invariant());
+        
+    plugin->iVirtualIapNextLayerRecord = new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId );
+    TUint value = iVirtualIapNextLayerRecord->iIAP;
+    plugin->iVirtualIapNextLayerRecord->iIAP = value;
+    value = iVirtualIapNextLayerRecord->iNextLayerSNAP;
+    plugin->iVirtualIapNextLayerRecord->iNextLayerSNAP = value;
+    value = iVirtualIapNextLayerRecord->iNextLayerIAP;
+    plugin->iVirtualIapNextLayerRecord->iNextLayerIAP = value;    
+
+    OstTraceFunctionExit0( CCMPLUGINVPN_COPYBEARERRECORDSL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::BearerRecordIdL
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::BearerRecordIdL( TUint32& aRecordId )
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_BEARERRECORDIDL_ENTRY );
+    
+    CCDVirtualBearerRecord* bearerRecord = GetVirtualBearerRecordLC();
+    aRecordId = bearerRecord->RecordId();
+    CleanupStack::PopAndDestroy(bearerRecord);
+
+    OstTraceFunctionExit0( CCMPLUGINVPN_BEARERRECORDIDL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::BearerRecordNameLC
+// ---------------------------------------------------------------------------
+//
+void CCmPluginVpn::BearerRecordNameLC( HBufC* &aBearerName )
+    {   
+    OstTraceFunctionEntry0( CCMPLUGINVPN_BEARERRECORDNAMELC_ENTRY );
+    
+    aBearerName = TPtrC( KCDTypeNameVirtualBearer ).AllocLC();
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_BEARERRECORDNAMELC_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::ServiceRecord
+// ---------------------------------------------------------------------------
+//
+CCDVPNServiceRecord& CCmPluginVpn::ServiceRecord() const
+    {    
+    OstTraceFunctionEntry0( CCMPLUGINVPN_SERVICERECORD_ENTRY );
+    
+    CCDVPNServiceRecord& serviceRecord = *static_cast<CCDVPNServiceRecord*>( iServiceRecord );
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_SERVICERECORD_EXIT );
+    return serviceRecord;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetVirtualBearerRecordLC
+// ---------------------------------------------------------------------------
+//
+CCDVirtualBearerRecord* CCmPluginVpn::GetVirtualBearerRecordLC() const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETVIRTUALBEARERRECORDLC_ENTRY );
+        
+    //First tries to load the virtual bearer record.
+    //If the loading fails creates a new one.
+    CMDBRecordSet<CCDVirtualBearerRecord>* bearersRS = 
+            new(ELeave) CMDBRecordSet<CCDVirtualBearerRecord>
+                                               (KCDTIdVirtualBearerRecord);
+    CleanupStack::PushL( bearersRS );
+
+    CCDVirtualBearerRecord* bearerRecord = 
+            static_cast<CCDVirtualBearerRecord *>
+                (CCDRecordBase::RecordFactoryL(KCDTIdVirtualBearerRecord));
+
+    CleanupStack::PushL( bearerRecord );
+
+    // Find entries used "vpnconnagt.agt" as agent from Table VirtualBearer
+    bearerRecord->iBearerAgent.SetL( KVpnVirtualBearerAgent );
+    bearersRS->iRecords.AppendL( bearerRecord );
+
+    CleanupStack::Pop( bearerRecord );
+    bearerRecord = NULL;
+    
+    CCDVirtualBearerRecord* retVal = NULL;
+    if ( bearersRS->FindL( iSession ) )
+        {
+        for (TInt i = 0; i < bearersRS->iRecords.Count(); ++i)
+            {            
+            TPtrC bearerName( (*bearersRS)[i]->iRecordName.GetL() );
+    
+            // Further comparing record ID referred to by this VPN IAP with entry ID in table VirtualBearer
+            // And also comparing bear name with our expected one "vpnbearer"
+            if( bearerName == TPtrC( KVpnVirtualBearerName ) )
+                {
+                TUint32 recordId = (*bearersRS)[i]->RecordId();
+                retVal = static_cast<CCDVirtualBearerRecord *>
+                                            (CCDRecordBase::RecordFactoryL(KCDTIdVirtualBearerRecord));
+                CleanupStack::PushL(retVal);
+                retVal->SetRecordId( recordId );
+                retVal->LoadL( iSession );
+                CleanupStack::Pop(retVal);
+                break;
+                }
+            }
+        }         
+    CleanupStack::PopAndDestroy( bearersRS );
+
+    //If iVirtualBearerRecord is still NULL the loading has failed we try to create a new 
+    //entry to the table.
+    if (retVal == NULL)
+        {
+        retVal = static_cast<CCDVirtualBearerRecord *>
+                                    (CCDRecordBase::RecordFactoryL(KCDTIdVirtualBearerRecord));
+        CleanupStack::PushL(retVal);
+        retVal->iRecordName.SetL( KVpnVirtualBearerName );
+        retVal->iBearerAgent.SetL( KVpnVirtualBearerAgent );
+        retVal->iVirtualBearerNifName.SetL(KVpnVirtualBearerNif);
+        retVal->iLastSocketActivityTimeout = (TUint32)KNoTimeout;
+        retVal->iLastSessionClosedTimeout = KLastSessionTimeout;
+        retVal->iLastSocketClosedTimeout = (TUint32)KNoTimeout;
+        retVal->iBearerTechnology = KCommDbBearerVirtual;
+        retVal->SetRecordId( KCDNewRecordRequest );
+        
+        retVal->StoreL( iSession );
+        }
+    else
+        {
+        CleanupStack::PushL(retVal);
+        }
+    
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETVIRTUALBEARERRECORDLC_EXIT );
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CCmPluginVpn::GetDefPriorityL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginVpn::GetDefPriorityL( const TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINVPN_GETDEFPRIORITYL_ENTRY );
+    
+    TUint32 retVal( KDataMobilitySelectionPolicyPriorityWildCard );
+
+    CCDGlobalBearerTypePriorizationRecord* priorityRecord =
+            new( ELeave ) CCDGlobalBearerTypePriorizationRecord( iBearerPriorityTableId );
+    CleanupStack::PushL( priorityRecord );
+
+    priorityRecord->iServiceType.SetL( TPtrC( KCDTypeNameVPNService ) );
+
+    if ( priorityRecord->FindL( iSession ) )
+        {
+        priorityRecord->LoadL( iSession );
+
+        switch ( aAttribute )
+            {
+            case ECmDefaultPriority:
+                {
+                retVal = priorityRecord->iPriority;
+                }
+                break;
+            case ECmDefaultUiPriority:
+                {
+                retVal = priorityRecord->iUIPriority;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    CleanupStack::PopAndDestroy( priorityRecord );
+
+    OstTraceFunctionExit0( CCMPLUGINVPN_GETDEFPRIORITYL_EXIT );
+    return retVal;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/src/cmpluginvpnproxy.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+* VPN plug-in's ECom proxy descriptor. 
+*/
+
+#include "cmpluginvpn.h"
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// Exported proxy for instantiation method resolution
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KPluginVPNBearerTypeUid, CCmPluginVpn::NewL)
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,7 @@
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+// OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
+// REMOVE BEFORE CHECK-IN TO VERSION CONTROL
+#define OST_TRACE_COMPILER_IN_USE
+#include <opensystemtrace.h>
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/traces/cmpluginvpnTraces.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,90 @@
+// Created by TraceCompiler 2.2.2
+// DO NOT EDIT, CHANGES WILL BE LOST
+
+#ifndef __CMPLUGINVPNTRACES_H__
+#define __CMPLUGINVPNTRACES_H__
+
+#define KOstTraceComponentID 0x10281bbe
+
+#define CCMPLUGINVPN_NEWL_ENTRY 0x8a0001
+#define CCMPLUGINVPN_NEWL_EXIT 0x8a0002
+#define CCMPLUGINVPN_CREATEINSTANCEL_ENTRY 0x8a0003
+#define CCMPLUGINVPN_CREATEINSTANCEL_EXIT 0x8a0004
+#define CCMPLUGINVPN_CCMPLUGINVPN_ENTRY 0x8a0005
+#define CCMPLUGINVPN_CCMPLUGINVPN_EXIT 0x8a0006
+#define DUP1_CCMPLUGINVPN_CCMPLUGINVPN_ENTRY 0x8a0007
+#define DUP1_CCMPLUGINVPN_CCMPLUGINVPN_EXIT 0x8a0008
+#define CCMPLUGINVPN_CONSTRUCTL_ENTRY 0x8a0009
+#define CCMPLUGINVPN_CONSTRUCTL_EXIT 0x8a000a
+#define CCMPLUGINVPN_GETBEARERINFOINTL_ENTRY 0x8a000b
+#define CCMPLUGINVPN_GETBEARERINFOINTL_EXIT 0x8a000c
+#define CCMPLUGINVPN_GETBEARERINFOBOOLL_ENTRY 0x8a000d
+#define CCMPLUGINVPN_GETBEARERINFOBOOLL_EXIT 0x8a000e
+#define CCMPLUGINVPN_GETBEARERINFOSTRINGL_ENTRY 0x8a000f
+#define CCMPLUGINVPN_GETBEARERINFOSTRINGL_EXIT 0x8a0010
+#define CCMPLUGINVPN_GETBEARERINFOSTRING8L_ENTRY 0x8a0011
+#define CCMPLUGINVPN_GETBEARERINFOSTRING8L_EXIT 0x8a0012
+#define CCMPLUGINVPN_CANHANDLEIAPIDL_ENTRY 0x8a0013
+#define CCMPLUGINVPN_CANHANDLEIAPIDL_EXIT 0x8a0014
+#define DUP1_CCMPLUGINVPN_CANHANDLEIAPIDL_ENTRY 0x8a0015
+#define DUP1_CCMPLUGINVPN_CANHANDLEIAPIDL_EXIT 0x8a0016
+#define CCMPLUGINVPN_GETBEARERTABLEIDSTOBEOBSERVEDL_ENTRY 0x8a0017
+#define CCMPLUGINVPN_GETBEARERTABLEIDSTOBEOBSERVEDL_EXIT 0x8a0018
+#define CCMPLUGINVPN_GETBEARERSPECIFICRECORDSL_ENTRY 0x8a0019
+#define CCMPLUGINVPN_GETBEARERSPECIFICRECORDSL_EXIT 0x8a001a
+#define CCMPLUGINVPN_GETBEARERINTATTRIBUTEL_ENTRY 0x8a001b
+#define CCMPLUGINVPN_GETBEARERINTATTRIBUTEL_EXIT 0x8a001c
+#define CCMPLUGINVPN_LOADSERVICERECORDL_ENTRY 0x8a001d
+#define CCMPLUGINVPN_LOADSERVICERECORDL_EXIT 0x8a001e
+#define CCMPLUGINVPN_CREATESERVICERECORDL_ENTRY 0x8a001f
+#define CCMPLUGINVPN_CREATESERVICERECORDL_EXIT 0x8a0020
+#define CCMPLUGINVPN_COPYSERVICERECORDL_ENTRY 0x8a0021
+#define CCMPLUGINVPN_COPYSERVICERECORDL_EXIT 0x8a0022
+#define CCMPLUGINVPN_SERVICERECORDNAMELC_ENTRY 0x8a0023
+#define CCMPLUGINVPN_SERVICERECORDNAMELC_EXIT 0x8a0024
+#define CCMPLUGINVPN_LOADBEARERRECORDSL_ENTRY 0x8a0025
+#define CCMPLUGINVPN_LOADBEARERRECORDSL_EXIT 0x8a0026
+#define CCMPLUGINVPN_CREATEBEARERRECORDSL_ENTRY 0x8a0027
+#define CCMPLUGINVPN_CREATEBEARERRECORDSL_EXIT 0x8a0028
+#define CCMPLUGINVPN_DELETEBEARERRECORDSL_ENTRY 0x8a0029
+#define CCMPLUGINVPN_DELETEBEARERRECORDSL_EXIT 0x8a002a
+#define CCMPLUGINVPN_RESETBEARERRECORDS_ENTRY 0x8a002b
+#define CCMPLUGINVPN_RESETBEARERRECORDS_EXIT 0x8a002c
+#define CCMPLUGINVPN_COPYBEARERRECORDSL_ENTRY 0x8a002d
+#define CCMPLUGINVPN_COPYBEARERRECORDSL_EXIT 0x8a002e
+#define CCMPLUGINVPN_BEARERRECORDIDL_ENTRY 0x8a002f
+#define CCMPLUGINVPN_BEARERRECORDIDL_EXIT 0x8a0030
+#define CCMPLUGINVPN_GETBEARERBOOLATTRIBUTEL_ENTRY 0x8a0031
+#define CCMPLUGINVPN_GETBEARERBOOLATTRIBUTEL_EXIT 0x8a0032
+#define CCMPLUGINVPN_GETBEARERSTRINGATTRIBUTEL_ENTRY 0x8a0033
+#define CCMPLUGINVPN_GETBEARERSTRINGATTRIBUTEL_EXIT 0x8a0034
+#define CCMPLUGINVPN_GETBEARERSTRING8ATTRIBUTEL_ENTRY 0x8a0035
+#define CCMPLUGINVPN_GETBEARERSTRING8ATTRIBUTEL_EXIT 0x8a0036
+#define CCMPLUGINVPN_SETBEARERBOOLATTRIBUTEL_ENTRY 0x8a0037
+#define CCMPLUGINVPN_SETBEARERBOOLATTRIBUTEL_EXIT 0x8a0038
+#define CCMPLUGINVPN_SETBEARERSTRING8ATTRIBUTEL_ENTRY 0x8a0039
+#define CCMPLUGINVPN_SETBEARERSTRING8ATTRIBUTEL_EXIT 0x8a003a
+#define CCMPLUGINVPN_SETBEARERINTATTRIBUTEL_ENTRY 0x8a003b
+#define CCMPLUGINVPN_SETBEARERINTATTRIBUTEL_EXIT 0x8a003c
+#define CCMPLUGINVPN_SETBEARERSTRINGATTRIBUTEL_ENTRY 0x8a003d
+#define CCMPLUGINVPN_SETBEARERSTRINGATTRIBUTEL_EXIT 0x8a003e
+#define CCMPLUGINVPN_UPDATESERVICERECORDL_ENTRY 0x8a003f
+#define CCMPLUGINVPN_UPDATESERVICERECORDL_EXIT 0x8a0040
+#define CCMPLUGINVPN_SERVICERECORDID_ENTRY 0x8a0041
+#define CCMPLUGINVPN_SERVICERECORDID_EXIT 0x8a0042
+#define CCMPLUGINVPN_UPDATEBEARERRECORDSL_ENTRY 0x8a0043
+#define CCMPLUGINVPN_UPDATEBEARERRECORDSL_EXIT 0x8a0044
+#define CCMPLUGINVPN_BEARERRECORDNAMELC_ENTRY 0x8a0045
+#define CCMPLUGINVPN_BEARERRECORDNAMELC_EXIT 0x8a0046
+#define CCMPLUGINVPN_SERVICERECORD_ENTRY 0x8a0047
+#define CCMPLUGINVPN_SERVICERECORD_EXIT 0x8a0048
+#define CCMPLUGINVPN_GETVIRTUALBEARERRECORDLC_ENTRY 0x8a0049
+#define CCMPLUGINVPN_GETVIRTUALBEARERRECORDLC_EXIT 0x8a004a
+#define CCMPLUGINVPN_GETDEFPRIORITYL_ENTRY 0x8a004b
+#define CCMPLUGINVPN_GETDEFPRIORITYL_EXIT 0x8a004c
+
+
+#endif
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginvpn/traces/fixed_id.definitions	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,79 @@
+#Fixed group and trace id definitions. If this file is removed, the identifiers are rebuilt.
+[GROUP]TRACE_FLOW=0x8a
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_BEARERRECORDIDL_ENTRY=0x2f
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_BEARERRECORDIDL_EXIT=0x30
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_BEARERRECORDNAMELC_ENTRY=0x45
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_BEARERRECORDNAMELC_EXIT=0x46
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CANHANDLEIAPIDL_ENTRY=0x13
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CANHANDLEIAPIDL_EXIT=0x14
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CCMPLUGINVPN_ENTRY=0x5
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CCMPLUGINVPN_EXIT=0x6
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CONSTRUCTL_ENTRY=0x9
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CONSTRUCTL_EXIT=0xa
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_COPYBEARERRECORDSL_ENTRY=0x2d
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_COPYBEARERRECORDSL_EXIT=0x2e
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_COPYSERVICERECORDL_ENTRY=0x21
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_COPYSERVICERECORDL_EXIT=0x22
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CREATEBEARERRECORDSL_ENTRY=0x27
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CREATEBEARERRECORDSL_EXIT=0x28
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CREATEINSTANCEL_ENTRY=0x3
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CREATEINSTANCEL_EXIT=0x4
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CREATESERVICERECORDL_ENTRY=0x1f
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_CREATESERVICERECORDL_EXIT=0x20
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_DELETEBEARERRECORDSL_ENTRY=0x29
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_DELETEBEARERRECORDSL_EXIT=0x2a
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERBOOLATTRIBUTEL_ENTRY=0x31
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERBOOLATTRIBUTEL_EXIT=0x32
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOBOOLL_ENTRY=0xd
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOBOOLL_EXIT=0xe
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOINTL_ENTRY=0xb
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOINTL_EXIT=0xc
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOSTRING8L_ENTRY=0x11
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOSTRING8L_EXIT=0x12
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOSTRINGL_ENTRY=0xf
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINFOSTRINGL_EXIT=0x10
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINTATTRIBUTEL_ENTRY=0x1b
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERINTATTRIBUTEL_EXIT=0x1c
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERSPECIFICRECORDSL_ENTRY=0x19
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERSPECIFICRECORDSL_EXIT=0x1a
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERSTRING8ATTRIBUTEL_ENTRY=0x35
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERSTRING8ATTRIBUTEL_EXIT=0x36
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERSTRINGATTRIBUTEL_ENTRY=0x33
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERSTRINGATTRIBUTEL_EXIT=0x34
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERTABLEIDSTOBEOBSERVEDL_ENTRY=0x17
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETBEARERTABLEIDSTOBEOBSERVEDL_EXIT=0x18
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETDEFPRIORITYL_ENTRY=0x4b
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETDEFPRIORITYL_EXIT=0x4c
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETVIRTUALBEARERRECORDLC_ENTRY=0x49
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_GETVIRTUALBEARERRECORDLC_EXIT=0x4a
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_LOADBEARERRECORDSL_ENTRY=0x25
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_LOADBEARERRECORDSL_EXIT=0x26
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_LOADSERVICERECORDL_ENTRY=0x1d
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_LOADSERVICERECORDL_EXIT=0x1e
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_NEWL_ENTRY=0x1
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_NEWL_EXIT=0x2
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_RESETBEARERRECORDS_ENTRY=0x2b
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_RESETBEARERRECORDS_EXIT=0x2c
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SERVICERECORDID_ENTRY=0x41
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SERVICERECORDID_EXIT=0x42
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SERVICERECORDNAMELC_ENTRY=0x23
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SERVICERECORDNAMELC_EXIT=0x24
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SERVICERECORD_ENTRY=0x47
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SERVICERECORD_EXIT=0x48
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERBOOLATTRIBUTEL_ENTRY=0x37
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERBOOLATTRIBUTEL_EXIT=0x38
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERINTATTRIBUTEL_ENTRY=0x3b
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERINTATTRIBUTEL_EXIT=0x3c
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERSTRING8ATTRIBUTEL_ENTRY=0x39
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERSTRING8ATTRIBUTEL_EXIT=0x3a
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERSTRINGATTRIBUTEL_ENTRY=0x3d
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_SETBEARERSTRINGATTRIBUTEL_EXIT=0x3e
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_UPDATEBEARERRECORDSL_ENTRY=0x43
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_UPDATEBEARERRECORDSL_EXIT=0x44
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_UPDATESERVICERECORDL_ENTRY=0x3f
+[TRACE]TRACE_FLOW[0x8A]_CCMPLUGINVPN_UPDATESERVICERECORDL_EXIT=0x40
+[TRACE]TRACE_FLOW[0x8A]_DUP1_CCMPLUGINVPN_CANHANDLEIAPIDL_ENTRY=0x15
+[TRACE]TRACE_FLOW[0x8A]_DUP1_CCMPLUGINVPN_CANHANDLEIAPIDL_EXIT=0x16
+[TRACE]TRACE_FLOW[0x8A]_DUP1_CCMPLUGINVPN_CCMPLUGINVPN_ENTRY=0x7
+[TRACE]TRACE_FLOW[0x8A]_DUP1_CCMPLUGINVPN_CCMPLUGINVPN_EXIT=0x8
+[[OBSOLETE]][TRACE]TRACE_FATAL[0x81]_CCMPLUGINVPN_LOADBEARERRECORDSL=0x1
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/data/10281BB2.rss	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/data/10281BB2.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,7 @@
 *
 */
 
-#include "ecom/RegistryInfo.rh"
+#include "ecom/registryinfo.rh"
 
 // Because attribute enums had to be added to namespace CMManager
 // it's not possible to included cmpluginwlandef.h
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -25,7 +25,7 @@
 
 PRJ_EXPORTS
 // export iby files
-../Rom/cmmpluginwlan.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(cmmpluginwlan.iby)
+../rom/cmmpluginwlan.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(cmmpluginwlan.iby)
 
 
 PRJ_MMPFILES
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/group/cmpluginwlan.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/group/cmpluginwlan.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,6 @@
 *
 */
 
-#include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
 
 TARGET      cmpluginwlan.dll
@@ -53,6 +52,9 @@
 LIBRARY     euser.lib
 LIBRARY     ecom.lib
 LIBRARY     commsdat.lib
+LIBRARY     featmgr.lib
+LIBRARY     eapsymbiantools.lib
+LIBRARY     eaptools.lib
+LIBRARY     eaptrace.lib
 LIBRARY     cmmanagerdatabase.lib
-LIBRARY     featmgr.lib
 LIBRARY     cmmpluginbase.lib
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/inc/cmpluginwlan.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/inc/cmpluginwlan.h	Thu Jul 22 16:37:38 2010 +0100
@@ -340,8 +340,9 @@
          * @param aSourceRecord A record where to copy from.
          * @param aDestRecord A record where to copy to.
          */
-        void CopyWlanServiceRecordL( CCDWlanServiceRecord* aSourceRecord,
-                                     CCDWlanServiceRecord* aDestRecord);
+        void CopyWlanServiceRecordL(
+                CCDWlanServiceRecord* aSourceRecord,
+                CCDWlanServiceRecord* aDestRecord);
 
         /**
          * Copies the bearer specific records to copy instance.
@@ -361,8 +362,9 @@
          * @param aAttribute Identifies the attribute to be checked.
          * @param aValue A value to be checked.
          */
-        void CheckSecurityAttributeValidityL( const TUint32 aAttribute,
-                                              const TUint32 aValue );
+        void CheckSecurityAttributeValidityL(
+                const TUint32 aAttribute,
+                const TUint32 aValue );
 
         /**
          * Convert a 8-bit string in ascii format to hex format. Ownership of
@@ -382,19 +384,30 @@
          */
         TUint8 ConvertHexCharToNumberL( const TUint8 aHexChar );
 
+        /**
+         * Returns the default priority value identified with the parameter.
+         * @param aAttribute Indentifies the default priority value requested.
+         */
+        TUint32 GetDefPriorityL( const TUint32 aAttribute ) const;
+
     private: // Data
 
         /**
-         * WLan service record.
+         * WLAN service record.
          */
         CCDWlanServiceRecord* iWlanServiceRecord;
 
         /**
-         * WLAN table id.
+         * WLAN table ID.
          */
         CommsDat::TMDBElementId iWlanTableId;
 
         /**
+         * Bearer priority table ID.
+         */
+        CommsDat::TMDBElementId iBearerPriorityTableId;
+
+        /**
          * Boolean to save the WAPI support info.
          */
         TBool iWAPISupported;
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlan.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlan.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,9 @@
 #include <cmpluginwlandef.h>
 #include <cmcommonconstants.h>
 #include <featmgr.h>
+#include <EapGeneralSettings.h>
 
+#include "datamobilitycommsdattypes.h"
 #include "cmpluginwlan.h"
 #include "cmwlancoveragecheck.h"
 #include "cmmanagerdef.h"
@@ -52,13 +54,11 @@
 
 const TInt KWlanServiceRecordIndex = 0;
 
-const TUint32 KDefaultPriorityWLan = 0;
-
 const TInt KWlanLastSocketActivityTimeout = -1;
 const TInt KWlanLastSessionClosedTimeout = 1;
 const TInt KWlanLastSocketClosedTimeout = -1;
 
-/// Modem bearer names for WLAN connection methods
+/// Modem bearer names for WLAN connection methods.
 _LIT( KModemBearerWLAN, "WLANBearer" );
 
 _LIT( KWlanBearerName, "WLANBearer" );
@@ -95,7 +95,6 @@
     OstTraceFunctionEntry0( CCMPLUGINWLAN_CCMPLUGINWLAN_ENTRY );
 
     ResetBearerRecords();
-    FeatureManager::UnInitializeLib();
 
     OstTraceFunctionExit0( CCMPLUGINWLAN_CCMPLUGINWLAN_EXIT );
     }
@@ -143,43 +142,50 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINWLAN_CONSTRUCTL_ENTRY );
 
-    FeatureManager::InitializeLibL();
+    // Feature Manager is initialized by the CmmServer, so no need to do it here.
 
     if ( ! FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) )
         {
-        FeatureManager::UnInitializeLib();
-
         User::Leave( KErrNotSupported );
         }
 
     CCmPluginBaseEng::ConstructL();
 
-    // get WLAN table id
+    // Get bearer priority table ID.
+    TRAP_IGNORE( iBearerPriorityTableId =
+            CCDGlobalBearerTypePriorizationRecord::TableIdL( iSession ) );
+
+    if ( !iBearerPriorityTableId )
+        {
+        iBearerPriorityTableId =
+                CCDGlobalBearerTypePriorizationRecord::CreateTableL( iSession );
+        }
+
+    TMDBElementId tableId( 0 );
+
+    TRAP_IGNORE( tableId = CCDWlanDeviceSettingsRecord::TableIdL( iSession ) );
+    if ( !tableId )
+        {
+        CCDWlanDeviceSettingsRecord::CreateTableL( iSession );
+        }
+
+    // Get WLAN table ID.
     TRAP_IGNORE( iWlanTableId = CCDWlanServiceRecord::TableIdL( iSession ) );
-
     if ( !iWlanTableId )
         {
         iWlanTableId = CCDWlanServiceRecord::CreateTableL( iSession );
-
-        TMDBElementId tableId = 0;
-
-        TRAP_IGNORE( tableId = CCDWlanDeviceSettingsRecord::TableIdL( iSession ) );
-        if ( !tableId )
-            {
-            CCDWlanDeviceSettingsRecord::CreateTableL( iSession );
-            }
+        }
 
-        TRAP_IGNORE( tableId = CCDWLANSecSSIDTable::TableIdL( iSession ) );
-        if ( !tableId )
-            {
-            CCDWLANSecSSIDTable::CreateTableL( iSession );
-            }
+    TRAP_IGNORE( tableId = CCDWLANSecSSIDTable::TableIdL( iSession ) );
+    if ( !tableId )
+        {
+        CCDWLANSecSSIDTable::CreateTableL( iSession );
+        }
 
-        TRAP_IGNORE( tableId = CCDDestNWTable::TableIdL( iSession ) );
-        if ( !tableId )
-            {
-            CCDDestNWTable::CreateTableL( iSession );
-            }
+    TRAP_IGNORE( tableId = CCDDestNWTable::TableIdL( iSession ) );
+    if ( !tableId )
+        {
+        CCDDestNWTable::CreateTableL( iSession );
         }
 
     iWAPISupported = FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi );
@@ -296,7 +302,8 @@
         {
         case ECmInvalidAttribute:
             {
-            retVal = 0;
+            // This attribute has been deprecated since Symbian^4.
+            User::Leave( KErrNotSupported );
             }
             break;
         case ECmExtensionLevel:
@@ -312,12 +319,12 @@
             break;
         case ECmDefaultUiPriority:
             {
-            retVal = KDefaultPriorityWLan;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityWLan;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case EWlanServiceId:
@@ -453,7 +460,7 @@
             break;
         case EWlan802_1xAllowUnencrypted:
             {
-            retVal = static_cast<TBool>( wlanServiceRecord->iWlanWpaKeyLength );
+            retVal = static_cast<TBool>( wlanServiceRecord->iWlanWpaKeyLength );//TODO, change typecast to if-else structure?
             }
             break;
         default:
@@ -1232,8 +1239,8 @@
 
     TBool retVal( EFalse );
 
-    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
-                        ( CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord) );
+    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>(
+            CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord) );
 
     CleanupStack::PushL( iapRecord );
     iapRecord->SetRecordId( aIapId );
@@ -1271,11 +1278,11 @@
         tmprec->iWlanServiceId.SetL( ( TUint32 )( aIapRecord->iService ) );
         if ( tmprec->FindL( iSession ) )
             {
-            // we found at least one WLAN using this IAP,
+            // Found at least one WLAN using this IAP.
             retVal = ETrue;
             }
 
-        CleanupStack::PopAndDestroy(tmprec);
+        CleanupStack::PopAndDestroy( tmprec );
         }
 
     OstTraceFunctionExit0( DUP1_CCMPLUGINWLAN_CANHANDLEIAPIDL_EXIT );
@@ -1290,9 +1297,21 @@
     {
     OstTraceFunctionEntry0( CCMPLUGINWLAN_DELETEBEARERRECORDSL_ENTRY );
 
+    // Save the wlan service record id for the EAP settings deletion 
+    TUint wlanServiceRecordId = iWlanServiceRecord->RecordId();
+    
     // As base class deletes service record, in this case LAN, only WLAN
     // related stuff needs to be deleted.
     iWlanServiceRecord->DeleteL( iSession );
+    
+    // Delete EAP specific
+    CEapGeneralSettings* eapSettings( NULL );
+    TRAPD( err, eapSettings = CEapGeneralSettings::NewL( ELan, wlanServiceRecordId ) );
+    if ( err == KErrNone )
+        {
+        eapSettings->DeleteAllEapSettings();
+        delete eapSettings;
+        }
 
     OstTraceFunctionExit0( CCMPLUGINWLAN_DELETEBEARERRECORDSL_EXIT );
     }
@@ -1307,8 +1326,8 @@
 
     if ( TPtrC( KCDTypeNameLANService ) == iIapRecord->iServiceType )
         {
-        iServiceRecord = static_cast<CCDLANServiceRecord *>
-                    ( CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
+        iServiceRecord = static_cast<CCDLANServiceRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
 
         ServiceRecord().SetRecordId( iIapRecord->iService );
         ServiceRecord().LoadL( iSession );
@@ -1362,11 +1381,10 @@
     delete iServiceRecord;
     iServiceRecord = NULL;
 
-    iServiceRecord = static_cast<CCDLANServiceRecord*>
-                (CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
+    iServiceRecord = static_cast<CCDLANServiceRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
 
-    CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord *>( iServiceRecord );
-
+    CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord*>( iServiceRecord );
 
     if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
         {
@@ -1401,7 +1419,7 @@
         lanServiceRecord->iConfigDaemonName.SetL( KEmpty );
         }
 
-    // create WLAN service record
+    // Create WLAN service record.
     CreateWlanServiceRecordL();
 
     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATESERVICERECORDL_EXIT );
@@ -1422,9 +1440,11 @@
     iWlanServiceRecord = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
     iWlanServiceRecord->SetRecordId( KCDNewRecordRequest );
 
+    // Some attributes need to have default values set.
     iWlanServiceRecord->iRecordName.SetL( iIapRecord->iRecordName );
     iWlanServiceRecord->iWlanConnMode.SetL( CMManager::EInfra );
     iWlanServiceRecord->iWlanSecMode.SetL( CMManager::EWlanSecModeOpen );
+    iWlanServiceRecord->iWlanAuthMode.SetL( CMManager::EWlanAuthModeOpen );
     iWlanServiceRecord->iWlanScanSSID.SetL( EFalse );
 
     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATEWLANSERVICERECORDL_EXIT );
@@ -2226,9 +2246,13 @@
             }
             break;
         case ECmDefaultUiPriority:
+            {
+            retVal = GetDefPriorityL( aAttribute );
+            }
+            break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityWLan;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ECmExtensionLevel:
@@ -2614,4 +2638,45 @@
     return result;
     }
 
+// ---------------------------------------------------------------------------
+// CCmPluginWlan::GetDefPriorityL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginWlan::GetDefPriorityL( const TUint32 aAttribute ) const
+    {
+    OstTraceFunctionEntry0( CCMPLUGINWLAN_GETDEFPRIORITYL_ENTRY );
+
+    TUint32 retVal( KDataMobilitySelectionPolicyPriorityWildCard );
+
+    CCDGlobalBearerTypePriorizationRecord* priorityRecord =
+            new( ELeave ) CCDGlobalBearerTypePriorizationRecord( iBearerPriorityTableId );
+    CleanupStack::PushL( priorityRecord );
+
+    priorityRecord->iServiceType.SetL( TPtrC( KCDTypeNameLANService ) );
+
+    if ( priorityRecord->FindL( iSession ) )
+        {
+        priorityRecord->LoadL( iSession );
+        switch ( aAttribute )
+            {
+            case ECmDefaultPriority:
+                {
+                retVal = priorityRecord->iPriority;
+                }
+                break;
+            case ECmDefaultUiPriority:
+                {
+                retVal = priorityRecord->iUIPriority;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    CleanupStack::PopAndDestroy( priorityRecord );
+
+    OstTraceFunctionExit0( CCMPLUGINWLAN_GETDEFPRIORITYL_EXIT );
+    return retVal;
+    }
+
 // End of File
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlanproxy.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlanproxy.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 #include "cmpluginwlan.h"
 #include <e32std.h>
-#include <ecom/ImplementationProxy.h>
+#include <ecom/implementationproxy.h>
 
 // Exported proxy for instantiation method resolution
 // Define the interface UIDs
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/traces/OstTraceDefinitions.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef __OSTTRACEDEFINITIONS_H__
 #define __OSTTRACEDEFINITIONS_H__
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
--- a/cmmanager/cmmgr/cmmplugins/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmplugins/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -28,7 +28,7 @@
 #include "../cmpluginpacketdata/group/bld.inf"
 #include "../cmpluginlan/group/bld.inf"
 #include "../cmpluginwlan/group/bld.inf"
-//#include "../cmpluginembdestination/group/bld.inf"
-//#include "../cmpluginvpn/group/bld.inf"
+#include "../cmpluginvpn/group/bld.inf"
+#include "../cmpluginembdestination/group/bld.inf"
 
 // End of File
--- a/cmmanager/cmmgr/cmmserver/group/cmmserver.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/group/cmmserver.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,7 @@
 TARGETTYPE      exe
 UID             0x1000008d 0x20016A7A
 
-CAPABILITY      NetworkControl NetworkServices ProtServ WriteDeviceData
+CAPABILITY      NetworkControl NetworkServices ProtServ ReadDeviceData WriteDeviceData
 VENDORID        VID_DEFAULT
 
 SOURCEPATH      ../src
@@ -66,5 +66,6 @@
 LIBRARY         centralrepository.lib
 LIBRARY         esock.lib
 LIBRARY	        hbcore.lib
+LIBRARY         sysutil.lib
 
 EPOCSTACKSIZE   0x4000
--- a/cmmanager/cmmgr/cmmserver/inc/cmmanagertextresolver.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmanagertextresolver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -22,7 +22,7 @@
 /**
  *  Utility class for resolving localised text.
  */
-class CCmManagerTextResolver
+NONSHARABLE_CLASS( CCmManagerTextResolver ) : public CBase
     {
 public:    
     /**
--- a/cmmanager/cmmgr/cmmserver/inc/cmmbearerpriority.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmbearerpriority.h	Thu Jul 22 16:37:38 2010 +0100
@@ -31,16 +31,16 @@
      */
     static CCmmBearerPriority* NewL(
             const TDesC& aServiceType,
-            const TUint& aPriority,
-            const TUint& aUiPriority );
+            const TUint aPriority,
+            const TUint aUiPriority );
 
     /**
      * Two phased constuction.
      */
     static CCmmBearerPriority* NewLC(
             const TDesC& aServiceType,
-            const TUint& aPriority,
-            const TUint& aUiPriority );
+            const TUint aPriority,
+            const TUint aUiPriority );
 
     /**
      * Destructor.
@@ -51,7 +51,7 @@
     /**
      * Constructor.
      */
-    CCmmBearerPriority( const TUint& aPriority, const TUint& aUiPriority );
+    CCmmBearerPriority( const TUint aPriority, const TUint aUiPriority );
 
     /**
      * 2nd phase constructor.
--- a/cmmanager/cmmgr/cmmserver/inc/cmmbearerprioritycache.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmbearerprioritycache.h	Thu Jul 22 16:37:38 2010 +0100
@@ -75,7 +75,7 @@
     void CopyL( RPointerArray<CCmmBearerPriority>& aArray ) const;
 
     /**
-     * Get the priority value for a service type from the bearer priority
+     * Get the priority value for a service type name from the bearer priority
      * cache.
      */
     TUint GetPriority( const TDesC& aServiceType ) const;
--- a/cmmanager/cmmgr/cmmserver/inc/cmmcache.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmcache.h	Thu Jul 22 16:37:38 2010 +0100
@@ -121,7 +121,7 @@
 public:
     void OpenDestinationL(
             CCmmDestinationInstance& aDestinationInstance,
-            const TUint32& aId );
+            const TUint32 aId );
 
     /**
      * Refresh the data contained in aDestinationInstance. This means reloading
@@ -134,12 +134,12 @@
     void CreateDestinationL(
             CCmmDestinationInstance& aDestinationInstance,
             const TDesC& aName,
-            const TUint32& aId );
+            const TUint32 aId );
 
     void OpenConnMethodL(
             CCmmConnMethodInstance& aConnMethodInstance,
             CCmmDestinationInstance* aDestinationInstance,
-            const TUint32& aId );
+            const TUint32 aId );
 
     /**
      * Refresh the data contained in aConnMethodInstance. This means reloading
@@ -152,8 +152,8 @@
     void CreateConnMethodL(
             CCmmConnMethodInstance& aConnMethodInstance,
             CCmmDestinationInstance* aDestinationInstance,
-            const TUint32& aBearerType,
-            const TUint32& aConnMethodId );
+            const TUint32 aBearerType,
+            const TUint32 aConnMethodId );
 
     /**
      * Creates a copy of the given client instance (copy of the connection
@@ -207,14 +207,14 @@
      * is already checked that the connection method given as parameter can be
      * deleted and a transaction is already open.
      */
-    void DeleteConnMethodAsPartOfDestinationUpdateL( const TUint32& aConnMethodId );
+    void DeleteConnMethodAsPartOfDestinationUpdateL( const TUint32 aConnMethodId );
 
     /**
      * Deletes a connection method as part of destination delete operation. It
      * is already checked that the connection method given as parameter can be
      * deleted and a transaction is already open.
      */
-    void DeleteConnMethodAsPartOfDestinationDeleteL( const TUint32& aConnMethodId );
+    void DeleteConnMethodAsPartOfDestinationDeleteL( const TUint32 aConnMethodId );
 
     /**
      * Basic connection method delete. Removes a connection method from any
@@ -222,23 +222,23 @@
      */
     void DeleteConnMethodL( CCmmConnMethodInstance& aConnMethodInstance );
 
-    TBool DestinationExistsWithId( const TUint32& aId );
-    TBool DestinationExistsWithNameL( const TDesC& aName, const TUint32& aDestinationId );
-    TBool DestinationOpenWithId( const TUint32& aId );
-    TBool NotSavedDestinationOpenWithNameL( const TDesC& aName, const TUint32& aDestinationId );
+    TBool DestinationExistsWithId( const TUint32 aId );
+    TBool DestinationExistsWithNameL( const TDesC& aName, const TUint32 aDestinationId );
+    TBool DestinationOpenWithId( const TUint32 aId );
+    TBool NotSavedDestinationOpenWithNameL( const TDesC& aName, const TUint32 aDestinationId );
 
-    TBool ConnMethodExistsWithId( const TUint32& aConnMethodId );
-    TBool ConnMethodOpenWithId( const TUint32& aConnMethodId );
+    TBool ConnMethodExistsWithId( const TUint32 aConnMethodId );
+    TBool ConnMethodOpenWithId( const TUint32 aConnMethodId );
 
     TBool DestinationExistsWithMetadataLocalizedL(
             CCmmDestinationInstance& aDestinationInstance,
-            const TUint32& aValue );
+            const TUint32 aValue );
     TBool DestinationExistsWithMetadataPurposeL(
             CCmmDestinationInstance& aDestinationInstance,
-            const TUint32& aValue );
+            const TUint32 aValue );
 
-    void DbChangeDetected( const TUint32& aTableId );
-    void DbChangeError( const TUint32& aTableId );
+    void DbChangeDetected( const TUint32 aTableId );
+    void DbChangeError( const TUint32 aTableId );
 
     void CloseDestination( CCmmDestinationInstance& aDestinationInstance );
     void CloseConnMethod( CCmmConnMethodInstance& aConnMethodInstance );
@@ -279,7 +279,7 @@
      */
     void OpenConnectionMethodInstanceL(
             CCmmConnMethodInstance& aConnMethodInstance,
-            const TUint32& aConnMethodId );
+            const TUint32 aConnMethodId );
 
     /**
      * Returns Connection Method specific integer value. CM is loaded(if not loaded already)
@@ -290,8 +290,8 @@
      * KErrNotFound.
      */
     TUint32 GetConnectionMethodInfoIntL(
-            const TUint32& aCmId,
-            const TUint32& aAttribute );
+            const TUint32 aCmId,
+            const TUint32 aAttribute );
 
     /**
      * Returns Connection Method specific boolean value. CM is loaded(if not loaded already)
@@ -302,8 +302,8 @@
      * KErrNotFound.
      */
     TBool GetConnectionMethodInfoBoolL(
-            const TUint32& aCmId,
-            const TUint32& aAttribute );
+            const TUint32 aCmId,
+            const TUint32 aAttribute );
 
     /**
      * Returns Connection Method specific 16 bit string value.
@@ -314,8 +314,8 @@
      * KErrNotFound.
      */
     HBufC* GetConnectionMethodInfoStringL(
-            const TUint32& aCmId,
-            const TUint32& aAttribute );
+            const TUint32 aCmId,
+            const TUint32 aAttribute );
 
     /**
      * Returns Connection Method specific 8 bit string value.
@@ -326,8 +326,8 @@
      * KErrNotFound.
      */
     HBufC8* GetConnectionMethodInfoString8L(
-            const TUint32& aCmId,
-            const TUint32& aAttribute );
+            const TUint32 aCmId,
+            const TUint32 aAttribute );
 
     /**
      * Returns bearer specific integer value. IAP does not need to be loaded for this.
@@ -337,8 +337,8 @@
      * KErrNotFound.
      */
     TUint32 GetBearerInfoIntL(
-            const TUint32& aBearerType,
-            const TUint32& aAttribute );
+            const TUint32 aBearerType,
+            const TUint32 aAttribute );
 
     /**
      * Returns bearer specific boolean value. IAP does not need to be loaded for this.
@@ -348,8 +348,8 @@
      * KErrNotFound.
      */
     TBool GetBearerInfoBoolL(
-            const TUint32& aBearerType,
-            const TUint32& aAttribute );
+            const TUint32 aBearerType,
+            const TUint32 aAttribute );
 
     /**
      * Returns bearer specific 16 bit string value. IAP does not need to be loaded for this.
@@ -359,8 +359,8 @@
      * KErrNotFound.
      */
     HBufC* GetBearerInfoStringL(
-            const TUint32& aBearerType,
-            const TUint32& aAttribute );
+            const TUint32 aBearerType,
+            const TUint32 aAttribute );
 
     /**
      * Returns bearer specific 8 bit string value. IAP does not need to be loaded for this.
@@ -370,8 +370,16 @@
      * KErrNotFound.
      */
     HBufC8* GetBearerInfoString8L(
-            const TUint32& aBearerType,
-            const TUint32& aAttribute );
+            const TUint32 aBearerType,
+            const TUint32 aAttribute );
+
+    /**
+     * Find and return a copy of a connection method item matching the given ID.
+     * Returns KErrNotFound, if the connection method is not found.
+     */
+    TInt GetConnMethodItem(
+            const TUint32 aConnMethodId,
+            TCmmConnMethodItem& aConnMethodItem ) const;
 
     /**
      * Returns all conenction method IDs. Unsupported connection methods are
@@ -385,7 +393,7 @@
      * Returns the number of destinations the provided connection method
      * belongs to.
      */
-    TInt DestinationsContainingConnMethod( const TUint32& aConnMethodId ) const;
+    TInt DestinationsContainingConnMethod( const TUint32 aConnMethodId ) const;
 
     /**
      * Return the EasyWLAN IAP ID, zero if not found or WLAN not supported.
@@ -416,7 +424,7 @@
      * Returns all the valid connection methods under given destination.
      */
     void GetConnMethodsFromDestinationL(
-            const TUint32& aDestinationId,
+            const TUint32 aDestinationId,
             RArray<TCmmConnMethodItem>& aConnMethodArray ) const;
 
     /**
@@ -430,8 +438,8 @@
     void UpdateBearerPriorityArrayL( const RPointerArray<CCmmBearerPriority>& aArray );
 
     TBool ConnMethodInOtherDestination(
-            const TUint32& aConnMethodId,
-            const TUint32& aDestinationId );
+            const TUint32 aConnMethodId,
+            const TUint32 aDestinationId );
     TUint32 NextFreeTemporaryId();
 
     /**
@@ -451,7 +459,7 @@
      * @return Returns ETrue if the CM is connected and EFalse if it's not
      * connected.
      */
-    TBool CheckIfCmConnected( const TUint32& aCmId ) const;
+    TBool CheckIfCmConnected( const TUint32 aCmId ) const;
 
     /**
      * Enumerates connections and checks if any of the connection methods in
@@ -468,32 +476,32 @@
      * Check from database if the given destination is an embedded destination
      * in any other destination.
      */
-    TBool DestinationIsEmbedded( const TUint32& aDestinationId ) const;
+    TBool DestinationIsEmbedded( const TUint32 aDestinationId ) const;
 
     /**
      * Check from database if the given destination has an embedded destination.
      */
-    TBool DestinationHasEmbedded( const TUint32& aDestinationId ) const;
+    TBool DestinationHasEmbedded( const TUint32 aDestinationId ) const;
 
     /**
      * Check from database if the given destination is pointed to by any
      * virtual IAP.
      */
-    TBool DestinationPointedToByVirtualIap( const TUint32& aDestinationId ) const;
+    TBool DestinationPointedToByVirtualIap( const TUint32 aDestinationId ) const;
 
     /**
      * Check from database if the given connection method is pointed to by any
      * virtual IAP.
      */
-    TBool ConnMethodPointedToByVirtualIap( const TUint32& aConnMethodId ) const;
+    TBool ConnMethodPointedToByVirtualIap( const TUint32 aConnMethodId ) const;
 
     /**
      * Check if the given connection method is the only connection method in
      * the given destination and if a virtual IAP points to that destination.
      */
     TBool ConnMethodInDestinationButLocked(
-            const TUint32& aConnMethodId,
-            const TUint32& aDestinationId ) const;
+            const TUint32 aConnMethodId,
+            const TUint32 aDestinationId ) const;
 
     /**
      * Remove all references to the given connection method from the
@@ -524,13 +532,21 @@
      * held in the temporary array iUpdatedConnMethods until successful commit
      * to database. This method is used to find out those real IDs before that.
      */
-    void TranslateTemporaryId( const TUint32& aTemporaryId, TUint32& aRealId ) const;
+    void TranslateTemporaryId( const TUint32 aTemporaryId, TUint32& aRealId ) const;
 
     /**
      * Check if the given connection method can have all references removed and
      * made into an uncategorized connection method.
      */
-    void CheckIfConnMethodReferencesCanBeRemovedL( const CCmmConnMethodInstance& aConnMethodInstance );
+    void CheckIfConnMethodReferencesCanBeRemovedL(
+            const CCmmConnMethodInstance& aConnMethodInstance );
+
+    /**
+     * Check if given connection method is referenced from any protected destination.
+     */
+    void CheckIfConnMethodBelongsToProtectedDestinationL(
+            const CCmmConnMethodInstance& aConnMethodInstance,
+            TBool& aBelongsToProtectedDestination );
 
     /**
      * Check if the given connection method can be deleted.
@@ -548,10 +564,10 @@
     CommsDat::TMDBElementId TableId( TCmmDbRecords aRecord );
 
 private:
-    TInt FindDestinationFromCache( const TUint32& aId );
-    TInt FindNotSavedDestinationFromCacheL( const TDesC& aName, const TUint32& aDestinationId );
+    TInt FindDestinationFromCache( const TUint32 aId );
+    TInt FindNotSavedDestinationFromCacheL( const TDesC& aName, const TUint32 aDestinationId );
 
-    TInt FindConnMethodFromCache( const TUint32& aConnMethodId );
+    TInt FindConnMethodFromCache( const TUint32 aConnMethodId );
 
     void ReplaceGenConnSettingsL( const TCmGenConnSettings& aGenConnSettings );
 
--- a/cmmanager/cmmgr/cmmserver/inc/cmmconnmethodinstance.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmconnmethodinstance.h	Thu Jul 22 16:37:38 2010 +0100
@@ -69,16 +69,6 @@
 
 public:
     /**
-     * Set the plugin base pointer.
-     */
-    void SetPlugin( CCmPluginBaseEng* aPlugin );
-
-    /**
-     * Get the plugin base pointer.
-     */
-    CCmPluginBaseEng* GetPlugin() const;
-
-    /**
      * Get connection method ID.
      */
     TUint32 GetId() const;
@@ -86,7 +76,7 @@
     /**
      * Set connection method ID.
      */
-    void SetId( const TUint32& aConnMethodId );
+    void SetId( const TUint32 aConnMethodId );
 
     /**
      * Return bearer type.
@@ -94,11 +84,6 @@
     TUint32 GetBearerType() const;
 
     /**
-     * Set bearer type.
-     */
-    void SetBearerType( const TUint32& aBearerType );
-
-    /**
      * Get handle ID.
      */
     TInt GetHandle() const;
@@ -106,7 +91,7 @@
     /**
      * Set handle ID.
      */
-    void SetHandle( const TInt& aHandle );
+    void SetHandle( const TInt aHandle );
 
     /**
      * Get pointer to the plugin data container.
@@ -137,7 +122,7 @@
      * @return Returns the value of the requested attribute if succees. Otherwise
      * leaves with KErrArgument
      */
-    TUint32 GetIntAttributeL( const TUint32& aAttribute );
+    TUint32 GetIntAttributeL( const TUint32 aAttribute );
 
     /**
      * Returns integer value identified by aAttribute. Some special cases
@@ -146,7 +131,7 @@
      * @return Returns the value of the requested attribute if succees. Otherwise
      * leaves with KErrArgument
      */
-    TBool GetBoolAttributeL( const TUint32& aAttribute );
+    TBool GetBoolAttributeL( const TUint32 aAttribute );
 
     /**
      * Returns 16 bit string value identified by aAttribute.
@@ -154,7 +139,7 @@
      * @return Returns the value of the requested attribute if succees. Otherwise
      * leaves with KErrArgument
      */
-    HBufC* GetStringAttributeL( const TUint32& aAttribute );
+    HBufC* GetStringAttributeL( const TUint32 aAttribute );
 
     /**
      * Returns 8 bit string value identified by aAttribute.
@@ -162,7 +147,7 @@
      * @return Returns the value of the requested attribute if succees. Otherwise
      * leaves with KErrArgument
      */
-    HBufC8* GetString8AttributeL( const TUint32& aAttribute );
+    HBufC8* GetString8AttributeL( const TUint32 aAttribute );
 
     /**
      * Sets the integer value identified by aAttribute.
@@ -171,8 +156,8 @@
      * @return None
      */
     void SetIntAttributeL(
-        const TUint32& aAttribute,
-        const TUint32& aValue );
+            const TUint32 aAttribute,
+            const TUint32 aValue );
 
     /**
      * Sets the integer value identified by aAttribute.
@@ -181,8 +166,8 @@
      * @return None
      */
     void SetBoolAttributeL(
-        const TUint32& aAttribute,
-        const TBool& aValue );
+            const TUint32 aAttribute,
+            const TBool aValue );
 
     /**
      * Sets the 16 bit string value identified by aAttribute.
@@ -191,8 +176,8 @@
      * @return None
      */
     void SetStringAttributeL(
-        const TUint32& aAttribute,
-        const TDesC16& aValue );
+            const TUint32 aAttribute,
+            const TDesC16& aValue );
 
     /**
      * Sets the 8 bit string value identified by aAttribute.
@@ -201,13 +186,8 @@
      * @return None
      */
     void SetString8AttributeL(
-        const TUint32& aAttribute,
-        const TDesC8& aValue );
-
-    /**
-     * Gets the current status of this connection method instance.
-     */
-    TCmmConnMethodStatus GetStatus() const;
+            const TUint32 aAttribute,
+            const TDesC8& aValue );
 
     /**
      * Sets a new status value.
@@ -226,7 +206,7 @@
      * transaction has completed successfully. Sets the internal state of this
      * connection method structure to reflect the new deleted state.
      */
-    void DeleteSuccessful( const TUint32& aNewSecondaryId );
+    void DeleteSuccessful( const TUint32 aNewSecondaryId );
 
     /**
      * After update/delete to database, refresh temporary ID to real ID if
@@ -239,7 +219,7 @@
      * Removes a connection method from any open destination handle in the same
      * session.
      */
-    void RemoveConnMethodFromSessionDestinationHandles( const TUint32& aConnMethodId );
+    void RemoveConnMethodFromSessionDestinationHandles( const TUint32 aConnMethodId );
 
 private:
     // Session that owns this instance.
--- a/cmmanager/cmmgr/cmmserver/inc/cmmconnmethoditem.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmconnmethoditem.h	Thu Jul 22 16:37:38 2010 +0100
@@ -34,7 +34,10 @@
             TUint32 aId,
             TUint32 aBearerType,
             TUint aBearerPriority,
-            TUint aPriority );
+            TUint aPriority,
+            TBool aIsVirtual = 0,
+            TUint32 aLinkedIapId = 0,
+            TUint32 aLinkedSnapId = 0 );
 
     /**
      * A comparison function. Uses priority since items are in priority order.
@@ -51,6 +54,30 @@
             const TUint32* aKey,
             const TCmmConnMethodItem& aEntry );
 
+    /**
+     * Return ETrue if this connection method item represents a virtual
+     * destination.
+     */
+    TBool IsVirtual() const; 
+
+    /**
+     * Return ETrue if this connection method item represents an embedded
+     * destination.
+     */
+    TBool IsEmbedded() const;
+
+    /**
+     * If this is a virtual IAP that points to an IAP, returns the ID of that
+     * IAP, 0 otherwise.
+     */
+    TUint32 LinkedIapId() const;
+
+    /**
+     * If this is a virtual IAP that points to a SNAP, returns the ID of that
+     * SNAP, 0 otherwise.
+     */
+    TUint32 LinkedSnapId() const;
+
 public:
     // Connection method ID.
     TUint32 iId;
@@ -62,8 +89,18 @@
     TUint iBearerPriority;
 
     // Priority value in the CCDDataMobilitySelectionPolicy-record. Only used
-    // for sorting purposes when building an array ofTCmmConnMethodItem-objects.
+    // for sorting purposes when building an array of TCmmConnMethodItem-objects.
     TUint iPriority;
+
+private:
+    // ETrue if this connection method is virtual.
+    TBool iIsVirtual;
+
+    // If not 0, this is a virtual IAP that points to IAP with ID iLinkedIapId.
+    TUint32 iLinkedIapId;
+
+    // If not 0, this is a virtual IAP that points to SNAP with ID iLinkedSnapId.
+    TUint32 iLinkedSnapId;
     };
 
 #endif // CMMCONNMETHODITEM_H_
--- a/cmmanager/cmmgr/cmmserver/inc/cmmconnmethodstruct.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmconnmethodstruct.h	Thu Jul 22 16:37:38 2010 +0100
@@ -35,8 +35,8 @@
 NONSHARABLE_CLASS( CCmmConnMethodStruct ) : public CBase
     {
 public:
-    static CCmmConnMethodStruct* NewL( const TUint32& aConnMethodId );
-    static CCmmConnMethodStruct* NewLC( const TUint32& aConnMethodId );
+    static CCmmConnMethodStruct* NewL( const TUint32 aConnMethodId );
+    static CCmmConnMethodStruct* NewLC( const TUint32 aConnMethodId );
     ~CCmmConnMethodStruct();
 
 private:
@@ -62,7 +62,7 @@
     /**
      * Set the connection method ID.
      */
-    void SetId( const TUint32& aConnMethodId );
+    void SetId( const TUint32 aConnMethodId );
 
     /**
      * Return bearer type.
@@ -80,8 +80,9 @@
     void SetStatus( const TCmmConnMethodStatus& aStatus );
 
     /**
-     * TODO
-     * 
+     * Refresh the connection method data in this cache side object to be in
+     * synch with the database and copy that data back to the session side
+     * connection method instance given as parameter.
      */
     void RefreshConnMethodInstanceL(
             CCmmConnMethodInstance& aConnMethodInstance );
@@ -90,11 +91,10 @@
      * Decrease the reference counter by one. Return the remaining number of
      * references.
      */
-    TInt SessionInstanceClosed(); //TODO, rename to ConnMethodInstanceClosed ?
+    TInt ConnMethodInstanceClosed();
 
     /**
-     * Set the connection method plugin. Updates status and sets reference
-     * counter to 1.
+     * Set the connection method plugin pointer, bearer type and status.
      */
     void SetPlugin(
             CCmPluginBaseEng* aPlugin,
@@ -118,7 +118,7 @@
      * transaction has completed successfully. Sets the internal state of this
      * connection method structure to reflect the new deleted state.
      */
-    void DeleteSuccessful( const TUint32& aNewSecondaryId );
+    void DeleteSuccessful( const TUint32 aNewSecondaryId );
 
 private:
     // The connection method plugin.
--- a/cmmanager/cmmgr/cmmserver/inc/cmmdestinationinstance.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmdestinationinstance.h	Thu Jul 22 16:37:38 2010 +0100
@@ -70,7 +70,7 @@
     void ConstructL();
 
 public:
-    void SetId( const TUint32& aId );
+    void SetId( const TUint32 aId );
     TUint32 GetId() const;
 
     /**
@@ -91,7 +91,7 @@
     /**
      * Set handle ID.
      */
-    void SetHandle( const TInt& aHandle );
+    void SetHandle( const TInt aHandle );
 
     /**
      * Set the record status for all records.
@@ -119,12 +119,18 @@
     HBufC* GetLocalisedDestinationNameL();
     void SetDestinationNameL( const TDesC& aDestinationName );
 
+    /**
+     * Get the destination icon.
+     */
+    HBufC* GetDestinationIconL();
+    void SetDestinationIconL( const TDesC& aDestinationIcon );
+
     void GetMetadataL(
             const CMManager::TSnapMetadataField& aMetadataField,
             TUint32& aMetadata );
     void SetMetadataL(
             const CMManager::TSnapMetadataField& aMetadataField,
-            const TUint32& aMetadata );
+            const TUint32 aMetadata );
 
     void GetProtectionL( CMManager::TProtectionLevel& aProtectionLevel );
     void SetProtectionL( CMManager::TProtectionLevel aProtectionLevel );
@@ -143,14 +149,14 @@
     /**
      * Return the protection level currently set into this destination instance.
      */
-    CMManager::TProtectionLevel CurrentProtectionLevel();
+    CMManager::TProtectionLevel CurrentProtectionLevelL();
 
     /**
      * Adds a connection method into this destination. Returns the index in
      * the connection method array where the connection method was added.
      */
     TInt AddConnMethodL(
-            const CCmmConnMethodInstance& aConnMethodInstance );
+            CCmmConnMethodInstance& aConnMethodInstance );
 
     /**
      * Adds an embedded destination into this destination. Returns the index in
@@ -175,13 +181,13 @@
      */
     void RemoveConnMethodFromDestinationL(
             const CCmmConnMethodInstance& aConnMethodInstance,
-            const TBool& aTestIfConnected = ETrue );
+            const TBool aTestIfConnected = ETrue );
 
     /**
      * Modifies the priority of a connection method inside this destination.
      */
     void ModifyConnMethodPriorityL(
-            const CCmmConnMethodInstance& aConnMethodInstance,
+            CCmmConnMethodInstance& aConnMethodInstance,
             TUint aIndex );
 
     /**
@@ -189,14 +195,14 @@
      * matches the provided ID. Return NULL if no match is found.
      */
     CCmmConnMethodInstance* FindConnMethodInstanceFromSessionById(
-            const TUint32& aConnMethodId ) const;
+            const TUint32 aConnMethodId ) const;
 
     /**
      * Finds a destination instance that belongs to the same session and matches
      * the provided ID. Return NULL if no match is found.
      */
     CCmmDestinationInstance* FindDestinationInstanceFromSessionById(
-            const TUint32& aDestinationId ) const;
+            const TUint32 aDestinationId ) const;
 
     /**
      * Check from all open destination handles in the same session if the given
@@ -204,15 +210,15 @@
      * skipped.
      */
     TBool ConnMethodInOtherDestinationInSession(
-            const TUint32& aConnMethodId,
-            const TUint32& aDestinationId ) const;
+            const TUint32 aConnMethodId,
+            const TUint32 aDestinationId ) const;
 
     /**
      * Check if the given connection method is in this destination. Include
      * embedded destinations.
      */
     TBool ValidConnMethodIdInDestinationIncludeEmbedded(
-            const TUint32& aConnMethodId ) const;
+            const TUint32 aConnMethodId ) const;
 
     /**
      * Check if the given connection method is inside this destination and if
@@ -221,7 +227,7 @@
      * if it is the only remaining connection method in a destination and a
      * virtual IAP points into that destination.
      */
-    TBool ConnMethodInDestinationButLocked( const TUint32& aConnMethodId ) const;
+    TBool ConnMethodInDestinationButLocked( const TUint32 aConnMethodId ) const;
 
     /**
      * Counts how many connection methods that require priority information are
@@ -244,7 +250,7 @@
      * ID. Checks the current (possibly unsaved) status of this destination
      * handle, not the current status in database.
      */
-    TBool HasEmbeddedWithId( const TUint32& aDestinationId ) const;
+    TBool HasEmbeddedWithId( const TUint32 aDestinationId ) const;
 
     /**
      * After update/delete to database, refresh temporary ID to real ID if
@@ -273,14 +279,14 @@
     /**
      * Loads a requested type of record from database if it is not yet loaded.
      */
-    void RefreshRecordL( TCmmDbRecords aRecordType );
+    void LoadRecordIfMissingL( TCmmDbRecords aRecordType );
 
     void LoadAllRecordsL();
-    void SetMetadataInternetL( const TUint32& aMetadata );
-    void SetMetadataHighlight( const TUint32& aMetadata );
-    void SetMetadataHiddenAgentL( const TUint32& aMetadata );
-    void SetMetadataLocalizationL( const TUint32& aMetadata );
-    void SetMetadataPurposeL( const TUint32& aMetadata );
+    void SetMetadataInternetL( const TUint32 aMetadata );
+    void SetMetadataHighlight( const TUint32 aMetadata );
+    void SetMetadataHiddenAgentL( const TUint32 aMetadata );
+    void SetMetadataLocalizationL( const TUint32 aMetadata );
+    void SetMetadataPurposeL( const TUint32 aMetadata );
 
     /**
      * Checks the current metadata for this destination, and verifies there is
--- a/cmmanager/cmmgr/cmmserver/inc/cmmdestinationstruct.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmdestinationstruct.h	Thu Jul 22 16:37:38 2010 +0100
@@ -46,22 +46,22 @@
     static CCmmDestinationStruct* NewL(
             CCmmCache* aCache,
             CCmmTransactionHandler* aTransactionHandler,
-            const TUint32& aId );
+            const TUint32 aId );
     static CCmmDestinationStruct* NewL(
             CCmmCache* aCache,
             CCmmTransactionHandler* aTransactionHandler,
             const TDesC& aName,
-            const TUint32& aId );
+            const TUint32 aId );
 
     static CCmmDestinationStruct* NewLC(
             CCmmCache* aCache,
             CCmmTransactionHandler* aTransactionHandler,
-            const TUint32& aId );
+            const TUint32 aId );
     static CCmmDestinationStruct* NewLC(
             CCmmCache* aCache,
             CCmmTransactionHandler* aTransactionHandler,
             const TDesC& aName,
-            const TUint32& aId );
+            const TUint32 aId );
 
     virtual ~CCmmDestinationStruct();
 
@@ -69,13 +69,13 @@
     CCmmDestinationStruct( CCmmCache* aCache, CCmmTransactionHandler* aTransactionHandler );
 
     // Opens an existing destination, based on ID.
-    void ConstructL( const TUint32& aDestinationId );
+    void ConstructL( const TUint32 aDestinationId );
 
     // Creates a new destination. With name and optionally also with ID.
-    void ConstructL( const TDesC& aName, const TUint32& aId );
+    void ConstructL( const TDesC& aName, const TUint32 aId );
 
 public:
-    void SetId( const TUint32& aId );
+    void SetId( const TUint32 aId );
     TUint32 GetId() const;
 
     /**
@@ -101,18 +101,51 @@
      */
     void SetStatusForAllRecords( const TCmmRecordStatus& aStatus );
 
-    void CreateSessionInstanceL( //TODO, rename to CreateDestinationInstanceL ?
+
+    /**
+     * Copies the data for this destination to a session instance and
+     * increments the reference counter by one.
+     */
+    void CreateDestinationInstanceL(
             CCmmDestinationInstance& aDestinationInstance );
+
+    /**
+     * Refresh the data contained in aDestinationInstance. This means reloading
+     * the data from database if necessary. After this call the contents of
+     * aDestinationInstance will reflect the current state in the database. 
+     */
     void RefreshDestinationInstanceL(
             CCmmDestinationInstance& aDestinationInstance );
+
+    /**
+     * Re-loads a destination record if needed and copies the latest version to
+     * the session instance given as parameter.
+     */
     void LoadRecordL(
             CCmmDestinationInstance& aDestinationInstance,
             TCmmDbRecords aRecordType );
+
+    /**
+     * Save the contents of a session side destination handle into database.
+     */
     void UpdateL(
             CCmmDestinationInstance& aDestinationInstance,
             CCmmCache* aCache );
+
+    /**
+     * Delete all database records of this destination. Also removes any
+     * records making this destination an embedded destination in another
+     * destination.
+     */
     void DeleteL();
-    TInt SessionInstanceClosed(); //TODO, rename to DestinationInstanceClosed ?
+
+    /**
+     * 
+     * This should be called when a client session closes a destination handle.
+     * Reference counter is decremented by one and the remaining number of
+     * references is returned.
+     */
+    TInt DestinationInstanceClosed();
 
     /**
      * Called after this destination has been updated and database transaction
@@ -128,6 +161,15 @@
     void SetDefaultCprL();
     void SetDefaultSCprL();
     void SetDefaultProtocolL();
+
+    /**
+     * Set attribute flag on the given record.
+     * @param aRecord Record to be set.
+     * @param aAttribute Attribute to be set.
+     * @param aSet ETrue to set, EFalse to clear.
+     */
+    void SetAttribute( CommsDat::CCDRecordBase* aRecord, TUint32 aAttribute, TBool aSet );
+
     CommsDat::CCDRecordBase* CopyRecordL(
             TCmmDbRecords aRecordType,
             CommsDat::CCDRecordBase* aSource );
--- a/cmmanager/cmmgr/cmmserver/inc/cmminstancemapping.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmminstancemapping.h	Thu Jul 22 16:37:38 2010 +0100
@@ -47,7 +47,10 @@
     RArray<TCmmConnMethodItem> iConnMethodItemArray;
 
     // IDs for unsupported connection methods inside this destination.
-    RArray<TUint32> iUnsupportedConnMethods;
+    RArray<TUint> iUnsupportedConnMethods;
+    
+    // The destination metadata.
+    TUint32 iMetadata;
     };
 
 
@@ -91,55 +94,77 @@
     /**
      * Check if the given ID is a valid existing destination ID.
      */
-    TBool ValidDestinationId( const TUint32& aId ) const;
+    TBool ValidDestinationId( const TUint32 aId ) const;
 
     /**
      * Check if the given ID is a valid existing connection method ID.
      */
-    TBool ValidConnMethodId( const TUint32& aId ) const;
+    TBool ValidConnMethodId( const TUint32 aId ) const;
+
+    /**
+     * Check if the given ID is a valid existing unsupported connection method
+     * ID.
+     */
+    TBool UnsupportedConnMethodId( const TUint32 aId ) const;
 
     /**
      * Check from database if the given destination is an embedded destination
      * in any other destination.
      */
-    TBool DestinationIsEmbedded( const TUint32& aDestinationId ) const;
+    TBool DestinationIsEmbedded( const TUint32 aDestinationId ) const;
 
     /**
      * Check from database if the given destination has an embedded destination.
      */
-    TBool DestinationHasEmbedded( const TUint32& aDestinationId ) const;
+    TBool DestinationHasEmbedded( const TUint32 aDestinationId ) const;
 
     /**
      * Check from database if the given destination is pointed to by any
      * virtual IAP.
      */
-    TBool DestinationPointedToByVirtualIap( const TUint32& aDestinationId ) const;
+    TBool DestinationPointedToByVirtualIap( const TUint32 aDestinationId ) const;
 
     /**
      * Check from database if the given connection method is pointed to by any
      * virtual IAP.
      */
-    TBool ConnMethodPointedToByVirtualIap( const TUint32& aConnMethodId ) const;
+    TBool ConnMethodPointedToByVirtualIap( const TUint32 aConnMethodId ) const;
 
     /**
      * Check if the given connection method is the only connection method in
      * the given destination and if a virtual IAP points to that destination.
      */
     TBool ConnMethodInDestinationButLocked(
-            const TUint32& aConnMethodId,
-            const TUint32& aDestinationId ) const;
+            const TUint32 aConnMethodId,
+            const TUint32 aDestinationId ) const;
 
     /**
      * Get bearer type of connection method matching given ID.
      * Return KErrNone if ID is found, KErrNotFound if not.
      */
-    TInt GetConnMethodBearerType( const TUint32& aConnMethodId, TUint32& bearerType ) const;
+    TInt GetConnMethodBearerType( const TUint32 aConnMethodId, TUint32& bearerType ) const;
 
     /**
      * Returns the number of destinations the provided connection method
      * belongs to.
      */
-    TInt DestinationsContainingConnMethod( const TUint32& aConnMethodId ) const;
+    TInt DestinationsContainingConnMethod( const TUint32 aConnMethodId ) const;
+
+    /**
+     * Returns the destination ids containing the connection method given as
+     * parameter.
+     */
+    void DestinationsContainingConnMethodL(
+            const TUint32 aConnMethodId,
+            RArray<TUint32>& aDestinationIds ) const;
+
+    /**
+     * Find and return a copy of a connection method item matching the given ID.
+     * Returns KErrNotFound, if the connection method is not found.
+     */
+    TInt GetConnMethodItem(
+            const TUint32 aConnMethodId,
+            TCmmConnMethodItem& aConnMethodItem ) const;
 
     /**
      * Returns all conenction method IDs. Unsupported connection methods are
@@ -164,7 +189,7 @@
      * into the provided connection method item array. The array is reset first.
      */
     void GetConnMethodsFromDestinationL(
-            const TUint32& aDestinationId,
+            const TUint32 aDestinationId,
             RArray<TCmmConnMethodItem>& aConnMethodArray ) const;
 
     /**
@@ -172,8 +197,8 @@
      * destination than the one given.
      */
     TBool ConnMethodInOtherDestination(
-            const TUint32& aConnMethodId,
-            const TUint32& aDestinationId );
+            const TUint32 aConnMethodId,
+            const TUint32 aDestinationId );
 
     /**
      * Return the EasyWLAN IAP ID, zero if not found or WLAN not supported.
@@ -190,47 +215,48 @@
      * removes the connection method from destination/connection method
      * structures so Refresh()-call is not needed.
      */
-    void AddConnMethodToDeletedListL( const TUint& aConnMethodId );
+    void AddConnMethodToDeletedListL( const TUint aConnMethodId );
 
     /**
      * Remove a connection method ID from deleted list. Nothing happens if ID
      * is not found from the list.
      */
-    void RemoveConnMethodFromDeletedList( const TUint& aConnMethodId );
+    void RemoveConnMethodFromDeletedList( const TUint aConnMethodId );
 
     /**
      * Add a destination ID to deleted list. Ignores any duplicates. Also
      * removes the destination from destination/connection method structures
      * so Refresh()-call is not needed.
      */
-    void AddDestinationToDeletedListL( const TUint& aDestinationId );
+    void AddDestinationToDeletedListL( const TUint aDestinationId );
 
     /**
      * Remove a destination ID from deleted list. Nothing happens if ID is not
      * found from the list.
      */
-    void RemoveDestinationFromDeletedList( const TUint& aDestinationId );
+    void RemoveDestinationFromDeletedList( const TUint aDestinationId );
 
     /**
      * Remove the connection method from current destination/connection method
      * structures. This is a lot faster than calling Refresh().
      */
-    void RemoveConnMethod( const TUint32& aConnMethodId );
+    void RemoveConnMethod( const TUint32 aConnMethodId );
 
     /**
      * Remove the connection method from current destination/connection method
      * structures. This is a lot faster than calling Refresh(). The ID of any
      * changed destination is added to the aChangedDestinations-array.
+     * Also adds the ID of any changed destinations to the provided array.
      */
     void RemoveConnMethod(
-            const TUint32& aConnMethodId,
+            const TUint32 aConnMethodId,
             RArray<TUint32>& aChangedDestinations );
 
     /**
      * Remove the destination from current destination/connection method
      * structures. This is a lot faster than calling Refresh().
      */
-    void RemoveDestination( const TUint32& aDestinationId );
+    void RemoveDestination( const TUint32 aDestinationId );
 
     /**
      * Remove the connection method from all destinations in the current
@@ -239,8 +265,13 @@
      * aChangedDestinations-array.
      */
     void RemoveConnMethodFromDestinations(
-            const TUint32& aConnMethodId,
+            const TUint32 aConnMethodId,
             RArray<TUint32>& aChangedDestinations );
+    
+    /**
+     * Get the metadata of the destination identified with given id.
+     */
+    TUint32 DestinationMetadata( const TUint32 aDestinationId ) const;
 
 private:
     /**
@@ -254,6 +285,24 @@
     void ReadAndValidateDestinationsL();
 
     /**
+     * Goes through the internal IAP table, checking all virtual IAPs that link
+     * to an IAP. If the linked IAP is not found, the virtual IAP is removed.
+     */
+    void ValidateVirtualIapsLinkingToIaps();
+
+    /**
+     * Goes through the internal IAP table, checking all virtual IAPs that link
+     * to a SNAP. If the linked SNAP is not found, the virtual IAP is removed.
+     */
+    void ValidateVirtualIapsLinkingToSnaps();
+
+    /**
+     * Find the destination item matching the provided destination ID.
+     * Returns a pointer to the internal destination item, NULL if not found.
+     */
+    CDestination* GetDestination( const TUint32 aDestinationId ) const;
+
+    /**
      * Returns the reference to shared CommsDat session handle.
      */
     CommsDat::CMDBSession& Session() const;
@@ -266,7 +315,7 @@
     RArray<TCmmConnMethodItem> iConnMethodItemArray;
 
     // IDs for all unsupported connection methods.
-    RArray<TUint32> iUnsupportedConnMethods;
+    RArray<TUint> iUnsupportedConnMethods;
 
     // All destinations.
     RPointerArray<CDestination> iDestinations;
--- a/cmmanager/cmmgr/cmmserver/inc/cmmserver.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmserver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -85,14 +85,14 @@
      * embedded.
      */
     TBool EmbeddedDestinationConflictsFromAllSessions(
-            const TUint32& aDestinationId,
-            const TUint32& aEmbeddedDestinationId );
+            const TUint32 aDestinationId,
+            const TUint32 aEmbeddedDestinationId );
 
     /**
      * Notify each session about a destination/connection method that has been
      * updated to, or deleted from, database.
      */
-    void RefreshHandlesForAllSessions( const TUint32& aId );
+    void RefreshHandlesForAllSessions( const TUint32 aId );
     
     /**
      * Custom security checking for IPCs marked with TSpecialCase::ECustomCheck.
@@ -104,6 +104,15 @@
             TInt& aAction,
             TSecurityInfo& aMissing );
 
+    /**
+     * Checks the client's capabilities in the middle of request handling. Some
+     * checks cannot be done with CustomSecurityCheckL() at the start phase of
+     * the operation.
+     * @param aMsg The IPC message from the client.
+     * @return Returns ETrue if client has the needed capabilities. Otherwise
+     * returns EFalse.
+     */
+    CPolicyServer::TCustomResult CapabilityCheckWithProtection( const RMessage2& aMessage );
 
 protected: // From CActive
     /**
--- a/cmmanager/cmmgr/cmmserver/inc/cmmsession.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/inc/cmmsession.h	Thu Jul 22 16:37:38 2010 +0100
@@ -21,6 +21,7 @@
 #define CMMSESSION_H_
 
 #include <e32base.h>
+#include <f32file.h>
 
 #include "cmmcache.h"
 
@@ -77,21 +78,21 @@
      * matches the provided ID. Return NULL if no match is found.
      */
     CCmmConnMethodInstance* FindConnMethodInstanceById(
-            const TUint32& aConnMethodId );
+            const TUint32 aConnMethodId );
 
     /**
      * Finds a destination instance that belongs to this session and matches
      * the provided handle.
      */
     CCmmDestinationInstance* FindDestinationInstanceByHandleL(
-            const TInt& aDestinationHandle );
+            const TInt aDestinationHandle );
 
     /**
      * Finds a destination instance that belongs to this session and matches
      * the provided ID. Return NULL if no match is found.
      */
     CCmmDestinationInstance* FindDestinationInstanceById(
-            const TUint32& aDestinationId );
+            const TUint32 aDestinationId );
 
     /**
      * Check from all open destination handles in this session if the given
@@ -99,8 +100,8 @@
      * skipped.
      */
     TBool ConnMethodInOtherDestination(
-            const TUint32& aConnMethodId,
-            const TUint32& aDestinationId );
+            const TUint32 aConnMethodId,
+            const TUint32 aDestinationId );
 
     /**
      * Check for restrictions for adding an embedded destination from destination
@@ -111,8 +112,8 @@
      * embedded.
      */
     TBool EmbeddedDestinationConflictsFromAllSessions(
-            const TUint32& aDestinationId,
-            const TUint32& aEmbeddedDestinationId );
+            const TUint32 aDestinationId,
+            const TUint32 aEmbeddedDestinationId );
 
     /**
      * Check for restrictions for adding an embedded destination from destination
@@ -123,8 +124,8 @@
      * embedded.
      */
     TBool EmbeddedDestinationConflicts(
-            const TUint32& aDestinationId,
-            const TUint32& aEmbeddedDestinationId );
+            const TUint32 aDestinationId,
+            const TUint32 aEmbeddedDestinationId );
 
     /**
      * After update to database, refresh temporary ID to real ID if necessary
@@ -138,13 +139,13 @@
      * session.
      */
     void RemoveConnMethodFromDestinationHandles(
-            const TUint32& aConnMethodId );
+            const TUint32 aConnMethodId );
 
     /**
      * Notify this sessions destination/connection method handles about an
      * updated/deleted destination/connection method.
      */
-    void RefreshHandles( const TUint32& aId ) const;
+    void RefreshHandles( const TUint32 aId ) const;
 
 private:
     /**
@@ -184,6 +185,7 @@
     void GetAllDestinationsL( const RMessage2& aMessage );
     void GetEasyWLANIdL( const RMessage2& aMessage );
     void GetSupportedBearersL( const RMessage2& aMessage );
+    void GetUncategorizedIconL( const RMessage2& aMessage );
     void ReadDefaultConnectionL( const RMessage2& aMessage );
     void ReadGenConnSettingsL( const RMessage2& aMessage );
     void WriteGenConnSettingsL( const RMessage2& aMessage );
@@ -192,7 +194,6 @@
     void CopyConnMethodL( const RMessage2& aMessage );
     void MoveConnMethodL( const RMessage2& aMessage );
     void RemoveConnMethodL( const RMessage2& aMessage );
-
     void RemoveAllReferencesL( const RMessage2& aMessage );
 
     void GetDestinationL( const RMessage2& aMessage );
@@ -210,6 +211,7 @@
     void IsDestinationConnectedL( const RMessage2& aMessage );
     void IsDestinationHiddenL( const RMessage2& aMessage );
     void DestinationIsEqualL( const RMessage2& aMessage );
+    void GetDestinationIconL( const RMessage2& aMessage );
 
     void DestAddConnMethodL( const RMessage2& aMessage );
     void DestAddEmbeddedDestinationL( const RMessage2& aMessage );
@@ -223,6 +225,7 @@
     void SetDestinationHiddenL( const RMessage2& aMessage );
     void UpdateDestinationL( const RMessage2& aMessage );
     void DeleteDestinationL( const RMessage2& aMessage );
+    void SetDestinationIconL( const RMessage2& aMessage );
 
     void CreateConnMethodL( const RMessage2& aMessage );
     void UpdateConnMethodL( const RMessage2& aMessage );
@@ -247,6 +250,18 @@
     void CreateCopyOfExistingL( const RMessage2& aMessage );
     void GetEmbeddedDestinationL( const RMessage2& aMessage );
 
+    /**
+     * Check if CM is protected and if so then check the needed capabilities.
+     */
+    void CheckCapabilitiesForProtectedCML( 
+            const RMessage2& aMessage,
+            CCmmConnMethodInstance* aConnectionMethod );
+
+    /**
+     * Checks the disk space.
+     */
+    TBool CheckSpaceBelowCriticalLevelL();
+
 private:
     RMessage2 iMessage;
 
@@ -265,6 +280,12 @@
     CObjectIx* iConnMethodObjects;
 
     CCmmCache& iCache; // Not owned
+
+    // Tells if Fileserver handle is valid.
+    TBool iFsConnected;
+
+    // File server handle.
+    RFs iFs;
     };
 
 #endif // CMMSESSION_H_
--- a/cmmanager/cmmgr/cmmserver/src/cmmanagerimpl.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmanagerimpl.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -70,6 +70,8 @@
 
     if ( iIsFeatureManagerInitialised )
         {
+        // Feature manager must not be uninitialized earlier. Plugins must be
+        // able to use it.
         FeatureManager::UnInitializeLib();
         }
 
@@ -107,6 +109,8 @@
     {
     OstTraceFunctionEntry0( CCMMANAGERIMPL_CONSTRUCTL_ENTRY );
 
+    // Feature Manager is initialized here, and it can be used by plugins also.
+    // It is uninitialized in destructor.
     FeatureManager::InitializeLibL();
     iIsFeatureManagerInitialised = ETrue;
     iWLanSupport = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
@@ -133,22 +137,22 @@
 
     TInt err( 0 );
 
-    TRAP( err, iSnapTableId = CCDDataMobilitySelectionPolicyRecord::TableIdL( iTrans->Session() ));
+    TRAP( err, iBearerPriorityTableId =
+            CCDGlobalBearerTypePriorizationRecord::TableIdL( iTrans->Session() ) );
     if ( err == KErrNotFound )
         {
-        iSnapTableId = CCDDataMobilitySelectionPolicyRecord::CreateTableL( iTrans->Session() );
+        iBearerPriorityTableId =
+               CCDGlobalBearerTypePriorizationRecord::CreateTableL( iTrans->Session() );
         }
     else
         {
         User::LeaveIfError( err );
         }
 
-    TRAP( err, iBearerPriorityTableId =
-            CCDGlobalBearerTypePriorizationRecord::TableIdL( iTrans->Session() ) );
+    TRAP( err, iSnapTableId = CCDDataMobilitySelectionPolicyRecord::TableIdL( iTrans->Session() ));
     if ( err == KErrNotFound )
         {
-        iBearerPriorityTableId =
-               CCDGlobalBearerTypePriorizationRecord::CreateTableL( iTrans->Session() );
+        iSnapTableId = CCDDataMobilitySelectionPolicyRecord::CreateTableL( iTrans->Session() );
         }
     else
         {
@@ -304,23 +308,25 @@
             CleanupStack::PushL( plugin );
 
             TBool inserted( EFalse );
-            //TODO, Implement plugin sorting by priority later.
-            /*
-            TInt defaultPriority( KDataMobilitySelectionPolicyPriorityWildCard );
+
+            TInt defaultPriority( CMManager::KDataMobilitySelectionPolicyPriorityWildCard );
 
-            // No UI priority -> wildcard
-            TRAP_IGNORE( defaultPriority = plugin->GetIntAttributeL( ECmDefaultUiPriority ) );
+            // No priority -> wildcard
+            TRAP_IGNORE( defaultPriority = plugin->GetBearerInfoIntL(
+                    CMManager::ECmDefaultPriority ) );
 
-            for ( TInt j( 0 ); j < iPlugins->Count(); ++j )
+            for ( TInt j = 0; j < iPlugins->Count(); j++ )
                 {
-                if ( defaultPriority > (*iPlugins)[j]->GetIntAttributeL( ECmDefaultUiPriority ) )
+                TUint32 bearerToCompare = (*iPlugins)[j]->GetBearerInfoIntL(
+                        CMManager::ECmDefaultPriority );
+                if ( defaultPriority > bearerToCompare )
                     {
                     continue;
                     }
-                else if ( defaultPriority == (*iPlugins)[j]->GetIntAttributeL( ECmDefaultUiPriority ) )
+                else if ( defaultPriority == bearerToCompare )
                     {
-                    if ( plugin->GetIntAttributeL( ECmExtensionLevel ) >
-                        (*iPlugins)[j]->GetIntAttributeL( ECmExtensionLevel ) )
+                    if ( plugin->GetBearerInfoIntL( ECmExtensionLevel ) >
+                            (*iPlugins)[j]->GetBearerInfoIntL( ECmExtensionLevel ) )
                         {
                         iPlugins->InsertL( j, plugin );
                         inserted = ETrue;
@@ -333,7 +339,7 @@
                     inserted = ETrue;
                     break;
                     }
-                }*/
+                }
 
             if ( !inserted )
                 {
--- a/cmmanager/cmmgr/cmmserver/src/cmmbearerpriority.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmbearerpriority.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -26,8 +26,8 @@
 //
 CCmmBearerPriority* CCmmBearerPriority::NewL(
         const TDesC& aServiceType,
-        const TUint& aPriority,
-        const TUint& aUiPriority )
+        const TUint aPriority,
+        const TUint aUiPriority )
     {
     CCmmBearerPriority* self = CCmmBearerPriority::NewLC( aServiceType, aPriority, aUiPriority );
     CleanupStack::Pop( self );
@@ -40,8 +40,8 @@
 //
 CCmmBearerPriority* CCmmBearerPriority::NewLC(
         const TDesC& aServiceType,
-        const TUint& aPriority,
-        const TUint& aUiPriority )
+        const TUint aPriority,
+        const TUint aUiPriority )
     {
     CCmmBearerPriority* self = new( ELeave ) CCmmBearerPriority( aPriority, aUiPriority );
     CleanupStack::PushL( self );
@@ -55,8 +55,8 @@
 // ---------------------------------------------------------------------------
 //
 CCmmBearerPriority::CCmmBearerPriority(
-        const TUint& aPriority,
-        const TUint& aUiPriority )
+        const TUint aPriority,
+        const TUint aUiPriority )
         :
         iPriority( aPriority ),
         iUiPriority( aUiPriority )
--- a/cmmanager/cmmgr/cmmserver/src/cmmbearerprioritycache.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmbearerprioritycache.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -201,11 +201,14 @@
     }
 
 // ---------------------------------------------------------------------------
-// Get the priority value for a service type from the bearer priority cache.
+// Get the priority value for a service type name from the bearer priority
+// cache.
 // ---------------------------------------------------------------------------
 //
 TUint CCmmBearerPriorityCache::GetPriority( const TDesC& aServiceType ) const
     {
+    OstTraceFunctionEntry0( CCMMBEARERPRIORITYCACHE_GETPRIORITY_ENTRY );
+
     TUint priority = CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
 
     if ( aServiceType.Length() > 0 )
@@ -220,6 +223,7 @@
             }
         }
 
+    OstTraceFunctionExit0( CCMMBEARERPRIORITYCACHE_GETPRIORITY_EXIT );
     return priority;
     }
 
--- a/cmmanager/cmmgr/cmmserver/src/cmmcache.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmcache.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -154,7 +154,7 @@
 //
 void CCmmCache::OpenDestinationL(
         CCmmDestinationInstance& aDestinationInstance,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_OPENDESTINATIONL_ENTRY );
 
@@ -175,7 +175,7 @@
 
         // Now that cache has a handle on this destination, copy the relevant
         // data to the session instance.
-        destination->CreateSessionInstanceL( aDestinationInstance );
+        destination->CreateDestinationInstanceL( aDestinationInstance );
 
         iDestinationArray.AppendL( destination );
         CleanupStack::Pop( destination );
@@ -184,7 +184,7 @@
         {
         // Cache already has a handle on this destination. Copy the relevant
         // data to the session instance.
-        iDestinationArray[index]->CreateSessionInstanceL( aDestinationInstance );
+        iDestinationArray[index]->CreateDestinationInstanceL( aDestinationInstance );
         }
 
     // Add list of currently contained connection methods.
@@ -236,14 +236,14 @@
 void CCmmCache::CreateDestinationL(
         CCmmDestinationInstance& aDestinationInstance,
         const TDesC& aName,
-        const TUint32& aId )
+        const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CREATEDESTINATIONL_ENTRY );
 
     // Create a new destination with given name.
     CCmmDestinationStruct* destination = CCmmDestinationStruct::NewLC( this, iTrans, aName, aId );
 
-    destination->CreateSessionInstanceL( aDestinationInstance );
+    destination->CreateDestinationInstanceL( aDestinationInstance );
 
     iDestinationArray.AppendL( destination );
     CleanupStack::Pop( destination );
@@ -261,7 +261,7 @@
 void CCmmCache::OpenConnMethodL(
         CCmmConnMethodInstance& aConnMethodInstance,
         CCmmDestinationInstance* aDestinationInstance,
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_OPENCONNMETHODL_ENTRY );
 
@@ -319,7 +319,11 @@
     {
     OstTraceFunctionEntry0( CCMMCACHE_REFRESHCONNMETHODL_ENTRY );
 
-    //TODO, what to do with embedded?
+    // If embedded destination --> refresh through destination API.
+    if ( aConnMethodInstance.IsEmbeddedDestination() )
+        {
+        return;
+        }
 
     TInt index = FindConnMethodFromCache( aConnMethodInstance.GetId() );
     if ( index == KErrNotFound )
@@ -352,8 +356,8 @@
 void CCmmCache::CreateConnMethodL(
         CCmmConnMethodInstance& aConnMethodInstance,
         CCmmDestinationInstance* aDestinationInstance,
-        const TUint32& aBearerType,
-        const TUint32& aConnMethodId )
+        const TUint32 aBearerType,
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CREATECONNMETHODL_ENTRY );
 
@@ -401,11 +405,13 @@
 
 
     // Store the connection method into cache.
-    CCmmConnMethodStruct* connMethodStruct = CCmmConnMethodStruct::NewLC( connMethodId ); // Use connMethodId here, so ID is either a real ID or a temporary ID.
+    // Use connMethodId here, so ID is either a real ID or a temporary ID.
+    CCmmConnMethodStruct* connMethodStruct = CCmmConnMethodStruct::NewL( connMethodId );
     connMethodStruct->SetPlugin( plugin, aBearerType, ECmmConnMethodStatusNotSaved );
+    CleanupStack::Pop( plugin );
+    CleanupStack::PushL( connMethodStruct );
     iConnMethodArray.AppendL( connMethodStruct );
     CleanupStack::Pop( connMethodStruct );
-    CleanupStack::Pop( plugin ); //TODO, pop after SetPlugin()-call?
 
     // Copy the connection method data to session instance.
     aConnMethodInstance.CopyDataL( connMethodStruct ); // Will increase reference counter.
@@ -416,6 +422,7 @@
         // Add connection method to destination.
         aDestinationInstance->AddConnMethodL( aConnMethodInstance );
         }
+
     OstTraceFunctionExit0( CCMMCACHE_CREATECONNMETHODL_EXIT );
     }
 
@@ -445,15 +452,21 @@
         User::Leave( KErrNotFound );
         }
 
-    CCmPluginBaseEng* pluginCopy = plugin->CreateCopyL( aConnMethodInstance.GetPluginDataInstance() );
+    CCmPluginBaseEng* pluginCopy =
+            plugin->CreateCopyL( aConnMethodInstance.GetPluginDataInstance() );
     CleanupStack::PushL( pluginCopy );
 
     // Store the connection method into cache.
-    CCmmConnMethodStruct* connMethodStruct = CCmmConnMethodStruct::NewLC( NextFreeTemporaryId() );
-    connMethodStruct->SetPlugin( pluginCopy, aConnMethodInstance.GetBearerType(), ECmmConnMethodStatusNotSaved );
+    CCmmConnMethodStruct* connMethodStruct =
+            CCmmConnMethodStruct::NewL( NextFreeTemporaryId() );
+    connMethodStruct->SetPlugin(
+            pluginCopy,
+            aConnMethodInstance.GetBearerType(),
+            ECmmConnMethodStatusNotSaved );
+    CleanupStack::Pop( pluginCopy );
+    CleanupStack::PushL( connMethodStruct );
     iConnMethodArray.AppendL( connMethodStruct );
     CleanupStack::Pop( connMethodStruct );
-    CleanupStack::Pop( pluginCopy ); //TODO, pop after SetPlugin()-call?
 
     // Copy the connection method data to session instance.
     aNewConnMethodInstance.CopyDataL( connMethodStruct ); // Will increase reference counter.
@@ -530,7 +543,9 @@
         // referenced from any other destination (in database or in any other
         // client-side destination handles).
         if ( !iInstanceMapping->ValidConnMethodId( id ) ||
-                iInstanceMapping->ConnMethodInOtherDestination( id, aDestinationInstance.GetId() ) ||
+                iInstanceMapping->ConnMethodInOtherDestination(
+                        id,
+                        aDestinationInstance.GetId() ) ||
                 aDestinationInstance.ConnMethodInOtherDestinationInSession( id, 0 ) )
             {
             aDestinationInstance.iConnMethodsToBeDeleted.Remove( i );
@@ -556,7 +571,7 @@
     // Update the connection methods inside this destination.
     for ( TInt i = 0; i < aDestinationInstance.iConnMethodItemArray.Count(); i++ )
         {
-        if ( aDestinationInstance.iConnMethodItemArray[i].iBearerType == KUidEmbeddedDestination )
+        if ( aDestinationInstance.iConnMethodItemArray[i].IsEmbedded() )
             {
             // Embedded destination.
 
@@ -581,7 +596,8 @@
                 //
                 // Skip update since client doesn't have an open handle to this
                 // destination.
-                if ( id >= KTemporaryIdCounterStart || !iInstanceMapping->ValidDestinationId( id ) )
+                if ( id >= KTemporaryIdCounterStart ||
+                        !iInstanceMapping->ValidDestinationId( id ) )
                     {
                     // Remove destination item from array if:
                     // - New destination, but client has already closed the handle for it.
@@ -618,13 +634,15 @@
             if ( aDestinationInstance.ProtectionChanged() )
                 {
                 // Check if the connection method protection level needs to be set.
-                switch ( aDestinationInstance.CurrentProtectionLevel() )
+                switch ( aDestinationInstance.CurrentProtectionLevelL() )
                     {
                     case CMManager::EProtLevel0:
                     case CMManager::EProtLevel2:
                         {
-                        if ( aDestinationInstance.LastProtectionLevel() == CMManager::EProtLevel1 ||
-                                aDestinationInstance.LastProtectionLevel() == CMManager::EProtLevel3 )
+                        if ( aDestinationInstance.LastProtectionLevel() ==
+                                CMManager::EProtLevel1 ||
+                                aDestinationInstance.LastProtectionLevel() ==
+                                CMManager::EProtLevel3 )
                             {
                             connMethodProtectionMustBeSet = ETrue;
                             cmProtected = EFalse;
@@ -766,6 +784,12 @@
     {
     OstTraceFunctionEntry0( CCMMCACHE_UPDATECONNMETHODL_ENTRY );
 
+    // Embedded destinatios cannot be updated as connection methods.
+    if ( aConnMethodInstance.IsEmbeddedDestination() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
     // Find connection method from cache.
     TUint32 connMethodId( aConnMethodInstance.GetId() );
     TInt index = FindConnMethodFromCache( connMethodId );
@@ -819,7 +843,9 @@
 // same is done for the connection methods inside this destination.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DeleteDestinationL( CCmmDestinationInstance& aDestinationInstance, TBool aForced )
+void CCmmCache::DeleteDestinationL(
+        CCmmDestinationInstance& aDestinationInstance,
+        TBool aForced ) //TODO, comment on aForced param?
     {
     OstTraceFunctionEntry0( CCMMCACHE_DELETEDESTINATIONL_ENTRY );
 
@@ -870,7 +896,7 @@
         TInt count( connMethodArray.Count() );
         if ( count )
             {
-            if ( connMethodArray[count - 1].iBearerType == KUidEmbeddedDestination )
+            if ( connMethodArray[count - 1].IsEmbedded() )
                 {
                 connMethodArray.Remove( count - 1 );
                 }
@@ -878,7 +904,9 @@
         // Remove any connection method that belongs to any other destination.
         for ( TInt i = 0; i < connMethodArray.Count(); i++ )
             {
-            if ( iInstanceMapping->ConnMethodInOtherDestination( connMethodArray[i].iId, destinationId ) )
+            if ( iInstanceMapping->ConnMethodInOtherDestination(
+                    connMethodArray[i].iId,
+                    destinationId ) )
                 {
                 connMethodArray.Remove( i );
                 i--;
@@ -969,7 +997,7 @@
 // as deleted (through an already open handle) will restore it.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DeleteConnMethodAsPartOfDestinationDeleteL( const TUint32& aConnMethodId )
+void CCmmCache::DeleteConnMethodAsPartOfDestinationDeleteL( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_ENTRY );
 
@@ -1045,6 +1073,7 @@
                 break;
             case ECmmConnMethodStatusToBeDeleted:
                 // Connection method has already been deleted.
+                OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_EXIT );
                 return;
             case ECmmConnMethodStatusChanged:
             default:
@@ -1061,7 +1090,7 @@
     TCmmIdStruct idStruct( aConnMethodId, 0 );
     iDeletedConnMethods.AppendL( idStruct );
 
-    OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_EXIT );
+    OstTraceFunctionExit0( DUP3_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1075,7 +1104,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmCache::DeleteConnMethodAsPartOfDestinationUpdateL(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_ENTRY );
 
@@ -1154,6 +1183,7 @@
                 break;
             case ECmmConnMethodStatusToBeDeleted:
                 // Connection method has already been deleted.
+                OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_EXIT );
                 return;
             case ECmmConnMethodStatusChanged:
             default:
@@ -1169,7 +1199,7 @@
         iDeletedConnMethods.AppendL( idStruct );
         }
 
-    OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_EXIT );
+    OstTraceFunctionExit0( DUP3_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1247,7 +1277,7 @@
 // aId needs to be in the current valid range (0x1001 - 0x10FF atm).
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationExistsWithId( const TUint32& aId )
+TBool CCmmCache::DestinationExistsWithId( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHID_ENTRY );
 
@@ -1262,7 +1292,7 @@
 // If a destination ID is given, that destination is skipped.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationExistsWithNameL( const TDesC& aName, const TUint32& aDestinationId )
+TBool CCmmCache::DestinationExistsWithNameL( const TDesC& aName, const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHNAMEL_ENTRY );
 
@@ -1319,7 +1349,6 @@
         }
 
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONEXISTSWITHNAMEL_EXIT );
-
     return found;
     }
 
@@ -1331,7 +1360,7 @@
 // with the same ID (The UpdateL() operation would fail for one of them anyway).
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationOpenWithId( const TUint32& aId )
+TBool CCmmCache::DestinationOpenWithId( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONOPENWITHID_ENTRY );
 
@@ -1341,8 +1370,8 @@
         {
         result = ETrue;
         }
+
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONOPENWITHID_EXIT );
-
     return result;
     }
 
@@ -1359,7 +1388,7 @@
 //
 TBool CCmmCache::NotSavedDestinationOpenWithNameL(
         const TDesC& aName,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_NOTSAVEDDESTINATIONOPENWITHNAMEL_ENTRY );
 
@@ -1369,8 +1398,8 @@
         {
         res = ETrue;
         }
+
     OstTraceFunctionExit0( CCMMCACHE_NOTSAVEDDESTINATIONOPENWITHNAMEL_EXIT );
-
     return res;
     }
 
@@ -1378,14 +1407,13 @@
 // Check if the given ID belongs to a valid existing connection method.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::ConnMethodExistsWithId( const TUint32& aConnMethodId )
+TBool CCmmCache::ConnMethodExistsWithId( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODEXISTSWITHID_ENTRY );
 
     TBool exists = iInstanceMapping->ValidConnMethodId( aConnMethodId );
 
     OstTraceFunctionExit0( CCMMCACHE_CONNMETHODEXISTSWITHID_EXIT );
-
     return exists;
     }
 
@@ -1398,7 +1426,7 @@
 // anyway).
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::ConnMethodOpenWithId( const TUint32& aConnMethodId )
+TBool CCmmCache::ConnMethodOpenWithId( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODOPENWITHID_ENTRY );
 
@@ -1408,8 +1436,8 @@
         {
         result = ETrue;
         }
+
     OstTraceFunctionExit0( CCMMCACHE_CONNMETHODOPENWITHID_EXIT );
-
     return result;
     }
 
@@ -1422,7 +1450,7 @@
 //
 TBool CCmmCache::DestinationExistsWithMetadataLocalizedL(
         CCmmDestinationInstance& aDestinationInstance,
-        const TUint32& aValue )
+        const TUint32 aValue )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATALOCALIZEDL_ENTRY );
 
@@ -1493,8 +1521,8 @@
             }
         CleanupStack::PopAndDestroy( metaSet );
         }
+
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATALOCALIZEDL_EXIT );
-
     return result;
     }
 
@@ -1507,7 +1535,7 @@
 //
 TBool CCmmCache::DestinationExistsWithMetadataPurposeL(
         CCmmDestinationInstance& aDestinationInstance,
-        const TUint32& aValue )
+        const TUint32 aValue )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATAPURPOSEL_ENTRY );
 
@@ -1578,8 +1606,8 @@
             }
         CleanupStack::PopAndDestroy( metaSet );
         }
+
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATAPURPOSEL_EXIT );
-
     return result;
     }
 
@@ -1590,7 +1618,7 @@
 // needed.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DbChangeDetected( const TUint32& aTableId )
+void CCmmCache::DbChangeDetected( const TUint32 aTableId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEDETECTED_ENTRY );
 
@@ -1605,7 +1633,7 @@
 // it has up-to-date information.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DbChangeError( const TUint32& aTableId )
+void CCmmCache::DbChangeError( const TUint32 aTableId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEERROR_ENTRY );
 
@@ -1629,7 +1657,7 @@
 
     if ( index >= 0 )
         {
-        TInt remainingSessionInstances = iDestinationArray[index]->SessionInstanceClosed();
+        TInt remainingSessionInstances = iDestinationArray[index]->DestinationInstanceClosed();
         if ( remainingSessionInstances <= 0)
             {
             // If status is 'to be deleted', then the last handle keeping this
@@ -1670,7 +1698,7 @@
 
     if ( index >= 0 )
         {
-        TInt remainingSessionInstances = iConnMethodArray[index]->SessionInstanceClosed();
+        TInt remainingSessionInstances = iConnMethodArray[index]->ConnMethodInstanceClosed();
         if ( remainingSessionInstances <= 0 )
             {
             // If status is 'to be deleted', then the last handle keeping this
@@ -1705,14 +1733,13 @@
 //
 CommsDat::CMDBSession& CCmmCache::Session() const
     {
-    OstTraceFunctionEntry0( CCMMCACHE_SESSION_ENTRY );
-
+    // No traces.
     return iTrans->Session();
     }
 
 //-----------------------------------------------------------------------------
 // Finds out the bearer type and priority of the service type from given IAP
-// record.
+// record. performs LoadL()-call on the provided IAP record.
 //-----------------------------------------------------------------------------
 //
 void CCmmCache::BearerInfoFromIapRecordL(
@@ -1722,8 +1749,8 @@
     {
     OstTraceFunctionEntry0( CCMMCACHE_BEARERINFOFROMIAPRECORDL_ENTRY );
 
-    // Load the IAP record from IAP table. This is an optimization that plugins
-    // doesn't have to do it every time the CanHandleIapIdL() is called.
+    // Load the IAP record from IAP table. This is an optimization so that
+    // plugins don't have to do it every time the CanHandleIapIdL() is called.
     aIapRecord->LoadL( Session() );
     BearerPriorityFromIapRecordL( aIapRecord, aBearerPriority );
     BearerTypeFromIapRecordL( aIapRecord, aBearerType );
@@ -1769,7 +1796,7 @@
     // Check which bearer handles the given IAP ID.
     for ( TInt i = 0; i < iPlugins->Count(); i++ )
         {
-        TRAP( err, canHandle = (*iPlugins)[i]->CanHandleIapIdL( aIapRecord ) ); //TODO, check leave, trap needed?
+        TRAP( err, canHandle = (*iPlugins)[i]->CanHandleIapIdL( aIapRecord ) );
         if ( !err && canHandle )
             {
             TUint32 thisExtLevel = (*iPlugins)[i]->GetBearerInfoIntL( ECmExtensionLevel );
@@ -1790,6 +1817,23 @@
     OstTraceFunctionExit0( CCMMCACHE_BEARERTYPEFROMIAPRECORDL_EXIT );
     }
 
+// ---------------------------------------------------------------------------
+// Find and return a copy of a connection method item matching the given ID.
+// Returns KErrNotFound, if the connection method is not found.
+// ---------------------------------------------------------------------------
+//
+TInt CCmmCache::GetConnMethodItem(
+        const TUint32 aConnMethodId,
+        TCmmConnMethodItem& aConnMethodItem ) const
+    {
+    OstTraceFunctionEntry0( CCMMCACHE_GETCONNMETHODITEM_ENTRY );
+
+    TInt result = iInstanceMapping->GetConnMethodItem( aConnMethodId, aConnMethodItem );
+
+    OstTraceFunctionExit0( CCMMCACHE_GETCONNMETHODITEM_EXIT );
+    return result;
+    }
+
 //-----------------------------------------------------------------------------
 // Returns all conenction method IDs. Unsupported connection methods are
 // included if aCheckBearerType is set to EFalse.
@@ -1810,7 +1854,7 @@
 // Returns the number of destinations the provided connection method belongs to.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::DestinationsContainingConnMethod( const TUint32& aConnMethodId ) const
+TInt CCmmCache::DestinationsContainingConnMethod( const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODREFERENCECOUNT_ENTRY );
 
@@ -1893,7 +1937,7 @@
 //-----------------------------------------------------------------------------
 //
 void CCmmCache::GetConnMethodsFromDestinationL(
-        const TUint32& aDestinationId,
+        const TUint32 aDestinationId,
         RArray<TCmmConnMethodItem>& aConnMethodArray ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNMETHODSFROMDESTINATIONL_ENTRY );
@@ -1936,8 +1980,8 @@
 //-----------------------------------------------------------------------------
 //
 TBool CCmmCache::ConnMethodInOtherDestination(
-        const TUint32& aConnMethodId,
-        const TUint32& aDestinationId )
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODINOTHERDESTINATION_ENTRY );
 
@@ -1975,7 +2019,7 @@
 // Returns either a valid array index or KErrNotFound.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::FindDestinationFromCache( const TUint32& aId )
+TInt CCmmCache::FindDestinationFromCache( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_FINDDESTINATIONFROMCACHE_ENTRY );
 
@@ -2004,7 +2048,9 @@
 // Returns either a valid array index or KErrNotFound.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::FindNotSavedDestinationFromCacheL( const TDesC& aName, const TUint32& aDestinationId )
+TInt CCmmCache::FindNotSavedDestinationFromCacheL(
+        const TDesC& aName,
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_FINDNOTSAVEDDESTINATIONFROMCACHEL_ENTRY );
 
@@ -2047,7 +2093,7 @@
 // Returns either a valid array index or KErrNotFound.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::FindConnMethodFromCache( const TUint32& aConnMethodId )
+TInt CCmmCache::FindConnMethodFromCache( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_FINDCONNMETHODFROMCACHE_ENTRY );
 
@@ -2076,7 +2122,7 @@
 //
 void CCmmCache::OpenConnectionMethodInstanceL(
         CCmmConnMethodInstance& aConnMethodInstance,
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_OPENCONNECTIONMETHODINSTANCEL_ENTRY );
 
@@ -2103,11 +2149,12 @@
         }
 
     // Store the connection method into cache.
-    CCmmConnMethodStruct* connMethodStruct = CCmmConnMethodStruct::NewLC( aConnMethodId );
+    CCmmConnMethodStruct* connMethodStruct = CCmmConnMethodStruct::NewL( aConnMethodId );
     connMethodStruct->SetPlugin( plugin, bearerType, ECmmConnMethodStatusValid );
+    CleanupStack::Pop( plugin );
+    CleanupStack::PushL( connMethodStruct );
     iConnMethodArray.AppendL( connMethodStruct );
     CleanupStack::Pop( connMethodStruct );
-    CleanupStack::Pop( plugin ); //TODO, pop after SetPlugin()-call?
 
     // Copy the connection method data to session instance.
     aConnMethodInstance.CopyDataL( connMethodStruct ); // Will increase reference counter.
@@ -2120,8 +2167,8 @@
 //-----------------------------------------------------------------------------
 //
 TUint32 CCmmCache::GetConnectionMethodInfoIntL(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOINTL_ENTRY );
 
@@ -2154,8 +2201,8 @@
 //-----------------------------------------------------------------------------
 //
 TBool CCmmCache::GetConnectionMethodInfoBoolL(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOBOOLL_ENTRY );
 
@@ -2188,8 +2235,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC* CCmmCache::GetConnectionMethodInfoStringL(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRINGL_ENTRY );
 
@@ -2222,8 +2269,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC8* CCmmCache::GetConnectionMethodInfoString8L(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRING8L_ENTRY );
 
@@ -2257,8 +2304,8 @@
 //-----------------------------------------------------------------------------
 //
 TUint32 CCmmCache::GetBearerInfoIntL(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOINTL_ENTRY );
 
@@ -2288,8 +2335,8 @@
 //-----------------------------------------------------------------------------
 //
 TBool CCmmCache::GetBearerInfoBoolL(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOBOOLL_ENTRY );
 
@@ -2319,8 +2366,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC* CCmmCache::GetBearerInfoStringL(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOSTRINGL_ENTRY );
 
@@ -2350,8 +2397,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC8* CCmmCache::GetBearerInfoString8L(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOSTRING8L_ENTRY );
 
@@ -2411,24 +2458,16 @@
         {
         iTrans->OpenTransactionLC();
 
-        TUint defConnType( 0 );
-        TUint internetSnapId( 0 );
-        iInstanceMapping->InternetDestinationIdL( internetSnapId );
-        if ( internetSnapId )
-            {
-            defConnType = ECmDefConnDestination;
-            }
-
         aGenConnSettings.iUsageOfWlan = ECmUsageOfWlanKnown;
         aGenConnSettings.iCellularDataUsageHome = ECmCellularDataUsageAutomatic;
         aGenConnSettings.iCellularDataUsageVisitor = ECmCellularDataUsageConfirm;
 
         defConnRecord->SetRecordId( KCDNewRecordRequest );
-        defConnRecord->iDefConnType = defConnType;
-        defConnRecord->iDefConnUid = internetSnapId;
         defConnRecord->iUsageOfWlan = ( TUint )aGenConnSettings.iUsageOfWlan;
-        defConnRecord->iCellularDataUsageHome = ( TUint )aGenConnSettings.iCellularDataUsageHome;
-        defConnRecord->iCellularDataUsageVisitor = ( TUint )aGenConnSettings.iCellularDataUsageVisitor;
+        defConnRecord->iCellularDataUsageHome =
+                ( TUint )aGenConnSettings.iCellularDataUsageHome;
+        defConnRecord->iCellularDataUsageVisitor =
+                ( TUint )aGenConnSettings.iCellularDataUsageVisitor;
         defConnRecord->StoreL( Session() );
 
         iTrans->CommitTransactionL();
@@ -2527,7 +2566,7 @@
 // connected.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::CheckIfCmConnected( const TUint32& aCmId ) const
+TBool CCmmCache::CheckIfCmConnected( const TUint32 aCmId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_CHECKIFCMCONNECTED_ENTRY );
 
@@ -2607,7 +2646,9 @@
                     }
                 else
                     {
-                    iInstanceMapping->GetConnMethodsFromDestinationL( aDestinationId, connMethodArray );
+                    iInstanceMapping->GetConnMethodsFromDestinationL(
+                            aDestinationId,
+                            connMethodArray );
                     }
 
                 // Iterate through all connections.
@@ -2647,7 +2688,7 @@
 // any other destination.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationIsEmbedded( const TUint32& aDestinationId ) const
+TBool CCmmCache::DestinationIsEmbedded( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONISEMBEDDED_ENTRY );
 
@@ -2661,7 +2702,7 @@
 // Check from database if the given destination has an embedded destination.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationHasEmbedded( const TUint32& aDestinationId ) const
+TBool CCmmCache::DestinationHasEmbedded( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONHASEMBEDDED_ENTRY );
 
@@ -2676,7 +2717,7 @@
 // IAP.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationPointedToByVirtualIap( const TUint32& aDestinationId ) const
+TBool CCmmCache::DestinationPointedToByVirtualIap( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONPOINTEDTOBYVIRTUALIAP_ENTRY );
 
@@ -2692,13 +2733,15 @@
 // virtual IAP.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::ConnMethodPointedToByVirtualIap( const TUint32& aConnMethodId ) const
+TBool CCmmCache::ConnMethodPointedToByVirtualIap( const TUint32 aConnMethodId ) const
     {
-
-    TBool pointedByVirtual =
+    OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODPOINTEDTOBYVIRTUALIAP_ENTRY );
+
+    TBool pointedToByVirtual =
             iInstanceMapping->ConnMethodPointedToByVirtualIap( aConnMethodId );
 
-    return pointedByVirtual;
+    OstTraceFunctionExit0( CCMMCACHE_CONNMETHODPOINTEDTOBYVIRTUALIAP_EXIT );
+    return pointedToByVirtual;
     }
 
 // ---------------------------------------------------------------------------
@@ -2707,7 +2750,8 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmCache::ConnMethodInDestinationButLocked(
-        const TUint32& aConnMethodId, const TUint32& aDestinationId ) const
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY );
 
@@ -2845,7 +2889,7 @@
 // This method is used to find out those real IDs before that.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::TranslateTemporaryId( const TUint32& aTemporaryId, TUint32& aRealId ) const
+void CCmmCache::TranslateTemporaryId( const TUint32 aTemporaryId, TUint32& aRealId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_TRANSLATETEMPORARYID_ENTRY );
 
@@ -2875,6 +2919,8 @@
 void CCmmCache::CheckIfConnMethodReferencesCanBeRemovedL(
         const CCmmConnMethodInstance& aConnMethodInstance )
     {
+    OstTraceFunctionEntry0( CCMMCACHE_CHECKIFCONNMETHODREFERENCESCANBEREMOVEDL_ENTRY );
+
     TUint32 connMethodId( aConnMethodInstance.GetId() );
 
     // Check that connection method exists in database.
@@ -2889,8 +2935,6 @@
         User::Leave( KErrArgument );
         }
 
-    //TODO, what if protected?
-
     // Iterate all destinations in database and check if possible reference can
     // be removed.
     RArray<TUint32> dbDestinations;
@@ -2898,7 +2942,9 @@
     iInstanceMapping->GetDestinationsL( dbDestinations );
     for ( TInt i = 0; i < dbDestinations.Count(); i++ )
         {
-        if ( iInstanceMapping->ConnMethodInDestinationButLocked( connMethodId, dbDestinations[i] ) )
+        if ( iInstanceMapping->ConnMethodInDestinationButLocked(
+                connMethodId,
+                dbDestinations[i] ) )
             {
             User::Leave( KErrLocked );
             }
@@ -2910,6 +2956,49 @@
         {
         User::Leave( KErrInUse );
         }
+
+    OstTraceFunctionExit0( CCMMCACHE_CHECKIFCONNMETHODREFERENCESCANBEREMOVEDL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// Check if given connection method is referenced from any protected destination.
+// ---------------------------------------------------------------------------
+//
+void CCmmCache::CheckIfConnMethodBelongsToProtectedDestinationL(
+        const CCmmConnMethodInstance& aConnMethodInstance,
+        TBool& aBelongsToProtectedDestination )
+    {
+    OstTraceFunctionEntry0( CCMMCACHE_CHECKIFCONNMETHODBELONGSTOPROTECTEDDESTINATIONL_ENTRY );
+
+    TUint32 connMethodId( aConnMethodInstance.GetId() );
+
+    // Check that connection method exists in database.
+    if ( !iInstanceMapping->ValidConnMethodId( connMethodId ) )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    aBelongsToProtectedDestination = EFalse;
+    // Get destinations which have references to connection method passed as parameter.
+    RArray<TUint32> dbDestinations;
+    CleanupClosePushL( dbDestinations );
+    iInstanceMapping->DestinationsContainingConnMethodL( connMethodId, dbDestinations );
+    TUint32 metadata( 0 );
+    for ( TInt i = 0; i < dbDestinations.Count(); i++ )
+        {
+        // Check if any of destinations is protected.
+        metadata = iInstanceMapping->DestinationMetadata( dbDestinations[i] );
+        TUint32 protlevel =
+                ( metadata & KDestProtectionLevelMask ) >> KBitsToShiftDestProtectionLevel;
+        if ( protlevel == CMManager::EProtLevel1 || protlevel == CMManager::EProtLevel3 )
+            {
+            aBelongsToProtectedDestination = ETrue;
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy( &dbDestinations );
+
+    OstTraceFunctionExit0( CCMMCACHE_CHECKIFCONNMETHODBELONGSTOPROTECTEDDESTINATIONL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -2919,6 +3008,8 @@
 void CCmmCache::CheckIfConnMethodCanBeDeletedL(
         const CCmmConnMethodInstance& aConnMethodInstance )
     {
+    OstTraceFunctionEntry0( CCMMCACHE_CHECKIFCONNMETHODCANBEDELETEDL_ENTRY );
+
     TUint32 connMethodId( aConnMethodInstance.GetId() );
 
     // Find connection method from cache.
@@ -2961,6 +3052,8 @@
         {
         User::Leave( KErrLocked );
         }
+
+    OstTraceFunctionExit0( CCMMCACHE_CHECKIFCONNMETHODCANBEDELETEDL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -2970,6 +3063,8 @@
 void CCmmCache::CheckIfDestinationCanBeDeletedL(
         const CCmmDestinationInstance& aDestinationInstance )
     {
+    OstTraceFunctionEntry0( CCMMCACHE_CHECKIFDESTINATIONCANBEDELETEDL_ENTRY );
+
     TUint32 destinationId( aDestinationInstance.GetId() );
 
     // Find destination from cache.
@@ -3019,6 +3114,8 @@
         {
         User::Leave( KErrInUse );
         }
+
+    OstTraceFunctionExit0( CCMMCACHE_CHECKIFDESTINATIONCANBEDELETEDL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -3035,13 +3132,16 @@
 // methods inside it are connected.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DeleteDestinationForcedL( CCmmDestinationInstance& aDestinationInstance ) //TODO, OST
+void CCmmCache::DeleteDestinationForcedL( CCmmDestinationInstance& aDestinationInstance )
     {
-    //TODO
+    OstTraceFunctionEntry0( CCMMCACHE_DELETEDESTINATIONFORCEDL_ENTRY );
+
     if ( !DestinationConnectedL( 0, &aDestinationInstance ) )
         {
         DeleteDestinationL( aDestinationInstance, ETrue );
         }
+
+    OstTraceFunctionExit0( CCMMCACHE_DELETEDESTINATIONFORCEDL_EXIT );
     }
 
 // End of file
--- a/cmmanager/cmmgr/cmmserver/src/cmmconnmethodinstance.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmconnmethodinstance.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -36,7 +36,9 @@
 // Two phased construction.
 // ---------------------------------------------------------------------------
 //
-CCmmConnMethodInstance* CCmmConnMethodInstance::NewL( CCmmSession* aCmmSession, CCmmCache* aCache )
+CCmmConnMethodInstance* CCmmConnMethodInstance::NewL(
+        CCmmSession* aCmmSession,
+        CCmmCache* aCache )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_NEWL_ENTRY );
 
@@ -51,7 +53,9 @@
 // Two phased construction.
 // ---------------------------------------------------------------------------
 //
-CCmmConnMethodInstance* CCmmConnMethodInstance::NewLC( CCmmSession* aCmmSession, CCmmCache* aCache )
+CCmmConnMethodInstance* CCmmConnMethodInstance::NewLC(
+        CCmmSession* aCmmSession,
+        CCmmCache* aCache )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_NEWLC_ENTRY );
 
@@ -86,7 +90,9 @@
 // Constructor.
 // ---------------------------------------------------------------------------
 //
-CCmmConnMethodInstance::CCmmConnMethodInstance( CCmmSession* aCmmSession, CCmmCache* aCache )
+CCmmConnMethodInstance::CCmmConnMethodInstance(
+        CCmmSession* aCmmSession,
+        CCmmCache* aCache )
         :
         iCmmSession( aCmmSession ),
         iCache( aCache )
@@ -117,37 +123,11 @@
     }
 
 // ---------------------------------------------------------------------------
-// Set the plugin base pointer.
-// ---------------------------------------------------------------------------
-//
-void CCmmConnMethodInstance::SetPlugin( CCmPluginBaseEng* aPlugin )
-    {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETPLUGIN_ENTRY );
-
-    iPlugin = aPlugin;
-
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_SETPLUGIN_EXIT );
-    }
-
-// ---------------------------------------------------------------------------
-// Get the plugin base pointer.
-// ---------------------------------------------------------------------------
-//
-CCmPluginBaseEng* CCmmConnMethodInstance::GetPlugin() const
-    {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETPLUGIN_ENTRY );
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETPLUGIN_EXIT );
-    return iPlugin;
-    }
-
-// ---------------------------------------------------------------------------
 // Get pointer to the plugin data container.
 // ---------------------------------------------------------------------------
 //
 CCmClientPluginInstance* CCmmConnMethodInstance::GetPluginDataInstance() const
     {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETPLUGINDATAINSTANCE_ENTRY );
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETPLUGINDATAINSTANCE_EXIT );
     return iPluginDataInstance;
     }
 
@@ -157,9 +137,6 @@
 //
 TUint32 CCmmConnMethodInstance::GetId() const
     {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETID_ENTRY );
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETID_EXIT );
-
     return iConnMethodId;
     }
 
@@ -167,7 +144,7 @@
 // Set connection method ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmConnMethodInstance::SetId( const TUint32& aConnMethodId )
+void CCmmConnMethodInstance::SetId( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETID_ENTRY );
 
@@ -182,26 +159,10 @@
 //
 TUint32 CCmmConnMethodInstance::GetBearerType() const
     {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETBEARERTYPE_ENTRY );
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETBEARERTYPE_EXIT );
-
     return iBearerType;
     }
 
 // ---------------------------------------------------------------------------
-// Get bearer type.
-// ---------------------------------------------------------------------------
-//
-void CCmmConnMethodInstance::SetBearerType( const TUint32& aBearerType )
-    {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETBEARERTYPE_ENTRY );
-
-    iBearerType = aBearerType;
-
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_SETBEARERTYPE_EXIT );
-    }
-
-// ---------------------------------------------------------------------------
 // Get handle ID.
 // ---------------------------------------------------------------------------
 //
@@ -214,7 +175,7 @@
 // Set handle ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmConnMethodInstance::SetHandle( const TInt& aHandle )
+void CCmmConnMethodInstance::SetHandle( const TInt aHandle )
     {
     iHandle = aHandle;
     }
@@ -281,7 +242,12 @@
         User::Leave( KErrCorrupt );
         }
 
-    iPlugin->GetPluginDataL( iPluginDataInstance ); //TODO, check deletes for iPluginDataInstance
+    // Embedded destination does not have any data.
+    if ( !IsEmbeddedDestination() )
+        {
+        iPlugin->GetPluginDataL( iPluginDataInstance );
+        }
+
     aConnMethodStruct->IncrementReferenceCounter();
 
     switch ( aConnMethodStruct->GetStatus() )
@@ -307,98 +273,126 @@
     }
 
 // ---------------------------------------------------------------------------
-// Refresh the relevant connection method data in cache side object to be in
-// synch with database and copy that data back to this session side connection
-// method object.
+// CCmmConnMethodInstance::GetIntAttributeL
 // ---------------------------------------------------------------------------
 //
-//TODO, cleanup
-/*
-void CCmmConnMethodInstance::RefreshDataL( CCmmConnMethodStruct* aConnMethodStruct ) //TODO, remove
+TUint32 CCmmConnMethodInstance::GetIntAttributeL( const TUint32 aAttribute )
     {
+    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETINTATTRIBUTEL_ENTRY );
 
-    //TODO
-    //if ( !aConnMethodStruct )
-        //{
-        //User::Leave( KErrCorrupt );
-        //}
     if ( !iPlugin )
         {
         User::Leave( KErrCorrupt );
         }
 
-    switch ( aConnMethodStruct->GetStatus() )
+    // Embedded destination has only limited set of attributes.
+    if ( IsEmbeddedDestination() )
         {
-        case ECmmConnMethodStatusValid:
-        case ECmmConnMethodStatusToBeDeleted:
+        switch ( aAttribute )
             {
-            //TODO, add record status check later and only call Reload() if necessary. TCmmRecordStatus
-            //if ( !aConnMethodStruct->UpToDate() )
-            //    {
-                iPlugin->ReLoadL();
-            //    }
-            iPlugin->GetPluginDataL( iPluginDataInstance );
+            case CMManager::ECmId:
+            case CMManager::ECmBearerType:
+            case CMManager::ECmDefaultPriority:
+            case CMManager::ECmDefaultUiPriority:
+            case ECmExtensionLevel:
+                {
+                break;
+                }
+            default:
+                {
+                User::Leave( KErrNotSupported );
+                }
             }
-            break;
-        case ECmmConnMethodStatusNotSaved: // This is checked before.
-        case ECmmConnMethodStatusChanged:
-        default:
-            User::Leave( KErrCorrupt );  // Error, invalid status.
-            break;
         }
 
-    // Internal state need to be set to the same state as after a successfull update.
-    UpdateSuccessful();
-
-    }*/
+    TUint32 result = iPlugin->GetIntAttributeL( aAttribute, iPluginDataInstance );
 
-// ---------------------------------------------------------------------------
-// CCmmConnMethodInstance::GetIntAttributeL
-// ---------------------------------------------------------------------------
-//
-TUint32 CCmmConnMethodInstance::GetIntAttributeL( const TUint32& aAttribute )
-    {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETINTATTRIBUTEL_ENTRY );
-
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
-
-    return iPlugin->GetIntAttributeL( aAttribute, iPluginDataInstance );
+    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETINTATTRIBUTEL_EXIT );
+    return result;
     }
 
 // ---------------------------------------------------------------------------
 // CCmmConnMethodInstance::GetBoolAttributeL
 // ---------------------------------------------------------------------------
 //
-TBool CCmmConnMethodInstance::GetBoolAttributeL( const TUint32& aAttribute )
+TBool CCmmConnMethodInstance::GetBoolAttributeL( const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETBOOLATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    // Embedded destination has only limited set of attributes.
+    if ( IsEmbeddedDestination() )
+        {
+        switch ( aAttribute )
+            {
+            case CMManager::ECmCoverage:
+            case CMManager::ECmDestination:
+            case CMManager::ECmProtected:
+            case CMManager::ECmHidden:
+            case CMManager::ECmBearerHasUi:
+            case CMManager::ECmVirtual:
+                {
+                break;
+                }
+            default:
+                {
+                User::Leave( KErrNotSupported );
+                }
+            }
+        }
 
     TBool retVal( EFalse );
-
     switch ( aAttribute )
         {
         case CMManager::ECmConnected:
             {
             if ( GetId() > 0 )
                 {
-                if ( iCache )
+                // Check first if this is embedded destination.
+                retVal = iPlugin->GetBoolAttributeL( CMManager::ECmDestination,
+                        iPluginDataInstance );
+                if ( retVal )
                     {
-                    retVal = iCache->CheckIfCmConnected( GetId() );
+                    retVal = iCache->DestinationConnectedL( GetId() );
+                    }
+                else
+                    {
+                    if ( iCache )
+                        {
+                        retVal = iCache->CheckIfCmConnected( GetId() );
+                        }
                     }
                 }
             }
             break;
         case CMManager::ECmIsLinked:
             {
-            //TODO
+            // Does any virtual iap point to this connection method.
+            // Check first if this connection method is an embedded destination.
+            if ( GetId() > 0 )
+                {
+                retVal = iPlugin->GetBoolAttributeL( CMManager::ECmDestination,
+                        iPluginDataInstance );
+                if ( retVal )
+                    {
+                    retVal = iCache->DestinationPointedToByVirtualIap( GetId() );
+                    }
+                else
+                    {
+                    retVal = iCache->ConnMethodPointedToByVirtualIap( GetId() );
+                    }
+                }
             }
             break;
         default:
             {
             retVal = iPlugin->GetBoolAttributeL( aAttribute, iPluginDataInstance );
             }
+            break;
         }
 
     OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETBOOLATTRIBUTEL_EXIT );
@@ -409,26 +403,50 @@
 // CCmmConnMethodInstance::GetStringAttributeL
 // ---------------------------------------------------------------------------
 //
-HBufC* CCmmConnMethodInstance::GetStringAttributeL( const TUint32& aAttribute )
+HBufC* CCmmConnMethodInstance::GetStringAttributeL( const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETSTRINGATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
 
-    return iPlugin->GetStringAttributeL( aAttribute, iPluginDataInstance );
+    // Embedded destination has only limited set of attributes.
+    if ( IsEmbeddedDestination() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    HBufC* result = iPlugin->GetStringAttributeL( aAttribute, iPluginDataInstance );
+
+    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETSTRINGATTRIBUTEL_EXIT );
+    return result;
     }
 
 // ---------------------------------------------------------------------------
 // CCmmConnMethodInstance::GetString8AttributeL
 // ---------------------------------------------------------------------------
 //
-HBufC8* CCmmConnMethodInstance::GetString8AttributeL( const TUint32& aAttribute )
+HBufC8* CCmmConnMethodInstance::GetString8AttributeL( const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETSTRING8ATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
 
-    return iPlugin->GetString8AttributeL( aAttribute, iPluginDataInstance );
+    // Embedded destination has only limited set of attributes.
+    if ( IsEmbeddedDestination() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    HBufC8* result = iPlugin->GetString8AttributeL( aAttribute, iPluginDataInstance );
+
+    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETSTRING8ATTRIBUTEL_EXIT );
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -436,12 +454,15 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodInstance::SetIntAttributeL(
-        const TUint32& aAttribute,
-        const TUint32& aValue )
+        const TUint32 aAttribute,
+        const TUint32 aValue )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETINTATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
 
     iPlugin->SetIntAttributeL( aAttribute, aValue, iPluginDataInstance );
 
@@ -453,12 +474,15 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodInstance::SetBoolAttributeL(
-        const TUint32& aAttribute,
-        const TBool& aValue )
+        const TUint32 aAttribute,
+        const TBool aValue )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETBOOLATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
 
     iPlugin->SetBoolAttributeL( aAttribute, aValue, iPluginDataInstance );
 
@@ -470,12 +494,15 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodInstance::SetStringAttributeL(
-        const TUint32& aAttribute,
+        const TUint32 aAttribute,
         const TDesC16& aValue )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETSTRINGATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
 
     iPlugin->SetStringAttributeL( aAttribute, aValue, iPluginDataInstance );
 
@@ -487,12 +514,15 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodInstance::SetString8AttributeL(
-        const TUint32& aAttribute,
+        const TUint32 aAttribute,
         const TDesC8& aValue )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_SETSTRING8ATTRIBUTEL_ENTRY );
 
-    __ASSERT_DEBUG( iPlugin != NULL, User::Leave( KErrNotFound ) );
+    if ( !iPlugin )
+        {
+        User::Leave( KErrCorrupt );
+        }
 
     iPlugin->SetString8AttributeL( aAttribute, aValue, iPluginDataInstance );
 
@@ -500,17 +530,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// Gets the current status of this connection method instance.
-// ---------------------------------------------------------------------------
-//
-TCmmConnMethodStatus CCmmConnMethodInstance::GetStatus() const
-    {
-    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_GETSTATUS_ENTRY );
-    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_GETSTATUS_EXIT );
-    return iStatus;
-    }
-
-// ---------------------------------------------------------------------------
 // Sets a new status value.
 // ---------------------------------------------------------------------------
 //
@@ -531,7 +550,11 @@
 //
 void CCmmConnMethodInstance::UpdateSuccessful()
     {
+    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_UPDATESUCCESSFUL_ENTRY );
+
     SetStatus( ECmmConnMethodStatusValid );
+
+    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_UPDATESUCCESSFUL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -540,10 +563,14 @@
 // connection method structure to reflect the new deleted state.
 // ---------------------------------------------------------------------------
 //
-void CCmmConnMethodInstance::DeleteSuccessful( const TUint32& aNewSecondaryId )
+void CCmmConnMethodInstance::DeleteSuccessful( const TUint32 aNewSecondaryId )
     {
+    OstTraceFunctionEntry0( CCMMCONNMETHODINSTANCE_DELETESUCCESSFUL_ENTRY );
+
     SetStatus( ECmmConnMethodStatusChanged );
     SetId( aNewSecondaryId );
+
+    OstTraceFunctionExit0( CCMMCONNMETHODINSTANCE_DELETESUCCESSFUL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -571,7 +598,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodInstance::RemoveConnMethodFromSessionDestinationHandles(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     if ( iCmmSession )
         {
--- a/cmmanager/cmmgr/cmmserver/src/cmmconnmethoditem.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmconnmethoditem.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -19,6 +19,9 @@
 */
 
 
+#include <cmmanagerdef.h>
+#include <cmpluginembdestinationdef.h>
+
 #include "cmmconnmethoditem.h"
 
 
@@ -27,11 +30,15 @@
 // ---------------------------------------------------------------------------
 //
 TCmmConnMethodItem::TCmmConnMethodItem()
+        :
+        iId( 0 ),
+        iBearerType( 0 ),
+        iBearerPriority( 0 ),
+        iPriority( 0 ),
+        iIsVirtual( 0 ),
+        iLinkedIapId( 0 ),
+        iLinkedSnapId( 0 )           
     {
-    iId = 0;
-    iBearerType = 0;
-    iBearerPriority = 0;
-    iPriority = 0;
     }
 
 // ---------------------------------------------------------------------------
@@ -42,12 +49,18 @@
         TUint32 aId,
         TUint32 aBearerType,
         TUint aBearerPriority,
-        TUint aPriority )
+        TUint aPriority,
+        TBool aIsVirtual,
+        TUint32 aLinkedIapId,
+        TUint32 aLinkedSnapId )
         :
         iId( aId ),
         iBearerType( aBearerType ),
         iBearerPriority( aBearerPriority ),
-        iPriority( aPriority )
+        iPriority( aPriority ),
+        iIsVirtual( aIsVirtual ),
+        iLinkedIapId( aLinkedIapId ),
+        iLinkedSnapId( aLinkedSnapId )
     {
     }
 
@@ -60,7 +73,27 @@
         const TCmmConnMethodItem& aSecond )
     {
     // Zero if match, negative if first is smaller, positive otherwise.
-    return ( TInt )aFirst.iPriority - ( TInt )aSecond.iPriority;
+    TInt result = ( TInt )aFirst.iPriority - ( TInt )aSecond.iPriority;
+
+    if ( result == 0 &&
+            aFirst.iPriority == CMManager::KDataMobilitySelectionPolicyPriorityWildCard )
+        {
+        // Embedded destination and virtual IAPs linking to SNAP have wildcard
+        // priority.
+        // If both connection methods have wildcard priority, only need to
+        // ensure that an embedded destination looses in priority to everything
+        // else.
+        if ( aFirst.iBearerType == KUidEmbeddedDestination )
+            {
+            result = 1; // Positive.
+            }
+        else if ( aSecond.iBearerType == KUidEmbeddedDestination )
+            {
+            result = -1; // Negative.
+            }
+        }
+    
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -81,4 +114,50 @@
     return result;
     }
 
+// ---------------------------------------------------------------------------
+// Return ETrue if this connection method item represents a virtual
+// destination.
+// ---------------------------------------------------------------------------
+//
+TBool TCmmConnMethodItem::IsVirtual() const
+    {
+    return iIsVirtual;
+    }
+
+// ---------------------------------------------------------------------------
+// Return ETrue if this connection method item represents an embedded
+// destination.
+// ---------------------------------------------------------------------------
+//
+TBool TCmmConnMethodItem::IsEmbedded() const
+    {
+    // No traces.
+    TBool result( EFalse );
+    if ( iBearerType == KUidEmbeddedDestination )
+        {
+        result = ETrue;
+        }
+    return result;
+    }
+
+// ---------------------------------------------------------------------------
+// If this is a virtual IAP that points to an IAP, returns the ID of that IAP,
+// 0 otherwise.
+// ---------------------------------------------------------------------------
+//
+TUint32 TCmmConnMethodItem::LinkedIapId() const
+    {
+    return iLinkedIapId;
+    }
+
+// ---------------------------------------------------------------------------
+// If this is a virtual IAP that points to a SNAP, returns the ID of that SNAP,
+// 0 otherwise.
+// ---------------------------------------------------------------------------
+//
+TUint32 TCmmConnMethodItem::LinkedSnapId() const
+    {
+    return iLinkedSnapId;
+    }
+
 // End of file
--- a/cmmanager/cmmgr/cmmserver/src/cmmconnmethodstruct.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmconnmethodstruct.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -34,7 +34,7 @@
 // ---------------------------------------------------------------------------
 //
 CCmmConnMethodStruct* CCmmConnMethodStruct::NewL(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODSTRUCT_NEWL_ENTRY );
 
@@ -50,7 +50,7 @@
 // ---------------------------------------------------------------------------
 //
 CCmmConnMethodStruct* CCmmConnMethodStruct::NewLC(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODSTRUCT_NEWLC_ENTRY );
 
@@ -138,7 +138,7 @@
 // Set the connection method ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmConnMethodStruct::SetId( const TUint32& aConnMethodId )
+void CCmmConnMethodStruct::SetId( const TUint32 aConnMethodId )
     {
     iConnMethodId = aConnMethodId;
     }
@@ -172,11 +172,9 @@
     }
 
 // ---------------------------------------------------------------------------
-// TODO
-//
-// Refresh the relevant connection method data in cache side object to be in
-// synch with database and copy that data back to this session side connection
-// method object.
+// Refresh the connection method data in this cache side object to be in synch
+// with the database and copy that data back to the session side connection
+// method instance given as parameter.
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodStruct::RefreshConnMethodInstanceL(
@@ -220,7 +218,7 @@
 // references.
 // ---------------------------------------------------------------------------
 //
-TInt CCmmConnMethodStruct::SessionInstanceClosed()
+TInt CCmmConnMethodStruct::ConnMethodInstanceClosed()
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODSTRUCT_SESSIONINSTANCECLOSED_ENTRY );
 
@@ -236,8 +234,7 @@
     }
 
 // ---------------------------------------------------------------------------
-// Set the connection method plugin. Updates status and sets reference
-// counter to 1.
+// Set the connection method plugin pointer, bearer type and status.
 // ---------------------------------------------------------------------------
 //
 void CCmmConnMethodStruct::SetPlugin(
@@ -251,13 +248,13 @@
     // when data is copied into it.
     if ( iReferenceCounter != 0 )
         {
-        ASSERT( 0 ); // Error.
+        ASSERT( 0 ); // Error, wrong internal status.
         }
 
     iConnMethodPlugin = aPlugin;
     iBearerType = aBearerType;
 
-    switch ( aStatus ) //TODO, add missing status
+    switch ( aStatus )
         {
         // Fallthrough intended
         case ECmmConnMethodStatusNotSaved:
@@ -265,9 +262,10 @@
             iStatus = aStatus;
             break;
         case ECmmConnMethodStatusChanged:
+        case ECmmConnMethodStatusToBeDeleted:
         default:
             iStatus = ECmmConnMethodStatusChanged;
-            ASSERT( 0 ); // Error, invalid status.
+            ASSERT( 0 ); // Error, invalid status as argument.
             break;
         }
 
@@ -289,7 +287,7 @@
 // connection method structure to reflect the new deleted state.
 // ---------------------------------------------------------------------------
 //
-void CCmmConnMethodStruct::DeleteSuccessful( const TUint32& aNewSecondaryId )
+void CCmmConnMethodStruct::DeleteSuccessful( const TUint32 aNewSecondaryId )
     {
     OstTraceFunctionEntry0( CCMMCONNMETHODSTRUCT_DELETESUCCESSFUL_ENTRY );
 
--- a/cmmanager/cmmgr/cmmserver/src/cmmdestinationinstance.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmdestinationinstance.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -38,7 +38,9 @@
 // Two phased construction.
 // ---------------------------------------------------------------------------
 //
-CCmmDestinationInstance* CCmmDestinationInstance::NewL( CCmmSession* aCmmSession, CCmmCache* aCache )
+CCmmDestinationInstance* CCmmDestinationInstance::NewL(
+        CCmmSession* aCmmSession,
+        CCmmCache* aCache )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_NEWL_ENTRY );
 
@@ -53,7 +55,9 @@
 // Two phased construction.
 // ---------------------------------------------------------------------------
 //
-CCmmDestinationInstance* CCmmDestinationInstance::NewLC( CCmmSession* aCmmSession, CCmmCache* aCache )
+CCmmDestinationInstance* CCmmDestinationInstance::NewLC(
+        CCmmSession* aCmmSession,
+        CCmmCache* aCache )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_NEWLC_ENTRY );
 
@@ -135,7 +139,7 @@
 // Set the destination ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetId( const TUint32& aId )
+void CCmmDestinationInstance::SetId( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETID_ENTRY );
 
@@ -214,7 +218,7 @@
 // Set handle ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetHandle( const TInt& aHandle )
+void CCmmDestinationInstance::SetHandle( const TInt aHandle )
     {
     iHandle = aHandle;
     }
@@ -242,7 +246,7 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETELEMENTIDL_ENTRY );
 
-    RefreshRecordL( ECmmDestNetworkRecord );
+    LoadRecordIfMissingL( ECmmDestNetworkRecord );
 
     if ( !iNetworkRecord )
         {
@@ -261,7 +265,7 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETRECORDTAGFROMAPRECORDL_ENTRY );
 
-    RefreshRecordL( ECmmDestApRecord );
+    LoadRecordIfMissingL( ECmmDestApRecord );
 
     if ( !iDestApRecord )
         {
@@ -406,7 +410,7 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETDESTINATIONNAMEL_ENTRY );
 
-    RefreshRecordL( ECmmDestNetworkRecord );
+    LoadRecordIfMissingL( ECmmDestNetworkRecord );
 
     if ( !iNetworkRecord )
         {
@@ -425,7 +429,9 @@
 //
 HBufC* CCmmDestinationInstance::GetLocalisedDestinationNameL()
     {
-    RefreshRecordL( ECmmDestNetworkRecord );
+    OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETLOCALISEDDESTINATIONNAMEL_ENTRY );
+
+    LoadRecordIfMissingL( ECmmDestNetworkRecord );
 
     if ( !iNetworkRecord )
         {
@@ -463,12 +469,13 @@
             break;
         }
 
-    // Not Internet, operator or intranet...or something went wrong 
+    // Not Internet, operator or intranet, or something went wrong. 
     if ( !isLocalised || ( isLocalised && !resolvedText ) )
         {
-        resolvedText = ( iNetworkRecord->iRecordName.GetL() ).AllocL();
+        resolvedText = TPtrC( iNetworkRecord->iRecordName ).AllocL();
         }
-    
+
+    OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETLOCALISEDDESTINATIONNAMEL_EXIT );
     return resolvedText;
     }
 
@@ -480,8 +487,6 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_ENTRY );
 
-    //TODO, capability check depending on destination protection level, or if it is internet destination. Internet destination should be protected always?
-
     // Write action, load all records.
     LoadAllRecordsL();
 
@@ -496,6 +501,47 @@
     }
 
 // ---------------------------------------------------------------------------
+// Get the destination icon.
+// ---------------------------------------------------------------------------
+//
+HBufC* CCmmDestinationInstance::GetDestinationIconL()
+    {
+    OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETDESTINATIONICONL_ENTRY );
+
+    LoadRecordIfMissingL( ECmmDestMetadataRecord );
+
+    if ( !iMetadataRecord )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    HBufC* icon( NULL );
+    icon = TPtrC( iMetadataRecord->iIconFileName ).AllocL();
+
+    OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETDESTINATIONICONL_EXIT );
+    return icon;
+    }
+
+// ---------------------------------------------------------------------------
+// Set the destination icon.
+// ---------------------------------------------------------------------------
+//
+void CCmmDestinationInstance::SetDestinationIconL( const TDesC& aDestinationIcon )
+    {
+    OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONICONL_ENTRY );
+
+    // Write action, load all records.
+    LoadAllRecordsL();
+
+    iMetadataRecord->iIconFileName.SetL( aDestinationIcon );
+
+    iMetadataRecordStatus = ECmmRecordStatusModified;
+    iStatus = ECmmDestinationStatusChanged;
+
+    OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETDESTINATIONICONL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
 // Get metadata of specified type.
 // ---------------------------------------------------------------------------
 //
@@ -505,38 +551,41 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETMETADATAL_ENTRY );
 
-    RefreshRecordL( ECmmDestMetadataRecord );
+    LoadRecordIfMissingL( ECmmDestMetadataRecord );
 
     if ( !iMetadataRecord )
         {
-        OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETMETADATAL_EXIT );
-
         User::Leave( KErrCorrupt );
         }
 
     switch ( aMetadataField )
         {
         case CMManager::ESnapMetadataInternet:
-            aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) & CMManager::ESnapMetadataInternet;
+            aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) &
+                    CMManager::ESnapMetadataInternet;
             break;
         case CMManager::ESnapMetadataHighlight:
-            aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) & CMManager::ESnapMetadataHighlight;
+            aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) &
+                    CMManager::ESnapMetadataHighlight;
             break;
         case CMManager::ESnapMetadataHiddenAgent:
-            aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) & CMManager::ESnapMetadataHiddenAgent;
+            aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) &
+                    CMManager::ESnapMetadataHiddenAgent;
             break;
         case CMManager::ESnapMetadataDestinationIsLocalised:
-            aMetadata = ( ( TUint32 )( iMetadataRecord->iMetadata ) & CMManager::ESnapMetadataDestinationIsLocalised ) >> 4;
+            aMetadata = ( ( TUint32 )( iMetadataRecord->iMetadata ) &
+                    CMManager::ESnapMetadataDestinationIsLocalised ) >> 4;
             break;
         case CMManager::ESnapMetadataPurpose:
-            aMetadata = ( ( TUint32 )( iMetadataRecord->iMetadata ) & CMManager::ESnapMetadataPurpose ) >> 8;
+            aMetadata = ( ( TUint32 )( iMetadataRecord->iMetadata ) &
+                    CMManager::ESnapMetadataPurpose ) >> 8;
             break;
         default:
             User::Leave( KErrArgument );
             break;
         }
 
-    OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_GETMETADATAL_EXIT );
+    OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETMETADATAL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -545,7 +594,7 @@
 //
 void CCmmDestinationInstance::SetMetadataL(
         const CMManager::TSnapMetadataField& aMetadataField,
-        const TUint32& aMetadata )
+        const TUint32 aMetadata )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAL_ENTRY );
 
@@ -588,14 +637,15 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETPROTECTIONL_ENTRY );
 
-    RefreshRecordL( ECmmDestMetadataRecord );
+    LoadRecordIfMissingL( ECmmDestMetadataRecord );
 
     if ( !iMetadataRecord )
         {
         User::Leave( KErrCorrupt );
         }
 
-    TUint32 value = ( ( TUint32 )( iMetadataRecord->iMetadata ) & KDestProtectionLevelMask ) >> KBitsToShiftDestProtectionLevel;
+    TUint32 value = ( ( TUint32 )( iMetadataRecord->iMetadata ) &
+            KDestProtectionLevelMask ) >> KBitsToShiftDestProtectionLevel;
     switch ( value )
         {
         case CMManager::EProtLevel0:
@@ -630,8 +680,8 @@
     // Write action, load all records.
     LoadAllRecordsL();
 
-    //TODO, verify capability check is done (NetworkControl).
-
+    // Protection level is saved to CommsDat during update-call, so we need to
+    // keep track of both the original value and the currently set new value.
     iCurrentProtectionLevel = aProtectionLevel;
     if ( !iProtectionChanged )
         {
@@ -682,9 +732,18 @@
 // Return the protection level currently set into this destination instance.
 // ---------------------------------------------------------------------------
 //
-CMManager::TProtectionLevel CCmmDestinationInstance::CurrentProtectionLevel()
+CMManager::TProtectionLevel CCmmDestinationInstance::CurrentProtectionLevelL()
     {
-    return iCurrentProtectionLevel;
+    OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CURRENTPROTECTIONLEVELL_ENTRY );
+
+    CMManager::TProtectionLevel protLevel( iCurrentProtectionLevel );
+    if ( !iProtectionChanged )
+        {
+        GetProtectionL( protLevel );
+        }
+
+    OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CURRENTPROTECTIONLEVELL_EXIT );
+    return protLevel;
     }
 
 // ---------------------------------------------------------------------------
@@ -695,15 +754,14 @@
 // ---------------------------------------------------------------------------
 //
 TInt CCmmDestinationInstance::AddConnMethodL(
-        const CCmmConnMethodInstance& aConnMethodInstance )
+        CCmmConnMethodInstance& aConnMethodInstance )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_ADDCONNMETHODL_ENTRY );
 
     TUint32 connMethodId( aConnMethodInstance.GetId() );
-    TUint32 bearerType( aConnMethodInstance.GetBearerType() );
 
     // Check that the connection method is not an embedded destination.
-    if ( bearerType == KUidEmbeddedDestination )
+    if ( aConnMethodInstance.IsEmbeddedDestination() )
         {
         User::Leave( KErrArgument );
         }
@@ -728,32 +786,98 @@
         }
 
     // Get the priority value of this connection method according to bearer.
+    TUint32 bearerType( aConnMethodInstance.GetBearerType() );
     TUint bearerPriority( 0 );
     iCache->BearerPriorityFromIapRecordL(
-            ( CommsDat::CCDIAPRecord* )aConnMethodInstance.GetPluginDataInstance()->iGenRecordArray[KIapRecordIndex],
+            ( CommsDat::CCDIAPRecord* )aConnMethodInstance.GetPluginDataInstance()
+                    ->iGenRecordArray[KIapRecordIndex],
             bearerPriority );
     TCmmConnMethodItem item( connMethodId, bearerType, bearerPriority, 0 );
 
     // Find out the correct position for the connection method inside this
     // destination.
-    TInt index = iConnMethodItemArray.Count();
-    for ( TInt i = index - 1; i >= 0; i-- )
+
+    // If the destination contains 1 or more connection methods of the same
+    // bearer type, position the new connection method after the last of these
+    // connection methods.
+    // If not, position the connection method before the first connection
+    // method found that has an equal or greater bearer based priority.
+
+    // The relevant connection method item count is the number of connection
+    // methods excluding a possible embedded destination.
+    TInt relevantCount = iConnMethodItemArray.Count();
+    if ( relevantCount > 0 && iConnMethodItemArray[ relevantCount - 1 ].IsEmbedded() )
         {
-        if ( iConnMethodItemArray[i].iBearerPriority ==
-                CMManager::KDataMobilitySelectionPolicyPriorityWildCard )
+        relevantCount--;
+        }
+    // The final position will be between 0 and relevantCount.
+    TInt index( relevantCount );
+
+    // If this is a virtual IAP that doesn't point to an IAP, position it at
+    // the end of the list.
+    TBool connMethodIsVirtual = aConnMethodInstance.GetBoolAttributeL( CMManager::ECmVirtual );
+    TUint32 linkedIapId( 0 );
+    if ( connMethodIsVirtual )
+        {
+        // Ask link information only if this is a virtual IAP.
+        linkedIapId = aConnMethodInstance.GetIntAttributeL( CMManager::ECmNextLayerIapId );
+        if ( linkedIapId == 0 )
             {
-            index = i;
-            continue;
-            }
-        if ( iConnMethodItemArray[i].iBearerPriority == bearerPriority )
-            {
-            break;
-            }
-        if ( iConnMethodItemArray[i].iBearerPriority > bearerPriority )
-            {
-            index = i;
+            item.iPriority = CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
+            index = relevantCount;
             }
         }
+    else
+        {
+        TBool positionFound( EFalse );
+        if ( connMethodIsVirtual )
+            {
+            // If this is a virtual IAP that links to another IAP, position it
+            // as if it was that IAP.
+            TCmmConnMethodItem linkedItem;
+            TInt err = iCache->GetConnMethodItem( linkedIapId, linkedItem );
+            if ( err )
+                {
+                User::Leave( KErrArgument );
+                }
+            if ( linkedItem.IsVirtual() )
+                {
+                // This is a virtual IAP linking to another virtual IAP.
+                index = relevantCount;
+                positionFound = ETrue;
+                }
+            bearerType = linkedItem.iBearerType;
+            bearerPriority = linkedItem.iBearerPriority;
+            }
+
+        if ( !positionFound )
+            {
+            // Search for any connection methods with the same bearer type.
+            for ( TInt i = 0; i < relevantCount; i++ )
+                {
+                if ( iConnMethodItemArray[i].iBearerType == bearerType )
+                    {
+                    index = i + 1;
+                    positionFound = ETrue;
+                    // Don't break, need find last item.
+                    }
+                }
+            }
+        if ( !positionFound )
+            {
+            // No connection method found with the same bearer type. Position
+            // the connection method according to bearer priority.
+            for ( TInt i = 0; i < relevantCount; i++ )
+                {
+                if ( iConnMethodItemArray[i].iBearerPriority >= bearerPriority )
+                    {
+                    index = i;
+                    break;
+                    }
+                }
+            }
+        }
+
     // Add the connection method item into this destination at the correct
     // position (priority).
     iConnMethodItemArray.InsertL( item, index );
@@ -827,7 +951,7 @@
             embeddedDestinationId,
             KUidEmbeddedDestination,
             CMManager::KDataMobilitySelectionPolicyPriorityWildCard,
-            0 );
+            CMManager::KDataMobilitySelectionPolicyPriorityWildCard );
     iConnMethodItemArray.AppendL( item );
 
     SetStatus( ECmmDestinationStatusChanged );
@@ -888,7 +1012,7 @@
 
     // If this connection method is an embedded destination, then removing it
     // from this destination is enough. The destination is not deleted.
-    if ( aConnMethodInstance.GetBearerType() != KUidEmbeddedDestination )
+    if ( !aConnMethodInstance.IsEmbeddedDestination() )
         {
         // Add connection method to delete list only if not referenced from any
         // other destination (in database or in any destination handles for the
@@ -914,7 +1038,7 @@
 //
 void CCmmDestinationInstance::RemoveConnMethodFromDestinationL(
         const CCmmConnMethodInstance& aConnMethodInstance,
-        const TBool& aTestIfConnected )
+        const TBool aTestIfConnected )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REMOVECONNMETHODFROMDESTINATIONL_ENTRY );
 
@@ -961,11 +1085,17 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmDestinationInstance::ModifyConnMethodPriorityL(
-        const CCmmConnMethodInstance& aConnMethodInstance,
+        CCmmConnMethodInstance& aConnMethodInstance,
         TUint aIndex )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_ENTRY );
 
+    // Check index range.
+    if ( aIndex >= iConnMethodItemArray.Count() )
+        {
+        User::Leave( KErrArgument );
+        }
+
     // Check if the connection method is in this destination. Also store the
     // current index of the connection method.
     TInt oldIndex( KErrNotFound );
@@ -977,26 +1107,24 @@
             break;
             }
         }
-    if ( oldIndex < 0 )
+    if ( oldIndex == KErrNotFound )
         {
         User::Leave( KErrArgument );
         }
 
     // If connection method is an embedded destination, just return silently.
-    if ( aConnMethodInstance.GetBearerType() == KUidEmbeddedDestination )
+    if ( aConnMethodInstance.IsEmbeddedDestination() )
         {
         OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT );
         return;
         }
 
-    //TODO, if CM is virtual IAP that points into DESTINATION, just return silently.
-    //
-    //
-
-    // Check index range.
-    if ( aIndex >= iConnMethodItemArray.Count() )
+    // If connection method is a virtual IAP linking to a destination, just return silently.
+    if ( aConnMethodInstance.GetBoolAttributeL( CMManager::ECmVirtual ) &&
+            aConnMethodInstance.GetIntAttributeL( CMManager::ECmNextLayerIapId ) == 0 )
         {
-        User::Leave( KErrArgument );
+        OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT );
+        return;
         }
 
     // If the given index points to any wildcard priority connection method,
@@ -1011,13 +1139,13 @@
             ASSERT( 0 );
             User::Leave( KErrCorrupt );
             }
-        aIndex = numberOfConnMethodsWithPriority--;
+        aIndex = numberOfConnMethodsWithPriority - 1;
         }
 
     // Check if the priority is changing from current.
     if ( oldIndex == aIndex )
         {
-        OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT );
+        OstTraceFunctionExit0( DUP2_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT );
         return;
         }
 
@@ -1028,7 +1156,7 @@
 
     SetStatus( ECmmDestinationStatusChanged );
 
-    OstTraceFunctionExit0( DUP2_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT );
+    OstTraceFunctionExit0( DUP3_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1037,7 +1165,7 @@
 // ---------------------------------------------------------------------------
 //
 CCmmConnMethodInstance* CCmmDestinationInstance::FindConnMethodInstanceFromSessionById(
-        const TUint32& aConnMethodId ) const
+        const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_FINDCONNMETHODINSTANCEFROMSESSIONBYID_ENTRY );
 
@@ -1054,7 +1182,7 @@
 // ---------------------------------------------------------------------------
 //
 CCmmDestinationInstance* CCmmDestinationInstance::FindDestinationInstanceFromSessionById(
-        const TUint32& aDestinationId ) const
+        const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_FINDDESTINATIONINSTANCEFROMSESSIONBYID_ENTRY );
 
@@ -1071,8 +1199,8 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmDestinationInstance::ConnMethodInOtherDestinationInSession(
-        const TUint32& aConnMethodId,
-        const TUint32& aDestinationId ) const
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONNMETHODINOTHERDESTINATIONINSESSION_ENTRY );
 
@@ -1088,7 +1216,8 @@
 // embedded destinations.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmDestinationInstance::ValidConnMethodIdInDestinationIncludeEmbedded( const TUint32& aConnMethodId ) const
+TBool CCmmDestinationInstance::ValidConnMethodIdInDestinationIncludeEmbedded(
+        const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_VALIDCONNMETHODIDINDESTINATIONINCLUDEEMBEDDED_ENTRY );
 
@@ -1118,7 +1247,7 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmDestinationInstance::ConnMethodInDestinationButLocked(
-        const TUint32& aConnMethodId ) const
+        const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY );
 
@@ -1154,11 +1283,10 @@
 
     for ( TUint i = 0; i < iConnMethodItemArray.Count(); i++ )
         {
-        //TODO, add virtual IAP pointing to SNAP check.
-        if ( iConnMethodItemArray[i].iBearerType == KUidEmbeddedDestination )
+        if ( iConnMethodItemArray[i].IsEmbedded() || iConnMethodItemArray[i].iPriority ==
+                CMManager::KDataMobilitySelectionPolicyPriorityWildCard )
             {
-            count = i;
-            break;
+            count--;
             }
         }
 
@@ -1183,7 +1311,7 @@
     TInt index = iConnMethodItemArray.Count() - 1;
     if ( index >= 0 )
         {
-        if ( iConnMethodItemArray[index].iBearerType == KUidEmbeddedDestination )
+        if ( iConnMethodItemArray[index].IsEmbedded() )
             {
             result = ETrue;
             }
@@ -1199,7 +1327,7 @@
 // the current status in database.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmDestinationInstance::HasEmbeddedWithId( const TUint32& aDestinationId ) const
+TBool CCmmDestinationInstance::HasEmbeddedWithId( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_HASEMBEDDEDWITHID_ENTRY );
 
@@ -1289,19 +1417,16 @@
     TBool result( ETrue );
 
     if ( iNetworkRecordStatus != ECmmRecordStatusLoaded &&
-            iNetworkRecordStatus != ECmmRecordStatusExpired &&
             iNetworkRecordStatus != ECmmRecordStatusModified )
         {
         result = EFalse;
         }
     if ( iDestApRecordStatus != ECmmRecordStatusLoaded &&
-            iDestApRecordStatus != ECmmRecordStatusExpired &&
             iDestApRecordStatus != ECmmRecordStatusModified )
         {
         result = EFalse;
         }
     if ( iMetadataRecordStatus != ECmmRecordStatusLoaded &&
-            iMetadataRecordStatus != ECmmRecordStatusExpired &&
             iMetadataRecordStatus != ECmmRecordStatusModified )
         {
         result = EFalse;
@@ -1316,10 +1441,14 @@
     }
 
 // ---------------------------------------------------------------------------
-// Loads a certain type of record from database if it is not up-to-date.
+// Loads a requested type of record from database if it is not yet loaded.
+//
+// Currently all records are loaded when client opens a handle to a
+// destination, but if future optimizations are added and records are only
+// loaded when needed, the functionality of this method becomes essential.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::RefreshRecordL( TCmmDbRecords aRecordType )
+void CCmmDestinationInstance::LoadRecordIfMissingL( TCmmDbRecords aRecordType )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_ENTRY );
 
@@ -1344,16 +1473,16 @@
         {
         // Fallthrough intended
         case ECmmRecordStatusBlank:
-        case ECmmRecordStatusExpired:
             iCache->LoadDestinationRecordL( *this, aRecordType );
             break;
         case ECmmRecordStatusLoaded:
         case ECmmRecordStatusModified:
             // Record is up-to-date.
             break;
+        case ECmmRecordStatusExpired:
         case ECmmRecordStatusUnsaved:
         default:
-            User::Leave( KErrCorrupt ); // Error, unknown status.
+            User::Leave( KErrCorrupt ); // Error, invalid or unknown status.
             break;
         }
 
@@ -1362,15 +1491,16 @@
 
 // ---------------------------------------------------------------------------
 // Loads all records from database that are not up-to-date.
+// Guarantees the record pointers are valid or leaves.
 // ---------------------------------------------------------------------------
 //
 void CCmmDestinationInstance::LoadAllRecordsL()
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_LOADALLRECORDSL_ENTRY );
 
-    RefreshRecordL( ECmmDestNetworkRecord );
-    RefreshRecordL( ECmmDestApRecord );
-    RefreshRecordL( ECmmDestMetadataRecord );
+    LoadRecordIfMissingL( ECmmDestNetworkRecord );
+    LoadRecordIfMissingL( ECmmDestApRecord );
+    LoadRecordIfMissingL( ECmmDestMetadataRecord );
 
     if ( !iNetworkRecord || !iDestApRecord || !iMetadataRecord )
         {
@@ -1384,13 +1514,15 @@
 // Set metadata of type ESnapMetadataInternet.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetMetadataInternetL( const TUint32& aMetadata )
+void CCmmDestinationInstance::SetMetadataInternetL( const TUint32 aMetadata )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAINTERNETL_ENTRY );
 
     if ( aMetadata )
         {
-        if ( iCache->DestinationExistsWithMetadataLocalizedL( *this, CMManager::ELocalisedDestInternet ) )
+        if ( iCache->DestinationExistsWithMetadataLocalizedL(
+                *this,
+                CMManager::ELocalisedDestInternet ) )
             {
             User::Leave( KErrAlreadyExists );
             }
@@ -1413,8 +1545,11 @@
         }
     else
         {
-        // Clear old ESnapMetadataInternet-bit, ESnapMetadataDestinationIsLocalised-bits and CMManager::ESnapMetadataPurpose-bits.
-        TUint32 temp = ~( CMManager::ESnapMetadataInternet | CMManager::ESnapMetadataDestinationIsLocalised | CMManager::ESnapMetadataPurpose );
+        // Clear old ESnapMetadataInternet-bit,
+        // ESnapMetadataDestinationIsLocalised-bits and CMManager::ESnapMetadataPurpose-bits.
+        TUint32 temp = ~( CMManager::ESnapMetadataInternet |
+                CMManager::ESnapMetadataDestinationIsLocalised |
+                CMManager::ESnapMetadataPurpose );
         iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & temp;
         }
 
@@ -1425,7 +1560,7 @@
 // Set metadata of type ESnapMetadataHighlight.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetMetadataHighlight( const TUint32& aMetadata )
+void CCmmDestinationInstance::SetMetadataHighlight( const TUint32 aMetadata )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAHIGHLIGHTL_ENTRY );
 
@@ -1434,12 +1569,14 @@
     if ( aMetadata )
         {
         // Set ESnapMetadataHighlight-bit.
-        iMetadataRecord->iMetadata = iMetadataRecord->iMetadata | CMManager::ESnapMetadataHighlight;
+        iMetadataRecord->iMetadata =
+                iMetadataRecord->iMetadata | CMManager::ESnapMetadataHighlight;
         }
     else
         {
         // Clear ESnapMetadataHighlight-bit.
-        iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHighlight );
+        iMetadataRecord->iMetadata =
+                iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHighlight );
         }
 
     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAHIGHLIGHTL_EXIT );
@@ -1449,29 +1586,35 @@
 // Set metadata of type ESnapMetadataHiddenAgent.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetMetadataHiddenAgentL( const TUint32& aMetadata )
+void CCmmDestinationInstance::SetMetadataHiddenAgentL( const TUint32 aMetadata )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAHIDDENAGENTL_ENTRY );
 
     if ( aMetadata )
         {
-        TUint32 metadataInternet(    iMetadataRecord->iMetadata & CMManager::ESnapMetadataInternet                      );
-        TUint32 metadataLocalized( ( iMetadataRecord->iMetadata & CMManager::ESnapMetadataDestinationIsLocalised ) >> 4 );
-        TUint32 metadataPurpose(   ( iMetadataRecord->iMetadata & CMManager::ESnapMetadataPurpose                ) >> 8 );
+        TUint32 metadataInternet( iMetadataRecord->iMetadata &
+                CMManager::ESnapMetadataInternet );
+        TUint32 metadataLocalized( ( iMetadataRecord->iMetadata &
+                CMManager::ESnapMetadataDestinationIsLocalised ) >> 4 );
+        TUint32 metadataPurpose( ( iMetadataRecord->iMetadata &
+                CMManager::ESnapMetadataPurpose ) >> 8 );
         if ( metadataInternet ||
                 ( metadataLocalized == CMManager::ELocalisedDestInternet ) ||
                 ( metadataPurpose == CMManager::ESnapPurposeInternet ) )
             {
-            // Not allowed to set ESnapMetadataHiddenAgent if destination is localized or has purpose set.
+            // Not allowed to set ESnapMetadataHiddenAgent if destination is
+            // localized or has purpose set.
             User::Leave( KErrArgument );
             }
         // Set ESnapMetadataHiddenAgent-bit.
-        iMetadataRecord->iMetadata = iMetadataRecord->iMetadata | CMManager::ESnapMetadataHiddenAgent;
+        iMetadataRecord->iMetadata =
+                iMetadataRecord->iMetadata | CMManager::ESnapMetadataHiddenAgent;
         }
     else
         {
         // Clear ESnapMetadataHiddenAgent-bit.
-        iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHiddenAgent );
+        iMetadataRecord->iMetadata =
+                iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHiddenAgent );
         }
 
     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAHIDDENAGENTL_EXIT );
@@ -1481,7 +1624,7 @@
 // Set metadata of type ESnapMetadataDestinationIsLocalised.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetMetadataLocalizationL( const TUint32& aMetadata )
+void CCmmDestinationInstance::SetMetadataLocalizationL( const TUint32 aMetadata )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATALOCALIZATIONL_ENTRY );
 
@@ -1491,10 +1634,14 @@
         User::Leave( KErrArgument );
         }
 
-    TUint32 temp = ~( CMManager::ESnapMetadataInternet | CMManager::ESnapMetadataDestinationIsLocalised | CMManager::ESnapMetadataPurpose );
+    TUint32 temp = ~(
+            CMManager::ESnapMetadataInternet |
+            CMManager::ESnapMetadataDestinationIsLocalised |
+            CMManager::ESnapMetadataPurpose );
     if ( aMetadata == CMManager::ENotLocalisedDest )
         {
-        // Clear old ESnapMetadataInternet-bit, ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
+        // Clear old ESnapMetadataInternet-bit,
+        // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
         iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & temp;
         }
     else
@@ -1504,7 +1651,8 @@
             User::Leave( KErrAlreadyExists );
             }
 
-        // Clear old ESnapMetadataInternet-bit, ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
+        // Clear old ESnapMetadataInternet-bit,
+        // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
         TUint32 value = iMetadataRecord->iMetadata & temp;
         switch ( aMetadata )
             {
@@ -1553,7 +1701,7 @@
 // Set metadata of type ESnapMetadataPurpose.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationInstance::SetMetadataPurposeL( const TUint32& aMetadata )
+void CCmmDestinationInstance::SetMetadataPurposeL( const TUint32 aMetadata )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAPURPOSEL_ENTRY );
 
@@ -1563,10 +1711,14 @@
         User::Leave( KErrArgument );
         }
 
-    TUint32 temp = ~( CMManager::ESnapMetadataInternet | CMManager::ESnapMetadataDestinationIsLocalised | CMManager::ESnapMetadataPurpose );
+    TUint32 temp = ~(
+            CMManager::ESnapMetadataInternet |
+            CMManager::ESnapMetadataDestinationIsLocalised |
+            CMManager::ESnapMetadataPurpose );
     if ( aMetadata == CMManager::ESnapPurposeUnknown )
         {
-        // Clear old ESnapMetadataInternet-bit, ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
+        // Clear old ESnapMetadataInternet-bit,
+        // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
         iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & temp;
         }
     else
@@ -1576,7 +1728,8 @@
             User::Leave( KErrAlreadyExists );
             }
 
-        // Clear old ESnapMetadataInternet-bit, ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
+        // Clear old ESnapMetadataInternet-bit,
+        // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits.
         TUint32 value = iMetadataRecord->iMetadata & temp;
 
         switch ( aMetadata )
@@ -1632,9 +1785,12 @@
     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONFLICTINGMETADATAFOUNDL_ENTRY );
 
     TBool result( EFalse );
-    TUint32 metadataInternet(    iMetadataRecord->iMetadata & CMManager::ESnapMetadataInternet                      );
-    TUint32 metadataLocalized( ( iMetadataRecord->iMetadata & CMManager::ESnapMetadataDestinationIsLocalised ) >> 4 );
-    TUint32 metadataPurpose(   ( iMetadataRecord->iMetadata & CMManager::ESnapMetadataPurpose                ) >> 8 );
+    TUint32 metadataInternet( iMetadataRecord->iMetadata &
+            CMManager::ESnapMetadataInternet );
+    TUint32 metadataLocalized( ( iMetadataRecord->iMetadata &
+            CMManager::ESnapMetadataDestinationIsLocalised ) >> 4 );
+    TUint32 metadataPurpose( ( iMetadataRecord->iMetadata &
+            CMManager::ESnapMetadataPurpose ) >> 8 );
 
     if ( metadataPurpose )
         {
@@ -1646,7 +1802,9 @@
             case CMManager::ESnapPurposeOperator:
             case CMManager::ESnapPurposeMMS:
             case CMManager::ESnapPurposeIntranet:
-                result = iCache->DestinationExistsWithMetadataPurposeL( *this, metadataPurpose );
+                result = iCache->DestinationExistsWithMetadataPurposeL(
+                        *this,
+                        metadataPurpose );
                 break;
             default:
                 User::Leave( KErrCorrupt ); // Invalid metadata.
@@ -1663,7 +1821,9 @@
             case CMManager::ELocalisedDestWap:
             case CMManager::ELocalisedDestMMS:
             case CMManager::ELocalisedDestIntranet:
-                result = iCache->DestinationExistsWithMetadataLocalizedL( *this, metadataLocalized );
+                result = iCache->DestinationExistsWithMetadataLocalizedL(
+                        *this,
+                        metadataLocalized );
                 break;
             default:
                 User::Leave( KErrCorrupt ); // Invalid metadata.
@@ -1673,7 +1833,9 @@
     else if ( metadataInternet )
         {
         // Error, metadataPurpose and metadataLocalized was not set. Continue anyway.
-        result = iCache->DestinationExistsWithMetadataLocalizedL( *this, CMManager::ELocalisedDestInternet );
+        result = iCache->DestinationExistsWithMetadataLocalizedL(
+                *this,
+                CMManager::ELocalisedDestInternet );
         }
 
     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CONFLICTINGMETADATAFOUNDL_EXIT );
--- a/cmmanager/cmmgr/cmmserver/src/cmmdestinationstruct.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmdestinationstruct.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,6 @@
 
 
 #include <datamobilitycommsdattypes.h>
-#include <cmpluginembdestinationdef.h>
 #include <in_sock.h> // KAfInet
 
 #include "cmmdestinationstruct.h"
@@ -42,11 +41,14 @@
 CCmmDestinationStruct* CCmmDestinationStruct::NewL(
         CCmmCache* aCache,
         CCmmTransactionHandler* aTransactionHandler,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_NEWL_ENTRY );
 
-    CCmmDestinationStruct* self = CCmmDestinationStruct::NewLC( aCache, aTransactionHandler, aDestinationId );
+    CCmmDestinationStruct* self = CCmmDestinationStruct::NewLC(
+            aCache,
+            aTransactionHandler,
+            aDestinationId );
     CleanupStack::Pop( self );
 
     OstTraceFunctionExit0( CCMMDESTINATIONSTRUCT_NEWL_EXIT );
@@ -63,11 +65,15 @@
         CCmmCache* aCache,
         CCmmTransactionHandler* aTransactionHandler,
         const TDesC& aName,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( DUP1_CCMMDESTINATIONSTRUCT_NEWL_ENTRY );
 
-    CCmmDestinationStruct* self = CCmmDestinationStruct::NewLC( aCache, aTransactionHandler, aName, aDestinationId );
+    CCmmDestinationStruct* self = CCmmDestinationStruct::NewLC(
+            aCache,
+            aTransactionHandler,
+            aName,
+            aDestinationId );
     CleanupStack::Pop( self );
 
     OstTraceFunctionExit0( DUP1_CCMMDESTINATIONSTRUCT_NEWL_EXIT );
@@ -82,11 +88,13 @@
 CCmmDestinationStruct* CCmmDestinationStruct::NewLC(
         CCmmCache* aCache,
         CCmmTransactionHandler* aTransactionHandler,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_NEWLC_ENTRY );
 
-    CCmmDestinationStruct* self = new( ELeave ) CCmmDestinationStruct( aCache, aTransactionHandler );
+    CCmmDestinationStruct* self = new( ELeave ) CCmmDestinationStruct(
+            aCache,
+            aTransactionHandler );
     CleanupStack::PushL( self );
     self->ConstructL( aDestinationId );
 
@@ -104,11 +112,13 @@
         CCmmCache* aCache,
         CCmmTransactionHandler* aTransactionHandler,
         const TDesC& aName,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( DUP1_CCMMDESTINATIONSTRUCT_NEWLC_ENTRY );
 
-    CCmmDestinationStruct* self = new( ELeave ) CCmmDestinationStruct( aCache, aTransactionHandler );
+    CCmmDestinationStruct* self = new( ELeave ) CCmmDestinationStruct(
+            aCache,
+            aTransactionHandler );
     CleanupStack::PushL( self );
     self->ConstructL( aName, aDestinationId );
 
@@ -169,12 +179,13 @@
 // Opens an existing destination based on ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationStruct::ConstructL( const TUint32& aDestinationId )
+void CCmmDestinationStruct::ConstructL( const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_CONSTRUCTL_ENTRY );
 
     // Check ID is in valid range.
-    if ( aDestinationId <= KCmDefaultDestinationAPTagId || aDestinationId >= KCmMaxDestinationAPTagId )
+    if ( aDestinationId <= KCmDefaultDestinationAPTagId ||
+            aDestinationId >= KCmMaxDestinationAPTagId )
         {
         User::Leave( KErrArgument );
         }
@@ -211,7 +222,6 @@
         // Not found -> fill in with default values.
         iMetadataRecord->iSNAP = iId;
         iMetadataRecord->iMetadata = 0;
-        iMetadataRecord->iIcon = 0;
         iMetadataRecord->SetRecordId( KCDNewRecordRequest );
         iMetadataRecordStatus = ECmmRecordStatusUnsaved;
         }
@@ -231,7 +241,7 @@
 // Creates a new destination. With name and optionally also with ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationStruct::ConstructL( const TDesC& aName, const TUint32& aDestinationId )
+void CCmmDestinationStruct::ConstructL( const TDesC& aName, const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( DUP1_CCMMDESTINATIONSTRUCT_CONSTRUCTL_ENTRY );
 
@@ -286,7 +296,7 @@
 // Set the destination ID.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationStruct::SetId( const TUint32& aId )
+void CCmmDestinationStruct::SetId( const TUint32 aId )
     {
     iId = aId;
     }
@@ -415,7 +425,7 @@
 // the reference counter by one.
 // ---------------------------------------------------------------------------
 //
-void CCmmDestinationStruct::CreateSessionInstanceL(
+void CCmmDestinationStruct::CreateDestinationInstanceL(
         CCmmDestinationInstance& aDestinationInstance )
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_CREATESESSIONINSTANCEL_ENTRY );
@@ -432,7 +442,7 @@
     // NULL. When update is called, copy the records into the cache also.
     //
 
-    switch ( iStatus ) //TODO, add missing status values
+    switch ( iStatus )
         {
         case ECmmDestinationStatusNotSaved:
             {
@@ -463,6 +473,8 @@
             aDestinationInstance.SetStatus( ECmmDestinationStatusValid );
             }
             break;
+        case ECmmDestinationStatusChanged:
+        case ECmmDestinationStatusToBeDeleted:
         default:
             User::Leave( KErrCorrupt ); // Invalid status.
             break;
@@ -475,7 +487,9 @@
     }
 
 // ---------------------------------------------------------------------------
-// TODO
+// Refresh the data contained in aDestinationInstance. This means reloading
+// the data from database if necessary. After this call the contents of
+// aDestinationInstance will reflect the current state in the database. 
 // ---------------------------------------------------------------------------
 //
 void CCmmDestinationStruct::RefreshDestinationInstanceL(
@@ -629,6 +643,9 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_UPDATEL_ENTRY );
 
+    TBool setProtection( EFalse );
+    CMManager::TProtectionLevel protLevel( CMManager::EProtLevel0 );
+
     // Structure:
     // - Use ModifyL() or StoreL() according to own status (new destination or
     //   changes to existing one).
@@ -668,6 +685,15 @@
 
             recordPointer = NULL;
 
+            // Set protections on network record as needed.
+            protLevel = aDestinationInstance.CurrentProtectionLevelL();
+            if ( protLevel == CMManager::EProtLevel1 ||
+                    protLevel == CMManager::EProtLevel2 )
+                {
+                setProtection = ETrue;
+                }
+            SetAttribute( instanceNetworkRecord, CommsDat::ECDProtectedWrite, setProtection );
+
             switch ( iStatus )
                 {
                 case ECmmDestinationStatusNotSaved:
@@ -677,9 +703,6 @@
                     // Store network record first, the record ID is needed for
                     // destination access point record.
                     // Record ID for network record is set during construction.
-
-                    //TODO, Check method call from old CmManager:
-                    //TODO, SetAttribute( iData->iNetworkRecord, ECDProtectedWrite, ProtectionLevel() == EProtLevel1 );
                     instanceNetworkRecord->StoreL( iTransactionHandler->Session() );
 
                     // If ID is out of valid range, it means this destination was created
@@ -691,7 +714,8 @@
                         {
                         id = instanceNetworkRecord->RecordId() + KCmDefaultDestinationAPTagId;
                         instanceDestApRecord->iRecordTag = id;
-                        instanceDestApRecord->iCustomSelectionPolicy = ( id - KCmDefaultDestinationAPTagId );
+                        instanceDestApRecord->iCustomSelectionPolicy =
+                                ( id - KCmDefaultDestinationAPTagId );
                         instanceMetadataRecord->iSNAP = id;
                         }
                     instanceDestApRecord->StoreL( iTransactionHandler->Session() );
@@ -704,8 +728,6 @@
                     {
                     // This destination already exists in database and is beeing modified.
 
-                    //TODO, Check method call from old CmManager:
-                    //TODO, SetAttribute( iData->iNetworkRecord, ECDProtectedWrite, ProtectionLevel() == EProtLevel1 );
                     instanceNetworkRecord->ModifyL( iTransactionHandler->Session() );
                     instanceDestApRecord->ModifyL( iTransactionHandler->Session() );
                     if ( iMetadataRecordStatus == ECmmRecordStatusUnsaved )
@@ -734,9 +756,12 @@
             iDestApRecordStatus = ECmmRecordStatusBlank;
             iNetworkRecordStatus = ECmmRecordStatusBlank;
             iMetadataRecordStatus = ECmmRecordStatusBlank;
-            iDestApRecord = static_cast<CommsDat::CCDAccessPointRecord*>( CopyRecordL( ECmmDestApRecord, instanceDestApRecord ) );
-            iNetworkRecord = static_cast<CommsDat::CCDNetworkRecord*>( CopyRecordL( ECmmDestNetworkRecord, instanceNetworkRecord ) );
-            iMetadataRecord = static_cast<CCDSNAPMetadataRecord*>( CopyRecordL( ECmmDestMetadataRecord, instanceMetadataRecord ) );
+            iDestApRecord = static_cast<CommsDat::CCDAccessPointRecord*>(
+                    CopyRecordL( ECmmDestApRecord, instanceDestApRecord ) );
+            iNetworkRecord = static_cast<CommsDat::CCDNetworkRecord*>(
+                    CopyRecordL( ECmmDestNetworkRecord, instanceNetworkRecord ) );
+            iMetadataRecord = static_cast<CCDSNAPMetadataRecord*>(
+                    CopyRecordL( ECmmDestMetadataRecord, instanceMetadataRecord ) );
 
             instanceDestApRecord = NULL;
             instanceNetworkRecord = NULL;
@@ -781,6 +806,10 @@
             // Initial record for destination itself.
             snapRecord1->iSNAP = id;
             snapRecord1->iRecordName.SetL( iNetworkRecord->iRecordName.GetL() );
+
+            // Set protections on snap record.
+            SetAttribute( snapRecord1, CommsDat::ECDProtectedWrite, setProtection );
+
             if ( existingRecordCount > index )
                 {
                 snapRecord1->SetElementId( snapRecordSet->iRecords[index]->ElementId() );
@@ -820,9 +849,16 @@
                             connMethodRealId );
                     }
 
-                //TODO, if protection level is 1 (dest AND CMs), set ECDProtectedWrite. See oldimplementation.
+                // Set protections on destination contents as needed.
+                setProtection = EFalse;
+                protLevel = aDestinationInstance.CurrentProtectionLevelL();
+                if ( protLevel == CMManager::EProtLevel1 )
+                    {
+                    setProtection = ETrue;
+                    }
+                SetAttribute( snapRecord2, CommsDat::ECDProtectedWrite, setProtection );
 
-                if ( aDestinationInstance.iConnMethodItemArray[i].iBearerType == KUidEmbeddedDestination )
+                if ( aDestinationInstance.iConnMethodItemArray[i].IsEmbedded() )
                     {
                     // Embedded destination.
                     snapRecord2->iEmbeddedSNAP = ( TInt )connMethodRealId;
@@ -830,15 +866,28 @@
                     snapRecord2->iPriority =
                             CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
                     aDestinationInstance.iConnMethodItemArray[i].iPriority =
-                            CMManager::KDataMobilitySelectionPolicyPriorityWildCard; // Update this just in case.
+                            CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
                     }
                 else
                     {
                     // Normal connection method.
                     snapRecord2->iEmbeddedSNAP = 0;
-                    snapRecord2->iIAP = ( KCDMaskShowField & CommsDat::KCDTIdIAPRecord ) | ( connMethodRealId << 8 );
-                    snapRecord2->iPriority = i + 1; // Priority values start from 1.
-                    aDestinationInstance.iConnMethodItemArray[i].iPriority = i + 1; // Update this just in case.
+                    snapRecord2->iIAP = CommsDat::KCDTIdIAPRecord | ( connMethodRealId << 8 );
+                    // If the connection method is a virtual IAP that doesn't
+                    // link to an IAP, set priority to wildcard.
+                    if ( aDestinationInstance.iConnMethodItemArray[i].IsVirtual() &&
+                            aDestinationInstance.iConnMethodItemArray[i].LinkedIapId() == 0 )
+                        {
+                        snapRecord2->iPriority =
+                                CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
+                        aDestinationInstance.iConnMethodItemArray[i].iPriority =
+                                CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
+                        }
+                    else
+                        {
+                        snapRecord2->iPriority = i + 1; // Priority values start from 1.
+                        aDestinationInstance.iConnMethodItemArray[i].iPriority = i + 1;
+                        }
                     }
 
                 if ( existingRecordCount > index )
@@ -896,30 +945,6 @@
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_DELETEL_ENTRY );
 
-    // Check general status.
-    /*switch ( iStatus ) //TODO, already done? yes, cleanup
-        {
-        case ECmmDestinationStatusNotSaved:
-            {
-            // Doesn'texist in database.
-            User::Leave( KErrNotFound );
-            }
-            break;
-        case ECmmDestinationStatusValid:
-            // Proceed.
-            break;
-        case ECmmDestinationStatusToBeDeleted:
-            {
-            // Already deleted, nothing to do.
-            return;
-            }
-        case ECmmDestinationStatusChanged:
-        default:
-            ASSERT( 0 ); // Error, invalid argument.
-            User::Leave( KErrCorrupt );
-            break;
-        }*/
-
     // Check status for records.
     switch ( iNetworkRecordStatus )
         {
@@ -1018,7 +1043,7 @@
 // references is returned.
 // ---------------------------------------------------------------------------
 //
-TInt CCmmDestinationStruct::SessionInstanceClosed()
+TInt CCmmDestinationStruct::DestinationInstanceClosed()
     {
     OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_SESSIONINSTANCECLOSED_ENTRY );
 
@@ -1185,6 +1210,28 @@
     }
 
 // -----------------------------------------------------------------------------
+// Set attribute flag on the given record.
+// -----------------------------------------------------------------------------
+void CCmmDestinationStruct::SetAttribute(
+        CommsDat::CCDRecordBase* aRecord,
+        TUint32 aAttribute,
+        TBool aSet )
+    {
+    OstTraceFunctionEntry0( CCMMDESTINATIONSTRUCT_SETATTRIBUTE_ENTRY );
+
+    if ( aSet )
+        {
+        aRecord->SetAttributes( aAttribute );
+        }
+    else
+        {
+        aRecord->ClearAttributes( aAttribute );
+        }
+
+    OstTraceFunctionExit0( CCMMDESTINATIONSTRUCT_SETATTRIBUTE_EXIT );
+    }
+
+// -----------------------------------------------------------------------------
 // Creates a copy of a record of the given type.
 // -----------------------------------------------------------------------------
 CommsDat::CCDRecordBase* CCmmDestinationStruct::CopyRecordL(
@@ -1333,6 +1380,10 @@
                 {
                 metadataRecord->iIcon.SetL( source->iIcon );
                 }
+            if ( !source->iIconFileName.IsNull() )
+                {
+                metadataRecord->iIconFileName.SetL( source->iIconFileName );
+                }
             metadataRecord->SetElementId( source->ElementId() );
 
             CleanupStack::Pop( metadataRecord );
--- a/cmmanager/cmmgr/cmmserver/src/cmminstancemapping.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmminstancemapping.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -194,7 +194,7 @@
 // Check if the given ID is a valid existing destination ID.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmInstanceMapping::ValidDestinationId( const TUint32& aId ) const
+TBool CCmmInstanceMapping::ValidDestinationId( const TUint32 aId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDDESTINATIONID_ENTRY );
 
@@ -220,7 +220,7 @@
 // Check if the given ID is a valid existing connection method ID.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmInstanceMapping::ValidConnMethodId( const TUint32& aId ) const
+TBool CCmmInstanceMapping::ValidConnMethodId( const TUint32 aId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDCONNMETHODID_ENTRY );
 
@@ -243,11 +243,37 @@
     }
 
 // ---------------------------------------------------------------------------
+// Check if the given ID is a valid existing unsupported connection method ID.
+// ---------------------------------------------------------------------------
+//
+TBool CCmmInstanceMapping::UnsupportedConnMethodId( const TUint32 aId ) const
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_UNSUPPORTEDCONNMETHODID_ENTRY );
+
+    TBool validity( EFalse );
+
+    if ( aId > 0 )
+        {
+        for ( TInt i = 0; i < iUnsupportedConnMethods.Count(); i++ )
+            {
+            if ( iUnsupportedConnMethods[i] == aId )
+                {
+                validity = ETrue;
+                break;
+                }
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_UNSUPPORTEDCONNMETHODID_EXIT );
+    return validity;
+    }
+
+// ---------------------------------------------------------------------------
 // Check from database if the given destination is an embedded destination in
 // any other destination.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmInstanceMapping::DestinationIsEmbedded( const TUint32& aDestinationId ) const
+TBool CCmmInstanceMapping::DestinationIsEmbedded( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONISEMBEDDED_ENTRY );
 
@@ -280,7 +306,7 @@
 // Check from database if the given destination has an embedded destination.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmInstanceMapping::DestinationHasEmbedded( const TUint32& aDestinationId ) const
+TBool CCmmInstanceMapping::DestinationHasEmbedded( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONHASEMBEDDED_ENTRY );
 
@@ -296,7 +322,7 @@
             TInt index = iDestinations[i]->iConnMethodItemArray.Count() - 1;
             if ( index >= 0 )
                 {
-                if ( iDestinations[i]->iConnMethodItemArray[index].iBearerType == KUidEmbeddedDestination )
+                if ( iDestinations[i]->iConnMethodItemArray[index].IsEmbedded() )
                     {
                     result = ETrue;
                     }
@@ -315,12 +341,25 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmInstanceMapping::DestinationPointedToByVirtualIap(
-        const TUint32& /*aDestinationId*/ ) const
+        const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_ENTRY );
-    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_EXIT );
 
-    return EFalse; //TODO, virtual IAPs are not yet supported.
+    TBool result( EFalse );
+    if ( aDestinationId > 0 )
+        {
+        for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ )
+            {
+            if ( iConnMethodItemArray[i].LinkedSnapId() == aDestinationId )
+                {
+                result = ETrue;
+                break;
+                }
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_EXIT );
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -329,12 +368,25 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmInstanceMapping::ConnMethodPointedToByVirtualIap(
-        const TUint32& /*aConnMethodId*/ ) const
+        const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_ENTRY );
-    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_EXIT );
 
-    return EFalse; //TODO, virtual IAPs are not yet supported.
+    TBool result( EFalse );
+    if ( aConnMethodId > 0 )
+        {
+        for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ )
+            {
+            if ( iConnMethodItemArray[i].LinkedIapId() == aConnMethodId )
+                {
+                result = ETrue;
+                break;
+                }
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_EXIT );
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -343,19 +395,33 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmInstanceMapping::ConnMethodInDestinationButLocked(
-        const TUint32& /*aConnMethodId*/,
-        const TUint32& /*aDestinationId*/ ) const
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY );
 
-    // - Find correct destination.
-    // - Check if it only has 1 CM.
-    // - Check if the CM is the one given.
-    // - Call DestinationPointedToByVirtualIap( aDestinationId ).
-    //
+    TBool result( EFalse );
+
+    // Find destination.
+    CDestination* destination( NULL );
+    destination = GetDestination( aDestinationId );
+
+    if ( destination )
+        {
+        // Check if the destination has only 1 IAP.
+        if ( destination->iConnMethodItemArray.Count() == 1 )
+            {
+            // Check if the IAP has given ID.
+            if ( destination->iConnMethodItemArray[0].iId == aConnMethodId )
+                {
+                // Check if this destination is linked from a virtual IAP.
+                result = DestinationPointedToByVirtualIap( aDestinationId );
+                }
+            }
+        }
+
     OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODINDESTINATIONBUTLOCKED_EXIT );
-
-    return EFalse; //TODO, virtual IAPs are not yet supported.
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -364,7 +430,7 @@
 // ---------------------------------------------------------------------------
 //
 TInt CCmmInstanceMapping::GetConnMethodBearerType(
-        const TUint32& aConnMethodId,
+        const TUint32 aConnMethodId,
         TUint32& bearerType ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODBEARERTYPE_ENTRY );
@@ -382,11 +448,14 @@
         }
     if ( result == KErrNotFound )
         {
-        // Embedded destinations are not in connection method array, need check from ID range.
+        // Embedded destinations are not in connection method array.
         if ( aConnMethodId > KCmmDestIdIntervalMin && aConnMethodId < KCmmDestIdIntervalMax )
             {
-            bearerType = KUidEmbeddedDestination;
-            result = KErrNone;
+            if ( ValidDestinationId( aConnMethodId ) )
+                {
+                bearerType = KUidEmbeddedDestination;
+                result = KErrNone;
+                }
             }
         }
 
@@ -401,7 +470,7 @@
 // ---------------------------------------------------------------------------
 //
 TInt CCmmInstanceMapping::DestinationsContainingConnMethod(
-        const TUint32& aConnMethodId ) const
+        const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODREFERENCECOUNT_ENTRY );
 
@@ -445,13 +514,61 @@
     }
 
 // ---------------------------------------------------------------------------
+// Returns the destination IDs containing the connection method given as
+// parameter.
+// ---------------------------------------------------------------------------
+//
+void CCmmInstanceMapping::DestinationsContainingConnMethodL(
+        const TUint32 aConnMethodId,
+        RArray<TUint32>& aDestinationIds ) const
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONSCONTAININGCONNMETHODL_ENTRY );
+    
+    aDestinationIds.Reset();
+    TInt count( 0 );
+    
+    // Go through each destination.
+    for ( TInt i = 0; i < iDestinations.Count(); i++ )
+        {
+        TBool foundInThisDestination( EFalse );
+
+        // Loop through all connection methods in this destination.
+        count = iDestinations[i]->iConnMethodItemArray.Count();
+        for ( TInt j = 0; j < count; j++ )
+            {
+            if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId )
+                {
+                foundInThisDestination = ETrue;
+                aDestinationIds.AppendL( iDestinations[i]->iId );
+                break;
+                }
+            }
+
+        // Check unsupported connection methods also.
+        if ( !foundInThisDestination )
+            {
+            count = iDestinations[i]->iUnsupportedConnMethods.Count();
+            for ( TInt j = 0; j < count; j++ )
+                {
+                if ( iDestinations[i]->iUnsupportedConnMethods[j] == aConnMethodId )
+                    {
+                    aDestinationIds.AppendL( iDestinations[i]->iId );
+                    break;
+                    }
+                }
+            }
+        }
+    
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONSCONTAININGCONNMETHODL_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
 // Get database session.
 // ---------------------------------------------------------------------------
 //
 CommsDat::CMDBSession& CCmmInstanceMapping::Session() const
     {
-    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_SESSION_ENTRY );
-
+    // No traces.
     return iCache.Session();
     }
 
@@ -468,14 +585,13 @@
             new( ELeave ) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord );
     CleanupStack::PushL( iapRecordSet );
 
-    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
+    CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
     CleanupStack::PushL( iapRecord );
 
     TRAP_IGNORE( iapRecordSet->LoadL( Session() ) );
 
-    //TODO, check from commsdat dump if all high-range IDs are available, or was some records
-    //TODO  used up by something. will this possibly affect cm/destination creation with predef ID? (Keijo)
-
+    // Clear the old info about IAPs.
     iConnMethodItemArray.Reset();
     iUnsupportedConnMethods.Reset();
 
@@ -488,25 +604,76 @@
         {
         TUint32 connMethodId( iapRecordSet->iRecords[i]->RecordId() );
 
-        // Check the connection method is not on the deleted list waiting to be deleted from database.
+        // Check the connection method is not on the deleted list waiting to be
+        // deleted from database.
         TInt indexInDeletedList = iDeletedConnMethods.FindInOrder( ( TUint )connMethodId );
         if ( indexInDeletedList == KErrNotFound )
             {
             // Check the bearer type of the iap. Leaves if iap is unsupported.
             iapRecord->SetRecordId( connMethodId );
-            TRAP( err, iCache.BearerInfoFromIapRecordL( iapRecord, bearerType, bearerPriority ) ); //TODO
+            TRAP( err, iCache.BearerInfoFromIapRecordL( iapRecord, bearerType, bearerPriority ) );
             if ( !err )
                 {
-                TCmmConnMethodItem item( connMethodId, bearerType, bearerPriority, 0 );
-                iConnMethodItemArray.Append( item ); // Ignore errors.
+                TBool isVirtual( EFalse );
+                TUint32 linkedIap( 0 );
+                TUint32 linkedSnap( 0 );
+
+                // BearerInfoFromIapRecordL() has called LoadL() for iapRecord.
+                if( TPtrC( KCDTypeNameVPNService ) == iapRecord->iServiceType )
+                    {
+                    isVirtual = ETrue;
+                    CCDVPNServiceRecord* serviceRecord = static_cast<CCDVPNServiceRecord*>(
+                            CCDRecordBase::RecordFactoryL( KCDTIdVPNServiceRecord ) );
+                    CleanupStack::PushL( serviceRecord );
+                    serviceRecord->SetRecordId( iapRecord->iService );
+                    serviceRecord->LoadL( Session() );
+
+                    // If neither link is set, or both are set, it is an error
+                    // but we ignore it. If both links are set, we use only the
+                    // SNAP link.
+                    if ( !serviceRecord->iServiceSNAP.IsNull() )
+                        {
+                        TUint32 apRecordId = serviceRecord->iServiceSNAP;
+                        if ( apRecordId != 0 )
+                            {
+                            CCDAccessPointRecord* apRecord = static_cast<CCDAccessPointRecord*>(
+                                    CCDRecordBase::RecordFactoryL( KCDTIdAccessPointRecord ) );
+                            apRecord->SetRecordId( apRecordId );
+                            TRAP( err, apRecord->LoadL( Session() ) );
+                            if ( !err )
+                                {
+                                linkedSnap = apRecord->iRecordTag;
+                                }
+                            }
+                        }
+                    if ( !linkedSnap && !serviceRecord->iServiceIAP.IsNull() )
+                        {
+                        linkedIap = serviceRecord->iServiceIAP;
+                        if ( linkedIap >= KCmmConnMethodIdIntervalMax )
+                            {
+                            linkedIap = ( linkedIap & KCDMaskShowRecordId ) >> KBitsInOneByte;
+                            }
+                        }
+
+                    CleanupStack::PopAndDestroy( serviceRecord );
+                    }
+                    TCmmConnMethodItem item(
+                            connMethodId,
+                            bearerType,
+                            bearerPriority,
+                            0,
+                            isVirtual,
+                            linkedIap,
+                            linkedSnap );
+                    iConnMethodItemArray.Append( item ); // Ignore errors.
                 }
             else if ( err == KErrNotSupported )
                 {
-                iUnsupportedConnMethods.Append( connMethodId ); // Ignore errors.
+                iUnsupportedConnMethods.InsertInOrder( ( TUint )connMethodId ); // Ignore errors.
                 }
             else if ( err == KErrNoMemory )
                 {
-                User::Leave( err ); //TODO, check what this will cause.
+                User::Leave( err );
                 }
             }
         }
@@ -514,6 +681,10 @@
     CleanupStack::PopAndDestroy( iapRecord );
     CleanupStack::PopAndDestroy( iapRecordSet );
 
+    // Check all virtual IAPs that link to an IAP. If the link is invalid
+    // (linked IAP not found), the IAP is removed.
+    ValidateVirtualIapsLinkingToIaps();
+
     OstTraceFunctionExit0( CCMMINSTANCEMAPPING_READANDVALIDATECONNMETHODSL_EXIT );
     }
 
@@ -561,26 +732,36 @@
             // If connMethodId and embeddedDestinationId are 0 this is a destination.
             if ( connMethodId == 0 && embeddedDestinationId == 0 )
                 {
-                TBool destAlreadyExists( EFalse );
-                for ( TInt j = 0; j < iDestinations.Count(); j++ )
-                    {
-                    if ( destinationId == iDestinations[j]->iId )
-                        {
-                        destAlreadyExists = ETrue;
-                        break;
-                        }
-                    }
-
+                TBool destAlreadyExists = ValidDestinationId( destinationId );
                 if ( !destAlreadyExists )
                     {
-                    CDestination* dest = CDestination::NewL();
-                    dest->iId = destinationId;
-                    iDestinations.Append( dest );
+                    CCDSNAPMetadataRecord* metadataRecord = new( ELeave ) CCDSNAPMetadataRecord(
+                            iCache.TableId( ECmmDestMetadataRecord ) );
+                    CleanupStack::PushL( metadataRecord );
+
+                    // Add destination metadata.
+                    metadataRecord->iSNAP.SetL( destinationId );
+                    if ( metadataRecord->FindL( Session() ) )
+                        {
+                        metadataRecord->LoadL( Session() );
+
+                        CDestination* dest = CDestination::NewLC();
+                        dest->iId = destinationId;
+                        dest->iMetadata = metadataRecord->iMetadata;
+                        iDestinations.AppendL( dest );
+                        CleanupStack::Pop( dest );
+                        }
+                    CleanupStack::PopAndDestroy( metadataRecord );
+                    metadataRecord = NULL;
                     }
                 }
             }
         }
 
+    // Check all virtual IAPs that link to a SNAP. If the link is invalid
+    // (linked SNAP not found), the IAP is removed.
+    ValidateVirtualIapsLinkingToSnaps();
+
     // Read snap ID, connection method ID and embedded destination ID.
     for ( TInt i = 0; i < snapRecordCount; i++ )
         {
@@ -596,14 +777,7 @@
             {
             // Find destination.
             CDestination* destination( NULL );
-            for ( TInt j = 0; j < iDestinations.Count(); j++ )
-                {
-                if ( destinationId == iDestinations[j]->iId )
-                    {
-                    destination = iDestinations[j];
-                    break;
-                    }
-                }
+            destination = GetDestination( destinationId );
 
             if ( destination )
                 {
@@ -633,7 +807,7 @@
                         if ( index == KErrNotFound )
                             {
                             item.iPriority = snapRecord->iPriority;
-                            destination->iConnMethodItemArray.InsertInOrderAllowRepeats( //TODO, if prio is 256, bearer type used? embeded should always be last.
+                            destination->iConnMethodItemArray.InsertInOrderAllowRepeats(
                                     item,
                                     connMethodItemOrderingLogic ); // Ignore errors.
                             }
@@ -641,17 +815,11 @@
                     else
                         {
                         // Check if the connection method is unsupported instead.
-                        for ( TInt j = 0; j < iUnsupportedConnMethods.Count(); j++ )
+                        TBool isUnsupported = UnsupportedConnMethodId( connMethodId );
+                        if ( isUnsupported )
                             {
-                            if ( iUnsupportedConnMethods[j] == connMethodId )
-                                {
-                                found = ETrue;
-                                break;
-                                }
-                            }
-                        if ( found )
-                            {
-                            destination->iUnsupportedConnMethods.Append( connMethodId ); // Ignore errors. //TODO, allow repeats?
+                            destination->iUnsupportedConnMethods.InsertInOrder(
+                                    ( TUint )connMethodId ); // Ignore errors.
                             }
                         }
                     }
@@ -663,16 +831,8 @@
                     if ( embeddedDestinationId != destinationId )
                         {
                         // Check embedded destination ID is valid.
-                        TBool found( EFalse );
-                        for ( TInt j = 0; j < iDestinations.Count(); j++ )
-                            {
-                            if ( embeddedDestinationId == iDestinations[j]->iId )
-                                {
-                                found = ETrue;
-                                break;
-                                }
-                            }
-                        if ( found )
+                        TBool valid = ValidDestinationId( embeddedDestinationId );
+                        if ( valid )
                             {
                             TCmmConnMethodItem item(
                                     embeddedDestinationId,
@@ -695,6 +855,106 @@
     }
 
 // ---------------------------------------------------------------------------
+// Goes through the internal IAP table, checking all virtual IAPs that link to
+// an IAP. If the linked IAP is not found, the virtual IAP is removed.
+// ---------------------------------------------------------------------------
+//
+void CCmmInstanceMapping::ValidateVirtualIapsLinkingToIaps()
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOIAPS_ENTRY );
+
+    for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ )
+        {
+        if ( iConnMethodItemArray[i].LinkedIapId() != 0 )
+            {
+            if ( !ValidConnMethodId( iConnMethodItemArray[i].LinkedIapId() ) )
+                {
+                iConnMethodItemArray.Remove( i );
+                i--; // Adjust counter.
+                }
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOIAPS_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// Goes through the internal IAP table, checking all virtual IAPs that link to
+// a SNAP. If the linked SNAP is not found, the virtual IAP is removed.
+// ---------------------------------------------------------------------------
+//
+void CCmmInstanceMapping::ValidateVirtualIapsLinkingToSnaps()
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOSNAPS_ENTRY );
+
+    for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ )
+        {
+        if ( iConnMethodItemArray[i].LinkedSnapId() != 0 )
+            {
+            if ( !ValidDestinationId( iConnMethodItemArray[i].LinkedSnapId() ) )
+                {
+                iConnMethodItemArray.Remove( i );
+                i--; // Adjust counter.
+                }
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOSNAPS_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// Find the destination item matching the provided destination ID.
+// Returns a pointer to the internal destination item, NULL if not found.
+// ---------------------------------------------------------------------------
+//
+CDestination* CCmmInstanceMapping::GetDestination( const TUint32 aDestinationId ) const
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETDESTINATION_ENTRY );
+
+    CDestination* destination( NULL );
+    if ( aDestinationId > 0 )
+        {
+        for ( TInt i = 0; i < iDestinations.Count(); i++ )
+            {
+            if ( iDestinations[i]->iId == aDestinationId )
+                {
+                destination = iDestinations[i];
+                break;
+                }
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETDESTINATION_EXIT );
+    return destination;
+    }
+
+// ---------------------------------------------------------------------------
+// Find and return a copy of a connection method item matching the given ID.
+// Returns KErrNotFound, if the connection method is not found.
+// ---------------------------------------------------------------------------
+//
+TInt CCmmInstanceMapping::GetConnMethodItem(
+        const TUint32 aConnMethodId,
+        TCmmConnMethodItem& aConnMethodItem ) const
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODITEM_ENTRY );
+
+    TInt result( KErrNotFound );
+    for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ )
+        {
+        if ( iConnMethodItemArray[i].iId == aConnMethodId )
+            {
+            aConnMethodItem = iConnMethodItemArray[i];
+            result = KErrNone;
+            break;
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODITEM_EXIT );
+    return result;
+    }
+
+// ---------------------------------------------------------------------------
 // Returns all conenction method IDs. Unsupported connection methods are
 // included if aCheckBearerType is set to EFalse.
 // ---------------------------------------------------------------------------
@@ -726,7 +986,7 @@
         // Include unsupported connection methods also.
         for ( TInt i = 0; i < iUnsupportedConnMethods.Count(); i++ )
             {
-            aConnMethodArray.AppendL( iUnsupportedConnMethods[i] );
+            aConnMethodArray.AppendL( ( TUint32 )iUnsupportedConnMethods[i] );
             }
         }
 
@@ -769,7 +1029,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmInstanceMapping::GetConnMethodsFromDestinationL(
-        const TUint32& aDestinationId,
+        const TUint32 aDestinationId,
         RArray<TCmmConnMethodItem>& aConnMethodArray ) const
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODSFROMDESTINATIONL_ENTRY );
@@ -805,8 +1065,8 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmInstanceMapping::ConnMethodInOtherDestination(
-        const TUint32& aConnMethodId,
-        const TUint32& aDestinationId )
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_ENTRY );
 
@@ -920,9 +1180,12 @@
 
         TUint32 metadata = metadataRecord->iMetadata;
 
-        TUint32 internet = metadata & CMManager::ESnapMetadataInternet;
-        TUint32 localizationValue = ( metadata & CMManager::ESnapMetadataDestinationIsLocalised ) >> 4;
-        TUint32 purposeValue = ( metadata & CMManager::ESnapMetadataPurpose ) >> 8;
+        TUint32 internet = metadata &
+                CMManager::ESnapMetadataInternet;
+        TUint32 localizationValue = ( metadata &
+                CMManager::ESnapMetadataDestinationIsLocalised ) >> 4;
+        TUint32 purposeValue = ( metadata &
+                CMManager::ESnapMetadataPurpose ) >> 8;
 
         // The first record that has a matching value in any of the 3 metadata
         // fields will be taken as the internet snap.
@@ -951,7 +1214,7 @@
 // has not been removed from database yet.
 // ---------------------------------------------------------------------------
 //
-void CCmmInstanceMapping::AddConnMethodToDeletedListL( const TUint& aConnMethodId )
+void CCmmInstanceMapping::AddConnMethodToDeletedListL( const TUint aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_ADDCONNMETHODTODELETEDLISTL_ENTRY );
 
@@ -968,7 +1231,7 @@
 // not found from the list.
 // ---------------------------------------------------------------------------
 //
-void CCmmInstanceMapping::RemoveConnMethodFromDeletedList( const TUint& aConnMethodId )
+void CCmmInstanceMapping::RemoveConnMethodFromDeletedList( const TUint aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDELETEDLIST_ENTRY );
 
@@ -988,7 +1251,7 @@
 // not been removed from database yet.
 // ---------------------------------------------------------------------------
 //
-void CCmmInstanceMapping::AddDestinationToDeletedListL( const TUint& aDestinationId )
+void CCmmInstanceMapping::AddDestinationToDeletedListL( const TUint aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_ADDDESTINATIONTODELETEDLISTL_ENTRY );
 
@@ -1005,7 +1268,7 @@
 // found from the list.
 // ---------------------------------------------------------------------------
 //
-void CCmmInstanceMapping::RemoveDestinationFromDeletedList( const TUint& aDestinationId ) //TODO, check removal is called in all necessary places.
+void CCmmInstanceMapping::RemoveDestinationFromDeletedList( const TUint aDestinationId ) //TODO, check removal is called in all necessary places.
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVEDESTINATIONFROMDELETEDLIST_ENTRY );
 
@@ -1024,7 +1287,7 @@
 // the connection method has been removed from database.
 // ---------------------------------------------------------------------------
 //
-void CCmmInstanceMapping::RemoveConnMethod( const TUint32& aConnMethodId ) //TODO, check where this is used and if it would be better to use version with array instead?
+void CCmmInstanceMapping::RemoveConnMethod( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHOD_ENTRY );
 
@@ -1058,12 +1321,14 @@
 // Remove the connection method from current destination/connection method
 // structures. This is a lot faster than calling Refresh(). Use this method if
 // the connection method has been removed from database.
+// Also adds the ID of any changed destinations to the provided array.
 // ---------------------------------------------------------------------------
 //
 void CCmmInstanceMapping::RemoveConnMethod(
-        const TUint32& aConnMethodId,
+        const TUint32 aConnMethodId,
         RArray<TUint32>& aChangedDestinations )
     {
+    OstTraceFunctionEntry0( DUP1_CCMMINSTANCEMAPPING_REMOVECONNMETHOD_ENTRY );
 
     // Remove from list of connection methods.
     for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ )
@@ -1089,7 +1354,8 @@
                 }
             }
         }
-
+    
+    OstTraceFunctionExit0( DUP1_CCMMINSTANCEMAPPING_REMOVECONNMETHOD_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1098,7 +1364,7 @@
 // the connection method has been removed from database.
 // ---------------------------------------------------------------------------
 //
-void CCmmInstanceMapping::RemoveDestination( const TUint32& aDestinationId )
+void CCmmInstanceMapping::RemoveDestination( const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVEDESTINATION_ENTRY );
 
@@ -1136,7 +1402,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmInstanceMapping::RemoveConnMethodFromDestinations(
-        const TUint32& aConnMethodId,
+        const TUint32 aConnMethodId,
         RArray<TUint32>& aChangedDestinations )
     {
     OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDESTINATIONS_ENTRY );
@@ -1159,4 +1425,28 @@
     OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDESTINATIONS_EXIT );
     }
 
+// ---------------------------------------------------------------------------
+// Iterate through destinations to find the one identified with parameter
+// and returns its metadata mask.
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmmInstanceMapping::DestinationMetadata( 
+        const TUint32 aDestinationId ) const
+    {
+    OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONMETADATA_ENTRY );
+
+    TUint32 metadata( 0 );
+    for ( TInt i = 0; i < iDestinations.Count(); i++ )
+        {
+        if ( iDestinations[i]->iId == aDestinationId )
+            {
+            metadata = iDestinations[i]->iMetadata;
+            break;
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONMETADATA_EXIT );
+    return metadata;
+    }
+
 // End of file
--- a/cmmanager/cmmgr/cmmserver/src/cmmserver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -34,29 +34,29 @@
 
 const TInt CCmmServer::iCmmRanges[iCmmRangeCount] =
     {
-    0,      //   0-10
-    11,     //  11-14
-    15,     //  15-21
-    22,     //  22-99
-    100,    // 100-112
-    113,    // 113-126
-    127,    // 127-199
-    200,    // 200-205
-    206,    // 206-210
-    211,    // 211-214
-    215,    // 215-220
-    221     // 221-KMaxInt
+    0,      //  1.   0-11
+    12,     //  2.  12-15
+    16,     //  3.  16-22
+    23,     //  4.  23-99
+    100,    //  5. 100-113
+    114,    //  6. 114-128
+    129,    //  7. 129-199
+    200,    //  8. 200-205
+    206,    //  9. 206-210
+    211,    // 10. 211-214
+    215,    // 11. 215-220
+    221     // 12. 221-KMaxInt
     };
 
 const TUint8 CCmmServer::iCmmElementIndex[iCmmRangeCount] =
     {
-    CPolicyServer::EAlwaysPass,     // 0-10
-    CPolicyServer::ECustomCheck,    // 11-14
-    CPolicyServer::ECustomCheck,    // 15-21
-    CPolicyServer::ENotSupported,   // 22-99
-    CPolicyServer::EAlwaysPass,     // 100-112
-    CPolicyServer::ECustomCheck,    // 113-126
-    CPolicyServer::ENotSupported,   // 127-199
+    CPolicyServer::EAlwaysPass,     // 0-11
+    CPolicyServer::ECustomCheck,    // 12-15
+    CPolicyServer::ECustomCheck,    // 16-22
+    CPolicyServer::ENotSupported,   // 23-99
+    CPolicyServer::EAlwaysPass,     // 100-113
+    CPolicyServer::ECustomCheck,    // 114-128
+    CPolicyServer::ENotSupported,   // 129-199
     CPolicyServer::EAlwaysPass,     // 200-205
     CPolicyServer::ECustomCheck,    // 206-210
     CPolicyServer::ECustomCheck,    // 211-214
@@ -73,12 +73,12 @@
     {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl), CPolicyServer::EFailClient},
     };
 
-const CPolicyServer::TPolicy CCmmServer::iCmmPolicy = //TODO, check comments
+const CPolicyServer::TPolicy CCmmServer::iCmmPolicy =
     {
     CPolicyServer::EAlwaysPass, // Specifies all connect attempts should pass
     iCmmRangeCount,     // Count of ranges
-    iCmmRanges,         // 0-999, 1000-1008, 1009...
-    iCmmElementIndex,   // Only range 1000-1008 are checked
+    iCmmRanges,         // 0-11, 12-15, 16...
+    iCmmElementIndex,   // What to do for each range
     iCmmElements        // The list of policy elements
     };
 
@@ -96,7 +96,7 @@
     {
     switch ( aMessage.Function() )
         {
-        // ***********  2nd range: 11-14 *************
+        // ***********  2nd range: 12-15 *************
         case ECmmGetConnMethodInfoInt:
         case ECmmGetConnMethodInfoBool:
         case ECmmGetConnMethodInfoString:
@@ -127,7 +127,7 @@
                 case CMManager::EWlanWapiPsk:
                 case CMManager::EWlanWapiPskFormat:
                 // 802.1x:
-                case CMManager::EWlan802_1xAllowUnencrypted: //TODO, should this be here?
+                case CMManager::EWlan802_1xAllowUnencrypted:
                 // Authentication:
                 case CMManager::ECmIFAuthName:
                 case CMManager::EPacketDataIFAuthName:
@@ -139,38 +139,31 @@
                         EPass : EFail;
                     }
                 default:
-                    // By default reading does not need any capabilities
+                    // By default reading does not need any capabilities.
                     return EPass;
                 }
             }
-        // ***********  3rd range: 15-21 *************
+        // ***********  3rd range: 16-22 *************
         case ECmmUpdateBearerPriorityArray:
         case ECmmWriteDefaultConnection:
         case ECmmWriteGeneralConnectionSettings:
+        // At this phase all capabilities are not checked because of
+        // it's too heavy operation...
+        // At Session phase the protection of the destination and/or
+        // connection method is checked. If protected, 
+        // ECapabilityNetworkControl is checked.
+        case ECmmCopyConnMethod:
+        case ECmmMoveConnMethod:
+        case ECmmRemoveConnMethod:
+        case ECmmRemoveAllReferences:
             {
             // ECapabilityWriteDeviceData is needed for writing
             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
                 EPass : EFail;
             }
-        case ECmmCopyConnMethod:
-        case ECmmMoveConnMethod:
-        case ECmmRemoveConnMethod:
-        case ECmmRemoveAllReferences:
-            {
-            // At this phase capability is not checked because of
-            // it's too heavy operation...
-            // At later phase the protection of the target destination
-            // and/or connection method is checked.
-            return EPass;
-            }
-        // ***********  6th range: 113-126 *************
+        // ***********  6th range: 114-128 *************
         case EDestCreateDestinationWithName:
         case EDestCreateDestinationWithNameAndId:
-            {
-            // ECapabilityWriteDeviceData is needed for writing
-            return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
-                EPass : EFail;
-            }
         case EDestIsConnected:
         case EDestAddConnMethod:
         case EDestAddEmbeddedDestination:
@@ -183,34 +176,32 @@
         case EDestSetHidden:
         case EDestUpdate:
         case EDestDelete:
-            {
-            // At this phase capability is not checked because of
-            // it's too heavy operation...
-            // At Session phase the protection of the destination and/or
-            // connection method is checked. If destination/connection method
-            // is protected ECapabilityNetworkControl is required from a
-            // client.
-            return EPass;
-            }
-        // ***********  9th range: 206-210 *************
-        case ECMCreateConnMethod:
-        case ECMCreateConnMethodWithId:
+        case EDestSetIcon:
             {
             // ECapabilityWriteDeviceData is needed for writing
             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
                 EPass : EFail;
             }
+        // ***********  9th range: 206-210 *************
+
+        // ECapabilityWriteDeviceData is needed for writing
+        case ECMCreateConnMethod:
+        case ECMCreateConnMethodWithId:
+        
+        // At this phase all capabilities are not checked because of
+        // it's too heavy operation...
+        // At Session phase the protection of the destination and/or
+        // connection method is checked. If protected, 
+        // ECapabilityNetworkControl is checked.
         case ECMCreateConnMethodToDest:
         case ECMCreateConnMethodToDestWithId:
         case ECMCreateCopyOfExisting:
             {
-            // At this phase capability is not checked because of
-            // it's too heavy operation...
-            // At Session phase the protection of the destination and/or
-            // connection method is checked.
-            return EPass;
+            return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
+                EPass : EFail;
             }
         // ***********  11th range: 215-220 *************
+        // Protection of the CM is checked later(protected needs ECapabilityNetworkControl)
         case ECMSetIntAttribute:
         case ECMSetBoolAttribute:
         case ECMSetStringAttribute:
@@ -235,7 +226,7 @@
                 case CMManager::EWlanWapiPsk:
                 case CMManager::EWlanWapiPskFormat:
                 // 802.1x:
-                case CMManager::EWlan802_1xAllowUnencrypted: //TODO, should this be here?
+                case CMManager::EWlan802_1xAllowUnencrypted:
                 // Authentication:
                 case CMManager::ECmIFAuthName:
                 case CMManager::EPacketDataIFAuthName:
@@ -257,7 +248,8 @@
         case ECMDelete:
         case ECMUpdate:
             {
-            // ECapabilityWriteDeviceData
+            // ECapabilityWriteDeviceData (if protected, ECapabilityNetworkControl
+            // is checked later).
             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
                 EPass : EFail;
             }
@@ -266,6 +258,50 @@
         }
     }
 
+/**
+ * This is for checking client's capabilities at later phase after
+ * protections of destination/connection method have been checked
+ * first.
+ */
+CPolicyServer::TCustomResult CCmmServer::CapabilityCheckWithProtection( 
+        const RMessage2& aMessage )
+    {
+    switch ( aMessage.Function() )
+        {
+        case ECmmCopyConnMethod:
+        case ECmmMoveConnMethod:
+        case ECmmRemoveConnMethod:
+        case ECmmRemoveAllReferences:
+        case EDestAddConnMethod:
+        case EDestDeleteConnMethod:
+        case EDestAddEmbeddedDestination:
+        case EDestRemoveConnMethod:
+        case EDestModifyPriority:
+        case EDestSetName:
+        case EDestSetMetadata:
+        case EDestSetProtection:
+        case EDestSetHidden:
+        case EDestUpdate:
+        case EDestDelete:
+        case EDestSetIcon:
+        case ECMCreateConnMethodToDest:
+        case ECMCreateConnMethodToDestWithId:
+        case ECMUpdate:
+        case ECMDelete:
+        case ECMSetIntAttribute:
+        case ECMSetBoolAttribute:
+        case ECMSetStringAttribute:
+        case ECMSetString8Attribute:
+            {
+            // ECapabilityNetworkControl
+            return ( iCmmElements[3].iPolicy.CheckPolicy( aMessage ) ) ? EPass : EFail;
+            }
+        default:
+            // Execution should never come here.
+            return EFail;
+        }
+    }
+
 CCmmServer::CCmmServer( TInt aPriority ) : CPolicyServer( aPriority, iCmmPolicy )
     {
     OstTraceFunctionEntry0( CCMMSERVER_CCMMSERVER_ENTRY );
@@ -340,7 +376,12 @@
     {
     OstTraceFunctionEntry0( CCMMSERVER_NEWSESSIONL_ENTRY );
 
-    return CCmmSession::NewL( *const_cast<CCmmServer*>( this ), iCmManager->Cache() );
+    CSession2* session = CCmmSession::NewL(
+            *const_cast<CCmmServer*>( this ),
+            iCmManager->Cache() );
+
+    OstTraceFunctionExit0( CCMMSERVER_NEWSESSIONL_EXIT );
+    return session;
     }
 
 // -----------------------------------------------------------------------------
@@ -376,6 +417,7 @@
             iShutdown->Start();
             }
         }
+
     OstTraceFunctionExit0( CCMMSERVER_DECREMENTSESSIONS_EXIT );
     }
 
@@ -387,7 +429,10 @@
     {
     OstTraceFunctionEntry0( CCMMSERVER_NEWCONTAINERL_ENTRY );
 
-    return iContainerIndex->CreateL();
+    CObjectCon* container = iContainerIndex->CreateL();
+
+    OstTraceFunctionExit0( CCMMSERVER_NEWCONTAINERL_EXIT );
+    return container;
     }
 
 // -----------------------------------------------------------------------------
@@ -419,7 +464,6 @@
     ReStart();
 
     OstTraceFunctionExit0( CCMMSERVER_RUNERROR_EXIT );
-
     return KErrNone;
     }
 
@@ -446,8 +490,8 @@
 // -----------------------------------------------------------------------------
 //
 TBool CCmmServer::EmbeddedDestinationConflictsFromAllSessions(
-        const TUint32& aDestinationId,
-        const TUint32& aEmbeddedDestinationId )
+        const TUint32 aDestinationId,
+        const TUint32 aEmbeddedDestinationId )
     {
     OstTraceFunctionEntry0( CCMMSERVER_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY );
 
@@ -475,7 +519,7 @@
 // updated to, or deleted from, database.
 // ---------------------------------------------------------------------------
 //
-void CCmmServer::RefreshHandlesForAllSessions( const TUint32& aId )
+void CCmmServer::RefreshHandlesForAllSessions( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMSERVER_REFRESHHANDLESFORALLSESSIONS_ENTRY );
 
--- a/cmmanager/cmmgr/cmmserver/src/cmmsession.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmsession.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,7 @@
 *
 */
 
-
+#include <sysutil.h>
 #include <cmconnectionmethoddef.h>
 #include <cmpluginembdestinationdef.h>
 #include <cmdefconnvalues.h>
@@ -63,7 +63,8 @@
 CCmmSession::CCmmSession( CCmmServer& aServer, CCmmCache& aCache )
         :
         iServer( aServer ),
-        iCache( aCache )
+        iCache( aCache ),
+        iFsConnected( EFalse )
     {
     OstTraceFunctionEntry0( CCMMSESSION_CCMMSESSION_ENTRY );
 
@@ -128,6 +129,13 @@
         iServer.RemoveContainer( iConnMethodContainer );
         iConnMethodContainer = NULL;
         }
+
+    if ( iFsConnected )
+        {
+        iFs.Close();
+        iFsConnected = EFalse;
+        }
+
     OstTraceFunctionExit0( DUP1_CCMMSESSION_CCMMSESSION_EXIT );
     }
 
@@ -207,6 +215,11 @@
             GetSupportedBearersL( aMessage );
             }
             break;
+        case ECmmGetUncategorizedIcon:
+            {
+            GetUncategorizedIconL( aMessage );
+            }
+            break;
         case ECmmReadDefaultConnection:
             {
             ReadDefaultConnectionL( aMessage );
@@ -269,6 +282,7 @@
         case EDestIsConnected:
         case EDestIsHidden:
         case EDestIsEqual:
+        case EDestGetIcon:
         case EDestAddConnMethod:
         case EDestAddEmbeddedDestination:
         case EDestDeleteConnMethod:
@@ -280,6 +294,7 @@
         case EDestSetHidden:
         case EDestUpdate:
         case EDestDelete:
+        case EDestSetIcon:
             {
             ServiceDestinationL( aMessage );
             }
@@ -329,7 +344,7 @@
 // -----------------------------------------------------------------------------
 //
 CCmmConnMethodInstance* CCmmSession::FindConnMethodInstanceById(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMSESSION_FINDCONNMETHODINSTANCEBYID_ENTRY );
 
@@ -356,7 +371,7 @@
 // -----------------------------------------------------------------------------
 //
 CCmmDestinationInstance* CCmmSession::FindDestinationInstanceByHandleL(
-        const TInt& aDestinationHandle )
+        const TInt aDestinationHandle )
     {
     OstTraceFunctionEntry0( CCMMSESSION_FINDDESTINATIONINSTANCEBYHANDLEL_ENTRY );
 
@@ -369,7 +384,7 @@
 // -----------------------------------------------------------------------------
 //
 CCmmDestinationInstance* CCmmSession::FindDestinationInstanceById(
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMSESSION_FINDDESTINATIONINSTANCEBYID_ENTRY );
 
@@ -396,8 +411,8 @@
 // -----------------------------------------------------------------------------
 //
 TBool CCmmSession::ConnMethodInOtherDestination(
-        const TUint32& aConnMethodId,
-        const TUint32& aDestinationId )
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMSESSION_CONNMETHODINOTHERDESTINATION_ENTRY );
 
@@ -432,12 +447,14 @@
 // -----------------------------------------------------------------------------
 //
 TBool CCmmSession::EmbeddedDestinationConflictsFromAllSessions(
-        const TUint32& aDestinationId,
-        const TUint32& aEmbeddedDestinationId )
+        const TUint32 aDestinationId,
+        const TUint32 aEmbeddedDestinationId )
     {
     OstTraceFunctionEntry0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY );
 
-    return iServer.EmbeddedDestinationConflictsFromAllSessions( aDestinationId, aEmbeddedDestinationId );
+    return iServer.EmbeddedDestinationConflictsFromAllSessions(
+            aDestinationId,
+            aEmbeddedDestinationId );
     }
 
 // -----------------------------------------------------------------------------
@@ -455,8 +472,8 @@
 // -----------------------------------------------------------------------------
 //
 TBool CCmmSession::EmbeddedDestinationConflicts(
-        const TUint32& aDestinationId,
-        const TUint32& aEmbeddedDestinationId )
+        const TUint32 aDestinationId,
+        const TUint32 aEmbeddedDestinationId )
     {
     OstTraceFunctionEntry0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTS_ENTRY );
 
@@ -562,7 +579,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmSession::RemoveConnMethodFromDestinationHandles(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMSESSION_REMOVECONNMETHODFROMDESTINATIONHANDLES_ENTRY );
 
@@ -591,7 +608,7 @@
 // updated/deleted destination/connection method.
 // ---------------------------------------------------------------------------
 //
-void CCmmSession::RefreshHandles( const TUint32& aId ) const
+void CCmmSession::RefreshHandles( const TUint32 aId ) const
     {
     OstTraceFunctionEntry0( CCMMSESSION_REFRESHHANDLES_ENTRY );
 
@@ -682,7 +699,7 @@
     CleanupStack::PushL( result );
 
     TInt bufferLen = aMessage.GetDesMaxLength( 2 );
-    if ( result && result->Length() > bufferLen )
+    if ( result->Length() > bufferLen )
         {
         User::Leave( KErrArgument );
         }
@@ -714,7 +731,7 @@
     CleanupStack::PushL( result );
 
     TInt bufferLen = aMessage.GetDesMaxLength( 2 );
-    if ( result && result->Length() > bufferLen )
+    if ( result->Length() > bufferLen )
         {
         User::Leave( KErrArgument );
         }
@@ -782,7 +799,7 @@
     CleanupStack::PushL( result );
 
     TInt bufferLen = aMessage.GetDesMaxLength( 2 );
-    if ( result && result->Length() > bufferLen )
+    if ( result->Length() > bufferLen )
         {
         User::Leave( KErrArgument );
         }
@@ -814,7 +831,7 @@
     CleanupStack::PushL( result );
 
     TInt bufferLen = aMessage.GetDesMaxLength( 2 );
-    if ( result && result->Length() > bufferLen )
+    if ( result->Length() > bufferLen )
         {
         User::Leave( KErrArgument );
         }
@@ -1017,6 +1034,29 @@
     }
 
 // -----------------------------------------------------------------------------
+// CCmmSession::GetUncategorizedIconL
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::GetUncategorizedIconL( const RMessage2& aMessage )
+    {
+    OstTraceFunctionEntry0( CCMMSESSION_GETUNCATEGORIZEDICONL_ENTRY );
+
+    HBufC* result = KCmmUncategorizedIconName().AllocLC();
+
+    TInt bufferLen = aMessage.GetDesMaxLength( 0 );
+    if ( result->Length() > bufferLen )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TPtrC resultPtr = result->Des();
+    aMessage.WriteL( 0, resultPtr );
+    CleanupStack::PopAndDestroy( result );
+
+    OstTraceFunctionExit0( CCMMSESSION_GETUNCATEGORIZEDICONL_EXIT );
+    }
+
+// -----------------------------------------------------------------------------
 // CCmmSession::ReadDefaultConnectionL
 // -----------------------------------------------------------------------------
 //
@@ -1103,7 +1143,8 @@
     for ( TInt i = 0; i < bearerCountInArray; i++ )
         {
         // Skip if service type is not valid.
-        if ( bearerPriorityArray[i]->ServiceType() && bearerPriorityArray[i]->ServiceType()->Length() > 0 )
+        if ( bearerPriorityArray[i]->ServiceType() &&
+                bearerPriorityArray[i]->ServiceType()->Length() > 0 )
             {
             maxBufLen += KCmmBearerPriorityHeaderLength; // Priorities and servicetype length.
             maxBufLen += bearerPriorityArray[i]->ServiceType()->Length();
@@ -1141,7 +1182,8 @@
     for ( TInt i = 0; i < bearerCountInArray; i++ )
         {
         // Skip if service type is not valid.
-        if ( bearerPriorityArray[i]->ServiceType() && bearerPriorityArray[i]->ServiceType()->Length() > 0 )
+        if ( bearerPriorityArray[i]->ServiceType() &&
+                bearerPriorityArray[i]->ServiceType()->Length() > 0 )
             {
             TUint32 priority = bearerPriorityArray[i]->Priority();
             TUint32 uiPriority = bearerPriorityArray[i]->UiPriority();
@@ -1173,6 +1215,12 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_UPDATEBEARERPRIORITYARRAYL_ENTRY );
 
+    // Check the disk space.
+    if ( CheckSpaceBelowCriticalLevelL() )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
     HBufC* bearerPriorityBuf = HBufC::NewLC( aMessage.GetDesMaxLengthL( 0 ) );
     TPtr bearerPriorityBufPtr( bearerPriorityBuf->Des() );
 
@@ -1213,7 +1261,10 @@
             position += stringLength;
 
             TPtrC tempServiceType( serviceName->Des() );
-            CCmmBearerPriority* item = CCmmBearerPriority::NewLC( tempServiceType, priority, uiPriority );
+            CCmmBearerPriority* item = CCmmBearerPriority::NewLC(
+                    tempServiceType,
+                    priority,
+                    uiPriority );
             bearerPriorityArray.AppendL( item );
             CleanupStack::Pop( item );
 
@@ -1240,8 +1291,16 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_COPYCONNMETHODL_ENTRY );
 
-    CCmmDestinationInstance* destination = ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() );
-    CCmmConnMethodInstance* connMethod = ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() );
+    // Check the disk space.
+    if ( CheckSpaceBelowCriticalLevelL() )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    CCmmDestinationInstance* destination =
+            ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() );
+    CCmmConnMethodInstance* connMethod =
+            ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() );
 
     // Can't add an embedded destination this way.
     if ( connMethod->IsEmbeddedDestination() )
@@ -1249,7 +1308,20 @@
         User::Leave( KErrArgument );
         }
 
-    //TODO, capability check, what to do if anything is protected.
+    // Check the protection level of the destination.
+    // And based on that check the needed capabilities from the client.
+    CMManager::TProtectionLevel protLevel( CMManager::EProtLevel0 );
+    destination->GetProtectionL( protLevel );
+    CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+    if ( protLevel == CMManager::EProtLevel1 )
+        {
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        }
+
+    if ( capabilities == CPolicyServer::EFail )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
 
     // Add connection method into destination.
     TInt index = destination->AddConnMethodL( *connMethod );
@@ -1274,6 +1346,12 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_MOVECONNMETHODL_ENTRY );
 
+    // Check the disk space.
+    if ( CheckSpaceBelowCriticalLevelL() )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
     // Read data from client request.
     TPckgBuf<TCmmIpcStructMoveConnMethod> attributesPckg;
     aMessage.ReadL( 0, attributesPckg );
@@ -1313,7 +1391,38 @@
         User::Leave( KErrInUse );
         }
 
-    //TODO, capability checks, what to do if anything is protected.
+    // Check the protection level of the source and target destination.
+    // And based on those check the needed capabilities from the client.
+    TBool protectionExists( EFalse );
+    CMManager::TProtectionLevel protLevelSource( CMManager::EProtLevel0 );
+    sourceDestination->GetProtectionL( protLevelSource );
+    if ( protLevelSource == CMManager::EProtLevel1 
+            || protLevelSource == CMManager::EProtLevel3 )
+        {
+        protectionExists = ETrue;
+        }
+
+    // If source destination is not protected check the target destination.
+    if ( !protectionExists )
+        {
+        CMManager::TProtectionLevel protLevelTarget( CMManager::EProtLevel0 );
+        targetDestination->GetProtectionL( protLevelTarget );
+        if ( protLevelTarget == CMManager::EProtLevel1 )
+            {
+            protectionExists = ETrue;
+            }
+        }
+
+    CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+    if ( protectionExists )
+        {
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        }
+
+    if ( capabilities == CPolicyServer::EFail )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
 
     // Add connection method into target destination and update it.
     attributesPckg().iIndex = targetDestination->AddConnMethodL( *connMethod );
@@ -1343,7 +1452,20 @@
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() );
 
-    //TODO, capability checks
+    // Check the protection level of the destination.
+    // And based on that check the needed capabilities from the client.
+    CMManager::TProtectionLevel protLevel( CMManager::EProtLevel0 );
+    destinationInstance->GetProtectionL( protLevel );
+    CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+    if ( protLevel == CMManager::EProtLevel1 || protLevel == CMManager::EProtLevel3 )
+        {
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        }
+
+    if ( capabilities == CPolicyServer::EFail )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
 
     destinationInstance->RemoveConnMethodFromDestinationL( *connMethodInstance );
     destinationInstance->UpdateL();
@@ -1363,6 +1485,20 @@
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
 
+    TBool capabilityCheckNeeded( EFalse );
+    iCache.CheckIfConnMethodBelongsToProtectedDestinationL(
+            *connMethodInstance,
+            capabilityCheckNeeded );
+    if ( capabilityCheckNeeded )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     iCache.CheckIfConnMethodReferencesCanBeRemovedL( *connMethodInstance );
     iCache.RemoveAllReferencesToConnMethodL( *connMethodInstance );
 
@@ -1454,6 +1590,11 @@
             DestinationIsEqualL( aMessage );
             }
             break;
+        case EDestGetIcon:
+            {
+            GetDestinationIconL( aMessage );
+            }
+            break;
         case EDestAddConnMethod:
             {
             DestAddConnMethodL( aMessage );
@@ -1509,6 +1650,11 @@
             DeleteDestinationL( aMessage );
             }
             break;
+        case EDestSetIcon:
+            {
+            SetDestinationIconL( aMessage );
+            }
+            break;
         default:
             {
             User::Leave( KErrNotSupported );
@@ -1685,10 +1831,12 @@
         }
 
     // Check if a destination with given ID exists (or is already created but not saved).
-    if ( iCache.DestinationExistsWithId( destinationId ) ||
-            iCache.DestinationOpenWithId( destinationId ) )
+    //TODO, Implement one single method for this check in CCmmCache-class, and call that. CCmmCache::DestinationOpenWithId() can be removed after that.
+    if ( iCache.DestinationExistsWithId( destinationId ) || iCache.DestinationOpenWithId( destinationId ) )
         {
         User::Leave( KErrAlreadyExists );
+        //TODO: Destination ID is decided based on network record ID. Connection methods also use network records.
+        //TODO: Add a check here too see that the necessary network record ID is also available.
         }
 
     // Load and check name.
@@ -1804,12 +1952,19 @@
     User::LeaveIfError( index );
 
     // Check if the connection method is an embedded destination.
-    if ( connMethodInstance->GetBearerType() == KUidEmbeddedDestination )
+    if ( connMethodInstance->IsEmbeddedDestination() )
         {
         index = CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
         }
 
-    //TODO, what if CM is virtual?
+    // If this is a virtual IAP that doesn't link to an IAP, the priority is wildcard.
+    else if ( connMethodInstance->GetBoolAttributeL( CMManager::ECmVirtual ) )
+        {
+        if ( connMethodInstance->GetIntAttributeL( CMManager::ECmNextLayerIapId ) == 0 )
+            {
+            index = CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
+            }
+        }
 
     TUint priority = ( TUint )index;
     TPckg<TUint> priorityPckg( priority );
@@ -1847,6 +2002,33 @@
     }
 
 // -----------------------------------------------------------------------------
+// CCmmSession::GetDestinationIconL
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::GetDestinationIconL( const RMessage2& aMessage )
+    {
+    OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONICONL_ENTRY );
+
+    CCmmDestinationInstance* destinationInstance =
+            ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+    HBufC* icon = destinationInstance->GetDestinationIconL();
+    CleanupStack::PushL( icon );
+    TPtrC iconPtr( icon->Des() );
+
+    TInt bufferLen = aMessage.GetDesMaxLength( 0 );
+    if ( iconPtr.Length() > bufferLen )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    aMessage.WriteL( 0, iconPtr );
+    CleanupStack::PopAndDestroy( icon );
+
+    OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONICONL_EXIT );
+    }
+
+// -----------------------------------------------------------------------------
 // CCmmSession::GetDestinationIdL
 // -----------------------------------------------------------------------------
 //
@@ -2012,6 +2194,20 @@
 
     CCmmDestinationInstance* destination =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destination->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     CCmmConnMethodInstance* connMethod =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
 
@@ -2035,12 +2231,26 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_DESTADDEMBEDDEDDESTINATIONL_ENTRY );
 
-    CCmmDestinationInstance* destination =
+    CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel = 
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     CCmmDestinationInstance* embeddedDestination =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() );
 
-    TInt index = destination->AddEmbeddedDestinationL( *embeddedDestination );
+    TInt index = destinationInstance->AddEmbeddedDestinationL( *embeddedDestination );
     TPckg<TInt> indexPckg( index );
     aMessage.WriteL( 1, indexPckg );
 
@@ -2059,8 +2269,25 @@
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
-
-    //TODO, capability checks
+    
+    // Check the protection of destination and if protected check the needed
+    // capabilities.
+    CMManager::TProtectionLevel protLevel = 
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel3 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
+    // Check the protection of CM and if protected check the needed
+    // capabilities.
+    CheckCapabilitiesForProtectedCML( aMessage, connMethodInstance );
 
     destinationInstance->DeleteConnMethodFromDestinationL( *connMethodInstance );
 
@@ -2080,7 +2307,20 @@
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
 
-    //TODO, capability checks
+    // Check the protection of destination and if protected check the needed
+    // capabilities.
+    CMManager::TProtectionLevel protLevel = 
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel3 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
 
     destinationInstance->RemoveConnMethodFromDestinationL( *connMethodInstance );
 
@@ -2097,11 +2337,25 @@
 
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+    // Check the protection of destination and if protected check the needed
+    // capabilities.
+    CMManager::TProtectionLevel protLevel = 
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel3 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
 
-    //TODO, capability checks
-
     // Index values start from 0 (0 meaning highest priority).
     TUint index( ( TUint )aMessage.Int1() );
 
@@ -2121,6 +2375,28 @@
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
 
+    // Check that client does not try to change the name of the Internet Destination.
+    TUint32 metadata( 0 );
+    destinationInstance->GetMetadataL( CMManager::ESnapMetadataPurpose, metadata );
+    if ( metadata == CMManager::ESnapPurposeInternet )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
+
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel2 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     // Load and check name.
     TInt destNameLength = aMessage.GetDesLength( 0 );
     if ( destNameLength <= 0 )
@@ -2147,6 +2423,48 @@
     }
 
 // -----------------------------------------------------------------------------
+// CCmmSession::SetDestinationIconL
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::SetDestinationIconL( const RMessage2& aMessage )
+    {
+    OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONICONL_ENTRY );
+
+    CCmmDestinationInstance* destinationInstance =
+            ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel2 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
+    // Load and check name.
+    TInt destIconNameLength = aMessage.GetDesLength( 0 );
+    if ( destIconNameLength < 0 || destIconNameLength > KCmmStringLengthMax )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    HBufC* newIconName = HBufC::NewLC( destIconNameLength );
+    TPtr ptrNewIconName = newIconName->Des();
+    aMessage.ReadL( 0, ptrNewIconName );
+
+    destinationInstance->SetDestinationIconL( *newIconName );
+    CleanupStack::PopAndDestroy( newIconName );
+
+    OstTraceFunctionExit0( CCMMSESSION_SETDESTINATIONICONL_EXIT );
+    }
+
+// -----------------------------------------------------------------------------
 // CCmmSession::SetDestinationMetadataL
 // -----------------------------------------------------------------------------
 //
@@ -2154,11 +2472,23 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONMETADATAL_ENTRY );
 
-    //TODO, Capability check. Protection level or Internet destination.
-
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
 
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel2 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     CMManager::TSnapMetadataField metadataField =
             ( CMManager::TSnapMetadataField )aMessage.Int0();
     TUint32 metadata = aMessage.Int1();
@@ -2176,7 +2506,13 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONPROTECTIONL_ENTRY );
 
-    //TODO, Capability check: ECapabilityNetworkControl
+    // Check the needed capabilities.
+    CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+    capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+    if ( capabilities == CPolicyServer::EFail )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
 
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
@@ -2198,6 +2534,20 @@
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
 
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+            protLevel == CMManager::EProtLevel2 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     TBool hidden = aMessage.Int0();
     destinationInstance->SetMetadataL( CMManager::ESnapMetadataHiddenAgent, hidden );
 
@@ -2212,8 +2562,30 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_UPDATEDESTINATIONL_ENTRY );
 
+    // Check the disk space.
+    if ( CheckSpaceBelowCriticalLevelL() )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+    // Check the protection and if protected check the needed capabilities
+    CMManager::TProtectionLevel protLevel =
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+         protLevel == CMManager::EProtLevel2 ||
+         protLevel == CMManager::EProtLevel3 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     destinationInstance->UpdateL();
 
     OstTraceFunctionExit0( CCMMSESSION_UPDATEDESTINATIONL_EXIT );
@@ -2230,6 +2602,22 @@
     CCmmDestinationInstance* destinationInstance =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
 
+    // Check the protection of destination and if protected check the needed
+    // capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destinationInstance->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 ||
+         protLevel == CMManager::EProtLevel2 ||
+         protLevel == CMManager::EProtLevel3 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     iCache.CheckIfDestinationCanBeDeletedL( *destinationInstance );
     iCache.DeleteDestinationL( *destinationInstance );
 
@@ -2380,13 +2768,14 @@
 
     TUint32 bearerType( aMessage.Int0() );
 
-    CCmmConnMethodInstance* connMethod = CCmmConnMethodInstance::NewLC( this, &iCache );
-    iCache.CreateConnMethodL( *connMethod, NULL, bearerType, 0 );
-
-    iConnMethodContainer->AddL( ( CObject* ) connMethod );
-    TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethod );
-    connMethod->SetHandle( handle );
-    CleanupStack::Pop( connMethod );
+    CCmmConnMethodInstance* connMethodInstance =
+            CCmmConnMethodInstance::NewLC( this, &iCache );
+    iCache.CreateConnMethodL( *connMethodInstance, NULL, bearerType, 0 );
+
+    iConnMethodContainer->AddL( ( CObject* ) connMethodInstance );
+    TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethodInstance );
+    connMethodInstance->SetHandle( handle );
+    CleanupStack::Pop( connMethodInstance );
 
     TPckg<TInt> handlePckg( handle );
     TInt error = aMessage.Write( 3, handlePckg );
@@ -2408,9 +2797,19 @@
     {
     OstTraceFunctionEntry0( CCMMSESSION_UPDATECONNMETHODL_ENTRY );
 
-    CCmmConnMethodInstance* connMethod =
+    // Check the disk space.
+    if ( CheckSpaceBelowCriticalLevelL() )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
-    connMethod->UpdateL();
+
+    // Check if the Client has capabilities to modify this CM.
+    CheckCapabilitiesForProtectedCML( aMessage, connMethodInstance );
+
+    connMethodInstance->UpdateL();
 
     OstTraceFunctionExit0( CCMMSESSION_UPDATECONNMETHODL_EXIT );
     }
@@ -2435,7 +2834,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CCmmSession::ConnMethodUpdateL
+// CCmmSession::DeleteConnMethodL
 // -----------------------------------------------------------------------------
 //
 void CCmmSession::DeleteConnMethodL( const RMessage2& aMessage )
@@ -2445,6 +2844,15 @@
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
 
+    // Embedded destinations cannot be deleted through connection method handle.
+    if ( connMethodInstance->IsEmbeddedDestination() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    // Check if the Client has capabilities to delete this CM.
+    CheckCapabilitiesForProtectedCML( aMessage, connMethodInstance );
+
     iCache.CheckIfConnMethodCanBeDeletedL( *connMethodInstance );
     iCache.DeleteConnMethodL( *connMethodInstance );
     // Ignore the boolean return value. It is always true, or the
@@ -2583,7 +2991,7 @@
     CleanupStack::PushL( value );
     TPtrC valuePtr = value->Des();
 
-    // check the buffer length of the given buffer
+    // Check the buffer length of the given buffer.
     TInt bufferLen = aMessage.GetDesMaxLength( 1 );
     if ( valuePtr.Length() > bufferLen )
         {
@@ -2617,7 +3025,7 @@
     CleanupStack::PushL( value );
     TPtrC8 valuePtr = value->Des();
 
-    // check the buffer length of the given buffer
+    // Check the buffer length of the given buffer.
     TInt bufferLen = aMessage.GetDesMaxLength( 1 );
     if ( valuePtr.Length() > bufferLen )
         {
@@ -2641,6 +3049,10 @@
     CCmmConnMethodInstance* cm =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
 
+    // Check the capability needed if protected CM
+    // ECapabilityWriteDeviceData is checked earlier already.
+    CheckCapabilitiesForProtectedCML( aMessage, cm );
+
     TUint32 attribute( aMessage.Int0() );
     TUint32 value( aMessage.Int1() );
 
@@ -2660,6 +3072,10 @@
     CCmmConnMethodInstance* cm =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
 
+    // Check the capability needed if protected CM
+    // ECapabilityWriteDeviceData is checked earlier already.
+    CheckCapabilitiesForProtectedCML( aMessage, cm );
+
     TUint32 attribute( aMessage.Int0() );
     TBool value( aMessage.Int1() );
 
@@ -2679,6 +3095,10 @@
     CCmmConnMethodInstance* cm =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
 
+    // Check the capability needed if protected CM
+    // ECapabilityWriteDeviceData is checked earlier already.
+    CheckCapabilitiesForProtectedCML( aMessage, cm );
+
     TUint32 attribute( aMessage.Int0() );
 
     HBufC* value = HBufC::NewLC( aMessage.GetDesLengthL( 1 ) );
@@ -2703,6 +3123,10 @@
     CCmmConnMethodInstance* cm =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
 
+    // Check the capability needed if protected CM
+    // ECapabilityWriteDeviceData is checked earlier already.
+    CheckCapabilitiesForProtectedCML( aMessage, cm );
+
     TUint32 attribute( aMessage.Int0() );
 
     HBufC8* value = HBufC8::NewLC( aMessage.GetDesLengthL( 1 ) );
@@ -2881,6 +3305,19 @@
     CCmmDestinationInstance* destination =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle );
 
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destination->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     CCmmConnMethodInstance* connMethod = CCmmConnMethodInstance::NewLC( this, &iCache );
     iCache.CreateConnMethodL( *connMethod, destination, bearerType, 0 );
 
@@ -2917,6 +3354,19 @@
     CCmmDestinationInstance* destination =
             ( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle );
 
+    // Check the protection and if protected check the needed capabilities.
+    CMManager::TProtectionLevel protLevel =
+            destination->CurrentProtectionLevelL();
+    if ( protLevel == CMManager::EProtLevel1 )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
     CCmmConnMethodInstance* connMethod =
             CCmmConnMethodInstance::NewLC( this, &iCache );
     // Will check if ID is available.
@@ -2999,7 +3449,8 @@
     }
 
 // -----------------------------------------------------------------------------
-// Creates a copy of an existing connection method and opens a handle to it.
+// Opens a destination handle to the embedded destination that the provided
+// connection method handle represents.
 // -----------------------------------------------------------------------------
 //
 void CCmmSession::GetEmbeddedDestinationL( const RMessage2& aMessage )
@@ -3009,7 +3460,8 @@
     CCmmConnMethodInstance* connMethodInstance =
             ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
 
-    if ( connMethodInstance->GetBearerType() != KUidEmbeddedDestination )
+    // Check this connection method realy represents an embedded destination.
+    if ( !connMethodInstance->IsEmbeddedDestination() )
         {
         User::Leave( KErrNotSupported );
         }
@@ -3058,7 +3510,55 @@
         iDestinationObjects->Remove( handle );
         User::Leave( error );
         }
+
     OstTraceFunctionExit0( CCMMSESSION_GETEMBEDDEDDESTINATIONL_EXIT );
     }
 
+// -----------------------------------------------------------------------------
+// Check if CM is protected and if so then check the needed capabilities.
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::CheckCapabilitiesForProtectedCML(
+        const RMessage2& aMessage,
+        CCmmConnMethodInstance* aConnectionMethodInstance )
+    {
+    OstTraceFunctionEntry0( CCMMSESSION_CHECKCAPABILITIESFORPROTECTEDCML_ENTRY );
+
+    TBool prot = aConnectionMethodInstance->GetBoolAttributeL( CMManager::ECmProtected );
+    if ( prot )
+        {
+        CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+        capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+        if ( capabilities == CPolicyServer::EFail )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+
+    OstTraceFunctionExit0( CCMMSESSION_CHECKCAPABILITIESFORPROTECTEDCML_EXIT );
+    }
+
+// ---------------------------------------------------------------------------
+// Check if there is space enough in the disk.
+// ---------------------------------------------------------------------------
+//
+TBool CCmmSession::CheckSpaceBelowCriticalLevelL()
+    {
+    if ( !iFsConnected )
+        {
+        TInt err = iFs.Connect();
+        if ( err )
+            {
+            // Error happened in connect --> disk space cannot be checked,
+            // --> return information that everything is ok.
+            return EFalse;
+            }
+        iFsConnected = ETrue;
+        }
+
+    TBool belowCL = SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, KMinimumDiskSpace );
+
+    return belowCL;
+    }
+
 // End of file
--- a/cmmanager/cmmgr/cmmserver/src/cmmtransactionhandler.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmtransactionhandler.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -84,6 +84,7 @@
 //
 CommsDat::CMDBSession& CCmmTransactionHandler::Session() const
     {
+    // No traces.
     return iDb;
     }
 
--- a/cmmanager/cmmgr/cmmserver/traces/OstTraceDefinitions.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef __OSTTRACEDEFINITIONS_H__
 #define __OSTTRACEDEFINITIONS_H__
 // OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
--- a/cmmanager/cmmgr/database/group/cmmanagerdatabase.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/database/group/cmmanagerdatabase.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,6 @@
 *
 */
 
-#include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
 
 TARGET        	cmmanagerdatabase.dll
@@ -42,9 +41,7 @@
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY       	euser.lib
-//LIBRARY         ECom.lib
 LIBRARY         COMMSDAT.lib
-//LIBRARY         flogger.lib
 
 
 #if defined(EABI)
--- a/cmmanager/cmmgr/database/inc/datamobilitycommsdattypes.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/database/inc/datamobilitycommsdattypes.h	Thu Jul 22 16:37:38 2010 +0100
@@ -43,6 +43,7 @@
 #define KCDTypeNameSNAPMetadataSNAP _S( "SNAP" )
 #define KCDTypeNameSNAPMetadataMetadata _S( "Metadata" )
 #define KCDTypeNameSNAPMetadataIcon _S( "Icon" )
+#define KCDTypeNameSNAPMetadataIconFileName _S( "IconFileName" )
 
 //Global bearer priorization table and fields
 #define KCDTypeNameGlobalService _S( "GlobalBearerTypePriorization" )
@@ -60,6 +61,7 @@
 #define KCDTypeNameIAPMetadataIAP _S( "IAP" )
 #define KCDTypeNameIAPMetadataMetadata _S( "Metadata" )
 #define KCDTypeNameIAPMetadataSeamlessness _S( "Seamlessness" )
+#define KCDTypeNameIAPMetadataIconFileName _S( "IconFileName" )
 
 //MIP4 table and fields
 #define KCDTypeNameMIP4 _S( "MIP4" )
@@ -124,6 +126,7 @@
 const CommsDat::TMDBElementId KCDTIdSNAPMetadataSNAP  = 0x00120000;
 const CommsDat::TMDBElementId KCDTIdSNAPMetadataMetadata  = 0x00130000;
 const CommsDat::TMDBElementId KCDTIdSNAPMetadataIcon  = 0x00140000;
+const CommsDat::TMDBElementId KCDTIdSNAPMetadataIconFileName  = 0x00150000;
 
     //mip service extension table
 const CommsDat::TMDBElementId KCDTIdMIPMIP4  = 0x00120000;
@@ -138,6 +141,7 @@
 const CommsDat::TMDBElementId KCDTIdIAPMetadataIAP  = 0x00120000;
 const CommsDat::TMDBElementId KCDTIdIAPMetadataMetadata  = 0x00130000;
 const CommsDat::TMDBElementId KCDTIdIAPMetadataSeamlessness  = 0x00140000;
+const CommsDat::TMDBElementId KCDTIdIAPMetadataIconFileName  = 0x00150000;
 
 //MIP4 Metadata
 const CommsDat::TMDBElementId KCDTIdMIP4HomeAddress = 0x00120000;
@@ -259,7 +263,8 @@
     public:
     CommsDat::CMDBField<TInt> iSNAP;
     CommsDat::CMDBField<TUint32> iMetadata;
-    CommsDat::CMDBField<TUint32> iIcon;       
+    CommsDat::CMDBField<TUint32> iIcon;         //< Not used.
+    CommsDat::CMDBField<TDesC> iIconFileName;   //< May contain path information also.
     
      private:
     
@@ -355,6 +360,7 @@
     CommsDat::CMDBRecordLink<CommsDat::CCDIAPRecord> iIAP;
     CommsDat::CMDBField<TUint32> iMetadata;
     CommsDat::CMDBField<TInt> iSeamlessness;
+    CommsDat::CMDBField<TDesC> iIconFileName;   //< May contain path information also.
 
      private:
     
@@ -473,8 +479,8 @@
     DATA_VTABLE
         
     public:
-    CommsDat::CMDBField<TUint> iDefConnType;
-    CommsDat::CMDBField<TUint> iDefConnUid;    
+    CommsDat::CMDBField<TUint> iDefConnType;    //< Not used.
+    CommsDat::CMDBField<TUint> iDefConnUid;     //< Not used.
     CommsDat::CMDBField<TUint> iUsageOfWlan;
     CommsDat::CMDBField<TUint> iCellularDataUsageHome;
     CommsDat::CMDBField<TUint> iCellularDataUsageVisitor;
--- a/cmmanager/cmmgr/database/src/cmmanagertableformats.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/database/src/cmmanagertableformats.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -105,17 +105,17 @@
 
 const SRecordTypeInfo CCDDefConnRecord::iRecordInfo[]=
   	{
-	    { KCDTIdRecordTag,	         EUint32,    ENoAttrs, KCDTypeNameRecordTag }, 
+	    { KCDTIdRecordTag,	         EUint32,    ENoAttrs, KCDTypeNameRecordTag },
     	{ KCDTIdRecordName,	         EText,      ENotNull, KCDTypeNameRecordName},
     	{ KCDTIdDefConnType,         EUint32,    ENoAttrs, DEFCONN_TYPE },
     	{ KCDTIdDefConnUid,          EUint32,    ENoAttrs, DEFCONN_UID },
     	{ KCDTIdUsageOfWlan,         EUint32,    ENoAttrs, USAGEOFWLAN },
     	{ KCDTIdCellularDataUsageHome,     EUint32,    ENoAttrs,   CELLULAR_DATA_USAGE_HOME },
-        { KCDTIdCellularDataUsageVisitor,  EUint32,    ENoAttrs,   CELLULAR_DATA_USAGE_VISITOR },    	
+        { KCDTIdCellularDataUsageVisitor,  EUint32,    ENoAttrs,   CELLULAR_DATA_USAGE_VISITOR },
 	    { 0, 0, ENoAttrs, KCDNull }
   	};
-  	
-    
+
+
 EXPORT_C const SRecordTypeInfo* CCDDefConnRecord::GetRecordInfo()
     { 
     return iRecordInfo; 
--- a/cmmanager/cmmgr/database/src/datamobilitycommsdattypes.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/database/src/datamobilitycommsdattypes.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -66,6 +66,7 @@
     X_REGISTER_ATTRIBUTE( CCDSNAPMetadataRecord, iSNAP, TMDBNum )
     X_REGISTER_ATTRIBUTE( CCDSNAPMetadataRecord, iMetadata, TMDBNum )
     X_REGISTER_ATTRIBUTE( CCDSNAPMetadataRecord, iIcon, TMDBNum )
+    X_REGISTER_ATTRIBUTE( CCDSNAPMetadataRecord, iIconFileName, TMDBLongText )
     X_REGISTER_ATTRIBUTE( CCDRecordBase, iRecordTag, TMDBNum )
     X_REGISTER_ATTRIBUTE( CCDRecordBase, iRecordName,TMDBText )
 END_ATTRIBUTE_TABLE()
@@ -74,6 +75,7 @@
     X_REGISTER_ATTRIBUTE( CCDIAPMetadataRecord, iIAP, TMDBNum )
     X_REGISTER_ATTRIBUTE( CCDIAPMetadataRecord, iMetadata, TMDBNum )
     X_REGISTER_ATTRIBUTE( CCDIAPMetadataRecord, iSeamlessness, TMDBNum )
+    X_REGISTER_ATTRIBUTE( CCDIAPMetadataRecord, iIconFileName, TMDBLongText )
     X_REGISTER_ATTRIBUTE( CCDRecordBase, iRecordTag, TMDBNum )
     X_REGISTER_ATTRIBUTE( CCDRecordBase, iRecordName, TMDBText )
 END_ATTRIBUTE_TABLE()
@@ -201,6 +203,8 @@
 		  ENoAttrs,                         KCDTypeNameSNAPMetadataMetadata },
 		{ KCDTIdSNAPMetadataIcon,           EInt,  	
 		  ENoAttrs,                         KCDTypeNameSNAPMetadataIcon },
+        { KCDTIdSNAPMetadataIconFileName,   ELongText,
+          ENoAttrs,                         KCDTypeNameSNAPMetadataIconFileName },
   		{ 0,                                0,          
   		  ENoAttrs,                         KCDNull }
   	};
@@ -217,6 +221,8 @@
 		  ENoAttrs,                         KCDTypeNameIAPMetadataMetadata },
 		{ KCDTIdIAPMetadataSeamlessness,    EInt,  	    
 		  ENoAttrs,                         KCDTypeNameIAPMetadataSeamlessness },
+        { KCDTIdIAPMetadataIconFileName,    ELongText,
+          ENoAttrs,                         KCDTypeNameIAPMetadataIconFileName },
   		{ 0,                                0,          
   		  ENoAttrs,                         KCDNull }
   	};
@@ -361,26 +367,26 @@
       iNextLayerSNAP( ( aElementId & KCDMaskShowRecordType ) | KCDTIdVirtualNextLayerSNAP),
       iNextLayerIAP( (aElementId & KCDMaskShowRecordType ) | KCDTIdVirtualNextLayerIAP)
       {}
-  
-EXPORT_C TMDBElementId 
+
+EXPORT_C TMDBElementId
     CCDVirtualIAPNextLayerRecord::CreateTableL( CMDBSession& aSession )
     {
     const SGenericRecordTypeInfo KVirtualIAPNextLayerTableFormat[] = {
-        SGenericRecordTypeInfo( KCDTIdRecordTag,                EUint32,    
-                                ENoAttrs,                       KCDTypeNameRecordTag ),
-        SGenericRecordTypeInfo( KCDTIdRecordName,               EText,      
-                                ENotNull,                       KCDTypeNameRecordName ),    
-        SGenericRecordTypeInfo( KCDTIdVirtualIAP,               EInt,    
-                                ENotNull,                       KCDTypeNameVirtualIAP ),
-        SGenericRecordTypeInfo( KCDTIdVirtualNextLayerSNAP,     EInt,    
-                                ENoAttrs,                       KCDTypeNameVirtualIAPNextLayerSNAP ),   
-        SGenericRecordTypeInfo( KCDTIdVirtualNextLayerIAP,      EInt,    
-                                ENoAttrs,                       KCDTypeNameVirtualIAPNextLayerIAP ),       
+        SGenericRecordTypeInfo( KCDTIdRecordTag,            EUint32,
+                                ENoAttrs,                   KCDTypeNameRecordTag ),
+        SGenericRecordTypeInfo( KCDTIdRecordName,           EText,
+                                ENotNull,                   KCDTypeNameRecordName ),    
+        SGenericRecordTypeInfo( KCDTIdVirtualIAP,           EInt,
+                                ENotNull,                   KCDTypeNameVirtualIAP ),
+        SGenericRecordTypeInfo( KCDTIdVirtualNextLayerSNAP, EInt,
+                                ENoAttrs,                   KCDTypeNameVirtualIAPNextLayerSNAP ),
+        SGenericRecordTypeInfo( KCDTIdVirtualNextLayerIAP,  EInt,
+                                ENoAttrs,                   KCDTypeNameVirtualIAPNextLayerIAP ),
         SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )
         };
 
-    return ::CreateTableL( aSession, 
-                           TPtrC( KCDTypeNameVirtualIAPNextLayer ), 
+    return ::CreateTableL( aSession,
+                           TPtrC( KCDTypeNameVirtualIAPNextLayer ),
                            KVirtualIAPNextLayerTableFormat );
     }
 
@@ -401,27 +407,27 @@
           KCDTIdGlobalServiceUIPriority )
         {}
 
-EXPORT_C TMDBElementId 
+EXPORT_C TMDBElementId
     CCDGlobalBearerTypePriorizationRecord::CreateTableL( CMDBSession& aSession )
     {
-   const SGenericRecordTypeInfo KGlobalBearerTypeTableFormat[] = {
-        SGenericRecordTypeInfo( KCDTIdRecordTag,                EUint32,    
-                                ENoAttrs,                       KCDTypeNameRecordTag ),
-        SGenericRecordTypeInfo( KCDTIdRecordName,                EText,      
-                                ENotNull,                       KCDTypeNameRecordName ),    
-        SGenericRecordTypeInfo( KCDTIdGlobalServiceType,        EText,    
-                                ENotNull,                       KCDTypeNameGlobalServiceType ),
-        SGenericRecordTypeInfo( KCDTIdGlobalServicePriority,    EInt,    
-                                ENoAttrs,                       KCDTypeNameGlobalServicePriority ),   
-        SGenericRecordTypeInfo( KCDTIdGlobalServiceUIPriority,    EInt,    
-                                ENoAttrs,                       KCDTypeNameGlobalServiceUIPriority ),       
-        SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )       
+    const SGenericRecordTypeInfo KGlobalBearerTypeTableFormat[] = {
+        SGenericRecordTypeInfo( KCDTIdRecordTag,             EUint32,
+                                ENoAttrs,                    KCDTypeNameRecordTag ),
+        SGenericRecordTypeInfo( KCDTIdRecordName,            EText,
+                                ENotNull,                    KCDTypeNameRecordName ),
+        SGenericRecordTypeInfo( KCDTIdGlobalServiceType,     EText,
+                                ENotNull,                    KCDTypeNameGlobalServiceType ),
+        SGenericRecordTypeInfo( KCDTIdGlobalServicePriority, EInt,
+                                ENoAttrs,                    KCDTypeNameGlobalServicePriority ),
+        SGenericRecordTypeInfo( KCDTIdGlobalServiceUIPriority, EInt,
+                                ENoAttrs,                    KCDTypeNameGlobalServiceUIPriority ),
+        SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )
     };
-    return ::CreateTableL( aSession, 
-                           TPtrC( KCDTypeNameGlobalService ), 
+    return ::CreateTableL( aSession,
+                           TPtrC( KCDTypeNameGlobalService ),
                            KGlobalBearerTypeTableFormat );
     }
-    
+
 EXPORT_C TMDBElementId 
     CCDGlobalBearerTypePriorizationRecord::TableIdL( CMDBSession& aSession )
     {
@@ -440,44 +446,44 @@
           iPriority( ( aElementId & KCDMaskShowRecordType ) | 
           KCDTIdDataMobilitySelectionPolicyPriority )
         {}
- 
-EXPORT_C TMDBElementId 
+
+EXPORT_C TMDBElementId
     CCDDataMobilitySelectionPolicyRecord::CreateTableL( CMDBSession& aSession )
     {
     const SGenericRecordTypeInfo KDataMobilitySelectionPolicyTableFormat[] = {
-        SGenericRecordTypeInfo( KCDTIdRecordTag,        EUint32,    
-                                ENoAttrs,               KCDTypeNameRecordTag ),
-        SGenericRecordTypeInfo( KCDTIdRecordName,        EText,      
-                                ENotNull,               KCDTypeNameRecordName ),    
-        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyNetwork,        EInt,    
-                                ENotNull,               KCDTypeNameDataMobilitySelectionPolicySNAP ),       
-        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyIAP,            ELink,    
-                                ENoAttrs,               KCDTypeNameDataMobilitySelectionPolicyIAP ),       
-        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyEmbeddedSNAP,    EInt,    
-                                ENoAttrs,               KCDTypeNameDataMobilitySelectionPolicyEmbeddedSNAP ),       
-        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyPriority,    EInt,    
-                                ENotNull,               KCDTypeNameDataMobilitySelectionPolicyPriority ),
-        SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )       
+        SGenericRecordTypeInfo( KCDTIdRecordTag, EUint32,
+                                ENoAttrs, KCDTypeNameRecordTag ),
+        SGenericRecordTypeInfo( KCDTIdRecordName, EText,
+                                ENotNull, KCDTypeNameRecordName ),
+        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyNetwork, EInt,
+                                ENotNull, KCDTypeNameDataMobilitySelectionPolicySNAP ),
+        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyIAP, ELink,
+                                ENoAttrs, KCDTypeNameDataMobilitySelectionPolicyIAP ),
+        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyEmbeddedSNAP, EInt,
+                                ENoAttrs, KCDTypeNameDataMobilitySelectionPolicyEmbeddedSNAP ),
+        SGenericRecordTypeInfo( KCDTIdDataMobilitySelectionPolicyPriority, EInt,
+                                ENotNull, KCDTypeNameDataMobilitySelectionPolicyPriority ),
+        SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )
     };
 
-    return ::CreateTableL( aSession, 
-                           TPtrC( KCDTypeNameDataMobilitySelectionPolicy ), 
+    return ::CreateTableL( aSession,
+                           TPtrC( KCDTypeNameDataMobilitySelectionPolicy ),
                            KDataMobilitySelectionPolicyTableFormat );
     }
-    
-EXPORT_C TMDBElementId 
+
+EXPORT_C TMDBElementId
     CCDDataMobilitySelectionPolicyRecord::TableIdL( CMDBSession& aSession )
     {
     return ::TableIdL( aSession, TPtrC( KCDTypeNameDataMobilitySelectionPolicy ) );
     }
 
 EXPORT_C CCDMIPServiceExtRecord::CCDMIPServiceExtRecord( TMDBElementId aElementId )
-        : CCDRecordBase( aElementId ), 
+        : CCDRecordBase( aElementId ),
           iMIP4( ( aElementId & KCDMaskShowRecordType ) | KCDTIdMIPMIP4 ),
           iMIP6( ( aElementId & KCDMaskShowRecordType ) | KCDTIdMIPMIP6 )
         {}
-        
-EXPORT_C TMDBElementId 
+
+EXPORT_C TMDBElementId
     CCDMIPServiceExtRecord::CreateTableL( CMDBSession& aSession )
     {
     const SGenericRecordTypeInfo KMIPServiceExtTableFormat[] = {
@@ -510,7 +516,9 @@
           iMetadata( ( aElementId & KCDMaskShowRecordType ) | 
           KCDTIdSNAPMetadataMetadata ),
           iIcon( ( aElementId & KCDMaskShowRecordType ) | 
-          KCDTIdSNAPMetadataIcon )
+          KCDTIdSNAPMetadataIcon ),
+          iIconFileName( ( aElementId & KCDMaskShowRecordType ) |
+          KCDTIdSNAPMetadataIconFileName )
         {}
 
 EXPORT_C TMDBElementId 
@@ -527,6 +535,8 @@
                                 ENoAttrs,               KCDTypeNameSNAPMetadataMetadata ),
         SGenericRecordTypeInfo( KCDTIdSNAPMetadataIcon,        EUint32,    
                                 ENoAttrs,               KCDTypeNameSNAPMetadataIcon ),
+        SGenericRecordTypeInfo( KCDTIdSNAPMetadataIconFileName,    ELongText,
+                                ENoAttrs, KCDTypeNameSNAPMetadataIconFileName ),
         SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )       
     };
 
@@ -548,31 +558,35 @@
           iMetadata( ( aElementId & KCDMaskShowRecordType ) | 
           KCDTIdIAPMetadataMetadata ),
           iSeamlessness( ( aElementId & KCDMaskShowRecordType ) | 
-          KCDTIdIAPMetadataSeamlessness )
+          KCDTIdIAPMetadataSeamlessness ),
+          iIconFileName( ( aElementId & KCDMaskShowRecordType ) |
+          KCDTIdIAPMetadataIconFileName )
         {}
 
-EXPORT_C TMDBElementId 
+EXPORT_C TMDBElementId
     CCDIAPMetadataRecord::CreateTableL( CMDBSession& aSession )
     {
     const SGenericRecordTypeInfo KIAPMetadataTableFormat[] = {
-        SGenericRecordTypeInfo( KCDTIdRecordTag,                EUint32,    
-                                ENoAttrs,                       KCDTypeNameRecordTag ),
-        SGenericRecordTypeInfo( KCDTIdRecordName,                EText,      
-                                ENotNull,                       KCDTypeNameRecordName ),    
-        SGenericRecordTypeInfo( KCDTIdIAPMetadataIAP,            ELink,    
-                                ENotNull,                       KCDTypeNameIAPMetadataIAP ),       
-        SGenericRecordTypeInfo( KCDTIdIAPMetadataMetadata,        EUint32,    
-                                ENoAttrs,               KCDTypeNameIAPMetadataMetadata ),
-        SGenericRecordTypeInfo( KCDTIdIAPMetadataSeamlessness, EInt,    
-                                ENoAttrs,                       KCDTypeNameIAPMetadataSeamlessness ),
+        SGenericRecordTypeInfo( KCDTIdRecordTag, EUint32,
+                                ENoAttrs, KCDTypeNameRecordTag ),
+        SGenericRecordTypeInfo( KCDTIdRecordName, EText,
+                                ENotNull, KCDTypeNameRecordName ),
+        SGenericRecordTypeInfo( KCDTIdIAPMetadataIAP, ELink,
+                                ENotNull, KCDTypeNameIAPMetadataIAP ),
+        SGenericRecordTypeInfo( KCDTIdIAPMetadataMetadata, EUint32,
+                                ENoAttrs, KCDTypeNameIAPMetadataMetadata ),
+        SGenericRecordTypeInfo( KCDTIdIAPMetadataSeamlessness, EInt,
+                                ENoAttrs, KCDTypeNameIAPMetadataSeamlessness ),
+        SGenericRecordTypeInfo( KCDTIdIAPMetadataIconFileName, ELongText,
+                                ENoAttrs, KCDTypeNameIAPMetadataIconFileName ),
         SGenericRecordTypeInfo( 0, 0, ENoAttrs, KCDNull )
     };
 
-    return ::CreateTableL( aSession, 
-                           TPtrC( KCDTypeNameIAPMetadata ), 
+    return ::CreateTableL( aSession,
+                           TPtrC( KCDTypeNameIAPMetadata ),
                            KIAPMetadataTableFormat );
     }
-    
+
 EXPORT_C TMDBElementId 
     CCDIAPMetadataRecord::TableIdL( CMDBSession& aSession )
     {
--- a/cmmanager/connection_settings_shim/bwins/connection_settings_shimu.def	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/bwins/connection_settings_shimu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -39,4 +39,9 @@
 	?createDestination@CmManagerShim@@QAEPAVCmDestinationShim@@VQString@@@Z @ 38 NONAME ; class CmDestinationShim * CmManagerShim::createDestination(class QString)
 	?refresh@CmConnectionMethodShim@@QAEXXZ @ 39 NONAME ; void CmConnectionMethodShim::refresh(void)
 	?refresh@CmDestinationShim@@QAEXXZ @ 40 NONAME ; void CmDestinationShim::refresh(void)
+	?getIcon@CmConnectionMethodShim@@QBE?AVQString@@XZ @ 41 NONAME ; class QString CmConnectionMethodShim::getIcon(void) const
+	?getIcon@CmDestinationShim@@QBE?AVQString@@XZ @ 42 NONAME ; class QString CmDestinationShim::getIcon(void) const
+	?setIcon@CmDestinationShim@@QAEXVQString@@@Z @ 43 NONAME ; void CmDestinationShim::setIcon(class QString)
+	?setIcon@CmConnectionMethodShim@@QAEXVQString@@@Z @ 44 NONAME ; void CmConnectionMethodShim::setIcon(class QString)
+	?getUncategorizedIcon@CmManagerShim@@QBE?AVQString@@XZ @ 45 NONAME ; class QString CmManagerShim::getUncategorizedIcon(void) const
 
--- a/cmmanager/connection_settings_shim/eabi/connection_settings_shimu.def	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/eabi/connection_settings_shimu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -45,4 +45,9 @@
 	_ZNK22CmConnectionMethodShim19getString8AttributeEN13CMManagerShim25ConnectionMethodAttributeE @ 44 NONAME
 	_ZN17CmDestinationShim7refreshEv @ 45 NONAME
 	_ZN22CmConnectionMethodShim7refreshEv @ 46 NONAME
+	_ZNK22CmConnectionMethodShim7getIconEv @ 47 NONAME
+	_ZNK17CmDestinationShim7getIconEv @ 48 NONAME
+	_ZN17CmDestinationShim7setIconE7QString @ 49 NONAME
+	_ZN22CmConnectionMethodShim7setIconE7QString @ 50 NONAME
+	_ZNK13CmManagerShim20getUncategorizedIconEv @ 51 NONAME
 
--- a/cmmanager/connection_settings_shim/inc/cmconnectionmethod_shim_s60_p.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/inc/cmconnectionmethod_shim_s60_p.h	Thu Jul 22 16:37:38 2010 +0100
@@ -76,6 +76,10 @@
 
     void Update();
     
+    QString GetIcon() const;
+    
+    void SetIcon(QString icon);
+    
     void Refresh();
     
 protected:
@@ -108,6 +112,10 @@
         CMManagerShim::ConnectionMethodAttribute attribute, 
         QString value);
     
+    void GetIconL(QString &value) const;
+    
+    void SetIconL(QString icon);
+    
     void TraceIfError(TInt error) const;
     
 private: // data    
--- a/cmmanager/connection_settings_shim/inc/cmdestination_shim_s60_p.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/inc/cmdestination_shim_s60_p.h	Thu Jul 22 16:37:38 2010 +0100
@@ -81,6 +81,10 @@
     
     void DeleteDestination();
     
+    QString GetIcon() const;
+    
+    void SetIcon(QString icon);
+    
 protected:
 
 private:
@@ -100,6 +104,10 @@
     void ModifyPriorityL(CmConnectionMethodShim *cm, int index);
            
     void SetNameL(QString name);
+    
+    void GetIconL(QString &icon) const;
+    
+    void SetIconL(QString icon);
               
     CMManagerShim::CmmProtectionLevel mapCmmProtectionLevel( 
         CMManager::TProtectionLevel protectionlvl) const;
--- a/cmmanager/connection_settings_shim/inc/cmmanager_shim_s60_p.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/inc/cmmanager_shim_s60_p.h	Thu Jul 22 16:37:38 2010 +0100
@@ -61,6 +61,8 @@
             
     void AllDestinations(QList<uint> &destArray) const;
     
+    QString GetUncategorizedIcon() const;
+    
 protected:
 
 private:
@@ -72,6 +74,8 @@
         bool legacyOnly) const;
     
     void AllDestinationsL(QList<uint> &destArray) const;
+    
+    void GetUncategorizedIconL(QString &icon) const;
 
     void TraceIfError(TInt error) const;
 
--- a/cmmanager/connection_settings_shim/src/cmconnectionmethod_shim.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/src/cmconnectionmethod_shim.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -105,6 +105,17 @@
     d_ptr->Update();
 }
 
+QString CmConnectionMethodShim::getIcon() const
+{
+    return d_ptr->GetIcon();
+}
+
+void CmConnectionMethodShim::setIcon(
+    QString icon)    
+{
+    d_ptr->SetIcon(icon);
+}
+
 void CmConnectionMethodShim::refresh()
 {
     d_ptr->Refresh();
--- a/cmmanager/connection_settings_shim/src/cmconnectionmethod_shim_s60.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/src/cmconnectionmethod_shim_s60.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -207,6 +207,31 @@
     OstTraceFunctionExit0(CMCONNECTIONMETHODSHIMPRIVATE_UPDATE_EXIT);
 }
 
+QString CmConnectionMethodShimPrivate::GetIcon() const
+{
+    OstTraceFunctionEntry0(CMCONNECTIONMETHODSHIMPRIVATE_GETICON_ENTRY);
+    
+    QString value;
+    TRAPD(error, GetIconL(value));
+    TraceIfError(error);
+    qt_symbian_throwIfError(error);
+    
+    OstTraceFunctionExit0(CMCONNECTIONMETHODSHIMPRIVATE_GETICON_EXIT);
+    return value;
+}
+
+void CmConnectionMethodShimPrivate::SetIcon(
+    QString icon)
+{
+    OstTraceFunctionEntry0(CMCONNECTIONMETHODSHIMPRIVATE_SETICON_ENTRY);
+    
+    TRAPD(error, SetIconL(icon));
+    TraceIfError(error);
+    qt_symbian_throwIfError(error);
+
+    OstTraceFunctionExit0(CMCONNECTIONMETHODSHIMPRIVATE_SETICON_EXIT);
+}
+
 void CmConnectionMethodShimPrivate::Refresh()
 {
     OstTraceFunctionEntry0(CMCONNECTIONMETHODSHIMPRIVATE_REFRESH_ENTRY);
@@ -267,6 +292,21 @@
     iCm.SetString8AttributeL(attribute, valuePtr);
 }
 
+void CmConnectionMethodShimPrivate::GetIconL( 
+    QString &value) const
+{
+    HBufC* buf = iCm.GetIconL();
+    value = QString::fromUtf16(buf->Ptr(), buf->Length());
+    delete buf;
+}
+
+void CmConnectionMethodShimPrivate::SetIconL(
+    QString icon)
+{
+    TPtrC16 valuePtr(reinterpret_cast<const TUint16*>(icon.utf16()));
+    iCm.SetIconL(valuePtr);
+}
+
 /*!
  * Traces given error code if it is not KErrNone. 
  * 
--- a/cmmanager/connection_settings_shim/src/cmdestination_shim.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/src/cmdestination_shim.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -130,3 +130,13 @@
 {
     d_ptr->DeleteDestination();
 }
+
+QString CmDestinationShim::getIcon() const
+{    
+    return d_ptr->GetIcon();
+}
+
+void CmDestinationShim::setIcon(QString icon)
+{    
+    d_ptr->SetIcon(icon);
+}
--- a/cmmanager/connection_settings_shim/src/cmdestination_shim_s60.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/src/cmdestination_shim_s60.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -288,6 +288,30 @@
     OstTraceFunctionExit0(CMDESTINATIONSHIMPRIVATE_DELETEDESTINATION_EXIT);
 }
 
+QString CmDestinationShimPrivate::GetIcon() const
+{    
+    OstTraceFunctionEntry0(CMDESTINATIONSHIMPRIVATE_GETICON_ENTRY);
+    
+    QString icon;
+    TRAPD(error, GetIconL(icon));
+    TraceIfError(error);
+    qt_symbian_throwIfError(error);
+    
+    OstTraceFunctionExit0(CMDESTINATIONSHIMPRIVATE_GETICON_EXIT);
+    return icon;
+}
+
+void CmDestinationShimPrivate::SetIcon(QString icon)
+{
+    OstTraceFunctionEntry0(CMDESTINATIONSHIMPRIVATE_SETICON_ENTRY);
+    
+    TRAPD(error, SetIconL(icon));
+    TraceIfError(error);
+    qt_symbian_throwIfError(error);
+
+    OstTraceFunctionExit0(CMDESTINATIONSHIMPRIVATE_SETICON_EXIT);
+}
+
 void CmDestinationShimPrivate::PriorityL(
     CmConnectionMethodShim *cmShim,
     uint &priority) const
@@ -347,6 +371,19 @@
     iDestination.SetNameL(namePtr);
 }
 
+void CmDestinationShimPrivate::GetIconL(QString &icon) const
+{
+    HBufC* iapName = iDestination.GetIconL();
+    icon = QString::fromUtf16(iapName->Ptr(), iapName->Length());
+    delete iapName;
+}
+
+void CmDestinationShimPrivate::SetIconL(QString icon)
+{
+    TPtrC16 iconPtr(reinterpret_cast<const TUint16*>(icon.utf16()));
+    iDestination.SetIconL(iconPtr);
+}
+
 /*!
  * Maps CM Manager protection levels to those defined by the shim.
  * 
--- a/cmmanager/connection_settings_shim/src/cmmanager_shim.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/src/cmmanager_shim.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -79,3 +79,8 @@
 {
     return d_ptr->AllDestinations(destArray);
 }
+
+QString CmManagerShim::getUncategorizedIcon() const
+{    
+    return d_ptr->GetUncategorizedIcon();
+}
--- a/cmmanager/connection_settings_shim/src/cmmanager_shim_s60.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/src/cmmanager_shim_s60.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -163,6 +163,19 @@
     OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_ALLDESTINATIONS_EXIT);
 }
 
+QString CmManagerShimPrivate::GetUncategorizedIcon() const
+{    
+    OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_GETUNCATEGORIZEDICON_ENTRY);
+    
+    QString icon;
+    TRAPD(error, GetUncategorizedIconL(icon));
+    TraceIfError(error);
+    qt_symbian_throwIfError(error);
+    
+    OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_GETUNCATEGORIZEDICON_EXIT);
+    return icon;
+}
+
 void CmManagerShimPrivate::ConnectionMethodL(
     QList<uint> &cmArray,
     bool legacyOnly) const
@@ -195,6 +208,13 @@
     destinationIdArray.Reset();
 }
 
+void CmManagerShimPrivate::GetUncategorizedIconL(QString &icon) const
+{
+    HBufC* iconName = iCmManager.GetUncategorizedIconL();
+    icon = QString::fromUtf16(iconName->Ptr(), iconName->Length());
+    delete iconName;
+}
+
 /*!
  * Traces given error code if it is not KErrNone. 
  * 
--- a/cmmanager/connection_settings_shim/tsrc/ut/testcmmgrshim.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/tsrc/ut/testcmmgrshim.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -1063,6 +1063,63 @@
     delete dest;
 }
 
+/**
+ * Test case for setting and getting icon from CM Manager
+ * -Creates a legacy WLAN connection method (i.e. does not belong to
+ *  any destination).
+ * -Sets & Gets Icon
+ * -Creates destination
+ * -Sets & Gets Icon
+ * -Deletes the connection method. 
+ */
+void TestCmMgrShim::tcIconOperations()
+{
+    // Create the connection method
+    CmConnectionMethodShim *cm = mCmManagerShim->createConnectionMethod(
+        CMManagerShim::BearerTypeWlan);
+    QVERIFY(cm != NULL);
+    
+    // Update to CommsDat
+    cm->update();
+    
+    // Create a new destination
+    CmDestinationShim *dest;
+    dest = mCmManagerShim->createDestination("TestDestination");
+    QVERIFY(dest != NULL);
+       
+    // Update to CommsDat
+    dest->update();
+
+    // Set icon
+    QString testString("TestIconName");
+    cm->setIcon(testString);
+    
+    // Update to CommsDat
+    cm->update();
+    
+    // Set icon
+    dest->setIcon(testString);
+    
+    // Update to CommsDat
+    dest->update();
+     
+    // Check icon
+    QString resultString = cm->getIcon();
+    QCOMPARE(resultString, testString);
+
+    // Check destination icon
+    QString resultDestString = dest->getIcon();
+    QCOMPARE(resultDestString, testString);
+
+    // Delete the connection method
+    cm->deleteConnectionMethod();
+    delete cm;
+    
+    // Delete the destination
+    dest->deleteDestination();
+    delete dest;
+}
+
 // -----------------------------------------------------------------------------
 // SUB TEST CASES
 // -----------------------------------------------------------------------------
--- a/cmmanager/connection_settings_shim/tsrc/ut/testcmmgrshim.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/connection_settings_shim/tsrc/ut/testcmmgrshim.h	Thu Jul 22 16:37:38 2010 +0100
@@ -52,6 +52,7 @@
         void tcDestinationMisc();
         void tcDestinationRefresh();
         void tcDestinationInvalidParams();
+        void tcIconOperations();
         
     private:
         // Sub test cases
--- a/cmmanager/cpdestinationplugin/cpdestinationplugin.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/cpdestinationplugin.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -10,14 +10,13 @@
 # Contributors:
 #
 # Description:
-#
+# Control Panel Destinations & Access points plugin project file
 
 TEMPLATE = lib
 TARGET = cpdestinationplugin
 DEPENDPATH += .
 INCLUDEPATH += . 
 CONFIG += hb plugin
-CONFIG += debug
 MOC_DIR = moc
 OBJECTS_DIR = obj
 RCC_DIR = rcc
@@ -41,6 +40,14 @@
 
 TRANSLATIONS = cpdestinationplugin.ts
 
+# Temporary solution to fix tracecompiler
+# When tracecompiler is fixed, this can be removed
+symbian: {
+
+    MMP_RULES += "USERINCLUDE traces"
+
+}
+
 symbian:
 { 
     TARGET.EPOCALLOWDLLDATA = 1
--- a/cmmanager/cpdestinationplugin/inc/cpadddestinationentryitemdata.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/inc/cpadddestinationentryitemdata.h	Thu Jul 22 16:37:38 2010 +0100
@@ -59,7 +59,6 @@
 	void showErrorNote();
     
 private slots:
-
     void onLaunchView();
 	
 private: // data
@@ -70,10 +69,6 @@
 	HbInputDialog      *mDialog;
 	//! New Destination name query's OK action
 	HbAction           *mOkAction;
-	
-	//! Maximun length for destination name
-	static const int DestinationNameMaxLength = 30;
-	
 };
 
 #endif //CPADDDESTINATIONENTRYITEMDATA_H
--- a/cmmanager/cpdestinationplugin/inc/cpdestinationentryitem.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/inc/cpdestinationentryitem.h	Thu Jul 22 16:37:38 2010 +0100
@@ -63,16 +63,18 @@
 public slots:
     void updateDestinationView();
     void showItemMenu(QPointF position);
+    void openDestination();
     void renameDestination();
     void confirmDestinationDelete();
     void deleteDestination();
     void activateArrangeMode();
     void viewDone();
     void viewCancel();
-    void updateIndex(HbListWidgetItem *widgetItem);
+    void updateIndex();
     void saveNewDestinationName();
     
 protected:
+    bool eventFilter(QObject *obj, QEvent *event);
     
 protected slots:
     
@@ -89,6 +91,7 @@
     void lauchNewDestinationNameQuery();
     void showRenameError(const QString &info);
     void showErrorNote(const QString &info);
+    QString resolveApIcon(QSharedPointer<CmConnectionMethodShim> cm) const; 
             
 private slots:
     
@@ -112,9 +115,6 @@
     HbInputDialog      *mDialog;
     //! New Destination name query's OK action
     HbAction           *mOkAction;
-    
-    //! Maximun length for destination name
-    static const int DestinationNameMaxLength = 30;
 };
 
 #endif /* CPDESTINATIONENTRYITEM_H */
--- a/cmmanager/cpdestinationplugin/inc/cpdestinationgroup.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/inc/cpdestinationgroup.h	Thu Jul 22 16:37:38 2010 +0100
@@ -61,7 +61,9 @@
     void createUncategorisedDestination();
     void fetchDestinations(QList<QSharedPointer<CmDestinationShim> > &destinationList);
     void loadBearerPlugins();
-	QString getDestinationAdditionalText(int iapCount);
+	QString getDestinationAdditionalText(QSharedPointer<CmDestinationShim> destination);
+	QString getDestinationAdditionalText(int destinationId);
+	QString resolveDestinationIcon(QSharedPointer<CmDestinationShim> destination) const; 
 	
 private slots:
 
--- a/cmmanager/cpdestinationplugin/inc/cpiapitem.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/inc/cpiapitem.h	Thu Jul 22 16:37:38 2010 +0100
@@ -66,7 +66,8 @@
     void shareIap();
     void queryDialogClosed();
     void deleteConfirmed();
-    void updateIap(const QModelIndex index);
+    void updateIap();
+    void openIap();
 
 protected:
     
--- a/cmmanager/cpdestinationplugin/src/cpadddestinationentryitemdata.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/src/cpadddestinationentryitemdata.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -61,9 +61,6 @@
     mDialog(0)
 {
     OstTraceFunctionEntry0(CPADDDESTINATIONENTRYITEMDATA_CPADDDESTINATIONENTRYITEMDATA_ENTRY);
-    // Fix connections
-    itemDataHelper.removeConnection(this,SIGNAL(pressed()),this,SLOT(onLaunchView()));
-    itemDataHelper.addConnection(this,SIGNAL(clicked()),this,SLOT(onLaunchView()));
     OstTraceFunctionExit0(CPADDDESTINATIONENTRYITEMDATA_CPADDDESTINATIONENTRYITEMDATA_EXIT);
 }
 
@@ -85,17 +82,21 @@
     OstTraceFunctionEntry0(CPADDDESTINATIONENTRYITEMDATA_ONLAUNCHVIEW_ENTRY);
     mDialog = new HbInputDialog();
     mDialog->setAttribute(Qt::WA_DeleteOnClose);
-    mDialog->lineEdit()->setMaxLength(DestinationNameMaxLength);
+    mDialog->lineEdit()->setMaxLength(CMManagerShim::CmNameLength);
     mDialog->clearActions();
     mDialog->setPromptText(hbTrId("txt_occ_dialog_destination_name"));
     mDialog->setInputMode(HbInputDialog::TextInput);
-    mOkAction = new HbAction(hbTrId("txt_common_button_ok"));
+    mOkAction = new HbAction(
+        hbTrId("txt_common_button_ok"),
+        mDialog);
     bool connected = connect(mOkAction, 
                              SIGNAL(triggered()), 
                              this, 
                              SLOT(setNewDestinationName()));
     Q_ASSERT(connected);
-    HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"));
+    HbAction *cancelAction = new HbAction(
+        hbTrId("txt_common_button_cancel"),
+        mDialog);
     mDialog->addAction(mOkAction);
     mDialog->addAction(cancelAction);
     mDialog->show();
@@ -175,6 +176,7 @@
             CmDestinationShim *destination = cmm->destination(destinationList[i]);
             if (0 == dest.compare(destination->name())) {
                 retVal = false;
+                delete destination;
                 break;
             }
             delete destination;
@@ -200,7 +202,9 @@
     QString info = hbTrId("txt_occ_info_invalid_name");
     note->setText(info);
     note->setTimeout(HbPopup::NoTimeout);
-    HbAction *errorOk = new HbAction(hbTrId("txt_common_button_ok"));
+    HbAction *errorOk = new HbAction(
+        hbTrId("txt_common_button_ok"),
+        note);
     bool connected = connect(
         errorOk,
         SIGNAL(triggered()),
--- a/cmmanager/cpdestinationplugin/src/cpdestinationentryitem.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/src/cpdestinationentryitem.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -93,7 +93,6 @@
     OstTraceFunctionEntry0(DUP1_CPDESTINATIONENTRYITEMDATA_CPDESTINATIONENTRYITEMDATA_ENTRY);
     delete mCmm;
     delete mAps;
-    delete mOkAction;
     OstTraceFunctionExit0(DUP1_CPDESTINATIONENTRYITEMDATA_CPDESTINATIONENTRYITEMDATA_EXIT);
 }
 
@@ -150,13 +149,9 @@
     // Toolbar. Allow arrange if more than one AP is shown
     if (mDestinationId != 0 && mAps->count() > 1) {
         HbToolBar *tb = view->toolBar();
-        HbAction *arrangeAction = tb->addAction(hbTrId("txt_occ_button_arrange"));
-        bool connected = connect(
-            arrangeAction, 
-            SIGNAL(triggered()), 
-            this, 
-            SLOT(activateArrangeMode()));
-        Q_ASSERT(connected);
+        HbIcon arrangeIcon("qtg_mono_sort");
+        HbAction *arrangeAction 
+            = tb->addAction(arrangeIcon, "", this, SLOT(activateArrangeMode()));
     }
     OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_CREATESETTINGVIEW_EXIT);
     return view;        
@@ -212,12 +207,18 @@
         iapDataItem->setContentWidgetData(
             QString("text"), 
             apList[i]->getStringAttribute(CMManagerShim::CmName));
+        
+        // Add Icon if found
+        HbIcon iapIcon(resolveApIcon(apList[i]));
+        iapDataItem->setEntryItemIcon(iapIcon);
        
         // Add priority to item if not Uncategorised "Destination"
         if (mDestinationId  != 0) {
             // Access Points are listed in priority order.
-            QString priority = hbTrId("txt_occ_dblist_val_priority_l1", i);
+            QString priority = hbTrId("txt_occ_dblist_val_priority_l1").arg(i + 1);
             iapDataItem->setContentWidgetData(QString("additionalText"), priority);
+        } else {
+            iapDataItem->setContentWidgetData(QString("stretched"), true);
         }
         
         // Set item disabled if it is protected
@@ -294,6 +295,14 @@
 }
 
 /*!
+   Opens selected destination.
+ */
+void CpDestinationEntryItemData::openDestination()
+{    
+    onLaunchView();
+}
+
+/*!
     Prompts user for new destination name and makes 
     the change in commsdat if new name is valid.
     
@@ -304,17 +313,22 @@
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_RENAMEDESTINATION_ENTRY);
     mDialog = new HbInputDialog();
     mDialog->setAttribute(Qt::WA_DeleteOnClose);
-    mDialog->lineEdit()->setMaxLength(DestinationNameMaxLength);
+    mDialog->lineEdit()->setMaxLength(CMManagerShim::CmNameLength);
     mDialog->clearActions();
     mDialog->setPromptText(hbTrId("txt_occ_dialog_destination_name"));
     mDialog->setInputMode(HbInputDialog::TextInput);
-    mOkAction = new HbAction(hbTrId("txt_common_button_ok"));
+    mDialog->setValue(mDestinationName);
+    mOkAction = new HbAction(
+        hbTrId("txt_common_button_ok"),
+        mDialog);
     bool connected = connect(mOkAction, 
                              SIGNAL(triggered()), 
                              this, 
                              SLOT(saveNewDestinationName()));
     Q_ASSERT(connected);
-    HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"));
+    HbAction *cancelAction = new HbAction(
+        hbTrId("txt_common_button_cancel"),
+        mDialog);
     mDialog->addAction(mOkAction);
     mDialog->addAction(cancelAction);
     mDialog->show();
@@ -332,7 +346,9 @@
     note->setAttribute(Qt::WA_DeleteOnClose);
     note->setText(hbTrId("txt_occ_info_delete_snap").arg(mDestinationName));
     note->clearActions();
-    HbAction *okAction = new HbAction(hbTrId("txt_common_button_yes"));
+    HbAction *okAction = new HbAction(
+        hbTrId("txt_common_button_yes"),
+        note);
     note->addAction(okAction);
     bool connected = connect(
         okAction, 
@@ -340,7 +356,9 @@
         this, 
         SLOT(deleteDestination()));
     Q_ASSERT(connected);
-    HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_no"));
+    HbAction *cancelAction = new HbAction(
+        hbTrId("txt_common_button_no"),
+        note);
     note->addAction(cancelAction);
     note->setTimeout(HbPopup::NoTimeout);
     note->show();
@@ -397,13 +415,7 @@
     HbMainWindow *mainWnd = mainWindows.front();
     HbView *view = new HbView();
     createArrangeModeView(view);
-    
-    bool connectionSuccessful = connect(
-            mList,
-            SIGNAL(released(HbListWidgetItem*)),
-            this,
-            SLOT(updateIndex(HbListWidgetItem*)));
-    Q_ASSERT(connectionSuccessful);
+    mList->installEventFilter(this);
     
     if (mainWnd && view) {
         mPreView = mainWnd->currentView();
@@ -454,6 +466,7 @@
     
     if (mainWnd && view)  {
         //restore previous status
+        mList->removeEventFilter(this);
         mainWnd->removeView(view);
         mainWnd->setCurrentView(mPreView);
         mPreView = NULL;
@@ -474,6 +487,7 @@
     
     if (mainWnd && view) {
         //restore previous status
+        mList->removeEventFilter(this);
         mainWnd->removeView(view);
         view->deleteLater();
         mainWnd->setCurrentView(mPreView);
@@ -486,17 +500,14 @@
     This function updates access points priorities shown in UI
     when user is in arrange mode.
     
-    @param[in] widgetItem Unused.
-    
     \sa activateArrangeMode()
  */
-void CpDestinationEntryItemData::updateIndex(HbListWidgetItem *widgetItem)
+void CpDestinationEntryItemData::updateIndex()
 {
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_UPDATEINDEX_ENTRY);
-    Q_UNUSED(widgetItem);
     for (int i = 0; i < mList->count(); i++) {
         HbListWidgetItem *item = mList->item(i);
-        QString priority = hbTrId("txt_occ_dblist_val_priority_l1", i);
+        QString priority = hbTrId("txt_occ_dblist_val_priority_l1").arg(i + 1);
         item->setSecondaryText(priority);
     }
     OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_UPDATEINDEX_EXIT);
@@ -523,7 +534,11 @@
             for (int i = 0; i < apIds.count(); i++) {
                 CmConnectionMethodShim *cm;
                 cm = cmm->connectionMethod(apIds.at(i));
-                apList.append(QSharedPointer<CmConnectionMethodShim>(cm));
+                if (!cm->getBoolAttribute(CMManagerShim::CmHidden)) {
+                    apList.append(QSharedPointer<CmConnectionMethodShim>(cm));
+                } else {
+                    delete cm;
+                }
             }
         } else {
             destination = cmm->destination(mDestinationId);
@@ -531,7 +546,12 @@
             for (int i = 0; i < apCount; i++) {
                 CmConnectionMethodShim *cm = NULL;
                 cm = destination->connectionMethod(i);
-                apList.append(QSharedPointer<CmConnectionMethodShim>(cm));
+                if (!cm->getBoolAttribute(CMManagerShim::CmDestination)
+                     && !cm->getBoolAttribute(CMManagerShim::CmHidden)) {
+                    apList.append(QSharedPointer<CmConnectionMethodShim>(cm));
+                } else {
+                    delete cm;
+                }
             }
             delete destination;
         }
@@ -571,6 +591,7 @@
             if (0 == destination.compare(dest->name())) {
                 destination = hbTrId("txt_occ_info_name_already_in_use");
                 retVal = false;
+                delete dest;
                 break;
             }
             delete dest;
@@ -608,8 +629,11 @@
             item->setData(apList[i]->getIntAttribute(CMManagerShim::CmId), Hb::IndexFeedbackRole);
 
             uint pri = destination->priority(apList[i].data());
-            QString priority = hbTrId("txt_occ_dblist_val_priority_l1", pri);
+            QString priority = hbTrId("txt_occ_dblist_val_priority_l1").arg(pri);
             item->setSecondaryText(priority);
+            
+            HbIcon iapIcon(resolveApIcon(apList[i]));
+            item->setIcon(iapIcon);
         
             mList->addItem(item);
         }
@@ -629,13 +653,9 @@
     }
     // Toolbar
     HbToolBar *tb = view->toolBar();
-    HbAction *doneAction = tb->addAction(hbTrId("txt_common_button_ok"));
-    bool connected = connect(
-        doneAction, 
-        SIGNAL(triggered()), 
-        this, 
-        SLOT(viewDone()));
-    Q_ASSERT(connected);
+    HbIcon okIcon("qtg_mono_tick");
+    HbAction *doneAction 
+        = tb->addAction(okIcon, "", this, SLOT(viewDone()));
     OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_CREATEARRANGEMODEVIEW_EXIT);
 }
 
@@ -652,8 +672,12 @@
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_CREATEITEMMENU_ENTRY);
     HbMenu *menu = new HbMenu();
     menu->setAttribute(Qt::WA_DeleteOnClose);
+    HbAction *openDestAction = menu->addAction(hbTrId("txt_common_menu_open"));
+    bool connected = 
+        connect(openDestAction, SIGNAL(triggered()), this, SLOT(openDestination()));
+    Q_ASSERT(connected);
     HbAction *renameDestAction = menu->addAction(hbTrId("txt_common_menu_rename_item"));
-    bool connected = 
+    connected = 
         connect(renameDestAction, SIGNAL(triggered()), this, SLOT(renameDestination()));
     Q_ASSERT(connected);
     HbAction *deleteDestAction = menu->addAction(hbTrId("txt_common_menu_delete"));
@@ -677,42 +701,44 @@
 
 /*!
     This function is called when user selects OK from destination
-    name query popup. The given name is valited and if the name is
-    valid, new destination is created in commsdat with given name.
-    If validation fails user is promted again for destination name.
+    name query popup. The given name is validated and if the name is
+    valid, new destination name is saved to commsdat. If validation fails
+    user is prompted again for destination name.
  */
 void CpDestinationEntryItemData::saveNewDestinationName()
 {
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_SAVENEWDESTINATIONNAME_ENTRY);
     QString destinationName = mDialog->value().toString();
-    bool destinationNameInvalid = true;
-    CmManagerShim *cmm = NULL;
-    CmDestinationShim *destination = NULL;
-    
-    try {
-        cmm = new CmManagerShim();
-        if (isDestinationNameValid(destinationName, cmm)) {
+    if (destinationName != mDestinationName) {
+        // Destination name was changed
+        bool destinationNameInvalid = true;
+        CmManagerShim *cmm = NULL;
+        CmDestinationShim *destination = NULL;
+        
+        try {
             cmm = new CmManagerShim();
-            destination = cmm->destination(mDestinationId);
-            destination->setName(destinationName);
-            destination->update();
-            mDestinationName = destinationName;
-            destinationNameInvalid = false;
+            if (isDestinationNameValid(destinationName, cmm)) {
+                destination = cmm->destination(mDestinationId);
+                destination->setName(destinationName);
+                destination->update();
+                mDestinationName = destinationName;
+                destinationNameInvalid = false;
+            }
+        } catch (const std::exception&) {
+            OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_SAVENEWDESTINATIONNAME_EXIT);
+            return;
         }
-    } catch (const std::exception&) {
-        OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_SAVENEWDESTINATIONNAME_EXIT);
-        return;
-    }
-    delete destination;
-    delete cmm;
-    
-    if (destinationNameInvalid) {   
-        // Validation function has modified destination name 
-        // to be error string
-        showRenameError(destinationName);
-    } else {
-        OstTrace0(TRACE_NORMAL, CPDESTINATIONENTRYITEMDATA_SAVENEWDESTINATIONNAME, "CpDestinationEntryItemData::saveNewDestinationName: emit destination changed");
-        emit destChanged();
+        delete destination;
+        delete cmm;
+        
+        if (destinationNameInvalid) {   
+            // Validation function has modified destination name 
+            // to be error string
+            showRenameError(destinationName);
+        } else {
+            OstTrace0(TRACE_NORMAL, CPDESTINATIONENTRYITEMDATA_SAVENEWDESTINATIONNAME, "CpDestinationEntryItemData::saveNewDestinationName: emit destination changed");
+            emit destChanged();
+        }
     }
     OstTraceFunctionExit0(DUP1_CPDESTINATIONENTRYITEMDATA_SAVENEWDESTINATIONNAME_EXIT);
 }
@@ -730,7 +756,9 @@
     note->setAttribute(Qt::WA_DeleteOnClose);
     note->setText(info);
     note->setTimeout(HbPopup::NoTimeout);
-    HbAction *errorOk = new HbAction(hbTrId("txt_common_button_ok"));
+    HbAction *errorOk = new HbAction(
+        hbTrId("txt_common_button_ok"),
+        note);
     bool connected = connect(
         errorOk,
         SIGNAL(triggered()),
@@ -755,8 +783,51 @@
     note->setAttribute(Qt::WA_DeleteOnClose);
     note->setText(info);
     note->setTimeout(HbPopup::NoTimeout);
-    HbAction *errorOk = new HbAction(hbTrId("txt_common_button_ok"));                       
+    HbAction *errorOk = new HbAction(
+        hbTrId("txt_common_button_ok"),
+        note);
     note->addAction(errorOk);
     note->show();    
     OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_SHOWERRORNOTE_EXIT);
 }
+
+/*!
+    Helper function for showing icons.
+    
+    \return Returns string representing given destination's icon
+ */
+QString CpDestinationEntryItemData::resolveApIcon(QSharedPointer<CmConnectionMethodShim> cm) const
+{
+    QString result(cm->getIcon());
+    
+    if (result.isEmpty()) {
+        uint bearerType = cm->getIntAttribute(CMManagerShim::CmBearerType);
+        switch (bearerType) {
+            case CMManagerShim::BearerTypeWlan:
+                result = "qtg_small_wlan";
+                break;
+            case CMManagerShim::BearerTypePacketData:
+                result = "qtg_small_gprs";
+                break;
+            default:
+                // Unknown bearer type
+                break;
+        }
+    }
+    return result;
+}
+
+/*!
+    Event filter for updating priorities when arrange mode is active.
+    
+    \return Returns false so that event gets forwarded
+ */
+bool CpDestinationEntryItemData::eventFilter(QObject *object, QEvent *event)
+{
+    Q_UNUSED(object);
+    if (event->type() == QEvent::GraphicsSceneMouseRelease) {
+        updateIndex();
+    }
+    return false;
+}
+
--- a/cmmanager/cpdestinationplugin/src/cpdestinationgroup.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/src/cpdestinationgroup.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 #include <QDir>
 #include <QPluginLoader>
 #include <QStringList>
-#include <HbDataform>
+#include <HbDataForm>
 #include <HbDataFormModel>
 #include <HbDataFormViewItem>
 #include <HbParameterLengthLimiter>
@@ -79,7 +79,7 @@
     // Create Destination list
     for (int i = 0; i < destinationList.count(); i++) {
         QString iapCount = 
-			getDestinationAdditionalText(destinationList.at(i)->connectionMethodCount());
+			getDestinationAdditionalText(destinationList.at(i));
         
         // Create new destination entry
         CpDestinationEntryItemData *destDataItem;
@@ -88,6 +88,8 @@
         destDataItem->setContentWidgetData(QString("additionalText"),iapCount);
         destDataItem->setDestinationId(destinationList.at(i)->id());
         destDataItem->setDestinationName(destinationList.at(i)->name());
+        HbIcon destIcon(resolveDestinationIcon(destinationList.at(i)));
+        destDataItem->setEntryItemIcon(destIcon);
         bool connected = connect(destDataItem, 
                                  SIGNAL(destChanged()), 
                                  this, 
@@ -124,13 +126,14 @@
 void CpDestinationGroup::addDestination(const QString &dest, int destId)
 {
     OstTraceFunctionEntry0(CPDESTINATIONGROUP_ADDDESTINATION_ENTRY);
-    QString iapCount = getDestinationAdditionalText(0);
     
     // Create UI item for new destination
     CpDestinationEntryItemData *destDataItem;
     destDataItem = new CpDestinationEntryItemData(*mItemDataHelper);
     destDataItem->setContentWidgetData(QString("text"), dest);
-    destDataItem->setContentWidgetData(QString("additionalText"), iapCount);
+    destDataItem->setContentWidgetData(
+        QString("additionalText"), 
+        hbTrId("txt_occ_dblist_internet_val_no_access_points"));
     destDataItem->setDestinationId(destId);
     destDataItem->setDestinationName(dest);
     connect(destDataItem, SIGNAL(destChanged()), this, SLOT(updateDestinationInformation()));
@@ -204,7 +207,6 @@
 void CpDestinationGroup::updateDestinationInformation()
 {
 	OstTraceFunctionEntry0(CPDESTINATIONGROUP_UPDATEDESTINATIONINFORMATION_ENTRY);
-	int apCount = 0;
 	// "Add Destination" child is removed from count (childCount() -1)
     for (int i = 0; i < childCount() - 1; i++) {
         CpDestinationEntryItemData  *destDataItem = 
@@ -220,16 +222,9 @@
                 this->removeChild(index);
                 mUncategorisedShown = false;
                 continue;
-            }
-            apCount = apList.count();  
-        } else {
-            CmDestinationShim *destination;
-            destination = mCmManager->destination(destDataItem->destinationId());
-            apCount = destination->connectionMethodCount();
-            delete destination;
+            } 
         }
-
-        QString iapCount = getDestinationAdditionalText(apCount);
+        QString iapCount = getDestinationAdditionalText(destDataItem->destinationId());
         destDataItem->setContentWidgetData(QString("additionalText"), iapCount);
         destDataItem->setContentWidgetData(QString("text"), destDataItem->destinationName());
     }
@@ -250,10 +245,12 @@
         CpDestinationEntryItemData *destDataItem;
         destDataItem = new CpDestinationEntryItemData(*mItemDataHelper);
         destDataItem->setContentWidgetData(QString("text"), hbTrId("txt_occ_dblist_uncategorized"));
-        QString iapCount = getDestinationAdditionalText(apList.count());
+        QString iapCount = getDestinationAdditionalText(0);
         destDataItem->setContentWidgetData(QString("additionalText"),iapCount);
         destDataItem->setDestinationId(0);
         destDataItem->setDestinationName(hbTrId("txt_occ_dblist_uncategorized"));
+        HbIcon destIcon(mCmManager->getUncategorizedIcon());
+        destDataItem->setEntryItemIcon(destIcon);
         bool connected = connect(
             destDataItem, 
             SIGNAL(destChanged()), 
@@ -286,6 +283,8 @@
             destination = mCmManager->destination(destArray[i]);
             if (!destination->isHidden()) {
                 destinationList.append(QSharedPointer<CmDestinationShim>(destination));
+            } else {
+                delete destination;
             }
         }
     } catch (const std::exception&) {
@@ -317,20 +316,110 @@
 }
 
 /*!
-    Helper function to be used in localisation.
+    Helper function to be used in localisation. (Overloaded)
     
     \return Returns correct localized QString according to access point count.
  */
-QString CpDestinationGroup::getDestinationAdditionalText(int iapCount)
+QString CpDestinationGroup::getDestinationAdditionalText(QSharedPointer<CmDestinationShim> destination)
 {
     OstTraceFunctionEntry0(CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT_ENTRY);
     QString result = "";
+    int iapCount = destination->connectionMethodCount();
+    int counter = 0;
+    for (int i = 0; i < iapCount; i++) {
+        CmConnectionMethodShim *cm = destination->connectionMethod(i);
+        if (cm->getBoolAttribute(CMManagerShim::CmDestination)
+            || cm->getBoolAttribute(CMManagerShim::CmHidden)) {
+            counter++;
+        }
+        delete cm; 
+    }
+    iapCount = iapCount - counter;
     if (iapCount > 0) {
-        //result = hbTrId("txt_occ_dblist_internet_val_ln_access_points", iapCount);
-        result = HbParameterLengthLimiter("txt_occ_dblist_internet_val_ln_access_points").arg(iapCount);
+        result = hbTrId("txt_occ_dblist_internet_val_ln_access_points", iapCount);
     } else {
         result = hbTrId("txt_occ_dblist_internet_val_no_access_points");
     }
     OstTrace0(TRACE_FLOW, CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT_EXIT, "Exit");
     return result;
 }
+
+/*!
+    Helper function to be used in localisation. (Overloaded)
+    
+    \return Returns correct localized QString according to access point count.
+ */
+QString CpDestinationGroup::getDestinationAdditionalText(int destinationId)
+{
+    OstTraceFunctionEntry0(CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT2_ENTRY);
+    QString result = "";
+    int iapCount = 0;
+    int counter = 0;
+    if (destinationId == 0) {
+        QList<uint> apList;
+        mCmManager->connectionMethod(apList);
+        iapCount = apList.count();
+        for (int i = 0; i < iapCount; i++) {
+            CmConnectionMethodShim *cm = mCmManager->connectionMethod(apList[i]);
+            if (cm->getBoolAttribute(CMManagerShim::CmDestination)
+                || cm->getBoolAttribute(CMManagerShim::CmHidden)) {
+                counter++;
+            }
+            delete cm; 
+        }
+    } else {
+        CmDestinationShim *destination = mCmManager->destination(destinationId);
+        iapCount = destination->connectionMethodCount();
+        for (int i = 0; i < iapCount; i++) {
+            CmConnectionMethodShim *cm = destination->connectionMethod(i);
+            if (cm->getBoolAttribute(CMManagerShim::CmDestination)
+                || cm->getBoolAttribute(CMManagerShim::CmHidden)) {
+                counter++;
+            }
+            delete cm; 
+        }
+        delete destination;
+    }
+    iapCount = iapCount - counter;
+    if (iapCount > 0) {
+        result = hbTrId("txt_occ_dblist_internet_val_ln_access_points", iapCount);
+    } else {
+        result = hbTrId("txt_occ_dblist_internet_val_no_access_points");
+    }
+    OstTrace0(TRACE_FLOW, CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT2_EXIT, "Exit");
+    return result;
+}
+
+/*!
+    Helper function for showing icons.
+    
+    \return Returns string representing given destination's icon
+ */
+QString CpDestinationGroup::resolveDestinationIcon(
+    QSharedPointer<CmDestinationShim> destination) const
+{
+    QString result(destination->getIcon());
+    
+    if (result.isEmpty()) {
+        uint metaData = destination->metadata(CMManagerShim::SnapMetadataPurpose);
+        switch (metaData) {
+            case CMManagerShim::SnapPurposeInternet:
+                result = "qtg_small_internet";
+                break;
+            case CMManagerShim::SnapPurposeIntranet:
+                result = "qtg_small_intranet";
+                break;
+            case CMManagerShim::SnapPurposeMMS:
+                result = "qtg_small_mms";
+                break;
+            case CMManagerShim::SnapPurposeOperator:
+                result = "qtg_small_operator";
+                break;
+            default:
+                // CMManagerShim::SnapPurposeUnknown
+                result = "qtg_small_favorite";
+                break;
+        }
+    }
+    return result;
+}
--- a/cmmanager/cpdestinationplugin/src/cpiapitem.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpdestinationplugin/src/cpiapitem.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -77,10 +77,10 @@
     bool apProtected,
     CpBearerApPluginInterface *bearerPlugin) :
     CpSettingFormEntryItemData(CpSettingFormEntryItemData::ButtonEntryItem, itemDataHelper), 
-    mItemDataHelper(&itemDataHelper),
     mIapId(iapId), 
     mIapName(iapName),
     mDestId(destId),
+    mItemDataHelper(&itemDataHelper),
     mBearerPlugin(bearerPlugin),
     mMoveOngoing(false),
     mDialog(0),
@@ -103,6 +103,11 @@
             this,
             SLOT(showItemMenu(QPointF)));
         itemDataHelper.addConnection(this,SIGNAL(clicked()),this,SLOT(onLaunchView()));
+        itemDataHelper.addConnection(
+            this,
+            SIGNAL(visibleChanged()),
+            this, 
+            SLOT(updateIap()));
     }
     OstTraceFunctionExit0(CPIAPITEM_CPIAPITEM_EXIT);
 }
@@ -223,6 +228,7 @@
             CmConnectionMethodShim *cm = destination->connectionMethodByID(mIapId);
             destination->deleteConnectionMethod(cm);
             destination->update();
+            delete cm;
             delete destination;
         } else {
             CmConnectionMethodShim *cm = mCmm->connectionMethod(mIapId);
@@ -246,10 +252,9 @@
 /*!
     Updates access point item name when the item becomes visible.
  */
-void CpIapItem::updateIap(const QModelIndex index)
+void CpIapItem::updateIap()
 {
     OstTrace0( TRACE_FLOW, CPIAPITEM_UPDATEIAP_ENTRY, "CpIapItem::updateIap entry" );
-    Q_UNUSED(index);
     try {
         CmConnectionMethodShim *cm = mCmm->connectionMethod(mIapId);
         this->setContentWidgetData("text", cm->getStringAttribute(CMManagerShim::CmName));
@@ -257,18 +262,18 @@
     } catch (const std::exception&) {
         OstTrace0( TRACE_NORMAL, CPIAPITEM_UPDATEIAP, "CpIapItem::updateIap: exception caught, CM name reading failed" );
     }
-    // Disconnect because we need to do this only after returning
-    // from accees point settings view
-    CpItemDataHelper *itemDataHelper = new CpItemDataHelper();
-    itemDataHelper->disconnectFromForm( 
-        SIGNAL(itemShown(const QModelIndex)),
-        this, 
-        SLOT(updateIap(const QModelIndex)));
-    delete itemDataHelper;
     OstTrace0( TRACE_FLOW, DUP1_CPIAPITEM_UPDATEIAP_EXIT, "CpIapItem::updateIap exit" );
 }
 
 /*!
+    Opens Iap settings view.
+ */
+void CpIapItem::openIap()
+{
+    onLaunchView();
+}
+
+/*!
     Gets access point specific view from bearer plugin.
     
     \return Returns settings view containing access point settings.
@@ -277,16 +282,16 @@
 {
     OstTraceFunctionEntry0(CPIAPITEM_CREATESETTINGVIEW_ENTRY);
     CpBaseSettingView *view = NULL;
-    CpItemDataHelper *itemDataHelper = new CpItemDataHelper();
     if (mBearerPlugin != NULL) {
-        CpIapItem *iap = const_cast<CpIapItem*>(this);
-        itemDataHelper->connectToForm( 
-            SIGNAL(itemShown(const QModelIndex)),
-            iap, 
-            SLOT(updateIap(const QModelIndex)));
-        view = mBearerPlugin->createSettingView(mIapId);
+        CmConnectionMethodShim *cm = mCmm->connectionMethod(mIapId);
+        bool cmConnected = cm->getBoolAttribute(CMManagerShim::CmConnected);
+        delete cm;
+        
+        // Do not open connected AP
+        if (!cmConnected) {
+            view = mBearerPlugin->createSettingView(mIapId);
+        }
     }
-    delete itemDataHelper;
     OstTraceFunctionExit0(CPIAPITEM_CREATESETTINGVIEW_EXIT);
     return view;
 }
@@ -446,9 +451,13 @@
     OstTraceFunctionEntry0(CPIAPITEM_CREATEITEMMENU_ENTRY);
     HbMenu* menu = new HbMenu();
     menu->setAttribute(Qt::WA_DeleteOnClose);
+    HbAction* openIapAction 
+            = menu->addAction(hbTrId("txt_common_menu_open"));
+    bool connected = connect(openIapAction, SIGNAL(triggered()), this, SLOT(openIap()));
+    Q_ASSERT(connected);
     HbAction* moveIapAction 
         = menu->addAction(hbTrId("txt_occ_menu_move_to_other_destination"));
-    bool connected = connect(moveIapAction, SIGNAL(triggered()), this, SLOT(moveIap()));
+    connected = connect(moveIapAction, SIGNAL(triggered()), this, SLOT(moveIap()));
     Q_ASSERT(connected);
     HbAction* deleteIapAction 
         = menu->addAction(hbTrId("txt_common_menu_delete"));
@@ -465,6 +474,7 @@
        
     if (cmConnected) {
         // Disable operations for connected APs
+        openIapAction->setDisabled(true);
         moveIapAction->setDisabled(true);
         deleteIapAction->setDisabled(true);
         shareIapAction->setDisabled(true);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/hbautotest.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,831 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "hbautotest.h"
+#include <hbmainwindow.h>
+#include <hbwidget.h>
+
+
+const qreal STEP = 4; //How many pixels to drag before sending an event
+
+//Init static members
+bool HbAutoTest::pointerPressed = false;
+QPointF HbAutoTest::pressPoint = QPointF();
+
+void HbAutoTest::mouseMove (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos, int delay)
+{
+    if (delay!=-1) {
+        QTest::qWait(delay);
+    }
+    QPointF targetPoint=QPointF();
+    if (pos==QPointF()) {
+        targetPoint = middlePointOfWidget(widget);
+    } else {
+        targetPoint = widget->mapToScene(pos);
+    }
+    if (pointerPressed) {
+        //Now we should drag an item
+        drag(window, targetPoint);
+            HbAutoTestMouseEvent me (
+            QEvent::MouseMove, 
+            targetPoint.toPoint(), 
+            window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+            Qt::NoButton, 
+            Qt::NoButton, 
+            Qt::NoModifier);
+            QSpontaneKeyEvent::setSpontaneous(&me);
+            qApp->notify((window->viewport()), &me);
+            QCoreApplication::sendPostedEvents();
+            QTest::qWait(1);
+    } else {
+            HbAutoTestMouseEvent me (
+            QEvent::MouseMove, 
+            targetPoint.toPoint(), 
+            window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+            Qt::NoButton, 
+            Qt::NoButton, 
+            Qt::NoModifier);
+            QSpontaneKeyEvent::setSpontaneous(&me);
+            qApp->notify((window->viewport()), &me);
+            QCoreApplication::sendPostedEvents();
+            QTest::qWait(1);
+
+    }
+    QTest::qWait(1);
+    QTest::qWait(1);
+}
+ 
+void HbAutoTest::mousePress (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos, int delay)
+{
+    if (delay!=-1) {
+        QTest::qWait(delay);
+    }
+    pointerPressed=true;
+    QPointF targetPoint=QPointF();
+    if (pos==QPointF()) {
+        targetPoint = middlePointOfWidget(widget);
+    } else {
+        targetPoint = widget->mapToScene(pos);
+    }
+    QCursor::setPos(window->mapToGlobal(targetPoint.toPoint()));
+
+    pressPoint=targetPoint;
+    
+    HbAutoTestMouseEvent me (
+    QEvent::MouseButtonPress, 
+    targetPoint.toPoint(), 
+    window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+    Qt::LeftButton, 
+    Qt::LeftButton, 
+    Qt::NoModifier);
+
+    QSpontaneKeyEvent::setSpontaneous(&me);
+    qApp->notify((window->viewport()), &me);
+    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendPostedEvents();
+    QTest::qWait(1);
+}
+
+void HbAutoTest::mouseRelease (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos, int delay)
+{
+    if (delay!=-1) {
+        QTest::qWait(delay);
+    }
+    pointerPressed=false;
+    QPointF targetPoint=QPointF();
+    if (pos==QPointF()) {
+        targetPoint = middlePointOfWidget(widget);
+    } else {
+        targetPoint = widget->mapToScene(pos);
+    }
+    QCursor::setPos(window->mapToGlobal(targetPoint.toPoint()));
+    pressPoint=QPointF();
+    HbAutoTestMouseEvent me (
+    QEvent::MouseButtonRelease, 
+    targetPoint.toPoint(), 
+    window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+    Qt::LeftButton, 
+    Qt::NoButton, 
+    Qt::NoModifier);
+
+    QSpontaneKeyEvent::setSpontaneous(&me);
+    qApp->notify((window->viewport()), &me);
+    QCoreApplication::sendPostedEvents();
+
+    QTest::qWait(1);
+    QTest::qWait(1);
+}
+
+void HbAutoTest::mouseClick (HbAutoTestMainWindow *window, const HbWidget *widget, QPointF pos, int delay)
+{
+    if (delay!=-1) {
+        QTest::qWait(delay);
+    }
+    QPointF targetPoint=QPointF();
+    if (pos==QPointF()) {
+        targetPoint = middlePointOfWidget(widget);
+    } else {
+        targetPoint = widget->mapToScene(pos);
+    }
+    
+    QCursor::setPos(window->mapToGlobal(targetPoint.toPoint()));
+    
+    HbAutoTestMouseEvent me (
+    QEvent::MouseButtonPress, 
+    targetPoint.toPoint(), 
+    window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+    Qt::LeftButton, 
+    Qt::LeftButton, 
+    Qt::NoModifier);
+    QSpontaneKeyEvent::setSpontaneous(&me);
+    qApp->notify((window->viewport()), &me);
+    QCoreApplication::sendPostedEvents();
+    QTest::qWait(1);
+
+    if (delay!=-1) {
+        QTest::qWait(delay);
+    }
+    HbAutoTestMouseEvent me2 (
+    QEvent::MouseButtonRelease, 
+    targetPoint.toPoint(), 
+    window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+    Qt::LeftButton, 
+    Qt::NoButton,
+    Qt::NoModifier);
+
+    QSpontaneKeyEvent::setSpontaneous(&me2);
+    qApp->notify((window->viewport()), &me2);
+    QCoreApplication::sendPostedEvents();
+
+    QTest::qWait(1);
+    QTest::qWait(1);
+}   
+
+QPointF HbAutoTest::middlePointOfWidget( const HbWidget* widget)
+{
+    QRectF widgetRect = widget->rect();
+    QRectF widgetSceneRect = widget->mapRectToScene(widgetRect);
+    qreal middleX = ((widgetSceneRect.right() - widgetSceneRect.left())/2)+widgetSceneRect.left();
+    qreal middleY = ((widgetSceneRect.bottom() - widgetSceneRect.top())/2)+widgetSceneRect.top();  
+    return QPointF(middleX,middleY);
+}
+
+
+
+void HbAutoTest::drag(HbAutoTestMainWindow *window, QPointF targetPoint)
+{
+    qreal tempX = targetPoint.x() - pressPoint.x();
+    qreal tempY = targetPoint.y() - pressPoint.y();
+    qreal totalTrip = sqrt ((tempX * tempX) + (tempY * tempY));
+    
+    int numberOfSteps = qRound(totalTrip / STEP);
+    HbAutoTestMouseEvent me (
+        QEvent::MouseMove, 
+        targetPoint.toPoint(), 
+        window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+        Qt::NoButton , 
+        Qt::LeftButton, 
+        Qt::NoModifier);
+
+    QPointF nextPanPoint=pressPoint;
+    for (int i=1; i<numberOfSteps; i++) { //On purpose not =<
+        
+        nextPanPoint.setY (pressPoint.y()+((i / (qreal)numberOfSteps) * tempY));
+        nextPanPoint.setX (pressPoint.x()+((i / (qreal)numberOfSteps) * tempX));
+        
+        QCursor::setPos(window->mapToGlobal(nextPanPoint.toPoint()));
+
+        me =  HbAutoTestMouseEvent (QEvent::MouseMove,
+                            nextPanPoint.toPoint(), 
+                            window->viewport()->mapToGlobal(nextPanPoint.toPoint()), 
+                            Qt::NoButton, 
+                            Qt::LeftButton, 
+                            Qt::NoModifier);   
+
+        QSpontaneKeyEvent::setSpontaneous(&me);
+        qApp->notify((window->viewport()), &me);
+        QCoreApplication::sendPostedEvents();
+    }
+
+    QCursor::setPos(window->mapToGlobal(targetPoint.toPoint()));
+
+    //One more (or the only one) step to the target
+    me =  HbAutoTestMouseEvent (QEvent::MouseMove,
+                            targetPoint.toPoint(), 
+                            window->viewport()->mapToGlobal(targetPoint.toPoint()), 
+                            Qt::NoButton, 
+                            Qt::LeftButton, 
+                            Qt::NoModifier);   
+    QSpontaneKeyEvent::setSpontaneous(&me);
+    qApp->notify((window->viewport()), &me);
+    QCoreApplication::sendPostedEvents();
+}
+
+
+void HbAutoTest::simulateEvent(QWidget *widget, bool press, int code,
+                              Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay)
+    {
+        //Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        /*extern int Q_TESTLIB_EXPORT defaultKeyDelay();
+
+        if (delay == -1 || delay < defaultKeyDelay())
+            delay = defaultKeyDelay();
+        if(delay > 0)
+            QTest::qWait(delay);*/
+        Q_UNUSED(delay);
+        QTest::qWait(10); //TODO: Remove this and reveal above out-commented code
+
+        HbAutoTestKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);
+        QSpontaneKeyEvent::setSpontaneous(&a);
+        if (!qApp->notify(widget, &a))
+            QTest::qWarn("Keyboard event not accepted by receiving widget");
+    }
+
+void HbAutoTest::sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code,
+                             QString text, Qt::KeyboardModifiers modifier, int delay)
+    {
+        QTEST_ASSERT(qApp);
+
+        if (!widget)
+            widget = QWidget::keyboardGrabber();
+        if (!widget) {
+            if (QWidget *apw = QApplication::activePopupWidget())
+                widget = apw->focusWidget() ? apw->focusWidget() : apw;
+            else
+                widget = QApplication::focusWidget();
+        }
+        if (!widget)
+            widget = QApplication::activeWindow();
+
+        QTEST_ASSERT(widget);
+
+        if (action == QTest::Click) {
+            QPointer<QWidget> ptr(widget);
+            sendKeyEvent(QTest::Press, widget, code, text, modifier, delay);
+            if (!ptr) {
+                // if we send key-events to embedded widgets, they might be destroyed
+                // when the user presses Return
+                return;
+            }
+            sendKeyEvent(QTest::Release, widget, code, text, modifier, delay);
+            return;
+        }
+
+        bool repeat = false;
+
+        if (action == QTest::Press) {
+            if (modifier & Qt::ShiftModifier)
+                simulateEvent(widget, true, Qt::Key_Shift, 0, QString(), false, delay);
+
+            if (modifier & Qt::ControlModifier)
+                simulateEvent(widget, true, Qt::Key_Control, modifier & Qt::ShiftModifier, QString(), false, delay);
+
+            if (modifier & Qt::AltModifier)
+                simulateEvent(widget, true, Qt::Key_Alt,
+                              modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
+            if (modifier & Qt::MetaModifier)
+                simulateEvent(widget, true, Qt::Key_Meta, modifier & (Qt::ShiftModifier
+                                                                      | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
+            simulateEvent(widget, true, code, modifier, text, repeat, delay);
+        } else if (action == QTest::Release) {
+            simulateEvent(widget, false, code, modifier, text, repeat, delay);
+
+            if (modifier & Qt::MetaModifier)
+                simulateEvent(widget, false, Qt::Key_Meta, modifier, QString(), false, delay);
+            if (modifier & Qt::AltModifier)
+                simulateEvent(widget, false, Qt::Key_Alt, modifier &
+                              (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
+
+            if (modifier & Qt::ControlModifier)
+                simulateEvent(widget, false, Qt::Key_Control,
+                              modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
+
+            if (modifier & Qt::ShiftModifier)
+                simulateEvent(widget, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
+        }
+    }
+
+void HbAutoTest::sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code,
+                             char ascii, Qt::KeyboardModifiers modifier, int delay)
+    {
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        QString text;
+        if (ascii)
+            text = QString(QChar::fromLatin1(ascii));
+        sendKeyEvent(action, widget, code, text, modifier, delay);
+    }
+
+void HbAutoTest::keyEvent(QTest::KeyAction action, QWidget *widget, char ascii,
+                                Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        sendKeyEvent(action, widget, asciiToKey(ascii), ascii, modifier, delay); 
+     }
+     
+void HbAutoTest::keyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key key,
+                                Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        sendKeyEvent(action, widget, key, keyToAscii(key), modifier, delay); 
+     }
+
+void HbAutoTest::keyClicks(QWidget *widget, const QString &sequence,
+                                 Qt::KeyboardModifiers modifier, int delay)
+    {
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        for (int i=0; i < sequence.length(); i++)
+            keyEvent(QTest::Click, widget, sequence.at(i).toLatin1(), modifier, delay);
+    }
+
+void HbAutoTest::keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        keyEvent(QTest::Press, widget, key, modifier, delay); 
+    }
+    
+void HbAutoTest::keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        keyEvent(QTest::Release, widget, key, modifier, delay); 
+    }
+    
+void HbAutoTest::keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        keyEvent(QTest::Click, widget, key, modifier, delay); 
+    }
+    
+void HbAutoTest::keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        keyEvent(QTest::Press, widget, key, modifier, delay); 
+    }
+    
+void HbAutoTest::keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        keyEvent(QTest::Release, widget, key, modifier, delay); }
+    
+void HbAutoTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay)
+    { 
+        Q_ASSERT_X(dynamic_cast<HbAutoTestMainWindow *>(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow");
+        keyEvent(QTest::Click, widget, key, modifier, delay); 
+    }
+
+Qt::Key HbAutoTest::asciiToKey(char ascii)
+{
+    switch ((unsigned char)ascii) {
+    case 0x08: return Qt::Key_Backspace;
+    case 0x09: return Qt::Key_Tab;
+    case 0x0b: return Qt::Key_Backtab;
+    case 0x0d: return Qt::Key_Return;
+    case 0x1b: return Qt::Key_Escape;
+    case 0x20: return Qt::Key_Space;
+    case 0x21: return Qt::Key_Exclam;
+    case 0x22: return Qt::Key_QuoteDbl;
+    case 0x23: return Qt::Key_NumberSign;
+    case 0x24: return Qt::Key_Dollar;
+    case 0x25: return Qt::Key_Percent;
+    case 0x26: return Qt::Key_Ampersand;
+    case 0x27: return Qt::Key_Apostrophe;
+    case 0x28: return Qt::Key_ParenLeft;
+    case 0x29: return Qt::Key_ParenRight;
+    case 0x2a: return Qt::Key_Asterisk;
+    case 0x2b: return Qt::Key_Plus;
+    case 0x2c: return Qt::Key_Comma;
+    case 0x2d: return Qt::Key_Minus;
+    case 0x2e: return Qt::Key_Period;
+    case 0x2f: return Qt::Key_Slash;
+    case 0x30: return Qt::Key_0;
+    case 0x31: return Qt::Key_1;
+    case 0x32: return Qt::Key_2;
+    case 0x33: return Qt::Key_3;
+    case 0x34: return Qt::Key_4;
+    case 0x35: return Qt::Key_5;
+    case 0x36: return Qt::Key_6;
+    case 0x37: return Qt::Key_7;
+    case 0x38: return Qt::Key_8;
+    case 0x39: return Qt::Key_9;
+    case 0x3a: return Qt::Key_Colon;
+    case 0x3b: return Qt::Key_Semicolon;
+    case 0x3c: return Qt::Key_Less;
+    case 0x3d: return Qt::Key_Equal;
+    case 0x3e: return Qt::Key_Greater;
+    case 0x3f: return Qt::Key_Question;
+    case 0x40: return Qt::Key_At;
+    case 0x41: return Qt::Key_A;
+    case 0x42: return Qt::Key_B;
+    case 0x43: return Qt::Key_C;
+    case 0x44: return Qt::Key_D;
+    case 0x45: return Qt::Key_E;
+    case 0x46: return Qt::Key_F;
+    case 0x47: return Qt::Key_G;
+    case 0x48: return Qt::Key_H;
+    case 0x49: return Qt::Key_I;
+    case 0x4a: return Qt::Key_J;
+    case 0x4b: return Qt::Key_K;
+    case 0x4c: return Qt::Key_L;
+    case 0x4d: return Qt::Key_M;
+    case 0x4e: return Qt::Key_N;
+    case 0x4f: return Qt::Key_O;
+    case 0x50: return Qt::Key_P;
+    case 0x51: return Qt::Key_Q;
+    case 0x52: return Qt::Key_R;
+    case 0x53: return Qt::Key_S;
+    case 0x54: return Qt::Key_T;
+    case 0x55: return Qt::Key_U;
+    case 0x56: return Qt::Key_V;
+    case 0x57: return Qt::Key_W;
+    case 0x58: return Qt::Key_X;
+    case 0x59: return Qt::Key_Y;
+    case 0x5a: return Qt::Key_Z;
+    case 0x5b: return Qt::Key_BracketLeft;
+    case 0x5c: return Qt::Key_Backslash;
+    case 0x5d: return Qt::Key_BracketRight;
+    case 0x5e: return Qt::Key_AsciiCircum;
+    case 0x5f: return Qt::Key_Underscore;
+    case 0x60: return Qt::Key_QuoteLeft;
+    case 0x61: return Qt::Key_A;
+    case 0x62: return Qt::Key_B;
+    case 0x63: return Qt::Key_C;
+    case 0x64: return Qt::Key_D;
+    case 0x65: return Qt::Key_E;
+    case 0x66: return Qt::Key_F;
+    case 0x67: return Qt::Key_G;
+    case 0x68: return Qt::Key_H;
+    case 0x69: return Qt::Key_I;
+    case 0x6a: return Qt::Key_J;
+    case 0x6b: return Qt::Key_K;
+    case 0x6c: return Qt::Key_L;
+    case 0x6d: return Qt::Key_M;
+    case 0x6e: return Qt::Key_N;
+    case 0x6f: return Qt::Key_O;
+    case 0x70: return Qt::Key_P;
+    case 0x71: return Qt::Key_Q;
+    case 0x72: return Qt::Key_R;
+    case 0x73: return Qt::Key_S;
+    case 0x74: return Qt::Key_T;
+    case 0x75: return Qt::Key_U;
+    case 0x76: return Qt::Key_V;
+    case 0x77: return Qt::Key_W;
+    case 0x78: return Qt::Key_X;
+    case 0x79: return Qt::Key_Y;
+    case 0x7a: return Qt::Key_Z;
+    case 0x7b: return Qt::Key_BraceLeft;
+    case 0x7c: return Qt::Key_Bar;
+    case 0x7d: return Qt::Key_BraceRight;
+    case 0x7e: return Qt::Key_AsciiTilde;
+
+    // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06
+    case 0xa0: return Qt::Key_nobreakspace;
+    case 0xa1: return Qt::Key_exclamdown;
+    case 0xa2: return Qt::Key_cent;
+    case 0xa3: return Qt::Key_sterling;
+    case 0xa4: return Qt::Key_currency;
+    case 0xa5: return Qt::Key_yen;
+    case 0xa6: return Qt::Key_brokenbar;
+    case 0xa7: return Qt::Key_section;
+    case 0xa8: return Qt::Key_diaeresis;
+    case 0xa9: return Qt::Key_copyright;
+    case 0xaa: return Qt::Key_ordfeminine;
+    case 0xab: return Qt::Key_guillemotleft;
+    case 0xac: return Qt::Key_notsign;
+    case 0xad: return Qt::Key_hyphen;
+    case 0xae: return Qt::Key_registered;
+    case 0xaf: return Qt::Key_macron;
+    case 0xb0: return Qt::Key_degree;
+    case 0xb1: return Qt::Key_plusminus;
+    case 0xb2: return Qt::Key_twosuperior;
+    case 0xb3: return Qt::Key_threesuperior;
+    case 0xb4: return Qt::Key_acute;
+    case 0xb5: return Qt::Key_mu;
+    case 0xb6: return Qt::Key_paragraph;
+    case 0xb7: return Qt::Key_periodcentered;
+    case 0xb8: return Qt::Key_cedilla;
+    case 0xb9: return Qt::Key_onesuperior;
+    case 0xba: return Qt::Key_masculine;
+    case 0xbb: return Qt::Key_guillemotright;
+    case 0xbc: return Qt::Key_onequarter;
+    case 0xbd: return Qt::Key_onehalf;
+    case 0xbe: return Qt::Key_threequarters;
+    case 0xbf: return Qt::Key_questiondown;
+    case 0xc0: return Qt::Key_Agrave;
+    case 0xc1: return Qt::Key_Aacute;
+    case 0xc2: return Qt::Key_Acircumflex;
+    case 0xc3: return Qt::Key_Atilde;
+    case 0xc4: return Qt::Key_Adiaeresis;
+    case 0xc5: return Qt::Key_Aring;
+    case 0xc6: return Qt::Key_AE;
+    case 0xc7: return Qt::Key_Ccedilla;
+    case 0xc8: return Qt::Key_Egrave;
+    case 0xc9: return Qt::Key_Eacute;
+    case 0xca: return Qt::Key_Ecircumflex;
+    case 0xcb: return Qt::Key_Ediaeresis;
+    case 0xcc: return Qt::Key_Igrave;
+    case 0xcd: return Qt::Key_Iacute;
+    case 0xce: return Qt::Key_Icircumflex;
+    case 0xcf: return Qt::Key_Idiaeresis;
+    case 0xd0: return Qt::Key_ETH;
+    case 0xd1: return Qt::Key_Ntilde;
+    case 0xd2: return Qt::Key_Ograve;
+    case 0xd3: return Qt::Key_Oacute;
+    case 0xd4: return Qt::Key_Ocircumflex;
+    case 0xd5: return Qt::Key_Otilde;
+    case 0xd6: return Qt::Key_Odiaeresis;
+    case 0xd7: return Qt::Key_multiply;
+    case 0xd8: return Qt::Key_Ooblique;
+    case 0xd9: return Qt::Key_Ugrave;
+    case 0xda: return Qt::Key_Uacute;
+    case 0xdb: return Qt::Key_Ucircumflex;
+    case 0xdc: return Qt::Key_Udiaeresis;
+    case 0xdd: return Qt::Key_Yacute;
+    case 0xde: return Qt::Key_THORN;
+    case 0xdf: return Qt::Key_ssharp;
+    case 0xe5: return Qt::Key_Aring;
+    case 0xe6: return Qt::Key_AE;
+    case 0xf7: return Qt::Key_division;
+    case 0xf8: return Qt::Key_Ooblique;
+    case 0xff: return Qt::Key_ydiaeresis;
+    default: QTEST_ASSERT(false); return Qt::Key(0);
+    }
+}
+
+char HbAutoTest::keyToAscii(Qt::Key key)
+{
+    switch (key) {
+    case Qt::Key_Backspace: return 0x8; //BS
+    case Qt::Key_Tab: return 0x09; // HT
+    case Qt::Key_Backtab: return 0x0b; // VT
+    case Qt::Key_Enter:
+    case Qt::Key_Return: return 0x0d; // CR
+    case Qt::Key_Escape: return 0x1b; // ESC
+    case Qt::Key_Space: return 0x20;        // 7 bit printable ASCII
+    case Qt::Key_Exclam: return 0x21;
+    case Qt::Key_QuoteDbl: return 0x22;
+    case Qt::Key_NumberSign: return 0x23;
+    case Qt::Key_Dollar: return 0x24;
+    case Qt::Key_Percent: return 0x25;
+    case Qt::Key_Ampersand: return 0x26;
+    case Qt::Key_Apostrophe: return 0x27;
+    case Qt::Key_ParenLeft: return 0x28;
+    case Qt::Key_ParenRight: return 0x29;
+    case Qt::Key_Asterisk: return 0x2a;
+    case Qt::Key_Plus: return 0x2b;
+    case Qt::Key_Comma: return 0x2c;
+    case Qt::Key_Minus: return 0x2d;
+    case Qt::Key_Period: return 0x2e;
+    case Qt::Key_Slash: return 0x2f;
+    case Qt::Key_0: return 0x30;
+    case Qt::Key_1: return 0x31;
+    case Qt::Key_2: return 0x32;
+    case Qt::Key_3: return 0x33;
+    case Qt::Key_4: return 0x34;
+    case Qt::Key_5: return 0x35;
+    case Qt::Key_6: return 0x36;
+    case Qt::Key_7: return 0x37;
+    case Qt::Key_8: return 0x38;
+    case Qt::Key_9: return 0x39;
+    case Qt::Key_Colon: return 0x3a;
+    case Qt::Key_Semicolon: return 0x3b;
+    case Qt::Key_Less: return 0x3c;
+    case Qt::Key_Equal: return 0x3d;
+    case Qt::Key_Greater: return 0x3e;
+    case Qt::Key_Question: return 0x3f;
+    case Qt::Key_At: return 0x40;
+    case Qt::Key_A: return 0x61; // 0x41 == 'A', 0x61 == 'a'
+    case Qt::Key_B: return 0x62;
+    case Qt::Key_C: return 0x63;
+    case Qt::Key_D: return 0x64;
+    case Qt::Key_E: return 0x65;
+    case Qt::Key_F: return 0x66;
+    case Qt::Key_G: return 0x67;
+    case Qt::Key_H: return 0x68;
+    case Qt::Key_I: return 0x69;
+    case Qt::Key_J: return 0x6a;
+    case Qt::Key_K: return 0x6b;
+    case Qt::Key_L: return 0x6c;
+    case Qt::Key_M: return 0x6d;
+    case Qt::Key_N: return 0x6e;
+    case Qt::Key_O: return 0x6f;
+    case Qt::Key_P: return 0x70;
+    case Qt::Key_Q: return 0x71;
+    case Qt::Key_R: return 0x72;
+    case Qt::Key_S: return 0x73;
+    case Qt::Key_T: return 0x74;
+    case Qt::Key_U: return 0x75;
+    case Qt::Key_V: return 0x76;
+    case Qt::Key_W: return 0x77;
+    case Qt::Key_X: return 0x78;
+    case Qt::Key_Y: return 0x79;
+    case Qt::Key_Z: return 0x7a;
+    case Qt::Key_BracketLeft: return 0x5b;
+    case Qt::Key_Backslash: return 0x5c;
+    case Qt::Key_BracketRight: return 0x5d;
+    case Qt::Key_AsciiCircum: return 0x5e;
+    case Qt::Key_Underscore: return 0x5f;
+    case Qt::Key_QuoteLeft: return 0x60;
+
+    case Qt::Key_BraceLeft: return 0x7b;
+    case Qt::Key_Bar: return 0x7c;
+    case Qt::Key_BraceRight: return 0x7d;
+    case Qt::Key_AsciiTilde: return 0x7e;
+
+    case Qt::Key_Delete: return 0;
+    case Qt::Key_Insert: return 0; // = 0x1006,
+    case Qt::Key_Pause: return 0; // = 0x1008,
+    case Qt::Key_Print: return 0; // = 0x1009,
+    case Qt::Key_SysReq: return 0; // = 0x100a,
+
+    case Qt::Key_Clear: return 0; // = 0x100b,
+
+    case Qt::Key_Home: return 0; // = 0x1010,        // cursor movement
+    case Qt::Key_End: return 0; // = 0x1011,
+    case Qt::Key_Left: return 0; // = 0x1012,
+    case Qt::Key_Up: return 0; // = 0x1013,
+    case Qt::Key_Right: return 0; // = 0x1014,
+    case Qt::Key_Down: return 0; // = 0x1015,
+    case Qt::Key_PageUp: return 0; // = 0x1016,
+    case Qt::Key_PageDown: return 0; // = 0x1017,
+    case Qt::Key_Shift: return 0; // = 0x1020,        // modifiers
+    case Qt::Key_Control: return 0; // = 0x1021,
+    case Qt::Key_Meta: return 0; // = 0x1022,
+    case Qt::Key_Alt: return 0; // = 0x1023,
+    case Qt::Key_CapsLock: return 0; // = 0x1024,
+    case Qt::Key_NumLock: return 0; // = 0x1025,
+    case Qt::Key_ScrollLock: return 0; // = 0x1026,
+    case Qt::Key_F1: return 0; // = 0x1030,        // function keys
+    case Qt::Key_F2: return 0; // = 0x1031,
+    case Qt::Key_F3: return 0; // = 0x1032,
+    case Qt::Key_F4: return 0; // = 0x1033,
+    case Qt::Key_F5: return 0; // = 0x1034,
+    case Qt::Key_F6: return 0; // = 0x1035,
+    case Qt::Key_F7: return 0; // = 0x1036,
+    case Qt::Key_F8: return 0; // = 0x1037,
+    case Qt::Key_F9: return 0; // = 0x1038,
+    case Qt::Key_F10: return 0; // = 0x1039,
+    case Qt::Key_F11: return 0; // = 0x103a,
+    case Qt::Key_F12: return 0; // = 0x103b,
+    case Qt::Key_F13: return 0; // = 0x103c,
+    case Qt::Key_F14: return 0; // = 0x103d,
+    case Qt::Key_F15: return 0; // = 0x103e,
+    case Qt::Key_F16: return 0; // = 0x103f,
+    case Qt::Key_F17: return 0; // = 0x1040,
+    case Qt::Key_F18: return 0; // = 0x1041,
+    case Qt::Key_F19: return 0; // = 0x1042,
+    case Qt::Key_F20: return 0; // = 0x1043,
+    case Qt::Key_F21: return 0; // = 0x1044,
+    case Qt::Key_F22: return 0; // = 0x1045,
+    case Qt::Key_F23: return 0; // = 0x1046,
+    case Qt::Key_F24: return 0; // = 0x1047,
+    case Qt::Key_F25: return 0; // = 0x1048,        // F25 .. F35 only on X11
+    case Qt::Key_F26: return 0; // = 0x1049,
+    case Qt::Key_F27: return 0; // = 0x104a,
+    case Qt::Key_F28: return 0; // = 0x104b,
+    case Qt::Key_F29: return 0; // = 0x104c,
+    case Qt::Key_F30: return 0; // = 0x104d,
+    case Qt::Key_F31: return 0; // = 0x104e,
+    case Qt::Key_F32: return 0; // = 0x104f,
+    case Qt::Key_F33: return 0; // = 0x1050,
+    case Qt::Key_F34: return 0; // = 0x1051,
+    case Qt::Key_F35: return 0; // = 0x1052,
+    case Qt::Key_Super_L: return 0; // = 0x1053,        // extra keys
+    case Qt::Key_Super_R: return 0; // = 0x1054,
+    case Qt::Key_Menu: return 0; // = 0x1055,
+    case Qt::Key_Hyper_L: return 0; // = 0x1056,
+    case Qt::Key_Hyper_R: return 0; // = 0x1057,
+    case Qt::Key_Help: return 0; // = 0x1058,
+    case Qt::Key_Direction_L: return 0; // = 0x1059,
+    case Qt::Key_Direction_R: return 0; // = 0x1060,
+
+    // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06
+    case Qt::Key_nobreakspace: return char(0xa0);
+    case Qt::Key_exclamdown: return char(0xa1);
+    case Qt::Key_cent: return char(0xa2);
+    case Qt::Key_sterling: return char(0xa3);
+    case Qt::Key_currency: return char(0xa4);
+    case Qt::Key_yen: return char(0xa5);
+    case Qt::Key_brokenbar: return char(0xa6);
+    case Qt::Key_section: return char(0xa7);
+    case Qt::Key_diaeresis: return char(0xa8);
+    case Qt::Key_copyright: return char(0xa9);
+    case Qt::Key_ordfeminine: return char(0xaa);
+    case Qt::Key_guillemotleft: return char(0xab); // left angle quotation mar
+    case Qt::Key_notsign: return char(0xac);
+    case Qt::Key_hyphen: return char(0xad);
+    case Qt::Key_registered: return char(0xae);
+    case Qt::Key_macron: return char(0xaf);
+    case Qt::Key_degree: return char(0xb0);
+    case Qt::Key_plusminus: return char(0xb1);
+    case Qt::Key_twosuperior: return char(0xb2);
+    case Qt::Key_threesuperior: return char(0xb3);
+    case Qt::Key_acute: return char(0xb4);
+    case Qt::Key_mu: return char(0xb5);
+    case Qt::Key_paragraph: return char(0xb6);
+    case Qt::Key_periodcentered: return char(0xb7);
+    case Qt::Key_cedilla: return char(0xb8);
+    case Qt::Key_onesuperior: return char(0xb9);
+    case Qt::Key_masculine: return char(0xba);
+    case Qt::Key_guillemotright: return char(0xbb); // right angle quotation mar
+    case Qt::Key_onequarter: return char(0xbc);
+    case Qt::Key_onehalf: return char(0xbd);
+    case Qt::Key_threequarters: return char(0xbe);
+    case Qt::Key_questiondown: return char(0xbf);
+    case Qt::Key_Agrave: return char(0xc0);
+    case Qt::Key_Aacute: return char(0xc1);
+    case Qt::Key_Acircumflex: return char(0xc2);
+    case Qt::Key_Atilde: return char(0xc3);
+    case Qt::Key_Adiaeresis: return char(0xc4);
+    case Qt::Key_Aring: return char(0xe5);
+    case Qt::Key_AE: return char(0xe6);
+    case Qt::Key_Ccedilla: return char(0xc7);
+    case Qt::Key_Egrave: return char(0xc8);
+    case Qt::Key_Eacute: return char(0xc9);
+    case Qt::Key_Ecircumflex: return char(0xca);
+    case Qt::Key_Ediaeresis: return char(0xcb);
+    case Qt::Key_Igrave: return char(0xcc);
+    case Qt::Key_Iacute: return char(0xcd);
+    case Qt::Key_Icircumflex: return char(0xce);
+    case Qt::Key_Idiaeresis: return char(0xcf);
+    case Qt::Key_ETH: return char(0xd0);
+    case Qt::Key_Ntilde: return char(0xd1);
+    case Qt::Key_Ograve: return char(0xd2);
+    case Qt::Key_Oacute: return char(0xd3);
+    case Qt::Key_Ocircumflex: return char(0xd4);
+    case Qt::Key_Otilde: return char(0xd5);
+    case Qt::Key_Odiaeresis: return char(0xd6);
+    case Qt::Key_multiply: return char(0xd7);
+    case Qt::Key_Ooblique: return char(0xf8);
+    case Qt::Key_Ugrave: return char(0xd9);
+    case Qt::Key_Uacute: return char(0xda);
+    case Qt::Key_Ucircumflex: return char(0xdb);
+    case Qt::Key_Udiaeresis: return char(0xdc);
+    case Qt::Key_Yacute: return char(0xdd);
+    case Qt::Key_THORN: return char(0xde);
+    case Qt::Key_ssharp: return char(0xdf);
+    case Qt::Key_division: return char(0xf7);
+    case Qt::Key_ydiaeresis: return char(0xff);
+
+    // multimedia/internet keys - ignored by default - see QKeyEvent c'tor
+
+    case Qt::Key_Back : return 0; // = 0x1061,
+    case Qt::Key_Forward : return 0; // = 0x1062,
+    case Qt::Key_Stop : return 0; // = 0x1063,
+    case Qt::Key_Refresh : return 0; // = 0x1064,
+
+    case Qt::Key_VolumeDown: return 0; // = 0x1070,
+    case Qt::Key_VolumeMute : return 0; // = 0x1071,
+    case Qt::Key_VolumeUp: return 0; // = 0x1072,
+    case Qt::Key_BassBoost: return 0; // = 0x1073,
+    case Qt::Key_BassUp: return 0; // = 0x1074,
+    case Qt::Key_BassDown: return 0; // = 0x1075,
+    case Qt::Key_TrebleUp: return 0; // = 0x1076,
+    case Qt::Key_TrebleDown: return 0; // = 0x1077,
+
+    case Qt::Key_MediaPlay : return 0; // = 0x1080,
+    case Qt::Key_MediaStop : return 0; // = 0x1081,
+    case Qt::Key_MediaPrevious : return 0; // = 0x1082,
+    case Qt::Key_MediaNext : return 0; // = 0x1083,
+    case Qt::Key_MediaRecord: return 0; // = 0x1084,
+
+    case Qt::Key_HomePage : return 0; // = 0x1090,
+    case Qt::Key_Favorites : return 0; // = 0x1091,
+    case Qt::Key_Search : return 0; // = 0x1092,
+    case Qt::Key_Standby: return 0; // = 0x1093,
+    case Qt::Key_OpenUrl: return 0; // = 0x1094,
+
+    case Qt::Key_LaunchMail : return 0; // = 0x10a0,
+    case Qt::Key_LaunchMedia: return 0; // = 0x10a1,
+    case Qt::Key_Launch0 : return 0; // = 0x10a2,
+    case Qt::Key_Launch1 : return 0; // = 0x10a3,
+    case Qt::Key_Launch2 : return 0; // = 0x10a4,
+    case Qt::Key_Launch3 : return 0; // = 0x10a5,
+    case Qt::Key_Launch4 : return 0; // = 0x10a6,
+    case Qt::Key_Launch5 : return 0; // = 0x10a7,
+    case Qt::Key_Launch6 : return 0; // = 0x10a8,
+    case Qt::Key_Launch7 : return 0; // = 0x10a9,
+    case Qt::Key_Launch8 : return 0; // = 0x10aa,
+    case Qt::Key_Launch9 : return 0; // = 0x10ab,
+    case Qt::Key_LaunchA : return 0; // = 0x10ac,
+    case Qt::Key_LaunchB : return 0; // = 0x10ad,
+    case Qt::Key_LaunchC : return 0; // = 0x10ae,
+    case Qt::Key_LaunchD : return 0; // = 0x10af,
+    case Qt::Key_LaunchE : return 0; // = 0x10b0,
+    case Qt::Key_LaunchF : return 0; // = 0x10b1,
+
+    default: QTEST_ASSERT(false); return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/hbautotest.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,279 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HBAUTOTEST_H
+#define HBAUTOTEST_H
+
+#include <hbnamespace.h>
+#include <hbmainwindow.h>
+#include <QtTest/QtTest>
+
+class HbMainWindow;
+class HbWidget;
+class HbAutoTestMainWindow;
+class HbAutoTest;
+class HbAutoTestMouseEvent; 
+/*
+INSTRUCTIONS:
+The class HbAutoTest is meant to be used with Orbit applications auto testing instead of GUI testing APIs of QTestLib.
+
+The functions of this class is to used similarily to the related QTestLib functions.
+
+Use HbAutoTestMainWindow (defined below) instead of HbMainWindow to enble filtering.
+Filterin filters out UI events that are not sent by function defined in HbAutoTest class.
+
+*/
+
+class HbAutoTestMouseEvent : public QMouseEvent
+{
+public:
+    HbAutoTestMouseEvent(Type type, const QPoint & pos, const QPoint & globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers ) 
+        : QMouseEvent(type,pos,globalPos,button,buttons,modifiers){}
+};
+
+class HbAutoTestKeyEvent : public QKeyEvent
+{
+public:
+        HbAutoTestKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
+              bool autorep = false, ushort count = 1 ) 
+        : QKeyEvent(type, key, modifiers, text, autorep, count){}
+};
+
+class HbAutoTest 
+{
+public:
+    
+    static void mouseMove (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos = QPointF(), int delay = -1 );
+    static void mousePress (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos = QPointF(), int delay = -1);
+    static void mouseRelease (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos = QPointF(), int delay = -1);
+    static void mouseClick (HbAutoTestMainWindow *window, const HbWidget *widget, QPointF pos = QPointF(), int delay = -1);
+   
+private:
+    static void drag(HbAutoTestMainWindow *window, QPointF targetPoint);
+    static QPointF middlePointOfWidget( const HbWidget* widget);
+
+    static bool pointerPressed;
+    static QPointF pressPoint;
+
+//Key event Part: copy-pasted from QTestLib and modified to support HbAutoTestKeyEvent to enable filtering.
+//see HbAutoTestMainWindow below.
+public:
+    
+    static Qt::Key asciiToKey(char ascii);
+    static char keyToAscii(Qt::Key key);
+
+    static void simulateEvent(QWidget *widget, bool press, int code,
+                              Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1);
+
+    static void sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code,
+                             QString text, Qt::KeyboardModifiers modifier, int delay=-1);    
+
+    static void sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code,
+                             char ascii, Qt::KeyboardModifiers modifier, int delay=-1);
+
+    static void keyEvent(QTest::KeyAction action, QWidget *widget, char ascii,
+                                Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+ 
+    static void keyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key key,
+                                Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+
+    static void keyClicks(QWidget *widget, const QString &sequence,
+                                 Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+
+    static void keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+    
+    static void keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+    
+    static void keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+    
+    static void keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+   
+    static void keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+
+    static void keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1);
+};
+
+class HbTestEvent
+{
+public:
+    virtual void simulate(QWidget *w) = 0;
+    virtual HbTestEvent *clone() const = 0;
+
+    virtual ~HbTestEvent() {}
+};
+
+class HbTestKeyEvent: public HbTestEvent
+{
+public:
+    inline HbTestKeyEvent(QTest::KeyAction action, Qt::Key key, Qt::KeyboardModifiers modifiers, int delay)
+        : _action(action), _delay(delay), _modifiers(modifiers), _ascii(0), _key(key) {}
+    inline HbTestKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers, int delay)
+        : _action(action), _delay(delay), _modifiers(modifiers),
+          _ascii(ascii), _key(Qt::Key_unknown) {}
+    inline HbTestEvent *clone() const { return new HbTestKeyEvent(*this); }
+
+    inline void simulate(QWidget *w)
+    {
+        if (_ascii == 0)
+            HbAutoTest::keyEvent(_action, w, _key, _modifiers, _delay);
+        else
+            HbAutoTest::keyEvent(_action, w, _ascii, _modifiers, _delay);
+    } 
+
+protected:
+    QTest::KeyAction _action;
+    int _delay;
+    Qt::KeyboardModifiers _modifiers;
+    char _ascii;
+    Qt::Key _key;
+};
+
+class HbTestKeyClicksEvent: public HbTestEvent
+{
+public:
+    inline HbTestKeyClicksEvent(const QString &keys, Qt::KeyboardModifiers modifiers, int delay)
+        : _keys(keys), _modifiers(modifiers), _delay(delay) {}
+    inline HbTestEvent *clone() const { return new HbTestKeyClicksEvent(*this); }
+
+    inline void simulate(QWidget *w)
+    {
+        HbAutoTest::keyClicks(w, _keys, _modifiers, _delay);
+    }
+
+private:
+    QString _keys;
+    Qt::KeyboardModifiers _modifiers;
+    int _delay;
+};
+
+class HbTestDelayEvent: public HbTestEvent
+{
+public:
+    inline HbTestDelayEvent(int msecs): _delay(msecs) {}
+    inline HbTestEvent *clone() const { return new HbTestDelayEvent(*this); }
+
+    inline void simulate(QWidget * /*w*/) { QTest::qWait(_delay); }
+
+private:
+    int _delay;
+};
+
+class HbTestEventList: public QList<HbTestEvent *>
+{
+public:
+    inline HbTestEventList() {}
+    inline HbTestEventList(const HbTestEventList &other): QList<HbTestEvent *>()
+    { for (int i = 0; i < other.count(); ++i) append(other.at(i)->clone()); }
+    inline ~HbTestEventList()
+    { clear(); }
+    inline void clear()
+    { qDeleteAll(*this); QList<HbTestEvent *>::clear(); }
+
+    inline void addKeyClick(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { addKeyEvent(QTest::Click, qtKey, modifiers, msecs); }
+    inline void addKeyPress(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { addKeyEvent(QTest::Press, qtKey, modifiers, msecs); }
+    inline void addKeyRelease(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { addKeyEvent(QTest::Release, qtKey, modifiers, msecs); }
+    inline void addKeyEvent(QTest::KeyAction action, Qt::Key qtKey,
+                            Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { append(new HbTestKeyEvent(action, qtKey, modifiers, msecs)); }
+
+    inline void addKeyClick(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { addKeyEvent(QTest::Click, ascii, modifiers, msecs); }
+    inline void addKeyPress(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { addKeyEvent(QTest::Press, ascii, modifiers, msecs); }
+    inline void addKeyRelease(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { addKeyEvent(QTest::Release, ascii, modifiers, msecs); }
+    inline void addKeyClicks(const QString &keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { append(new HbTestKeyClicksEvent(keys, modifiers, msecs)); }
+    inline void addKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1)
+    { append(new HbTestKeyEvent(action, ascii, modifiers, msecs)); }
+
+    inline void addDelay(int msecs)
+    { append(new HbTestDelayEvent(msecs)); }
+
+    inline void simulate(QWidget *w)
+    {
+        for (int i = 0; i < count(); ++i)
+            at(i)->simulate(w);
+    }
+};
+
+class HbAutoTestMainWindow : public HbMainWindow
+{
+public:
+    HbAutoTestMainWindow() : HbMainWindow() {}
+    
+    void mousePressEvent(QMouseEvent *event)
+    {
+        qDebug(
+            "HbAutoTestMainWindow::mousePressEvent: x(%d) y(%d)",
+            event->x(),
+            event->y());
+         if ( dynamic_cast<HbAutoTestMouseEvent *>(event) ) {
+                HbMainWindow::mousePressEvent(event);
+            } else {
+                ;//Do nothing 
+         }
+    }
+
+    void mouseMoveEvent(QMouseEvent *event)
+    {
+        if ( dynamic_cast<HbAutoTestMouseEvent *>(event) ) {
+                HbMainWindow::mouseMoveEvent(event);
+            } else {
+                ;//Do nothing
+         }
+    }
+
+    void mouseReleaseEvent(QMouseEvent *event)
+    {
+         if ( dynamic_cast<HbAutoTestMouseEvent *>(event) ) {
+                HbMainWindow::mouseReleaseEvent(event);
+            } else {
+                ;//Do nothing  
+         }
+    }
+
+    void keyPressEvent(QKeyEvent *event)
+    {
+        if ( dynamic_cast<HbAutoTestKeyEvent *>(event) ) {
+                HbMainWindow::keyPressEvent(event);
+            } else {
+                ;//Do nothing  
+         }
+    }
+    void keyReleaseEvent(QKeyEvent *event)
+    {
+        if ( dynamic_cast<HbAutoTestKeyEvent *>(event) ) {
+                HbMainWindow::keyReleaseEvent(event);
+            } else {
+                ;//Do nothing  
+         }
+    }
+
+    void mouseDoubleClickEvent(QMouseEvent *event)
+    {
+        Q_UNUSED(event);
+        //Just ignore, not supported in Orbit
+    }
+};
+
+
+Q_DECLARE_METATYPE(HbTestEventList)
+#endif //HBAUTOTEST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/testcpdestinationplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,663 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Control Panel WLAN AP plugin unit testing.
+*/
+
+#include <HbApplication>
+#include <HbMainWindow>
+#include <HbView>
+#include <HbDialog>
+#include <HbRadioButtonList>
+#include <HbAction>
+#include <HbDataForm>
+#include <HbDataFormModel>
+#include <HbDataFormModelItem>
+#include <QtTest/QtTest>
+#include <cmmanager_shim.h>
+#include <cmconnectionmethod_shim.h>
+#include <cpplugininterface.h>
+#include <cppluginutility.h>
+#include <cpitemdatahelper.h>
+#include <cpsettingformitemdata.h>
+
+//#include "cmapplsettingsui_p.h"
+//#include "cmradiodialog.h"
+//#include "cpdestinationplugin.h"
+
+#include "hbautotest.h"
+#include "testcpdestinationplugin.h"
+
+// -----------------------------------------------------------------------------
+// STATIC TEST DATA
+// -----------------------------------------------------------------------------
+
+static const QString pluginDir =
+    "\\resource\\qt\\plugins\\controlpanel";
+
+static const QString pluginName = "cpdestinationplugin.dll";
+
+// Time to wait before continuing after an UI step
+static const int waitTime = 10;
+
+static const QString navigationButton = "HbNavigationButton";
+
+// UI coordinates
+static const QPoint destinationGroup(175,30);
+static const QPoint internetDestination(175,100);
+static const QPoint internetFirstAp(175,130);
+static const QPoint internetFirstApMove(175,160);
+static const QPoint internetFirstApDelete(175,210);
+static const QPoint internetFirstApShare(175,260);
+
+static const QPoint deleteDialogOk(100,300);
+
+static const QPoint tbButton(175,550);
+static const QPoint arrangeFirstAp(175,30);
+static const QPoint arrangeDragEnd(175,140);
+
+static const QPoint uncatDestination(175,455);
+static const QPoint uncatAp(175,120);
+static const QPoint uncatMenuMove(175,140);
+static const QPoint uncatMenuDelete(175,180);
+
+static const QPoint destDialogOk(100,370);
+static const QPoint destDialogSecond(100,255);
+static const QPoint destDialogThird(100,315);
+static const QPoint destDialogNewDest(100,345);
+
+static const QPoint addDestination(175,410);
+static const QPoint addDialog(175,235);
+static const QPoint addDialogOk(100,300);
+static const QPoint newDestinationRename(175,445);
+static const QPoint newDestinationDelete(175,490);
+
+static const QPoint addDialogKb(175,155);
+static const QPoint addDialogOkKb(100,225);
+
+static const QPoint secondDestination(175,195);
+static const QPoint thirdDestination(175,275);
+static const QPoint fourthDestination(175,355);
+
+
+
+#if 0
+// Destination list item for Connection Method selection
+static const QString dedicatedAccessPoint = "Dedicated access point";
+
+static const QStringList allDestinations = QStringList() <<
+    "Internet" <<
+    "My Snap" <<
+    dedicatedAccessPoint;
+
+static const QStringList allConnectionMethods = QStringList()
+    << "Home WLAN"
+    << "packet data 1"
+    << "packet data 2"
+    << "packet data 3"
+    << "Streaming"
+    << "WLAN IAP 1"
+    << "WLAN IAP 2"
+    << "WLAN IAP 3";
+
+static const QStringList gprsConnectionMethods = QStringList()
+    << "packet data 1"
+    << "packet data 2"
+    << "packet data 3"
+    << "Streaming";
+
+static const QStringList wlanConnectionMethods = QStringList()
+    << "Home WLAN"
+    << "WLAN IAP 1"
+    << "WLAN IAP 2"
+    << "WLAN IAP 3";
+#endif
+
+// -----------------------------------------------------------------------------
+// FRAMEWORK FUNCTIONS
+// -----------------------------------------------------------------------------
+
+/**
+ * Test main function. Runs all test cases.
+ */
+#ifndef TESTCMAPPLSETTINGSUI_NO_OUTPUT_REDIRECT
+int main(int argc, char *argv[])
+{
+    HbApplication app(argc, argv);
+    app.setApplicationName("TestCpDestinationPlugin");
+    
+    char *pass[3];  
+    pass[0] = argv[0];
+    pass[1] = "-o"; 
+    pass[2] = "c:\\data\\TestCpDestinationPlugin.txt";
+ 
+    TestCpDestinationPlugin tc;
+    int res = QTest::qExec(&tc, 3, pass);
+ 
+    return res;
+}
+#else
+QTEST_MAIN(TestCpDestinationPlugin)
+#endif
+
+/**
+ * This function is be called before the first test case is executed.
+ */
+void TestCpDestinationPlugin::initTestCase()
+{
+    mMainWindow = new HbAutoTestMainWindow;
+    mMainWindow->show();
+    
+    // Load plugin
+    QDir dir(pluginDir);
+    QPluginLoader loader(dir.absoluteFilePath(pluginName));
+    mPlugin = QSharedPointer<CpPluginInterface>
+        (qobject_cast<CpPluginInterface *>(loader.instance()));
+    //QVERIFY(mPlugin != NULL);
+
+    
+    // Create destinations view
+    subCreateSettingsView();
+    
+    HbAutoTest::mouseClick(mMainWindow, mView, destinationGroup, waitTime);
+    QTest::qWait(200);
+}
+
+/**
+ * This function is be called after the last test case was executed.
+ */
+void TestCpDestinationPlugin::cleanupTestCase()
+{
+    delete mMainWindow;
+    mMainWindow = 0;
+}
+
+/**
+ * This function is be called before each test case is executed.
+ */
+void TestCpDestinationPlugin::init()
+{
+    // Expand settings group
+   // mTestView->mForm->setExpanded(
+   //     mTestView->mModel->indexFromItem(mTestView->mApSettingsGroupItem),
+    //    true);
+}
+
+/**
+ * This function is be called after each test case is executed.
+ */
+void TestCpDestinationPlugin::cleanup()
+{
+
+}
+
+// -----------------------------------------------------------------------------
+// TEST CASES
+// -----------------------------------------------------------------------------
+void TestCpDestinationPlugin::tcArrangeAps()
+{   
+    // Open Internet destination
+    HbAutoTest::mouseClick(mMainWindow, mView, internetDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Activate arrange mode
+    HbAutoTest::mouseClick(mMainWindow, mView, tbButton, waitTime);
+    QTest::qWait(500);
+    
+    // Drag
+    HbAutoTest::mousePress(mMainWindow, mView, arrangeFirstAp, waitTime);
+    QTest::qWait(300);
+    HbAutoTest::mouseMove(mMainWindow, mView, arrangeDragEnd, waitTime);
+    QTest::qWait(300);
+    HbAutoTest::mouseRelease(mMainWindow, mView, arrangeDragEnd, waitTime);
+    
+    HbAutoTest::mouseClick(mMainWindow, mView, arrangeDragEnd, waitTime);
+    QTest::qWait(500);
+    
+    // Cancel
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+    
+    // Activate arrange mode again
+    HbAutoTest::mouseClick(mMainWindow, mView, tbButton, waitTime);
+    QTest::qWait(500);
+    
+    // Drag
+    HbAutoTest::mousePress(mMainWindow, mView, arrangeFirstAp, waitTime);
+    QTest::qWait(300);
+    HbAutoTest::mouseMove(mMainWindow, mView, arrangeDragEnd, waitTime);
+    QTest::qWait(300);
+    // HbAutoTest::mouseRelease(mMainWindow, mView, arrangeDragEnd, waitTime);
+    
+    HbAutoTest::mouseClick(mMainWindow, mView, arrangeDragEnd, waitTime);
+    QTest::qWait(500);
+    
+    // OK
+    HbAutoTest::mouseClick(mMainWindow, mView, tbButton, waitTime);
+    QTest::qWait(500);
+    
+    // Back to main view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+    
+}
+
+void TestCpDestinationPlugin::tcMoveAp()
+{   
+    // Open uncategorised aps
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatAp, 700);
+    QTest::qWait(50);
+    
+    // Select move
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatMenuMove, waitTime);
+    QTest::qWait(300);
+    
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, destDialogOk, waitTime);
+    QTest::qWait(2000);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcShareDeleteAp()
+{
+    // Open Internet destination
+    HbAutoTest::mouseClick(mMainWindow, mView, internetDestination, waitTime);
+    QTest::qWait(500);
+      
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstAp, 700);
+    QTest::qWait(50);
+      
+    // Select share
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstApShare, waitTime);
+    QTest::qWait(300);
+      
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, destDialogOk, waitTime);
+    QTest::qWait(2000);
+    
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstAp, 700);
+    QTest::qWait(50);
+          
+    // Select share
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstApDelete, waitTime);
+    QTest::qWait(300);
+          
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, deleteDialogOk, waitTime);
+    QTest::qWait(2000);
+      
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcAddDestination()
+{
+    // Add Destination
+    HbAutoTest::mouseClick(mMainWindow, mView, addDestination, waitTime);
+    QTest::qWait(500);
+      
+    // Click OK -> Error note
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // Click OK -> errorNote disappears
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // Activate keyboard
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialog, waitTime);
+    QTest::qWait(500);
+        
+    // Activate line-edit
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogKb, waitTime);
+    QTest::qWait(500);
+        
+    // Input text
+    HbAutoTest::keyClicks(mMainWindow, "Internet", 0, waitTime);
+    QTest::qWait(2000);
+          
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOkKb, waitTime);
+    QTest::qWait(500);
+        
+    // Select ok again -> Error note
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+        
+    // Click OK -> errorNote disappears
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // Activate keyboard
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialog, waitTime);
+    QTest::qWait(500);
+    
+    // Activate line-edit
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogKb, waitTime);
+    QTest::qWait(500);
+    
+    // Input text
+    HbAutoTest::keyClicks(mMainWindow, "foo", 0, waitTime);
+    QTest::qWait(2000);
+      
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOkKb, waitTime);
+    QTest::qWait(500);
+    
+    // Select ok again
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcDestinationRename()
+{
+    // Open context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, addDestination, 700);
+    QTest::qWait(50);
+      
+    // Click OK -> Error note
+    HbAutoTest::mouseClick(mMainWindow, mView, newDestinationRename, waitTime);
+    QTest::qWait(300);
+    
+    // Click OK -> error note shown
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(300);
+    
+    // Click OK -> errorNote disappears
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // Activate keyboard
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialog, waitTime);
+    QTest::qWait(500);
+    
+    // Activate line-edit
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogKb, waitTime);
+    QTest::qWait(500);
+    
+    // Input text
+    HbAutoTest::keyClicks(mMainWindow, "Internet", 0, waitTime);
+    QTest::qWait(2000);
+      
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOkKb, waitTime);
+    QTest::qWait(500);
+    
+    // Select ok again -> Error note
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // Click OK -> errorNote disappears
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+        
+    // Activate keyboard
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialog, waitTime);
+    QTest::qWait(500);
+        
+    // Activate line-edit
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogKb, waitTime);
+    QTest::qWait(500);
+        
+    // Input text
+    HbAutoTest::keyClicks(mMainWindow, "bar", 0, waitTime);
+    QTest::qWait(2000);
+          
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOkKb, waitTime);
+    QTest::qWait(500);
+        
+    // Select ok again
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // TODO: remove
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcDestinationDelete()
+{
+    // Open context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, addDestination, 700);
+    QTest::qWait(50);
+      
+    // Click OK -> Error note
+    HbAutoTest::mouseClick(mMainWindow, mView, newDestinationDelete, waitTime);
+    QTest::qWait(300);
+    
+    // Click OK -> error note shown
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(1000);  
+  
+    // TODO: remove
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcCreateAndDeleteDestination()
+{
+    // Add Destination
+    HbAutoTest::mouseClick(mMainWindow, mView, addDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Activate keyboard
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialog, waitTime);
+    QTest::qWait(500);
+    
+    // Activate line-edit
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogKb, waitTime);
+    QTest::qWait(500);
+    
+    // Input text
+    HbAutoTest::keyClicks(mMainWindow, "foo", 0, waitTime);
+    QTest::qWait(2000);
+      
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOkKb, waitTime);
+    QTest::qWait(500);
+    
+    // Select ok again
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(500);
+    
+    // Open Internet destination
+    HbAutoTest::mouseClick(mMainWindow, mView, internetDestination, waitTime);
+    QTest::qWait(500);
+          
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstAp, 700);
+    QTest::qWait(50);
+          
+    // Select move
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstApMove, waitTime);
+    QTest::qWait(300);
+    
+    // Select destination
+    HbAutoTest::mouseClick(mMainWindow, mView, destDialogNewDest, waitTime);
+    QTest::qWait(300);
+    
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, destDialogOk, waitTime);
+    QTest::qWait(2000);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+    
+    // Open context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, addDestination, 700);
+    QTest::qWait(50);
+      
+    // Click OK -> Error note
+    HbAutoTest::mouseClick(mMainWindow, mView, newDestinationDelete, waitTime);
+    QTest::qWait(300);
+    
+    // Click OK -> error note shown
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(1000);  
+  
+    // TODO: remove
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcOpenDestinations()
+{
+    // Open uncategorised aps
+    HbAutoTest::mouseClick(mMainWindow, mView, secondDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+    
+    // Open uncategorised aps
+    HbAutoTest::mouseClick(mMainWindow, mView, thirdDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+    
+    // Open uncategorised aps
+    HbAutoTest::mouseClick(mMainWindow, mView, fourthDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+    
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatAp, 700);
+    QTest::qWait(50);
+    
+    // TODO: remove
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcDeleteUncat()
+{   
+    // Open uncategorised aps
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatDestination, waitTime);
+    QTest::qWait(500);
+    
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatAp, 700);
+    QTest::qWait(50);
+    
+    // Select move
+    HbAutoTest::mouseClick(mMainWindow, mView, uncatMenuDelete, waitTime);
+    QTest::qWait(500);
+    
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(2000);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+void TestCpDestinationPlugin::tcMoveProtected()
+{   
+    // Open Internet destination
+    HbAutoTest::mouseClick(mMainWindow, mView, internetDestination, waitTime);
+    QTest::qWait(500);
+          
+    // Activate context menu
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstAp, 700);
+    QTest::qWait(50);
+          
+    // Select move
+    HbAutoTest::mouseClick(mMainWindow, mView, internetFirstApMove, waitTime);
+    QTest::qWait(300);
+    
+    // Select destination
+    HbAutoTest::mouseClick(mMainWindow, mView, destDialogSecond, waitTime);
+    QTest::qWait(300);
+    
+    // Select ok
+    HbAutoTest::mouseClick(mMainWindow, mView, destDialogOk, waitTime);
+    QTest::qWait(2000);
+    
+    HbAutoTest::mouseClick(mMainWindow, mView, addDialogOk, waitTime);
+    QTest::qWait(2000);
+    
+    // Back to destination view
+    subClickWidget(navigationButton);
+    QTest::qWait(500);
+}
+
+// -----------------------------------------------------------------------------
+// SUB TEST CASES
+// -----------------------------------------------------------------------------
+
+void TestCpDestinationPlugin::subCreateSettingsView()
+{
+    // Create settings view
+    HbView *view = new HbView();
+    CpItemDataHelper *itemDataHelper = new CpItemDataHelper();
+    itemDataHelper->setParent(view);
+    HbDataForm *form = new HbDataForm();
+    HbDataFormModel *model = new HbDataFormModel;
+    CpPluginUtility::addCpItemPrototype(form);
+    QList<CpSettingFormItemData *> list = mPlugin->createSettingFormItemData(*itemDataHelper);
+    HbDataFormModelItem *modelItem = NULL;
+    modelItem = list[0];
+    model->appendDataFormItem(modelItem);
+    form->setModel(model);
+    model->setParent(form);
+    view->setWidget(form);
+    itemDataHelper->bindToForm(form);
+    
+    // Display the view
+    // TODO: connect aboutToClose() signal
+    mMainWindow->addView(view);
+    mMainWindow->setCurrentView(view); 
+    
+    mView = view;
+}
+
+void TestCpDestinationPlugin::subClickWidget(const QString &name)
+{
+    QList<QGraphicsItem *> itemList = mMainWindow->scene()->items();
+
+    QGraphicsItem *target = 0;
+    foreach (QGraphicsItem* item, itemList) {
+        if (item->isWidget()) {
+            QString widgetClassName(static_cast<QGraphicsWidget*>(item)->metaObject()->className());
+            qDebug() << widgetClassName;
+            
+            if (widgetClassName == name) {
+                target = item;
+                //break;
+            }
+        }
+    }
+
+    Q_ASSERT(target);
+    HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/testcpdestinationplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Control Panel WLAN AP plugin unit testing.
+*/
+
+#include <QStringList>
+#include <QtTest/QtTest>
+#include <cmmanagerdefines_shim.h>
+
+//#include "cmapplsettingsui.h"
+
+class HbDialog;
+class HbMainWindow;
+class HbAutoTestMainWindow;
+class HbDataFormModelItem;
+class CpBearerApPluginInterface;
+class CpPluginInterface;
+class HbView;
+
+class TestCpDestinationPlugin : public QObject
+{
+    Q_OBJECT
+
+    public slots:
+        // Test framework functions
+        void initTestCase();
+        void cleanupTestCase();
+        void init();
+        void cleanup();
+
+    private slots:
+        // Test cases
+        void tcArrangeAps();
+        void tcMoveAp();
+        void tcShareDeleteAp();
+        void tcAddDestination();
+        void tcDestinationRename();
+        void tcDestinationDelete();
+        void tcCreateAndDeleteDestination();
+        void tcDeleteUncat();
+        void tcOpenDestinations();
+
+    private:
+        // Sub test cases
+        void subCreateSettingsView();
+        void subClickWidget(const QString &name);
+        
+        // Not Run cases
+        void tcMoveProtected();
+        
+
+    private:
+        // Code references
+        
+        // Test data
+        HbAutoTestMainWindow              *mMainWindow;
+        QSharedPointer<CpPluginInterface> mPlugin;
+        HbView                            *mView;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/testcpdestinationplugin.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Project file for Control Panel Destination plugin unit tests.
+
+TEMPLATE = app
+
+TARGET = testcpdestinationplugin
+
+CONFIG += hb qtestlib
+
+INCLUDEPATH += . ../../inc
+DEPENDPATH += .
+
+HEADERS += \
+    hbautotest.h \
+    testcpdestinationplugin.h
+SOURCES += \
+    hbautotest.cpp \
+    testcpdestinationplugin.cpp
+
+LIBS += \
+    -lcpdestinationplugin \
+    -lconnection_settings_shim \
+    -lcpframework
+    
+#    -lconnection_settings_shim \
+#    -lcmmanager
+#    -lcommsdat \
+#    -lcommdb \
+#    -lecom
+
+symbian: {
+    TARGET.CAPABILITY = ALL -TCB
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/tools/commsdat_restore.bat	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem Script for restoring backup of commsdat.
+
+copy backup\cccccc00.cre \epoc32\winscw\c\private\10202be9\persists\cccccc00.cre
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/tools/commsdat_set.bat	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,19 @@
+@rem
+@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem Script for setting test commsdat.
+
+md backup
+copy \epoc32\winscw\c\private\10202be9\persists\cccccc00.cre backup\
+copy default.cre \epoc32\winscw\c\private\10202be9\persists\cccccc00.cre
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cpdestinationplugin/tsrc/ut/tools/cpdestinationplugin_ctc.bat	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,92 @@
+::
+:: Copyright (c) 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"
+:: which accompanies this distribution, and is available
+:: at the URL "http://www.eclipse.org/legal/epl-v10.html".
+::
+:: Initial Contributors:
+:: Nokia Corporation - initial contribution.
+::
+:: Contributors:
+::
+:: Description:
+:: Script running Control Panel Destination plugin test cases with CTC analysis.
+
+@echo off
+
+:: -----------------------------------------------------------------------------
+:: Instructions
+:: -----------------------------------------------------------------------------
+:: 
+:: Remember to use the test CommsDat that can be set and restored with the
+:: helper scripts:
+:: - commsdat_set.bat
+:: - commsdat_restore.bat
+
+call .\commsdat_set.bat
+
+::-----------------------------------------------------------------------------
+:: Set the local variables
+::-----------------------------------------------------------------------------
+
+:: Control Panel Destination plugin base directory
+set cpdestinationplugin_dir=..\..\..
+pushd %cpdestinationplugin_dir%
+
+:: CTC instrumentation excludes
+set ctc_excludes=-C EXCLUDE=* -C NO_EXCLUDE=src\*.cpp -C SKIP_FUNCTION_NAME=CpAddDestinationEntryItemData::createSettingView,CpDestinationEntryItemData::showErrorNote,CpIapItem::showErrorNote
+
+::-----------------------------------------------------------------------------
+:: Remove old coverage data
+::-----------------------------------------------------------------------------
+
+echo Cleaning up...
+del MON.* ctcerr.txt profile.txt
+rd /s /q CTCHTML
+echo ...done
+
+::-----------------------------------------------------------------------------
+:: Build & instrument code
+::-----------------------------------------------------------------------------
+
+echo Building code and instrumenting..
+call del MON.* ctcerr.txt profile.txt
+call make distclean
+call qmake
+call ctcwrap -i d -2comp %ctc_excludes% sbs -c winscw_udeb
+echo ...done
+
+::-----------------------------------------------------------------------------
+:: Build test code
+::-----------------------------------------------------------------------------
+
+echo Building test code...
+call cd tsrc\ut
+call make distclean
+call qmake
+call sbs -c winscw_udeb
+echo ...done
+
+::-----------------------------------------------------------------------------
+:: Execute the tests
+::-----------------------------------------------------------------------------
+
+echo Running tests..
+cd ..\..
+call \epoc32\release\winscw\udeb\testcpdestinationplugin.exe
+echo ...done
+
+::-----------------------------------------------------------------------------
+:: Create coverage results
+::-----------------------------------------------------------------------------
+
+echo Creating results...
+call ctcpost -p profile.txt
+call ctc2html -i profile.txt
+echo ...done
+
+call .\commsdat_restore.bat
+
+popd
Binary file cmmanager/cpdestinationplugin/tsrc/ut/tools/default.cre has changed
--- a/cmmanager/cpipsettingsplugin/cpipsettingsplugin.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpipsettingsplugin/cpipsettingsplugin.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -35,6 +35,14 @@
 
 TRANSLATIONS = cpipsettingsplugin.ts
 
+# Temporary solution to fix tracecompiler
+# When tracecompiler is fixed, this can be removed
+symbian: {
+
+    MMP_RULES += "USERINCLUDE traces"
+
+}
+
 symbian:
 {
 TARGET.EPOCALLOWDLLDATA = 1
--- a/cmmanager/cpipsettingsplugin/inc/cpipsettingsplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpipsettingsplugin/inc/cpipsettingsplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -12,6 +12,7 @@
 * Contributors:
 *
 * Description:  
+* Control Panel "Network Settings" plugin header file.
 *   
 */
 
@@ -20,12 +21,13 @@
 
 // System includes
 #include <QObject>
+#include <QSharedPointer>
 #include <cpplugininterface.h>
 
 // User includes
 
 // Forward declarations
-class QTranslator;
+class HbTranslator;
 
 // External data types
 
@@ -51,11 +53,13 @@
 protected slots:
 
 private:
+    Q_DISABLE_COPY(CpIpSettingsPlugin)
 
 private slots:
     
 private: // data
-    QTranslator *mTranslator;
+    //! Translator instance
+    QSharedPointer<HbTranslator> mTranslator;
 };
 
 #endif // CPIPSETTINGSPLUGIN_H
--- a/cmmanager/cpipsettingsplugin/inc/cpipsettingsview.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpipsettingsplugin/inc/cpipsettingsview.h	Thu Jul 22 16:37:38 2010 +0100
@@ -47,6 +47,7 @@
 protected slots:
 
 private:
+    Q_DISABLE_COPY(CpIpSettingsView)
 
 private slots:
     
--- a/cmmanager/cpipsettingsplugin/src/cpipsettingsplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpipsettingsplugin/src/cpipsettingsplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -12,13 +12,12 @@
 * Contributors:
 *
 * Description:  
+* Control Panel "Network Settings" plugin implementation.
 *
 */
 
 // System includes
-#include <QApplication>
-#include <QLocale>
-#include <QTranslator>
+#include <HbTranslator>
 #include <cpsettingformentryitemdataimpl.h>
 
 // User includes
@@ -42,14 +41,9 @@
 /*!
     Constructor.
 */
-CpIpSettingsPlugin::CpIpSettingsPlugin()
+CpIpSettingsPlugin::CpIpSettingsPlugin() :
+    mTranslator(new HbTranslator("cpipsettingsplugin"))
 {
-    // Install localization
-    QString lang = QLocale::system().name();
-    QString path = "z:/resource/qt/translations/";
-    mTranslator = new QTranslator(this);
-    mTranslator->load(path + "cpipsettingsplugin_" + lang);
-    qApp->installTranslator(mTranslator);
 }
 
 /*!
--- a/cmmanager/cpipsettingsplugin/src/cpipsettingsview.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpipsettingsplugin/src/cpipsettingsview.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -11,7 +11,8 @@
 *
 * Contributors:
 *
-* Description:  
+* Description: 
+* Control Panel "Network Settings" view implementation.
 *
 */
 
@@ -38,6 +39,7 @@
 static const QString ipSettingsPlugins[] = {
     "cpwlansettingsplugin.qtplugin",
     "cpdestinationplugin.qtplugin",
+    "videosettingsplugin.qtplugin",
     "cpvpnmanagementplugin.qtplugin",
     "" // empty item terminates the list
 };
@@ -54,13 +56,14 @@
 {
     HbDataForm *form = new HbDataForm();
     this->setWidget(form);
+    form->setHeading(hbTrId("txt_occ_subhead_network_settings"));
     CpPluginUtility::addCpItemPrototype(form);
     HbDataFormModel *model = new HbDataFormModel(form);
 
     // The parameter given as 0 is a HbDataForm pointer, not parent
     mItemDataHelper = new CpItemDataHelper(0);
     mItemDataHelper->setParent(this);
-    
+
     HbDataFormModelItem *modelItem;
     CpPluginInterface *plugin = NULL;
     QDir pluginsDir("\\resource\\qt\\plugins\\controlpanel");
--- a/cmmanager/cppacketdataapplugin/cppacketdataapplugin.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/cppacketdataapplugin.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -20,6 +20,12 @@
 DEPENDPATH += .
 INCLUDEPATH += .
 
+# Temporary solution to fix tracecompiler
+# When tracecompiler is fixed, this can be removed
+symbian: {
+    MMP_RULES += "USERINCLUDE traces"
+}
+
 CONFIG += hb plugin
 
 MOC_DIR = moc
@@ -37,6 +43,9 @@
            src/cppacketdataapview.cpp \
            src/cppacketdataapadvancedview.cpp
 
+# Include plugin utilities
+include(../cppluginutils/cppluginutils.pri)
+
 TRANSLATIONS = cpapplugin.ts
 
 symbian:
--- a/cmmanager/cppacketdataapplugin/inc/cppacketdataapadvancedview.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/inc/cppacketdataapadvancedview.h	Thu Jul 22 16:37:38 2010 +0100
@@ -20,13 +20,17 @@
 #define CPPACKETDATAAPADVANCEDVIEW_H
 
 // System includes
+#include <QAbstractSocket>
+#include <HbMessageBox>
 #include <cpbasesettingview.h>
+#include <cmmanagerdefines_shim.h>
 
 // User includes
 
 // Forward declarations
 class HbDataForm;
 class HbDataFormModel;
+class HbDataFormModelItem;
 class CmConnectionMethodShim;
 
 // External data types
@@ -53,9 +57,59 @@
 protected slots:
  
 private:
+    Q_DISABLE_COPY(CpPacketDataApAdvancedView)
+
+    //! Network type
+    enum NetworkType {
+        NetworkTypeIpv4 = 0,
+        NetworkTypeIpv6
+    };
+
+    //! IPv6 DNS type
+    enum Ipv6DnsType {
+        Ipv6DnsTypeAutomatic = 0,
+        Ipv6DnsTypeWellKnown,
+        Ipv6DnsTypeUserDefined
+    };
+    
     void createAdvancedSettings();
+    void createIpGroup();
+    void updateIpGroup();
+    void createIpv4SettingItems();
+    void deleteIpv4SettingItems();
+    void createIpv6SettingItems();
+    void deleteIpv6SettingItems();
+    void createProxyGroup();
+    void updateProxyGroup();
+    NetworkType getNetworkType();
+    QString getIpAddress(CMManagerShim::ConnectionMethodAttribute attribute);
+    Ipv6DnsType getIpv6DnsType();
+    void enableIpv4AddressFields(int state);
+    void enableIpv4DnsFields(int state);
+    void enableIpv6DnsFields(int selectionIndex);
+    bool validateAndSaveIpAddress(
+        HbDataFormModelItem *item,
+        CMManagerShim::ConnectionMethodAttribute attribute,
+        QAbstractSocket::NetworkLayerProtocol protocol);
+    void showMessageBox(
+        HbMessageBox::MessageBoxType type,
+        const QString &text);
+    bool tryUpdate();
+    void handleUpdateError();
     
 private slots:
+    void setEditorPreferences(const QModelIndex index);
+    void changeNetworkType(int type);
+    void changeIpv4AddressMode(int state);
+    void changeIpv4Address();
+    void changeIpv4DnsMode(int state);
+    void changeIpv4PrimaryDnsAddress();
+    void changeIpv4SecondaryDnsAddress();
+    void changeIpv6DnsMode(int selectionIndex);
+    void changeIpv6PrimaryDnsAddress();
+    void changeIpv6SecondaryDnsAddress();
+    void changeProxyServer();
+    void changeProxyPort();
     
 private: // data
     //! Dataform
@@ -64,6 +118,41 @@
     HbDataFormModel *mModel;
     //! Connection Settings Shim connection method pointer
     CmConnectionMethodShim *mCmConnectionMethod;
+    //! "IP settings" group
+    HbDataFormModelItem *mIpGroup;
+    //! "Network type" (IPv4/IPv6) setting item
+    HbDataFormModelItem *mNetworkType;
+    //! "Automatic" setting item for phone IP address
+    HbDataFormModelItem *mIpv4Automatic;
+    //! "Phone IP address" setting item
+    HbDataFormModelItem *mIpv4Address;
+    //! "Automatic" setting item for IPv4 DNS addresses
+    HbDataFormModelItem *mIpv4DnsAutomatic;
+    //! "Primary name server" setting item
+    HbDataFormModelItem *mIpv4DnsAddress1;
+    //! "Secondary name server" setting item
+    HbDataFormModelItem *mIpv4DnsAddress2;
+    //! "Automatic" setting item for IPv6 DNS addresses
+    HbDataFormModelItem *mIpv6DnsAutomatic;
+    //! "Primary name server" setting item
+    HbDataFormModelItem *mIpv6DnsAddress1;
+    //! "Secondary name server" setting item
+    HbDataFormModelItem *mIpv6DnsAddress2;
+    //! "Proxy settings" group
+    HbDataFormModelItem *mProxyGroup;
+    //! "Proxy server address" setting item
+    HbDataFormModelItem *mProxyServer;
+    //! "Proxy port number" setting item
+    HbDataFormModelItem *mProxyPort;
+    //! Message box for info notes
+    QSharedPointer<HbMessageBox> mMessageBox;
+    //! Flag for IPv6 support
+    bool mIpv6Supported;
+    //! Current network type (IPv4/IPv6)
+    NetworkType mCurrentNetworkType;
+    
+    // Friend classes
+    friend class TestCpPacketDataApPlugin;
 };
 
 #endif // CPPACKETDATAAPADVANCEDVIEW_H
--- a/cmmanager/cppacketdataapplugin/inc/cppacketdataapplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/inc/cppacketdataapplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -21,12 +21,13 @@
 
 // System includes
 #include <QObject>
+#include <QSharedPointer>
 #include <cpbearerapplugininterface.h>
 
 // User includes
 
 // Forward declarations
-class QTranslator;
+class HbTranslator;
 class CmManagerShim;
 class CmConnectionMethodShim;
 
@@ -56,12 +57,13 @@
 protected slots:
 
 private:
+    Q_DISABLE_COPY(CpPacketDataApPlugin)
 
 private slots:
     
 private: // data
     //! Translator instance
-    QTranslator *mTranslator;
+    QSharedPointer<HbTranslator> mTranslator;
     //! CM Manager Shim instance
     CmManagerShim *mCmManager;
     //! CM Connection Method Shim instance
--- a/cmmanager/cppacketdataapplugin/inc/cppacketdataapview.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/inc/cppacketdataapview.h	Thu Jul 22 16:37:38 2010 +0100
@@ -59,6 +59,8 @@
 protected slots:
  
 private:
+    Q_DISABLE_COPY(CpPacketDataApView)
+    
     void createAccessPointSettingsGroup();
     void updateAccessPointSettingsGroup();
     void showMessageBox(
@@ -71,7 +73,6 @@
     void connectionNameChanged();
     void accessPointNameChanged();
     void userNameChanged();
-    void promptForAuthChanged(int state);
     void passwordChanged();
     void authenticationChanged(int index);
     void homepageChanged();
@@ -92,8 +93,6 @@
     HbDataFormModelItem *mAccessPointNameItem;
     //! "User name" setting item
     HbDataFormModelItem *mUserNameItem;
-    //! "Prompt" setting item
-    HbDataFormModelItem *mPromptForAuthItem;
     //! "Password" setting item
     HbDataFormModelItem *mPasswordItem;
     //! "Authentication" setting item
@@ -106,8 +105,6 @@
     CmConnectionMethodShim *mCmConnectionMethod;
     //! Message box for info notes
     QSharedPointer<HbMessageBox> mMessageBox;
-    //! Maps checkbox value to CMManagerShim::PacketDataIFPromptForAuth value
-    QMap<Qt::CheckState, bool> mPromptForAuthMap;
     //! Maps authentication combobox index to CMManagerShim::PacketDataDisablePlainTextAuth value
     QMap<int, bool> mAuthenticationMap;
     
--- a/cmmanager/cppacketdataapplugin/src/cppacketdataapadvancedview.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/src/cppacketdataapadvancedview.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,14 +17,31 @@
 */
 
 // System includes
+#include <QHostAddress>
+#include <HbCheckBox>
+#include <HbLineEdit>
+#include <HbDataFormViewItem>
+#include <HbWidget>
+#include <HbEditorInterface>
+#include <HbUrlFilter>
+#include <HbInputDialog>
 #include <HbDataForm>
 #include <HbDataFormModel>
+#include <cmconnectionmethod_shim.h>
+#include <cmmanagerdefines_shim.h>
 #include <cpsettingformitemdata.h>
-#include <cmconnectionmethod_shim.h>
+#include <etelpckt.h>
 
 // User includes
+#include "cpipv4filter.h"
+#include "cpipv6filter.h"
 #include "cppacketdataapadvancedview.h"
 
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cppacketdataapadvancedviewTraces.h"
+#endif
+
 /*!
     \class CpPacketDataApAdvancedView
     \brief Implements the advanced settings view for packet data bearer
@@ -48,16 +65,39 @@
         CpBaseSettingView(0, parent),
         mForm(0),
         mModel(0),
-        mCmConnectionMethod(cmConnectionMethod)
+        mCmConnectionMethod(cmConnectionMethod),
+        mIpGroup(0),
+        mNetworkType(0),
+        mIpv4Automatic(0),
+        mIpv4Address(0),
+        mIpv4DnsAutomatic(0),
+        mIpv4DnsAddress1(0),
+        mIpv4DnsAddress2(0),
+        mIpv6DnsAutomatic(0),
+        mIpv6DnsAddress1(0),
+        mIpv6DnsAddress2(0),
+        mProxyGroup(0),
+        mProxyServer(0),
+        mProxyPort(0),
+        mMessageBox(0),
+        mIpv6Supported(false),
+        mCurrentNetworkType(NetworkTypeIpv4)
 {
-    // Construct packet data AP settings UI
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CPPACKETDATAAPADVANCEDVIEW_ENTRY);
+    
+    // Construct packet data AP advanced settings UI
     mForm = new HbDataForm();
     this->setWidget(mForm);
     mModel = new HbDataFormModel(mForm);
     mForm->setModel(mModel);
-    
+
+    mIpv6Supported = mCmConnectionMethod->getBoolAttribute(
+        CMManagerShim::CmIPv6Supported);
+        
     // Add advanced settings groups
     createAdvancedSettings();
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CPPACKETDATAAPADVANCEDVIEW_EXIT);
 }
 
 /*!
@@ -65,12 +105,1104 @@
 */
 CpPacketDataApAdvancedView::~CpPacketDataApAdvancedView()
 {
+    OstTraceFunctionEntry0(DUP1_CPPACKETDATAAPADVANCEDVIEW_CPPACKETDATAAPADVANCEDVIEW_ENTRY);
+    
+    OstTraceFunctionExit0(DUP1_CPPACKETDATAAPADVANCEDVIEW_CPPACKETDATAAPADVANCEDVIEW_EXIT);
+}
+
+/*!
+    Creates all advanced settings groups.
+*/
+void CpPacketDataApAdvancedView::createAdvancedSettings()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CREATEADVANCEDSETTINGS_ENTRY);
+    
+    // Create settings groups
+    createIpGroup();
+    createProxyGroup();
+    
+    // Read values and update UI
+    updateIpGroup();
+    updateProxyGroup();
+    
+    // Connect signal to initialize settings item widgets
+    bool status = connect(
+        mForm,
+        SIGNAL(itemShown(const QModelIndex)),
+        this,
+        SLOT(setEditorPreferences(const QModelIndex)));
+    Q_ASSERT(status);
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CREATEADVANCEDSETTINGS_EXIT);
+}
+
+/*!
+    Creates the IP settings group.
+*/
+void CpPacketDataApAdvancedView::createIpGroup()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CREATEIPGROUP_ENTRY);
+    
+    // IP settings group
+    mIpGroup = new CpSettingFormItemData(
+        HbDataFormModelItem::GroupItem,
+        hbTrId("txt_occ_subhead_ip_settings"));
+    mModel->appendDataFormItem(mIpGroup);
+    
+    if (mIpv6Supported) {
+        // IPv6 supported
+        // Network type
+        mNetworkType = new CpSettingFormItemData(
+            HbDataFormModelItem::ComboBoxItem,
+            hbTrId("txt_occ_setlabel_network_type"));
+        QStringList networkTypeList;
+        networkTypeList
+            << hbTrId("txt_occ_setlabel_network_type_val_ipv4")
+            << hbTrId("txt_occ_setlabel_network_type_val_ipv6");
+        mNetworkType->setContentWidgetData("items", networkTypeList);
+        mForm->addConnection(
+            mNetworkType,
+            SIGNAL(currentIndexChanged(int)),
+            this,
+            SLOT(changeNetworkType(int)));
+        mIpGroup->appendChild(mNetworkType);
+        
+        mCurrentNetworkType = getNetworkType();
+        if (mCurrentNetworkType == NetworkTypeIpv4) {
+            // IPv4
+            createIpv4SettingItems();
+        } else {
+            // IPv6
+            createIpv6SettingItems();
+        }
+    } else {
+        // IPv6 not supported, create IPv4 settings items
+        createIpv4SettingItems();
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CREATEIPGROUP_EXIT);
+}
+
+/*!
+    Reads attribute values and updates the IP settings group.
+*/
+void CpPacketDataApAdvancedView::updateIpGroup()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_UPDATEIPGROUP_ENTRY);
+    
+    // Network type
+    if (mNetworkType) {
+        // Every time update is called we check if network type (IPv4/IPv6)
+        // has changed and update items on UI if necessary.
+    
+        // Get network type from CommsDat
+        NetworkType newNetworkType = getNetworkType();
+        if (newNetworkType != mCurrentNetworkType) {
+            // Network type has changed, update UI
+            if (newNetworkType == NetworkTypeIpv6) {
+                // IPv4 -> IPv6
+                deleteIpv4SettingItems();
+                createIpv6SettingItems();
+            } else {
+                // IPv6 -> IPv4
+                deleteIpv6SettingItems();
+                createIpv4SettingItems();
+            }
+            mCurrentNetworkType = newNetworkType;
+        }
+        mNetworkType->setContentWidgetData("currentIndex", newNetworkType);
+    }
+    
+    // Phone IP address (IPv4)
+    // "Automatic" checkbox
+    if (mIpv4Automatic) {
+        bool ipAddressFromServer = mCmConnectionMethod->getBoolAttribute(
+            CMManagerShim::PacketDataIPAddrFromServer);
+        Qt::CheckState state = Qt::Unchecked;
+        if (ipAddressFromServer) {
+            state = Qt::Checked;
+        }
+        mIpv4Automatic->setContentWidgetData("checkState", state);
+
+        // Enable/disable user defined IP address fields
+        enableIpv4AddressFields(state);
+    }
+
+    // Phone IP address (IPv4)
+    if (mIpv4Address) {
+        QString string = getIpAddress(CMManagerShim::CmIPAddress);
+        mIpv4Address->setContentWidgetData("text", string);
+    }
+    
+    // IPv4 DNS addresses
+    // "Automatic" checkbox
+    if (mIpv4DnsAutomatic) {
+        Qt::CheckState state = Qt::Unchecked;
+        if (mCmConnectionMethod->getBoolAttribute(
+            CMManagerShim::CmIPDNSAddrFromServer)) {
+            state = Qt::Checked;
+        }
+        mIpv4DnsAutomatic->setContentWidgetData("checkState", state);
+
+        // Enable/disable user defined DNS address fields
+        enableIpv4DnsFields(state);
+    }
+    
+    // IPv4 primary DNS address
+    if (mIpv4DnsAddress1) {
+        QString string = getIpAddress(CMManagerShim::CmIPNameServer1);
+        mIpv4DnsAddress1->setContentWidgetData("text", string);
+    }
+    
+    // IPv4 secondary DNS address
+    if (mIpv4DnsAddress2) {
+        QString string = getIpAddress(CMManagerShim::CmIPNameServer2);
+        mIpv4DnsAddress2->setContentWidgetData("text", string);
+    }
+    
+    // IPv6 DNS addresses
+    // Automatic/well-known/user defined combobox
+    if (mIpv6DnsAutomatic) {
+        uint type = getIpv6DnsType();
+        mIpv6DnsAutomatic->setContentWidgetData("currentIndex", type);
+
+        // Enable/disable user defined DNS address fields
+        enableIpv6DnsFields(type);
+    }
+    
+    // IPv6 primary DNS address
+    if (mIpv6DnsAddress1) {
+        QString string = getIpAddress(CMManagerShim::CmIP6NameServer1);
+        mIpv6DnsAddress1->setContentWidgetData("text", string);
+    }
+    
+    // IPv6 secondary DNS address
+    if (mIpv6DnsAddress2) {
+        QString string = getIpAddress(CMManagerShim::CmIP6NameServer2);
+        mIpv6DnsAddress2->setContentWidgetData("text", string);
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_UPDATEIPGROUP_EXIT);
+}
+
+/*!
+    Creates the IPv4 setting items.
+*/
+void CpPacketDataApAdvancedView::createIpv4SettingItems()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CREATEIPV4SETTINGITEMS_ENTRY);
+
+    // Phone IP address
+    // "Automatic" checkbox
+    mIpv4Automatic = new CpSettingFormItemData(
+        HbDataFormModelItem::CheckBoxItem,
+        hbTrId("txt_occ_setlabel_phone_ip_address"));
+    mIpv4Automatic->setContentWidgetData(
+        "text",
+        hbTrId("txt_occ_setlabel_val_automatic"));
+    mForm->addConnection(
+        mIpv4Automatic,
+        SIGNAL(stateChanged(int)),
+        this,
+        SLOT(changeIpv4AddressMode(int)));
+    mIpGroup->appendChild(mIpv4Automatic);
+    
+    // Phone IP address
+    mIpv4Address = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_phone_ip_address"));
+    mForm->addConnection(
+        mIpv4Address,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv4Address()));
+    mIpGroup->appendChild(mIpv4Address);
+    
+    // DNS addresses
+    // "Automatic" checkbox
+    mIpv4DnsAutomatic = new CpSettingFormItemData(
+        HbDataFormModelItem::CheckBoxItem,
+        hbTrId("txt_occ_setlabel_dns_addresses"));
+    mIpv4DnsAutomatic->setContentWidgetData(
+        "text",
+        hbTrId("txt_occ_setlabel_val_automatic"));
+    mForm->addConnection(
+        mIpv4DnsAutomatic,
+        SIGNAL(stateChanged(int)), 
+        this,
+        SLOT(changeIpv4DnsMode(int)));
+    mIpGroup->appendChild(mIpv4DnsAutomatic);
+    
+    // Primary DNS address
+    mIpv4DnsAddress1 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_primary_name_server"));
+    mForm->addConnection(
+        mIpv4DnsAddress1,
+        SIGNAL(editingFinished()), 
+        this,
+        SLOT(changeIpv4PrimaryDnsAddress()));
+    mIpGroup->appendChild(mIpv4DnsAddress1);
+    
+    // Secondary DNS address
+    mIpv4DnsAddress2 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_secondary_name_server"));
+    mForm->addConnection(
+        mIpv4DnsAddress2,
+        SIGNAL(editingFinished()), 
+        this,
+        SLOT(changeIpv4SecondaryDnsAddress()));
+    mIpGroup->appendChild(mIpv4DnsAddress2);
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CREATEIPV4SETTINGITEMS_EXIT);
+}
+
+/*!
+    Deletes the IPv4 setting items.
+*/
+void CpPacketDataApAdvancedView::deleteIpv4SettingItems()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_DELETEIPV4SETTINGITEMS_ENTRY);
+
+    // Phone IP address
+    // "Automatic" checkbox
+    if (mIpv4Automatic) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv4Automatic));
+        mIpv4Automatic = NULL;
+    }
+    
+    // Phone IP address
+    if (mIpv4Address) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv4Address));
+        mIpv4Address = NULL;
+    }
+    
+    // DNS addresses
+    // "Automatic" checkbox
+    if (mIpv4DnsAutomatic) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv4DnsAutomatic));
+        mIpv4DnsAutomatic = NULL;
+    }
+    
+    // Primary DNS address
+    if (mIpv4DnsAddress1) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv4DnsAddress1));
+        mIpv4DnsAddress1 = NULL;
+    }
+    
+    // Secondary DNS address
+    if (mIpv4DnsAddress2) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv4DnsAddress2));
+        mIpv4DnsAddress2 = NULL;
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_DELETEIPV4SETTINGITEMS_EXIT);
+}
+
+/*!
+    Creates the IPv6 setting items.
+*/
+void CpPacketDataApAdvancedView::createIpv6SettingItems()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CREATEIPV6SETTINGITEMS_ENTRY);
+    
+    // DNS addresses
+    // Automatic/well-known/user defined combobox
+    mIpv6DnsAutomatic = new CpSettingFormItemData(
+        HbDataFormModelItem::ComboBoxItem,
+        hbTrId("txt_occ_setlabel_dns_addresses"));
+    QStringList dnsModeList;
+    // Order of the list must match the Ipv6DnsType enum
+    dnsModeList
+        << hbTrId("txt_occ_setlabel_val_automatic")
+        << hbTrId("txt_occ_setlabel_dns_addresses_val_wellknown")
+        << hbTrId("txt_occ_setlabel_dns_addresses_val_user_defined");
+    mIpv6DnsAutomatic->setContentWidgetData("items", dnsModeList);
+    mForm->addConnection(
+        mIpv6DnsAutomatic,
+        SIGNAL(currentIndexChanged(int)),
+        this,
+        SLOT(changeIpv6DnsMode(int)));
+    mIpGroup->appendChild(mIpv6DnsAutomatic);
+    
+    // Primary DNS address
+    mIpv6DnsAddress1 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_primary_name_server"));
+    mForm->addConnection(
+        mIpv6DnsAddress1,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv6PrimaryDnsAddress()));
+    mIpGroup->appendChild(mIpv6DnsAddress1);
+    
+    // Secondary DNS address
+    mIpv6DnsAddress2 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_secondary_name_server"));
+    mForm->addConnection(
+        mIpv6DnsAddress2,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv6SecondaryDnsAddress()));  
+    mIpGroup->appendChild(mIpv6DnsAddress2);
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CREATEIPV6SETTINGITEMS_EXIT);
+}
+
+/*!
+    Deletes the IPv6 setting items.
+*/
+void CpPacketDataApAdvancedView::deleteIpv6SettingItems()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_DELETEIPV6SETTINGITEMS_ENTRY);
+    
+    // DNS addresses
+    // Automatic/well-known/user defined combobox
+    if (mIpv6DnsAutomatic) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv6DnsAutomatic));
+        mIpv6DnsAutomatic = NULL;
+    }
+    
+    // Primary DNS address
+    if (mIpv6DnsAddress1) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv6DnsAddress1));
+        mIpv6DnsAddress1 = NULL;
+    }
+    
+    // Secondary DNS address
+    if (mIpv6DnsAddress2) {
+        mIpGroup->removeChild(mIpGroup->indexOf(mIpv6DnsAddress2));
+        mIpv6DnsAddress2 = NULL;
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_DELETEIPV6SETTINGITEMS_EXIT);
+}
+
+/*!
+    Creates the proxy settings group.
+*/
+void CpPacketDataApAdvancedView::createProxyGroup()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CREATEPROXYGROUP_ENTRY);
+    
+    // Proxy settings group
+    mProxyGroup = new CpSettingFormItemData(
+        HbDataFormModelItem::GroupItem, 
+        hbTrId("txt_occ_subhead_proxy_settings"));
+    mModel->appendDataFormItem(mProxyGroup);
+    
+    // Proxy server address
+    mProxyServer = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_proxy_server_address"));
+    mForm->addConnection(
+        mProxyServer,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeProxyServer()));
+    mProxyGroup->appendChild(mProxyServer);
+    
+    // Proxy port number
+    mProxyPort = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_proxy_port_number"));
+    mForm->addConnection(
+        mProxyPort,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeProxyPort()));
+    mProxyGroup->appendChild(mProxyPort);
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CREATEPROXYGROUP_EXIT);
+}
+
+/*!
+    Reads attribute values and updates the proxy settings group.
+*/
+void CpPacketDataApAdvancedView::updateProxyGroup()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_UPDATEPROXYGROUP_ENTRY);
+    
+    // Proxy server address
+    QString serverAddress = mCmConnectionMethod->getStringAttribute(
+        CMManagerShim::CmProxyServerName);
+    mProxyServer->setContentWidgetData("text", serverAddress);
+    
+    // Proxy port number
+    uint portNumber = mCmConnectionMethod->getIntAttribute(
+        CMManagerShim::CmProxyPortNumber);
+    if (portNumber > 0) {
+        mProxyPort->setContentWidgetData("text", QVariant(portNumber));
+    } else {
+        mProxyPort->setContentWidgetData("text", "");
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_UPDATEPROXYGROUP_EXIT);
+}
+
+/*!
+    Reads network type (IPv4/IPv6) from CommsDat.
+*/
+CpPacketDataApAdvancedView::NetworkType CpPacketDataApAdvancedView::getNetworkType()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_GETNETWORKTYPE_ENTRY);
+
+    uint networkType = mCmConnectionMethod->getIntAttribute(
+        CMManagerShim::PacketDataPDPType);
+    
+    if (networkType == RPacketContext::EPdpTypeIPv6) {
+        OstTraceFunctionExit0(DUP1_CPPACKETDATAAPADVANCEDVIEW_GETNETWORKTYPE_EXIT);
+        return NetworkTypeIpv6;
+    }
+
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_GETNETWORKTYPE_EXIT);
+    return NetworkTypeIpv4;
+}
+
+/*!
+    Reads an IP address from CommsDat with given attribute. If string is
+    empty, a zero address (0.0.0.0 or 0:0:0:0:0:0:0:0) is returned.
+*/
+QString CpPacketDataApAdvancedView::getIpAddress(
+    CMManagerShim::ConnectionMethodAttribute attribute)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_GETIPADDRESS_ENTRY);
+    
+    QString ipAddress = mCmConnectionMethod->getStringAttribute(attribute);
+    
+    if (ipAddress.isEmpty()) {
+        // String is empty, return a zero address instead
+        switch (attribute) {
+            case CMManagerShim::CmIPAddress:
+            case CMManagerShim::CmIPNameServer1:
+            case CMManagerShim::CmIPNameServer2:
+                // IPv4 address
+                ipAddress = CMManagerShim::UnspecifiedIpv4Address; 
+                break;
+            
+            case CMManagerShim::CmIP6NameServer1:
+            case CMManagerShim::CmIP6NameServer2:
+                // IPv6 address
+                ipAddress = CMManagerShim::DynamicIpv6Address;
+                break;
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_GETIPADDRESS_EXIT);
+    return ipAddress;
+}
+
+/*!
+    Resolves IPv6 DNS address type.
+*/
+CpPacketDataApAdvancedView::Ipv6DnsType CpPacketDataApAdvancedView::getIpv6DnsType()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_GETIPV6DNSTYPE_ENTRY);
+    
+    // Read "DNS address from server" flag
+    bool dnsAddressFromServer = mCmConnectionMethod->getBoolAttribute(
+        CMManagerShim::CmIP6DNSAddrFromServer);
+    
+    // Read IPv6 DNS addresses from CommsDat
+    QString primaryAddress = mCmConnectionMethod->getStringAttribute(
+        CMManagerShim::CmIP6NameServer1);
+    QString secondaryAddress = mCmConnectionMethod->getStringAttribute(
+        CMManagerShim::CmIP6NameServer2);
+
+    // Resolve IPv6 DNS address type
+    Ipv6DnsType type = Ipv6DnsTypeUserDefined;
+    if (dnsAddressFromServer) {
+        // Automatic
+        type = Ipv6DnsTypeAutomatic;
+    } else if (primaryAddress.toLower() == CMManagerShim::KnownIpv6NameServer1
+        && secondaryAddress.toLower() == CMManagerShim::KnownIpv6NameServer2) {
+        // Well-known IPv6 DNS addresses
+        type = Ipv6DnsTypeWellKnown;
+    }
+
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_GETIPV6DNSTYPE_EXIT);
+    return type;
+}
+
+/*!
+    Sets IPv4 address field enabled/disabled.
+*/
+void CpPacketDataApAdvancedView::enableIpv4AddressFields(int state)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_ENABLEIPV4ADDRESSFIELDS_ENTRY);
+    
+    if (state == Qt::Checked) {
+        // Automatic, disable text field
+        if (mIpv4Address) {
+            mIpv4Address->setEnabled(false);
+        }
+    } else {
+        // User defined, enable text field
+        if (mIpv4Address) {
+            mIpv4Address->setEnabled(true);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_ENABLEIPV4ADDRESSFIELDS_EXIT);
 }
 
 /*!
-    Adds settings items to the model.
+    Sets IPv4 DNS address fields enabled/disabled.
+*/
+void CpPacketDataApAdvancedView::enableIpv4DnsFields(int state)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_ENABLEIPV4DNSFIELDS_ENTRY);
+    
+    if (state == Qt::Checked) {
+        // Automatic, disable text fields
+        if (mIpv4DnsAddress1) {
+            mIpv4DnsAddress1->setEnabled(false);
+        }
+        if (mIpv4DnsAddress2) {
+            mIpv4DnsAddress2->setEnabled(false);
+        }
+    } else {
+        // User defined, enable text fields
+        if (mIpv4DnsAddress1) {
+            mIpv4DnsAddress1->setEnabled(true);
+        }
+        if (mIpv4DnsAddress2) {
+            mIpv4DnsAddress2->setEnabled(true);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_ENABLEIPV4DNSFIELDS_EXIT);
+}
+
+/*!
+    Sets IPv6 DNS address fields enabled/disabled.
+*/
+void CpPacketDataApAdvancedView::enableIpv6DnsFields(int selectionIndex)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_ENABLEIPV6DNSFIELDS_ENTRY);
+    
+    // Check combobox value
+    if (selectionIndex == Ipv6DnsTypeUserDefined) {
+        // User-defined, enable text fields
+        if (mIpv6DnsAddress1) {
+            mIpv6DnsAddress1->setEnabled(true);
+        }
+        if (mIpv6DnsAddress2) {
+            mIpv6DnsAddress2->setEnabled(true);
+        }
+    } else {
+        // Automatic or well-known, disable text fields
+        if (mIpv6DnsAddress1) {
+            mIpv6DnsAddress1->setEnabled(false);
+        }
+        if (mIpv6DnsAddress2) {
+            mIpv6DnsAddress2->setEnabled(false);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_ENABLEIPV6DNSFIELDS_EXIT);
+}
+
+/*!
+    Validates an IP address and saves it to CommsDat in case it was a valid
+    address or an empty string. In case the address is not valid, an error
+    note is shown to the user and previous setting is restored to the UI.
+*/
+bool CpPacketDataApAdvancedView::validateAndSaveIpAddress(
+    HbDataFormModelItem *item,
+    CMManagerShim::ConnectionMethodAttribute attribute,
+    QAbstractSocket::NetworkLayerProtocol protocol)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_VALIDATEANDSAVEIPADDRESS_ENTRY);
+    
+    bool success = false;
+    
+    // Check address
+    QString address = item->contentWidgetData("text").toString();
+    QHostAddress hostAddress;
+    if (hostAddress.setAddress(address)
+        && hostAddress.protocol() == protocol) {
+        // Proper address, convert to lower case (IPv6)
+        address = hostAddress.toString().toLower();
+    } else if (address.isEmpty()) {
+        // Empty string, replace with 0.0.0.0 or 0:0:0:0:0:0:0:0
+        if (protocol == QAbstractSocket::IPv4Protocol) {
+            address = CMManagerShim::UnspecifiedIpv4Address;
+        } else {
+            address = CMManagerShim::DynamicIpv6Address;
+        }
+    } else {
+        // Invalid address
+        address.clear();
+    }
+
+    if (!address.isEmpty()) {
+        // Save to CommsDat
+        mCmConnectionMethod->setStringAttribute(attribute, address);
+        if (tryUpdate()) {
+            success = true;
+            item->setContentWidgetData("text", address);
+        }
+    } else {
+        // Inform user of invalid name
+        showMessageBox(
+            HbMessageBox::MessageTypeInformation,
+            hbTrId("txt_occ_info_invalid_input"));
+        // Restore previous setting
+        address = getIpAddress(attribute);
+        item->setContentWidgetData("text", address);
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_VALIDATEANDSAVEIPADDRESS_EXIT);
+    return success;
+}
+
+/*!
+    Shows message box with "OK" button using given text.
+*/
+void CpPacketDataApAdvancedView::showMessageBox(
+    HbMessageBox::MessageBoxType type,
+    const QString &text)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_SHOWMESSAGEBOX_ENTRY);
+    
+    // Create a message box
+    mMessageBox = QSharedPointer<HbMessageBox>(new HbMessageBox(type));
+    mMessageBox->setText(text);
+    mMessageBox->setModal(true);
+    mMessageBox->setTimeout(HbPopup::NoTimeout);
+    mMessageBox->open();
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_SHOWMESSAGEBOX_EXIT);
+}
+
+/*!
+    Tries to update connection method changes to CommsDat.
+    Returns "true" if success, "false" if some error happened. 
+*/
+bool CpPacketDataApAdvancedView::tryUpdate()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_TRYUPDATE_ENTRY);
+    
+    // Try update
+    try {
+        mCmConnectionMethod->update();
+    }
+    catch (const std::exception&) {
+        // Handle error
+        handleUpdateError();
+        
+        OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_TRYUPDATE_EXIT);
+        return false;
+    }
+
+    OstTraceFunctionExit0(DUP1_CPPACKETDATAAPADVANCEDVIEW_TRYUPDATE_EXIT);
+    return true;
+}
+
+/*!
+    Handles failed CommsDat update.
+ */
+void CpPacketDataApAdvancedView::handleUpdateError()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_HANDLEUPDATEERROR_ENTRY);
+    
+    // Show error note to user
+    showMessageBox(
+        HbMessageBox::MessageTypeWarning,
+        hbTrId("txt_occ_info_unable_to_save_setting"));
+    // Reload settings from CommsDat and update UI
+    try {
+        mCmConnectionMethod->refresh();
+    }
+    catch (const std::exception&) {
+        // Ignore error from refresh. Most likely this will not happen, but
+        // if it does, there isn't very much we can do.
+        OstTrace0(
+            TRACE_ERROR,
+            CPPACKETDATAAPPADVANCEDVIEW_HANDLEUPDATEERROR,
+            "Refresh failed");
+    };
+    updateIpGroup();
+    updateProxyGroup();
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_HANDLEUPDATEERROR_EXIT);
+}
+
+/*!
+    Initializes all settings groups.
+*/
+void CpPacketDataApAdvancedView::setEditorPreferences(const QModelIndex index)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_SETEDITORPREFERENCES_ENTRY);
+    
+    HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *>
+        (mForm->itemByIndex(index));
+    HbDataFormModelItem *modelItem = mModel->itemFromIndex(index);
+
+    if (modelItem == mIpv4Address
+        || modelItem == mIpv4DnsAddress1
+        || modelItem == mIpv4DnsAddress2
+        || modelItem == mIpv6DnsAddress1
+        || modelItem == mIpv6DnsAddress2
+        || modelItem == mProxyServer
+        || modelItem == mProxyPort) {
+        // HbLineEdit items, get editor and editor interface
+        HbLineEdit *edit = qobject_cast<HbLineEdit *>
+            (viewItem->dataItemContentWidget());
+        HbEditorInterface editorInterface(edit);
+
+        if (modelItem == mIpv4Address
+            || modelItem == mIpv4DnsAddress1
+            || modelItem == mIpv4DnsAddress2) {
+                // IPv4 IP address
+                editorInterface.setMode(HbInputModeNumeric);
+                editorInterface.setFilter(CpIpv4Filter::instance());
+                edit->setMaxLength(CMManagerShim::CmIP4AddressLength);
+        } else if (modelItem == mIpv6DnsAddress1
+            || modelItem == mIpv6DnsAddress2) {
+                // IPv6 IP address
+                editorInterface.setInputConstraints(
+                    HbEditorConstraintLatinAlphabetOnly);
+                editorInterface.setFilter(CpIpv6Filter::instance());
+                edit->setInputMethodHints(
+                    Qt::ImhNoPredictiveText
+                    | Qt::ImhPreferLowercase);
+                edit->setMaxLength(CMManagerShim::CmIP6NameServerLength);
+        } else if (modelItem == mProxyServer) {                
+                // Proxy server address
+                editorInterface.setMode(HbInputModeNone);
+                editorInterface.setInputConstraints(
+                    HbEditorConstraintLatinAlphabetOnly);
+                editorInterface.setFilter(HbUrlFilter::instance());
+                editorInterface.setEditorClass(HbInputEditorClassUrl);
+                editorInterface.setDigitType(HbDigitTypeNone);
+                edit->setInputMethodHints(
+                    Qt::ImhNoPredictiveText
+                    | Qt::ImhPreferLowercase);
+                edit->setMaxLength(CMManagerShim::CmProxyServerNameLength);
+        } else { /* mProxyPort */                
+                // Proxy port number
+                editorInterface.setMode(HbInputModeNumeric);
+                edit->setInputMethodHints(Qt::ImhDigitsOnly);
+                edit->setMaxLength(CMManagerShim::CmProxyPortNumberLength);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_SETEDITORPREFERENCES_EXIT);
+}
+
+/*!
+    Handles change to network type (IPv4/IPv6).
+*/
+void CpPacketDataApAdvancedView::changeNetworkType(int type)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGENETWORKTYPE_ENTRY);
+
+    // Save network type to CommsDat
+    int pdpType;
+    if (type == NetworkTypeIpv6) {
+        pdpType = RPacketContext::EPdpTypeIPv6;
+    } else {
+        pdpType = RPacketContext::EPdpTypeIPv4;
+    }
+    mCmConnectionMethod->setIntAttribute(
+        CMManagerShim::PacketDataPDPType,
+        pdpType);
+    if (tryUpdate())
+        {
+        // This will handle updating the UI with correct setting items 
+        updateIpGroup();
+        }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGENETWORKTYPE_EXIT);
+}
+
+/*!
+    Handles change to IPv4 address mode (automatic/user defined).
 */
-void CpPacketDataApAdvancedView::createAdvancedSettings()
+void CpPacketDataApAdvancedView::changeIpv4AddressMode(int state)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4ADDRESSMODE_ENTRY);
+    
+    bool ipv4AddressFromServer;
+    if (state == Qt::Checked) {
+        ipv4AddressFromServer = true;
+    } else {
+        ipv4AddressFromServer = false;
+    }
+    
+    if (!ipv4AddressFromServer
+        && getIpAddress(CMManagerShim::CmIPAddress) ==
+            CMManagerShim::UnspecifiedIpv4Address) {
+        // User defined IP address selected, but no valid address is stored.
+        // Just enable the UI IP editors, because CMManager will update the
+        // "IP address from server" flag by itself when a valid IP address
+        // is stored.
+        enableIpv4AddressFields(state);
+    } else {
+        // Save setting to CommsDat
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIPAddrFromServer,
+            ipv4AddressFromServer);
+        if (tryUpdate()) {
+            enableIpv4AddressFields(state);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4ADDRESSMODE_EXIT);
+}
+
+/*!
+    Saves IPv4 address to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeIpv4Address()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4ADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv4Address,
+        CMManagerShim::CmIPAddress,
+        QAbstractSocket::IPv4Protocol)) {
+        // In case the IP address is empty or 0.0.0.0, CMManager changes the
+        // "IP address from server" flag to true. We need to refresh the UI to
+        // make sure we are in sync.
+        updateIpGroup();
+    }
+
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4ADDRESS_EXIT);
+}
+
+/*!
+    Handles change to IPv4 DNS mode (automatic/user defined).
+*/
+void CpPacketDataApAdvancedView::changeIpv4DnsMode(int state)
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4DNSMODE_ENTRY);
+    
+    bool dnsAddressFromServer;
+    if (state == Qt::Checked) {
+        dnsAddressFromServer = true;
+    } else {
+        dnsAddressFromServer = false;
+    }
+    // Save setting to CommsDat
+    mCmConnectionMethod->setBoolAttribute(
+        CMManagerShim::CmIPDNSAddrFromServer,
+        dnsAddressFromServer);
+    if (tryUpdate()) {
+        enableIpv4DnsFields(state);
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4DNSMODE_EXIT);
+}
+
+/*!
+    Saves IPv4 primary DNS address to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeIpv4PrimaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4PRIMARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv4DnsAddress1,
+        CMManagerShim::CmIPNameServer1,
+        QAbstractSocket::IPv4Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIPDNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0.0.0.0, CMManager will
+            // check secondary DNS address and in case it is a valid address,
+            // move it to the primary DNS address. We need to refresh the
+            // UI to make sure we are in sync. If tryUpdate() fails it does
+            // the refresh automatically, so only success case is handled
+            // here.
+            updateIpGroup();            
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4PRIMARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Saves IPv4 secondary DNS address to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeIpv4SecondaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4SECONDARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv4DnsAddress2,
+        CMManagerShim::CmIPNameServer2,
+        QAbstractSocket::IPv4Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIPDNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0.0.0.0, CMManager will
+            // write the address there instead of secondary DNS address, so we
+            // need to refresh the UI to make sure we are in sync. If
+            // tryUpdate() fails it does the refresh automatically, so only
+            // success case is handled here.
+            updateIpGroup();
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV4SECONDARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Handles change to IPv6 DNS mode (automatic/well-known/user defined).
+*/
+void CpPacketDataApAdvancedView::changeIpv6DnsMode(int state)
 {
-    // TODO: Implement the advanced settings view.
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV6DNSMODE_ENTRY);
+    
+    // Update "DNS address from server" flag
+    if (state == Ipv6DnsTypeAutomatic) {
+        // Automatic
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            true);
+    } else {
+        // User defined or well-known address
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            false);
+        
+        if (state == Ipv6DnsTypeWellKnown) {
+            // Well-known address, set DNS addresses and update UI
+            mCmConnectionMethod->setStringAttribute(
+                CMManagerShim::CmIP6NameServer1,
+                CMManagerShim::KnownIpv6NameServer1);
+            mIpv6DnsAddress1->setContentWidgetData(
+                "text",
+                CMManagerShim::KnownIpv6NameServer1);
+            mCmConnectionMethod->setStringAttribute(
+                CMManagerShim::CmIP6NameServer2,
+                CMManagerShim::KnownIpv6NameServer2);
+            mIpv6DnsAddress2->setContentWidgetData(
+                "text",
+                CMManagerShim::KnownIpv6NameServer2);        
+        }
+    }
+
+    if (tryUpdate()) {
+        enableIpv6DnsFields(state);
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV6DNSMODE_EXIT);
+}
+
+/*!
+    Saves IPv6 primary DNS address to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeIpv6PrimaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV6PRIMARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv6DnsAddress1,
+        CMManagerShim::CmIP6NameServer1,
+        QAbstractSocket::IPv6Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0:0:0:0:0:0:0:0,
+            // CMManager will check secondary DNS address and in case it is a
+            // valid address, move it to the primary DNS address. We need to
+            // refresh the UI to make sure we are in sync. If tryUpdate()
+            // fails it does the refresh automatically, so only success case
+            // is handled here.
+            updateIpGroup();            
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV6PRIMARYDNSADDRESS_EXIT);
 }
+
+/*!
+    Saves IPv6 secondary DNS address to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeIpv6SecondaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV6SECONDARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv6DnsAddress2,
+        CMManagerShim::CmIP6NameServer2,
+        QAbstractSocket::IPv6Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0:0:0:0:0:0:0:0,
+            // CMManager will write the address there instead of secondary DNS
+            // address, so we need to refresh the UI to make sure we are in
+            // sync. If tryUpdate() fails it does the refresh automatically,
+            // so only success case is handled here.
+            updateIpGroup();
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEIPV6SECONDARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Saves proxy server address to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeProxyServer()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEPROXYSERVER_ENTRY);
+    
+    QString proxyServer = mProxyServer->contentWidgetData("text").toString();
+    mCmConnectionMethod->setStringAttribute(
+        CMManagerShim::CmProxyServerName,
+        proxyServer);
+    (void)tryUpdate();
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEPROXYSERVER_EXIT);
+}
+
+/*!
+    Saves proxy port to CommsDat.
+*/
+void CpPacketDataApAdvancedView::changeProxyPort()
+{
+    OstTraceFunctionEntry0(CPPACKETDATAAPADVANCEDVIEW_CHANGEPROXYPORT_ENTRY);
+    
+    uint proxyPort = mProxyPort->contentWidgetData("text").toInt();
+    if (proxyPort <= 65535) {
+        if (proxyPort == 0) {
+            // Don't show zero
+            mProxyPort->setContentWidgetData("text", "");
+        }
+        mCmConnectionMethod->setIntAttribute(
+            CMManagerShim::CmProxyPortNumber,
+            proxyPort);
+        (void)tryUpdate();
+    } else {
+        // Inform user of invalid value
+        showMessageBox(
+            HbMessageBox::MessageTypeInformation,
+            hbTrId("txt_occ_info_invalid_input"));
+        // Restore previous setting
+        proxyPort = mCmConnectionMethod->getIntAttribute(
+            CMManagerShim::CmProxyPortNumber);
+        if (proxyPort > 0) {
+            mProxyPort->setContentWidgetData("text", QVariant(proxyPort));
+        } else {
+            mProxyPort->setContentWidgetData("text", "");
+        }
+    }
+    
+    OstTraceFunctionExit0(CPPACKETDATAAPADVANCEDVIEW_CHANGEPROXYPORT_EXIT);
+}
--- a/cmmanager/cppacketdataapplugin/src/cppacketdataapplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/src/cppacketdataapplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,9 +17,7 @@
 */
 
 // System includes
-#include <QString>
-#include <QTranslator>
-#include <QCoreApplication>
+#include <HbTranslator>
 #include <cmmanager_shim.h>
 #include <cmconnectionmethod_shim.h>
 
@@ -49,19 +47,12 @@
     Constructor.
 */
 CpPacketDataApPlugin::CpPacketDataApPlugin() :
-    mTranslator(0),
+    mTranslator(new HbTranslator("cpapplugin")),
     mCmManager(0),
     mCmConnectionMethod(0)
 {
     OstTraceFunctionEntry0(CPPACKETDATAAPPLUGIN_CPPACKETDATAAPPLUGIN_ENTRY);
  
-    // Install localization
-    QString lang = QLocale::system().name();
-    QString path = "z:/resource/qt/translations/";
-    mTranslator = new QTranslator(this);
-    mTranslator->load(path + "cpapplugin_" + lang);
-    qApp->installTranslator(mTranslator);
-    
     OstTraceFunctionExit0(CPPACKETDATAAPPLUGIN_CPPACKETDATAAPPLUGIN_EXIT);
 }
 
--- a/cmmanager/cppacketdataapplugin/src/cppacketdataapview.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/src/cppacketdataapview.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -69,7 +69,6 @@
         mConnectionNameItem(0),
         mAccessPointNameItem(0),
         mUserNameItem(0),
-        mPromptForAuthItem(0),
         mPasswordItem(0),
         mAuthenticationItem(0),
         mHomepageItem(0),
@@ -170,23 +169,6 @@
         SLOT(userNameChanged()));
     mApSettingsGroupItem->appendChild(mUserNameItem);
     
-    // Prompt for password
-    mPromptForAuthItem = new CpSettingFormItemData(
-        HbDataFormModelItem::CheckBoxItem,
-        hbTrId("txt_occ_setlabel_password"));
-    mPromptForAuthItem->setContentWidgetData("text",
-        hbTrId("txt_occ_setlabel_password_val_prompt"));
-    // Construct map to link item values to setting values
-    mPromptForAuthMap.insert(Qt::Unchecked, false); // Do not prompt
-    mPromptForAuthMap.insert(Qt::Checked, true); // Prompt for password
-    // Connect signal and add item to group
-    mForm->addConnection(
-        mPromptForAuthItem,
-        SIGNAL(stateChanged(int)),
-        this,
-        SLOT(promptForAuthChanged(int)));
-    mApSettingsGroupItem->appendChild(mPromptForAuthItem);
-    
     // Password
     mPasswordItem = new CpSettingFormItemData(
         HbDataFormModelItem::TextItem,
@@ -263,17 +245,6 @@
         CMManagerShim::PacketDataIFAuthName);
     mUserNameItem->setContentWidgetData("text", userName);
     
-    // Prompt for password
-    bool promptForAuth = mCmConnectionMethod->getBoolAttribute(
-        CMManagerShim::PacketDataIFPromptForAuth);
-    mPromptForAuthItem->setContentWidgetData("checkState",
-        mPromptForAuthMap.key(promptForAuth));
-    if (promptForAuth) {
-        mPasswordItem->setEnabled(false);
-    } else {
-        mPasswordItem->setEnabled(true);
-    }
-    
     // Password
     QString password = mCmConnectionMethod->getStringAttribute(
         CMManagerShim::PacketDataIFAuthPass);
@@ -449,28 +420,6 @@
 }
 
 /*!
-    Updates prompt for password setting to CommsDat.
-*/
-void CpPacketDataApView::promptForAuthChanged(int state)
-{
-    OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_PROMPTFORAUTHCHANGED_ENTRY);
-    
-    // If prompt for auth is selected, password edit should be disabled.
-    if (state == Qt::Checked) {
-        mPasswordItem->setEnabled(false);
-    } else {
-        mPasswordItem->setEnabled(true);
-    }
-    // Update to CommsDat
-    mCmConnectionMethod->setBoolAttribute(
-        CMManagerShim::PacketDataIFPromptForAuth,
-        mPromptForAuthMap.value(static_cast<Qt::CheckState>(state)));
-    (void)tryUpdate();
-    
-    OstTraceFunctionExit0(CPPACKETDATAAPVIEW_PROMPTFORAUTHCHANGED_EXIT);
-}
-
-/*!
     Updates password to CommsDat.
 */
 void CpPacketDataApView::passwordChanged()
--- a/cmmanager/cppacketdataapplugin/tsrc/ut/hbautotest.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/tsrc/ut/hbautotest.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -48,8 +48,7 @@
             Qt::NoButton, 
             Qt::NoModifier);
             QSpontaneKeyEvent::setSpontaneous(&me);
-            qApp->notify((window->viewport()), &me);
-            QCoreApplication::sendPostedEvents();
+            QCoreApplication::sendEvent(window->viewport(), &me);
             QTest::qWait(1);
     } else {
             HbAutoTestMouseEvent me (
@@ -60,8 +59,7 @@
             Qt::NoButton, 
             Qt::NoModifier);
             QSpontaneKeyEvent::setSpontaneous(&me);
-            qApp->notify((window->viewport()), &me);
-            QCoreApplication::sendPostedEvents();
+            QCoreApplication::sendEvent(window->viewport(), &me);
             QTest::qWait(1);
 
     }
@@ -94,9 +92,7 @@
     Qt::NoModifier);
 
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
-    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendEvent(window->viewport(), &me);
     QTest::qWait(1);
 }
 
@@ -123,8 +119,7 @@
     Qt::NoModifier);
 
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendEvent(window->viewport(), &me);
 
     QTest::qWait(1);
     QTest::qWait(1);
@@ -152,15 +147,12 @@
     Qt::LeftButton, 
     Qt::NoModifier);
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
-    //QTime currentTime = QTime::currentTime();
-    //qDebug() << currentTime.toString("hh:mm:ss.zzz") << ": Left button down";
-    QTest::qWait(1);
+    QCoreApplication::sendEvent(window->viewport(), &me);
 
     if (delay!=-1) {
         QTest::qWait(delay);
     }
+
     HbAutoTestMouseEvent me2 (
     QEvent::MouseButtonRelease, 
     targetPoint.toPoint(), 
@@ -170,10 +162,7 @@
     Qt::NoModifier);
 
     QSpontaneKeyEvent::setSpontaneous(&me2);
-    qApp->notify((window->viewport()), &me2);
-    QCoreApplication::sendPostedEvents();
-    //currentTime = QTime::currentTime();
-    //qDebug() << currentTime.toString("hh:mm:ss.zzz") << ": Left button up";
+    QCoreApplication::sendEvent(window->viewport(), &me2);
 
     QTest::qWait(1);
     QTest::qWait(1);
@@ -221,8 +210,8 @@
                             Qt::NoModifier);   
 
         QSpontaneKeyEvent::setSpontaneous(&me);
-        qApp->notify((window->viewport()), &me);
-        QCoreApplication::sendPostedEvents();
+        QCoreApplication::sendEvent(window->viewport(), &me);
+        QTest::qWait(1);
     }
 
     QCursor::setPos(window->mapToGlobal(targetPoint.toPoint()));
@@ -235,8 +224,7 @@
                             Qt::LeftButton, 
                             Qt::NoModifier);   
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendEvent(window->viewport(), &me);
 }
 
 
@@ -255,7 +243,7 @@
 
         HbAutoTestKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);
         QSpontaneKeyEvent::setSpontaneous(&a);
-        if (!qApp->notify(widget, &a))
+        if (!QCoreApplication::sendEvent(widget, &a))
             QTest::qWarn("Keyboard event not accepted by receiving widget");
     }
 
--- a/cmmanager/cppacketdataapplugin/tsrc/ut/testcppacketdataapplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/tsrc/ut/testcppacketdataapplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,12 +24,17 @@
 #include <HbDataForm>
 #include <HbDataFormModel>
 #include <HbDataFormModelItem>
+#include <HbDataFormViewItem>
+#include <HbModelIterator>
+#include <HbComboBox>
 #include <QtTest/QtTest>
+#include <etelpckt.h>
 #include <cpbearerapplugininterface.h>
 #include <cmmanager_shim.h>
 #include <cmconnectionmethod_shim.h>
 
 #include "cppacketdataapview.h"
+#include "cppacketdataapadvancedview.h"
 
 #include "hbautotest.h"
 #include "testcppacketdataapplugin.h"
@@ -50,28 +55,30 @@
 static const int waitTime = 10;
 
 // UI coordinates
-static const QPoint sideTop(350, 60);
-static const QPoint scrollStart(350, 300);
-static const QPoint scrollStop(350, 240);
+static const QPoint scrollMiddle(350, 280);
+static const QPoint scrollTop(350, 30);
+static const QPoint scrollBottom(350, 540);
 
-static const QPoint messageBoxOkButton(170, 320);
-
-// These are measured when view is scrolled to top
-static const QPoint connectionNameLineEdit(330, 110);
-
-static const QPoint accessPointNameLineEdit(330, 190);
+// Use positive offset if dropdown opens under the combobox
+static const QPoint comboBoxFirstItemOffset(80, 75);
+static const QPoint comboBoxItemOffset(0, 51);
+// Use negative offset if dropdown opens above the combobox
+static const QPoint comboBoxFirstItemNegativeOffset(80, -29);
+static const QPoint comboBoxItemNegativeOffset(0, -51);
 
-static const QPoint userNameLineEdit(330, 265);
+static const QPoint exitEditorOffset(-10, -20);
 
-// These are measured when view is scrolled to bottom
-static const QPoint passwordPromptCheckbox(50, 295);
-static const QPoint passwordLineEdit(330, 380);
+static const QPoint messageBoxOkButtonOffset(160, 140);
 
-static const QPoint authenticationComboBox(175, 470);
-static const QPoint authenticationSecure(100, 420);
-static const QPoint authenticationNormal(100, 365);
+// Advanced settings groups
+static const QPoint ipGroup(160, 10);
+static const QPoint proxyGroup(160, 60);
 
-static const QPoint homepageLineEdit(330, 555);
+// Test strings
+static const QString tooLongUserName =
+    "too long name 123456789012345678901234567890123456THISISEXTRA";
+static const QString truncatedUserName =
+    "too long name 123456789012345678901234567890123456";
 
 // -----------------------------------------------------------------------------
 // FRAMEWORK FUNCTIONS
@@ -111,15 +118,20 @@
     
     // Load plugin
     QDir dir(pluginDir);
-    QPluginLoader loader(dir.absoluteFilePath(pluginName));
-    mPlugin = qobject_cast<CpBearerApPluginInterface *>(loader.instance());
+    mPluginLoader = new QPluginLoader(dir.absoluteFilePath(pluginName));
+    mPlugin = qobject_cast<CpBearerApPluginInterface *>(mPluginLoader->instance());
     QVERIFY(mPlugin != NULL);
     
     // Verify plugin bearer type
     QVERIFY(mPlugin->bearerType() == CMManagerShim::BearerTypePacketData);
     
+    // Write initial settings to CommsDat
+    subInitializeCommsDat();
+    
     // Create packet data settings view (connection method ID given)
     subCreateSettingsView(testApId);
+    
+    subGetUiWidgets();
 }
 
 /**
@@ -129,6 +141,11 @@
 {
     delete mMainWindow;
     mMainWindow = 0;
+    
+    // Force unloading of plugin
+    mPluginLoader->unload();
+    delete mPluginLoader;
+    mPluginLoader = 0;
 }
 
 /**
@@ -158,15 +175,16 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::CmNameLength);
+    QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -184,11 +202,11 @@
     QTest::addColumn<QString>("result");
     
     QTest::newRow("maximum length")
-        << "really long name 1234567890123"
-        << "really long name 1234567890123";
+        << "really long name 123456789012345678901234567890123"
+        << "really long name 123456789012345678901234567890123";
     QTest::newRow("too long")
-        << "too long name 123456789012345678901234567890"
-        << "too long name 1234567890123456";
+        << "too long name 12345678901234567890123456789012345678901234"
+        << "too long name 123456789012345678901234567890123456";
     QTest::newRow("basic") // last one must always fit on one line in UI
         << "test packet AP"
         << "test packet AP";
@@ -202,16 +220,20 @@
     QString previous = 
         mTestView->mConnectionNameItem->contentWidgetData("text").toString();
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::CmNameLength);
+    QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset);
 
     QTest::qWait(100);
     // Dismiss messagebox
-    HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestView->mMessageBox.data(),
+        messageBoxOkButtonOffset);
     
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -228,15 +250,16 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, accessPointNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::PacketDataAPNameLength);
+    QString text = mTestView->mAccessPointNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -272,16 +295,20 @@
     QString previous = 
         mTestView->mAccessPointNameItem->contentWidgetData("text").toString();
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, accessPointNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::PacketDataAPNameLength);
+    QString text = mTestView->mAccessPointNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget, exitEditorOffset);
 
     QTest::qWait(100);
     // Dismiss messagebox
-    HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestView->mMessageBox.data(),
+        messageBoxOkButtonOffset);
     
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -290,6 +317,33 @@
         previous);
 }
 
+
+/**
+ * Tests handling of too long string from CommsDat (longer than UI accepts).
+ */
+void TestCpPacketDataApPlugin::tcTooLongUserNameInCommsDat()
+{
+    // Verify UI text, the widget contains the too long string, even though
+    // it is not shown completely on UI
+    QString text = mTestView->mUserNameItem->contentWidgetData("text").toString();
+    QCOMPARE(tooLongUserName, text);
+
+    QTest::qWait(1000);
+    
+    // Visit editing state, truncated string should be saved to CommsDat
+    HbAutoTest::mouseClick(mMainWindow, mUserNameWidget);
+    
+    QTest::qWait(1000);
+    
+    HbAutoTest::mouseClick(mMainWindow, mUserNameWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIFAuthName,
+        mTestView->mUserNameItem,
+        truncatedUserName);
+}
+
 /**
  * Tests changing of user name.
  */
@@ -298,15 +352,16 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, userNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mUserNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::PacketDataIFAuthNameLength);
+    QString text = mTestView->mUserNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mUserNameWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -323,13 +378,12 @@
     QTest::addColumn<QString>("string");
     QTest::addColumn<QString>("result");
 
-// Long strings don't work, Orbit bug? Screen goes blank
-//    QTest::newRow("maximum length")
-//        << "really long name 123456789012345678901234567890123"
-//        << "really long name 123456789012345678901234567890123";
-//    QTest::newRow("too long")
-//        << "too long name 1234567890123456789012345678901234567890123"
-//        << "too long name 123456789012345678901234567890123456";
+    QTest::newRow("maximum length")
+        << "really long name 123456789012345678901234567890123"
+        << "really long name 123456789012345678901234567890123";
+    QTest::newRow("too long")
+        << "too long name 1234567890123456789012345678901234567890123"
+        << "too long name 123456789012345678901234567890123456";
     QTest::newRow("basic")
         << "username"
         << "username";
@@ -343,44 +397,7 @@
  */
 void TestCpPacketDataApPlugin::tcScrollToBottom()
 {
-    // Scroll to the bottom of the view
-    HbAutoTest::mousePress(mMainWindow, mTestView, scrollStart);
-    QTest::qWait(500);
-    HbAutoTest::mouseMove(mMainWindow, mTestView, scrollStop);
-    HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollStop);
-}
-
-/**
- * Tests "prompt" password checkbox.
- */
-void TestCpPacketDataApPlugin::tcChangePromptPassword()
-{
-    // Ensure prompt for password is unchecked
-    bool prompt = subGetBool(CMManagerShim::PacketDataIFPromptForAuth);
-    if (prompt) {
-        // Disable prompt for password
-        HbAutoTest::mouseClick(
-            mMainWindow,
-            mTestView,
-            passwordPromptCheckbox);
-    }
-    
-    // Enable prompt for password and verify
-    HbAutoTest::mouseClick(mMainWindow, mTestView, passwordPromptCheckbox);
-    subVerifyBool(
-        CMManagerShim::PacketDataIFPromptForAuth,
-        true);
-    
-    // Verify that password lineedit is disabled, following steps will
-    // fail if editing is allowed
-    HbAutoTest::mouseClick(mMainWindow, mTestView, passwordLineEdit);
-    QTest::qWait(waitTime);
-
-    // Disable prompt for password and verify
-    HbAutoTest::mouseClick(mMainWindow, mTestView, passwordPromptCheckbox);
-    subVerifyBool(
-        CMManagerShim::PacketDataIFPromptForAuth,
-        false);
+    subScrollToBottom();
 }
 
 /**
@@ -391,15 +408,16 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, passwordLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mPasswordWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::PacketDataIFAuthPassLength);
+    QString text = mTestView->mPasswordItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mPasswordWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -416,13 +434,12 @@
     QTest::addColumn<QString>("string");
     QTest::addColumn<QString>("result");
 
-// Long strings don't work, Orbit bug? Screen goes blank
-//    QTest::newRow("maximum length")
-//        << "really long name 123456789012345678901234567890123"
-//        << "really long name 123456789012345678901234567890123";
-//    QTest::newRow("too long")
-//        << "too long name 1234567890123456789012345678901234567890123"
-//        << "too long name 123456789012345678901234567890123456";
+    QTest::newRow("maximum length")
+        << "really long name 123456789012345678901234567890123"
+        << "really long name 123456789012345678901234567890123";
+    QTest::newRow("too long")
+        << "too long name 1234567890123456789012345678901234567890123"
+        << "too long name 123456789012345678901234567890123456";
     QTest::newRow("basic")
         << "password"
         << "password";
@@ -436,19 +453,22 @@
  */
 void TestCpPacketDataApPlugin::tcChangeAuthenticationMode()
 {
+    QPointF normalPointOffset = comboBoxFirstItemOffset;
+    QPointF securePointOffset = comboBoxFirstItemOffset + comboBoxItemOffset;
+    
     // Set authentication mode to secure
-    HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationComboBox, 100);
+    HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget);
     QTest::qWait(100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationSecure, 100);
+    HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget, securePointOffset);
 
     subVerifyBool(
         CMManagerShim::PacketDataDisablePlainTextAuth,
         true);
     
     // Set authentication mode to normal
-    HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationComboBox, 100);
+    HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget);
     QTest::qWait(100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationNormal, 100);
+    HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget, normalPointOffset);
 
     subVerifyBool(
         CMManagerShim::PacketDataDisablePlainTextAuth,
@@ -463,7 +483,7 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, homepageLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mHomepageWidget);
     
     // Erase old string
     QString text = mTestView->mHomepageItem->contentWidgetData("text").toString();
@@ -472,7 +492,7 @@
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
+    HbAutoTest::mouseClick(mMainWindow, mHomepageWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -489,10 +509,9 @@
     QTest::addColumn<QString>("string");
     QTest::addColumn<QString>("result");
   
-// Doesn't work always, view goes blank sometimes, Orbit bug?
-//    QTest::newRow("long")
-//        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
-//        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
+    QTest::newRow("long")
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
     QTest::newRow("basic") // last one should always fit on one line in UI
         << "http://www.symbian.org/"
         << "http://www.symbian.org/";
@@ -502,9 +521,9 @@
 }
 
 /**
- * Tests advanced settings view (which is currently empty).
+ * Opens advanced settings view.
  */
-void TestCpPacketDataApPlugin::tcAdvancedSettings()
+void TestCpPacketDataApPlugin::tcOpenAdvancedSettingsView()
 {
     // Launch advanced settings view
     bool status = connect(
@@ -515,8 +534,622 @@
     Q_ASSERT(status);
     emit menuActionTriggered(mTestView->mAdvancedSettingsAction);
 
-    QTest::qWait(2000);
+    QTest::qWait(1000);
+    
+    mTestViewAdvanced = static_cast<CpPacketDataApAdvancedView *>(mMainWindow->currentView());
+}
+
+/**
+ * Expands the IP settings group.
+ */
+void TestCpPacketDataApPlugin::tcExpandIpSettings()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipGroup);
+    
+    subGetAdvancedUiWidgets(0);
+}
+
+/**
+ * Sets the network type to IPv4 and gets UI widget pointers.
+ */
+void TestCpPacketDataApPlugin::tcSetIpv4NetworkType()
+{
+    QPointF ipv4PointOffset = comboBoxFirstItemOffset;
+    
+    // Set network type to IPv4
+    HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget, ipv4PointOffset, 100);
+    subVerifyUint(CMManagerShim::PacketDataPDPType, RPacketContext::EPdpTypeIPv4);
+    
+    subGetAdvancedUiWidgets(0);
+}
+
+/**
+ * Tests enabling of automatic phone IP address.
+ */
+void TestCpPacketDataApPlugin::tcEnableAutomaticIpv4Address()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IP address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
+    }
+    // Enable automatic IP address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
+    subVerifyBool(
+        CMManagerShim::PacketDataIPAddrFromServer,
+        true);
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget);
+}
+
+/**
+ * Tests disabling of automatic phone IP address.
+ */
+void TestCpPacketDataApPlugin::tcEnableUserDefinedIpv4Address()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IP address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
+    }
+    // Can't verify the setting from CommsDat here, because CMManager will
+    // set it back to true if no valid IP address is yet defined. The flag
+    // is verified in tcChangeIpAddress().
+}
+
+/**
+ * Tests changing of IP address.
+ */
+void TestCpPacketDataApPlugin::tcChangeIpAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4Address->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPAddr,
+        mTestViewAdvanced->mIpv4Address,
+        result);
+    subVerifyBool(
+        CMManagerShim::PacketDataIPAddrFromServer,
+        false);
+}
+
+/**
+ * Test data for IP address change test case.
+ */
+void TestCpPacketDataApPlugin::tcChangeIpAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("too long")
+        << "255.255.255.2551234"
+        << "255.255.255.255";
+    QTest::newRow("normal")
+        << "192.168.0.1"
+        << "192.168.0.1";
+}
+
+/**
+ * Scrolls the tested view to the bottom.
+ */
+void TestCpPacketDataApPlugin::tcScrollToBottom2()
+{
+    subScrollToBottom();
+    
+    subGetAdvancedUiWidgets(0);
+}
+
+/**
+ * Tests enabling of automatic IPv4 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcEnableAutomaticIpv4DnsAddress()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IPv4 DNS address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
+    }
+    // Enable automatic IPv4 DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
+    subVerifyBool(
+        CMManagerShim::PacketDataIPDNSAddrFromServer,
+        true);
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget);
+}
+
+/**
+ * Tests disabling of automatic IPv4 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcEnableUserDefinedIpv4DnsAddress()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IPv4 DNS address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
+    }
+    // Can't verify the setting from CommsDat here, because CMManager will
+    // set it back to true if no valid IP address is yet defined. The flag
+    // is verified in tcChangeIpv4DnsAddress().
+}
+
+/**
+ * Tests changing of IPv4 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcChangeIpv4DnsAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    // Primary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPNameServer1,
+        mTestViewAdvanced->mIpv4DnsAddress1,
+        result);
+    
+    // Secondary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget);
+    
+    // Erase old string
+    text = mTestViewAdvanced->mIpv4DnsAddress2->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPNameServer2,
+        mTestViewAdvanced->mIpv4DnsAddress2,
+        result);
+    
+    // Verify user defined address is in use
+    subVerifyBool(
+        CMManagerShim::PacketDataIPDNSAddrFromServer,
+        false);
+}
+
+/**
+ * Test data for IPv4 DNS address change test case.
+ */
+void TestCpPacketDataApPlugin::tcChangeIpv4DnsAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("too long")
+        << "255.255.255.2551234"
+        << "255.255.255.255";
+    QTest::newRow("normal")
+        << "192.168.0.1"
+        << "192.168.0.1";
+}
+
+/**
+ * Tests invalid IPv4 DNS address.
+ */
+void TestCpPacketDataApPlugin::tcInvalidIpv4DnsAddress()
+{
+    QString previous = 
+        mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPNameServer1,
+        mTestViewAdvanced->mIpv4DnsAddress1,
+        previous);
+}
+
+/**
+ * Scrolls the tested view to the top.
+ */
+void TestCpPacketDataApPlugin::tcScrollToTop()
+{
+    subScrollToTop();
+}
+
+/**
+ * Sets the network type to IPv6 and gets UI widget pointers.
+ */
+void TestCpPacketDataApPlugin::tcSetIpv6NetworkType()
+{
+    QPointF ipv6PointOffset = comboBoxFirstItemOffset + comboBoxItemOffset;
+    
+    // Set network type to IPv6
+    HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget, ipv6PointOffset, 100);
+    subVerifyUint(CMManagerShim::PacketDataPDPType, RPacketContext::EPdpTypeIPv6);
+
+    subGetAdvancedUiWidgets(0);
+}
+
+/**
+ * Tests enabling of automatic IPv6 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcEnableAutomaticIpv6DnsAddress()
+{
+    // Enable automatic IPv6 DNS address
+    QPointF automaticPointOffset = comboBoxFirstItemOffset;
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
+    QTest::qWait(100);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, automaticPointOffset, 100);
+    QTest::qWait(100);
+    subVerifyBool(
+        CMManagerShim::PacketDataIPIP6DNSAddrFromServer,
+        true);
     
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
+}
+
+/**
+ * Tests enabling of well-known IPv6 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcEnableWellKnownIpv6DnsAddress()
+{
+    // Enable well-known IPv6 DNS address
+    QPointF wellKnownPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset;
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
+    QTest::qWait(100);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, wellKnownPointOffset, 100);
+    QTest::qWait(100);
+    subVerifyBool(
+        CMManagerShim::PacketDataIPIP6DNSAddrFromServer,
+        false);
+    subVerifyString(
+        CMManagerShim::PacketDataIPIP6NameServer1,
+        mTestViewAdvanced->mIpv6DnsAddress1,
+        "fec0:000:0000:ffff::1");
+    subVerifyString(
+        CMManagerShim::PacketDataIPIP6NameServer2,
+        mTestViewAdvanced->mIpv6DnsAddress2,
+        "fec0:000:0000:ffff::2");
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
+}
+
+/**
+ * Tests enabling of user defined IPv6 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcEnableUserDefinedIpv6DnsAddress()
+{
+    // Select user defined IPv6 DNS address
+    QPointF userDefinedPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset * 2;
+    //QPointF userDefinedPointOffset(0, 160);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
+    QTest::qWait(100);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, userDefinedPointOffset, 100);
+    QTest::qWait(100);
+    // Can't verify the setting from CommsDat here, because CMManager will
+    // set it back to true if no valid IP address is yet defined. The flag
+    // is verified in tcChangeIpv4DnsAddress().
+}
+
+/**
+ * Tests changing of IPv6 DNS addresses.
+ */
+void TestCpPacketDataApPlugin::tcChangeIpv6DnsAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    // Primary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPIP6NameServer1,
+        mTestViewAdvanced->mIpv6DnsAddress1,
+        result);
+    
+    // Secondary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
+    
+    // Erase old string
+    text = mTestViewAdvanced->mIpv6DnsAddress2->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPIP6NameServer2,
+        mTestViewAdvanced->mIpv6DnsAddress2,
+        result);
+    
+    // Verify user defined address is in use
+    subVerifyBool(
+        CMManagerShim::PacketDataIPIP6DNSAddrFromServer,
+        false);
+}
+
+/**
+ * Test data for IPv6 DNS address change test case.
+ */
+void TestCpPacketDataApPlugin::tcChangeIpv6DnsAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("normal")
+        << "2001:db8:85a3::8a2e:370:7334"
+        << "2001:db8:85a3:0:0:8a2e:370:7334";
+}
+
+/**
+ * Tests invalid IPv6 DNS address.
+ */
+void TestCpPacketDataApPlugin::tcInvalidIpv6DnsAddress()
+{
+    QString previous = 
+        mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "abcdef:fedcba", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::PacketDataIPIP6NameServer1,
+        mTestViewAdvanced->mIpv6DnsAddress1,
+        previous);
+}
+
+/**
+ * Collapses the IP settings group.
+ */
+void TestCpPacketDataApPlugin::tcCollapseIpSettings()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipGroup);
+}
+
+/**
+ * Expands the proxy settings group and gets UI widget pointers.
+ */
+void TestCpPacketDataApPlugin::tcExpandProxySettingsAndGetUiWidgets()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup);
+
+    QTest::qWait(500);
+    
+    subGetAdvancedUiWidgets(1);
+}
+
+/**
+ * Tests changing of proxy server address.
+ */
+void TestCpPacketDataApPlugin::tcChangeProxyServerAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mProxyServer->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmProxyServerName,
+        mTestViewAdvanced->mProxyServer,
+        result);
+    // Verify user defined address flag is set correctly
+    if (result.isEmpty()) {
+        subVerifyBool(
+            CMManagerShim::CmProxyUsageEnabled,
+            false);
+    } else {
+        subVerifyBool(
+            CMManagerShim::CmProxyUsageEnabled,
+            true);
+    }
+}
+
+/**
+ * Test data for proxy server address change test case.
+ */
+void TestCpPacketDataApPlugin::tcChangeProxyServerAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("long")
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
+    QTest::newRow("empty")
+        << ""
+        << "";
+    QTest::newRow("basic") // last one should always fit on one line in UI
+        << "http://www.symbian.org/"
+        << "http://www.symbian.org/";
+}
+
+/**
+ * Tests changing of proxy port number.
+ */
+void TestCpPacketDataApPlugin::tcChangeProxyPortNumber()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyUint(
+        CMManagerShim::CmProxyPortNumber,
+        result.toInt());
+    QCOMPARE(
+        mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(),
+        result.toInt());
+}
+
+/**
+ * Test data for proxy port number change test case.
+ */
+void TestCpPacketDataApPlugin::tcChangeProxyPortNumber_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("basic")
+        << "8080"
+        << "8080";
+    QTest::newRow("too long")
+        << "1234567890"
+        << "12345";
+    QTest::newRow("zero")
+        << "0"
+        << "";
+    QTest::newRow("empty")
+        << ""
+        << "";
+}
+
+/**
+ * Tests invalid proxy port number.
+ */
+void TestCpPacketDataApPlugin::tcInvalidProxyPortNumber()
+{
+    int previous = 
+        mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt();
+    
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "65536", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyUint(
+        CMManagerShim::CmProxyPortNumber,
+        previous);
+    QCOMPARE(
+        mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(),
+        previous);
+}
+
+/**
+ * Collapses the proxy settings group.
+ */
+void TestCpPacketDataApPlugin::tcCollapseProxySettings()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup);
+}
+
+/**
+ * Returns from advanced settings view.
+ */
+void TestCpPacketDataApPlugin::tcCloseAdvancedSettingsView()
+{
     // Return from advanced settings view
     subClickWidget("HbNavigationButton");
 }
@@ -526,6 +1159,125 @@
 // -----------------------------------------------------------------------------
 
 /**
+ * Gets UI widget pointers.
+ */
+void TestCpPacketDataApPlugin::subGetUiWidgets()
+{
+    HbModelIterator iterator(mTestView->mModel);
+    
+    // Get "Access point settings" group item
+    QModelIndex apGroupIndex = iterator.index(0);
+    
+    // Get UI widgets
+    mConnectionNameWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(0, apGroupIndex));
+    mAccessPointNameWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(1, apGroupIndex));
+    mUserNameWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(2, apGroupIndex));
+    mPasswordWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(4, apGroupIndex));
+    mAuthenticationWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(5, apGroupIndex));
+    mHomepageWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(6, apGroupIndex));
+}
+
+/**
+ * Gets advanced settings view UI widget pointers by group index.
+ */
+void TestCpPacketDataApPlugin::subGetAdvancedUiWidgets(
+    uint index)
+{
+    // Get the group item
+    HbModelIterator iterator(mTestViewAdvanced->mModel);
+    QModelIndex groupIndex = iterator.index(index);
+    
+    // Get UI widgets
+    if (index == 0) {
+        // IP settings group
+        mNetworkTypeWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(0, groupIndex));
+        if (qobject_cast<HbComboBox *>(mNetworkTypeWidget)->currentIndex() == 0) {
+            // IPv4
+            mIpv4AddressAutomaticWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(1, groupIndex));
+            mIpv4AddressWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(2, groupIndex));
+            mIpv4DnsAddressAutomaticWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(3, groupIndex));
+            mIpv4PrimaryDnsAddressWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(4, groupIndex));
+            mIpv4SecondaryDnsAddressWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(5, groupIndex));
+        } else {
+            // IPv6
+            mIpv6DnsAddressAutomaticWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(1, groupIndex));
+            mIpv6PrimaryDnsAddressWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(2, groupIndex));
+            mIpv6SecondaryDnsAddressWidget = subGetWidgetByIndex(
+                mTestViewAdvanced->mForm,
+                iterator.index(3, groupIndex));
+        }
+    } else {
+        // Proxy settings group
+        mProxyServerAddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(0, groupIndex));
+        mProxyPortNumberWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(1, groupIndex));
+    }
+}
+
+/**
+ * Gets an UI widget from HbDataForm by index. 
+ */
+HbWidget *TestCpPacketDataApPlugin::subGetWidgetByIndex(
+    HbDataForm *form,
+    const QModelIndex &index)
+{
+    HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *>
+        (form->itemByIndex(index));
+    HbWidget *widget = viewItem->dataItemContentWidget();
+    //QString widgetClassName(widget->metaObject()->className());
+    //qDebug() << widgetClassName;
+    return widget;
+}
+
+/**
+ * Writes initial settings to CommsDat needed by some test cases.
+ */
+void TestCpPacketDataApPlugin::subInitializeCommsDat()
+{
+    QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
+    QScopedPointer<CmConnectionMethodShim> connectionMethod( 
+        cmManager->connectionMethod(testApId));
+    
+    // Initial settings
+    connectionMethod->setStringAttribute(
+        CMManagerShim::PacketDataIFAuthName,
+        tooLongUserName);
+    
+    connectionMethod->update();
+}
+
+/**
  * Creates the settings view and shows it.
  */
 void TestCpPacketDataApPlugin::subCreateSettingsView(uint connectionMethodId)
@@ -549,6 +1301,8 @@
     HbDataFormModelItem *item,
     QString expected)
 {
+    QTest::qWait(waitTime);
+
     // Read attribute value from CommsDat
     QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
     QScopedPointer<CmConnectionMethodShim> connectionMethod( 
@@ -569,17 +1323,15 @@
 void TestCpPacketDataApPlugin::subClearLineEdit(
     uint length)
 {
-    // Erase old string
-    QTest::qWait(5000); // TODO: Remove this when item specific menu doesn't pop up anymore
-
     // Move cursor to end of string
-    //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, 0, waitTime); // doesn't seem to do anything? 
+    //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, Qt::ControlModifier, waitTime); // doesn't seem to do anything? 
     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
     for (int i=0; i<25; i++) {
         HbAutoTest::keyClick(mMainWindow, Qt::Key_Right, 0, waitTime);
     }
+    // Erase string
     for (int i=0; i<length; i++) {
         HbAutoTest::keyClick(mMainWindow, Qt::Key_Backspace, 0, waitTime);
     }
@@ -604,6 +1356,8 @@
     CMManagerShim::ConnectionMethodAttribute attribute,
     bool expected)
 {
+    QTest::qWait(waitTime);
+    
     // Read attribute value from CommsDat
     QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
     QScopedPointer<CmConnectionMethodShim> connectionMethod( 
@@ -614,6 +1368,24 @@
 }
 
 /**
+ * Verifies that given attribute contains expected integer value in CommsDat. 
+ */
+void TestCpPacketDataApPlugin::subVerifyUint(
+    CMManagerShim::ConnectionMethodAttribute attribute,
+    uint expected)
+{
+    QTest::qWait(waitTime);
+
+    // Read attribute value from CommsDat
+    QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
+    QScopedPointer<CmConnectionMethodShim> connectionMethod( 
+        cmManager->connectionMethod(testApId));
+    uint commsdat = connectionMethod->getIntAttribute(attribute);
+    
+    QCOMPARE(commsdat, expected);
+}
+
+/**
  * Clicks a widget currently on UI by class name.
  */
 void TestCpPacketDataApPlugin::subClickWidget(const QString &name)
@@ -636,3 +1408,27 @@
     Q_ASSERT(target);
     HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target));
 }
+
+/**
+ * Scrolls the tested view to the bottom.
+ */
+void TestCpPacketDataApPlugin::subScrollToBottom()
+{
+    // Scroll to the bottom of the view
+    HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle);
+    QTest::qWait(1000);
+    HbAutoTest::mouseMove(mMainWindow, mTestView, scrollTop);
+    HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollTop);
+}
+
+/**
+ * Scrolls the tested view to the top.
+ */
+void TestCpPacketDataApPlugin::subScrollToTop()
+{
+    // Scroll to the top of the view
+    HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle);
+    QTest::qWait(1000);
+    HbAutoTest::mouseMove(mMainWindow, mTestView, scrollBottom);
+    HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollBottom);
+}
--- a/cmmanager/cppacketdataapplugin/tsrc/ut/testcppacketdataapplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cppacketdataapplugin/tsrc/ut/testcppacketdataapplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -19,12 +19,16 @@
 #include <QtTest/QtTest>
 #include <cmmanagerdefines_shim.h>
 
+class HbWidget;
 class HbDialog;
 class HbMainWindow;
 class HbAutoTestMainWindow;
+class HbDataForm;
 class HbDataFormModelItem;
+class HbDataFormViewItem;
 class HbAction;
 class CpPacketDataApView;
+class CpPacketDataApAdvancedView;
 class CpBearerApPluginInterface;
 
 class TestCpPacketDataApPlugin : public QObject
@@ -50,19 +54,54 @@
         void tcChangeAccessPointName();
         void tcChangeAccessPointName_data();
         void tcAccessPointNameEmpty();
+        void tcTooLongUserNameInCommsDat();
         void tcChangeUserName();
         void tcChangeUserName_data();
         void tcScrollToBottom();
-        void tcChangePromptPassword();
         void tcChangePassword();
         void tcChangePassword_data();
         void tcChangeAuthenticationMode();
         void tcChangeHomepage();
         void tcChangeHomepage_data();
-        void tcAdvancedSettings();
+        void tcOpenAdvancedSettingsView();
+        void tcExpandIpSettings();
+        void tcSetIpv4NetworkType();
+        void tcEnableAutomaticIpv4Address();
+        void tcEnableUserDefinedIpv4Address();
+        void tcChangeIpAddress();
+        void tcChangeIpAddress_data();
+        void tcScrollToBottom2();
+        void tcEnableAutomaticIpv4DnsAddress();
+        void tcEnableUserDefinedIpv4DnsAddress();
+        void tcChangeIpv4DnsAddress();
+        void tcChangeIpv4DnsAddress_data();
+        void tcInvalidIpv4DnsAddress();
+        void tcScrollToTop();
+        void tcSetIpv6NetworkType();
+        void tcEnableAutomaticIpv6DnsAddress();
+        void tcEnableWellKnownIpv6DnsAddress();
+        void tcEnableUserDefinedIpv6DnsAddress();
+        void tcChangeIpv6DnsAddress();
+        void tcChangeIpv6DnsAddress_data();
+        void tcInvalidIpv6DnsAddress();
+        void tcCollapseIpSettings();
+        void tcExpandProxySettingsAndGetUiWidgets();
+        void tcChangeProxyServerAddress();
+        void tcChangeProxyServerAddress_data();
+        void tcChangeProxyPortNumber();
+        void tcChangeProxyPortNumber_data();
+        void tcInvalidProxyPortNumber();
+        void tcCollapseProxySettings();
+        void tcCloseAdvancedSettingsView();
 
     private:
         // Sub test cases
+        void subGetUiWidgets();
+        void subGetAdvancedUiWidgets(uint index);
+        HbWidget *subGetWidgetByIndex(
+            HbDataForm *form,
+            const QModelIndex &index);
+        void subInitializeCommsDat();
         void subCreateSettingsView(uint connetionMethodId);
         void subVerifyString(
             CMManagerShim::ConnectionMethodAttribute attribute,
@@ -73,13 +112,41 @@
         void subVerifyBool(
             CMManagerShim::ConnectionMethodAttribute attribute,
             bool expected);
+        void subVerifyUint(
+            CMManagerShim::ConnectionMethodAttribute attribute,
+            uint expected);
         void subClickWidget(const QString &name);
+        void subScrollToBottom();
+        void subScrollToTop();
 
     private:
         // Code references
         CpPacketDataApView *mTestView;
+        CpPacketDataApAdvancedView *mTestViewAdvanced;
+        // "Access point settings" UI widgets
+        HbWidget *mConnectionNameWidget;
+        HbWidget *mAccessPointNameWidget;
+        HbWidget *mUserNameWidget;
+        HbWidget *mPasswordWidget;
+        HbWidget *mAuthenticationWidget;
+        HbWidget *mHomepageWidget;
+        // "Advanced settings" UI widgets
+        HbDataFormViewItem *mIpGroupViewItem;
+        HbDataFormViewItem *mProxyGroupViewItem;
+        HbWidget *mNetworkTypeWidget;
+        HbWidget *mIpv4AddressAutomaticWidget;
+        HbWidget *mIpv4AddressWidget;
+        HbWidget *mIpv4DnsAddressAutomaticWidget;
+        HbWidget *mIpv4PrimaryDnsAddressWidget;
+        HbWidget *mIpv4SecondaryDnsAddressWidget;
+        HbWidget *mIpv6DnsAddressAutomaticWidget;
+        HbWidget *mIpv6PrimaryDnsAddressWidget;
+        HbWidget *mIpv6SecondaryDnsAddressWidget;
+        HbWidget *mProxyServerAddressWidget;
+        HbWidget *mProxyPortNumberWidget;
         
         // Test data
         HbAutoTestMainWindow *mMainWindow;
+        QPluginLoader *mPluginLoader;
         CpBearerApPluginInterface *mPlugin;
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cppluginutils/cppluginutils.pri	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Project info include file for Control Panel plugin utilities.
+#
+
+# Sources
+HEADERS += $$PWD/inc/cpipv4filter.h \
+           $$PWD/inc/cpipv6filter.h
+SOURCES += $$PWD/src/cpipv4filter.cpp \
+           $$PWD/src/cpipv6filter.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cppluginutils/inc/cpipv4filter.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 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""
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* IPv4 input filter header file.
+*
+*/
+
+#ifndef CPIPV4FILTER_H
+#define CPIPV4FILTER_H
+
+// System includes
+#include <HbInputFilter>
+
+// User includes
+
+// Forward declarations
+
+// External data types
+
+// Constants
+
+// Class declaration
+class CpIpv4Filter : public HbInputFilter
+{
+public:
+    static CpIpv4Filter* instance();
+    virtual ~CpIpv4Filter();
+    virtual bool filter(QChar aChar);
+
+signals:
+
+public slots:
+
+protected:
+
+protected slots:
+
+private:
+    Q_DISABLE_COPY(CpIpv4Filter)
+
+    CpIpv4Filter();
+
+private slots:
+    
+private: // data
+};
+
+#endif // CPIPV4FILTER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cppluginutils/inc/cpipv6filter.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 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""
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* IPv6 input filter header file.
+*
+*/
+
+#ifndef CPIPV6FILTER_H
+#define CPIPV6FILTER_H
+
+// System includes
+#include <HbInputFilter>
+
+// User includes
+
+// Forward declarations
+
+// External data types
+
+// Constants
+
+// Class declaration
+class CpIpv6Filter : public HbInputFilter
+{
+public:
+    static CpIpv6Filter* instance();
+    virtual ~CpIpv6Filter();
+    virtual bool filter(QChar aChar);
+
+signals:
+
+public slots:
+
+protected:
+
+protected slots:
+
+private:
+    Q_DISABLE_COPY(CpIpv6Filter)
+
+    CpIpv6Filter();
+
+private slots:
+    
+private: // data
+};
+
+#endif // CPIPV6FILTER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cppluginutils/src/cpipv4filter.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 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""
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* IPv4 input filter implementation.
+*
+*/
+
+// System includes
+#include <HbInputFilter>
+
+// User includes
+#include "cpipv4filter.h"
+
+/*!
+    \class CpIpv4Filter
+    \brief IPv4 input filter implementation.
+*/
+
+// External function prototypes
+
+// Local constants
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+/*!
+    Returns static instance of the class.
+*/
+CpIpv4Filter* CpIpv4Filter::instance()
+{
+    static CpIpv4Filter myInstance;
+    return &myInstance;
+}
+
+/*!
+    Constructor.
+*/
+CpIpv4Filter::CpIpv4Filter()
+{
+}
+
+/*!
+    Destructor.
+*/
+CpIpv4Filter::~CpIpv4Filter()
+{
+}
+
+/*!
+    Returns true if given character is valid for an IPv4 address.
+*/
+bool CpIpv4Filter::filter(QChar aChar)
+{
+    if (aChar >= '0' && aChar <= '9') {
+        return true;
+    }
+    if (aChar == '.') {
+        return true;
+    }
+
+    return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cppluginutils/src/cpipv6filter.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 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""
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* IPv6 input filter implementation.
+*
+*/
+
+// System includes
+#include <HbInputFilter>
+
+// User includes
+#include "cpipv6filter.h"
+
+/*!
+    \class CpIpv6Filter
+    \brief IPv6 input filter implementation.
+*/
+
+// External function prototypes
+
+// Local constants
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+/*!
+    Returns static instance of the class.
+*/
+CpIpv6Filter* CpIpv6Filter::instance()
+{
+    static CpIpv6Filter myInstance;
+    return &myInstance;
+}
+
+/*!
+    Constructor.
+*/
+CpIpv6Filter::CpIpv6Filter()
+{
+}
+
+/*!
+    Destructor.
+*/
+CpIpv6Filter::~CpIpv6Filter()
+{
+}
+
+/*!
+    Returns true if given character is valid for an IPv6 address.
+*/
+bool CpIpv6Filter::filter(QChar aChar)
+{
+    if ((aChar >= 'a' && aChar <= 'f')
+        || (aChar >= 'A' && aChar <= 'F')
+        || (aChar >= '0' && aChar <= '9')) {
+        return true;
+    }
+    if (aChar == ':' || aChar == '.') {
+        return true;
+    }
+
+    return false;
+}
--- a/cmmanager/cpwlanapplugin/cpwlanapplugin.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/cpwlanapplugin.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -20,6 +20,12 @@
 DEPENDPATH += .
 INCLUDEPATH += .
 
+# Temporary solution to fix tracecompiler
+# When tracecompiler is fixed, this can be removed
+symbian: {
+    MMP_RULES += "USERINCLUDE traces"
+}
+
 CONFIG += hb plugin
 
 MOC_DIR = moc
@@ -37,6 +43,9 @@
            src/cpwlanapview.cpp \
            src/cpwlanapadvancedview.cpp
 
+# Include plugin utilities
+include(../cppluginutils/cppluginutils.pri)
+
 symbian:
 {
 TARGET.EPOCALLOWDLLDATA = 1
--- a/cmmanager/cpwlanapplugin/inc/cpwlanapadvancedview.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/inc/cpwlanapadvancedview.h	Thu Jul 22 16:37:38 2010 +0100
@@ -20,13 +20,18 @@
 #define CPWLANAPADVANCEDVIEW_H
 
 // System includes
+#include <QAbstractSocket>
+#include <HbMessageBox>
 #include <cpbasesettingview.h>
+#include <cmmanagerdefines_shim.h>
 
 // User includes
 
 // Forward declarations
 class HbDataForm;
 class HbDataFormModel;
+class HbDataFormModelItem;
+class HbValidator;
 class CmConnectionMethodShim;
 
 // External data types
@@ -53,10 +58,52 @@
 protected slots:
  
 private:
+    Q_DISABLE_COPY(CpWlanApAdvancedView)
+   
+    //! IPv6 DNS type
+    enum Ipv6DnsType {
+        Ipv6DnsTypeAutomatic = 0,
+        Ipv6DnsTypeWellKnown,
+        Ipv6DnsTypeUserDefined
+    };
+
     void createAdvancedSettings();
+    void createIpv4Group();
+    void updateIpv4Group();
+    void createIpv6Group();
+    void updateIpv6Group();
+    void createProxyGroup();
+    void updateProxyGroup();
+    QString getIpAddress(CMManagerShim::ConnectionMethodAttribute attribute);
+    Ipv6DnsType getIpv6DnsType();
+    void enableIpv4AddressFields(int state);
+    void enableIpv4DnsFields(int state);
+    void enableIpv6DnsFields(int selectionIndex);
+    bool validateAndSaveIpAddress(
+        HbDataFormModelItem *item,
+        CMManagerShim::ConnectionMethodAttribute attribute,
+        QAbstractSocket::NetworkLayerProtocol protocol);
+    void showMessageBox(
+        HbMessageBox::MessageBoxType type,
+        const QString &text);
+    bool tryUpdate();
+    void handleUpdateError();
     
 private slots:
-    
+    void setEditorPreferences(const QModelIndex index);
+    void changeIpv4AddressMode(int state);
+    void changeIpv4Address();
+    void changeIpv4SubnetMask();
+    void changeIpv4Gateway();
+    void changeIpv4DnsMode(int state);
+    void changeIpv4PrimaryDnsAddress();
+    void changeIpv4SecondaryDnsAddress();
+    void changeIpv6DnsMode(int selectionIndex);
+    void changeIpv6PrimaryDnsAddress();
+    void changeIpv6SecondaryDnsAddress();
+    void changeProxyServer();
+    void changeProxyPort();
+
 private: // data
     //! Dataform
     HbDataForm *mForm;
@@ -64,6 +111,43 @@
     HbDataFormModel *mModel;
     //! Connection Settings Shim connection method pointer
     CmConnectionMethodShim *mCmConnectionMethod;
+    //! "IPv4 settings" group
+    HbDataFormModelItem *mIpv4Group;
+    //! "Automatic" setting item for phone IP address
+    HbDataFormModelItem *mIpv4Automatic;
+    //! "Phone IP address" setting item
+    HbDataFormModelItem *mIpv4Address;
+    //! "Subnet mask" setting item
+    HbDataFormModelItem *mIpv4SubnetMask;
+    //! "Default gateway" setting item
+    HbDataFormModelItem *mIpv4Gateway;
+    //! "Automatic" setting item for IPv4 DNS addresses
+    HbDataFormModelItem *mIpv4DnsAutomatic;
+    //! "Primary name server" setting item
+    HbDataFormModelItem *mIpv4DnsAddress1;
+    //! "Secondary name server" setting item
+    HbDataFormModelItem *mIpv4DnsAddress2;
+    //! "IPv6 settings" group
+    HbDataFormModelItem *mIpv6Group;
+    //! "Automatic" setting item for IPv6 DNS addresses
+    HbDataFormModelItem *mIpv6DnsAutomatic;
+    //! "Primary name server" setting item
+    HbDataFormModelItem *mIpv6DnsAddress1;
+    //! "Secondary name server" setting item
+    HbDataFormModelItem *mIpv6DnsAddress2;
+    //! "Proxy settings" group
+    HbDataFormModelItem *mProxyGroup;
+    //! "Proxy server address" setting item
+    HbDataFormModelItem *mProxyServer;
+    //! "Proxy port number" setting item
+    HbDataFormModelItem *mProxyPort;
+    //! Message box for info notes
+    QSharedPointer<HbMessageBox> mMessageBox;
+    //! Flag for IPv6 support
+    bool mIpv6Supported;
+    
+    // Friend classes
+    friend class TestCpWlanApPlugin;
 };
 
 #endif // CPWLANAPADVANCEDVIEW_H
--- a/cmmanager/cpwlanapplugin/inc/cpwlanapplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/inc/cpwlanapplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -21,12 +21,13 @@
 
 // System includes
 #include <QObject>
+#include <QSharedPointer>
 #include <cpbearerapplugininterface.h>
 
 // User includes
 
 // Forward declarations
-class QTranslator;
+class HbTranslator;
 class CmManagerShim;
 class CmConnectionMethodShim;
 
@@ -56,12 +57,13 @@
 protected slots:
 
 private:
+    Q_DISABLE_COPY(CpWlanApPlugin)
 
 private slots:
     
 private: // data
     //! Translator instance
-    QTranslator *mTranslator;
+    QSharedPointer<HbTranslator> mTranslator;
     //! CM Manager Shim instance
     CmManagerShim *mCmManager;
     //! CM Connection Method Shim instance
--- a/cmmanager/cpwlanapplugin/inc/cpwlanapview.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/inc/cpwlanapview.h	Thu Jul 22 16:37:38 2010 +0100
@@ -24,6 +24,7 @@
 #include <QMap>
 #include <HbMessageBox>
 #include <cpbasesettingview.h>
+#include <cmconnectionmethod_shim.h>
 
 // User includes
 
@@ -60,21 +61,29 @@
 protected slots:
  
 private:
+    Q_DISABLE_COPY(CpWlanApView)
+
     void createAccessPointSettingsGroup();
     void updateAccessPointSettingsGroup();
-    void loadSecurityPlugins();
+    void loadSecurityPlugins(
+        CMManagerShim::WlanConnMode networkMode);
     void updateSecurityGroup(int index);
     void showMessageBox(
         HbMessageBox::MessageBoxType type,
         const QString &text);
     bool tryUpdate();
     void handleUpdateError();
-       
+    void updateAdHocChannelItem(
+        CMManagerShim::WlanConnMode networkMode);
+    void updateSecurityModeItem(
+        CMManagerShim::WlanConnMode networkMode);
+    
 private slots:
     void connectionNameChanged();
     void wlanNetworkNameChanged();
     void networkStatusChanged(int index);
     void networkModeChanged(int index);
+    void adHocChannelChanged(int index);
     void securityModeChanged(int index);
     void homepageChanged();
     void menuActionTriggered(HbAction *action);
@@ -82,6 +91,10 @@
     void setEditorPreferences(const QModelIndex modelIndex);
     
 private: // data
+    // WLAN ad-hoc channel minimum and maximum values 
+    static const uint WlanAdHocChannelMinValue = 1;
+    static const uint WlanAdHocChannelMaxValue = 11;
+    
     //! Dataform
     HbDataForm *mForm;
     //! Dataform model
@@ -98,6 +111,8 @@
     HbDataFormModelItem *mNetworkStatusItem;
     //! "Network mode" setting item
     HbDataFormModelItem *mNetworkModeItem;
+    //! "Ad-hoc channel" setting item
+    HbDataFormModelItem *mAdHocChannelItem;
     //! "Security mode" setting item
     HbDataFormModelItem *mSecurityModeItem;
     //! "Homepage" setting item
--- a/cmmanager/cpwlanapplugin/src/cpwlanapadvancedview.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/src/cpwlanapadvancedview.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -11,20 +11,36 @@
 *
 * Contributors:
 *
-* Description:
+* Description:  
 * Control Panel WLAN AP advanced settings view implementation.
 *
 */
 
 // System includes
+#include <QHostAddress>
+#include <HbCheckBox>
+#include <HbLineEdit>
+#include <HbDataFormViewItem>
+#include <HbWidget>
+#include <HbEditorInterface>
+#include <HbUrlFilter>
+#include <HbInputDialog>
 #include <HbDataForm>
 #include <HbDataFormModel>
 #include <cmconnectionmethod_shim.h>
+#include <cmmanagerdefines_shim.h>
 #include <cpsettingformitemdata.h>
 
 // User includes
+#include "cpipv4filter.h"
+#include "cpipv6filter.h"
 #include "cpwlanapadvancedview.h"
 
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cpwlanapadvancedviewTraces.h"
+#endif
+
 /*!
     \class CpWlanApAdvancedView
     \brief This class implements the WLAN AP Control Panel advanced
@@ -48,16 +64,40 @@
         CpBaseSettingView(0, parent),
         mForm(0),
         mModel(0),
-        mCmConnectionMethod(cmConnectionMethod)
+        mCmConnectionMethod(cmConnectionMethod),
+        mIpv4Group(0),
+        mIpv4Automatic(0),
+        mIpv4Address(0),
+        mIpv4SubnetMask(0),
+        mIpv4Gateway(0),
+        mIpv4DnsAutomatic(0),
+        mIpv4DnsAddress1(0),
+        mIpv4DnsAddress2(0),
+        mIpv6Group(0),
+        mIpv6DnsAutomatic(0),
+        mIpv6DnsAddress1(0),
+        mIpv6DnsAddress2(0),
+        mProxyGroup(0),
+        mProxyServer(0),
+        mProxyPort(0),
+        mMessageBox(0),
+        mIpv6Supported(false)
 {
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CPWLANAPADVANCEDVIEW_ENTRY);
+    
     // Construct WLAN AP advanced settings UI
     mForm = new HbDataForm();
     this->setWidget(mForm);
     mModel = new HbDataFormModel(mForm);
     mForm->setModel(mModel);
 
+    mIpv6Supported = mCmConnectionMethod->getBoolAttribute(
+        CMManagerShim::CmIPv6Supported);
+        
     // Add advanced settings groups
     createAdvancedSettings();
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CPWLANAPADVANCEDVIEW_EXIT);
 }
 
 /*!
@@ -65,6 +105,9 @@
 */
 CpWlanApAdvancedView::~CpWlanApAdvancedView()
 {
+    OstTraceFunctionEntry0(DUP1_CPWLANAPADVANCEDVIEW_CPWLANAPADVANCEDVIEW_ENTRY);
+    
+    OstTraceFunctionExit0(DUP1_CPWLANAPADVANCEDVIEW_CPWLANAPADVANCEDVIEW_EXIT);
 }
 
 /*!
@@ -72,5 +115,973 @@
 */
 void CpWlanApAdvancedView::createAdvancedSettings()
 {
-    // TODO: Implement the advanced settings view.
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CREATEADVANCEDSETTINGS_ENTRY);
+    
+    // Create settings groups
+    createIpv4Group();
+    if (mIpv6Supported) {
+        createIpv6Group();
+    }
+    createProxyGroup();
+    
+    // Read values and update UI
+    updateIpv4Group();
+    if (mIpv6Supported) {
+        updateIpv6Group();
+    }
+    updateProxyGroup();
+    
+    // Connect signal to initialize settings item widgets
+    bool status = connect(
+        mForm,
+        SIGNAL(itemShown(const QModelIndex)),
+        this,
+        SLOT(setEditorPreferences(const QModelIndex)));
+    Q_ASSERT(status);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CREATEADVANCEDSETTINGS_EXIT);
+}
+
+/*!
+    Creates the IPv4 settings group.
+*/
+void CpWlanApAdvancedView::createIpv4Group()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CREATEIPV4GROUP_ENTRY);
+    
+    // IPv4 settings group
+    mIpv4Group = new CpSettingFormItemData(
+        HbDataFormModelItem::GroupItem,
+        hbTrId("txt_occ_subhead_ipv4_settings"));
+    mModel->appendDataFormItem(mIpv4Group);
+    
+    // Phone IP address
+    // "Automatic" checkbox
+    mIpv4Automatic = new CpSettingFormItemData(
+        HbDataFormModelItem::CheckBoxItem,
+        hbTrId("txt_occ_setlabel_phone_ip_address"));
+    mIpv4Automatic->setContentWidgetData(
+        "text",
+        hbTrId("txt_occ_setlabel_val_automatic"));
+    mForm->addConnection(
+        mIpv4Automatic,
+        SIGNAL(stateChanged(int)),
+        this,
+        SLOT(changeIpv4AddressMode(int)));
+    mIpv4Group->appendChild(mIpv4Automatic);
+    
+    // Phone IP address
+    mIpv4Address = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_phone_ip_address"));
+    mForm->addConnection(
+        mIpv4Address,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv4Address()));
+    mIpv4Group->appendChild(mIpv4Address);
+    
+    // Subnet mask
+    mIpv4SubnetMask = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_subnet_mask"));
+    mForm->addConnection(
+        mIpv4SubnetMask,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv4SubnetMask()));
+    mIpv4Group->appendChild(mIpv4SubnetMask);
+    
+    // Gateway
+    mIpv4Gateway = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_default_gateway"));
+    mForm->addConnection(
+        mIpv4Gateway,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv4Gateway()));
+    mIpv4Group->appendChild(mIpv4Gateway);
+    
+    // DNS addresses
+    // "Automatic" checkbox
+    mIpv4DnsAutomatic = new CpSettingFormItemData(
+        HbDataFormModelItem::CheckBoxItem,
+        hbTrId("txt_occ_setlabel_dns_addresses"));
+    mIpv4DnsAutomatic->setContentWidgetData(
+        "text",
+        hbTrId("txt_occ_setlabel_val_automatic"));
+    mForm->addConnection(
+        mIpv4DnsAutomatic,
+        SIGNAL(stateChanged(int)), 
+        this,
+        SLOT(changeIpv4DnsMode(int)));
+    mIpv4Group->appendChild(mIpv4DnsAutomatic);
+    
+    // Primary DNS address
+    mIpv4DnsAddress1 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_primary_name_server"));
+    mForm->addConnection(
+        mIpv4DnsAddress1,
+        SIGNAL(editingFinished()), 
+        this,
+        SLOT(changeIpv4PrimaryDnsAddress()));
+    mIpv4Group->appendChild(mIpv4DnsAddress1);
+    
+    // Secondary DNS address
+    mIpv4DnsAddress2 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_secondary_name_server"));
+    mForm->addConnection(
+        mIpv4DnsAddress2,
+        SIGNAL(editingFinished()), 
+        this,
+        SLOT(changeIpv4SecondaryDnsAddress()));
+    mIpv4Group->appendChild(mIpv4DnsAddress2);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CREATEIPV4GROUP_EXIT);
+}
+
+/*!
+    Reads attribute values and updates the IPv4 settings group.
+*/
+void CpWlanApAdvancedView::updateIpv4Group()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_UPDATEIPV4GROUP_ENTRY);
+    
+    // Phone IP address
+    // "Automatic" checkbox
+    bool ipAddressFromServer = mCmConnectionMethod->getBoolAttribute(
+        CMManagerShim::CmIPAddrFromServer);
+    Qt::CheckState state = Qt::Unchecked;
+    if (ipAddressFromServer) {
+        state = Qt::Checked;
+    }
+    mIpv4Automatic->setContentWidgetData("checkState", state);
+
+    // Enable/disable user defined IP address fields
+    enableIpv4AddressFields(state);
+    
+    // Phone IP address
+    QString string = getIpAddress(CMManagerShim::CmIPAddress);
+    mIpv4Address->setContentWidgetData("text", string);
+    
+    // Subnet mask
+    string = getIpAddress(CMManagerShim::CmIPNetmask);
+    mIpv4SubnetMask->setContentWidgetData("text", string);
+    
+    // Gateway
+    string = getIpAddress(CMManagerShim::CmIPGateway);
+    mIpv4Gateway->setContentWidgetData("text", string);
+    
+    // DNS addresses
+    // "Automatic" checkbox
+    state = Qt::Unchecked;
+    if (mCmConnectionMethod->getBoolAttribute(
+        CMManagerShim::CmIPDNSAddrFromServer)) {
+        state = Qt::Checked;
+    }
+    mIpv4DnsAutomatic->setContentWidgetData("checkState", state);
+
+    // Enable/disable user defined DNS address fields
+    enableIpv4DnsFields(state);
+    
+    // Primary DNS address
+    string = getIpAddress(CMManagerShim::CmIPNameServer1);
+    mIpv4DnsAddress1->setContentWidgetData("text", string);
+    
+    // Secondary DNS address
+    string = getIpAddress(CMManagerShim::CmIPNameServer2);
+    mIpv4DnsAddress2->setContentWidgetData("text", string);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_UPDATEIPV4GROUP_EXIT);
+}
+
+/*!
+    Creates the IPv6 settings group.
+*/
+void CpWlanApAdvancedView::createIpv6Group()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CREATEIPV6GROUP_ENTRY);
+    
+    // IPv6 settings group
+    mIpv6Group = new CpSettingFormItemData(
+        HbDataFormModelItem::GroupItem, 
+        hbTrId("txt_occ_subhead_ipv6_settings"));
+    mModel->appendDataFormItem(mIpv6Group);
+    
+    // DNS addresses
+    // Automatic/well-known/user defined combobox
+    mIpv6DnsAutomatic = new CpSettingFormItemData(
+        HbDataFormModelItem::ComboBoxItem,
+        hbTrId("txt_occ_setlabel_dns_addresses"));
+    QStringList dnsModeList;
+    // Order of the list must match the Ipv6DnsType enum
+    dnsModeList
+        << hbTrId("txt_occ_setlabel_val_automatic")
+        << hbTrId("txt_occ_setlabel_dns_addresses_val_wellknown")
+        << hbTrId("txt_occ_setlabel_dns_addresses_val_user_defined");
+    mIpv6DnsAutomatic->setContentWidgetData("items", dnsModeList);
+    mForm->addConnection(
+        mIpv6DnsAutomatic,
+        SIGNAL(currentIndexChanged(int)),
+        this,
+        SLOT(changeIpv6DnsMode(int)));
+    mIpv6Group->appendChild(mIpv6DnsAutomatic);
+    
+    // Primary DNS address
+    mIpv6DnsAddress1 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_primary_name_server"));
+    mForm->addConnection(
+        mIpv6DnsAddress1,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv6PrimaryDnsAddress()));
+    mIpv6Group->appendChild(mIpv6DnsAddress1);
+    
+    // Secondary DNS address
+    mIpv6DnsAddress2 = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_secondary_name_server"));
+    mForm->addConnection(
+        mIpv6DnsAddress2,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeIpv6SecondaryDnsAddress()));  
+    mIpv6Group->appendChild(mIpv6DnsAddress2);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CREATEIPV6GROUP_EXIT);
+}
+
+/*!
+    Reads attribute values and updates the IPv6 settings group.
+*/
+void CpWlanApAdvancedView::updateIpv6Group()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_UPDATEIPV6GROUP_ENTRY);
+    
+    // DNS addresses
+    // Automatic/well-known/user defined combobox
+    uint type = getIpv6DnsType();
+    mIpv6DnsAutomatic->setContentWidgetData("currentIndex", type);
+
+    // Enable/disable user defined DNS address fields
+    enableIpv6DnsFields(type);
+    
+    // Primary DNS address
+    QString string = getIpAddress(CMManagerShim::CmIP6NameServer1);
+    mIpv6DnsAddress1->setContentWidgetData("text", string);
+    
+    // Secondary DNS address
+    string = getIpAddress(CMManagerShim::CmIP6NameServer2);
+    mIpv6DnsAddress2->setContentWidgetData("text", string);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_UPDATEIPV6GROUP_EXIT);
+}
+
+/*!
+    Creates the proxy settings group.
+*/
+void CpWlanApAdvancedView::createProxyGroup()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CREATEPROXYGROUP_ENTRY);
+    
+    // Proxy settings group
+    mProxyGroup = new CpSettingFormItemData(
+        HbDataFormModelItem::GroupItem, 
+        hbTrId("txt_occ_subhead_proxy_settings"));
+    mModel->appendDataFormItem(mProxyGroup);
+    
+    // Proxy server address
+    mProxyServer = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_proxy_server_address"));
+    mForm->addConnection(
+        mProxyServer,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeProxyServer()));
+    mProxyGroup->appendChild(mProxyServer);
+    
+    // Proxy port number
+    mProxyPort = new CpSettingFormItemData(
+        HbDataFormModelItem::TextItem,
+        hbTrId("txt_occ_setlabel_proxy_port_number"));
+    mForm->addConnection(
+        mProxyPort,
+        SIGNAL(editingFinished()),
+        this,
+        SLOT(changeProxyPort()));
+    mProxyGroup->appendChild(mProxyPort);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CREATEPROXYGROUP_EXIT);
+}
+
+/*!
+    Reads attribute values and updates the proxy settings group.
+*/
+void CpWlanApAdvancedView::updateProxyGroup()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_UPDATEPROXYGROUP_ENTRY);
+    
+    // Proxy server address
+    QString serverAddress = mCmConnectionMethod->getStringAttribute(
+        CMManagerShim::CmProxyServerName);
+    mProxyServer->setContentWidgetData("text", serverAddress);
+    
+    // Proxy port number
+    uint portNumber = mCmConnectionMethod->getIntAttribute(
+        CMManagerShim::CmProxyPortNumber);
+    if (portNumber > 0) {
+        mProxyPort->setContentWidgetData("text", QVariant(portNumber));
+    } else {
+        mProxyPort->setContentWidgetData("text", "");
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_UPDATEPROXYGROUP_EXIT);
+}
+
+/*!
+    Reads an IP address from CommsDat with given attribute. If string is
+    empty, a zero address (0.0.0.0 or 0:0:0:0:0:0:0:0) is returned.
+*/
+QString CpWlanApAdvancedView::getIpAddress(
+    CMManagerShim::ConnectionMethodAttribute attribute)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_GETIPADDRESS_ENTRY);
+    
+    QString ipAddress = mCmConnectionMethod->getStringAttribute(attribute);
+    
+    if (ipAddress.isEmpty()) {
+        // String is empty, return a zero address instead
+        switch (attribute) {
+        case CMManagerShim::CmIP6NameServer1:
+        case CMManagerShim::CmIP6NameServer2:
+            // IPv6 address
+            ipAddress = CMManagerShim::DynamicIpv6Address;
+            break;
+        default:
+            // IPv4 address
+            ipAddress = CMManagerShim::UnspecifiedIpv4Address; 
+            break;
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_GETIPADDRESS_EXIT);
+    return ipAddress;
+}
+
+/*!
+    Resolves IPv6 DNS address type.
+*/
+CpWlanApAdvancedView::Ipv6DnsType CpWlanApAdvancedView::getIpv6DnsType()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_GETIPV6DNSTYPE_ENTRY);
+    
+    // Read "DNS address from server" flag
+    bool dnsAddressFromServer = mCmConnectionMethod->getBoolAttribute(
+        CMManagerShim::CmIP6DNSAddrFromServer);
+    
+    // Read IPv6 DNS addresses from CommsDat
+    QString primaryAddress = mCmConnectionMethod->getStringAttribute(
+        CMManagerShim::CmIP6NameServer1);
+    QString secondaryAddress = mCmConnectionMethod->getStringAttribute(
+        CMManagerShim::CmIP6NameServer2);
+
+    // Resolve IPv6 DNS address type
+    Ipv6DnsType type = Ipv6DnsTypeUserDefined;
+    if (dnsAddressFromServer) {
+        // Automatic
+        type = Ipv6DnsTypeAutomatic;
+    } else if (primaryAddress.toLower() == CMManagerShim::KnownIpv6NameServer1
+        && secondaryAddress.toLower() == CMManagerShim::KnownIpv6NameServer2) {
+        // Well-known IPv6 DNS addresses
+        type = Ipv6DnsTypeWellKnown;
+    }
+
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_GETIPV6DNSTYPE_EXIT);
+    return type;
+}
+
+/*!
+    Sets IPv4 address field enabled/disabled.
+*/
+void CpWlanApAdvancedView::enableIpv4AddressFields(int state)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_ENABLEIPV4ADDRESSFIELDS_ENTRY);
+    
+    if (state == Qt::Checked) {
+        // Automatic, disable text field
+        mIpv4Address->setEnabled(false);
+        mIpv4SubnetMask->setEnabled(false);
+        mIpv4Gateway->setEnabled(false);
+    } else {
+        // Manual, enable text field
+        mIpv4Address->setEnabled(true);
+        mIpv4SubnetMask->setEnabled(true);
+        mIpv4Gateway->setEnabled(true);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_ENABLEIPV4ADDRESSFIELDS_EXIT);
+}
+
+/*!
+    Sets IPv4 DNS address fields enabled/disabled.
+*/
+void CpWlanApAdvancedView::enableIpv4DnsFields(int state)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_ENABLEIPV4DNSFIELDS_ENTRY);
+    
+    if (state == Qt::Checked) {
+        // Automatic, disable text fields
+        mIpv4DnsAddress1->setEnabled(false);
+        mIpv4DnsAddress2->setEnabled(false);
+    } else {
+        // Manual, enable text fields
+        mIpv4DnsAddress1->setEnabled(true);
+        mIpv4DnsAddress2->setEnabled(true);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_ENABLEIPV4DNSFIELDS_EXIT);
+}
+
+/*!
+    Sets IPv6 DNS address fields enabled/disabled.
+*/
+void CpWlanApAdvancedView::enableIpv6DnsFields(int selectionIndex)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_ENABLEIPV6DNSFIELDS_ENTRY);
+    
+    // Check combobox value
+    if (selectionIndex == Ipv6DnsTypeUserDefined) {
+        // User-defined, enable text fields
+        mIpv6DnsAddress1->setEnabled(true);
+        mIpv6DnsAddress2->setEnabled(true);
+    } else {
+        // Automatic or well-known, disable text fields
+        mIpv6DnsAddress1->setEnabled(false);
+        mIpv6DnsAddress2->setEnabled(false);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_ENABLEIPV6DNSFIELDS_EXIT);
 }
+
+/*!
+    Validates an IP address and saves it to CommsDat in case it was a valid
+    address or an empty string. In case the address is not valid, an error
+    note is shown to the user and previous setting is restored to the UI.
+*/
+bool CpWlanApAdvancedView::validateAndSaveIpAddress(
+    HbDataFormModelItem *item,
+    CMManagerShim::ConnectionMethodAttribute attribute,
+    QAbstractSocket::NetworkLayerProtocol protocol)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_VALIDATEANDSAVEIPADDRESS_ENTRY);
+    
+    bool success = false;
+    
+    // Check address
+    QString address = item->contentWidgetData("text").toString();
+    QHostAddress hostAddress;
+    if (hostAddress.setAddress(address)
+        && hostAddress.protocol() == protocol) {
+        // Proper address, convert to lower case (IPv6)
+        address = hostAddress.toString().toLower();
+    } else if (address.isEmpty()) {
+        // Empty string, replace with 0.0.0.0 or 0:0:0:0:0:0:0:0
+        if (protocol == QAbstractSocket::IPv4Protocol) {
+            address = CMManagerShim::UnspecifiedIpv4Address;
+        } else {
+            address = CMManagerShim::DynamicIpv6Address;
+        }
+    } else {
+        // Invalid address
+        address.clear();
+    }
+
+    if (!address.isEmpty()) {
+        // Save to CommsDat
+        mCmConnectionMethod->setStringAttribute(attribute, address);
+        if (tryUpdate()) {
+            success = true;
+            item->setContentWidgetData("text", address);
+        }
+    } else {
+        // Inform user of invalid name
+        showMessageBox(
+            HbMessageBox::MessageTypeInformation,
+            hbTrId("txt_occ_info_invalid_input"));
+        // Restore previous setting
+        address = getIpAddress(attribute);
+        item->setContentWidgetData("text", address);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_VALIDATEANDSAVEIPADDRESS_EXIT);
+    return success;
+}
+
+/*!
+    Shows message box with "OK" button using given text.
+*/
+void CpWlanApAdvancedView::showMessageBox(
+    HbMessageBox::MessageBoxType type,
+    const QString &text)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_SHOWMESSAGEBOX_ENTRY);
+    
+    // Create a message box
+    mMessageBox = QSharedPointer<HbMessageBox>(new HbMessageBox(type));
+    mMessageBox->setText(text);
+    mMessageBox->setModal(true);
+    mMessageBox->setTimeout(HbPopup::NoTimeout);
+    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+    mMessageBox->open();
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_SHOWMESSAGEBOX_EXIT);
+}
+
+/*!
+    Tries to update connection method changes to CommsDat.
+    Returns "true" if success, "false" if some error happened. 
+*/
+bool CpWlanApAdvancedView::tryUpdate()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_TRYUPDATE_ENTRY);
+    
+    // Try update
+    bool success = true;
+    try {
+        mCmConnectionMethod->update();
+    }
+    catch (const std::exception&) {
+        // Handle error
+        handleUpdateError();
+        
+        success = false;
+    }
+
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_TRYUPDATE_EXIT);
+    return success;
+}
+
+/*!
+    Handles failed CommsDat update.
+ */
+void CpWlanApAdvancedView::handleUpdateError()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_HANDLEUPDATEERROR_ENTRY);
+    
+    // Show error note to user
+    showMessageBox(
+        HbMessageBox::MessageTypeWarning,
+        hbTrId("txt_occ_info_unable_to_save_setting"));
+    // Reload settings from CommsDat and update UI
+    try {
+        mCmConnectionMethod->refresh();
+    }
+    catch (const std::exception&) {
+        // Ignore error from refresh. Most likely this will not happen, but
+        // if it does, there isn't very much we can do.
+        OstTrace0(
+            TRACE_ERROR,
+            CPWLANAPPADVANCEDVIEW_HANDLEUPDATEERROR,
+            "Refresh failed");
+    };
+    updateIpv4Group();
+    if (mIpv6Supported) {
+        updateIpv6Group();
+    }
+    updateProxyGroup();
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_HANDLEUPDATEERROR_EXIT);
+}
+
+/*!
+    Initializes all settings groups.
+*/
+void CpWlanApAdvancedView::setEditorPreferences(const QModelIndex index)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_SETEDITORPREFERENCES_ENTRY);
+    
+    HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *>
+        (mForm->itemByIndex(index));
+    HbDataFormModelItem *modelItem = mModel->itemFromIndex(index);
+
+    if (modelItem == mIpv4Address
+        || modelItem == mIpv4SubnetMask
+        || modelItem == mIpv4Gateway
+        || modelItem == mIpv4DnsAddress1
+        || modelItem == mIpv4DnsAddress2
+        || modelItem == mIpv6DnsAddress1
+        || modelItem == mIpv6DnsAddress2
+        || modelItem == mProxyServer
+        || modelItem == mProxyPort) {
+        // HbLineEdit items, get editor and editor interface
+        HbLineEdit *edit = qobject_cast<HbLineEdit *>
+            (viewItem->dataItemContentWidget());
+        HbEditorInterface editorInterface(edit);
+
+        if (modelItem == mIpv4Address
+            || modelItem == mIpv4SubnetMask
+            || modelItem == mIpv4Gateway
+            || modelItem == mIpv4DnsAddress1
+            || modelItem == mIpv4DnsAddress2) {
+            // IPv4 IP address
+            editorInterface.setMode(HbInputModeNumeric);
+            editorInterface.setFilter(CpIpv4Filter::instance());
+            edit->setMaxLength(CMManagerShim::CmIP4AddressLength);
+        } else if (modelItem == mIpv6DnsAddress1
+            || modelItem == mIpv6DnsAddress2) {
+            // IPv6 IP address
+            editorInterface.setInputConstraints(
+                HbEditorConstraintLatinAlphabetOnly);
+            editorInterface.setFilter(CpIpv6Filter::instance());
+            edit->setInputMethodHints(
+                Qt::ImhNoPredictiveText
+                | Qt::ImhPreferLowercase);
+            edit->setMaxLength(CMManagerShim::CmIP6NameServerLength);
+        } else if (modelItem == mProxyServer) {                
+            // Proxy server address
+            editorInterface.setMode(HbInputModeNone);
+            editorInterface.setInputConstraints(
+                HbEditorConstraintLatinAlphabetOnly);
+            editorInterface.setFilter(HbUrlFilter::instance());
+            editorInterface.setEditorClass(HbInputEditorClassUrl);
+            editorInterface.setDigitType(HbDigitTypeNone);
+            edit->setInputMethodHints(
+                Qt::ImhNoPredictiveText
+                | Qt::ImhPreferLowercase);
+            edit->setMaxLength(CMManagerShim::CmProxyServerNameLength);
+        } else { /* mProxyPort */                
+            // Proxy port number
+            editorInterface.setMode(HbInputModeNumeric);
+            edit->setInputMethodHints(Qt::ImhDigitsOnly);
+            edit->setMaxLength(CMManagerShim::CmProxyPortNumberLength);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_SETEDITORPREFERENCES_EXIT);
+}
+
+/*!
+    Handles change to IPv4 address mode (automatic/user defined).
+*/
+void CpWlanApAdvancedView::changeIpv4AddressMode(int state)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4ADDRESSMODE_ENTRY);
+    
+    bool ipv4AddressFromServer;
+    if (state == Qt::Checked) {
+        ipv4AddressFromServer = true;
+    } else {
+        ipv4AddressFromServer = false;
+    }
+    
+    if (!ipv4AddressFromServer
+        && getIpAddress(CMManagerShim::CmIPAddress) ==
+            CMManagerShim::UnspecifiedIpv4Address) {
+        // User defined IP address selected, but no valid address is stored.
+        // Just enable the UI IP editors, because CMManager will update the
+        // "IP address from server" flag by itself when a valid IP address
+        // is stored.
+        enableIpv4AddressFields(state);
+    } else {
+        // Save setting to CommsDat
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIPAddrFromServer,
+            ipv4AddressFromServer);
+        if (tryUpdate()) {
+            enableIpv4AddressFields(state);
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4ADDRESSMODE_EXIT);
+}
+
+/*!
+    Saves IPv4 address to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv4Address()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4ADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv4Address,
+        CMManagerShim::CmIPAddress,
+        QAbstractSocket::IPv4Protocol)) {
+        // In case the IP address is empty or 0.0.0.0, CMManager changes the
+        // "IP address from server" flag to true. We need to refresh the UI to
+        // make sure we are in sync.
+        updateIpv4Group();
+    }
+
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4ADDRESS_EXIT);
+}
+
+/*!
+    Saves IPv4 subnet mask to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv4SubnetMask()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4SUBNETMASK_ENTRY);
+    
+    (void)validateAndSaveIpAddress(
+        mIpv4SubnetMask,
+        CMManagerShim::CmIPNetmask,
+        QAbstractSocket::IPv4Protocol);
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4SUBNETMASK_EXIT);
+}
+
+/*!
+    Saves IPv4 gateway to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv4Gateway()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4GATEWAY_ENTRY);
+    
+    (void)validateAndSaveIpAddress(
+        mIpv4Gateway,
+        CMManagerShim::CmIPGateway,
+        QAbstractSocket::IPv4Protocol);
+
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4GATEWAY_EXIT);
+}
+
+/*!
+    Handles change to IPv4 DNS mode (automatic/user defined).
+*/
+void CpWlanApAdvancedView::changeIpv4DnsMode(int state)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4DNSMODE_ENTRY);
+    
+    bool dnsAddressFromServer;
+    if (state == Qt::Checked) {
+        dnsAddressFromServer = true;
+    } else {
+        dnsAddressFromServer = false;
+    }
+    // Save setting to CommsDat
+    mCmConnectionMethod->setBoolAttribute(
+        CMManagerShim::CmIPDNSAddrFromServer,
+        dnsAddressFromServer);
+    if (tryUpdate()) {
+        enableIpv4DnsFields(state);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4DNSMODE_EXIT);
+}
+
+/*!
+    Saves IPv4 primary DNS address to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv4PrimaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4PRIMARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv4DnsAddress1,
+        CMManagerShim::CmIPNameServer1,
+        QAbstractSocket::IPv4Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIPDNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0.0.0.0, CMManager will
+            // check secondary DNS address and in case it is a valid address,
+            // move it to the primary DNS address. We need to refresh the
+            // UI to make sure we are in sync. If tryUpdate() fails it does
+            // the refresh automatically, so only success case is handled
+            // here.
+            updateIpv4Group();            
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4PRIMARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Saves IPv4 secondary DNS address to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv4SecondaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV4SECONDARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv4DnsAddress2,
+        CMManagerShim::CmIPNameServer2,
+        QAbstractSocket::IPv4Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIPDNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0.0.0.0, CMManager will
+            // write the address there instead of secondary DNS address, so we
+            // need to refresh the UI to make sure we are in sync. If
+            // tryUpdate() fails it does the refresh automatically, so only
+            // success case is handled here.
+            updateIpv4Group();
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV4SECONDARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Handles change to IPv6 DNS mode (automatic/well-known/user defined).
+*/
+void CpWlanApAdvancedView::changeIpv6DnsMode(int state)
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV6DNSMODE_ENTRY);
+    
+    // Update "DNS address from server" flag
+    if (state == Ipv6DnsTypeAutomatic) {
+        // Automatic
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            true);
+    } else {
+        // User defined or well-known address
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            false);
+        
+        if (state == Ipv6DnsTypeWellKnown) {
+            // Well-known address, set DNS addresses and update UI
+            mCmConnectionMethod->setStringAttribute(
+                CMManagerShim::CmIP6NameServer1,
+                CMManagerShim::KnownIpv6NameServer1);
+            mIpv6DnsAddress1->setContentWidgetData(
+                "text",
+                CMManagerShim::KnownIpv6NameServer1);
+            mCmConnectionMethod->setStringAttribute(
+                CMManagerShim::CmIP6NameServer2,
+                CMManagerShim::KnownIpv6NameServer2);
+            mIpv6DnsAddress2->setContentWidgetData(
+                "text",
+                CMManagerShim::KnownIpv6NameServer2);        
+        }
+    }
+
+    if (tryUpdate()) {
+        enableIpv6DnsFields(state);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV6DNSMODE_EXIT);
+}
+
+/*!
+    Saves IPv6 primary DNS address to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv6PrimaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV6PRIMARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv6DnsAddress1,
+        CMManagerShim::CmIP6NameServer1,
+        QAbstractSocket::IPv6Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0:0:0:0:0:0:0:0,
+            // CMManager will check secondary DNS address and in case it is a
+            // valid address, move it to the primary DNS address. We need to
+            // refresh the UI to make sure we are in sync. If tryUpdate()
+            // fails it does the refresh automatically, so only success case
+            // is handled here.
+            updateIpv6Group();            
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV6PRIMARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Saves IPv6 secondary DNS address to CommsDat.
+*/
+void CpWlanApAdvancedView::changeIpv6SecondaryDnsAddress()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEIPV6SECONDARYDNSADDRESS_ENTRY);
+    
+    if (validateAndSaveIpAddress(
+        mIpv6DnsAddress2,
+        CMManagerShim::CmIP6NameServer2,
+        QAbstractSocket::IPv6Protocol)) {
+        // Address saved successfully, update "DNS address from server" flag
+        mCmConnectionMethod->setBoolAttribute(
+            CMManagerShim::CmIP6DNSAddrFromServer,
+            false);
+        if (tryUpdate()) {
+            // In case primary DNS address is empty or 0:0:0:0:0:0:0:0,
+            // CMManager will write the address there instead of secondary DNS
+            // address, so we need to refresh the UI to make sure we are in
+            // sync. If tryUpdate() fails it does the refresh automatically,
+            // so only success case is handled here.
+            updateIpv6Group();
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEIPV6SECONDARYDNSADDRESS_EXIT);
+}
+
+/*!
+    Saves proxy server address to CommsDat.
+*/
+void CpWlanApAdvancedView::changeProxyServer()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEPROXYSERVER_ENTRY);
+    
+    QString proxyServer = mProxyServer->contentWidgetData("text").toString();
+    mCmConnectionMethod->setStringAttribute(
+        CMManagerShim::CmProxyServerName,
+        proxyServer);
+    if (tryUpdate()) {
+        // If proxy server name is empty, CMManager will also clear the
+        // proxy port. Therefore UI needs to be updated.
+        updateProxyGroup();
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEPROXYSERVER_EXIT);
+}
+
+/*!
+    Saves proxy port to CommsDat.
+*/
+void CpWlanApAdvancedView::changeProxyPort()
+{
+    OstTraceFunctionEntry0(CPWLANAPADVANCEDVIEW_CHANGEPROXYPORT_ENTRY);
+    
+    uint proxyPort = mProxyPort->contentWidgetData("text").toInt();
+    if (proxyPort <= 65535) {
+        if (proxyPort == 0) {
+            // Don't show zero
+            mProxyPort->setContentWidgetData("text", "");
+        }
+        mCmConnectionMethod->setIntAttribute(
+            CMManagerShim::CmProxyPortNumber,
+            proxyPort);
+        (void)tryUpdate();
+    } else {
+        // Inform user of invalid value
+        showMessageBox(
+            HbMessageBox::MessageTypeInformation,
+            hbTrId("txt_occ_info_invalid_input"));
+        // Restore previous setting
+        proxyPort = mCmConnectionMethod->getIntAttribute(
+            CMManagerShim::CmProxyPortNumber);
+        if (proxyPort > 0) {
+            mProxyPort->setContentWidgetData("text", QVariant(proxyPort));
+        } else {
+            mProxyPort->setContentWidgetData("text", "");
+        }
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPADVANCEDVIEW_CHANGEPROXYPORT_EXIT);
+}
--- a/cmmanager/cpwlanapplugin/src/cpwlanapplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/src/cpwlanapplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,7 @@
 */
 
 // System includes
-#include <QtCore>
+#include <HbTranslator>
 #include <cmmanager_shim.h>
 #include <cmconnectionmethod_shim.h>
 
@@ -46,19 +46,12 @@
     Constructor.
 */
 CpWlanApPlugin::CpWlanApPlugin() :
-    mTranslator(0),
+    mTranslator(new HbTranslator("cpapplugin")),
     mCmManager(0),
     mCmConnectionMethod(0)
 {
     OstTraceFunctionEntry0(CPWLANAPPLUGIN_CPWLANAPPLUGIN_ENTRY);
 
-    // Install localization
-    QString lang = QLocale::system().name();
-    QString path = "z:/resource/qt/translations/";
-    mTranslator = new QTranslator(this);
-    mTranslator->load(path + "cpapplugin_" + lang);
-    qApp->installTranslator(mTranslator);
-    
     OstTraceFunctionExit0(CPWLANAPPLUGIN_CPWLANAPPLUGIN_EXIT);
 }
 
--- a/cmmanager/cpwlanapplugin/src/cpwlanapview.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/src/cpwlanapview.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -32,6 +32,7 @@
 #include <HbPopup>
 #include <HbMessageBox>
 #include <HbAction>
+#include <HbStringUtil>
 #include <wlanmgmtcommon.h>
 #include <cpitemdatahelper.h>
 #include <cpsettingformitemdata.h>
@@ -79,6 +80,7 @@
         mWlanNetworkNameItem(0),
         mNetworkStatusItem(0),
         mNetworkModeItem(0),
+        mAdHocChannelItem(0),
         mSecurityModeItem(0),
         mHomepageItem(0),
         mSecuritySettingsGroupItem(0),
@@ -221,28 +223,15 @@
         SLOT(networkModeChanged(int)));
     mApSettingsGroupItem->appendChild(mNetworkModeItem);
     
+    // Ad-hoc channel
+    // Added dynamically according to set network mode
+    
     // Security mode
     mSecurityModeItem = new CpSettingFormItemData(
         HbDataFormModelItem::ComboBoxItem,
         hbTrId("txt_occ_setlabel_wlan_security_mode"));
-    // Load WLAN security plugins and construct map
-    mSecurityModeMap.insert(0, NULL); // open mode
-    // Load all security plugins and construct map
-    loadSecurityPlugins();
-    // Add items to combobox
-    QStringList securityModeItems;
-    foreach (CpWlanSecurityPluginInterface *plugin, mSecurityModeMap) {
-        if (plugin) {
-            // Add security mode from plugin
-            securityModeItems
-                << hbTrId(plugin->securityModeTextId().toLatin1());
-        } else {
-            // Add open mode
-            securityModeItems
-                << hbTrId("txt_occ_setlabel_wlan_security_mode_val_open");
-        }
-    }
-    mSecurityModeItem->setContentWidgetData("items", securityModeItems);
+    // Security modes added dynamically according to set network mode
+
     // Connect signal and add item to group
     mForm->addConnection(
         mSecurityModeItem,
@@ -296,28 +285,19 @@
         mNetworkStatusMap.key(scanSsid));
     
     // Network mode
-    int networkMode =  mCmConnectionMethod->getIntAttribute(
-        CMManagerShim::WlanConnectionMode);
+    CMManagerShim::WlanConnMode networkMode =
+		static_cast<CMManagerShim::WlanConnMode>
+      	(mCmConnectionMethod->getIntAttribute(
+            CMManagerShim::WlanConnectionMode));
     mNetworkModeItem->setContentWidgetData(
         "currentIndex",
         mNetworkModeMap.key(networkMode));
     
+    // Ad-hoc channel
+    updateAdHocChannelItem(networkMode);
+    
     // Security mode
-    QVariant securityMode = mCmConnectionMethod->getIntAttribute(
-        CMManagerShim::WlanSecurityMode);
-    // Iterate through the map to find correct security plugin and set
-    // mode index
-    int securityModeIndex = 0;
-    QMapIterator<int, CpWlanSecurityPluginInterface *> i(mSecurityModeMap);
-    while (i.hasNext()) {
-        i.next();
-        if (i.value()
-            && i.value()->securityMode() == securityMode.toInt()) {
-            securityModeIndex = i.key();
-        }
-    }
-    mSecurityModeItem->setContentWidgetData("currentIndex",
-        securityModeIndex);
+    updateSecurityModeItem(networkMode);
     
     // Homepage
     QString homepage = mCmConnectionMethod->getStringAttribute(
@@ -330,7 +310,8 @@
 /*!
     Loads all WLAN security plugins.
 */
-void CpWlanApView::loadSecurityPlugins()
+void CpWlanApView::loadSecurityPlugins(
+    CMManagerShim::WlanConnMode networkMode)
 {
     OstTraceFunctionEntry0(CPWLANAPVIEW_LOADSECURITYPLUGINS_ENTRY);
     
@@ -357,12 +338,16 @@
         }
     }
     
-    // Add security plugins to map
+    // Add security plugins to map. If network mode is ad-hoc, only WEP
+    // is allowed.
     int i;
     i = mSecurityModeMap.size();
     foreach (CpWlanSecurityPluginInterface *plugin, plugins) {
-        mSecurityModeMap.insert(i, plugin);
-        i++;
+        if (networkMode != CMManagerShim::Adhoc
+            || plugin->securityMode() == CMManagerShim::WlanSecModeWep) {
+            mSecurityModeMap.insert(i, plugin);
+            i++;
+        }
     }
     
     OstTraceFunctionExit0(CPWLANAPVIEW_LOADSECURITYPLUGINS_EXIT);
@@ -473,6 +458,132 @@
 }
 
 /*!
+    Updates Ad-hoc channel item. Setting item is shown if network mode is
+    ad-hoc, otherwise it is not shown.
+ */
+void CpWlanApView::updateAdHocChannelItem(
+    CMManagerShim::WlanConnMode networkMode)
+{
+    if (networkMode == CMManagerShim::Infra) {
+        // Infrastructure
+        if (mAdHocChannelItem) {
+            mApSettingsGroupItem->removeChild(
+                mApSettingsGroupItem->indexOf(mAdHocChannelItem));
+            mAdHocChannelItem = NULL;
+        }
+    } else {
+        // Ad-hoc
+        if (!mAdHocChannelItem) {
+            // Ad-hoc channel item not shown, add it
+            mAdHocChannelItem = new CpSettingFormItemData(
+                HbDataFormModelItem::ComboBoxItem,
+                hbTrId("txt_occ_setlabel_adhoc_channel"));
+            // Add items to combobox
+            QStringList adHocChannelItems;
+            adHocChannelItems
+                << hbTrId("txt_occ_setlabel_adhoc_channel_val_automatic");
+            for (int i = WlanAdHocChannelMinValue;
+                i <= WlanAdHocChannelMaxValue;
+                i++) {
+                QString channel;
+                channel.setNum(i);
+                adHocChannelItems << HbStringUtil::convertDigits(channel);
+            }
+            mAdHocChannelItem->setContentWidgetData(
+                "items",
+                adHocChannelItems);
+            // Connect signal and add item to group
+            mForm->addConnection(
+                mAdHocChannelItem,
+                SIGNAL(currentIndexChanged(int)),
+                this,
+                SLOT(adHocChannelChanged(int)));
+            // Add item after the network mode item
+            mApSettingsGroupItem->insertChild(
+                mApSettingsGroupItem->indexOf(mNetworkModeItem) + 1,
+                mAdHocChannelItem);
+        }
+        // Update ad-hoc item
+        int adHocChannelId = mCmConnectionMethod->getIntAttribute(
+            CMManagerShim::WlanChannelID);
+        mAdHocChannelItem->setContentWidgetData(
+            "currentIndex",
+            adHocChannelId);
+    }
+}
+
+/*!
+    Updates security mode item.
+ */
+void CpWlanApView::updateSecurityModeItem(
+    CMManagerShim::WlanConnMode networkMode)
+{
+    // Load WLAN security plugins and construct map
+    mSecurityModeMap.clear();
+    mSecurityModeMap.insert(0, NULL); // open mode
+    loadSecurityPlugins(networkMode);
+    
+    // Add items to combobox
+    QStringList securityModeItems;
+    foreach (CpWlanSecurityPluginInterface *plugin, mSecurityModeMap) {
+        if (plugin) {
+            // Add security mode from plugin
+            securityModeItems
+                << hbTrId(plugin->securityModeTextId().toLatin1());
+        } else {
+            // Add open mode
+            securityModeItems
+                << hbTrId("txt_occ_setlabel_wlan_security_mode_val_open");
+        }
+    }
+    // Remove connection before setting new content, because combobox
+    // will emit currentIndexChanged signal and we don't want that.
+    mForm->removeConnection(
+        mSecurityModeItem,
+        SIGNAL(currentIndexChanged(int)),
+        this,
+        SLOT(securityModeChanged(int)));
+    mSecurityModeItem->setContentWidgetData("items", securityModeItems);
+    mForm->addConnection(
+        mSecurityModeItem,
+        SIGNAL(currentIndexChanged(int)),
+        this,
+        SLOT(securityModeChanged(int)));
+    
+    uint securityMode = mCmConnectionMethod->getIntAttribute(
+        CMManagerShim::WlanSecurityMode);
+    // Iterate through the map to find correct security plugin and set
+    // mode index
+    int securityModeIndex = 0;
+    QMapIterator<int, CpWlanSecurityPluginInterface *> i(mSecurityModeMap);
+    while (i.hasNext()) {
+        i.next();
+        if (i.value()
+            && i.value()->securityMode() == securityMode) {
+            securityModeIndex = i.key();
+        }
+    }
+    mSecurityModeItem->setContentWidgetData("currentIndex",
+        securityModeIndex);
+    
+    if (securityMode != CMManagerShim::WlanSecModeOpen
+        && securityModeIndex == 0) {
+        // Security plugin implementing the selected security mode not found,
+        // set security mode to open also in CommsDat  
+        mCmConnectionMethod->setIntAttribute(
+            CMManagerShim::WlanSecurityMode,
+            CMManagerShim::WlanSecModeOpen);
+        // Try update
+        try {
+            mCmConnectionMethod->update();
+        }
+        catch (const std::exception&) {
+            // Error in update, but can't show error notes at this point
+        }
+    }
+}
+
+/*!
     Stores connection name.
 */
 void CpWlanApView::connectionNameChanged()
@@ -547,7 +658,8 @@
     OstTraceFunctionEntry0(CPWLANAPVIEW_NETWORKSTATUSCHANGED_ENTRY);
     
     // Update to CommsDat
-    mCmConnectionMethod->setBoolAttribute(CMManagerShim::WlanScanSSID,
+    mCmConnectionMethod->setBoolAttribute(
+        CMManagerShim::WlanScanSSID,
         mNetworkStatusMap.value(index));
     (void)tryUpdate();
     
@@ -562,11 +674,36 @@
     OstTraceFunctionEntry0(CPWLANAPVIEW_NETWORKMODECHANGED_ENTRY);
     
     // Update to CommsDat
-    mCmConnectionMethod->setIntAttribute(CMManagerShim::WlanConnectionMode,
+    mCmConnectionMethod->setIntAttribute(
+        CMManagerShim::WlanConnectionMode,
         mNetworkModeMap.value(index));
+    if (tryUpdate()) {
+        // If mode is ad-hoc, ad-hoc channel item must be shown
+        CMManagerShim::WlanConnMode networkMode =
+            static_cast<CMManagerShim::WlanConnMode>
+                (mNetworkModeMap.value(index));
+        updateAdHocChannelItem(networkMode);
+		// Also security mode list may need updating
+        updateSecurityModeItem(networkMode);
+    }
+    
+    OstTraceFunctionExit0(CPWLANAPVIEW_NETWORKMODECHANGED_EXIT);
+}
+
+/*!
+    Stores ad-hoc channel ID.
+*/
+void CpWlanApView::adHocChannelChanged(int index)
+{
+    OstTraceFunctionEntry0(CPWLANAPVIEW_ADHOCCHANNELCHANGED_ENTRY);
+    
+    // Update to CommsDat
+    mCmConnectionMethod->setIntAttribute(
+        CMManagerShim::WlanChannelID,
+        index);
     (void)tryUpdate();
     
-    OstTraceFunctionExit0(CPWLANAPVIEW_NETWORKMODECHANGED_EXIT);
+    OstTraceFunctionExit0(CPWLANAPVIEW_ADHOCCHANNELCHANGED_EXIT);
 }
 
 /*!
@@ -580,10 +717,12 @@
     CpWlanSecurityPluginInterface *plugin = mSecurityModeMap.value(index);
     // Update to CommsDat
     if (plugin) {
-        mCmConnectionMethod->setIntAttribute(CMManagerShim::WlanSecurityMode,
+        mCmConnectionMethod->setIntAttribute(
+            CMManagerShim::WlanSecurityMode,
             plugin->securityMode());
     } else {
-        mCmConnectionMethod->setIntAttribute(CMManagerShim::WlanSecurityMode,
+        mCmConnectionMethod->setIntAttribute(
+            CMManagerShim::WlanSecurityMode,
             CMManagerShim::WlanSecModeOpen);
     }
     (void)tryUpdate();
--- a/cmmanager/cpwlanapplugin/tsrc/ut/hbautotest.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/tsrc/ut/hbautotest.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -48,8 +48,7 @@
             Qt::NoButton, 
             Qt::NoModifier);
             QSpontaneKeyEvent::setSpontaneous(&me);
-            qApp->notify((window->viewport()), &me);
-            QCoreApplication::sendPostedEvents();
+            QCoreApplication::sendEvent(window->viewport(), &me);
             QTest::qWait(1);
     } else {
             HbAutoTestMouseEvent me (
@@ -60,8 +59,7 @@
             Qt::NoButton, 
             Qt::NoModifier);
             QSpontaneKeyEvent::setSpontaneous(&me);
-            qApp->notify((window->viewport()), &me);
-            QCoreApplication::sendPostedEvents();
+            QCoreApplication::sendEvent(window->viewport(), &me);
             QTest::qWait(1);
 
     }
@@ -94,9 +92,7 @@
     Qt::NoModifier);
 
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
-    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendEvent(window->viewport(), &me);
     QTest::qWait(1);
 }
 
@@ -123,8 +119,7 @@
     Qt::NoModifier);
 
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendEvent(window->viewport(), &me);
 
     QTest::qWait(1);
     QTest::qWait(1);
@@ -152,15 +147,12 @@
     Qt::LeftButton, 
     Qt::NoModifier);
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
-    //QTime currentTime = QTime::currentTime();
-    //qDebug() << currentTime.toString("hh:mm:ss.zzz") << ": Left button down";
-    QTest::qWait(1);
+    QCoreApplication::sendEvent(window->viewport(), &me);
 
     if (delay!=-1) {
         QTest::qWait(delay);
     }
+
     HbAutoTestMouseEvent me2 (
     QEvent::MouseButtonRelease, 
     targetPoint.toPoint(), 
@@ -170,10 +162,7 @@
     Qt::NoModifier);
 
     QSpontaneKeyEvent::setSpontaneous(&me2);
-    qApp->notify((window->viewport()), &me2);
-    QCoreApplication::sendPostedEvents();
-    //currentTime = QTime::currentTime();
-    //qDebug() << currentTime.toString("hh:mm:ss.zzz") << ": Left button up";
+    QCoreApplication::sendEvent(window->viewport(), &me2);
 
     QTest::qWait(1);
     QTest::qWait(1);
@@ -221,8 +210,8 @@
                             Qt::NoModifier);   
 
         QSpontaneKeyEvent::setSpontaneous(&me);
-        qApp->notify((window->viewport()), &me);
-        QCoreApplication::sendPostedEvents();
+        QCoreApplication::sendEvent(window->viewport(), &me);
+        QTest::qWait(1);
     }
 
     QCursor::setPos(window->mapToGlobal(targetPoint.toPoint()));
@@ -235,8 +224,7 @@
                             Qt::LeftButton, 
                             Qt::NoModifier);   
     QSpontaneKeyEvent::setSpontaneous(&me);
-    qApp->notify((window->viewport()), &me);
-    QCoreApplication::sendPostedEvents();
+    QCoreApplication::sendEvent(window->viewport(), &me);
 }
 
 
@@ -255,7 +243,7 @@
 
         HbAutoTestKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);
         QSpontaneKeyEvent::setSpontaneous(&a);
-        if (!qApp->notify(widget, &a))
+        if (!QCoreApplication::sendEvent(widget, &a))
             QTest::qWarn("Keyboard event not accepted by receiving widget");
     }
 
--- a/cmmanager/cpwlanapplugin/tsrc/ut/testcpwlanapplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/tsrc/ut/testcpwlanapplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,12 +24,16 @@
 #include <HbDataForm>
 #include <HbDataFormModel>
 #include <HbDataFormModelItem>
+#include <HbDataFormViewItem>
+#include <HbModelIterator>
+#include <QSharedPointer>
 #include <QtTest/QtTest>
 #include <cpbearerapplugininterface.h>
 #include <cmmanager_shim.h>
 #include <cmconnectionmethod_shim.h>
 
 #include "cpwlanapview.h"
+#include "cpwlanapadvancedview.h"
 
 #include "hbautotest.h"
 #include "testcpwlanapplugin.h"
@@ -55,33 +59,25 @@
 static const int waitTime = 10;
 
 // UI coordinates
-static const QPoint connectionNameLabel(175, 70);
-
-static const QPoint connectionNameLineEdit(330, 110);
-
-static const QPoint wlanNetworkNameLineEdit(330, 190);
-
-static const QPoint networkStatusComboBox(175, 270);
-static const QPoint networkStatusPublic(175, 325);
-static const QPoint networkStatusHidden(175, 375);
-
-static const QPoint networkModeComboBox(175, 365);
-static const QPoint networkModeIntrastructure(175, 415);
-static const QPoint networkModeAdHoc(175, 465);
+static const QPoint scrollMiddle(350, 280);
+static const QPoint scrollTop(350, 30);
+static const QPoint scrollBottom(350, 540);
 
-static const QPoint securityModeComboBox(175, 460);
-#ifndef WLAN_SECURITY_PLUGINS_AVAILABLE
-static const QPoint securityModeOpen(175, 510);
-#else
-static const QPoint securityModeOpen(175, 260);
-static const QPoint securityModeWep(175, 305);
-static const QPoint securityModeWpaWpa2(175, 355);
-static const QPoint securityModeWpa2(175, 405);
-#endif
+// Use positive offset if dropdown opens under the combobox
+static const QPoint comboBoxFirstItemOffset(80, 75);
+static const QPoint comboBoxItemOffset(0, 51);
+// Use negative offset if dropdown opens above the combobox
+static const QPoint comboBoxFirstItemNegativeOffset(80, -29);
+static const QPoint comboBoxItemNegativeOffset(0, -51);
 
-static const QPoint homepageLineEdit(330, 545);
+static const QPoint exitEditorOffset(-10, -20);
+
+static const QPoint messageBoxOkButtonOffset(160, 140);
 
-static const QPoint messageBoxOkButton(170, 320);
+// Advanced settings groups
+static const QPoint ipv4Group(160, 10);
+static const QPoint ipv6Group(160, 60);
+static const QPoint proxyGroup(160, 110);
 
 // -----------------------------------------------------------------------------
 // FRAMEWORK FUNCTIONS
@@ -121,8 +117,8 @@
     
     // Load plugin
     QDir dir(pluginDir);
-    QPluginLoader loader(dir.absoluteFilePath(pluginName));
-    mPlugin = qobject_cast<CpBearerApPluginInterface *>(loader.instance());
+    mPluginLoader = new QPluginLoader(dir.absoluteFilePath(pluginName));
+    mPlugin = qobject_cast<CpBearerApPluginInterface *>(mPluginLoader->instance());
     QVERIFY(mPlugin != NULL);
     
     // Verify plugin bearer type
@@ -130,6 +126,8 @@
     
     // Create WLAN settings view (connection method ID given)
     subCreateSettingsView(testApId);
+    
+    subGetUiWidgets();
 }
 
 /**
@@ -139,6 +137,11 @@
 {
     delete mMainWindow;
     mMainWindow = 0;
+    
+    // Force unloading of plugin
+    mPluginLoader->unload();
+    delete mPluginLoader;
+    mPluginLoader = 0;
 }
 
 /**
@@ -168,15 +171,16 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::CmNameLength);
+    QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -194,11 +198,11 @@
     QTest::addColumn<QString>("result");
     
     QTest::newRow("maximum length")
-        << "really long name 1234567890123"
-        << "really long name 1234567890123";
+        << "really long name 123456789012345678901234567890123"
+        << "really long name 123456789012345678901234567890123";
     QTest::newRow("too long")
-        << "too long name 123456789012345678901234567890"
-        << "too long name 1234567890123456";
+        << "too long name 12345678901234567890123456789012345678901234"
+        << "too long name 123456789012345678901234567890123456";
     QTest::newRow("basic") // last one must always fit on one line in UI
         << "test WLAN AP"
         << "test WLAN AP";
@@ -212,15 +216,20 @@
     QString previous = 
         mTestView->mConnectionNameItem->contentWidgetData("text").toString();
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);    
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget);
+
     // Erase old string
-    subClearLineEdit(CMManagerShim::CmNameLength);
+    QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
+    HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset);
 
     QTest::qWait(100);
     // Dismiss messagebox
-    HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestView->mMessageBox.data(),
+        messageBoxOkButtonOffset);
     
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -237,15 +246,16 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, wlanNetworkNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::WlanSSIDLength);
+    QString text = mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
+    HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -281,16 +291,20 @@
     QString previous = 
         mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, wlanNetworkNameLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget);
     
     // Erase old string
-    subClearLineEdit(CMManagerShim::WlanSSIDLength);
+    QString text = mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
+    HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget, exitEditorOffset);
 
     QTest::qWait(100);
     // Dismiss messagebox
-    HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestView->mMessageBox.data(),
+        messageBoxOkButtonOffset);
     
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -304,14 +318,17 @@
  */
 void TestCpWlanApPlugin::tcChangeNetworkStatus()
 {
+    QPointF publicPointOffset = comboBoxFirstItemOffset;
+    QPointF hiddenPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset;
+    
     // Set network status to hidden
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusComboBox, 100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusHidden, 100);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget, hiddenPointOffset, 100);
     subVerifyNetworkStatus(HiddenStatus);
 
     // Set network status to public
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusComboBox, 100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusPublic, 100);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget, publicPointOffset, 100);
     subVerifyNetworkStatus(PublicStatus);
 }
 
@@ -320,14 +337,17 @@
  */
 void TestCpWlanApPlugin::tcChangeNetworkMode()
 {
+    QPointF infraPointOffset = comboBoxFirstItemOffset;
+    QPointF adHocPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset;
+    
     // Set network mode to ad-hoc
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeComboBox, 100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeAdHoc, 100);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget, adHocPointOffset, 100);
     subVerifyUint(CMManagerShim::WlanConnectionMode, CMManagerShim::Adhoc);
 
     // Set network mode to infrastructure
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeComboBox, 100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeIntrastructure, 100);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget);
+    HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget, infraPointOffset, 100);
     subVerifyUint(CMManagerShim::WlanConnectionMode, CMManagerShim::Infra);
 }
 
@@ -337,37 +357,52 @@
 void TestCpWlanApPlugin::tcChangeSecurityMode()
 {
 #ifdef WLAN_SECURITY_PLUGINS_AVAILABLE
-    // Ensure security mode is open
-    HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeComboBox, 100);
+    QPointF openPointOffset = comboBoxFirstItemNegativeOffset + comboBoxItemNegativeOffset * 3;
+    QPointF wepPointOffset = comboBoxFirstItemNegativeOffset + comboBoxItemNegativeOffset * 2;
+    QPointF wpaPointOffset = comboBoxFirstItemNegativeOffset + comboBoxItemNegativeOffset;
+    QPointF wpa2PointOffset = comboBoxFirstItemNegativeOffset;
+#else
+    QPointF openPointOffset = comboBoxFirstItemNegativeOffset;
+#endif
+    
+#ifdef WLAN_SECURITY_PLUGINS_AVAILABLE
+    // Set security mode to WEP
+    HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget);
     QTest::qWait(100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeOpen, 100);
-    subVerifyUint(
-        CMManagerShim::WlanSecurityMode,
-        CMManagerShim::WlanSecModeOpen);
-
-    QTest::qWait(1000);
-
-    // Set security mode to WEP
-    HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeComboBox, 100);
-    QTest::qWait(100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeWep, 100);
+    HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget, wepPointOffset, 100);
     subVerifyUint(
         CMManagerShim::WlanSecurityMode,
         CMManagerShim::WlanSecModeWep);
     
     QTest::qWait(1000);
 #endif
-    
     // Set security mode to open
-    HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeComboBox, 100);
+    HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget);
     QTest::qWait(100);
-    HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeOpen, 100);
+    HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget, openPointOffset, 100);
     subVerifyUint(
         CMManagerShim::WlanSecurityMode,
         CMManagerShim::WlanSecModeOpen);
 }
 
 /**
+ * Scrolls the tested view to the bottom.
+ */
+void TestCpWlanApPlugin::tcScrollToBottom()
+{
+    subScrollToBottom();
+}
+
+/**
+ * Gets UI widget pointers because homepage view item may have been
+ * created before it was visible on the UI.
+ */
+void TestCpWlanApPlugin::tcGetUiWidgets()
+{
+    subGetUiWidgets();
+}
+
+/**
  * Tests changing of homepage.
  */
 void TestCpWlanApPlugin::tcChangeHomepage()
@@ -375,7 +410,7 @@
     QFETCH(QString, string);
     QFETCH(QString, result);
     
-    HbAutoTest::mouseClick(mMainWindow, mTestView, homepageLineEdit);
+    HbAutoTest::mouseClick(mMainWindow, mHomepageWidget);
     
     // Erase old string
     QString text = mTestView->mHomepageItem->contentWidgetData("text").toString();
@@ -384,7 +419,7 @@
     // Enter new string
     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
 
-    HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
+    HbAutoTest::mouseClick(mMainWindow, mHomepageWidget, exitEditorOffset);
 
     // Verify both commsdat and UI widget
     subVerifyString(
@@ -401,10 +436,9 @@
     QTest::addColumn<QString>("string");
     QTest::addColumn<QString>("result");
   
-// Doesn't work always, view goes blank sometimes, Orbit bug?
-//    QTest::newRow("long")
-//        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
-//        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
+    QTest::newRow("long")
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
     QTest::newRow("basic") // last one should always fit on one line in UI
         << "http://www.symbian.org/"
         << "http://www.symbian.org/";
@@ -414,9 +448,9 @@
 }
 
 /**
- * Tests advanced settings view (which is currently empty).
+ * Opens advanced settings view.
  */
-void TestCpWlanApPlugin::tcAdvancedSettings()
+void TestCpWlanApPlugin::tcOpenAdvancedSettingsView()
 {
     // Launch advanced settings view
     bool status = connect(
@@ -426,9 +460,781 @@
         SLOT(menuActionTriggered(HbAction *)));
     Q_ASSERT(status);
     emit menuActionTriggered(mTestView->mAdvancedSettingsAction);
+    
+    QTest::qWait(1000);
+    
+    mTestViewAdvanced = static_cast<CpWlanApAdvancedView *>(mMainWindow->currentView());
+}
 
-    QTest::qWait(2000);
+/**
+ * Expands the IPv4 settings group and gets UI widget pointers.
+ */
+void TestCpWlanApPlugin::tcExpandIpv4SettingsAndGetUiWidgets()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv4Group);
+    
+    QTest::qWait(500);
+
+    subGetAdvancedUiWidgets(0);
+}
+
+/**
+ * Tests enabling of automatic phone IP address.
+ */
+void TestCpWlanApPlugin::tcEnableAutomaticIpv4Address()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IP address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
+    }
+    // Enable automatic IP address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
+    subVerifyBool(
+        CMManagerShim::CmIPAddrFromServer,
+        true);
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget);
+}
+
+/**
+ * Tests disabling of automatic phone IP address.
+ */
+void TestCpWlanApPlugin::tcEnableUserDefinedIpv4Address()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IP address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
+    }
+    // Can't verify the setting from CommsDat here, because CMManager will
+    // set it back to true if no valid IP address is yet defined. The flag
+    // is verified in tcChangeIpAddress().
+}
+
+/**
+ * Tests changing of IP address.
+ */
+void TestCpWlanApPlugin::tcChangeIpAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4Address->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPAddress,
+        mTestViewAdvanced->mIpv4Address,
+        result);
+    subVerifyBool(
+        CMManagerShim::CmIPAddrFromServer,
+        false);
+}
+
+/**
+ * Test data for IP address change test case.
+ */
+void TestCpWlanApPlugin::tcChangeIpAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("too long")
+        << "255.255.255.2551234"
+        << "255.255.255.255";
+    QTest::newRow("normal")
+        << "192.168.0.1"
+        << "192.168.0.1";
+}
+
+/**
+ * Tests changing of subnet mask.
+ */
+void TestCpWlanApPlugin::tcChangeSubnetMask()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4SubnetMask->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPNetmask,
+        mTestViewAdvanced->mIpv4SubnetMask,
+        result);
+}
+
+/**
+ * Test data for subnet mask change test case.
+ */
+void TestCpWlanApPlugin::tcChangeSubnetMask_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("empty")
+        << ""
+        << "0.0.0.0";
+    QTest::newRow("zero")
+        << "0.0.0.0"
+        << "0.0.0.0";
+    QTest::newRow("too long")
+        << "255.255.255.2551234"
+        << "255.255.255.255";
+    QTest::newRow("normal")
+        << "192.168.0.1"
+        << "192.168.0.1";
+}
+
+/**
+ * Tests invalid subnet mask.
+ */
+void TestCpWlanApPlugin::tcInvalidSubnetMask()
+{
+    QString previous = 
+        mTestViewAdvanced->mIpv4SubnetMask->contentWidgetData("text").toString();
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4SubnetMask->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPNetmask,
+        mTestViewAdvanced->mIpv4SubnetMask,
+        previous);
+}
+
+/**
+ * Tests changing of gateway.
+ */
+void TestCpWlanApPlugin::tcChangeGateway()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4Gateway->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPGateway,
+        mTestViewAdvanced->mIpv4Gateway,
+        result);
+}
+
+/**
+ * Test data for gateway change test case.
+ */
+void TestCpWlanApPlugin::tcChangeGateway_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("empty")
+        << ""
+        << "0.0.0.0";
+    QTest::newRow("zero")
+        << "0.0.0.0"
+        << "0.0.0.0";
+    QTest::newRow("too long")
+        << "255.255.255.2551234"
+        << "255.255.255.255";
+    QTest::newRow("normal")
+        << "192.168.0.1"
+        << "192.168.0.1";
+}
+
+/**
+ * Tests invalid gateway address.
+ */
+void TestCpWlanApPlugin::tcInvalidGateway()
+{
+    QString previous = 
+        mTestViewAdvanced->mIpv4Gateway->contentWidgetData("text").toString();
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4Gateway->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPGateway,
+        mTestViewAdvanced->mIpv4Gateway,
+        previous);
+}
+
+/**
+ * Scrolls the tested view to the bottom.
+ */
+void TestCpWlanApPlugin::tcScrollToBottom2()
+{
+    subScrollToBottom();
+}
+
+/**
+ * Tests enabling of automatic IPv4 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcEnableAutomaticIpv4DnsAddress()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IPv4 DNS address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
+    }
+    // Enable automatic IPv4 DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
+    subVerifyBool(
+        CMManagerShim::CmIPDNSAddrFromServer,
+        true);
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget);
+}
+
+/**
+ * Tests disabling of automatic IPv4 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcEnableUserDefinedIpv4DnsAddress()
+{
+    Qt::CheckState state = static_cast<Qt::CheckState>
+        (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt());
+    if (state == Qt::Checked) {
+        // Disable automatic IPv4 DNS address
+        HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
+    }
+    // Can't verify the setting from CommsDat here, because CMManager will
+    // set it back to true if no valid IP address is yet defined. The flag
+    // is verified in tcChangeIpv4DnsAddress().
+}
+
+/**
+ * Tests changing of IPv4 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcChangeIpv4DnsAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    // Primary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPNameServer1,
+        mTestViewAdvanced->mIpv4DnsAddress1,
+        result);
+    
+    // Secondary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget);
+    
+    // Erase old string
+    text = mTestViewAdvanced->mIpv4DnsAddress2->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPNameServer2,
+        mTestViewAdvanced->mIpv4DnsAddress2,
+        result);
+    
+    // Verify user defined address is in use
+    subVerifyBool(
+        CMManagerShim::CmIPDNSAddrFromServer,
+        false);
+}
+
+/**
+ * Test data for IPv4 DNS address change test case.
+ */
+void TestCpWlanApPlugin::tcChangeIpv4DnsAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("too long")
+        << "255.255.255.2551234"
+        << "255.255.255.255";
+    QTest::newRow("normal")
+        << "192.168.0.1"
+        << "192.168.0.1";
+}
+
+/**
+ * Tests invalid IPv4 DNS address.
+ */
+void TestCpWlanApPlugin::tcInvalidIpv4DnsAddress()
+{
+    QString previous = 
+        mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
     
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIPNameServer1,
+        mTestViewAdvanced->mIpv4DnsAddress1,
+        previous);
+}
+
+/**
+ * Scrolls the tested view to the top.
+ */
+void TestCpWlanApPlugin::tcScrollToTop()
+{
+    subScrollToTop();
+}
+
+/**
+ * Collapses the IPv4 settings group.
+ */
+void TestCpWlanApPlugin::tcCollapseIpv4Settings()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv4Group);
+}
+
+/**
+ * Expands the IPv6 settings group and gets UI widget pointers.
+ */
+void TestCpWlanApPlugin::tcExpandIpv6SettingsAndGetUiWidgets()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv6Group);
+
+    QTest::qWait(500);
+    
+    subGetAdvancedUiWidgets(1);
+}
+
+/**
+ * Tests enabling of automatic IPv6 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcEnableAutomaticIpv6DnsAddress()
+{
+    // Enable automatic IPv6 DNS address
+    QPointF automaticPointOffset = comboBoxFirstItemOffset;
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
+    QTest::qWait(100);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, automaticPointOffset, 100);
+    QTest::qWait(100);
+    subVerifyBool(
+        CMManagerShim::CmIP6DNSAddrFromServer,
+        true);
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
+}
+
+/**
+ * Tests enabling of well-known IPv6 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcEnableWellKnownIpv6DnsAddress()
+{
+    // Enable well-known IPv6 DNS address
+    QPointF wellKnownPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset;
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
+    QTest::qWait(100);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, wellKnownPointOffset, 100);
+    QTest::qWait(100);
+    subVerifyBool(
+        CMManagerShim::CmIP6DNSAddrFromServer,
+        false);
+    subVerifyString(
+        CMManagerShim::CmIP6NameServer1,
+        mTestViewAdvanced->mIpv6DnsAddress1,
+        "fec0:000:0000:ffff::1");
+    subVerifyString(
+        CMManagerShim::CmIP6NameServer2,
+        mTestViewAdvanced->mIpv6DnsAddress2,
+        "fec0:000:0000:ffff::2");
+    
+    // Ensure that editing the IP address is not allowed
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
+}
+
+/**
+ * Tests enabling of user defined IPv6 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcEnableUserDefinedIpv6DnsAddress()
+{
+    // Select user defined IPv6 DNS address
+    QPointF userDefinedPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset * 2;
+    //QPointF userDefinedPointOffset(0, 160);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
+    QTest::qWait(100);
+    HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, userDefinedPointOffset, 100);
+    QTest::qWait(100);
+    // Can't verify the setting from CommsDat here, because CMManager will
+    // set it back to true if no valid IP address is yet defined. The flag
+    // is verified in tcChangeIpv4DnsAddress().
+}
+
+/**
+ * Tests changing of IPv6 DNS addresses.
+ */
+void TestCpWlanApPlugin::tcChangeIpv6DnsAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    // Primary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIP6NameServer1,
+        mTestViewAdvanced->mIpv6DnsAddress1,
+        result);
+    
+    // Secondary DNS address
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
+    
+    // Erase old string
+    text = mTestViewAdvanced->mIpv6DnsAddress2->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget, exitEditorOffset);
+
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIP6NameServer2,
+        mTestViewAdvanced->mIpv6DnsAddress2,
+        result);
+    
+    // Verify user defined address is in use
+    subVerifyBool(
+        CMManagerShim::CmIP6DNSAddrFromServer,
+        false);
+}
+
+/**
+ * Test data for IPv6 DNS address change test case.
+ */
+void TestCpWlanApPlugin::tcChangeIpv6DnsAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("normal")
+        << "2001:db8:85a3::8a2e:370:7334"
+        << "2001:db8:85a3:0:0:8a2e:370:7334";
+}
+
+/**
+ * Tests invalid IPv6 DNS address.
+ */
+void TestCpWlanApPlugin::tcInvalidIpv6DnsAddress()
+{
+    QString previous = 
+        mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
+    
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "abcdef:fedcba", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmIP6NameServer1,
+        mTestViewAdvanced->mIpv6DnsAddress1,
+        previous);
+}
+
+/**
+ * Collapses the IPv6 settings group.
+ */
+void TestCpWlanApPlugin::tcCollapseIpv6Settings()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv6Group);
+}
+
+/**
+ * Expands the proxy settings group and gets UI widget pointers.
+ */
+void TestCpWlanApPlugin::tcExpandProxySettingsAndGetUiWidgets()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup);
+
+    QTest::qWait(500);
+    
+    subGetAdvancedUiWidgets(2);
+}
+
+/**
+ * Tests changing of proxy server address.
+ */
+void TestCpWlanApPlugin::tcChangeProxyServerAddress()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mProxyServer->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    
+    // Verify both commsdat and UI widget
+    subVerifyString(
+        CMManagerShim::CmProxyServerName,
+        mTestViewAdvanced->mProxyServer,
+        result);
+    // Verify user defined address flag is set correctly
+    if (result.isEmpty()) {
+        subVerifyBool(
+            CMManagerShim::CmProxyUsageEnabled,
+            false);
+    } else {
+        subVerifyBool(
+            CMManagerShim::CmProxyUsageEnabled,
+            true);
+    }
+}
+
+/**
+ * Test data for proxy server address change test case.
+ */
+void TestCpWlanApPlugin::tcChangeProxyServerAddress_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("long")
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
+        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
+    QTest::newRow("empty")
+        << ""
+        << "";
+    QTest::newRow("basic") // last one should always fit on one line in UI
+        << "http://www.symbian.org/"
+        << "http://www.symbian.org/";
+}
+
+/**
+ * Tests changing of proxy port number.
+ */
+void TestCpWlanApPlugin::tcChangeProxyPortNumber()
+{
+    QFETCH(QString, string);
+    QFETCH(QString, result);
+    
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+
+    // Verify both commsdat and UI widget
+    subVerifyUint(
+        CMManagerShim::CmProxyPortNumber,
+        result.toInt());
+    QCOMPARE(
+        mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(),
+        result.toInt());
+}
+
+/**
+ * Test data for proxy port number change test case.
+ */
+void TestCpWlanApPlugin::tcChangeProxyPortNumber_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<QString>("result");
+  
+    QTest::newRow("basic")
+        << "8080"
+        << "8080";
+    QTest::newRow("too long")
+        << "1234567890"
+        << "12345";
+    QTest::newRow("zero")
+        << "0"
+        << "";
+    QTest::newRow("empty")
+        << ""
+        << "";
+}
+
+/**
+ * Tests invalid proxy port number.
+ */
+void TestCpWlanApPlugin::tcInvalidProxyPortNumber()
+{
+    int previous = 
+        mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt();
+    
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget);
+    
+    // Erase old string
+    QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString();
+    subClearLineEdit(text.size());
+    
+    // Enter new string
+    HbAutoTest::keyClicks(mMainWindow, "65536", 0, waitTime);
+
+    HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset);
+
+    QTest::qWait(100);
+    // Dismiss messagebox
+    HbAutoTest::mouseClick(
+        mMainWindow,
+        mTestViewAdvanced->mMessageBox.data(),
+        messageBoxOkButtonOffset);
+    
+    // Verify both commsdat and UI widget
+    subVerifyUint(
+        CMManagerShim::CmProxyPortNumber,
+        previous);
+    QCOMPARE(
+        mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(),
+        previous);
+}
+
+/**
+ * Collapses the proxy settings group.
+ */
+void TestCpWlanApPlugin::tcCollapseProxySettings()
+{
+    HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup);
+}
+
+/**
+ * Returns from advanced settings view.
+ */
+void TestCpWlanApPlugin::tcCloseAdvancedSettingsView()
+{
     // Return from advanced settings view
     subClickWidget("HbNavigationButton");
 }
@@ -438,6 +1244,108 @@
 // -----------------------------------------------------------------------------
 
 /**
+ * Gets UI widget pointers.
+ */
+void TestCpWlanApPlugin::subGetUiWidgets()
+{
+    HbModelIterator iterator(mTestView->mModel);
+    
+    // Get "Access point settings" group item
+    QModelIndex apGroupIndex = iterator.index(0);
+    
+    // Get UI widgets
+    mConnectionNameWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(0, apGroupIndex));
+    mWlanNetworkNameWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(1, apGroupIndex));
+    mNetworkStatusWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(2, apGroupIndex));
+    mNetworkModeWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(3, apGroupIndex));
+    mSecurityModeWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(4, apGroupIndex));
+    mHomepageWidget = subGetWidgetByIndex(
+        mTestView->mForm,
+        iterator.index(5, apGroupIndex));
+}
+
+/**
+ * Gets advanced settings view UI widget pointers by group index.
+ */
+void TestCpWlanApPlugin::subGetAdvancedUiWidgets(
+    uint index)
+{
+    // Get the group item
+    HbModelIterator iterator(mTestViewAdvanced->mModel);
+    QModelIndex groupIndex = iterator.index(index);
+    
+    // Get UI widgets
+    if (index == 0) {
+        // IPv4 settings group
+        mIpv4AddressAutomaticWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(0, groupIndex));
+        mIpv4AddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(1, groupIndex));
+        mIpv4SubnetMaskWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(2, groupIndex));
+        mIpv4GatewayWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(3, groupIndex));
+        mIpv4DnsAddressAutomaticWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(4, groupIndex));
+        mIpv4PrimaryDnsAddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(5, groupIndex));
+        mIpv4SecondaryDnsAddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(6, groupIndex));
+    } else if (index == 1) {
+        // IPv6 settings group
+        mIpv6DnsAddressAutomaticWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(0, groupIndex));
+        mIpv6PrimaryDnsAddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(1, groupIndex));
+        mIpv6SecondaryDnsAddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(2, groupIndex));    
+    } else {
+        // Proxy settings group
+        mProxyServerAddressWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(0, groupIndex));
+        mProxyPortNumberWidget = subGetWidgetByIndex(
+            mTestViewAdvanced->mForm,
+            iterator.index(1, groupIndex));
+    }
+}
+
+/**
+ * Gets an UI widget from HbDataForm by index. 
+ */
+HbWidget *TestCpWlanApPlugin::subGetWidgetByIndex(
+    HbDataForm *form,
+    const QModelIndex &index)
+{
+    HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *>
+        (form->itemByIndex(index));
+    HbWidget *widget = viewItem->dataItemContentWidget();
+    //QString widgetClassName(widget->metaObject()->className());
+    //qDebug() << widgetClassName;
+    return widget;
+}
+
+/**
  * Verifies that given string is correctly stored in CommsDat and shown on UI. 
  */
 void TestCpWlanApPlugin::subVerifyString(
@@ -503,17 +1411,15 @@
 void TestCpWlanApPlugin::subClearLineEdit(
     uint length)
 {
-    // Erase old string
-    QTest::qWait(5000); // TODO: Remove this when item specific menu doesn't pop up anymore
-
     // Move cursor to end of string
-    //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, 0, waitTime); // doesn't seem to do anything? 
+    //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, Qt::ControlModifier, waitTime); // doesn't seem to do anything? 
     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
     for (int i=0; i<25; i++) {
         HbAutoTest::keyClick(mMainWindow, Qt::Key_Right, 0, waitTime);
     }
+    // Erase string
     for (int i=0; i<length; i++) {
         HbAutoTest::keyClick(mMainWindow, Qt::Key_Backspace, 0, waitTime);
     }
@@ -558,3 +1464,56 @@
     Q_ASSERT(target);
     HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target));
 }
+
+/**
+ * Returns the middle point of a widget.
+ */
+QPointF TestCpWlanApPlugin::subMiddlePointOfWidget(const HbWidget *widget)
+{
+    QRectF widgetRect = widget->rect();
+    QRectF widgetSceneRect = widget->mapRectToScene(widgetRect);
+    qreal middleX = ((widgetSceneRect.right() - widgetSceneRect.left()) / 2) + widgetSceneRect.left();
+    qreal middleY = ((widgetSceneRect.bottom() - widgetSceneRect.top()) / 2) + widgetSceneRect.top();
+    
+    return QPointF(middleX, middleY);
+}
+
+/**
+ * Verifies that given attribute contains expected boolean value in CommsDat. 
+ */
+void TestCpWlanApPlugin::subVerifyBool(
+    CMManagerShim::ConnectionMethodAttribute attribute,
+    bool expected)
+{
+    // Read attribute value from CommsDat
+    QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
+    QScopedPointer<CmConnectionMethodShim> connectionMethod( 
+        cmManager->connectionMethod(testApId));
+    bool commsdat = connectionMethod->getBoolAttribute(attribute);
+    
+    QCOMPARE(commsdat, expected);
+}
+
+/**
+ * Scrolls the tested view to the bottom.
+ */
+void TestCpWlanApPlugin::subScrollToBottom()
+{
+    // Scroll to the bottom of the view
+    HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle);
+    QTest::qWait(1000);
+    HbAutoTest::mouseMove(mMainWindow, mTestView, scrollTop);
+    HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollTop);
+}
+
+/**
+ * Scrolls the tested view to the top.
+ */
+void TestCpWlanApPlugin::subScrollToTop()
+{
+    // Scroll to the top of the view
+    HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle);
+    QTest::qWait(1000);
+    HbAutoTest::mouseMove(mMainWindow, mTestView, scrollBottom);
+    HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollBottom);
+}
--- a/cmmanager/cpwlanapplugin/tsrc/ut/testcpwlanapplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cpwlanapplugin/tsrc/ut/testcpwlanapplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -19,12 +19,16 @@
 #include <QtTest/QtTest>
 #include <cmmanagerdefines_shim.h>
 
+class HbWidget;
 class HbDialog;
 class HbMainWindow;
 class HbAutoTestMainWindow;
+class HbDataForm;
 class HbDataFormModelItem;
+class HbDataFormViewItem;
 class HbAction;
 class CpWlanApView;
+class CpWlanApAdvancedView;
 class CpBearerApPluginInterface;
 
 enum NetworkStatus {
@@ -58,12 +62,54 @@
         void tcChangeNetworkStatus();
         void tcChangeNetworkMode();
         void tcChangeSecurityMode();
+        void tcScrollToBottom();
+        void tcGetUiWidgets();
         void tcChangeHomepage();
         void tcChangeHomepage_data();
-        void tcAdvancedSettings();
+        void tcOpenAdvancedSettingsView();
+        void tcExpandIpv4SettingsAndGetUiWidgets();
+        void tcEnableAutomaticIpv4Address();
+        void tcEnableUserDefinedIpv4Address();
+        void tcChangeIpAddress();
+        void tcChangeIpAddress_data();
+        void tcChangeSubnetMask();
+        void tcChangeSubnetMask_data();
+        void tcInvalidSubnetMask();
+        void tcChangeGateway();
+        void tcChangeGateway_data();
+        void tcInvalidGateway();
+        void tcScrollToBottom2();
+        void tcEnableAutomaticIpv4DnsAddress();
+        void tcEnableUserDefinedIpv4DnsAddress();
+        void tcChangeIpv4DnsAddress();
+        void tcChangeIpv4DnsAddress_data();
+        void tcInvalidIpv4DnsAddress();
+        void tcScrollToTop();
+        void tcCollapseIpv4Settings();
+        void tcExpandIpv6SettingsAndGetUiWidgets();
+        void tcEnableAutomaticIpv6DnsAddress();
+        void tcEnableWellKnownIpv6DnsAddress();
+        void tcEnableUserDefinedIpv6DnsAddress();
+        void tcChangeIpv6DnsAddress();
+        void tcChangeIpv6DnsAddress_data();
+        void tcInvalidIpv6DnsAddress();
+        void tcCollapseIpv6Settings();
+        void tcExpandProxySettingsAndGetUiWidgets();
+        void tcChangeProxyServerAddress();
+        void tcChangeProxyServerAddress_data();
+        void tcChangeProxyPortNumber();
+        void tcChangeProxyPortNumber_data();
+        void tcInvalidProxyPortNumber();
+        void tcCollapseProxySettings();
+        void tcCloseAdvancedSettingsView();
 
     private:
         // Sub test cases
+        void subGetUiWidgets();
+        void subGetAdvancedUiWidgets(uint index);
+        HbWidget *subGetWidgetByIndex(
+            HbDataForm *form,
+            const QModelIndex &index);
         void subVerifyString(
             CMManagerShim::ConnectionMethodAttribute attribute,
             HbDataFormModelItem *item,
@@ -76,12 +122,43 @@
         void subClearLineEdit(uint length);
         void subCreateSettingsView(uint connetionMethodId);
         void subClickWidget(const QString &name);
+        QPointF subMiddlePointOfWidget(const HbWidget *widget);
+        void subVerifyBool(
+            CMManagerShim::ConnectionMethodAttribute attribute,
+            bool expected);
+        void subScrollToBottom();
+        void subScrollToTop();
 
     private:
         // Code references
         CpWlanApView *mTestView;
+        CpWlanApAdvancedView *mTestViewAdvanced;
+        // "Access point settings" UI widgets
+        HbWidget *mConnectionNameWidget;
+        HbWidget *mWlanNetworkNameWidget;
+        HbWidget *mNetworkStatusWidget;
+        HbWidget *mNetworkModeWidget;
+        HbWidget *mSecurityModeWidget;
+        HbWidget *mHomepageWidget;
+        // "Advanced settings" UI widgets
+        HbDataFormViewItem *mIpv4GroupViewItem;
+        HbDataFormViewItem *mIpv6GroupViewItem;
+        HbDataFormViewItem *mProxyGroupViewItem;
+        HbWidget *mIpv4AddressAutomaticWidget;
+        HbWidget *mIpv4AddressWidget;
+        HbWidget *mIpv4SubnetMaskWidget;
+        HbWidget *mIpv4GatewayWidget;
+        HbWidget *mIpv4DnsAddressAutomaticWidget;
+        HbWidget *mIpv4PrimaryDnsAddressWidget;
+        HbWidget *mIpv4SecondaryDnsAddressWidget;
+        HbWidget *mIpv6DnsAddressAutomaticWidget;
+        HbWidget *mIpv6PrimaryDnsAddressWidget;
+        HbWidget *mIpv6SecondaryDnsAddressWidget;
+        HbWidget *mProxyServerAddressWidget;
+        HbWidget *mProxyPortNumberWidget;
         
         // Test data
         HbAutoTestMainWindow *mMainWindow;
+        QPluginLoader *mPluginLoader;
         CpBearerApPluginInterface *mPlugin;
 };
--- a/connectionmonitoring/cellularindicatorplugin/inc/cellularindicatorplugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/cellularindicatorplugin/inc/cellularindicatorplugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -69,10 +69,6 @@
     // Used to get indicator data (icon or text)
     QVariant indicatorData(int role) const;
 
-private slots:
-    // handler for error codes
-    void processError(QProcess::ProcessError err);
-
 private: // data
 
     // Disable copy constructor
--- a/connectionmonitoring/cellularindicatorplugin/src/cellularindicatorplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/cellularindicatorplugin/src/cellularindicatorplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,7 @@
  */
 
 #include <QtPlugin>
-#include <QTranslator>
+#include <HbTranslator>
 #include <QLocale>
 #include <QList>
 #include <HbLabel>
@@ -94,12 +94,7 @@
     Q_UNUSED(indicatorType)
     
     // Install localization
-    QTranslator *translator = new QTranslator(this);
-
-    QString lang = QLocale::system().name(); 
-    QString path = "Z:/resource/qt/translations/"; 
-    translator->load("cellularindicatorplugin_" + lang, path);
-    qApp->installTranslator(translator);
+    HbTranslator *translator(new HbTranslator("cellularindicatorplugin"));
     
     OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_EXIT );
     return this;
@@ -156,15 +151,13 @@
     
     Q_UNUSED(type)
     bool handled = false;
+    QVariantMap data;
     
     switch(type) {
     case InteractionActivated:
-        //connect error() to slot processError() to get error, 
-        QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)),                       
-                          this, SLOT(processError(QProcess::ProcessError)));
+        // Emit a signal that will inform the client to start the connectionview client
+        emit userActivated(data);
 
-        // Show connection view
-        process.start("connview");
         handled = true;
         break;
     
@@ -209,17 +202,14 @@
             else if ( indicatorInfo[0].toInt() && (indicatorInfo.count() >= 2)) {
                 
                 // Only one connection -> show name of the iap
-                QString iapName;
-                iapName = indicatorInfo[1].toString();
-                QString str = QString(hbTrId("txt_occ_dblist_cellular_data_val_1_connected"));
-                ret = str.arg(iapName);
+                ret = indicatorInfo[1].toString();
             }
         }
         break;
 
     case DecorationNameRole:
         // Return the icon
-        ret = HbIcon("qtg_small_gprs");
+        ret = QString("qtg_small_gprs");
         break;
     
     default:
@@ -231,26 +221,3 @@
     return ret;
 }
 
-/*!
-    The processError is a handler for error codes.
-*/
-void CellularIndicatorPlugin::processError(QProcess::ProcessError err)
-    {
-    OstTraceFunctionEntry1(CELLULARINDICATORPLUGIN_PROCESSERROR_ENTRY, this);
-  
-    switch (err) {   
-        case QProcess::FailedToStart: 
-        case QProcess::Crashed: 
-        case QProcess::Timedout: 
-        case QProcess::ReadError: 
-        case QProcess::WriteError: 
-        case QProcess::UnknownError:
-            OstTrace1( CELLULARINDICATORPLUGIN_ERR,PROCESSERROR_KNOWN,"Process Error %u", err);
-            break;  
-        default:
-        OstTrace1( CELLULARINDICATORPLUGIN_ERR,PROCESSERROR_UNKNOWN,"Unknown Process Error %u", err);
-            break;
-        }
-    OstTraceFunctionExit1(CELLULARINDICATORPLUGIN_PROCESSERROR_EXIT, this);
-    }
-
--- a/connectionmonitoring/connectionmonitorui/data/ConnectionMonitorUi_reg.rss	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/data/ConnectionMonitorUi_reg.rss	Thu Jul 22 16:37:38 2010 +0100
@@ -17,7 +17,7 @@
 
 
 #include <appinfo.rh>
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <data_caging_paths_strings.hrh>
 
 UID2 KUidAppRegistrationResourceFile
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <nifvar.h>
 #include <StringLoader.h>
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <avkon.rsg>
 #include <AknUtils.h>
 #include <apgcli.h>
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiAppUi.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiAppUi.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,7 +23,7 @@
 #include <AknUtils.h>
 #include <cmmanagerext.h>
 #include <nifvar.h>
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include "ConnectionMonitorUi.hrh"
 #include "ConnectionMonitorUiAppUi.h"
 #include "ConnectionMonitorUiView.h"
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiContainer.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiContainer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -33,7 +33,7 @@
 #include "FeatureManagerWrapper.h"
 #include "ActiveWrapper.h"
 
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <ConnectionMonitorUi.mbg>
 #include <data_caging_path_literals.hrh>
 
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiDetailsContainer.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiDetailsContainer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -22,7 +22,7 @@
 #include <aknnavi.h>    //for CNaviPane
 #include <aknnavide.h>  //for CAknNavigationDecorator
 #include <StringLoader.h>
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 
 #include "ConnectionArray.h"
 #include "ConnectionMonitorUiLogger.h"
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiDetailsView.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiDetailsView.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 
 // INCLUDE FILES
-#include  <ConnectionMonitorUi.rsg>
+#include  <connectionmonitorui.rsg>
 #include  "ConnectionMonitorUiDetailsView.h"
 #include  "ConnectionMonitorUiDetailsContainer.h" 
 #include  "ConnectionMonitorUi.hrh"
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiView.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionMonitorUiView.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 // INCLUDE FILES
 #include  <eikmenup.h>
 #include  <akntitle.h>   //for CAknTitlePane
-#include  <ConnectionMonitorUi.rsg>
+#include  <connectionmonitorui.rsg>
 #include  <StringLoader.h>
 
 #include  <hlplch.h>
--- a/connectionmonitoring/connectionmonitorui/src/CsdConnectionInfo.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/CsdConnectionInfo.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 // INCLUDE FILES
 //#include <nifvar.h>
 #include <StringLoader.h>
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <ConnectionMonitorUi.mbg>
 #include <AknUtils.h>
 
--- a/connectionmonitoring/connectionmonitorui/src/EasyWLANConnectionInfo.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/EasyWLANConnectionInfo.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 
 // INCLUDE FILES
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <ConnectionMonitorUi.mbg>
 
 #include "EasyWLANConnectionInfo.h"
--- a/connectionmonitoring/connectionmonitorui/src/GprsConnectionInfo.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/GprsConnectionInfo.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 // INCLUDE FILES
 //#include <nifvar.h>
 #include <StringLoader.h>
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <ConnectionMonitorUi.mbg>
 //#include <Avkon.rsg>
 
--- a/connectionmonitoring/connectionmonitorui/src/WlanConnectionInfo.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionmonitorui/src/WlanConnectionInfo.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 
 // INCLUDE FILES
-#include <ConnectionMonitorUi.rsg>
+#include <connectionmonitorui.rsg>
 #include <ConnectionMonitorUi.mbg>
 
 #include "ConnectionArray.h"
--- a/connectionmonitoring/connectionview/connectionview.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionview/connectionview.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,10 @@
 #
 TEMPLATE = app
 TARGET = connview
-CONFIG += hb no_icon
+
+CONFIG += hb no_icon mobility
+MOBILITY+=bearer
+
 DEPENDPATH += . inc src
 INCLUDEPATH += .
 
@@ -34,8 +37,6 @@
 
 SYMBIAN_PLATFORMS = WINSCW ARMV5
 
-LIBS += -lqtbearer
-
 symbian {
     TARGET.CAPABILITY = NetworkServices NetworkControl
     TARGET.UID3 = 0x2002C36A
--- a/connectionmonitoring/connectionview/inc/connectionview.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionview/inc/connectionview.h	Thu Jul 22 16:37:38 2010 +0100
@@ -135,9 +135,6 @@
         /* The toolbar on the view */
         HbToolBar *mToolBar;
         
-        /* The toolbar action which can be used to disconnect all the connections */
-        HbAction *mDisconnectAction;
-        
         /* The id of the timer used to close the application */
         int mClosingTimer;
         
--- a/connectionmonitoring/connectionview/res/connectionview.css	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionview/res/connectionview.css	Thu Jul 22 16:37:38 2010 +0100
@@ -26,3 +26,10 @@
 {
     max-width: expr(var(hb-param-screen-short-edge)-var(hb-param-margin-gene-left)-var(hb-param-margin-gene-right));
 }
+
+HbLabel#mConnectionLabel::text
+{
+    font-variant: secondary;
+    text-height: var(hb-param-text-height-tiny);
+    text-line-count-max: 1;
+}
--- a/connectionmonitoring/connectionview/src/connectionview.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connectionview/src/connectionview.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -15,7 +15,7 @@
 *
 */
 
-#include <QTranslator>
+#include <HbTranslator>
 #include <QLocale>
 #include <QList>
 #include <HbLabel>
@@ -45,6 +45,8 @@
 QTM_USE_NAMESPACE
 
 
+const qreal typeLabelWidth = 18.0;
+
 ConnectionView::ConnectionView():
     mNetConfigurationManager(new QNetworkConfigurationManager(this)),
     mSignalMapper(new QSignalMapper(this)),
@@ -53,11 +55,7 @@
 {
     OstTraceFunctionEntry0( CONNECTIONVIEW_CONNECTIONVIEW_ENTRY );
     // Install localization
-    QTranslator *translator = new QTranslator(this);
-    QString lang = QLocale::system().name(); 
-    QString path = "Z:/resource/qt/translations/"; 
-    translator->load("connectionview_" + lang, path);
-    qApp->installTranslator(translator);
+    HbTranslator *translator(new HbTranslator("connectionview"));
     
     // Register custom layout location
     bool registerStatus = HbStyleLoader::registerFilePath(":/layout/");
@@ -143,10 +141,12 @@
     // Create the toolbar and the disconnection action
     mToolBar = new HbToolBar();    
     HbIcon icon("qtg_mono_disconnect");
-    mDisconnectAction = mToolBar->addAction(icon, hbTrId("txt_occ_button_disconnect_all"));
+    HbAction *disconnectAction = new HbAction(mToolBar);
+    disconnectAction->setIcon(icon);
+    mToolBar->addAction(disconnectAction);
     mMainView->setToolBar(mToolBar);
     bool connectStatus = connect(
-            mDisconnectAction,
+            disconnectAction,
             SIGNAL(triggered(bool)),
             this,
             SLOT(disconnectAll()));
@@ -178,9 +178,9 @@
     
     // Toolbar is shown only if there are more than one connections active
     if (mConnectionCount > 1) {
-        mToolBar->show();
+        mMainView->setItemVisible(Hb::ToolBarItem, true);
     } else {
-        mToolBar->hide();
+        mMainView->setItemVisible(Hb::ToolBarItem, false);
     }
     
     // if there are connections, the main view with the connections is shown
@@ -314,8 +314,16 @@
     QGraphicsLinearLayout *labelLayout = new QGraphicsLinearLayout(Qt::Horizontal);
     labelLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     HbLabel *typeLabel = new HbLabel(hbTrId("txt_occ_list_name"));
+
+    // get the pixel size matching the spesified 18 units using the HbDeviceProfile
+    // and set the width of the label
+    HbDeviceProfile profile = HbDeviceProfile::profile(mMainView);
+    typeLabel->setPreferredWidth(typeLabelWidth*profile.unitValue());
+    typeLabel->setObjectName("mConnectionLabel");
+    
     HbLabel *nameLabel = new HbLabel(iapName);
     nameLabel->setAlignment(Qt::AlignRight);
+    nameLabel->setObjectName("mConnectionLabel");
     labelLayout->addItem(typeLabel);
     labelLayout->addItem(nameLabel);
    
--- a/connectionmonitoring/connmon/connectionmonitor/src/ConnMonNoti.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/connmon/connectionmonitor/src/ConnMonNoti.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,6 +21,8 @@
 #include <e32base.h>
 #include <rmmcustomapi.h>
 #include <featmgr.h>
+#include <gsmerror.h>     // KErrPacketDataTsyMaxPdpContextsReached 
+#include <etelpckt.h>     // KErrUmtsMaxNumOfContextExceededByNetwork
 
 #include "ConnMonServ.h"
 #include "ConnMonSess.h"
@@ -562,10 +564,10 @@
         }
     else
         {
-        iEventInfo.Reset();
-
         if ( iInfoBuf().iStage != static_cast< TInt >( iEventInfo.iData ) )
             {
+            iEventInfo.Reset();
+            
             // Send only new stage info to clients
             iEventInfo.iEventType       = EConnMonConnectionStatusChange;
             iEventInfo.iConnectionId    = iConnectionId;
@@ -640,35 +642,15 @@
                 }
             }
 
-        if ( iInfoBuf().iError == KErrNone )
-            {
-            // New request
-            Receive();
-            }
-        else
+        // New request
+        Receive();
+            
+        if ( iInfoBuf().iError == KErrDisconnected )
             {
-            // Connection is closing.
-            CSubConnUpDownNotifier* subConnUpDownNotifier = 0;
-            TInt err = iServer->Iap()->GetSubConnUpDownNotifier(
-                    iConnectionId,
-                    &subConnUpDownNotifier );
-
-            if ( KErrNone == err )
-                {
-                // Subconn down notifier has stopped and allinterface closed event has arrived
-                if ( !subConnUpDownNotifier->IsActive() )
-                    {
-                    subConnUpDownNotifier->SendDeletedEvent();
-                    }
-                }
-
-            if ( iInfoBuf().iError == KErrDisconnected )
-                {
-                // Enable WLAN scan when IAP availability is check for the
-                // next time because current bearer has been lost (-36).
-                // MPM needs a fresh list of available iaps.
-                iServer->Iap()->EnableWlanScan();
-                }
+            // Enable WLAN scan when IAP availability is check for the
+            // next time because current bearer has been lost (-36).
+            // MPM needs a fresh list of available iaps.
+            iServer->Iap()->EnableWlanScan();
             }
         }
     //LOGEXITFN("CProgressNotifier::RunL()")
--- a/connectionmonitoring/indicatorobserver/inc/indicatorobserver.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/indicatorobserver/inc/indicatorobserver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -25,6 +25,7 @@
 #include <xqsettingskey.h>
 
 class XQSettingsManager;
+class HbIndicator;
 
 QTM_USE_NAMESPACE
 
@@ -61,12 +62,16 @@
     void activateWlanIndicatorPlugin(QList<QVariant> list);
     
     void deactivateWlanIndicatorPlugin();
-        
+    
 private slots:
     void updateWlanRadioStatus(const XQSettingsKey &key, const QVariant &value);
 
     void handleConfigurationChanged(const QNetworkConfiguration& config);
     
+    void userActivateCellularIndicator(const QString &type, const QVariantMap &data);
+
+    void userActivateWlanIndicator(const QString &type, const QVariantMap &data);
+    
 private:
     /*!
         Pointer to network configuration manager
@@ -94,6 +99,11 @@
     bool mWlanEnabled;
     
     /*!
+        Indicates whether WLAN radio is forced off
+    */
+    bool mWlanForceDisabled;
+    
+    /*!
         Indicates whether WLAN indicator plugin is activated
     */
     bool mWlanIndicatorIsActivated;
@@ -102,6 +112,16 @@
         Indicates whether cellular indicator plugin is activated
     */
     bool mCellularIndicatorIsActivated;
+    
+    /*!
+         Pointer to the WLAN indicator
+     */
+    HbIndicator *mWlanIndicator;
+    
+    /*!
+         Pointer to the cellular indicator
+     */
+    HbIndicator *mCellularIndicator;
 
     friend class ObserverTester;
     
--- a/connectionmonitoring/indicatorobserver/indicatorobserver.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/indicatorobserver/indicatorobserver.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -16,14 +16,14 @@
 
 TEMPLATE = app
 TARGET = indicatorobserver
-CONFIG += hb \
-          no_icon
+CONFIG += hb no_icon mobility
+MOBILITY += bearer
 
 INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \
                ./inc \
                ./traces
                
-LIBS += -lqtbearer -lxqsettingsmanager
+LIBS += -lxqsettingsmanager
 
 QT += core \
       network 
--- a/connectionmonitoring/indicatorobserver/src/indicatorobserver.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionmonitoring/indicatorobserver/src/indicatorobserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -45,8 +45,11 @@
     mActiveCellularConfigurations(new QList<QNetworkConfiguration>),
     mActiveWlanConfigurations(new QList<QNetworkConfiguration>),    
     mWlanEnabled(0),
+    mWlanForceDisabled(0),
     mWlanIndicatorIsActivated(false),
-    mCellularIndicatorIsActivated(false)
+    mCellularIndicatorIsActivated(false),
+    mWlanIndicator(NULL),
+    mCellularIndicator(NULL)
     
 {
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_CONSTRUCTOR_ENTRY, "-->");
@@ -79,19 +82,25 @@
         KCRUidWlanDeviceSettingsRegistryId.iUid,
         KWlanOnOff);
     
+    // Also subscribe for KForceDisableWlan change indications
+    XQSettingsKey wlanForceKey(
+        XQSettingsKey::TargetCentralRepository,
+        KCRUidWlanDeviceSettingsRegistryId.iUid, 
+        KWlanForceDisable);
+    
     //Read current status of WLAN radio
-    //mWlanEnabled = mSettingsManager->readItemValue(wlanKey).toInt() ? true : false;
-    mWlanEnabled = true; 
-    //TODO: Replace above code with commented code when WlanOnOff implementation is in release.
-    //TODO: Remeber to add check for read failure(call error() method from settings manager).
-    
+    mWlanEnabled = mSettingsManager->readItemValue(wlanKey).toInt() ? true : false;
+    mWlanForceDisabled = mSettingsManager->readItemValue(wlanForceKey).toInt() ? true : false;
+
     mSettingsManager->startMonitoring(wlanKey);
+    mSettingsManager->startMonitoring(wlanForceKey);
 
     initializeIndicators();
     
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_CONSTRUCTOR_EXIT, "<--");
 }
 
+
 /*!
     IndicatorObserver::~IndicatorObserver
 */
@@ -118,6 +127,9 @@
         delete mActiveWlanConfigurations;
         }
     
+    delete mCellularIndicator;
+    delete mWlanIndicator;
+    
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_DESTRUCTOR_EXIT, "<--");
 }
 
@@ -129,6 +141,25 @@
 
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_INITIALIZEINDICATORS_ENTRY, "-->");
     
+    // create the indicators and make connections
+    mCellularIndicator = new HbIndicator();  
+    // connect the user activated slot here, so that the indicator know to start the connview in case
+    // the user taps the indicator
+    bool conn = QObject::connect(
+                    mCellularIndicator, 
+                    SIGNAL(userActivated(const QString&, const QVariantMap&)), 
+                    this, 
+                    SLOT(userActivateCellularIndicator(const QString&, const QVariantMap&)));
+    
+    mWlanIndicator = new HbIndicator();  
+    // connect the user activated slot here, so that the indicator know to start the wlan sniffer in case
+    // the user taps the indicator
+    conn = QObject::connect(
+                    mWlanIndicator, 
+                    SIGNAL(userActivated(const QString&, const QVariantMap&)), 
+                    this, 
+                    SLOT(userActivateWlanIndicator(const QString&, const QVariantMap&)));
+    
     findActiveConfigurations();
     updateWlanIndicator();
     updateCellularIndicator();
@@ -143,16 +174,15 @@
 {
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_UPDATEWLANRADIOSTATUS_ENTRY, "-->");
     
-    // The key parameter is not used, since only WLAN ON/OFF setting is connected to this slot
-    Q_UNUSED(key);
+    // The change notification is received either for the WlanOnoff key, or the
+    // ForceDisableWlan key
+    if (KWlanOnOff == key.key()) {
+        mWlanEnabled = value.toInt() ? true : false;
+    } else {
+        mWlanForceDisabled = value.toInt() ? true : false;
+    }
     
-    // Inform about WLAN ON/OFF status change
-    Q_UNUSED(value); //TODO: to be removed with final implementation. To keep compiler satisfied.
-    //    mWlanEnabled = value.toInt() ? true : false;
-    
-    mWlanEnabled = true; //TODO: Replace with above code when WlanOnOff implementation is in release
-    
-    if (mWlanEnabled == false) {    
+    if (mWlanEnabled == false || mWlanForceDisabled == true) {    
         deactivateWlanIndicatorPlugin();
     } else {
         updateWlanIndicator();
@@ -204,7 +234,7 @@
 
     //We do not deactivate WlanIndicator plugin here as it is done in updateWlanRadioStatus method
     //as WLAN radio status determines whether to show indicator or not
-    if ( mWlanEnabled ) {
+    if ( mWlanEnabled && !mWlanForceDisabled) {
         if(count == 0) {
             list.insert(0, wlanNotConnected);
             activateWlanIndicatorPlugin(list);
@@ -280,6 +310,30 @@
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_HANDLECONFIGURATIONCHANGED_EXIT, "<--");
 }
 
+void IndicatorObserver::userActivateCellularIndicator(const QString &type, const QVariantMap &data)
+{
+    OstTrace0(TRACE_FLOW, INDICATOROBSERVER_USERACTIVATECELLULARINDICATOR_ENTRY, "-->");
+    
+    Q_UNUSED(data);
+    Q_UNUSED(type);
+    // Show connection view
+    QProcess::startDetached("connview");
+    
+    OstTrace0(TRACE_FLOW, INDICATOROBSERVER_USERACTIVATECELLULARINDICATOR_EXIT, "<--");
+}
+
+void IndicatorObserver::userActivateWlanIndicator(const QString &type, const QVariantMap &data)
+{
+    OstTrace0(TRACE_FLOW, INDICATOROBSERVER_USERACTIVATEWLANINDICATOR_ENTRY, "-->");
+    
+    Q_UNUSED(data);
+    Q_UNUSED(type);
+    // Show wlan list view
+    QProcess::startDetached("WlanSniffer");
+
+    OstTrace0(TRACE_FLOW, INDICATOROBSERVER_USERACTIVATEWLANINDICATOR_EXIT, "<--");
+}
+
 /*!
     IndicatorObserver::activateCellularIndicatorPlugin
 */
@@ -287,9 +341,8 @@
 {
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_ACTIVATECELLULARINDICATORPLUGIN_ENTRY, "-->");
     
-    HbIndicator indicator;    
-    bool success = indicator.activate("com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0", list);
-    
+    bool success = mCellularIndicator->activate("com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0", list);
+     
     if (!success) {
         mCellularIndicatorIsActivated = false;
         OstTrace0(TRACE_FLOW, INDICATOROBSERVER_CELLULAR_INDICATOR_ACTIVATION_FAILED, "Cellular indicator activation failed"); 
@@ -307,8 +360,7 @@
 {
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_DEACTIVATECELLULARINDICATORPLUGIN_ENTRY, "-->");
     
-    HbIndicator indicator;
-    indicator.deactivate("com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0");
+    mCellularIndicator->deactivate("com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0");
     mCellularIndicatorIsActivated = false;
     
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_DEACTIVATECELLULARINDICATORPLUGIN_EXIT, "<--");
@@ -320,10 +372,9 @@
 void IndicatorObserver::activateWlanIndicatorPlugin(QList<QVariant> list)
 {
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_ACTIVATEWLANINDICATORPLUGIN_ENTRY, "-->");
-
-    HbIndicator indicator;
-    bool success = indicator.activate("com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0", list);
     
+    bool success = mWlanIndicator->activate("com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0", list);
+   
     if (!success) {
         mWlanIndicatorIsActivated = false;
         OstTrace0(TRACE_FLOW, INDICATOROBSERVER_WLAN_INDICATOR_ACTIVATION_FAILED, "WLAN indicator activation failed"); 
@@ -341,8 +392,7 @@
 {
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_DEACTIVATEWLANINDICATORPLUGIN_ENTRY, "-->");
 
-    HbIndicator indicator;
-    indicator.deactivate("com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0");
+    mWlanIndicator->deactivate("com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0");
     mWlanIndicatorIsActivated = false;
     
     OstTrace0(TRACE_FLOW, INDICATOROBSERVER_DEACTIVATEWLANINDICATORPLUGIN_EXIT, "<--");   
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifInc/NetworkInfoArray.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifInc/NetworkInfoArray.h	Thu Jul 22 16:37:38 2010 +0100
@@ -83,7 +83,7 @@
         * @return index value of network in the array, or -1 if there
         * is no network the given Id
         */
-        TInt GetArrayIndex( TName aNetworkName ) const;
+        TInt GetArrayIndex( TName& aNetworkName ) const;
 
         /**
         * Add only new network to the array
@@ -125,4 +125,4 @@
         CArrayPtrFlat<CNetworkInfoBase>* iNetworkInfoArray;   ///< Owned.
     };
 
-#endif // NETWORKINFOARRAY_NOTIF_H_INCLUDED
\ No newline at end of file
+#endif // NETWORKINFOARRAY_NOTIF_H_INCLUDED
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifInc/WepWpaQueryDlg.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifInc/WepWpaQueryDlg.h	Thu Jul 22 16:37:38 2010 +0100
@@ -88,7 +88,7 @@
     * @param aResId resource id
     * @return -
     */
-    void CWepWpaQueryDlg::ShowInfoNoteL( TInt aResId );
+    void ShowInfoNoteL( TInt aResId );
     
     /**
     * PreLayoutDynInitL
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveOfflineWlanDisabledNote.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveOfflineWlanDisabledNote.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -19,7 +19,7 @@
 // INCLUDE FILES
 #include "ActiveOfflineWlanDisabledNote.h"
 
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <AknGlobalNote.h>
 #include <StringLoader.h>
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveSelectWLanDlgPlugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveSelectWLanDlgPlugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 // INCLUDE FILES
 #include <AknWaitDialog.h>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <AknGlobalNote.h>
 #include <StringLoader.h>
 #include <centralrepository.h>
@@ -84,7 +84,11 @@
 CActiveSelectWLanDlgPlugin::CActiveSelectWLanDlgPlugin( 
                                                 CSelectWLanDlgPlugin* aPlugin )
 : CActive( EPriorityStandard ), 
-  iPlugin( aPlugin )
+  iPlugin( aPlugin ),
+  iWlanDataProv( NULL ),
+  iPeriodic( NULL),
+  iResultsListDialog( NULL),
+  iWaitDialog( NULL )
     {
     }
     
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveWLANNetworkUnavailableNote.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveWLANNetworkUnavailableNote.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -19,7 +19,7 @@
 // INCLUDE FILES
 #include "ActiveWLANNetworkUnavailableNote.h"
 
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <AknGlobalNote.h>
 #include <StringLoader.h>
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ConnUiUtilsNotif.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ConnUiUtilsNotif.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -46,8 +46,9 @@
 //
 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
     {
-    CArrayPtrFlat<MEikSrvNotifierBase2>* array = new (ELeave) 
-                    CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity );
+    CArrayPtrFlat<MEikSrvNotifierBase2>* array = NULL;
+    TRAP_IGNORE( array = new (ELeave) 
+                    CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity ); )
 
     if ( array )
         {
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/EasyWepDlgNotif.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/EasyWepDlgNotif.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,7 +21,7 @@
 #include "WepWpaQueryDlg.h"
 #include "ConnUiUtilsNotif.h"
 
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <StringLoader.h>
 #include <featmgr.h>
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/EasyWpaDlgNotif.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/EasyWpaDlgNotif.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -21,7 +21,7 @@
 #include "WepWpaQueryDlg.h"
 #include "ConnUiUtilsNotif.h"
 
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <StringLoader.h>
 
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/NetworkInfoArray.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/NetworkInfoArray.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -37,6 +37,7 @@
 // ---------------------------------------------------------
 //
 CNetworkInfoArray::CNetworkInfoArray()
+: iNetworkInfoArray( NULL )
     {
     }
 
@@ -121,7 +122,7 @@
 // CNetworkInfoArray::GetArrayIndex
 // ---------------------------------------------------------
 //
-TInt CNetworkInfoArray::GetArrayIndex( TName aNetworkName ) const
+TInt CNetworkInfoArray::GetArrayIndex( TName& aNetworkName ) const
     {
     CLOG_ENTERFN( "CNetworkInfoArray::GetArrayIndex" );
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/NetworkInfoBase.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/NetworkInfoBase.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -19,7 +19,7 @@
 
 // INCLUDE FILES
 #include <StringLoader.h>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 
 #include "NetworkInfoBase.h"
 #include "ConnUiUtilsNotif.hrh"
@@ -35,9 +35,12 @@
 // ---------------------------------------------------------
 //
 CNetworkInfoBase::CNetworkInfoBase()
-: iOthersEntry( EFalse ),
-  iProtectedSetupSupported( EFalse )
-  
+: iSignalStrength( ESignalStrengthMin ),
+  iNetworkMode( ENetworkModeInfrastructure ),
+  iSecurityMode( EWlanConnectionSecurityOpen ),
+  iOthersEntry( EFalse ),
+  iProtectedSetupSupported( EFalse ),
+  iExtendedSecurityMode( EWlanConnectionExtentedSecurityModeOpen )
     {
     }
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/OfflineWlanNoteDlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/OfflineWlanNoteDlg.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -37,7 +37,8 @@
 // ---------------------------------------------------------
 //
 COfflineWlanNoteDlg::COfflineWlanNoteDlg( COfflineWlanNoteNotif* aNotif )
-: iNotif( aNotif )    
+: iNotif( aNotif ),
+  iExpiryTimer( NULL )
     {
     }
     
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/OfflineWlanNoteNotif.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/OfflineWlanNoteNotif.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -25,7 +25,7 @@
 
 #include <e32property.h>         // For RProperty 
 #include <UikonInternalPSKeys.h> // For KPSUidUikon and KUikGlobalNotesAllowed.
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 
 
 // ================= MEMBER FUNCTIONS =======================
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/SelectWLANDlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/SelectWLANDlg.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -26,7 +26,7 @@
 #include <aknnotewrappers.h>
 #include <aknnotedialog.h>
 #include <connectionuiutilities.mbg>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <StringLoader.h>
 #include <data_caging_path_literals.hrh>
 #include <uikon/eiksrvui.h>
@@ -65,7 +65,9 @@
 : CAknListQueryDialog( &aIndex ),
   iPlugin( aPlugin ),
   iNetworkArray( aNetworkArray ),
-  iFromOkToExit( EFalse )
+  iFromOkToExit( EFalse ),
+  iWaitDialog( NULL ),
+  iExpiryTimer( NULL )
     {
     }
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/WepWpaQueryDlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/WepWpaQueryDlg.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 #include <aknnotewrappers.h>
 #include <StringLoader.h>
 #include <aknnotedialog.h>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <uikon/eiksrvui.h>
 
 #include "WepWpaQueryDlg.h"
@@ -61,7 +61,8 @@
 : CAknTextQueryDialog( aDataText ),
   iNotif( aNotif ), 
   iDialogType( aDialogType ), 
-  iHex( aHex )
+  iHex( aHex ),
+  iExpiryTimer( NULL)
     {
     }
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/WlanNetworkDataProvider.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/WlanNetworkDataProvider.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -64,7 +64,12 @@
 // ---------------------------------------------------------
 //
 CWlanNetworkDataProvider::CWlanNetworkDataProvider() 
-: CBase()
+: CBase(),
+#ifndef __WINS__
+  iWlanMgmt( NULL ),
+  iScanInfo( NULL ),
+#endif // !__WINS__
+  iNetworkInfoArray( NULL )
     {
     }
 
@@ -85,7 +90,7 @@
         }
     delete iWlanMgmt;
     delete iScanInfo;
-#endif
+#endif // !__WINS__
 
     CLOG_LEAVEFN( "CWlanNetworkDataProvider::~CWlanNetworkDataProvider" );
     }
@@ -277,7 +282,7 @@
                                    TWlanConnectionExtentedSecurityMode aExtSecurityMode,
                                    TBool aProtectedSetupSupported )
     {
-    TBuf<KWlanMaxSsidLength> networkName16;
+    TName networkName16;
     networkName16.Copy( aNetworkName );
     TInt index = iNetworkInfoArray->GetArrayIndex( networkName16 );
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/cellulardataconfirmation.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/cellulardataconfirmation.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,7 @@
 
 // INCLUDE FILES
 #include <StringLoader.h>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <hb/hbcore/hbsymbianvariant.h>
 #include "ConnectionDialogsLogger.h"
 #include "cellulardataconfirmation.h"
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/easywapidlgnotif.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/easywapidlgnotif.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -20,7 +20,7 @@
 #include "WepWpaQueryDlg.h"
 #include "ConnUiUtilsNotif.h"
 
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <StringLoader.h>
 
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/nowlansdiscreetpopup.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/nowlansdiscreetpopup.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -22,7 +22,7 @@
 #include <StringLoader.h>
 #include <avkon.hrh>
 #include <connectionuiutilities.mbg>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 
 #include "nowlansdiscreetpopup.h"
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/wlanpowersavetest.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/wlanpowersavetest.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 
 #include <uikon/eiksrvui.h>
 #include <StringLoader.h>
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 
 // ================= MEMBER FUNCTIONS =======================
 //
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/wlanpowersavetestnotif.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/wlanpowersavetestnotif.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 #include "ConnUiUtilsNotif.h"
 #include "ConnectionDialogsLogger.h"
 
-#include <ConnUiUtilsNotif.rsg>
+#include <connuiutilsnotif.rsg>
 #include <StringLoader.h>
 
 #include <ConnectionUiUtilities.h>
@@ -39,7 +39,9 @@
 //
 CWlanPowerSaveQueryNotif::CWlanPowerSaveQueryNotif()
     :
-    iDisable( EFalse )
+    iDialog( NULL ),
+    iDisable( EFalse ),
+    iExitAsync( NULL )
     {
     }
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/inc/ChangeConnectionDlg.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/inc/ChangeConnectionDlg.h	Thu Jul 22 16:37:38 2010 +0100
@@ -102,15 +102,6 @@
         */
         void HandleTimedOut();
 
-    private:  // New functions
-
-        /**
-        * Sets graphic icons
-        * @param    -
-        */
-        void SetIconsL();
-
-
     private: //data
         TUint32*            iIAPId;
         TBuf<CommsDat::KMaxTextLength> iConnectionName;
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/inc/connectionstatuspopup.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/inc/connectionstatuspopup.h	Thu Jul 22 16:37:38 2010 +0100
@@ -136,6 +136,32 @@
     
     // The state of the popup
     TPopupState iPopupState;
+    
+    enum TTouchAction
+        {
+        /**
+         * Do nothing
+         */
+        EDoNothing,
+        
+        /**
+         * Open WLAN view
+         */
+        EOpenWlanView,
+        
+        /**
+         *  Open connection view
+         */
+        EOpenCellularView,
+        
+        };
+    
+    /**
+     * Indicates what to do when popup is activated (tapped) and
+     * enables/disables touch activation based on value.
+     */
+    TTouchAction iTouchAction;
+    
     };
 
 #endif /* __CCONNECTIONSTATUSPOPUP_H_ */
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ActiveCChangeConnectionDlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ActiveCChangeConnectionDlg.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -26,7 +26,7 @@
 #include <wlanmgmtclient.h>
 #endif
 
-#include <ConnectionUiUtilities.rsg>
+#include <connectionuiutilities.rsg>
 
 #include "ActiveCChangeConnectionDlg.h"
 #include "ChangeConnectionDlg.h"
@@ -81,7 +81,8 @@
                                             TUint32* aIAPId, 
                                             const TConnectionPrefs& aPrefs,
                                             TDes& aConnectionName  ) 
-: CActiveIAPListing( aPrefs ), 
+: CActiveIAPListing( aPrefs ),
+  iDialog( NULL ),
   isDialogDeleting( EFalse ),
   iIAPId( aIAPId ),
   iConnectionName( aConnectionName ),
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ActiveWrapper.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ActiveWrapper.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -71,7 +71,15 @@
 //
 CActiveWrapper::CActiveWrapper( const TUint aIndexOfNote ) 
 : CActive( CActive::EPriorityStandard ),
-  iIndexOfNote( aIndexOfNote )
+  iSSID( NULL ),
+  iConnectionMode( NULL ),
+  iSecurityMode( NULL ),
+  iExtSecurityMode( NULL ),
+  iProtectedSetupSupported( NULL ),
+  iRS( NULL ),
+  iIndexOfNote( aIndexOfNote ),
+  iKey( NULL ),
+  iHex( NULL )
     {
     }
 
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ChangeConnectionDlg.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ChangeConnectionDlg.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -27,8 +27,7 @@
 #include <WlanCdbCols.h>
 
 #include <data_caging_path_literals.hrh>
-#include <ConnectionUiUtilities.rsg>
-#include <apsettings.mbg>
+#include <connectionuiutilities.rsg>
 
 #include "ChangeConnectionDlg.h"
 #include "ActiveCChangeConnectionDlg.h"
@@ -37,18 +36,10 @@
 
 // CONSTANTS
 
-// ROM folder
-_LIT( KDriveZ, "z:" );
-
-// Name of the MBM file containing icons
-_LIT( KFileIcons, "ApSettings.mbm" );
-
 #if defined(_DEBUG)
 _LIT( KErrNullPointer, "NULL pointer" );
 #endif
 
-LOCAL_D const TInt KIconsGranularity = 4;
-
 
 // ================= MEMBER FUNCTIONS =======================
 
@@ -61,7 +52,8 @@
   iIAPId( aIAPId ),
   iConnectionName( aConnectionName ),
   iIsWLANFeatureSupported( EFalse ),
-  iActiveDlg( aActiveDlg )
+  iActiveDlg( aActiveDlg ),
+  iExpiryTimer( NULL )
     {
     }
 
@@ -166,8 +158,6 @@
     SetItemTextArray( iActiveDlg->ActIAPs() );       
     SetOwnershipType( ELbmDoesNotOwnItemArray );
 
-    SetIconsL();
-    
     // Timer not in use due the unresolved crash
     //iExpiryTimer = CExpiryTimer::NewL( *this );
     //iExpiryTimer->Start();
@@ -196,67 +186,6 @@
     }
 
 
-// ---------------------------------------------------------
-// CChangeConnectionDlg::SetIconsL()
-// ---------------------------------------------------------
-//
-void CChangeConnectionDlg::SetIconsL()
-    {
-    CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( 
-                                                        KIconsGranularity );
-    CleanupStack::PushL( icons );
-
-    MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
-
-    TFileName iconsFileName;
-
-    iconsFileName.Append( KDriveZ );
-
-    iconsFileName.Append( KDC_APP_BITMAP_DIR );
-
-    iconsFileName.Append( KFileIcons );
-
-    icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
-                            KAknsIIDQgnPropWmlGprs,
-                            iconsFileName, 
-                            EMbmApsettingsQgn_prop_wml_gprs, 
-                            EMbmApsettingsQgn_prop_wml_gprs_mask ) );
-
-    icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
-                            KAknsIIDQgnPropWmlCsd,
-                            iconsFileName, 
-                            EMbmApsettingsQgn_prop_wml_csd, 
-                            EMbmApsettingsQgn_prop_wml_csd_mask ) );
-
-    icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
-                            KAknsIIDQgnPropWmlHscsd,
-                            iconsFileName, 
-                            EMbmApsettingsQgn_prop_wml_hscsd, 
-                            EMbmApsettingsQgn_prop_wml_hscsd_mask ) );
-
-    if ( iIsWLANFeatureSupported )
-        {
-        icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
-                            KAknsIIDQgnPropWlanEasy,
-                            iconsFileName, 
-                            EMbmApsettingsQgn_prop_wlan_easy, 
-                            EMbmApsettingsQgn_prop_wlan_easy_mask ) );
-    
-        icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
-                            KAknsIIDQgnPropWlanBearer,
-                            iconsFileName, 
-                            EMbmApsettingsQgn_prop_wlan_bearer, 
-                            EMbmApsettingsQgn_prop_wlan_bearer_mask ) );
-        }
-    
-    SetIconArrayL( icons );
-
-    CleanupStack::Pop( icons );
-    }
-
-
-
-
 // ----------------------------------------------------------------------------
 // void CChangeConnectionDlg::HandleResourceChange( TInt aType )
 // Handle resource change events. 
@@ -268,7 +197,6 @@
         {
         CAknListQueryDialog::HandleResourceChange( aType );
 
-        TRAP_IGNORE( SetIconsL() );
         SizeChanged();
         }
     else
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ConnectionUiUtilitiesImpl.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ConnectionUiUtilitiesImpl.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -46,7 +46,7 @@
 #include "ActiveCChangeConnectionDlg.h"
 #include "connectionstatuspopup.h"
 
-#include <ConnectionUiUtilities.rsg>
+#include <connectionuiutilities.rsg>
 #include <data_caging_path_literals.hrh>
 
 #include "ConnectionDialogsLogger.h"
@@ -85,7 +85,11 @@
 //
 CConnectionUiUtilitiesImpl::CConnectionUiUtilitiesImpl() 
 : iResOffset( 0 ),
-  iIsWlanSupported( EFalse )
+  iIsWlanSupported( EFalse ),
+  iDummy( EFalse ),
+  iDummySecMode( EWlanConnectionSecurityOpen ),
+  iDummyExtSecMode( EWlanConnectionExtentedSecurityModeOpen ),
+  iConnStatusPopup( NULL )
     {
     for ( TInt i = 0; i < KNumberOfWrappedDialogs; i++ )
         {
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/connectionstatuspopup.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/connectionstatuspopup.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -35,22 +35,22 @@
 
 // Error code definitions are from these headers
 #include <wlanerrorcodes.h> // WLAN-specific error code definitions
+#include <gsmerror.h>       // KErrPacketDataTsyMaxPdpContextsReached 
 #include <in_iface.h>
-#include <etelpckt.h>       // GPRS-specific causes for Session Managemeei saant
+#include <etelpckt.h>       // GPRS-specific causes for Session Management
 #include <nd_err.h>         // NetDial errors
 #include <inet6err.h>       // IPv6 error constants
 #include <rmmcustomapi.h>
 
 // Errors in UI spec not found elsewhere
-const TInt KErrPDPMaxContextsReached    = -6000;
 const TInt KErrDndNameNotFound          = -5120;
 const TInt KErrGeneralConnection        = -50000;
 const TInt KErrGenConnNoGPRSNetwork     = -3609;
 
 // Icons representing bearer
-_LIT( KIconCellular, "pri_small_wlan.svg" );
-_LIT( KIconWlan,     "pri_small_gprs.svg" );
-_LIT( KIconVpn,      "pri_small_vpn.svg" ); 
+_LIT( KIconCellular, "qtg_small_gprs" );
+_LIT( KIconWlan,     "qtg_small_wlan" );
+_LIT( KIconVpn,      "qtg_small_vpn" ); 
 _LIT( KIconNone,     "" );
 
 // Empty text
@@ -96,6 +96,10 @@
         "txt_occ_dpopinfo_connection_unavailable");
 _LIT(Ktxt_occ_dpophead_configuration_failed,
         "txt_occ_dpophead_configuration_failed");
+_LIT(Ktxt_occ_dpophead_maximum_connections_in_use,
+        "txt_occ_dpophead_maximum_connections_in_use");
+_LIT(Ktxt_occ_dpopinfo_select_to_manage,
+        "txt_occ_dpopinfo_select_to_manage");
 
 
 //-----------------------------------------------------------------------------
@@ -103,7 +107,7 @@
 //-----------------------------------------------------------------------------
 //
 CConnectionStatusPopup::CConnectionStatusPopup()
-:iPopup( NULL ), iPopupState( EPopupClosed )
+:iPopup( NULL ), iPopupState( EPopupClosed ), iTouchAction( EDoNothing )
     {
     }
 
@@ -176,6 +180,8 @@
         iPopup->SetTextL( KTextNone );
         iPopup->SetIconNameL( KIconNone );
         );
+    iTouchAction = EDoNothing;
+    iPopup->SetTimeout( KForeverTimeout );
 
     SetState( EPopupConnecting );
  
@@ -205,6 +211,7 @@
         }
     else
         {
+        iPopup->SetTimeout( KForeverTimeout );
         SetState( EPopupConnectingIap );
         }
     
@@ -239,6 +246,7 @@
     
     if (showPopup)
         {
+        iPopup->SetTimeout( KHbLongNotificationDialogTimeout ); 
         SetState( EPopupError );
         }
 
@@ -252,37 +260,12 @@
 void CConnectionStatusPopup::SetState( TPopupState aNewState )
     {
     OstTraceExt2( TRACE_FLOW, CCONNECTIONSTATUSPOPUP_SETSTATE, "CConnectionStatusPopup::SetState;iPopupState=%u;aNewState=%u", iPopupState, aNewState );
-    
-    switch (aNewState)
-        {
-        
-        case EPopupClosed:
-            // Close popup if it's not already closing or closed
-            if (iPopupState != EPopupClosed && iPopupState != EPopupError)
-                {
-                iPopup->Close();
-                }
-            break;
-            
-        case EPopupConnecting:
-            iPopup->EnableTouchActivation( EFalse );
-            iPopup->SetTimeout( KForeverTimeout );
-            break;
-            
-        case EPopupConnectingIap:
-            iPopup->EnableTouchActivation( ETrue );
-            iPopup->SetTimeout( KForeverTimeout );
-            break;
-            
-        default: // EPopupError
-            __ASSERT_DEBUG( aNewState == EPopupError, User::Invariant() );
-            iPopup->EnableTouchActivation( EFalse );
-            iPopup->SetTimeout( KHbLongNotificationDialogTimeout ); 
-            break;
-        }
-    
+
     if (aNewState != EPopupClosed)
         {
+        // Enable touch activation based on defined action
+        iPopup->EnableTouchActivation( iTouchAction != EDoNothing );
+
         // Show or update popup
         if (iPopupState == EPopupClosed)
             {
@@ -293,6 +276,14 @@
             TRAP_IGNORE( iPopup->UpdateL() );
             }
         }
+    else
+        {
+        // Close popup if it's not already closed or closing 
+        if (iPopupState != EPopupClosed && iPopupState != EPopupError)
+            {
+            iPopup->Close();
+            }
+        }
     
     iPopupState = aNewState;
     }
@@ -338,16 +329,19 @@
         }
     CleanupStack::PopAndDestroy( connectionName ); 
 
-    // Icon
+    // Icon and action
     switch (bearerType)
         {
         case KUidWlanBearerType:
+            iTouchAction = EOpenWlanView;
             iPopup->SetIconNameL( KIconWlan );
             break;
         case KPluginVPNBearerTypeUid:
+            iTouchAction = EDoNothing;
             iPopup->SetIconNameL( KIconVpn );
             break;
         default:
+            iTouchAction = EOpenCellularView;
             iPopup->SetIconNameL( KIconCellular );
         }
     
@@ -365,12 +359,22 @@
     // Icons, which are resolved at the end
     enum TIconType
         {
-        EIconWlan, EIconCellular, EIconNone
+        // WLAN icon
+        EIconWlan, 
+        // Cellular icon
+        EIconCellular, 
+        // No icon to be used
+        EIconNoneSet, 
+        // Icon from connecting popup to be used
+        EIconUsePreviouslyDefined
         };
+
+    // Most errors have following values
     TIconType icon = EIconWlan;
-
+    iTouchAction = EDoNothing;
     TPtrC titlePtr;
     titlePtr.Set( Ktxt_occ_dpophead_connection_failed );
+    
     TPtrC textPtr;
 
     // Resolve title, text and icon of error code.
@@ -478,9 +482,6 @@
             break;
 
         // Group 9
-        case KErrPDPMaxContextsReached:
-            icon = EIconCellular;
-            // These were GPRS; fall through
         case KErrWlanConnAlreadyActive:
             textPtr.Set( Ktxt_occ_dpopinfo_connection_already_active );
             break;
@@ -503,7 +504,6 @@
         case KErrGeneralConnection:
         case KErrGprsMSCTemporarilyNotReachable:
         case KErrGprsLlcOrSndcpFailure:
-        case KErrGprsInsufficientResources:
         case KErrGprsActivationRejectedByGGSN:
         case KErrPacketDataTsyInvalidAPN:
             icon = EIconCellular;
@@ -526,7 +526,11 @@
         case KErrGprsNSAPIAlreadyUsed:
         case KErrGprsQoSNotAccepted:
         case KErrGprsReactivationRequested:
+        case KErrGprsOfflineMode:
             icon = EIconCellular;
+            // These were GPRS; fall through
+        case KErrWlanOff:
+        case KErrWlanForceOff:
             textPtr.Set( Ktxt_occ_dpopinfo_connection_unavailable );
             break;
 
@@ -557,11 +561,25 @@
             titlePtr.Set( Ktxt_occ_dpophead_configuration_failed );
             textPtr.Set( Ktxt_occ_dpopinfo_please_try_again );
             break;
-
+            
+        // Group 15, errors related to maximum number of PDP contexts
+        case KErrGprsInsufficientResources:
+        case KErrUmtsMaxNumOfContextExceededByNetwork: 
+        case KErrUmtsMaxNumOfContextExceededByPhone:
+        case KErrPacketDataTsyMaxPdpContextsReached:
+            // Open cellular view for these errors
+            iTouchAction = EOpenCellularView;
+            // The icon is left out from these popups in order to make room 
+            // for the text which needs to be as descriptive as possible
+            icon = EIconNoneSet;
+            titlePtr.Set( Ktxt_occ_dpophead_maximum_connections_in_use );
+            textPtr.Set( Ktxt_occ_dpopinfo_select_to_manage );
+            break;
+            
         // For error values not specifically mapped to any error message
         // the discreet pop-up #12 is used.
         default:
-            icon = EIconNone;
+            icon = EIconUsePreviouslyDefined;
             textPtr.Set( Ktxt_occ_dpopinfo_connection_unavailable );
             break;
         }
@@ -581,8 +599,11 @@
         case EIconCellular:
             iPopup->SetIconNameL( KIconCellular );
             break;
+        case EIconNoneSet:
+            iPopup->SetIconNameL( KIconNone );
+            break;
         default:
-            __ASSERT_DEBUG( icon == EIconNone, User::Invariant());
+            __ASSERT_DEBUG( icon == EIconUsePreviouslyDefined, User::Invariant());
             // Leave icon as-is, either set by ConnectingViaDiscreetPopup
             // or undefined.
             break;
@@ -602,13 +623,13 @@
     {
     OstTraceFunctionEntry0( CCONNECTIONSTATUSPOPUP_NOTIFICATIONDIALOGACTIVATED_ENTRY );
     
-    // Launch wlan view or connection view depending of bearer
+    // Launch wlan view or connection view depending on bearer
     TPtrC procName; 
-    if (iPopup->IconName().Compare( KIconWlan ) == 0)
+    if ( iTouchAction == EOpenWlanView )
         {
         procName.Set( KWlanViewExeFile );
         }
-    else if (iPopup->IconName().Compare( KIconCellular ) == 0)
+    else if ( iTouchAction == EOpenCellularView )
         {
         procName.Set( KConnViewExeFile );
         }
--- a/connectionutilities/ConnectionDialogs/DisconnectDlg/src/ConnectionInfo.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/DisconnectDlg/src/ConnectionInfo.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -26,7 +26,7 @@
 #include <apgcli.h>
 #include <AknsUtils.h>
 
-#include <DisconnectDlg.rsg>
+#include <disconnectdlg.rsg>
 #include <disconnectdlgui.mbg>
 #include <data_caging_path_literals.hrh>
 
--- a/connectionutilities/ConnectionDialogs/DisconnectDlg/src/ConnectionModel.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/DisconnectDlg/src/ConnectionModel.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -34,7 +34,7 @@
 #include <commsdat_partner.h>
 #endif
 
-#include <DisconnectDlg.rsg>
+#include <disconnectdlg.rsg>
 
 
 // CONSTANTS
--- a/connectionutilities/ConnectionDialogs/DisconnectDlg/src/DisconnectDlgDialog.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/DisconnectDlg/src/DisconnectDlgDialog.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-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"
@@ -12,8 +12,7 @@
 * Contributors:
 *
 * Description: 
-*     Defines the pop-up selection list with the active connections.
-*
+* Defines the pop-up selection list with the active connections.
 */
 
 
@@ -26,7 +25,7 @@
 #include "ConnectionDialogsLogger.h"
 #include "ExpiryTimer.h"
 
-#include <DisconnectDlg.rsg>
+#include <disconnectdlg.rsg>
 #include <AknIconArray.h>
 #include <StringLoader.h>
 #include <uikon/eiksrvui.h>
@@ -222,19 +221,17 @@
         TInt result = iConnModel->EndConnection( toBeClosedItem );
         iDisconnectDialogUi->iDialogRun = EFalse;
         if ( result )
-            {
-            TInt resId = R_QTN_CMON_INFO_CONN_ALREADY_END;
+            {            
             if( KNullUnit == result )
                 {
                 result = KErrNone;
                 }
             else
-                {
-                resId = R_QTN_NETW_INFO_DISCONNECT_FAILED;
+                {               
+                iConnModel->InfoNoteL( R_QTN_NETW_INFO_DISCONNECT_FAILED );
                 result = KErrGeneral;
                 }
-
-            iConnModel->InfoNoteL( resId );
+            
             iDisconnectDialogUi->CompleteL( result );
             }
         }
--- a/connectionutilities/ConnectionDialogs/DisconnectDlg/src/DisconnectDlgUi.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/DisconnectDlg/src/DisconnectDlgUi.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -29,7 +29,7 @@
 #include <bautils.h>
 #include <textresolver.h>
 
-#include <DisconnectDlg.rsg>
+#include <disconnectdlg.rsg>
 #include <data_caging_path_literals.hrh>
 
 
--- a/connectionutilities/ConnectionDialogs/cconndlg/inc/ConnDlgPlugin.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/cconndlg/inc/ConnDlgPlugin.h	Thu Jul 22 16:37:38 2010 +0100
@@ -163,7 +163,7 @@
                                             public CConnectionDialogsNotifBase
     {
 public:
-    CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin();
+    CConnDlgAuthenticationPlugin();
 
     /**
     * NewL function
--- a/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -59,8 +59,9 @@
 
 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
     {
-    CArrayPtrFlat<MEikSrvNotifierBase2>* array = new (ELeave) 
-                    CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity );
+    CArrayPtrFlat<MEikSrvNotifierBase2>* array = NULL;
+    TRAP_IGNORE( array = new (ELeave) 
+                    CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity ); )
 
     if ( array )
         {
--- a/connectionutilities/ConnectionDialogs/group/ConnUiUtilsNotif.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/group/ConnUiUtilsNotif.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -91,13 +91,10 @@
 
 SYSTEMINCLUDE   /epoc32/include/libc 
 SYSTEMINCLUDE   /epoc32/include/uikon
-SYSTEMINCLUDE   /epoc32/include/mw/hb/hbcore
-SYSTEMINCLUDE   /epoc32/include/mw/hb/hbwidgets
-
 
 LIBRARY     euser.lib eikdlg.lib eiksrv.lib cone.lib eikcore.lib eikcoctl.lib
 LIBRARY     bafl.lib avkon.lib AknSkins.lib Ecom.lib 
-LIBRARY		eiksrvui.lib
+LIBRARY     eiksrvui.lib
 LIBRARY     commonengine.lib
 LIBRARY     AKNNOTIFY.LIB
 LIBRARY     AknIcon.lib
@@ -109,7 +106,7 @@
 LIBRARY     charconv.lib
 
 LIBRARY     commdb.lib
-LIBRARY		  cmmanager.lib
+LIBRARY     cmmanager.lib
 LIBRARY     etel3rdparty.lib 
 LIBRARY     HbCore.lib
 LIBRARY     HbWidgets.lib
--- a/connectionutilities/ConnectionDialogs/group/ConnectionUiUtilities.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/group/ConnectionUiUtilities.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -23,6 +23,7 @@
 
 TARGET      ConnectionUiUtilities.dll
 TARGETTYPE  DLL
+UID         0x1000008d 0x2002FF74
 
 CAPABILITY CAP_GENERAL_DLL
 VENDORID VID_DEFAULT
--- a/connectionutilities/ConnectionDialogs/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 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"
@@ -27,7 +27,6 @@
 // export iby files
 ../rom/agentdialog.iby				CORE_MW_LAYER_IBY_EXPORT_PATH(agentdialog.iby)
 ../rom/cconndlg.iby				CORE_MW_LAYER_IBY_EXPORT_PATH(cconndlg.iby)
-../rom/cconndlgResources.iby			LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(cconndlgResources.iby)
 
 ../rom/ConnectionDialogs.iby			CORE_MW_LAYER_IBY_EXPORT_PATH(ConnectionDialogs.iby)
 
--- a/connectionutilities/ConnectionDialogs/inc/ConnectionInfo.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/inc/ConnectionInfo.h	Thu Jul 22 16:37:38 2010 +0100
@@ -102,7 +102,7 @@
         * Returns iId member
         * @return iId member
         */
-        inline const TUint32 Id() const;
+        inline TUint32 Id() const;
 
         /**
         * ListItem() function
@@ -123,7 +123,7 @@
         * Returns iVPN_iap_id member
         * @return iVPN_iap_id member
         */
-        inline const TUint32 VPNIapId() const;
+        inline TUint32 VPNIapId() const;
 
 
         /**
@@ -131,7 +131,7 @@
         * Returns iDestinationId member
         * @return iDestinationId member
         */
-        inline const TUint32 DestinationId() const;
+        inline TUint32 DestinationId() const;
 
 
         /**
@@ -139,7 +139,7 @@
         * Tells if connection is VPN
         * @return ETrue if connection is VPN
         */
-        inline const TBool IsVPN() const;
+        inline TBool IsVPN() const;
 
 
     private:    // Data
--- a/connectionutilities/ConnectionDialogs/inc/ConnectionInfo.inl	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/inc/ConnectionInfo.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -28,7 +28,7 @@
 // CConnectionInfo::Id
 // ---------------------------------------------------------
 //
-const TUint32 CConnectionInfo::Id() const
+TUint32 CConnectionInfo::Id() const
     {
     return iId;
     }
@@ -58,7 +58,7 @@
 // CConnectionInfo::VPNIapId()
 // ---------------------------------------------------------
 //
-const TUint32 CConnectionInfo::VPNIapId() const
+TUint32 CConnectionInfo::VPNIapId() const
     {
     return iVPN_iap_id;
     }
@@ -68,7 +68,7 @@
 // CConnectionInfo::DestinationId()
 // ---------------------------------------------------------
 //
-const TUint32 CConnectionInfo::DestinationId() const
+TUint32 CConnectionInfo::DestinationId() const
     {
     return iDestinationId;
     }
@@ -78,7 +78,7 @@
 // CConnectionInfo::VPNIapId()
 // ---------------------------------------------------------
 //
-const TBool CConnectionInfo::IsVPN() const
+TBool CConnectionInfo::IsVPN() const
     {
     return iIsVPN;
     }
--- a/connectionutilities/ConnectionDialogs/rom/cconndlgResources.iby	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#ifndef __CCONNDLGRESOURCES_IBY__
-#define __CCONNDLGRESOURCES_IBY__
-
-data=DATAZ_\RESOURCE_FILES_DIR\CConndlgplugin.rsc	RESOURCE_FILES_DIR\CConndlgplugin.rsc
-
-#endif
\ No newline at end of file
--- a/connectionutilities/ConnectionDialogs/src/ActiveIAPListing.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/src/ActiveIAPListing.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -92,10 +92,16 @@
 CActiveIAPListing::CActiveIAPListing( const TConnectionPrefs& aPrefs )
 : CActive( EPriorityUserInput ), 
   iDb( NULL ), 
+  iPeriodic( NULL ),
   iWaitDialog( NULL ), 
 #ifndef __WINS__
   iWlanMgmt( NULL ),
 #endif // !__WINS__
+  iIAPs( NULL ),
+  iWlanIAPs( NULL ),
+  iActIAPs( NULL ),
+  iClientStatus( NULL ),
+  iIsWLANFeatureSupported( EFalse ),
   iPrefs( aPrefs )
     {
     }
--- a/connectionutilities/ConnectionDialogs/src/ConnectionDialogsNotifBase.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/src/ConnectionDialogsNotifBase.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -88,9 +88,13 @@
 // ---------------------------------------------------------
 //
 CConnectionDialogsNotifBase::CConnectionDialogsNotifBase()
-: iCancelled( EFalse ), 
+: iReplySlot( 0 ),
+  iCancelled( EFalse ),
   iResource( 0 )
     {
+    iInfo.iUid = TUid::Null();
+    iInfo.iChannel = TUid::Null();
+    iInfo.iPriority = 0;
     }
 
 
--- a/connectionutilities/ConnectionDialogs/src/ConnectionInfoKey.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/ConnectionDialogs/src/ConnectionInfoKey.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -29,7 +29,9 @@
 //
 CConnectionInfoKey::CConnectionInfoKey( TBool aIsWLANFeatureSupported )
 : TKeyArrayFix( 0, ECmpCollated ),
-  iIsWLANFeatureSupported( aIsWLANFeatureSupported )
+  iPtr( NULL ),
+  iIsWLANFeatureSupported( aIsWLANFeatureSupported ),
+  iNameEasyWLAN( NULL )
     {
     }
 
--- a/connectionutilities/confirmqueries/src/cellularpromptdialog.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/connectionutilities/confirmqueries/src/cellularpromptdialog.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -15,7 +15,7 @@
 *
 */
 
-#include <QTranslator>
+#include <HbTranslator>
 #include <QLocale>
 #include <QList>
 #include <HbLabel>
@@ -45,12 +45,8 @@
     OstTraceFunctionEntry0( CELLULARPROMPTDIALOG_CELLULARPROMPTDIALOG_ENTRY );
 
     // Install localization
-    QTranslator *translator = new QTranslator(this);
-    QString lang = QLocale::system().name(); 
-    QString path = "Z:/resource/qt/translations/"; 
-    translator->load("cellularpromptdialog_" + lang, path);
-    qApp->installTranslator(translator);
-    
+    HbTranslator *translator(new HbTranslator("cellularpromptdialog"));
+
     createDialog(parameters);
     mClose = false;
     
Binary file data/cccccc00_emulator.cre has changed
--- a/dbcreator/commsdatcreator/Inc/cdcprocessordn.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Inc/cdcprocessordn.h	Thu Jul 22 16:37:38 2010 +0100
@@ -114,14 +114,7 @@
         * Writes the actual created access point to the log file.
         */
         void DoLogL();
-    
-    private:
-        /**
-        * Tells whether the current destination has the internet metadata set.
-        * @return ETrue if the destination is Internet, EFalse otherwise.
-        */
-//        TBool IsInternet();
-        
+            
     private:
     
         // @var The destiantion that is created
@@ -147,4 +140,4 @@
 #endif PROCESSOR_DN_H
 
 
-// End of File.
\ No newline at end of file
+// End of File.
--- a/dbcreator/commsdatcreator/Inc/cdcprocessorglobal.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Inc/cdcprocessorglobal.h	Thu Jul 22 16:37:38 2010 +0100
@@ -62,12 +62,8 @@
                                 RPointerArray< RCmConnectionMethodExt >& aPluginArray,
                                 RPointerArray< HBufC >& aPluginNames, 
                                 RPointerArray< RCmDestinationExt >& aDestArray,
-                                RPointerArray< HBufC >& aDestNames,
-                                RPointerArray< HBufC >& aDefCon );
+                                RPointerArray< HBufC >& aDestNames );
 
-        // Stores the default connection values
-     //   void SetDefaultConnectionL();
-        
         /**
         * Destructor.
         */
@@ -84,8 +80,7 @@
                           RPointerArray< RCmConnectionMethodExt >& aPluginArray,
                           RPointerArray< HBufC >& aPluginNames, 
                           RPointerArray< RCmDestinationExt >& aDestArray,
-                          RPointerArray< HBufC >& aDestNames,
-                          RPointerArray< HBufC >& aDefCon);
+                          RPointerArray< HBufC >& aDestNames );
                           
         /**
         * Second phase constructor. Leaves on failure.
@@ -119,22 +114,7 @@
         void UpdateGlobalBearerArrayL
                             ( TDbCreatorGlobalSettings aField, TUint32 aPrio );
                 
-        /**
-        * Sets the value of default connection type parsing and converting
-        *                           the param string to the right enum. 
-        * @param aPtrTag string of the type.
-        */
-        void SetDefaultConnectionTypeL( HBufC16* aPtrTag );
-                            
-        /**
-        * Sets the id of default connection method. It founds the connection
-        *     method or destination corresponding to the given name.
-        *     Type depends on the default connection type.
-        *     If the method/destination cannot be found then no id is set.
-        * @param aPtrTag string of the connection method/destination name.
-        */
-        void SetDefaultConnectionNameL( HBufC16* aPtrTag );
-
+                         
         /**
         * Sets the WLAN Usage parameter in general connection settings.
         * @param aPtrTag string containing the parameter's value.
@@ -158,9 +138,6 @@
         // Stores the general connection settings, using CMM
         void SetGenConnSettingsL();
         
-        // Stores the default connection's values, using CMM
-        void SetDefConnRecordL( const TInt aId );
-        
         // Stores the WLAN parameters
         void SaveGlobalWlanParameterL( const TUint32 aTableType, 
         							   const TDbCreatorGlobalSettings aField, 
@@ -168,9 +145,6 @@
 
     private:
         
-        // @var Default connection's data
-        TCmDefConnType iDefaultConnectionType;
-        TBool iDefaultConnectionSet;
 
         // @var GPRS attach mode : whenneeded/whenavailable
         TBool  iAttachWhenNeeded;
@@ -178,9 +152,6 @@
         RArray< TBearerPriority > iBearerArray;
         TBool iBearerArrayChanged;
         
-        // @var Stores the default connection type / name pair
-        RPointerArray< HBufC >* iDefCon; 
-        
         // @var Stores the general connection settings
         TCmGenConnSettings* iGenConnSettings;
         
--- a/dbcreator/commsdatcreator/Inc/cdcprocessorvpn.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Inc/cdcprocessorvpn.h	Thu Jul 22 16:37:38 2010 +0100
@@ -84,12 +84,8 @@
                        RPointerArray< HBufC >& aUnderLying );
         
         /**
-        * From CProcessorBase. Processes the actual tag.
-        * @param aFieldIDPresent shows if field id is read from input file
-        * @return the result of the process, KErrNone if the actual tag is
-        * valid.
+        * From CProcessorBase. 
         */
-        ////virtual void ProcessTagL( TBool aFieldIDPresent );
         virtual void ProcessSpecialFieldsL( TInt aField, HBufC* aTagPtr, TInt aDx );
 
     private:
@@ -105,4 +101,4 @@
 #endif PROCESSOR_VPN_H
 
 
-// End of File.
\ No newline at end of file
+// End of File.
--- a/dbcreator/commsdatcreator/Inc/cdcprocessorwlan.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Inc/cdcprocessorwlan.h	Thu Jul 22 16:37:38 2010 +0100
@@ -28,7 +28,8 @@
 #include <cmmanagerext.h>
 #include <cmconnectionmethodext.h>
 #include <metadatabase.h>
-#include <EapSettings.h>
+#include <EapGeneralSettings.h>
+#include <EapExpandedType.h>
 
 #include "cdcprocessorbase.h"
 
@@ -49,7 +50,7 @@
         ~CEapTypeElement();
 		HBufC* iName;
         EAPSettings* iEapSettings; 
-        EAPSettings::TEapType iEncapsulatingEapId;
+        TEapExpandedType iEncapsulatingEapId; 
         };
 
 
@@ -220,6 +221,13 @@
         void SaveWPAL( TUint32 aIapId );
         
         /**
+        * Gets the expanded EAP type
+        * @param aFieldId is the id of the field 
+        * @return expanded EAP type
+        */
+        TEapExpandedType GetExpandedEapTypeIdL( TDesC& aField );
+        
+        /**
         * Gets the TagContainer index that belongst to the given WPA field
         * @param aFieldId is the id of the field 
         * @return index in TagContainer
@@ -260,51 +268,25 @@
         
         /*
          * Sets the values of the expanded Eap lists to the database 
-         * @param aGeneric for accessing the database records 
+         * @param aServiceId for accessing the EAP data 
          */
-        void SetExpandedEapListL( CMDBGenericRecord* aGeneric );
+        void SetExpandedEapListL( const TUint aServiceId );
         
-        /*
-         * Creates expanded Eap list from the common Eap list
-         * @param aEapList the common Eap list from which the expanded list
-         *              will be created 
-         * @param aEnabledNeed indicates the type of the result expanded  
-         *           Eap list. If it is ETrue then the enabled expanded
-         *           Eap list will be created. Else the disbled one.
-         * @return The created expanded Eap list. It can be empty. 
-         */
-        HBufC8* ExpandedEapListLC( HBufC16* aEapList, TBool aEnabledNeed );
-  
-        /*
-         * Adds one item to the expanded Eap list
-         * @param aExpandedEapList to which the new item will be added.
-         * @param aSlice the common Eap list slice containing one 
-         *              3 digit long number with sign.
-         */
-        void AddToList( HBufC8* aExpandedEapList, TPtrC16 aSlice );
-
     private:
     
         void AddSecurityDataL( TInt aField, HBufC* aPtrTag, TBool aIsWep );
 
-		void AddEAPSettingL( const TInt aField, const HBufC16* const aValue );
+		void AddEAPSettingL( const TInt aField, HBufC16* aValue );
 		
 		TBool EAPSetting( const TInt aField );
 	
 		void FillCipherSuitesL( const HBufC16* const aPtrTag, const TInt aEapIndex );
 		
-		EAPSettings::TEapType GetEapTypeIdFromSettingId( const TInt aField );
-		
-		TUint FindCertificateEntryL( const CertificateEntry::TCertType aCertType, const TInt aEapIndex );
+		TEapExpandedType GetEapTypeIdFromSettingId( const TInt aField ); 
 		
-		void ConvertSubjectKeyIdToBinaryL( const HBufC16* const aSubjectKeyIdString, TDes& aBinaryKey);
-        /*
-        // @var Stores indexes of WEP fields
-        TInt iWEPIndex[KWEPKeyNumOfFields];
-        
-        // @var Stores indexes of WPA fields
-        TInt iWPAIndex[KWPAKeyNumOfFields];
-        */
+		TUint FindCertificateEntryL( const EapCertificateEntry::TCertType aCertType, const TInt aEapIndex );
+		
+		void ConvertSubjectKeyIdToBinaryL( const HBufC16* const aSubjectKeyIdString, TKeyIdentifier& aBinaryKey);
         
         // @var Indicates the WLAN security mode
         TDbCreatorSecurityMode iSecurityMode;
@@ -322,15 +304,9 @@
        
         // @var HBufC for empty WEP and WPA tags
         HBufC* iEmptyTag;
-
-        // @var Stores indexes of WEP fields
-        ////RPointerArray< HBufC > iWepData;
         
         HBufC* iWepData[KWEPKeyNumOfFields];
         
-        // @var Stores indexes of WPA fields
-        ////RPointerArray< HBufC > iWpaData;
-        
         HBufC* iWpaData[KWPAKeyNumOfFields];
 
         TInt iDataStart;
@@ -343,4 +319,4 @@
 #endif PROCESSOR_WLAN_H
 
 
-// End of File.
\ No newline at end of file
+// End of File.
--- a/dbcreator/commsdatcreator/Src/cdccommsdatcreator.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Src/cdccommsdatcreator.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -150,8 +150,6 @@
     CLOG_WRITE( "Processing started...\n" )
     CLOG_WRITE( "=====================\n" )               
 
-	iCmManager.OpenL();
-
     TDbCreatorInputCharSet charSet( ECharSetUnknown );//input character set
 
     //Creates access points
@@ -303,8 +301,7 @@
                                                           iPluginArray,
                                                           iPluginNames,
                                                           iDestArray,
-                                                          iDestNames,
-                                                          iDefCon ); 
+                                                          iDestNames ); 
                 iFileProcessor->ParseFileL();
 
                 delete iFileProcessor;
@@ -325,7 +322,7 @@
                   
 
     // Updates the IAPs that are not in destinations.
-    UpdateUncatCmsL( iCmInDest /*, iPluginNames, iPluginArray*/ );
+    UpdateUncatCmsL( iCmInDest );
 
     // Sets the underlying IAP/SNAPS for vpn IAPs    
     SetUnderlyingIapL( iUnderLying );
@@ -349,9 +346,6 @@
     // Sets linger settings
     SetLingerSettingsL( iLingerSettings );
 
-    // Sets the default connection    
-//    SetDefaultConnectionL( iDefCon );
-    
     // Logs IAPs in UDEB mode
     #ifdef _DEBUG
     LogIapIdsL();
@@ -416,8 +410,6 @@
     
     iLingerSettings.ResetAndDestroy();
 
-    iDefCon.ResetAndDestroy();
-    
     iCmInDest.Close(); 
     
     iCmManager.Close();
@@ -435,7 +427,9 @@
     FeatureManager::InitializeLibL();
     iIsWlanS = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
     FeatureManager::UnInitializeLib();
-    CLOG_WRITE( "FeatureManager closed\n" )               
+    CLOG_WRITE( "FeatureManager closed\n" )
+
+    iCmManager.OpenL();
     }
     
 //------------------------------------------------
@@ -583,34 +577,6 @@
         }
     }
 
-// ---------------------------------------------------------
-// CCdcCommsDatCreator::ProcessDNL
-// ---------------------------------------------------------
-//
-/*void CCdcCommsDatCreator::SetDefaultConnectionL( RPointerArray< HBufC >& aDefCon )
-    {
-    // Sets the default connection    
-    if( aDefCon.Count() > 0 )
-        {
-        CLOG_WRITE_FORMAT( "SetDefaultConnectionL: %d\n", aDefCon.Count() )
-        CLOG_WRITE( "--------------------------------------\n" )
-
-        CProcessorGlobal* glb = CProcessorGlobal::NewL( iReader,
-                                               iCmManager,
-                                               iPluginArray,
-                                               iPluginNames,
-                                               iDestArray,
-                                               iDestNames,
-                                               aDefCon );
-        
-        CleanupStack::PushL( glb );
-        glb->SetDefaultConnectionL();
-        
-        CleanupStack::PopAndDestroy( glb );
-
-        CLOG_WRITE( "--------------------------------------\n" )
-        }
-    }*/
 
 // ---------------------------------------------------------
 // CCdcCommsDatCreator::SetUnderlyingIapL
--- a/dbcreator/commsdatcreator/Src/cdcprocessordn.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Src/cdcprocessordn.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -187,18 +187,6 @@
                         }
                     }
                 break;
-                // SetIconL API removed from new cmmgr implementation
-                //case EDN_Icon:
-                //    {
-                //    TPtrC16 iconPtr = ptrTag->Right( ptrTag->Length() );
-                //    TLex16 lex( iconPtr );
-                //    TUint32 icon( 0 );
-                //    if ( lex.Val( icon, EDecimal ) == KErrNone )
-                //        {
-                //        iDestination.SetIconL( icon );
-                //        }
-                //    }
-                //break;
                 case EDN_Metadata:
                     {
                     if( !ptrTag->Compare( KPurposeUnknown ) )
--- a/dbcreator/commsdatcreator/Src/cdcprocessorglobal.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Src/cdcprocessorglobal.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -38,7 +38,6 @@
 #include <cmmanagerext.h>
 #include <cmmanager.h>
 #include <cmdestinationext.h>
-#include <cmdefconnvalues.h>
 #include <WlanCdbCols.h>
 #include <wlancontainer.h>
 #include <featmgr.h>
@@ -106,16 +105,14 @@
                           RPointerArray< RCmConnectionMethodExt >& aPluginArray,
                           RPointerArray< HBufC >& aPluginNames, 
                           RPointerArray< RCmDestinationExt >& aDestArray,
-                          RPointerArray< HBufC >& aDestNames,
-                          RPointerArray< HBufC >& aDefCon )
+                          RPointerArray< HBufC >& aDestNames )
     {
     CProcessorGlobal* self = new ( ELeave ) CProcessorGlobal( aFileReader,
                                                               aCmManager,
                                                               aPluginArray,
                                                               aPluginNames,
                                                               aDestArray,
-                                                              aDestNames,
-                                                              aDefCon );
+                                                              aDestNames );
     CleanupStack::PushL( self );
 
     // From base class
@@ -134,12 +131,10 @@
                                     RPointerArray< RCmConnectionMethodExt >& aPluginArray,
                                     RPointerArray< HBufC >& aPluginNames, 
                                     RPointerArray< RCmDestinationExt >& aDestArray,
-                                    RPointerArray< HBufC >& aDestNames,
-                                    RPointerArray< HBufC >& aDefCon ) :
+                                    RPointerArray< HBufC >& aDestNames ) :
     CProcessorBase( aFileReader, aCmManager, aPluginArray, aPluginNames, aDestArray, aDestNames ),
     iAttachWhenNeeded ( EFalse )
     {
-    iDefCon = &aDefCon;
     }
     
     
@@ -308,20 +303,6 @@
                 break;
                 }
                 
-            case EDefaultConnectionType:
-                {
-                iDefCon->Append( ptrTag->AllocL() );
-                //SetDefaultConnectionTypeL( ptrTag )
-                break;
-                }
-                
-            case EDefaultConnectionName:
-                {
-                iDefCon->Append( ptrTag->AllocL() );
-                //SetDefaultConnectionNameL( ptrTag )
-                break;
-                }
-                
             case EGprsLastSocketActivityTimeout:
             case EGprsLastSessionClosedTimeout:
             case EGprsLastSocketClosedTimeout:		
@@ -611,87 +592,6 @@
     }
 
 // ---------------------------------------------------------
-// CProcessorGlobal::SetDefaultConnectionL
-// ---------------------------------------------------------
-//
-/*void CProcessorGlobal::SetDefaultConnectionL()
-    {
-    if( iDefCon->Count() > 0 )
-        {
-        SetDefaultConnectionTypeL( (*iDefCon)[0] );
-        }
-    if( iDefCon->Count() > 1 )
-        {
-        SetDefaultConnectionNameL( (*iDefCon)[1] );
-        }
-    }*/
-
-// ---------------------------------------------------------
-// CProcessorGlobal::SetDefaultConnectionTypeL
-// ---------------------------------------------------------
-//
-void CProcessorGlobal::SetDefaultConnectionTypeL( HBufC16* aPtrTag )
-    {
-    iDefaultConnectionSet = EFalse;
-    
-    if ( aPtrTag->CompareF( KStrAlwaysAsk ) == 0 ) 
-        {
-        iDefaultConnectionType = ECmDefConnAlwaysAsk;
-        SetDefConnRecordL( 0 );
-        }
-    else if ( aPtrTag->CompareF( KStrAskOnce ) == 0 ) 
-        {
-        iDefaultConnectionType = ECmDefConnAskOnce;
-        SetDefConnRecordL( 0 );
-        }
-    else if ( aPtrTag->CompareF( KStrDestination ) == 0 ) 
-        {
-        iDefaultConnectionType = ECmDefConnDestination;
-        }
-    else if ( aPtrTag->CompareF( KStrConnectionMethod ) == 0 ) 
-        {
-        iDefaultConnectionType = ECmDefConnConnectionMethod;
-        }
-    else
-        {
-        CLOG_WRITE(
-        "Warning: Default connection type is not valid. Always ask is set.")
-        iDefaultConnectionType = ECmDefConnAlwaysAsk;
-        SetDefConnRecordL( 0 );
-        }    
-    }
-
-// ---------------------------------------------------------
-// CProcessorGlobal::SetDefaultConnectionNameL
-// ---------------------------------------------------------
-//
-void CProcessorGlobal::SetDefaultConnectionNameL( HBufC16* aPtrTag )
-    {
-        
-    // Name is ignored if the defconn has been set. It can happen e.g.
-    // if iDefaultConnectionType is ECmDefConnAlwaysAsk or ECmDefConnAskOnce     
-    if ( iDefaultConnectionSet )
-        {
-        return;
-        }
-        
-    TInt uId = KErrNotFound;
-    if ( iDefaultConnectionType == ECmDefConnDestination )
-        {
-        uId = GetDestinationIdL( aPtrTag );
-        }
-    else if ( iDefaultConnectionType == ECmDefConnConnectionMethod )
-        {
-        uId = GetPluginIdL( aPtrTag );
-        }
-        
-    if( uId != KErrNotFound )
-        {
-        SetDefConnRecordL( uId );
-        }
-    }
-
-// ---------------------------------------------------------
 // CProcessorGlobal::SetGenConnSettingWlanUsage
 // ---------------------------------------------------------
 //
@@ -756,25 +656,6 @@
     }
 
 //-----------------------------------------------------------------------------
-//  CProcessorGlobal::SetDefConnRecordL()
-//-----------------------------------------------------------------------------
-//
-void CProcessorGlobal::SetDefConnRecordL( const TInt /*aId*/ )
-    {
-
-/*    TCmDefConnValue value;
-    value.iType = iDefaultConnectionType;
-    value.iId = aId;*/
-    
-//    iCmManager->WriteDefConnL( value );
-    
-    // It gets true if the defconn was set correctly
-    iDefaultConnectionSet = ETrue;
-
-    }
-    
-
-//-----------------------------------------------------------------------------
 //  CProcessorGlobal::SaveGlobalWlanParameterL()
 //-----------------------------------------------------------------------------
 //
--- a/dbcreator/commsdatcreator/Src/cdcprocessorwlan.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Src/cdcprocessorwlan.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -33,7 +33,6 @@
 #include <WlanCdbCols.h>
 #include <commsdattypesv1_1.h>
 #include <wlancontainer.h>
-#include <EapType.h>
 
 using namespace CMManager;
 
@@ -60,12 +59,6 @@
 // ratio between sizes of ascii and unicode characters
 const TUint KAsciiUnicodeRatio = 2;
 
-// Length of expanded EAP type identifier
-const TUint KExpandedEAPIdLength = 8;
-
-// Plain MSCHAPv2 EAP identifier. Needed because of special handling
-const TUint8 KMschapv2TypeId[] = {0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x63};
-
 // ================= MEMBER FUNCTIONS =======================
 
 CEapTypeElement::~CEapTypeElement()
@@ -144,6 +137,7 @@
 CProcessorWlan::~CProcessorWlan()
     {
     delete iEmptyTag;
+    REComSession::FinalClose();
     }
 
 // ---------------------------------------------------------
@@ -379,7 +373,7 @@
             //WPA
             case EWPAPresharedKey:
             case EWPAKeyLength:
-            case EWPAListOfEAPs:
+            case EWPAEapMethod:
             case EWPAUseOfPresharedKey:
                 {
                 if( iSecurityMode != ESecurityModeWEP && iSecurityMode != ESecurityModeOpen )
@@ -601,50 +595,30 @@
 	    
 	    CleanupStack::PopAndDestroy( iapRecord );	        
 	            
-		TInt err = KErrNone;
-	    TUint8 expandedEapId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-	    TBuf8<KExpandedEAPIdLength> cue;
-	    
-		// Set-up 64-bit expanded EAP id
-		if ( eap->iEapSettings->iEAPType == KMschapv2TypeId[7] )
-			{
-			// This is plain MSCHAPv2. Set vendor ID correctly
-			expandedEapId[1] = KMschapv2TypeId[1];
-			expandedEapId[2] = KMschapv2TypeId[2];
-			expandedEapId[3] = KMschapv2TypeId[3];
-			}
-		
-		expandedEapId[KExpandedEAPIdLength - 1] = static_cast<TUint8> ( eap->iEapSettings->iEAPType );	
-		cue.Copy( expandedEapId, KExpandedEAPIdLength );
-		
-		// Try loading EAP ECOM module
-		CLOG_WRITE_FORMAT( "Try to load EAP module: %d", expandedEapId[7]);
-		CEapType* eapType = 0;
-		TRAP( err, eapType = CEapType::NewL( cue, ELan, serviceId ) );
-		// The error is caused by probably missing EAP method from the device. Ignore the error
-		// because same scripts can be used for devices with and without certain methods.
-		if( err == KErrNone )
-			{
-		    CleanupStack::PushL( eapType );
-		        
-		    // Check if this type is tunneled
-		    if ( eap->iEncapsulatingEapId != EAPSettings::EEapNone )
-		    	{
-		    	// It is tunneled. Take the last byte of the expanded id.
-		    	eapType->SetTunnelingType( eap->iEncapsulatingEapId );    	
-		    	}
-		    CLOG_WRITE( "Calling eapType->SetConfiguration" );
-		    eapType->SetConfigurationL( *eap->iEapSettings );
-		    CLOG_WRITE( "eapType->SetConfiguration success!" );
-		    CleanupStack::PopAndDestroy( eapType );
-			}
+        CEapType* eapType ( NULL );
+        TRAPD( leave, 
+               eapType = CEapType::NewL( ELan, 
+                                         serviceId, 
+                                         eap->iEapSettings->iEAPExpandedType ) );
+        if ( leave == KErrNone )
+            {
+            CleanupStack::PushL( eapType );
+            
+            // Inner EAP
+            if ( eap->iEncapsulatingEapId != *EapExpandedTypeNone.GetType() )
+                {
+                eapType->SetTunnelingType( eap->iEncapsulatingEapId );
+                }
+                    
+            // write EAP setting
+            eapType->SetConfigurationL(*eap->iEapSettings);
+            CleanupStack::PopAndDestroy( eapType );
+            }
         }
-        
+    
     session->Close();
     CleanupStack::PopAndDestroy( session );
     CLOG_WRITE( "Finished EAP settings saving" );
-	//iEapSettings.ResetAndDestroy();
 
     CLOG_WRITE_FORMAT( "SaveSecurityInfoL end %d", iSecurityInfo->Count() );
 }
@@ -1206,6 +1180,7 @@
 void CProcessorWlan::SaveWPAL( TUint32 aIapId )
     {
     CLOG_WRITE( "CProcessorWlan::SaveWPAL enter" );
+    
     CMDBSession* session = CMDBSession::NewL( CMDBSession::LatestVersion() );
     CleanupStack::PushL( session );
     
@@ -1248,17 +1223,11 @@
     secModeField->SetL( iSecurityMode );
     
     CLOG_WRITE( "Wrote securityMode" );
+
     // Save EAP list
-    CMDBField<TDesC>* wlanEapsField = static_cast<CMDBField<TDesC>*>
-                                ( generic->GetFieldByIdL( KCDTIdWlanEaps ) );
-    wlanEapsField->SetL( WPAFieldData( EWPAListOfEAPs )->Des() );
-
-	CLOG_WRITE( "Wrote EAPList" );
-	
-    SetExpandedEapListL( generic );
-
-	CLOG_WRITE( "Wrote expandedEapList" );	
-	
+    SetExpandedEapListL( service );
+    CLOG_WRITE( "Wrote Expanded EAPList" );
+    
     // Save PreShared Key
     TBuf8<KMaxLengthOfKeyData> keyWPA;
     //convert to 8 bit
@@ -1296,122 +1265,105 @@
 // CProcessorWlan::SetExpandedEapListL
 // ---------------------------------------------------------
 //
-void CProcessorWlan::SetExpandedEapListL( CMDBGenericRecord* generic )
+void CProcessorWlan::SetExpandedEapListL( const TUint aServiceId )
     {
+    CLOG_WRITE( "CProcessorWlan::SetExpandedEapListL" )
     // Gets the text format eap list
-    HBufC16* eapList = WPAFieldData( EWPAListOfEAPs );
+    HBufC16* eapList = WPAFieldData( EWPAEapMethod );
     
     if ( eapList != NULL && 0 < eapList->Length() )
         {
+        // load general EAP settings If
+        CEapGeneralSettings* eapGs;
+        eapGs = CEapGeneralSettings::NewL( ELan, aServiceId );
+        CleanupStack::PushL( eapGs );
         
-        // Creates the expanded eap lists    
-        HBufC8* enabledEapList = ExpandedEapListLC( eapList, ETrue );
-        HBufC8* disabledEapList = ExpandedEapListLC( eapList, EFalse );
+        // get lists of enabled/disabled EAPs for the IAP
+        RArray< TEapExpandedType > enabledEapMethods;
+        RArray< TEapExpandedType > disabledEapMethods;
         
-        // Save enabled EAP list
-        CMDBField<TDesC8>* wlanEnabledEapsField = static_cast<CMDBField<TDesC8>*>
-                                ( generic->GetFieldByIdL( KCDTIdWlanEnabledEaps ) );
-        wlanEnabledEapsField->SetL( enabledEapList->Des() );
-
-        // Save disabled EAP list
-        CMDBField<TDesC8>* wlanDisabledEapsField = static_cast<CMDBField<TDesC8>*>
-                                ( generic->GetFieldByIdL( KCDTIdWlanDisabledEaps ) );
-        wlanDisabledEapsField->SetL( disabledEapList->Des() );
+        enabledEapMethods.Append( GetExpandedEapTypeIdL( *eapList ) );
         
-        CleanupStack::PopAndDestroy( disabledEapList );
-        CleanupStack::PopAndDestroy( enabledEapList );
-        
+        // disabledEapMethods can be empty, SetEapMethods takes care of it,
+        // only enabledEapMethods is a must with correct contents
+        User::LeaveIfError( eapGs->SetEapMethods( enabledEapMethods, 
+                                                     disabledEapMethods ) );
+   
+        CleanupStack::PopAndDestroy( eapGs );
         }
     }
 
 // ---------------------------------------------------------
-// CProcessorWlan::ExpandedEapListLC
+// CProcessorWlan::GetExpandedEapTypeId
 // ---------------------------------------------------------
 //
-HBufC8* CProcessorWlan::ExpandedEapListLC( HBufC16* aEapList, TBool aEnabledNeed )
+TEapExpandedType CProcessorWlan::GetExpandedEapTypeIdL( TDesC& aField )
     {
-    // The eap list has a well defined form 
-    // so this parser supposes this concrete form like this:
-    // "+018,-023,+026,-021,-006"
+    TUint8 resultByte;
+    TLex16 lex( aField.Ptr() );
+    User::LeaveIfError( lex.Val( resultByte, EDecimal ) );
     
-    // Lenght of a 3 digit long signed number 
-     const TInt sliceLength = 4;
-     
-   // Max lenght of the resulted list.
-    // Adding one "," then divide the lenght of a slice+1   
-    TInt maxLenght = ( ( aEapList->Length()+1 ) / 5 ) * 8;
+    CLOG_WRITE_FORMAT( "CProcessorWlan::GetExpandedEapTypeIdL: EAP %d",
+                    (int)resultByte )
     
-    HBufC8* expandedEapList = HBufC8::NewLC( maxLenght );
-    
-    TInt pos = 0;
-    while ( pos + sliceLength <= aEapList->Length() )
+    switch ( resultByte )
         {
-        // Getting a slice
-        TPtrC16 slice = aEapList->Mid( pos, sliceLength );
-        
-        // Checks the sign
-        if( slice[0] == '+' )
+        case 0x06:
             {
-            if( aEnabledNeed )
-                {
-                AddToList( expandedEapList, slice );
-                }
+            return *EapExpandedTypeGtc.GetType();
+            }
+        case 0x0d:
+            {
+            return *EapExpandedTypeTls.GetType();
             }
-        else if( slice[0] == '-' )
+        case 0x11:
+            {
+            return *EapExpandedTypeLeap.GetType();
+            }
+        case 0x12:
             {
-            if( !aEnabledNeed )
-                {
-                AddToList( expandedEapList, slice );
-                }
+            return *EapExpandedTypeSim.GetType();
             }
-        else
+        case 0x15:
             {
-            CLOG_WRITE_FORMAT( "! Error : Wrong Eap list format %S", aEapList );
+            return *EapExpandedTypeTtls.GetType();
             }
-        
-        // Step over one slice and "," e.g. "+023,"
-        pos+=5;    
-        
+        case 0x17:
+            {
+            return *EapExpandedTypeAka.GetType();
+            }
+        case 0x19:
+            {
+            return *EapExpandedTypePeap.GetType();
+            }
+        case 0x1a:
+            {
+            return *EapExpandedTypeMsChapv2.GetType();
+            }
+        case 0x2b:
+            {
+            return *EapExpandedTypeFast.GetType();
+            }
+        case 0x01:
+            {
+            return *EapExpandedTypeProtectedSetup.GetType();
+            }
+        case 0x62:
+            {
+            return *EapExpandedTypeTtlsPap.GetType();
+            }
+        case 0x63:
+            {
+            return *EapExpandedPlainMsChapv2.GetType();
+            }
+        default:
+            {
+            return *EapExpandedTypeNone.GetType();
+            }
         }
-    if( pos != aEapList->Length() + 1)    
-        {
-        CLOG_WRITE_FORMAT( "! Warning : possible wrong Eap list format %S", aEapList );
-        }
-        
-    return expandedEapList;    
     }
 
 // ---------------------------------------------------------
-// CProcessorWlan::AddToList
-// ---------------------------------------------------------
-//
-void CProcessorWlan::AddToList( HBufC8* aExpandedEapList, TPtrC16 aSlice )
-    {
-    // Fills the 8 byte form with "0xFE000000000000"        
-    TBuf8<8> expandedForm;
-    expandedForm.AppendFill( 0xFE, 1 );
-    expandedForm.AppendFill( 0x00, 6 );
-        
-    // Leave the "sign"     
-    TPtrC16 number = aSlice.Mid( 1 );    
-    TUint8 resultByte;
-    TLex16 lex( number );
-        
-    if( KErrNone == lex.Val( resultByte, EDecimal ) )
-        {
-        expandedForm.AppendFill( resultByte, 1 );
-        }
-    else
-        {
-        expandedForm.AppendFill( 0x00, 1 );
-        CLOG_WRITE( "! Error : Unlexed Eap number. 0 is addded" );
-        }
-
-    aExpandedEapList->Des().Append( expandedForm ); 
-    }
-
-
-// ---------------------------------------------------------
 // CProcessorWlan::WPAIndex
 // ---------------------------------------------------------
 //       
@@ -1423,7 +1375,6 @@
     return aFieldId - 0x2000 + iDataStart;                     
     }
     
-    
 // ---------------------------------------------------------
 // CProcessorWlan::WPAFieldData
 // ---------------------------------------------------------
@@ -1582,11 +1533,12 @@
 		return EFalse;
 		}
 	}
+
 // ---------------------------------------------------------
 // CProcessorWlan::GetEapTypeIdFromSettingId
 // ---------------------------------------------------------
 //
-EAPSettings::TEapType CProcessorWlan::GetEapTypeIdFromSettingId( const TInt aField )
+TEapExpandedType CProcessorWlan::GetEapTypeIdFromSettingId( const TInt aField )
 	{
 	switch ( aField )
 		{
@@ -1594,7 +1546,7 @@
 		case EEapGtcSessionValidityTime:
 		case EEapGtcEncapsulation:
 			{
-			return EAPSettings::EEapGtc;
+			return *EapExpandedTypeGtc.GetType();
 			}
 		case EEapTlsUsername:
 		case EEapTlsRealm:
@@ -1610,13 +1562,13 @@
 		case EEapTlsCaCertSerialNumber:
 		case EEapTlsEncapsulation:
 			{
-			return EAPSettings::EEapTls;
+			return *EapExpandedTypeTls.GetType();
 			}
 		case EEapLeapUsername:
 		case EEapLeapPassword:
 		case EEapLeapSessionValidityTime:
 			{
-			return EAPSettings::EEapLeap;
+			return *EapExpandedTypeLeap.GetType();
 			}
 		case EEapSimUsername:
 		case EEapSimRealm:
@@ -1624,7 +1576,7 @@
 		case EEapSimSessionValidityTime:
 		case EEapSimEncapsulation:
 			{
-			return EAPSettings::EEapSim;
+			return *EapExpandedTypeSim.GetType();
 			}
 		case EEapTtlsUsername:
 		case EEapTtlsRealm:
@@ -1640,7 +1592,7 @@
 		case EEapTtlsCaCertIssuerName:
 		case EEapTtlsCaCertSerialNumber:
 			{
-			return EAPSettings::EEapTtls;
+			return *EapExpandedTypeTtls.GetType();
 			}
 		case EEapAkaUsername:
 		case EEapAkaRealm:
@@ -1648,7 +1600,7 @@
 		case EEapAkaSessionValidityTime:
 		case EEapAkaEncapsulation:
 			{
-			return EAPSettings::EEapAka;
+			return *EapExpandedTypeAka.GetType();
 			}
 		case EEapPeapUsername:
 		case EEapPeapRealm:
@@ -1667,14 +1619,14 @@
 		case EEapPeapCaCertIssuerName:
 		case EEapPeapCaCertSerialNumber:		
 			{
-			return EAPSettings::EEapPeap;
+			return *EapExpandedTypePeap.GetType();
 			}
 		case EEapMschapv2Username:
 		case EEapMschapv2Password:
 		case EEapMschapv2SessionValidityTime:
 		case EEapMschapv2Encapsulation:
 			{
-			return EAPSettings::EEapMschapv2;
+			return *EapExpandedTypeMsChapv2.GetType();
 			}
 		case EEapFastUsername:
 		case EEapFastRealm:
@@ -1695,7 +1647,7 @@
 		case EEapFastCaCertIssuerName:
 		case EEapFastCaCertSerialNumber:
 			{
-			return EAPSettings::EEapFast; 
+			return *EapExpandedTypeFast.GetType();
 			}
 		
 		case EMschapv2Username:
@@ -1703,23 +1655,24 @@
 		case EMschapv2SessionValidityTime:
 		case EMschapv2Encapsulation:
 			{
-			return EAPSettings::EPlainMschapv2;
+			return *EapExpandedPlainMsChapv2.GetType();
 			}
 		default:
 			{
-			return EAPSettings::EEapNone;
+			return *EapExpandedTypeNone.GetType();
 			}
 		
 		}
 	}
+	
 // ---------------------------------------------------------
 // CProcessorWlan::AddEAPSetting
 // ---------------------------------------------------------
 //
-void CProcessorWlan::AddEAPSettingL( const TInt aField, const HBufC16* const aValue  )
+void CProcessorWlan::AddEAPSettingL( const TInt aField, HBufC16* aValue  )
     {
-    EAPSettings::TEapType eapId = GetEapTypeIdFromSettingId( aField );
-    if ( eapId == EAPSettings::EEapNone )
+    TEapExpandedType eapId = GetEapTypeIdFromSettingId( aField );
+    if ( eapId == *EapExpandedTypeNone.GetType() )
     	{
     	CLOG_WRITE( "! Error : Unknown EAP method" );
     	User::Leave( KErrArgument ); 
@@ -1729,7 +1682,7 @@
 	// Search if the EAP instance already exists in the array for this
 	for ( eapIndex = 0 ; eapIndex < iEapSettings.Count() ; eapIndex++ )
 		{       				
-		if ( ( iEapSettings[eapIndex]->iEapSettings->iEAPType == eapId )
+		if ( ( iEapSettings[eapIndex]->iEapSettings->iEAPExpandedType == eapId )
 			 && ( iEapSettings[eapIndex]->iName != NULL ) 
 			 && ( iEapSettings[eapIndex]->iName->Compare( *iName ) == 0 ))        					 	
 		 	{       				
@@ -1746,7 +1699,7 @@
 		
 		newEap->iEapSettings = new (ELeave) EAPSettings;
 		
-		newEap->iEapSettings->iEAPType = eapId;
+		newEap->iEapSettings->iEAPExpandedType = eapId;
 		
 		newEap->iName = iName->AllocL();                           
 		               	    	
@@ -1773,6 +1726,8 @@
 			{
 			iEapSettings[eapIndex]->iEapSettings->iUsernamePresent = ETrue;
 			iEapSettings[eapIndex]->iEapSettings->iUsername.Copy( *aValue );
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticUsernamePresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticUsername = EFalse;
 			break;
 			}
 			
@@ -1781,7 +1736,9 @@
 		case EMschapv2Password:
 			{
 			iEapSettings[eapIndex]->iEapSettings->iPasswordPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iPassword.Copy( *aValue );			
+			iEapSettings[eapIndex]->iEapSettings->iPassword.Copy( *aValue );
+			iEapSettings[eapIndex]->iEapSettings->iShowPassWordPromptPresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticUsername = EFalse;
 			break;
 			}
 
@@ -1793,7 +1750,9 @@
 		case EEapFastRealm:
 			{
 			iEapSettings[eapIndex]->iEapSettings->iRealmPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iRealm.Copy( *aValue );			
+			iEapSettings[eapIndex]->iEapSettings->iRealm.Copy( *aValue );
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticRealmPresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticRealm = EFalse;
 			break;
 			}
 				
@@ -1813,7 +1772,7 @@
 			TUint value( 0 );
 			if( lex.Val( value, EDecimal) != KErrNone )
 				{				
-				CLOG_WRITE_FORMAT( "! Error : Invalid session validity time value. EapId: %d", eapId );
+				CLOG_WRITE_FORMAT( "! Error : Invalid session validity time value. EapId: %d", eapId.GetVendorType() );
 				User::Leave( KErrArgument );
 				}			
 
@@ -1833,11 +1792,10 @@
 			TUint eapTypeId( 0 );						
 			if( lex.Val( eapTypeId, EDecimal) != KErrNone )
 				{
-				CLOG_WRITE_FORMAT( "! Error : Invalid encapsulation value. EapId: %d", eapId );
+				CLOG_WRITE_FORMAT( "! Error : Invalid encapsulation value. EapId: %d", eapId.GetVendorType() );
 				User::Leave( KErrArgument );
 				}			
-
-			iEapSettings[eapIndex]->iEncapsulatingEapId = static_cast< EAPSettings::TEapType >( eapTypeId );
+			iEapSettings[eapIndex]->iEncapsulatingEapId.SetValue( eapId.GetVendorId(), eapTypeId ); 
 			break;
 			}
 		
@@ -1858,7 +1816,7 @@
                 }
             else 
                 {                
-                CLOG_WRITE_FORMAT( "! Error : Invalid VerifyServerRealm. EapId: %d", eapId );                
+                CLOG_WRITE_FORMAT( "! Error : Invalid VerifyServerRealm. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
                 }
 
@@ -1882,7 +1840,7 @@
                 }
             else 
                 {                
-                CLOG_WRITE_FORMAT( "! Error : Invalid RequireClientAuth. EapId: %d", eapId );                
+                CLOG_WRITE_FORMAT( "! Error : Invalid RequireClientAuth. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
                 }
 			
@@ -1897,7 +1855,7 @@
 			TRAPD( err, FillCipherSuitesL( aValue, eapIndex ) );
 			if( err != KErrNone )
 				{
-				CLOG_WRITE_FORMAT( "! Error : Invalid CipherSuites. EapId: %d", eapId );
+				CLOG_WRITE_FORMAT( "! Error : Invalid CipherSuites. EapId: %d", eapId.GetVendorType() );
 				User::Leave( KErrArgument );
 				}
 			break;
@@ -1908,20 +1866,21 @@
 		case EEapPeapUserCertSubjectKeyId:
 		case EEapFastUserCertSubjectKeyId:
 			{
-			TInt certIndex = FindCertificateEntryL( CertificateEntry::EUser, eapIndex );
+			TInt certIndex = FindCertificateEntryL( EapCertificateEntry::EUser, eapIndex ); 
 
-			TBuf<KKeyIdentifierLength> key;
+			TKeyIdentifier key;
 			
 			TRAPD( err, ConvertSubjectKeyIdToBinaryL( aValue, key) );
 			if( err != KErrNone )
 				{
-				CLOG_WRITE_FORMAT( "! Error : Invalid UserCertSubjectKeyId. EapId: %d", eapId );
+				CLOG_WRITE_FORMAT( "! Error : Invalid UserCertSubjectKeyId. EapId: %d", eapId.GetVendorType() );
 				User::Leave( KErrArgument );
 				}
    			
    			iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyID.Copy(key);
-   			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyIDPresent = ETrue;
+   			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIsEnabled( ETrue );
+   			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSubjectKeyId( key );
+   			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSubjectKeyIdPresent();
 			break;
 			}
 		
@@ -1930,11 +1889,12 @@
 		case EEapPeapUserCertIssuerName:
 		case EEapFastUserCertIssuerName:
 			{
-			TUint certIndex = FindCertificateEntryL( CertificateEntry::EUser, eapIndex );
+			TUint certIndex = FindCertificateEntryL( EapCertificateEntry::EUser, eapIndex ); 
 			
 			iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerNamePresent= ETrue;
-	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerName.Copy( *aValue );			
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIsEnabled( ETrue );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSubjectKeyIdPresent();
+	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIssuerName( *aValue );			
 			break;
 			}
 		
@@ -1943,11 +1903,12 @@
 		case EEapPeapUserCertSerialNumber:
 		case EEapFastUserCertSerialNumber:
 			{
-			TUint certIndex = FindCertificateEntryL( CertificateEntry::EUser, eapIndex );
+			TUint certIndex = FindCertificateEntryL( EapCertificateEntry::EUser, eapIndex );
 			
 			iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumberPresent= ETrue;
-	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumber.Copy( *aValue );			
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIsEnabled( ETrue );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSerialNumberPresent();
+	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSerialNumber( *aValue );			
 			break;
 			}
 		
@@ -1956,20 +1917,23 @@
 		case EEapPeapCaCertSubjectKeyId:
 		case EEapFastCaCertSubjectKeyId:
 			{
-			TInt certIndex = FindCertificateEntryL( CertificateEntry::ECA, eapIndex );
+			TInt certIndex = FindCertificateEntryL( EapCertificateEntry::ECA, eapIndex ); 
 
-			TBuf<KKeyIdentifierLength> key;
+			TKeyIdentifier key;
 			
 			TRAPD( err, ConvertSubjectKeyIdToBinaryL( aValue, key) );
 			if( err != KErrNone )
 				{
-				CLOG_WRITE_FORMAT( "! Error : Invalid UserCertSubjectKeyId. EapId: %d", eapId );
+				CLOG_WRITE_FORMAT( "! Error : Invalid UserCertSubjectKeyId. EapId: %d", eapId.GetVendorType() );
 				User::Leave( KErrArgument );
 				}
 
 			iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyID.Copy(key);   			
-   			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyIDPresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIsEnabled( ETrue );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSubjectKeyId( key );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSubjectKeyIdPresent();
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticCACertificatePresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticCACertificate = EFalse;
 			break;
 			}
 		
@@ -1978,10 +1942,13 @@
 		case EEapPeapCaCertIssuerName:
 		case EEapFastCaCertIssuerName:
 			{
-			TUint certIndex = FindCertificateEntryL( CertificateEntry::ECA, eapIndex );
+			TUint certIndex = FindCertificateEntryL( EapCertificateEntry::ECA, eapIndex ); 
 			iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerNamePresent= ETrue;
-	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerName.Copy( *aValue );			
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIsEnabled( ETrue );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIssuerNamePresent();
+	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIssuerName( *aValue );
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticCACertificatePresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticCACertificate = EFalse;
 			
 			break;
 			}
@@ -1991,10 +1958,13 @@
 		case EEapPeapCaCertSerialNumber:
 		case EEapFastCaCertSerialNumber:
 			{
-			TUint certIndex = FindCertificateEntryL( CertificateEntry::ECA, eapIndex );
+			TUint certIndex = FindCertificateEntryL( EapCertificateEntry::ECA, eapIndex ); 
 			iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue;
-			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumberPresent= ETrue;
-	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumber.Copy( *aValue );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetIsEnabled( ETrue );
+			iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSerialNumberPresent();
+	 		iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex]->SetSerialNumber( *aValue );
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticCACertificatePresent = ETrue;
+			iEapSettings[eapIndex]->iEapSettings->iUseAutomaticCACertificate = EFalse;
 			break;
 			}
 		
@@ -2013,7 +1983,7 @@
 	            }
 	        else 
 	            {
-	            CLOG_WRITE_FORMAT( "! Error : Invalid UsePseudonyms. EapId: %d", eapId );                
+	            CLOG_WRITE_FORMAT( "! Error : Invalid UsePseudonyms. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			break;
@@ -2023,35 +1993,8 @@
 		case EEapPeapEncapsulatedTypes:
 		case EEapFastEncapsulatedTypes:
 			{
-		    // Lenght of a 3 digit long signed number 
-		     const TInt sliceLength = 4;
-    
-		    TInt pos = 0;
-    		while ( pos + sliceLength <= aValue->Length() )
-        		{
-	        	// Getting a slice
-	        	TPtrC16 slice = aValue->Mid( pos, sliceLength );
-	        
-	        	// Checks the sign
-	        	if( slice[0] == '+' )
-	            	{
-         		   	TLex lex( slice.Ptr() + 1 );		
-					TUint encapsEapId( 0 );		
-					
-					if( lex.Val( encapsEapId, EDecimal) != KErrNone )
-						{				
-						CLOG_WRITE_FORMAT( "! Error : Invalid EncapsulatedTypes. EapId: %d", eapId );
-						User::Leave( KErrArgument );
-						}								
-					
-           			iEapSettings[eapIndex]->iEapSettings->iEncapsulatedEAPTypes.Append( encapsEapId );
-					iEapSettings[eapIndex]->iEapSettings->iEncapsulatedEAPTypesPresent = ETrue;
-	            	}
-	                    	       
-		        // Step over one slice and "," e.g. "+023,"
-		        pos+=5;            
-        		}
-
+			iEapSettings[eapIndex]->iEapSettings->iEnabledEncapsulatedEAPExpandedTypes.Append( GetExpandedEapTypeIdL( *aValue ) );
+            iEapSettings[eapIndex]->iEapSettings->iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue;
 			break;
 			}
 		
@@ -2069,7 +2012,7 @@
 	            }
 	        else 
 	            {
-   	            CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV0Allowed. EapId: %d", eapId );                
+   	            CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV0Allowed. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2090,7 +2033,7 @@
 	            }
 	        else 
 	            {
-   	            CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV1Allowed. EapId: %d", eapId );                
+   	            CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV1Allowed. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2111,7 +2054,7 @@
 	            }
 	        else 
 	            {
-   	            CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV2Allowed. EapId: %d", eapId );
+   	            CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV2Allowed. EapId: %d", eapId.GetVendorType() );
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2132,7 +2075,7 @@
 	            }
 	        else 
 	            {
-  	            CLOG_WRITE_FORMAT( "! Error : Invalid EEapFastAuthProvModeAllowed. EapId: %d", eapId );                
+  	            CLOG_WRITE_FORMAT( "! Error : Invalid EEapFastAuthProvModeAllowed. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2154,7 +2097,7 @@
 	        else 
 	            {
 
-  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastUnauthProvModeAllowed. EapId: %d", eapId );                
+  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastUnauthProvModeAllowed. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2175,7 +2118,7 @@
 	            }
 	        else 
 	            {
-  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnADHPNoPAC. EapId: %d", eapId );                
+  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnADHPNoPAC. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2196,7 +2139,7 @@
 	            }
 	        else 
 	            {
-  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnADHPNoMatchingPAC. EapId: %d", eapId );                
+  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnADHPNoMatchingPAC. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2217,7 +2160,7 @@
 	            }
 	        else 
 	            {
-  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnNotDefaultServer. EapId: %d", eapId );                
+  	            CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnNotDefaultServer. EapId: %d", eapId.GetVendorType() );                
                 User::Leave( KErrArgument );
 	            }
 			
@@ -2268,12 +2211,12 @@
 // CProcessorWlan::FindCertificateEntry
 // ---------------------------------------------------------
 //
-TUint CProcessorWlan::FindCertificateEntryL( const CertificateEntry::TCertType aCertType, const TInt aEapIndex )
+TUint CProcessorWlan::FindCertificateEntryL( const EapCertificateEntry::TCertType aCertType, const TInt aEapIndex )
     {
     TUint certIndex( 0 );
 	for( certIndex = 0; certIndex < iEapSettings[aEapIndex]->iEapSettings->iCertificates.Count() ; certIndex++ )
 		{
-		if( iEapSettings[aEapIndex]->iEapSettings->iCertificates[certIndex].iCertType == aCertType )
+		if( iEapSettings[aEapIndex]->iEapSettings->iCertificates[certIndex]->GetCertType() == aCertType )
 			{
 			// Found
 			break;
@@ -2282,9 +2225,9 @@
 	if( certIndex == iEapSettings[aEapIndex]->iEapSettings->iCertificates.Count() )
 		{
 		// Not found. Create
-		CertificateEntry entry;
-
-		entry.iCertType = aCertType;
+		EapCertificateEntry* entry;
+		entry = new (ELeave) EapCertificateEntry;
+		entry->SetCertType( aCertType );
 
 		iEapSettings[aEapIndex]->iEapSettings->iCertificates.AppendL( entry );
 
@@ -2297,7 +2240,7 @@
 // CProcessorWlan::ConvertSubjectKeyIdToBinary
 // ---------------------------------------------------------
 //
-void CProcessorWlan::ConvertSubjectKeyIdToBinaryL( const HBufC16* const aSubjectKeyIdString, TDes& aBinaryKey)
+void CProcessorWlan::ConvertSubjectKeyIdToBinaryL( const HBufC16* const aSubjectKeyIdString, TKeyIdentifier& aBinaryKey)
 	{
 	TInt err( KErrNone );
 	
--- a/dbcreator/commsdatcreator/Src/cdcreaderxml.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/Src/cdcreaderxml.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -169,7 +169,7 @@
 //---------------
 //WPAPresharedKey         string    WPA/WPA2 pre-shared key in plain text. 
 //WPAKeyLength            integer   The length of the WPA/WPA2 pre-shared key.
-//WPAListOfEAPs           string    A list of EAPs in use
+//WPAEapMethod            string    A EAP method in use
 //WPAUseOfPresharedKey    string    WPA/WPA2 pre-shared key usage.
 //=============
 //VPN specific:
@@ -323,7 +323,7 @@
 //WPA security
 _LIT16( KWPAPresharedKey,           "WPAPresharedKey" );
 _LIT16( KWPAKeyLength,              "WPAKeyLength" );
-_LIT16( KWPAListOfEAPs,             "WPAListOfEAPs" );
+_LIT16( KWPAEapMethod,              "WPAEapMethod");
 _LIT16( KWPAUseOfPresharedKey,      "WPAUseOfPresharedKey" );
 
 //EAP security
@@ -473,8 +473,6 @@
 _LIT16( KUIPriorityDialIn,          "UIPriorityDialIn" );
 _LIT16( KUIPriorityVpn,             "UIPriorityVpn" );
 _LIT16( KUIPriorityMip,             "UIPriorityMip" );
-_LIT16( KDefaultConnectionType,     "DefaultConnectionType" );
-_LIT16( KDefaultConnectionName,     "DefaultConnectionName" );
 _LIT16( KUsageOfWlan,               "UsageOfWlan" );
 _LIT16( KCellularDataUsageHome,     "CellularDataUsageHome" );
 _LIT16( KCellularDataUsageVisitor,  "CellularDataUsageVisitor" );
@@ -494,15 +492,6 @@
 _LIT16( KWlanPowerMode,             "WlanPowerMode" );
 
 
-//maximum number of PacketData AP parameters
-const TInt KMaxPacketDataParam = 28;
-const TInt KMaxLANParam = 26;
-const TInt KMaxWLANParam = 125;
-const TInt KMaxGlobalParam = 42;
-const TInt KMaxVPNParam = 12;
-const TInt KMaxDNParam = 19;
-
-
 // ================= MEMBER FUNCTIONS =======================
 
 // ---------------------------------------------------------
@@ -912,26 +901,32 @@
     
     if ( iLine->FindF( KFeatureHeadPacketData ) != KErrNotFound )
         {
+        CLOG_WRITE( "CReaderXML::DetectFeatureHead(): EFeaturePacketData" );
         feature = EFeaturePacketData;
         }
     else if ( iLine->FindF( KFeatureHeadWLAN ) != KErrNotFound )
         {
+        CLOG_WRITE( "CReaderXML::DetectFeatureHead(): EFeatureWLAN" );
         feature = EFeatureWLAN;
         }
     else if ( iLine->FindF( KFeatureHeadLAN ) != KErrNotFound )
         {
+        CLOG_WRITE( "CReaderXML::DetectFeatureHead(): EFeatureLAN" );
         feature = EFeatureLAN;
         }
     else if ( iLine->FindF( KFeatureHeadVPN ) != KErrNotFound )
         {
+        CLOG_WRITE( "CReaderXML::DetectFeatureHead(): EFeatureVPN" );
         feature = EFeatureVPN;
         }
     else if ( iLine->FindF( KFeatureHeadDN ) != KErrNotFound )
         {
+        CLOG_WRITE( "CReaderXML::DetectFeatureHead(): EFeatureDN" );
         feature = EFeatureDN;
         }
     else if ( iLine->FindF( KFeatureHeadGlobal ) != KErrNotFound )
         {
+        CLOG_WRITE( "CReaderXML::DetectFeatureHead(): EFeatureGlobal" );
         feature = EFeatureGlobal;
         iFoundGlobal = ETrue;        
         }
@@ -1020,7 +1015,6 @@
 //
 TInt CReaderXML::DetectParam()
     {
-    TInt maxParam( 0 );           //maximum nunber of params in array
     TInt fieldId( KErrNotFound ); //field id of detected parameter 
     RArray<EInputParams> *params( NULL ); //pointer to the table used 
                                         //for or detection    
@@ -1028,27 +1022,21 @@
     switch ( CurrentFeature() )        
         {
         case EFeaturePacketData:
-            maxParam = KMaxPacketDataParam;
             params   = &iPDParams;
             break;
         case EFeatureWLAN:
-            maxParam = KMaxWLANParam;
             params   = &iWLanParams;
             break;
         case EFeatureLAN:
-            maxParam = KMaxLANParam;
             params   = &iLanParams;
             break;
         case EFeatureVPN:
-            maxParam = KMaxVPNParam;
             params   = &iVpnParams;
             break;
         case EFeatureDN:
-            maxParam = KMaxDNParam;
             params =   &iDNParams;
             break;
         case EFeatureGlobal:
-            maxParam = KMaxGlobalParam;
             params   = &iGlobalParams;
             break;
         default:
@@ -1057,14 +1045,13 @@
        
     //looks for parameter match
     HBufC16* paramName = ReadParam( EParamName );
-    TBool found ( EFalse );
-    
     if ( paramName == NULL )
             {
             return fieldId;
             }
 
-    for ( TInt idx = 0; idx < maxParam && !found; idx++ )
+    TBool found ( EFalse );
+    for ( TInt idx = 0; idx < params->Count() && !found; idx++ )
         {        
         if ( paramName->CompareF( (*params)[idx].iParam ) == 0 )
             {
@@ -1127,6 +1114,18 @@
             CLOG_WRITE_FORMAT( "! Warning: tag could not be allocated %S:",
                                      &tag );
             }
+// Debugging help; commented out for clearer log.
+//        else 
+//            {
+//            if (aSegment == EParamValue)
+//                {
+//                CLOG_WRITE_FORMAT( "CReaderXML::ReadParam: value %S", &tag );
+//                }
+//            else if (aSegment == EParamName)
+//                {
+//                CLOG_WRITE_FORMAT( "CReaderXML::ReadParam: name %S", &tag );
+//                }
+//            }
         }
     return ret;
     }
@@ -1642,7 +1641,7 @@
     iWLanParams.Append( EInputParams( EWEPKey4Data,                 KWEPKey4Data ) );
     iWLanParams.Append( EInputParams( EWPAPresharedKey,             KWPAPresharedKey ) );
     iWLanParams.Append( EInputParams( EWPAKeyLength,                KWPAKeyLength ) );
-    iWLanParams.Append( EInputParams( EWPAListOfEAPs,               KWPAListOfEAPs ) );
+    iWLanParams.Append( EInputParams( EWPAEapMethod,                KWPAEapMethod ) );
     iWLanParams.Append( EInputParams( EWPAUseOfPresharedKey,        KWPAUseOfPresharedKey ) );
     iWLanParams.Append( EInputParams( EEapGtcUsername,              KEapGtcUsername ) );
     iWLanParams.Append( EInputParams( EEapGtcSessionValidityTime,   KEapGtcSessionValidityTime ) );
@@ -1777,8 +1776,6 @@
     iGlobalParams.Append( EInputParams( EUIPriorityDialIn,      KUIPriorityDialIn ) );
     iGlobalParams.Append( EInputParams( EUIPriorityVpn,         KUIPriorityVpn ) );
     iGlobalParams.Append( EInputParams( EUIPriorityMip,         KUIPriorityMip ) );
-    iGlobalParams.Append( EInputParams( EDefaultConnectionType, KDefaultConnectionType ) );
-    iGlobalParams.Append( EInputParams( EDefaultConnectionName, KDefaultConnectionName ) );
     iGlobalParams.Append( EInputParams( EUsageOfWlan,           KUsageOfWlan ) );
     iGlobalParams.Append( EInputParams( ECellularDataUsageHome,         KCellularDataUsageHome ) );
     iGlobalParams.Append( EInputParams( ECellularDataUsageVisitor,      KCellularDataUsageVisitor ) );
--- a/dbcreator/commsdatcreator/group/cdccommsdatcreator.mmp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreator/group/cdccommsdatcreator.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -73,3 +73,4 @@
 LIBRARY        cmmanagerdatabase.lib
 LIBRARY        flogger.lib 
 LIBRARY        centralrepository.lib
+LIBRARY        eaptools.lib
--- a/dbcreator/commsdatcreatorrfsplugin/src/cdccommsdatcreatorrfsplugin.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatcreatorrfsplugin/src/cdccommsdatcreatorrfsplugin.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -18,7 +18,6 @@
 
 
 #include <centralrepository.h>
-#include "cdccommsdatcreatorcrkeys.h"
 
 #include "cdccommsdatcreatorrfsplugin.h"
 #include "cdclogger.h"
--- a/dbcreator/commsdatstartup/Inc/cdccommsdatstartup.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatstartup/Inc/cdccommsdatstartup.h	Thu Jul 22 16:37:38 2010 +0100
@@ -67,17 +67,6 @@
     */
     void CheckCreatorUIdL();
 
-    /*
-    * Reads the database descriptor input file name
-    * @param out: Name of the database descriptor file 
-    */
-    void GetInputFileNameL( TFileName &aFileName );
-
-    /*
-    * Creates repository
-    */
-    void CreateRepositoryL();
-
    	/**
     * Resets the commsdat repository. This causes the default Commsdat
     * from z to be copied to c
@@ -89,15 +78,6 @@
     */
     void ResetEAPSettingsL();
     
-    /*
-    * Sets the startup status
-    * @param startup status to be set.
-    */
-    void SetStartupStatusL( TInt aStatus );
-    
-    // Repository
-    CRepository *iRepository;
-
     };
 
 
--- a/dbcreator/commsdatstartup/Src/cdccommsdatstartup.cpp	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/commsdatstartup/Src/cdccommsdatstartup.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -27,7 +27,6 @@
 #include <etelpckt.h>
 
 #include <centralrepository.h>
-#include "cdccommsdatcreatorcrkeys.h"
 
 #include "cdccommsdatstartup.h"
 #include "cdccommsdatcreator.h"
@@ -37,6 +36,7 @@
 
 // CONSTANTS
 const TUid KCRUidCommsDb = { 0xcccccc00 };
+_LIT( KVariantXmlFile, "Z:\\private\\10281BC3\\VariantData_commsdat.xml" );
 
 //------------------------------------------------
 // CCdcCommsDatStartup::DoStartL
@@ -50,11 +50,6 @@
     
     CheckCreatorUIdL();
 
-    CreateRepositoryL();
-    
-    // Set status to not initialised
-    SetStartupStatusL( ECommsDatInitialisationFailed );
-
 	CLOG_WRITE( "CCdcCommsDatStartup::ResetCommsDatToDefaultL()" );
 	// In all RFS cases CommsDat must be reset 
 	ResetCommsDatToDefaultL();
@@ -71,136 +66,40 @@
 	// In all RFS cases CommsDat tables must be checked/created
 	cdc->CreateTablesL();
 	
-    TFileName fileName;
-    GetInputFileNameL( fileName );
-        
-    // CommsDatCreator feature is supported if input file name
-    // lenght is not 0. However file name lenght at least 5. (x.xml)     
-    if( fileName.Length() > 0 )
+    // If variant XML file exists, read it and create settings
+    TFileName fileName( KVariantXmlFile );
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    RFile file;
+    if ( KErrNone == file.Open( fs, fileName, EFileRead ) )
         {
+        file.Close();
         CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation enabled" );
-        
-        TFileName path( _L("Z:\\private\\10281BC3\\" )  );
-        path.Append( fileName );
+    
+        TRAPD(err, cdc->CreateCommsDatL( fileName ) );
+        if ( err != KErrNone )
+            {
+            // CommsDat creation leaved so something must be wrong.
+            // Reset CommsDat and EAP settings.
+            ResetCommsDatToDefaultL();
+            ResetEAPSettingsL();
+            cdc->CreateTablesL();
+            User::Leave( err );
+            }
 
-		CLOG_WRITE( "CCdcCommsDatStartup::CreateCommsDatL begin" );
-	
-        TRAPD(err, cdc->CreateCommsDatL( path ) );
-        if(err != KErrNone )
-        	{
-        	// CommsDat creation leaved so something must be wrong.
-        	// Reset CommsDat and EAP settings.
-        	ResetCommsDatToDefaultL();
-        	ResetEAPSettingsL();
-        	cdc->CreateTablesL();
-        	User::Leave( err );
-        	}
-
-        CLOG_WRITE( "CCdcCommsDatStartup::CreateCommsDatL end" );               
+        CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation done" );
         }
-       else
-       	{
-       	CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation disabled" );
-       	}
-        
-    // If nothing has leaved then everything is okay (both in disabled and
-    // enabled cases.
-    SetStartupStatusL( ECommsDatInitialised );
+    else
+        {
+        CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation disabled" );
+        }
+    fs.Close();
         
     CleanupStack::PopAndDestroy( cdc );
     CLOG_WRITE( "CCdcCommsDatStartup::DoStartL end" );
     }
 
 // ----------------------------------------------------------------------------
-// CCdcCommsDatStartup::CreateRepositoryL()
-// ----------------------------------------------------------------------------
-//    
-void CCdcCommsDatStartup::CreateRepositoryL()
-    {
-    CLOG_WRITE( "CCdcCommsDatStartup::CreateRepositoryL()" );
-
-    TRAPD( err, iRepository = CRepository::NewL( KCRUidCommsDatCreator ) );
-    
-    // Log is important now, because repository cannot contain the 
-    // error value if it cannot be used 
-    if( err != KErrNone )
-        {
-        CLOG_WRITE_FORMAT( "Repository could not created err : %d", err );
-        User::Leave( err );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CCdcCommsDatStartup::SetStartupStatusL()
-// ----------------------------------------------------------------------------
-//    
-void CCdcCommsDatStartup::SetStartupStatusL( TInt aResult )
-    {
-    CLOG_WRITE_FORMAT( "CCdcCommsDatStartup::SetStartupStatusL() %d", aResult );
-
-    TInt err = iRepository->Set( KCommsDatCreatorStartupStatus, aResult );
-    if( err != KErrNone )
-        {
-        CLOG_WRITE_FORMAT( 
-                "Value could not write to repository err : %d", err );
-        User::Leave( err );
-        }
-
-    CLOG_WRITE_FORMAT( "CCdcCommsDatStartup::SetStartupStatusL() %d", aResult );
-    }
-
-// ----------------------------------------------------------------------------
-// CCdcCommsDatStartup::GetInputFileNameL()
-// ----------------------------------------------------------------------------
-//    
-void CCdcCommsDatStartup::GetInputFileNameL( TFileName &aFileName )
-    {
-    CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL()" );
-
-    TInt err = iRepository->Get( KCommsDatCreatorInputFileName, aFileName );
-    if( err != KErrNone )
-        {
-        CLOG_WRITE_FORMAT(
-                 "Value could not red from repository err : %d", err );
-        User::Leave( err );
-        }
-
-    CLOG_WRITE( "Input filename red" );
-
-    HBufC *fileName = aFileName.AllocLC();
-
-    CLOG_WRITE_FORMAT( "Input filename value : %S", fileName );
-    
-    CleanupStack::PopAndDestroy( fileName );
-    
-    // Check if file exists. If it doesn't reset filename.
-    RFs fs;
-    err = fs.Connect();//check
-    
-    if( err == KErrNone )
-    	{
-    	RFile file;
-    
-    	TFileName path( _L("Z:\\private\\10281BC3\\" )  );
-    	path.Append( aFileName );
-
-    	err = file.Open(fs, path, EFileRead);
-    	if( err != KErrNone )
-    	{
-	    	CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL() File does not exist");
-  	  	aFileName.Zero();
-    	}
-    	else
-    	{
-    		file.Close();
-    	}
-    	fs.Close();
-    	}
-    
-    CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL()" );
-    }
-
-// ----------------------------------------------------------------------------
 // CCdcCommsDatStartup::CheckCreatorUIdL()
 // ----------------------------------------------------------------------------
 //   	
@@ -211,7 +110,7 @@
     
     CLOG_WRITE( "CCdcCommsDatStartup::CheckCreatorUIdL" );
     
-    TUid creatorId = User::CreatorIdentity();
+    TUid creatorId = User::CreatorSecureId();
 
     CLOG_WRITE_FORMAT( "CreatorId : %x", creatorId );
    
@@ -229,10 +128,6 @@
 //   	
 CCdcCommsDatStartup::~CCdcCommsDatStartup()
     {
-    if( iRepository )
-        {
-        delete iRepository;
-        }
     }
 
 // ----------------------------------------------------------------------------
Binary file dbcreator/commsdatstartup/cenrep/keys_commsdatcreator.xls has changed
Binary file dbcreator/conf/commsdatcreator.confml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbcreator/conf/commsdatcreator.implml	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<container xmlns="http://www.symbianfoundation.org/xml/implml/1">
+
+	<tempVariable ref="TempCommsDatCreator.InputPath" />
+
+	<container>
+		<tag name='target' value='rofs3' />
+		<phase name='pre' />
+		<ruleml xmlns="http://www.s60.com/xml/ruleml/3">
+
+			<!-- correct cccccc00.cre to image -->
+			<rule>
+		  ${APs.AP} or
+		  ${VPN_APs.VPN_AP} or
+		  ${LAN_APs.LAN_AP} or
+		  ${WLAN_APs.WLAN_AP}
+		  configures 
+		  ${TempCommsDatCreator.InputPath} = '/epoc32/data/Z/private/10202be9'
+		 </rule>
+
+		</ruleml>
+
+	</container>
+
+	<container>
+		<tag name='target' value='rofs3' />
+		<phase name='normal' />
+		<content xmlns="http://www.s60.com/xml/content/2">
+			<desc>Copy commsdat content</desc>
+			<output dir="content/private/10202be9" file="cccccc00.cre">
+				<externalinput dir="${TempCommsDatCreator.InputPath}">
+					<include files="cccccc00_empty.cre" />
+				</externalinput>
+			</output>
+		</content>
+	</container>
+
+</container>
\ No newline at end of file
Binary file dbcreator/conf/commsdatcreator_10281BC8.crml has changed
--- a/dbcreator/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -24,7 +24,7 @@
 PRJ_EXPORTS
 ../conf/commsdatcreator.confml				MW_LAYER_CONFML(commsdatcreator.confml)
 ../conf/commsdatcreator_01.gcfml			MW_LAYER_GCFML(commsdatcreator_01.gcfml)
-../conf/commsdatcreator_10281BC8.crml	MW_LAYER_CRML(commsdatcreator_10281BC8.crml)
+../conf/commsdatcreator.implml          MW_LAYER_CRML(commsdatcreator.implml)
 ../rom/commsdatcreator.iby						CORE_MW_LAYER_IBY_EXPORT_PATH(commsdatcreator.iby)
 
 
--- a/dbcreator/inc/cdccommon.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/dbcreator/inc/cdccommon.h	Thu Jul 22 16:37:38 2010 +0100
@@ -162,7 +162,7 @@
     {
     EWPAPresharedKey = 0x00002000,    // Preshared key 
     EWPAKeyLength    = 0x00002001,    // Key length
-    EWPAListOfEAPs   = 0x00002002,    // List of EA plugins
+    EWPAEapMethod    = 0x00002002,    // EAP Method
     EWPAUseOfPresharedKey =0x00002003,// Use of preshared key
     };
     
--- a/dbcreator/inc/cdccommsdatcreatorcrkeys.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:   Commsdatcreator related central repository keys
-*
-*/
-
-
-
-#ifndef __CDC_COMMSDAT_CREATOR_CR_KEYS_H__
-#define __CDC_COMMSDAT_CREATOR_CR_KEYS_H__
-
-/** CommsDatCreator API */
-/** Provides access CDCCommsDatCreator Startup Status CenRep key*/
-
-const TUid KCRUidCommsDatCreator= {0x10281BC8};
-
-
-/** 
-* Defines the status of the CommsDat creation. 
-*
-* Integer type
-*
-* Default value: 0
-*/
-const TUint32 KCommsDatCreatorStartupStatus = 0x00000001;
-
-
-/** 
-* Defines the input file name for CommsDat creation. 
-*
-* String type
-*
-* Default value: VariantData.xml
-*/
-const TUint32 KCommsDatCreatorInputFileName = 0x00000002;
-
-/** 
-* Possible statuses of the CommsDat creation. 
-*
-* enum type
-*
-* Default value: 0
-*/
-
-enum TCommsDatCreatorStartupStatus
-	{
-	ECommsDatNotInitialised,
-	ECommsDatInitialised,
-	ECommsDatInitialisationFailed
-	};
-
-
-
-#endif // __CDC_COMMSDAT_CREATOR_CR_KEYS_H__
\ No newline at end of file
--- a/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -26,13 +26,13 @@
 ../inc/meshpreface1.cfg         /epoc32/release/winscw/udeb/z/system/data/meshpreface1.cfg
 
 PRJ_MMPFILES
-#include "../accesspointcontrol/apcontrollistplugin/group/bld.inf"
 #include "../alwayson_net_plugin/group/bld.inf"
 #include "../apengine/group/bld.inf"
 #include "../bearermanagement/group/bld.inf"
 #include "../cmmanager/group/bld.inf"
 #include "../connectionmonitoring/group/bld.inf"
 #include "../connectionutilities/ConnectionDialogs/group/bld.inf"
+#include "../keepalive/group/bld.inf"
 #include "../dbcreator/group/bld.inf"
 #include "../ipcm_plat/group/bld.inf"
 #include "../ipcm_pub/group/bld.inf"
--- a/inc/meshpreface1.cfg	Thu Jun 17 22:32:02 2010 +0100
+++ b/inc/meshpreface1.cfg	Thu Jul 22 16:37:38 2010 +0100
@@ -318,6 +318,14 @@
 	FIELD_COUNT=2
 END_ADD
 
+ADD_SECTION
+# COMMDB_ID = 7
+	Name=pdpcpr
+	CprUid=0x102822E2
+	FIELD_COUNT=2
+END_ADD
+
+
 ############################################################
 ## SCprTable
 ## 
@@ -545,7 +553,7 @@
 	Name=spud-ppp
 	Tier=Link.TierTable.271064565
 	MCpr=MCprTable.10
-	Cpr=CprTable.3
+	Cpr=CprTable.7
 	SCpr=SCprTable.4
 	Protocol=ProtocolTable.3
 	FIELD_COUNT=6
@@ -556,7 +564,7 @@
 	Name=spud-rawip
 	Tier=Link.TierTable.271064565
 	MCpr=MCprTable.10
-	Cpr=CprTable.3
+	Cpr=CprTable.7
 	SCpr=SCprTable.4
 	Protocol=ProtocolTable.5
 	FIELD_COUNT=6
@@ -602,3 +610,4 @@
 	FIELD_COUNT=6
 END_ADD
 
+
--- a/ipcm_plat/bearer_settings_plugin_api/inc/cmpluginbaseeng.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/bearer_settings_plugin_api/inc/cmpluginbaseeng.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2010 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"
@@ -63,14 +63,14 @@
 /**
  * Record indexes for generic iap records in the Client instance table.
  */
-const TInt KIapRecordIndex = 0;
-const TInt KServiceRecordIndex = 1;
-const TInt KNetworkRecordIndex = 2;
-const TInt KWAPAPRecordIndex = 3;
-const TInt KWAPBearerRecordIndex = 4;
-const TInt KMetaDataRecordIndex = 5;
-const TInt KLocationRecordIndex = 6;
-const TInt KProxyRecordIndex = 7;
+const TInt KIapRecordIndex = 0;         // Mandatory record
+const TInt KServiceRecordIndex = 1;     // Mandatory record
+const TInt KNetworkRecordIndex = 2;     // Mandatory record
+const TInt KWAPAPRecordIndex = 3;       // Mandatory record
+const TInt KWAPBearerRecordIndex = 4;   // Mandatory record
+const TInt KMetaDataRecordIndex = 5;    // Mandatory record
+const TInt KLocationRecordIndex = 6;    // Optional record
+const TInt KProxyRecordIndex = 7;       // Mandatory record (flag in record tells if in use)
 
 
 // DATA TYPES
@@ -80,8 +80,8 @@
     ECmInt,
     ECmText,
     ECmText8
-    }TCMFieldTypes;
-    
+    } TCMFieldTypes;
+
 // Attributes that are related to bearer plugin creation
 enum TBearerCreationCommonAttributes
     {
@@ -90,13 +90,13 @@
                                                 * bearer creation related
                                                 * attributes
                                                 */
-    
+
     ECmExtensionLevel,          /**<
-                                * Return the extension level of the given 
+                                * Return the extension level of the given
                                 * bearer type. 1 means the level 1st.
                                 * (TUint32 - default: none - read only)
                                 */
-    
+
     ECmBearerCreationCommonAttributesEnd = 9999 /**<
                                                 * Marks the end of bearer
                                                 * creation related attributes
@@ -106,21 +106,24 @@
 /**
  * Flags for Iap metadata to indicate:
  * EMetaHighlight: If it's set it indicates that a connection method is
- *                 highlighted in Agent dialog. Only one connection 
+ *                 highlighted in Agent dialog. Only one connection
  *                 method can have this flag set.
- * EMetaHiddenAgent: If it's set it indicates that an connection method is 
+ * EMetaHiddenAgent: If it's set it indicates that an connection method is
  *                   hidden connection method in Agent dialog.
+ * EMetaHotSpot: If it's set it indicates that an connection method is
+ *               HotSpot connection method.
  */
 enum TCmMetaDataFields
     {
     EMetaHighlight    = 0x00000001,
-    EMetaHiddenAgent  = 0x00000002
+    EMetaHiddenAgent  = 0x00000002,
+    EMetaHotSpot      = 0x00000004
     };
 
 // FORWARD DECLARATIONS
 class CCmPluginBaseEng;
 class CCDIAPMetadataRecord;
-        
+
 // CLASS DECLARATION
 /**
  * Initialisation instance for plugin creation. Used in plugin
@@ -134,18 +137,18 @@
          * @param aSessionRef Reference for open Session handle to CommsDat.
          */
         IMPORT_C TCmPluginInitParam( CommsDat::CMDBSession& aSessionRef );
-        
+
     public:
         /**
          * Reference to CommsDat session handle.
          */
         CommsDat::CMDBSession& iSessionRef;
-            
+
         /**
          * Reserved for future.
          */
-        TAny*               iNotused1;
-        TAny*               iNotused2;
+        TAny* iNotused1;
+        TAny* iNotused2;
     };
 
 // CLASS DECLARATION
@@ -167,7 +170,7 @@
          * CCmClientPluginInstance object.
          */
         IMPORT_C static CCmClientPluginInstance* NewLC();
-        
+
         /**
          * Destructor
          */
@@ -178,7 +181,7 @@
          * Default constructor.
          */
         CCmClientPluginInstance();
-        
+
         /**
          * Second phase constructor.
          */
@@ -187,7 +190,7 @@
     public:
         /**
          * Pointer array for generic record pointers. Those are copies
-         * from CommsDat versions for the client usage. 
+         * from CommsDat versions for the client usage.
          */
         RPointerArray<CommsDat::CCDRecordBase> iGenRecordArray;
 
@@ -197,15 +200,15 @@
          * the different plugins.
          */
         RPointerArray<CommsDat::CCDRecordBase> iBearerSpecRecordArray;
-        
+
         /** Naming way of the CM. e.g. ENamingUnique */
-        CMManager::TNamingMethod               iNamingMethod;
-        
+        CMManager::TNamingMethod iNamingMethod;
+
         /** Boolean to keep the information if location is enabled */
-        TBool                                  iLocationEnabled;
-        
+        TBool iLocationEnabled;
+
         /** Iap Record id of this Connection Method */
-        TUint32                                iIapId;
+        TUint32 iIapId;
     };
 
 /**
@@ -219,11 +222,11 @@
 class CCmPluginBaseEng : public CBase
     {
     public:
-       /** 
+       /**
         * Destructor.
         */
        IMPORT_C virtual ~CCmPluginBaseEng();
-        
+
         /**
          * Create a new instance of the given bearer type plugin.
          * Used from CMM server to avoid using slow ECom framework.
@@ -231,28 +234,28 @@
          * @return Returns CCmPluginBaseEng type pointer which represents pure
          * bearer instance for the CMM server.
          */
-        virtual CCmPluginBaseEng* 
-                CreateInstanceL( TCmPluginInitParam& aInitParam ) const = 0;
+        virtual CCmPluginBaseEng* CreateInstanceL(
+                TCmPluginInitParam& aInitParam ) const = 0;
 
         /**
-         * Following GetBearerInfoXXXL methods return the values of the 
+         * Following GetBearerInfoXXXL methods return the values of the
          * requested attributes. These values are bearerspecific so they
          * don't vary between CMs with same bearer type.
          * @param aAttribute An attribute identifier.
          * @return Returns the value requested. If not found leaves with
-         * KErrNotFound error code. 
+         * KErrNotFound error code.
          */
-        IMPORT_C virtual TUint32 GetBearerInfoIntL( 
-                                                TUint32 aAttribute ) const = 0;
-        
-        IMPORT_C virtual TBool GetBearerInfoBoolL( 
-                                                TUint32 aAttribute ) const = 0;
+        IMPORT_C virtual TUint32 GetBearerInfoIntL(
+                TUint32 aAttribute ) const = 0;
+
+        IMPORT_C virtual TBool GetBearerInfoBoolL(
+                TUint32 aAttribute ) const = 0;
 
-        IMPORT_C virtual HBufC* GetBearerInfoStringL( 
-                                                TUint32 aAttribute ) const = 0;
-        
-        IMPORT_C virtual HBufC8* GetBearerInfoString8L( 
-                                                TUint32 aAttribute ) const = 0;
+        IMPORT_C virtual HBufC* GetBearerInfoStringL(
+                TUint32 aAttribute ) const = 0;
+
+        IMPORT_C virtual HBufC8* GetBearerInfoString8L(
+                TUint32 aAttribute ) const = 0;
 
         /**
          * Checks if the plug-in can handle the Connection Method identified
@@ -261,14 +264,14 @@
          * @return ETrue if plug-in can handle the IAP, otherwise EFalse.
          */
         virtual TBool CanHandleIapIdL( TUint32 aIapId ) const = 0;
-         
+
         /**
          * Checks if the plug-in can handle the given IAP record.
          * @param aIapRecord IAP record to be checked
          * @return ETrue if plug-in can handle the IAP, otherwise EFalse.
          */
-        virtual TBool CanHandleIapIdL( 
-                 CommsDat::CCDIAPRecord* aIapRecord ) const = 0;
+        virtual TBool CanHandleIapIdL(
+                CommsDat::CCDIAPRecord* aIapRecord ) const = 0;
 
     public: // Client interface
         /**
@@ -284,37 +287,37 @@
         IMPORT_C void ReLoadL();
 
         /**
-         * Creates a new Connection Method in memory. Call UpdateL() to store 
+         * Creates a new Connection Method in memory. Call UpdateL() to store
          * it in CommsDat. No CommsDat transaction operation is needed for this.
-         * @param aCmId Predefined iapid to be used when saving to CommsDat. 
+         * @param aCmId Predefined iapid to be used when saving to CommsDat.
          *       0 means that CommsDat gives the id.
          */
         IMPORT_C void CreateNewL( TUint32 aCmId );
-         
+
         /**
          * Creates a copy of an existing Connection Method.
          * @param aClientPluginInstance The source data to create the copy from.
          * @return CCmPluginBaseEng type pointer to an object which represents
          * the new plugin to the CMM server.
          */
-        IMPORT_C CCmPluginBaseEng* CreateCopyL( 
-                         CCmClientPluginInstance* aClientPluginInstance );
+        IMPORT_C CCmPluginBaseEng* CreateCopyL(
+                CCmClientPluginInstance* aClientPluginInstance );
 
         /**
          * Updates all records to commsdat. Data is copied from the client's copy
          * to the original data.
-         * This method does not open/rollback/commit transaction to CommsDat. 
+         * This method does not open/rollback/commit transaction to CommsDat.
          * Caller must handle transactions.
          */
-        IMPORT_C virtual void UpdateL( 
+        IMPORT_C virtual void UpdateL(
                 CCmClientPluginInstance* aClientPluginInstance );
 
         /*
-         * Deletes all the records of this CM from the database. 
-         * All the preventing conditions must be checked before calling this. 
-         * This method does not open/rollback/commit transaction to CommsDat. 
+         * Deletes all the records of this CM from the database.
+         * All the preventing conditions must be checked before calling this.
+         * This method does not open/rollback/commit transaction to CommsDat.
          * Caller must handle transactions.
-         */    
+         */
         IMPORT_C virtual void DeleteL();
 
         /**
@@ -322,53 +325,61 @@
          * @param aClientPluginInstance An object where to copy the data.
          */
         IMPORT_C void GetPluginDataL( CCmClientPluginInstance* aClientPluginInstance );
-        
+
         /**
-         * Following GetXXXXAttributeL methods return the values of the 
+         * Following GetXXXXAttributeL methods return the values of the
          * requested attributes. Attributes are returned from the client's
          * copy of the data. These values are CM specific.
          * @param aAttribute An attribute identifier.
          * @param aClientPluginInstance Client's copy of the data where
          * to get the return value.
          * @return Returns the value requested. If not found leaves with
-         * KErrNotFound error code. 
+         * KErrNotFound error code.
          */
-        IMPORT_C TUint32 GetIntAttributeL( 
-                            TUint32 aAttribute, 
-                            CCmClientPluginInstance* aClientPluginInstance );
-        
-        IMPORT_C TBool GetBoolAttributeL( 
-                            TUint32 aAttribute,
-                            CCmClientPluginInstance* aClientPluginInstance );
-                                         
-        IMPORT_C HBufC* GetStringAttributeL( 
-                            TUint32 aAttribute, 
-                            CCmClientPluginInstance* aClientPluginInstance );
-        
-        IMPORT_C HBufC8* GetString8AttributeL( 
-                            TUint32 aAttribute, 
-                            CCmClientPluginInstance* aClientPluginInstance );
+        IMPORT_C TUint32 GetIntAttributeL(
+                TUint32 aAttribute,
+                CCmClientPluginInstance* aClientPluginInstance );
+
+        IMPORT_C TBool GetBoolAttributeL(
+                TUint32 aAttribute,
+                CCmClientPluginInstance* aClientPluginInstance );
+
+        IMPORT_C HBufC* GetStringAttributeL(
+                TUint32 aAttribute,
+                CCmClientPluginInstance* aClientPluginInstance );
+
+        IMPORT_C HBufC8* GetString8AttributeL(
+                TUint32 aAttribute,
+                CCmClientPluginInstance* aClientPluginInstance );
 
         /**
-         * Following SetXXXXAttributeL methods set the given values 
-         * identified with attributes. Attributes are set to the 
+         * Following SetXXXXAttributeL methods set the given values
+         * identified with attributes. Attributes are set to the
          * client's copy of the data.
          * @param aAttribute An attribute identifier.
          * @param aValue Value to set.
          * @param aClientPluginInstance Client's copy of the data where
          * to set the given value.
          */
-        IMPORT_C void SetIntAttributeL( TUint32 aAttribute, TUint32 aValue, 
-                                        CCmClientPluginInstance* aClientPluginInstance );
-        
-        IMPORT_C void SetBoolAttributeL( TUint32 aAttribute, TBool aValue,
-                                         CCmClientPluginInstance* aClientPluginInstance );
-                                         
-        IMPORT_C void SetStringAttributeL( TUint32 aAttribute, const TDesC16& aValue,
-                                           CCmClientPluginInstance* aClientPluginInstance );
-        
-        IMPORT_C void SetString8AttributeL( TUint32 aAttribute, const TDesC8& aValue,
-                                            CCmClientPluginInstance* aClientPluginInstance );
+        IMPORT_C void SetIntAttributeL(
+                TUint32 aAttribute,
+                TUint32 aValue,
+                CCmClientPluginInstance* aClientPluginInstance );
+
+        IMPORT_C void SetBoolAttributeL(
+                TUint32 aAttribute,
+                TBool aValue,
+                CCmClientPluginInstance* aClientPluginInstance );
+
+        IMPORT_C void SetStringAttributeL(
+                TUint32 aAttribute,
+                const TDesC16& aValue,
+                CCmClientPluginInstance* aClientPluginInstance );
+
+        IMPORT_C void SetString8AttributeL(
+                TUint32 aAttribute,
+                const TDesC8& aValue,
+                CCmClientPluginInstance* aClientPluginInstance );
 
         /**
          * Requests CommsDat table ids to be observed for changes by the cmm
@@ -386,99 +397,99 @@
          * @param aTableIdArray A reference to an array where plugin must add
          * the ids of the tables it want's to be observed.
          */
-        IMPORT_C virtual void GetBearerTableIdsToBeObservedL( 
+        IMPORT_C virtual void GetBearerTableIdsToBeObservedL(
                 RArray<TUint32>& aTableIdArray ) const = 0;
 
     public: // plugin interface
         /**
          * Creates a copy of all bearer specific CommsDat data for the client.
          * Called as result of GetPluginDataL().
-         * @param aRecordArray An array where the copy the records. Only 
+         * @param aRecordArray An array where the copy the records. Only
          * the bearer specific implementation knows the amount and order
          * of these records in the array.
          */
-        virtual void GetBearerSpecificRecordsL( 
+        virtual void GetBearerSpecificRecordsL(
                 RPointerArray<CommsDat::CCDRecordBase>& aRecordArray ) = 0;
 
         /**
          * Following GetBearerXXXXAttribute methods get only the
          * fields in records in pointer arrays(parameters).
          * @param aAttribute Identifier of the requested value.
-         * @param aGenRecordArray An array containing pointers to generic 
+         * @param aGenRecordArray An array containing pointers to generic
          * records of the Connection Method.
          * @param aBearerSpecRecordArray An array containing pointers to bearer
          * specific records of the Connection Method. aAttribute
          * parameter should identify one field(integer, boolean string)
-         * in one of these records. 
-         * @return Returns the requested value. In error case leaves with 
+         * in one of these records.
+         * @return Returns the requested value. In error case leaves with
          * system-wide error code.
          */
 
-        virtual TUint32 GetBearerIntAttributeL( 
-                TUint32 aAttribute, 
+        virtual TUint32 GetBearerIntAttributeL(
+                TUint32 aAttribute,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
-        
-        virtual TBool GetBearerBoolAttributeL( 
-                TUint32 aAttribute, 
+
+        virtual TBool GetBearerBoolAttributeL(
+                TUint32 aAttribute,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
-                                         
-        virtual HBufC* GetBearerStringAttributeL( 
-                TUint32 aAttribute, 
+
+        virtual HBufC* GetBearerStringAttributeL(
+                TUint32 aAttribute,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
-        
-        virtual HBufC8* GetBearerString8AttributeL( 
-                TUint32 aAttribute, 
+
+        virtual HBufC8* GetBearerString8AttributeL(
+                TUint32 aAttribute,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
 
         /**
          * Following SetBearerXXXXAttribute methods set only the
-         * fields in records in pointer arrays(parameters). They are not 
+         * fields in records in pointer arrays(parameters). They are not
          * allowed to update the original records in plugins.
          * @param aAttribute Identifier of the field to set.
          * @param aValue The value to set.
-         * @param aGenRecordArray An array containing pointers to generic 
+         * @param aGenRecordArray An array containing pointers to generic
          * records of the Connection Method.
          * @param aBearerSpecRecordArray An array containing pointers to bearer
          * specific records of the Connection Method. aAttribute
          * parameter should identify one field(integer, boolean string)
-         * in one of these records. 
+         * in one of these records.
          * @return None.
          */
 
-        virtual void SetBearerIntAttributeL( 
-                TUint32 aAttribute, 
-                TUint32 aValue, 
+        virtual void SetBearerIntAttributeL(
+                TUint32 aAttribute,
+                TUint32 aValue,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
-        
-        virtual void SetBearerBoolAttributeL( 
-                TUint32 aAttribute, 
+
+        virtual void SetBearerBoolAttributeL(
+                TUint32 aAttribute,
                 TBool aValue,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
-                                         
-        virtual void SetBearerStringAttributeL( 
-                TUint32 aAttribute, 
+
+        virtual void SetBearerStringAttributeL(
+                TUint32 aAttribute,
                 const TDesC16& aValue,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
 
-        virtual void SetBearerString8AttributeL( 
-                TUint32 aAttribute, 
-                const TDesC8& aValue,                                                    
+        virtual void SetBearerString8AttributeL(
+                TUint32 aAttribute,
+                const TDesC8& aValue,
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
 
         /**
-         * Inherited class can make some preraration before CCmPluginBaseEng 
+         * Inherited class can make some preraration before CCmPluginBaseEng
          * would start loading bearer specific records.
          */
         virtual void PreparePluginToLoadRecordsL() = 0;
-        
+
         /**
          * Gives the plugin a possibility to do some preparing operations
          * if needed.
@@ -487,10 +498,10 @@
         virtual void PrepareToCopyDataL( CCmPluginBaseEng* aCopyInstance ) = 0;
 
         /**
-         * Inherited class can make some preraration before CCmPluginBaseEng 
+         * Inherited class can make some preraration before CCmPluginBaseEng
          * would start to update all the records.
          * @param aGenRecordArray Reference to generic records pointer array.
-         * @param aBearerSpecRecordArray Reference to bearer specific records 
+         * @param aBearerSpecRecordArray Reference to bearer specific records
          * pointer array.
          */
         virtual void PreparePluginToUpdateRecordsL(
@@ -498,14 +509,14 @@
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
 
         /**
-         * Plugin can prepare to delete the Connection Method with this 
-         * function. Called from DeleteL() before any record would be 
+         * Plugin can prepare to delete the Connection Method with this
+         * function. Called from DeleteL() before any record would be
          * deleted. No records are deleted here.
          */
         virtual void PrepareToDeleteRecordsL(){};
 
         /**
-         * Loads the service record. Service record type is known and loaded by 
+         * Loads the service record. Service record type is known and loaded by
          * plugin(bearer specific) part of the implementation even if the record
          * is saved to the generic side. Service record is linked to IAP record.
          */
@@ -519,17 +530,17 @@
         /**
          * Update service record.
          * @param aGenRecordArray Reference to generic records pointer array.
-         * @param aBearerSpecRecordArray Reference to bearer specific records 
+         * @param aBearerSpecRecordArray Reference to bearer specific records
          * pointer array.
          */
-        virtual void UpdateServiceRecordL( 
+        virtual void UpdateServiceRecordL(
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
 
         /**
          * Copies the service record. Bearer specific part knows the type of it's
          * service record.
-         * @return Returns the service record pointer. 
+         * @return Returns the service record pointer.
          */
         virtual CommsDat::CCDRecordBase* CopyServiceRecordL() = 0;
 
@@ -541,14 +552,14 @@
 
         /**
          * Returns the service record name of the Connection Method.
-         * @param aServiceName Name of the service record the CM's iap record 
+         * @param aServiceName Name of the service record the CM's iap record
          * points to.
          */
         virtual void ServiceRecordNameLC( HBufC* &aServiceName ) = 0;
 
         /**
-         * Inherited class loads all the bearer specific records after 
-         * loading generic records. Called from LoadL(). 
+         * Inherited class loads all the bearer specific records after
+         * loading generic records. Called from LoadL().
          */
         virtual void LoadBearerRecordsL() = 0;
 
@@ -560,9 +571,9 @@
         /**
          * Update bearer specific records.
          * @param aGenRecordArray Reference to generic records pointer array.
-         * @param aBearerSpecRecordArray Reference to bearer specific records 
+         * @param aBearerSpecRecordArray Reference to bearer specific records
          */
-        virtual void UpdateBearerRecordsL( 
+        virtual void UpdateBearerRecordsL(
                 RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
                 RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray ) = 0;
 
@@ -572,50 +583,50 @@
          */
         virtual void DeleteBearerRecordsL() = 0;
 
-         /** 
-          * Resets the bearer specific records. 
-          */
-         virtual void ResetBearerRecords() = 0;
+        /**
+         * Resets the bearer specific records.
+         */
+        virtual void ResetBearerRecords() = 0;
 
         /**
-         * Copies the bearer specific records to copy instance given as 
-         * parameter. 
+         * Copies the bearer specific records to copy instance given as
+         * parameter.
          * @param aCopyInstance Pointer to instance where to copy.
          */
         virtual void CopyBearerRecordsL( CCmPluginBaseEng* aCopyInstance ) = 0;
 
         /**
          * Returns the bearer record id of the Connection Method.
-         * @param aRecordId Id of the bearer record this CM's iap record 
+         * @param aRecordId Id of the bearer record this CM's iap record
          * points to.
          */
         virtual void BearerRecordIdL( TUint32& aRecordId ) = 0;
 
         /**
          * Returns the bearer record name of the Connection Method.
-         * @param aBearerName Name of the bearer record this CM's iap record 
+         * @param aBearerName Name of the bearer record this CM's iap record
          * points to.
          */
         virtual void BearerRecordNameLC( HBufC* &aBearerName ) = 0;
 
     protected:
-        /** 
-         * Constructor 
+        /**
+         * Constructor
          */
         IMPORT_C CCmPluginBaseEng( TCmPluginInitParam *aInitParam );
-        
-        /** 
+
+        /**
          * Second phase constructor
          */
         IMPORT_C virtual void ConstructL();
-        
+
         /**
          * Checks if the ECmName attribute was set since the last update.
          * If so, name is updated in passed record
          * @param aSrcRecord record to be checked against
          * @param aDestRecord record to be checked against aSrcRecord
          */
-        IMPORT_C void CheckIfNameModifiedL( 
+        IMPORT_C void CheckIfNameModifiedL(
                 CommsDat::CCDRecordBase* aSrcRecord,
                 CommsDat::CCDRecordBase* aDestRecord ) const;
 
@@ -629,16 +640,28 @@
          * @param aDNS1 first DNS server address
          * @param aDNS1 secord DNS server address
          * @param aDNSFromServer DNS address from server flag
-         */                                            
-        IMPORT_C void CheckDNSServerAddressL( 
+         */
+        IMPORT_C void CheckDNSServerAddressL(
                 TBool aIPv6,
                 CommsDat::CMDBField<TDesC>& aDNS1,
                 CommsDat::CMDBField<TDesC>& aDNS2,
                 CommsDat::CMDBField<TBool>& aDNSFromServer );
 
+        /**
+         * Copies the values and attributes of all fields from aSource-record
+         * into aDestination record.
+         * Does not copy the record element ID. Also, does not touch any field
+         * in aDestination-record that is NULL in aSource-record.
+         * @param aSource The record that is copied from.
+         * @param aDestination The record that is copied to.
+         */
+        IMPORT_C void CopyRecordFieldsL(
+                CommsDat::CMDBRecordBase& aSource,
+                CommsDat::CMDBRecordBase& aDestination );
+
     private:
         /**
-         * Handles all the Connection Method data copying to instance given as 
+         * Handles all the Connection Method data copying to instance given as
          * parameter. This is called from CreateCopyL().
          * @ param aCopyInstance Pointer to plugin to copy the data.
          */
@@ -654,28 +677,29 @@
         /**
          * Copies the record identified by aRecordIdentifier to copy instance.
          * @param aRecordIdentifier Identifies the record which is copied copy.
-         * @param aCopyInstance Pointer to plugin to copy the data. 
+         * @param aCopyInstance Pointer to plugin to copy the data.
          */
-        void CopyRecordDataL( TUint32 aRecordIdentifier,
-                              CCmPluginBaseEng* aCopyInstance );
+        void CopyRecordDataL(
+                TUint32 aRecordIdentifier,
+                CCmPluginBaseEng* aCopyInstance );
 
         /**
          * Creates proxy record and sets the proxy settings enabled for this
          * Connection Method.
          */
         void EnableProxyL( TBool aEnable );
-        
+
         /**
-         * Creates location record and sets the location enabled for this 
+         * Creates location record and sets the location enabled for this
          * Connection Method.
          */
         void EnableLocationL( TBool aEnable );
 
         /**
-         * Calls all the loading methods. 
+         * Calls all the loading methods.
          */
         void DoLoadL( TUint32 aIapId );
-        
+
         /**
          * Loads IAP record.
          * @param aIapId Identifies the IAP record to load.
@@ -693,7 +717,7 @@
          * of calling LoadL().
          */
         void LoadNetworkRecordL();
-        
+
         /**
          * Loads location record related to this IAP. This is called as a result
          * of calling LoadL().
@@ -711,12 +735,12 @@
          * of calling LoadL().
          */
         void LoadMetadataRecordL();
-        
+
         /**
          * Following methods are called as a result of calling method UpdateL().
          * Each method overwrites the original data in memory with the client copy
          * of that data. Client data has all the possible changes set by client.
-         * After overwrite the data is written to CommsDat. 
+         * After overwrite the data is written to CommsDat.
          * @param aClientPluginInstance The client copy of the original data with the
          * possible changes.
          */
@@ -728,14 +752,14 @@
         void UpdateWapRecordL( CCmClientPluginInstance* aClientPluginInstance );
         void UpdateMetadataRecordL( CCmClientPluginInstance* aClientPluginInstance );
         void UpdateServiceRecordL( CCmClientPluginInstance* aClientPluginInstance );
-        
+
         /**
         * Creates new wap records.
         */
         void NewWapRecordL();
 
         /**
-         * Searches the WAP records related to this iap. This is called as a 
+         * Searches the WAP records related to this iap. This is called as a
          * result of LoadL().
          * @return Returns pointer to WAP IP record. If it's not found NULL is
          * returned.
@@ -748,14 +772,14 @@
         * @return Returns metadata record pointer.
         */
         CCDIAPMetadataRecord* NewMetadataRecordL( TBool aSetDef );
-        
+
         /**
-         * Searches the metadata record belonging to this iap. This is called as a 
+         * Searches the metadata record belonging to this iap. This is called as a
          * result of LoadL().
          * @return Returns pointer to WAP IP record. If it's not found NULL is
          * returned.
          */
-        CCDIAPMetadataRecord* FindMetadataRecordL();
+        CCDIAPMetadataRecord* FindMetadataRecordL(); //TODO, check comment, return value...
 
         /**
         * Set attribute flag on the given record.
@@ -763,19 +787,21 @@
         * @param aAttribute Attribute to be set.
         * @param aSet ETrue to set, EFalse to clear
         */
-        void SetAttribute( CommsDat::CCDRecordBase* aRecord, 
-                           TUint32 aAttribute, 
-                           TBool aSet );
-                           
+        void SetAttribute(
+                CommsDat::CCDRecordBase* aRecord,
+                TUint32 aAttribute,
+                TBool aSet );
+
         /**
         * Copy the attributes of the source record to the destination.
         * @param aSrcRecord record of which attributes are copied
         * @param ADstRecord record of which attributes are set
         */
-        void CopyAttributes( CommsDat::CCDRecordBase* aSrcRecord, 
-                             CommsDat::CCDRecordBase* aDstRecord );
+        void CopyAttributes(
+                CommsDat::CCDRecordBase* aSrcRecord,
+                CommsDat::CCDRecordBase* aDstRecord );
 
-        
+
         /**
         * Returns the default location record id.
         * @return Returns the default location record id.
@@ -785,16 +811,16 @@
     private:
 
         /**
-         * Gives a possibility to make some prerarations before 
+         * Gives a possibility to make some prerarations before
          * starting to load bearer specific records.
          */
         void PrepareToLoadRecordsL();
 
         /**
-         * Gives a possibility to make some prerarations before 
+         * Gives a possibility to make some prerarations before
          * starting to update bearer specific records.
          */
-        void PrepareToUpdateRecordsL( 
+        void PrepareToUpdateRecordsL(
                 CCmClientPluginInstance* aClientPluginInstance );
 
         /**
@@ -802,7 +828,7 @@
          * @return Returns the element id of the iap record.
          */
         CommsDat::TMDBElementId IAPRecordElementId() const;
-        
+
         /**
          * Checks the protection attribute of the IAP.
          * @return Returns ETrue if the IAP is protected. Otherwise returns
@@ -813,36 +839,35 @@
         /**
          * Sets the name of the proxy server to proxy record. If name's
          * length is 0, proxyport is set to 0 and proxyserver usage
-         * boolean is set to EFalse. If the name is longer than 0, 
+         * boolean is set to EFalse. If the name is longer than 0,
          * boolean is set to ETrue.
          * @param aProxyServer Address to be set.
          * @param Record pointer where to set.
          */
-        void SetProxyServerNameL( const TDesC& aProxyServer,
-                                  CommsDat::CCDRecordBase* aProxyRecord );
+        void SetProxyServerNameL(
+                const TDesC& aProxyServer,
+                CommsDat::CCDRecordBase* aProxyRecord );
 
         /**
          * Sets a name to IAP.
          * @param aName Name to set.
-         * @param aClientPluginInstance Client copy of data where to set the 
+         * @param aClientPluginInstance Client copy of data where to set the
          * name. UpdateL() updates the name to the CommsDat.
          */
-        void SetNameL( const TDesC& aName,
-                       CommsDat::CCDRecordBase* aIapRecord,
-                       const CMManager::TNamingMethod aNamingMethod );
+        void SetNameL(
+                const TDesC& aName,
+                CommsDat::CCDRecordBase* aIapRecord,
+                const CMManager::TNamingMethod aNamingMethod );
 
         /**
          * Following methods are called as a result of SetNameL() to
          * make a valid name of the given string.
          */
-        HBufC* DoMakeValidNameL( const TDesC& aName, 
-                                 const TUint32& aIapId );
-        HBufC* EnsureMaxLengthLC( const TDesC& aName, 
-                                  TBool& aChanged );
+        HBufC* DoMakeValidNameL( const TDesC& aName, const TUint32& aIapId );
+        HBufC* EnsureMaxLengthLC( const TDesC& aName, TBool& aChanged );
         TPtrC GetPrefix( const TDesC& aName );
         TInt GetPostfix( const TDesC& aName, const TDesC& aPrefix );
-        TBool IsValidNameL( const TDesC& aNameText,
-                            const TUint32& aIapId );
+        TBool IsValidNameL( const TDesC& aNameText, const TUint32& aIapId );
         HBufC* EscapeTextLC( const TDesC& aLiteral );
         void SetDefaultNameL( const TDesC& aName );
 
@@ -854,8 +879,8 @@
 
         /**
         * Check if the passed IP address is one of these:
-        * - empty string    -   
-        * - '0:0:0:0:0:0:0:0' 
+        * - empty string    -
+        * - '0:0:0:0:0:0:0:0'
         * - 'fec0:000:0000:ffff::1'
         * - 'fec0:000:0000:ffff::2'
         * @param aIpAddress IP address to be checked
@@ -863,7 +888,7 @@
         CMManager::TIPv6Types ClassifyIPv6Address( const TDesC& aIpv6Address );
 
     public: // Data
-    
+
         // Required attribute for the framework
         // (An identifier used during destruction)
         TUid    iDtor_ID_Key;
@@ -877,7 +902,7 @@
         CommsDat::CMDBSession& iSession;
 
         /**
-         * Generic record pointers. 
+         * Generic record pointers.
          */
         CommsDat::CCDIAPRecord*             iIapRecord;
         CommsDat::CCDProxiesRecord*         iProxyRecord;
@@ -887,29 +912,29 @@
         CommsDat::CCDWAPAccessPointRecord*  iWapAPRecord;
         CommsDat::CCDWAPIPBearerRecord*     iWapIPBearerRecord;
         CCDIAPMetadataRecord*               iMetaDataRecord;
-        
-    private:
+
         /**
          * IAP record id of the CM. 0 means that this is not stored to CommsDat
-         * yet. If in UpdateL phase iap record has an id but iIapId == 0 --> 
+         * yet. If in UpdateL phase iap record has an id but iIapId == 0 -->
          * predefined iap id
          */
-        TUint32         iIapId;
+        TUint32 iCmId;
 
+    private:
         /**
          * Naming method of the CM.
          */
-        CMManager::TNamingMethod    iNamingMethod;
-        
+        CMManager::TNamingMethod iNamingMethod;
+
         /**
-         * Table id of the iap metadata table. 
+         * Table id of the iap metadata table.
          */
-        CommsDat::TMDBElementId     iMetadataTableId;
-        
+        CommsDat::TMDBElementId iMetadataTableId;
+
         /**
          * Identifies if the location is enabled.
          */
-        TBool                       iLocationEnabled;
+        TBool iLocationEnabled;
     };
-    
+
 #endif // CMPLUGINBASEENG_H
--- a/ipcm_plat/commsdat_wlan_api/inc/cmmanagertablefields.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/commsdat_wlan_api/inc/cmmanagertablefields.h	Thu Jul 22 16:37:38 2010 +0100
@@ -23,9 +23,9 @@
 
 // INCLUDES
 #include <e32base.h>
-#include <Metadatabase.h>
+#include <metadatabase.h>
 #include <WlanCdbCols.h>
-#include <CommsDatTypesV1_1.h>
+#include <commsdattypesv1_1.h>
 
 using namespace CommsDat;
 
--- a/ipcm_plat/commsdat_wlan_api/inc/wlancontainer.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/commsdat_wlan_api/inc/wlancontainer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -23,8 +23,8 @@
 
 // INCLUDES
 #include <e32base.h>
-#include <Metadatabase.h>
-#include <CommsDatTypesV1_1.h>
+#include <metadatabase.h>
+#include <commsdattypesv1_1.h>
 #include <cmmanagertablefields.h>
 
 // FORWARD DECLARATIONS
--- a/ipcm_plat/connection_settings_shim_api/inc/cmconnectionmethod_shim.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/connection_settings_shim_api/inc/cmconnectionmethod_shim.h	Thu Jul 22 16:37:38 2010 +0100
@@ -164,6 +164,21 @@
     void update();
     
     /*!
+     * Gets the icon identifier(name) of the connection method. It can
+     * contain path information.
+     * @return Contains string representing icon
+     */
+    QString getIcon() const;
+    
+    /*!
+     * Sets the icon identifier(name) of the destination. It can
+     * contain path information.
+     * 
+     * @param icon New icon
+     */      
+    void setIcon(QString icon);
+    
+    /*!
      * Reload the contents of the connection method from database.
      * Any current changes made to the connection method are lost.
      */
--- a/ipcm_plat/connection_settings_shim_api/inc/cmdestination_shim.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/connection_settings_shim_api/inc/cmdestination_shim.h	Thu Jul 22 16:37:38 2010 +0100
@@ -198,6 +198,22 @@
      * not deleted.
      */
     void deleteDestination();
+    
+    /*!
+     * Gets the icon identifier(name) of the destination. It can
+     * contain path information.
+     * 
+     * @return Name of the Icon
+     */      
+    QString getIcon() const;
+    
+    /*!
+     * Sets the icon identifier(name) of the destination. It can
+     * contain path information.
+     * 
+     * @param icon New icon
+     */      
+    void setIcon(QString icon);
 
 protected:
 
--- a/ipcm_plat/connection_settings_shim_api/inc/cmmanager_shim.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/connection_settings_shim_api/inc/cmmanager_shim.h	Thu Jul 22 16:37:38 2010 +0100
@@ -119,6 +119,14 @@
      */ 
     void allDestinations(QList<uint> &destArray) const;
     
+    /*!
+     * Gets the "Uncategorized" icon identifier(name). It can
+     * contain path information.
+     * 
+     * @return Name of the Icon
+     */      
+    QString getUncategorizedIcon() const;
+    
 protected:
 
 private:
--- a/ipcm_plat/connection_settings_shim_api/inc/cmmanagerdefines_shim.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/connection_settings_shim_api/inc/cmmanagerdefines_shim.h	Thu Jul 22 16:37:38 2010 +0100
@@ -1,25 +1,26 @@
 /*
- * Copyright (c) 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""
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- *
- * Description:  
- * Defines for data types and attributes used in CmManagerShim interface.
- */
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+* Defines for data types and attributes used in CmManagerShim interface.
+*/
 
 #ifndef CMMANAGERDEFINES_SHIM_H
 #define CMMANAGERDEFINES_SHIM_H
 
 // System includes
 
+#include <QString>
 #include <cmmanagerdef.h>
 #include <cmconnectionmethoddef.h>
 #include <cmpluginwlandef.h>
@@ -64,7 +65,7 @@
      *  Constants for maximum string lengths.
      */
     //! Connection name length
-    const uint CmNameLength                 = 30;
+    const uint CmNameLength                 = 50;
     //! Homepage address length
     const uint CmStartPageLength            = 1024;
     //! IPv4 IP address length
@@ -88,7 +89,9 @@
      *  Enumerations for connection method attributes.
      */
     enum ConnectionMethodAttribute {
-        // Common attributes        
+        // Common attributes
+        //! From TConnectionMethodCommonAttributes in cmconnectionmethoddef.h
+        CmDestination                   = CMManager::ECmDestination,
         //! From TConnectionMethodCommonAttributes in cmconnectionmethoddef.h
         CmBearerType                    = CMManager::ECmBearerType,
         //! From TConnectionMethodCommonAttributes in cmconnectionmethoddef.h
@@ -137,6 +140,8 @@
         CmProxyServerName               = CMManager::ECmProxyServerName,
         //! From TConnectionMethodCommonAttributes in cmconnectionmethoddef.h
         CmProxyPortNumber               = CMManager::ECmProxyPortNumber,
+        //! From TConnectionMethodCommonAttributes in cmconnectionmethoddef.h
+        CmMetaHotSpot                   = CMManager::ECmMetaHotSpot,
 
         // Packet data specific attributes
         /*!
@@ -220,6 +225,8 @@
         //!  From TConnectionMethodWlanSpecificAttributes in cmpluginwlandef.h
         WlanScanSSID                    = CMManager::EWlanScanSSID,
         //!  From TConnectionMethodWlanSpecificAttributes in cmpluginwlandef.h
+        WlanChannelID                   = CMManager::EWlanChannelID,
+        //!  From TConnectionMethodWlanSpecificAttributes in cmpluginwlandef.h
         WlanWepKey1InHex                = CMManager::EWlanWepKey1InHex,
         //!  From TConnectionMethodWlanSpecificAttributes in cmpluginwlandef.h
         WlanWepKey2InHex                = CMManager::EWlanWepKey2InHex,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/flextimer_api/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:               FlexTimer API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/rflextimer.h			MW_LAYER_PLATFORM_EXPORT_PATH(rflextimer.h)
+../inc/flextimer.h			MW_LAYER_PLATFORM_EXPORT_PATH(flextimer.h)
+../inc/flexperiodic.h		MW_LAYER_PLATFORM_EXPORT_PATH(flexperiodic.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/flextimer_api/inc/flexperiodic.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,415 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  CFlexPeriodic class for Flexible Timer server access.
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+
+#ifndef CFLEXPERIODIC_H
+#define CFLEXPERIODIC_H
+
+// INCLUDE FILES
+#include "flextimer.h"
+
+// CLASS DECLARATION
+/**
+ *  Class providing access to flexible periodic timer service.
+ *  This class inherits CFlexTimer and provides user with a periodic
+ *  timer very similar to CPeriodic with the exception that both
+ *  the initial delay and the consequent intervals have flexible
+ *  windows of opportunity during which they may expire.
+ *  
+ *  The flexible window sizes are set with Configure-function. If these window
+ *  sizes are not explicitly set by the user, a default window size is used.
+ *  See RFlexTimer for details about default window. 
+ *  
+ *  Note that when CFlexPeriodic expires next expiry interval always starts 
+ *  at that moment. This means that over time, timer expiry can start to 
+ *  "slide" when comparing to CPeriodic. 
+ *  
+ *  For example: CPeriodic is started at 8 o'clock with 30 minute interval.
+ *  It will then expire at 8.30, 9.00, ... 15.30, 16.00
+ *  
+ *  If CFlexPeriodic is used as a timer it can possibly expire at
+ *  8.30, 9.00, 9.28, 9.55, ... 15.45, 16.12 etc. 
+ *
+ *  @see CFlexTimer
+ *  @see RFlexTimer
+ *  @see CPeriodic
+ *
+ *  Example:
+ *  
+ *  Class definition:
+ *  @code
+ *  // Forward declaration
+ *  class CFlexPeriodic;
+ *
+ *  // Class definition
+ *  class CMyNetworkServiceMonitor : public CBase
+ *      {
+ *      public: // Members
+ *
+ *          // Destructor
+ *          virtual ~CMyNetworkServiceMonitor();
+ *
+ *          // Two-phased constructor
+ *          static CMyNetworkServiceMonitor* NewL(
+ *              TTimeIntervalMicroSeconds aWindow,
+ *              TTimeIntervalMicroSeconds aInterval );
+ *
+ *      private: // Members
+ *
+ *          // Constructor
+ *          CMyNetworkServiceMonitor();
+ *
+ *          // 2nd phase constuctor
+ *          void ConstructL(
+ *              TTimeIntervalMicroSeconds aWindow,
+ *              TTimeIntervalMicroSeconds aInterval );
+ *
+ *          // Callback function for periodic timer. A function for TCallBack.
+ *          static TInt DoMonitoring( TAny* aArgument );
+ *
+ *          // Callback function for timer server errors. A function for 
+ *          // TCallBack.
+ *          static TInt HandleError( TAny* aArgument );
+ *
+ *          // Does the network server monitoring.
+ *          // Implementation is not provided by this example.
+ *          DoNetworkServiceMonitoring();
+ *
+ *      private: // Data
+ *
+ *          // Owns. Flexible periodic timer.
+ *          CFlexPeriodic* iTimer;
+ *      };
+ *  @endcode
+ *
+ *  Class implementation:
+ *  @code
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor::CMyNetworkServiceMonitor() : iTimer( NULL )
+ *      {
+ *      // Nothing to do
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor::~CMyNetworkServiceMonitor()
+ *      {
+ *      if ( iTimer != NULL )
+ *          {
+ *          iTimer->Cancel(); // Cancel pending timer
+ *          delete iTimer;
+ *          }
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor* CMyNetworkServiceMonitor::NewL(
+ *      TTimeIntervalMicroSeconds aWindow,
+ *      TTimeIntervalMicroSeconds aInterval )
+ *      {
+ *      CMyNetworkServiceMonitor* self =
+ *          new (ELeave) CMyNetworkServiceMonitor;
+ *      CleanupStack::PushL( self );
+ *      self->ConstructL( aWindow, aInterval );
+ *      CleanupStack::Pop( self );
+ *      return self;
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  void CMyNetworkServiceMonitor::ConstructL(
+ *      TTimeIntervalMicroSeconds aWindow,
+ *      TTimeIntervalMicroSeconds aInterval )
+ *      {
+ *      // Constants
+ *      const TTimeIntervalMicroSeconds KNoWindow( 0 );
+ *      const TTimeIntervalMicroSeconds KImmediately( 0 );
+ *
+ *      iTimer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+ *
+ *      // Push timer to cleanup stack due configuration may leave
+ *      CleanupStack::PushL( iTimer );
+ *
+ *      // Set delay window 0 minute
+ *      User::LeaveIfError( 
+ *          iTimer->Configure( KNoWindow, aWindow ) );
+ *
+ *      // Start the timer, 1st call immediately
+ *      iTimer->Start(
+ *          KImmediately,
+ *          aInterval,
+ *          TCallBack( DoMonitoring, this ),
+ *          TCallBack( HandleError, this ) );
+ *
+ *      CleanupStack::Pop( iTimer );
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  TInt CMyNetworkServiceMonitor::DoMonitoring( TAny* aArgument )
+ *      {
+ *      CMyNetworkServiceMonitor* monitor =
+ *          static_cast<CMyNetworkServiceMonitor*>( aArgument );
+ *
+ *      monitor->DoNetworkServerMonitoring();
+ *      return KErrNone;
+ *      }
+ *     
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  TInt CMyNetworkServiceMonitor::HandleError( TAny* aArgument )
+ *      {
+ *      CMyNetworkServiceMonitor* monitor =
+ *          static_cast<CMyNetworkServiceMonitor*>( aArgument );
+ *
+ *      // Handling of the timer server error (e.g. closing up the application)
+ *      // here.
+ *          .
+ *          .
+ *          .
+ *      return KErrNone;
+ *      }     
+ *  @endcode
+ */
+class CFlexPeriodic : public CFlexTimer
+    {
+public:
+
+    /**
+     * A leaving constructor for the object.
+     * 
+     * @param aPriority Priority of the active object. Type CActive::TPriority
+     * 
+     * @return A pointer to a CFlexPeriodic object on success.
+     * 
+     * @leave KErrMemory Not enough memory
+     */
+    static IMPORT_C CFlexPeriodic* NewL( TInt aPriority );
+
+    /**
+     * Destructor for the object.
+     */
+    virtual IMPORT_C ~CFlexPeriodic();
+
+    /**
+     * Starts the periodic timer. After the timer has been started, it first
+     * calls aCallBack function after the aDelay time has expired. Thereafter
+     * the aCallBack function is called periodically after anInterval from the
+     * previous expiry has elapsed. All the expirations happen within timing
+     * tolerancies indicated by the flexibility windows. The flexibility
+     * window sizes are set with a Configure-function. The Configure needs to
+     * be called before Starting the periodic timer. 32-bit delay and interval
+     * values.
+
+     * @param aDelay is the initial delay between this Start-function and the
+     * first timer expiry. This value presents the maximum delay - flexibility
+     * is applied to a time window opening prior to this.
+     * @param anInterval is the size of the intervals after the initial delay.
+     * This value presents the maximum interval - flexibility is applied to
+     * a time window opening prior to this. Interval must be at least one 
+     * microsecond.
+     * @param aCallBack is a reference to a function that is executed at each
+     * expiry of the timer. NULL call back function reference is prohibited.
+     * @param aCallBackError optional, but recommended parameter is a 
+     * reference to a function that is executed if error occurs somewhere 
+     * in FlexTimer system (e.g. memory allocation failed). 
+     * If user does not provide this argument and error occurs, client 
+     * is paniced. Recommended action in case of error is to hold back all 
+     * actions for a while and give system some time to recover and free 
+     * resources.
+     *
+     * @panic CFlexPeriodic  6 aDelay is negative
+     * @panic CFlexPeriodic  7 aInterval is zero or negative
+     * @panic CFlexPeriodic 31 aCallBack.iFunction is NULL
+     * @panic RFlexTimer    15 Start() has been called twice without 
+     * cancelling the timer first
+     *
+     * @see Configure
+     */
+    IMPORT_C void Start( TTimeIntervalMicroSeconds32 aDelay,
+                         TTimeIntervalMicroSeconds32 anInterval,
+                         TCallBack aCallBack,
+                         TCallBack aCallBackError = TCallBack() );
+    
+    /**
+     * This function overloads the Start-function with 64-bit delay and
+     * interval values.
+     *
+     * @param aDelay is the initial delay between this Start-function and the
+     * first timer expiry. This value presents the maximum delay - flexibility
+     * is applied to a time window opening prior to this.
+     * @param anInterval is the size of the intervals after the initial delay.
+     * This value presents the maximum interval - flexibility is applied to
+     * a time window opening prior to this. Interval must be at least one 
+     * microsecond.
+     * @param aCallBack is a reference to a function that is executed at each
+     * expiry of the timer. NULL call back function reference is prohibited.
+     * @param aCallBackError optional, but recommended parameter is a 
+     * reference to a function that is executed if error occurs somewhere 
+     * in FlexTimer system (e.g. memory allocation failed). 
+     * If user does not provide this argument and error occurs, client 
+     * is paniced. Recommended action in case of error is to hold back all 
+     * actions for a while and give system some time to recover and free 
+     * resources.
+     *
+     * @panic CFlexPeriodic  6 aDelay is negative
+     * @panic CFlexPeriodic  7 aInterval is zero or negative
+     * @panic CFlexPeriodic 31 aCallBack.iFunction is NULL
+     * @panic RFlexTimer    15 Start() has been called twice without 
+     * cancelling the timer first
+     * @panic RFlexTimer    24 aDelay or aInterval is too long (over 730 days)
+     *
+     * @see Configure
+     */
+    IMPORT_C void Start( TTimeIntervalMicroSeconds aDelay,
+                         TTimeIntervalMicroSeconds anInterval,
+                         TCallBack aCallBack,
+                         TCallBack aCallBackError = TCallBack() );
+
+    /**
+     * Sets the window sizes inside which the timer can expire. Must be called
+     * before timer is started. If configure is called after the timer has
+     * been Started, this function returns an error code.
+     * 
+     * The window sizes set with this function override the default window
+     * sizes. @see RFlexTimer::Configure
+     *
+     * @param aDelayWindow is the flexibility window size in 32-bit
+     * microseconds for the initial delay.
+     * @param aIntervalWindow is the flexibility window size in 32-bit
+     * microseconds for the intervals after the initial delay.
+     *
+     * @return KErrNone on success. KErrInUse, if timer has been
+     * started already. In case of error, the window sizes not established
+     * into the timer and need to be configured again.
+     *
+     * @panic CFlexPeriodic  8 aDelayWindow is negative
+     * @panic CFlexPeriodic  9 aIntervalWindow is negative
+     */
+    IMPORT_C TInt Configure( TTimeIntervalMicroSeconds32 aDelayWindow,
+                             TTimeIntervalMicroSeconds32 aIntervalWindow );
+
+    /**
+     * This function overloads the Configure-function with 64-bit parameters.
+     *
+     * @param aDelayWindow is the flexibility window size in 64-bit 
+     * microseconds for the initial delay.
+     * @param aIntervalWindow is the flexibility window size in 64-bit
+     * microseconds for the intervals after the initial delay.
+     *
+     * @return KErrNone on success. KErrInUse, if timer has been
+     * started already. In case of error, the window sizes not established
+     * into the timer and need to be configured again.
+     *
+     * @panic CFlexPeriodic  8 aDelayWindow is negative
+     * @panic CFlexPeriodic  9 aIntervalWindow is negative
+     * @panic RFlexTimer    24 aDelayWindow or aIntervalWindow is too long 
+     * (over 730 days)
+     */
+    IMPORT_C TInt Configure( TTimeIntervalMicroSeconds aDelayWindow,
+                             TTimeIntervalMicroSeconds aIntervalWindow );
+
+protected:
+
+    /**
+     * Inherited from CActive.
+     */
+    virtual void RunL();
+    
+private:
+
+    /**
+     * Constructs the object. The second phase of the construction.
+     */
+    void ConstructL();
+
+    /**
+     * Private constructor for the object.
+     * @param aPriority The priority of the active object. If timing is
+     * critical, it should be higher than that of all other active objects
+     * owned by the scheduler.
+     */
+    CFlexPeriodic( TInt aPriority );
+
+private:
+    
+    /**
+     * No definition. This function is not to be used through CFlexPeriodic.
+     * @see CFlexTimer
+     */
+    void After( TTimeIntervalMicroSeconds32 aInterval );
+    
+    /**
+     * No definition. This function is not to be used through CFlexPeriodic.
+     * @see CFlexTimer
+     */
+    void After( TTimeIntervalMicroSeconds aInterval );
+
+    /**
+     * No definition. This function is not to be used through CFlexPeriodic.
+     * @see CFlexTimer
+     */
+    void At( const TTime& aTime );
+
+    /**
+     * No definition. This function is not to be used through CFlexPeriodic.
+     * @see CFlexTimer
+     */
+    void AtUTC( const TTime& aTime );
+    
+    /**
+     * No definition. This function is not to be used through CFlexPeriodic.
+     * @see CFlexTimer
+     */
+    TInt Configure( TTimeIntervalMicroSeconds32 aWindowSize );
+
+    /**
+     * Interval value that is used after the initial delay.
+     */
+    TTimeIntervalMicroSeconds iInterval;
+
+    /**
+     * Flex window size that is used after the initial delay.
+     */
+    TTimeIntervalMicroSeconds iIntervalWindow;
+
+    /**
+     * The callback function which is called at the completion of
+     * flextimer server requests.
+     */
+    TCallBack iCallBack;
+    
+    /**
+     * The callback function which is called if error accurs
+     * somewhere in FlexTimerSystem. i.e. Error code is returned
+     * to RunL.
+     */
+    TCallBack iCallBackError;
+    
+    /**
+     * This member stores information, whether the interval configuration
+     * should be sent to the server or not.
+     */
+    TBool   iSendConfigure;
+
+    };
+
+#endif /* CFLEXPERIODIC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/flextimer_api/inc/flextimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  CFlexTimer class for Flexible Timer server access.
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+
+#ifndef CFLEXTIMER_H
+#define CFLEXTIMER_H
+
+// INCLUDE FILES
+#include <e32base.h> 
+#include "rflextimer.h"
+
+// CLASS DECLARATION
+/**
+ *  Class providing access to flexible timer service.
+ *  This class uses RFlexTimer to provide user with timeout services. Each
+ *  timeout that is requested with this class has a time window during which
+ *  it may expire. The size of this window needs to be configured by the user.
+ *  If not configured, a default window size is used. See RFlexTimer for 
+ *  details about default window. 
+ *  
+ *  This class can not be instantiated; it needs to be inherited by a
+ *  user's derived class. The user also needs to implement the RunL
+ *  function.
+ *  
+ *  The timer returns one of the following values for TRequestStatus or any
+ *  other system-wide error codes:
+ *  
+ *  <table border=1 bordercolor="#84B0C7" cellspacing="0" align="center">
+ *  <tr>
+ *      <th>Return value</th>
+ *      <th>Description</th>
+ *      <th>@c At()</th>
+ *      <th>@c AtUTC()</th>
+ *      <th>@c After()</th>
+ *  </tr>
+ *  <tr>
+ *      <td>@c KErrNone</td>
+ *      <td>Timer has expired normally</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>  
+ *      <td align="center">X</td>
+ *  </tr>
+ *  <tr>
+ *      <td>@c KErrCancel</td>
+ *      <td>Timer has been cancelled</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *  </tr>
+ *  <tr>
+ *      <td>@c KErrAbort</td>
+ *      <td>Timer has been aborted due time change</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *      <td align="center">&nbsp;</td>
+ *  </tr>
+ *  </table>
+ *  
+ *  Any object derived from this class needs to connect to the flextimer
+ *  server by calling CFlexTimer::ConstructL() function before calling 
+ *  configuration or timeout functions. Otherwise any timeout function will
+ *  result in panic.
+ *
+ *  @see RFlexTimer
+ *  @see CTimer
+ *
+ *  Example:
+ *  
+ *  Class definition:
+ *  @code
+ *  class CMyNetworkServiceMonitor : public CFlexTimer
+ *      {
+ *      public: // Members
+ *
+ *          // Public two-phased constructor
+ *          static CMyNetworkServiceMonitor* NewL( 
+ *              TTimeIntervalMicroSeconds aWindow,
+ *              TTimeIntervalMicroSeconds aInterval );
+ *
+ *          // Destructor
+ *          virtual ~CMyNetworkServiceMonitor();
+ *
+ *      protected: // From CActive
+ *
+ *          // Handles an active object's request completion event
+ *          virtual void RunL();
+ *
+ *      private: // Members
+ *
+ *          // Private constructor
+ *          CMyNetworkServiceMonitor( TTimeIntervalMicroSeconds aInterval );
+ *
+ *          // Second phase constructor
+ *          void ConstructL( TTimeIntervalMicroSeconds aWindow );
+ *
+ *          // Does the network server monitoring.
+ *          // Implementation is not provided by this example.
+ *          DoNetworkServiceMonitoring();
+ *
+ *      private: // Data
+ *
+ *          TTimeIntervalMicroSeconds iInterval;
+ *      };
+ *  @endcode
+ *
+ *  Class implementation:
+ *  @code
+ *  CMyNetworkServiceMonitor::CMyNetworkServiceMonitor( TTimeIntervalMicroSeconds aInterval ) :
+ *      CFlexTimer( CActive::EPriorityStandard ),
+ *      iInterval( aInterval )
+ *      {
+ *      // Nothing to do
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor::~CMyNetworkServiceMonitor()
+ *      {
+ *      Cancel(); // DoCancel() is implemented by CFlexTimer
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  void CMyNetworkServiceMonitor::ConstructL( TTimeIntervalMicroSeconds aWindow )
+ *      {
+ *      const TTimeIntervalMicroSeconds KImmediately( 0 );
+ *
+ *      CFlexTimer::ConstructL();
+ *      CActiveScheduler::Add( this );
+ *
+ *      Configure( aWindow );
+ *
+ *      After( KImmediately );  // Kick-off the timer
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor* CMyNetworkServiceMonitor::NewL(
+ *      TTimeIntervalMicroSeconds aWindow,
+ *      TTimeIntervalMicroSeconds aInterval   )
+ *      {
+ *      CMyNetworkServiceMonitor* self =
+ *          new (ELeave) CMyNetworkServiceMonitor( aInterval );
+ *      CleanupStack::PushL( self );
+ *      self->ConstructL( aWindow );
+ *      CleanupStack::Pop( self );
+ *      return self;
+ *      }
+ *
+ *  // ---------------------------------------------------------------------------
+ *  //
+ *  void CMyNetworkServiceMonitor::RunL()
+ *      {
+ *      // Note! If used RFlexTimer::At() or RFlexTimer::AtUTC()
+ *      // iStatus == KErrAbort should also be handled.
+ *    
+ *      if ( iStatus == KErrNone )
+ *          {
+ *          // Do the network server monitor actions
+ *          DoNetworkServiceMonitoring();
+ *
+ *          // Refresh the timer
+ *          After( iInterval );
+ *          }
+ *      else if ( iStatus == KErrCancel )
+ *          {
+ *          // Timer was cancelled. Do not activate it again... 
+ *          }
+ *      else
+ *          {
+ *          // Handle the error by implementing RunError()
+ *          // See also: CActive::RunError()
+ *          User::Leave( iStatus );
+ *          }
+ *      }
+ *  @endcode
+ */
+class CFlexTimer : public CActive
+    {
+public:
+
+    /**
+     * Destructs the object.
+     */
+    IMPORT_C virtual ~CFlexTimer();
+
+    /**
+     * Fire timer at latest on the given interval. 32-bit interval value.
+     * @param aInterval the interval value until which the timer must expire.
+     * 
+     * @panic CFlexTimer 10 CFlexTimer::ConstructL() has not been called yet
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer  1 aInterval is negative
+     *
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds32 KInterval32( 600000000 ); // 10 min
+     *      After( KInterval32 );
+     * @endcode
+     */
+    IMPORT_C void After( TTimeIntervalMicroSeconds32 aInterval );
+    
+    /**
+     * Fire timer at latest on the given interval. 64-bit interval value.
+     *
+     * @param aInterval the interval value until which the timer must expire.
+     * 
+     * @panic CFlexTimer 10 CFlexTimer::ConstructL() has not been called yet
+     * @panic RFlexTimer  1 aInterval is negative
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer 24 aInterval is too big (over 730 days)
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds KInterval64( 600000000 ); // 10 min
+     *      After( KInterval64 );
+     * @endcode
+     */
+    IMPORT_C void After( TTimeIntervalMicroSeconds aInterval );
+
+    /**
+     * Fire timer at latest by the given time value. The time value provided
+     * here is related to HomeTime. @see TTime. If the system
+     * time changes before the timer requested with At-function expires, it
+     * will cancel itself. This will result in the aStatus argument to have
+     * KErrAbort-value.
+     *
+     * @param aTime indicates the latest time when this timer should be fired.
+     *
+     * @panic CFlexTimer 10 CFlexTimer::ConstructL() has not been called yet
+     * @panic RFlexTimer 3  aTime is in the past
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer 24 aTime is too far to the future (over 730 days)
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMinutes KWaitTime( 5 );
+     *
+     *      TTime now;
+     *      now.HomeTime();
+     *
+     *      At( nowUtc + KWaitTime );
+     * @endcode
+     */
+    IMPORT_C void At( const TTime& aTime );
+
+    /**
+     * Fire timer at latest by the given UTC (Coordinated Universal Time)
+     * time value. If the system
+     * time changes before the timer requested with At-function expires, it
+     * will cancel itself. This will result in the aStatus argument to have
+     * KErrAbort-value.
+     * @param aTime indicates the latest UTC time when this timer should be
+     * fired. 
+     *
+     * @panic CFlexTimer 10 CFlexTimer::ConstructL() has not been called yet
+     * @panic RFlexTimer 3  aTime is in the past
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer 24 aTime is too far to the future (over 730 days)
+     *
+     * Example:
+     * @code
+     *      const TTimeIntervalMinutes KWaitTime( 5 );
+     *
+     *      TTime nowUtc;
+     *      nowUtc.UniversalTime();
+     *
+     *      AtUTC( nowUtc + KWaitTime );
+     * @endcode
+     */
+    IMPORT_C void AtUTC( const TTime& aTime );
+
+    /**
+     * Sets the window size in which flexibility is possible for the timer.
+     * @see RFlexTimer::Configure
+     * @param aWindowSize is the window size in 32-bit microseconds in which
+     * timer flexiblity is possible.
+     * @return KErrNone on success. KErrInUse, if timer has been
+     * started already.
+     *
+     * @panic CFlexTimer 10 CFlexTimer::ConstructL() has not been called yet
+     * @panic RFlexTimer 5  aWindowSize is negative
+     * 
+     * Example:
+     * @code
+     *     const TTimeIntervalMicroSeconds32 KWindow32( 120000000 ); // 2 mins
+     *     Configure( KWindow32 );
+     * @endcode
+     */
+    IMPORT_C TInt Configure( TTimeIntervalMicroSeconds32 aWindowSize );
+    
+    /**
+     * Sets the window size in which flexibility is possible for the timer.
+     * @see RFlexTimer::Configure
+     * @param aWindowSize is the window size in 64-bit microseconds in which
+     * timer flexiblity is possible.
+     * @return KErrNone on success. KErrInUse, if timer has been
+     * started already.
+     *
+     * @panic CFlexTimer 10 CFlexTimer::ConstructL() has not been called yet
+     * @panic RFlexTimer 5  aWindowSize is negative
+     * @panic RFlexTimer 24 aWindowSize is too big (max 730 days)
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds KWindow64( 120000000 ); // 2 mins
+     *      Configure( KWindow64 );
+     * @endcode
+     */
+    IMPORT_C TInt Configure( TTimeIntervalMicroSeconds aWindowSize );
+
+protected:
+    
+    /**
+     * 2nd phase constructor for this the object. Connects to the flextimer
+     * server and creates a session. This function needs to be called by the
+     * object that is derived from this class.
+     */
+    IMPORT_C void ConstructL();
+
+    /**
+     * Constructs the object.
+     */
+    IMPORT_C CFlexTimer( TInt aPriority );
+
+    /**
+     * Inherited from CActive.
+     */
+    IMPORT_C virtual void DoCancel();
+
+private:
+
+    /**
+     * The timer resource used by this object.
+     */
+    RFlexTimer iTimer;
+
+    };
+
+#endif // CFLEXTIMER_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/flextimer_api/inc/rflextimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,594 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  RFlexTimer class for Flexible Timer server access.
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+
+#ifndef RFLEXTIMER_H
+#define RFLEXTIMER_H
+
+// INCLUDE FILES
+#include <e32std.h> 
+
+// CLASS DECLARATION
+/**
+ *  Resource class providing access to flexible timer server.
+ *  
+ *  This timer class is in many ways similar to RTimer in its use. The
+ *  main difference is the option to set a timer expiry window. When the timer
+ *  expiry window has been set to a value greater than zero, requested
+ *  timeouts may expire at any point of time inside this window. This timer
+ *  should be used for timed air-interface operations, such as keep-alive
+ *  messages. The use of normal timers is recommended if the timeouts are not
+ *  related to data transmission or reception activity in the device.
+ *  
+ *  The purpose for a flexible timer is to allow the system the opportunity to
+ *  align timed behaviour that uses radio resources. For example, when a
+ *  radio device is otherwise in an idle state, simple keep-alive messaging
+ *  can be grouped together so that all traffic happens in single bursts
+ *  instead of being distributed evenly along time timeline. This maximises
+ *  radio idle time and therefore also battery lifetime.
+ *  
+ *  This class defines a client interface for flexible timer server
+ *  (CFlexTimerServer). When a user requests timeout with RFlexTimer, the
+ *  server will expire the request non-deterministically within an time window
+ *  configured by the user. Timer resolution is one second.
+ *  
+ *  The timer returns one of the following values for TRequestStatus or any
+ *  other system-wide error codes:
+ *  
+ *  <table border=1 bordercolor="#84B0C7" cellspacing="0" align="center">
+ *  <tr>
+ *      <th>Return value</th>
+ *      <th>Description</th>
+ *      <th>@c At()</th>
+ *      <th>@c AtUTC()</th>
+ *      <th>@c After()</th>
+ *      <th>@c AfterTicks()</th>
+ *  </tr>
+ *  <tr>
+ *      <td>@c KErrNone</td>
+ *      <td>Timer has expired normally</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>  
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *  </tr>
+ *  <tr>
+ *      <td>@c KErrCancel</td>
+ *      <td>Timer has been cancelled by @c Cancel()</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *  </tr>
+ *  <tr>
+ *      <td>@c KErrAbort</td>
+ *      <td>Timer has been aborted due time change</td>
+ *      <td align="center">X</td>
+ *      <td align="center">X</td>
+ *      <td align="center">&nbsp;</td>
+ *      <td align="center">&nbsp;</td>
+ *  </tr>
+ *  </table>
+ *  
+ *  Example: A user uses Configure-function to set the timer window to
+ *  2,000,000 microseconds. Next the user requests a timeout with an interval
+ *  value of 3,000,000 microseconds. Now the timer may expire at any moment
+ *  after 1,000,000 microseconds and at latest after 3,000,000 microseconds
+ *  (+ possible timer inaccuracy (timer resolution) ) has passed from the 
+ *  timeout request. 
+ *
+ *  Passing a negative timer interval value or a past time instant 
+ *  to timer functions will cause a panic . Restarting a timer that is already
+ *  running will cause panic. Cancel must be used before starting timer again.
+ *
+ *  @see CFlexTimer
+ *  @see CFlexPeriodic
+ *  @see RTimer
+ *
+ *  Examples:
+ *
+ *  Synchronous usage of RFlexTimer:
+ *  @code
+ *      const TTimeIntervalMicroSeconds KInterval( 900000000 ); // 15 mins
+ *      const TTimeIntervalMicroSeconds KWindow( 300000000 ); // 5 mins
+ *
+ *      TRequestStatus status;
+ *
+ *      RFlexTimer timer;
+ *      User::LeaveIfError( timer.Connect() );
+ *
+ *      timer.Configure( KWindow );
+ *      timer.After( status, KInterval );
+ *
+ *      User::WaitForRequest( status );     // Wait till the timer expires
+ *
+ *      // Check the request's status
+ *      if ( status == KErrNone )
+ *          {
+ *          // Timer was expired ok
+ *          }
+ *      else if ( status == KErrAborted )
+ *          {
+ *          // Only for At() and AtUTC()
+ *          // Timer was aborted by time change
+ *          }
+ *      else if ( status == KErrCancel )
+ *          {
+ *          // timer.Cancel() was called while the timer was active
+ *          }
+ *      else
+ *          {
+ *          // Some other error has happened
+ *          }
+ *          .
+ *          .
+ *          .
+ *      timer.Close();
+ *  @endcode
+ *
+ *  Asynchronous usage of RFlexTimer (consider using CFlexTimer or 
+ *  CFlexPeriodic instead of own implementation):
+ *  
+ *  Class definition
+ *  @code
+ *      class CMyNetworkServiceMonitor : public CActive
+ *      {
+ *      public: // Members
+ *
+ *          // Public two-phased constructor
+ *          static CMyNetworkServiceMonitor* NewL(
+ *              TTimeIntervalMicroSeconds aWindow,
+ *              TTimeIntervalMicroSeconds aInterval );
+ *
+ *          // Destructor
+ *          virtual ~CMyNetworkServiceMonitor();
+ *
+ *      protected: // From CActive
+ *
+ *          // Cancel outstanding request. Called by CActive::Cancel().
+ *          virtual void DoCancel();
+ *
+ *          // Handle request completion event  
+ *          virtual void RunL();
+ *      
+ *      private: // Members
+ *
+ *          // Constructor
+ *          CMyNetworkServiceMonitor( TTimeIntervalMicroSeconds aInterval );
+ *
+ *          // Second phase constructor
+ *          void ConstructL( TTimeIntervalMicroSeconds aWindow );
+ *
+ *          // Does the network server monitoring.
+ *          // Implementation is not provided by this example.
+ *          void DoNetworkServiceMonitoring();
+ *      
+ *      private: // Data
+ *          RFlexTimer iTimer;
+ *          TTimeIntervalMicroSeconds iInterval;
+ *      };
+ *  @endcode
+ *
+ *  @code
+ *  CMyNetworkServiceMonitor::CMyNetworkServiceMonitor( 
+ *      TTimeIntervalMicroSeconds aInterval ):
+ *      CActive( CActive::EPriorityStandard ),
+ *      iInterval( aInterval )
+ *      {
+ *      // Nothing to do
+ *      } 
+ *
+ *  // -----------------------------------------------------------------------------
+ *  //
+ *  void CMyNetworkServiceMonitor::ConstructL( 
+ *      TTimeIntervalMicroSeconds aWindow )
+ *      {
+ *      User::LeaveIfError( iTimer.Connect() );
+ *      iTimer.Configure( aWindow );
+ *      }
+ *
+ *  // -----------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor* CMyNetworkServiceMonitor::NewL( 
+ *      TTimeIntervalMicroSeconds aWindow,
+ *      TTimeIntervalMicroSeconds aInterval )
+ *      {
+ *      CMyNetworkServerMonitor* self =
+ *          new (ELeave) CMyNetworkServerMonitor( aInterval );
+ *      CleanupStack::PushL( self );
+ *      self->ConstructL( aWindow );
+ *      CleanupStack::Pop( self );
+ *
+ *      iTimer.After( TTimeIntervalMicroSeconds( 0 ) );
+ *      SetActive();
+ *
+ *      return self;
+ *      }
+ *
+ *  // -----------------------------------------------------------------------------
+ *  //
+ *  CMyNetworkServiceMonitor::~CMyNetworkServiceMonitor()
+ *      {
+ *      Cancel();       // Calls CActive::Cancel()
+ *      iTimer.Close(); // Close the timer handle
+ *      }
+ *      
+ *  // -----------------------------------------------------------------------------
+ *  //
+ *  void CMyNetworkServiceMonitor::DoCancel()
+ *      {
+ *      iTimer.Cancel();
+ *      }
+ *
+ *  // -----------------------------------------------------------------------------
+ *  //
+ *  void CMyNetworkServiceMonitor::RunL()
+ *      {
+ *      // Note! If used RFlexTimer::At() or RFlexTimer::AtUTC()
+ *      // iStatus == KErrAbort should also be handled.
+ *      
+ *      if ( iStatus == KErrNone )
+ *          {
+ *          // Do the network server monitor actions
+ *          DoNetworkServiceMonitoring();
+ *
+ *           // Refresh the timer
+ *          iTimer.After( iInterval );
+ *          SetActive();
+ *          }
+ *      else if ( iStatus == KErrCancel )
+ *          {
+ *          // Timer was cancelled. Do not activate it again... 
+ *          }
+ *      else
+ *          {
+ *          // Handle the error by implementing RunError()
+ *          // See also: CActive::RunError()
+ *          User::Leave( iStatus );
+ *          }
+ *      }
+ *  @endcode
+ */
+class RFlexTimer : public RSessionBase
+    {
+public:
+    // Constructors and destructors
+
+    /**
+     * Constructs the object.
+     */
+    IMPORT_C RFlexTimer();
+
+    /**
+     * Destructs the object.
+     */
+    IMPORT_C ~RFlexTimer();
+
+    /**
+     * Connects to the timer server. This function needs to be called before
+     * any timeouts can be requested.
+     * 
+     * @return KErrNone on success. KErrNotSupported if client's and server's
+     * versions don't match. Otherwise returns one of the system-wide error
+     * codes.
+     * @panic RFlexTimer 33 Connected is called twice without closing the
+     * handle first
+     * 
+     * Example:
+     * @code
+     *      RFlexTimer timer;
+     *      User::LeaveIfError( timer.Connect() );
+     *          .
+     *          . // Set timer/wait for expiration.
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C TInt Connect();
+
+    /**
+     * Cancels the timer. Active timer will be completed with status 
+     * KErrCancel. If there are no active timer, Cancel() does nothing.
+     * 
+     * @panic KERN-EXEC 0 Cancel() was called before Connect()
+     * 
+     * Example:
+     * @code
+     *      RFlexTimer timer;
+     *      User::LeaveIfError( timer.Connect() );
+     *          .
+     *          .
+     *          .
+     *      // Oops, no need to wait the timer expiration
+     *      timer.Cancel(); // Cancel the pending timer    
+     *          .
+     *          .
+     *          .  
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C void Cancel();
+
+    /**
+     * An asynchronous timeout request to the flexible timer server.
+     * Fire timer at latest on the given 32-bit interval.
+     * 
+     * @param aStatus active object to be used for getting responses.	
+     * @param aInterval the interval value until which the timer must expire.
+     * 
+     * @panic RFlexTimer 1  aInterval is negative
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     *
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds32 KInterval32( 300000000 ); // 5 mins  
+     *      const TTimeIntervalMicroSeconds32 KWindow32( 120000000 ); // 2 mins  
+     *      
+     *      TRequestStatus status;
+     *      RFlexTimer timer;
+     *      
+     *      User:LeaveIfError( timer.Connect() );
+     *      timer.Configure( KWindow32 );
+     *      timer.After( status, KInterval32 );
+     *      
+     *      User::WaitForRequest( status ); // Wait timer to expire, synchronous
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode 
+     */
+    IMPORT_C void After( TRequestStatus& aStatus,
+                         TTimeIntervalMicroSeconds32 aInterval );
+    
+    /**
+     * An asynchronous timeout request to the flexible timer server.
+     * Fire timer at latest on the given 64-bit interval.
+     * @param aStatus active object to be used for getting responses.   
+     * @param aInterval the interval value until which the timer must expire.   
+     * @panic RFlexTimer 1  aInterval is negative
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer 24 aInterval is too big (max 730 days)
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds KInterval64( 300000000 ); // 5 mins
+     *
+     *      TRequestStatus status;
+     *      RFlexTimer timer;
+     *      
+     *      User::LeaveIfError( timer.Connect() );
+     *      timer.After( status, KInterval64 );
+     *      
+     *      User::WaitForRequest( status ); // Wait timer to expire, synchronous
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C void After( TRequestStatus& aStatus,
+                         TTimeIntervalMicroSeconds aInterval );
+
+    /**
+     * An asynchronous timeout request to the flexible timer server.
+     * Fire timer at latest after the given number of system ticks.
+     * 
+     * By default the system tick is 1/64 second. The exact value for one
+     * system tick can be retrieve via Symbian OS HAL API:
+     * 
+     * @code
+     *      TInt tickInMicroSeconds;
+     *      HAL::Get( HAL::ESystemTickPeriod, tickInMicroSeconds );
+     * @endcode
+     * 
+     * @param aStatus active object to be used for getting responses.
+     * @param aTicks the interval value until which the timer must expire. 	
+     * @panic RFlexTimer 2  aTicks is negative
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * 
+     * Example:
+     * @code
+     *      const TInt KIntervalInTicks( 57600 ); // 15 mins (1 tick = 15625 microseconds)
+     *
+     *      TRequestStatus status;
+     *      RFlexTimer timer;
+     *      
+     *      User::LeaveIfError( timer.Connect() );
+     *      timer.AfterTicks( status, KIntervalInTicks );
+     *      
+     *      User::WaitForRequest( status ); // Wait timer to expire, synchronous
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C void AfterTicks( TRequestStatus& aStatus, TInt aTicks );
+
+    /**
+     * An asynchronous timeout request to the flexible timer server.
+     * Fire timer between at latest by the given time value. If the system
+     * time changes before the timer requested with At-function expires, it
+     * will cancel itself. This will result in the aStatus argument to have
+     * KErrAbort-value.
+     * @param aStatus active object to be used for getting responses.
+     * @param aTime indicates the latest system-time when this timer should
+     * be fired.
+     * @panic RFlexTimer 3  aTime is in the past
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer 24 aTime is too far in the future (max 730 days)
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMinutes KWaitTime( 5 );
+     *      
+     *      TRequestStatus status;
+     *      RFlexTimer timer;
+     *      User::LeaveIfError( timer.Connect() );
+     *      
+     *      TTime now;
+     *      now.HomeTime();
+     *
+     *      timer.At( status, now + KWaitTime );
+     *      
+     *      User::WaitForRequest( status ); // Wait timer to expire, synchronous
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C void At( TRequestStatus& aStatus, const TTime& aTime );
+
+    /**
+     * An asynchronous timeout request to the flexible timer server.
+     * Fire timer between at latest by the given UTC (Coordinated Universal
+     * Time) time value. If the system time changes before the timer requested
+     * with AtUTC-function expires, it will cancel itself. This will result in
+     * the aStatus argument to have KErrAbort-value.
+     * @param aStatus active object to be used for getting responses.
+     * @param aTime indicates the latest UTC time when this timer should be
+     * fired. 
+     * @panic RFlexTimer 4  aTime is in the past
+     * @panic RFlexTimer 15 Timer is already active. Wait it to expire or
+     * cancel it first.
+     * @panic RFlexTimer 24 aTime is too far in the future (max 730 days)
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMinutes KWaitTime( 5 );
+     *
+     *      TRequestStatus status;
+     *      RFlexTimer timer;
+     *      User::LeaveIfError( timer.Connect() );
+     *
+     *      TTime nowUtc;
+     *      nowUtc.UniversalTime();
+     *
+     *      timer.At( status, nowUtc + KWaitTime );
+     *
+     *      User::WaitForRequest( status ); // Wait timer to expire, synchronous
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C void AtUTC( TRequestStatus& aStatus, const TTime& aTime );
+
+    /**
+     * Sets the window size in which alignment is possible for the timer.
+     * This is a synchronous command - it will return only after the server
+     * has completed the configuration message. If the timer is already
+     * running, it will return KErrInUse.
+     * 
+     * If user is not calling this function in prior to start timer, default
+     * value will be used as time window. Default value is currently 20%
+     * of total timer running time 
+     * (0.2 * (requested_expiry_time - current_time)) and this value is in 
+     * subject to change.
+     * 
+	 * If the user wishes to restore the default window size behaviour,
+     * a new timer is needed. 
+	 *
+     * Giving zero value as aWindowSize parameter, means that timer is fired
+     * precisely at requested time.
+	 *
+     * @param aWindowSize is the window size in 32-bit microseconds in which
+     * alignment is possible.
+     *
+     * @return KErrNone on success, KErrInUse if timer is set (wait it to be
+     * expired or cancel it before configuring). Otherwise returns one of the 
+     * system-wide error codes.
+     *
+     * @panic RFlexTimer 5  aWindowSize is negative
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds32 KWindow32( 120000000 ); // 2 mins
+     *
+     *      RFlexTimer timer;
+     *      User::LeaveIfError( timer.Connect() );
+     *      
+     *      timer.Configure( KWindow32 );
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C TInt Configure( TTimeIntervalMicroSeconds32 aWindowSize );
+    
+    /**
+     * This function overloads the Configure-function with 64-bit parameters.
+     * 
+     * @param aWindowSize is the window size in 64-bit microseconds in which
+     * alignment is possible.
+     * 
+     * @return KErrNone on success, KErrInUse if timer is set, wait it to 
+     * expire or cancel it before configuring. Otherwise returns one of the 
+     * system-wide error codes.
+     * 
+     * @panic RFlexTimer 5  aWindowSize is negative
+     * @panic RFlexTimer 24 aWindowSize is too big (max 730 days)
+     * 
+     * @see TInt Configure( TTimeIntervalMicroSeconds32 )
+     * 
+     * Example:
+     * @code
+     *      const TTimeIntervalMicroSeconds KWindow64( 120000000 ); // 2 mins
+     *
+     *      RFlexTimer timer;
+     *      User::LeaveIfError( timer.Connect() );
+     *      
+     *      timer.Configure( KWindow64 );
+     *          .
+     *          .
+     *          .
+     *      timer.Close();  // Close the handle
+     * @endcode
+     */
+    IMPORT_C TInt Configure( TTimeIntervalMicroSeconds aWindowSize );
+
+private:
+    
+    /**
+     * Gets the version number.
+     * @return The version.
+     */
+    TVersion Version() const;
+
+    /**
+     * Connects to the server. If server does not exist, it is created.
+     * @return KErrNone on success. Otherwise returns one of the system-wide
+     * error codes.
+     */
+    TInt StartServer();
+
+    };
+
+#endif // RFLEXTIMER_H
+
+// End of File
--- a/ipcm_plat/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_plat/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-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"
@@ -23,7 +23,8 @@
 #include "../disconnect_dialog_api/group/bld.inf"
 #include "../disconnect_dialog_disable_api/group/bld.inf"
 #include "../extended_connection_settings_api/group/bld.inf"
-#include "../mpm_default_connection_api/group/bld.inf"
 #include "../pdpcontextmanager2_reset_factory_settings_api/group/bld.inf"
 #include "../pdpcontextmanager2_settings_api/group/bld.inf"
 #include "../mpm_connect_screen_api/group/bld.inf"
+#include "../flextimer_api/group/bld.inf"
+#include "../mpm_vpn_toggle_api/group/bld.inf"
--- a/ipcm_plat/mpm_default_connection_api/group/bld.inf	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Build info for MPM Default Connection API.
-*
-*/
-
-#include <platform_paths.hrh>
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-
-../inc/rmpmdefaultconnection.h     MW_LAYER_PLATFORM_EXPORT_PATH(rmpmdefaultconnection.h)
-
-
--- a/ipcm_plat/mpm_default_connection_api/inc/rmpmdefaultconnection.h	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
-* Copyright (c) 2007 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Client interface to MPM Default Connection server
-*
-*/
-
-#ifndef RMPMDEFAULTCONNECTION_H
-#define RMPMDEFAULTCONNECTION_H
-
-#include <e32std.h>
-
-/**
- *  Cleant API for MPM Default Connection server
- *  services.
- *
- *  Enables registering IAP to be used as default connection. 
- *  Only one client may be connected at a time 
- *  @code
- *  RMPMDefaultConnection rmpmdc;
- *  TInt err = KErrNone;
- *  //connect and set default IAP
- *  err = rmpmdc.Connect();
- *  err = rmpmdc.SetDefaultIAP( iapId );
- *
- *  //when IAP no longer used as default
- *  err = rmpmdc.ClearDefaultIAP();
- *  rmpmdc.Close();
- *  @endcode
- *
- *  @lib mpmdefaultconnection.dll
- *  @since S60 v3.2
- */
-class RMPMDefaultConnection : public RSessionBase
-    {
-
-public:
-
-    /**
-     * Constructor.
-     *
-     * @since S60 v3.2
-     */
-    inline RMPMDefaultConnection() : RSessionBase(), 
-    iClientConnected( EFalse )
-    {};
-
-    /**
-     * Creates connection to server
-     *
-     * @since S60 v3.2
-     * @return KErrNone if successful, otherwise one of the
-     * system-wide error codes
-     */
-    IMPORT_C TInt Connect();
-
-    /**
-     * Closes connection to server
-     * If IAP has been registered by the client it is also deregistered here
-     *
-     * @since S60 v3.2
-     */
-    IMPORT_C void Close();
-
-    /**
-     * Sets IAP to be used as default connection
-     *
-     * @since S60 v3.2
-     * @param aIapId CommsDat record id of the IAP
-     * @return KErrNone if successful, otherwise one of the
-     * system-wide error codes
-     */
-    IMPORT_C TInt SetDefaultIAP( TInt aIapId );
-
-
-    /**
-     * Clears IAP from being used as default connection
-     *
-     * @since S60 v3.2
-     * @param aIapId CommsDat record id of the IAP
-     * @return KErrNone if successful, otherwise one of the
-     * system-wide error codes
-     */
-    IMPORT_C TInt ClearDefaultIAP();
-    
-    /**
-     * Returns MPM Default Connection server version.
-     * @since 3.2
-     * @return Version of the MPM Default Connection server
-     */
-     IMPORT_C TVersion Version() const;
-    
-private: // data
-
-    /**
-     * Is client connected to server or not
-     */
-     TBool iClientConnected;    
-
-    };
-
-#endif // RMPMDEFAULTCONNECTION_H
--- a/ipcm_plat/mpm_default_connection_api/mpm_default_connection_api.metaxml	Thu Jun 17 22:32:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-<?xml version="1.0" ?>
-<api id="b2e86b78ef2622115024f5670a07a915" dataversion="1.0">
-  <name>MPM Default Connection API</name>
-  <description>Used by an Active Idle plugin for setting default IAP (in practice a WLAN IAP that has earlier been started explicitly by the Active Idle plugin itself)</description>
-  <type>c++</type>
-  <subsystem>bearermanagement</subsystem>
-  <libs>
-    <lib name="mpmdefaultconnection.lib" />
-  </libs>
-  <release category="domain"/>
-  <attributes>
-     <!-- This indicates wether the api provedes separate html documentation -->
-     <!-- or is the additional documentation generated from headers. -->
-     <!-- If you are unsuere then the value is "no" -->
-     <htmldocprovided>yes</htmldocprovided>
-     <adaptation>no</adaptation>
-  </attributes>
-</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/mpm_vpn_toggle_api/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used to export api headers.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/mpmvpntoggleapi.h     MW_LAYER_PLATFORM_EXPORT_PATH(mpmvpntoggleapi.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/mpm_vpn_toggle_api/inc/mpmvpntoggleapi.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Defines central repository key for VPN toggle
+*
+*/
+
+#ifndef MPMVPNTOGGLEAPI_H
+#define MPMVPNTOGGLEAPI_H
+
+/**
+ * The UID of the repository to be accessed.
+ */
+const TUid KMpmVpnToggleCenRepUid = {0x20016A88}; 
+
+/**
+ * This key contains value, which defines if VPN connection is preferred
+ * connection. Client can set this value if it has WriteDeviceData and
+ * NetworkControl capabilities.
+ */
+const TUint32 KMpmVpnTogglePreferVpn = 0x00000001;
+
+/**
+ * This key contains VPN IAP Id value for VPN IAP which is used to establish
+ * VPN connection, when VPN connection is preferred. Client can set this value
+ * if it has WriteDeviceData and NetworkControl capabilities. TUint32 value
+ * needs to be converted from TInt.
+ */
+const TUint32 KMpmVpnToggleIapId = 0x00000002;
+
+/**
+ * This key contains SNAP Id value SNAP which is used to establish VPN
+ * connection, when VPN connection is preferred. Client can set this value
+ * if it has WriteDeviceData and NetworkControl capabilities. TUint32 value
+ * needs to be converted from TInt.
+ */
+const TUint32 KMpmVpnToggleSnapId = 0x00000003;
+
+#endif // MPMVPNTOGGLEAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/mpm_vpn_toggle_api/mpm_vpn_toggle_api.metaxml	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<api id="1d6087f5136e401d3622dd9952b7da47" dataversion="2.0">
+  <name>mpm_vpn_toggle_api</name>
+  <description>Provides API to set/get VPN connection preferred value, which defines whether VPN connection is preferred connection. VPN IAP Id or Intranet SNAP Id needs to be also defined, when VPN connection is preferred connection. VPN IAP Id or Intranet SNAP Id needs to be defined, if VPN connection is preferred.</description>
+  <type>c++</type>
+  <collection>mpm_vpn_toggle_api</collection>
+  <libs>
+    <lib name="centralrepository.lib"/>
+  </libs>
+  <release category="platform" sinceversion=""/>
+  <attributes>
+    <htmldocprovided>no</htmldocprovided>
+    <adaptation>no</adaptation>
+  </attributes>
+</api>
--- a/ipcm_pub/connection_settings_api/inc/cmconnectionmethoddef.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_pub/connection_settings_api/inc/cmconnectionmethoddef.h	Thu Jul 22 16:37:38 2010 +0100
@@ -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"
@@ -25,7 +25,7 @@
 
 // Beginning of the CMManager enum range (internal use)
 const TUint KLanBaseSpecificAttributes = 20000;
-const TUint KLanBaseIfNetworks = 20100; 
+const TUint KLanBaseIfNetworks = 20100;
 // End of the CMManager enum range (internal use)
 const TUint KLanBaseRangeMax = 29999;
 
@@ -34,8 +34,8 @@
 
 namespace CMManager
     {
-    //Enumeration for possible values of seamlessness field 
-    //in IAP Metadata table 
+    //Enumeration for possible values of seamlessness field
+    //in IAP Metadata table
     /**  Naming method options */
     enum TNamingMethod
         {
@@ -44,7 +44,7 @@
         ENamingNotAccept    ///< Do not accept duplication. It will leave with
                             ///< KErrArgument.
         };
-    
+
     // Enumeration for IPv6 types
     enum TIPv6Types
         {
@@ -52,7 +52,7 @@
         EIPv6WellKnown,     ///< Well known IPv6 type
         EIPv6UserDefined    ///< User defined IPv6 type
         };
-    
+
     enum TSeamlessnessValue
         {
         ESeamlessnessNotRoamedTo,   // NOT supported
@@ -60,22 +60,22 @@
         ESeamlessnessShowprogress,  // Shows progress
         ESeamlessnessFullySeamless  // NOT supported
         };
-    
-    
+
+
     /// Unspecified IPv4 address
     _LIT( KUnspecifiedIPv4, "0.0.0.0" );
-    
+
     /// Known IPv6 name server 1
     _LIT( KKnownIp6NameServer1, "fec0:000:0000:ffff::1" );
     /// Known IPv6 name server 2
     _LIT( KKnownIp6NameServer2, "fec0:000:0000:ffff::2" );
-    
+
     /// Dynamic IPv6 address
     _LIT( KDynamicIpv6Address, "0:0:0:0:0:0:0:0" );
 
     /// Default proxy protocol name
     _LIT( KDefProxyProtocolName, "http" );
-    
+
     /// Default proxy port number
     _LIT( KDefaultProxyPortNumber, "0" );
 
@@ -98,26 +98,26 @@
     enum TConnectionMethodCommonAttributes
         {
         /**
-        * The following attributes can be queried via both 
+        * The following attributes can be queried via both
         * the manager interface's and connection method interface's ::Get functions.
         */
         ECmCoverage,                /**<
                                     * Checks if there's coverage for this bearer.
                                     * (TBool - default: none - read only)
                                     */
-                        
+
         ECmDefaultPriority,         /**<
-                                    * Default global priority of the CM's bearer 
+                                    * Default global priority of the CM's bearer
                                     * type.
                                     * (TUint32 - default: none - read only)
                                     */
-                        
+
         ECmDestination,             /**<
-                                    * ETrue if this connection method is 
+                                    * ETrue if this connection method is
                                     * an embedded destination.
                                     * (TBool - default: none - read only)
                                     */
-                            
+
         ECmBearerHasUi,             /**<
                                     * Indicates whether the bearer has any UI.
                                     * (TBool - default: none - read only)
@@ -127,9 +127,9 @@
                                     * Returns ETrue if IPv6 is supported.
                                     * (TBool - default: none - read only)
                                     */
-                                    
+
         ECmDefaultUiPriority,       /**<
-                                    * Priority of this bearer type when shown in UI for 
+                                    * Priority of this bearer type when shown in UI for
                                     * configuring a new IAP.
                                     * (TUint32 - default: none - read only)
                                     */
@@ -140,16 +140,16 @@
                                     * Used with Get/SetStringAttribute().
                                     * Returns NULL if not found.
                                     * (String - default: None )
-                                    */ 
-                       
+                                    */
+
         ECmCommsDBBearerType = 204, /**<
                                     * For backward compatibility, connection method
                                     * can return its CommsDB specific bearer type.
                                     * (TUint32 - default: none - read only)
-                                    * Leaves with KErrUnknown if no associated bearer 
+                                    * Leaves with KErrUnknown if no associated bearer
                                     * type exists in CommsDat.
                                     */
-                                
+
         ECmVirtual = 206,          /**<
                                     * Is the given connection method virtual?
                                     * (TBool - default: none - read only)
@@ -157,86 +157,86 @@
 
         /**
         * These are not bearer specific, but controling attributes.
-        */    
+        */
         ECmInvalidAttribute = 400,  /**<
-                                    * Client application can check which attribute 
+                                    * Client application can check which attribute
                                     * was incorrect in UpdateL().
                                     * (TUint32 - default: none - read only)
                                     */
-                                    
+
         ECmLoadResult = 402,        /**<
                                     * Result of the load process. KErrNone if there
                                     * was no error. Otherwise a system wide
                                     * error code.
                                     * (TUint32 - default: KErrNone - read only)
                                     */
-        
+
         /**
         * Attributes the can be queried only via
         * - connection method's GetXXXAttributeL()
         * - connection manager's function GetConnectionMethodInfoXXXL()
         * functions
         */
-        ECmBearerType = 500,        /**<   
-                                    * Bearer type of the CM 
+        ECmBearerType = 500,        /**<
+                                    * Bearer type of the CM
                                     * (TUint - default: none - read only)
                                     */
-                        
-        ECmName,                    /**<   
+
+        ECmName,                    /**<
                                     * Name of the CM
                                     * (String - default: none)
                                     */
-        
-        ECmIapId,                   /**<    
+
+        ECmIapId,                   /**<
                                     * IAP id
                                     * (TUint32 - default: none - read only)
                                     */
-                        
+
         ECmStartPage,               /**<
                                     * Start page of the connection method
                                     * (String - default: empty string)
                                     */
 
         ECmHidden,                  /**<
-                                    * Connection method is hidden. 
+                                    * Connection method is hidden.
                                     * (not supported yet)
                                     * (TBool - default: EFalse)
                                     */
 
         ECmProtected,               /**<
-                                    * This connection method is protected. 
+                                    * This connection method is protected.
                                     * Modifying it needs NetworkControl capability.
                                     * (TBool - default: EFalse)
                                     */
-                        
+
         ECmNamingMethod,            /**<
                                     * See acceptable values in TNamingControl.
                                     * (TUint32 - default: ENamingUnique)
-                                    */             
-        
+                                    */
+
         ECmSeamlessnessLevel,   /**<
                                 * Defines whether an IAP can be roamed to.
                                 * See details in TSeamlessnessValue.
                                 * (TUint32 - default: ESeamlessnessConfirmFirst )
                                 */
-                                
+
         ECmElementID,           /**<
                                 * Element id of the connection method in IAP table.
                                 * (TUint32 - default: none - read only)
                                 */
-        
+
         ECmNetworkId,           /**<
                                 * Network id of the connection method.
                                 * (TUint32 - default: none - read only)
                                 */
-                                
+
         ECmConnected,           /**<
                                 * Is network connection created with connection
                                 * method?
                                 * (TBool - default: none - read only)
                                 */
 
-        ECmId,                  /**<    
+        ECmId,                  /**<
                                 * ID to uniquely identify the connection
                                 * methods
                                 * It is guaranteed that every connection
@@ -246,22 +246,22 @@
 
         ECmWapId,               /**
 		                        * Provided for backwards compatibility only.
-                                * The record ID of the connection methods' 
+                                * The record ID of the connection methods'
                                 * corresponding WAP_ACCESS_POINT record, which
-                                * use had been deprecated as the main ID 
+                                * use had been deprecated as the main ID
                                 * should now be ECmIapId, ECmElementID or ECmId.
                                 * (TUint32 - default: none - read only)
                                 */
 
         ECmIapServiceId,        /**
 		                        * Provided for backwards compatibility only.
-                                * The record ID of the connection methods' 
+                                * The record ID of the connection methods'
                                 * service record
                                 * (TUint32 - default: none - read only)
                                 */
 
         /**
-        * The following attributes are stored in the connection method's 
+        * The following attributes are stored in the connection method's
         * meta data record.
         */
         ECmMetaHighlight = 600, /**<
@@ -270,365 +270,370 @@
                                 * method can have this flag set.
                                 * (TBool - default: EFalse)
                                 */
-                                
+
         ECmMetaHiddenAgent,     /**<
                                 * Set to hide this connection method in Agent
                                 * dialog.
                                 * (TBool - default: EFalse)
                                 */
-                                
+
         // These attributes can be used with virtual bearer type
         // connection methods.
         ECmNextLayerIapId,      /**<
                                 * Returns the linked connection method's IAP id.
                                 * (TUint32 - default: None)
                                 */
-                                
+
         ECmNextLayerSNAPId,     /**<
                                 * Returns the linked connection method's SNAP id.
                                 * (TUint32 - default: None)
                                 */
-        
+
+        ECmMetaHotSpot,         /**<
+                                * Sets/Gets the information if the IAP is HotSpot IAP.
+                                * (TBool - default: EFalse)
+                                */
+
         // Proxy attributes
         ECmProxyUsageEnabled = 1000,    /**<
                                         * Set to enable/disable proxy setting
                                         * of connection method.
-                                        * Disabling: record is deleted from proxy 
+                                        * Disabling: record is deleted from proxy
                                         * when UpdateL() is called.
-                                        * Proxy record is deleted on UpdateL() 
+                                        * Proxy record is deleted on UpdateL()
                                         * if ECmProxyServerName is an empty string.
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (TBool: default: EFalse)
                                         */
-     
+
         ECmProxyServerName,             /**<
                                         * Name of the host.
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (String - default: none)
                                         */
-                                        
+
         ECmProxyProtocolName,           /**<
-                                        * Name of the protocol for which this proxy 
+                                        * Name of the protocol for which this proxy
                                         * can be used.
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (String - default: none)
                                         */
-                                        
-        ECmProxyPortNumber,             /**< 
+
+        ECmProxyPortNumber,             /**<
                                         * Port number
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (TUint32 - default: none)
                                         */
-                                        
+
         ECmProxyExceptions,             /**<
-                                        * ";" separated list of the addresses for 
+                                        * ";" separated list of the addresses for
                                         * which the proxy server should not be used.
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (String - default: none)
                                         */
-                                        
+
         ECmProxyRangeMax = 1999,        /**<
                                         * Marks the end of the proxy range
                                         */
-                                  
+
         ECmChargeCardUsageEnabled = 2000,   /**<
-                                            * Same as in ECmProxyUsageEnabled but 
-                                            * for charge card. 
+                                            * Same as in ECmProxyUsageEnabled but
+                                            * for charge card.
                                             * (TBool - default: EFalse)
-                                            */      
-                                            
+                                            */
+
         ECmChargeCardAccountNumber,         /**<
                                             * Account number
                                             * (String - default: none)
                                             */
-                                            
+
         ECmChargeCardPIN,                   /**<
                                             * PIN number
                                             * (String - default: none)
                                             */
-        
+
         ECmChargeCardLocalRule,             /**<
-                                            * Order of dialling account number, 
+                                            * Order of dialling account number,
                                             * PIN and phone number for local calls.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmChargeCardNatRule,               /**<
-                                            * Order of dialling account number, 
-                                            * PIN and phone number for national 
+                                            * Order of dialling account number,
+                                            * PIN and phone number for national
                                             * calls.
                                             * (String - default: none)
                                             */
 
         ECmChargeCardIntlRule,              /**<
-                                            * Order of  dialling account number, 
-                                            * PIN and phone number for 
+                                            * Order of  dialling account number,
+                                            * PIN and phone number for
                                             * international calls.
                                             * (String - default: none)
                                             */
-        
+
         ECmChargeCardRangeMax = 2999,       /**<
                                             * Marks the end of the chargecard range
                                             */
-                                            
+
         ECmLocationUsageEnabled = 3000,     /**<
-                                            * Same as in ECmProxyUsageEnabled but 
-                                            * for location. 
+                                            * Same as in ECmProxyUsageEnabled but
+                                            * for location.
                                             * (TBool - default: EFalse)
                                             */
-                                            
+
         ECmLocationIntlPrefixCode,          /**<
                                             * International prefix code.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmLocationNatPrefixCode,           /**<
                                             * National prefix code.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmLocationNatCode,                 /**<
                                             * National code
                                             * (String - default: none)
                                             */
-                                            
+
         ECmLocationAreaCode,                /**<
                                             * Area code.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmLocationDialOutCode,             /**<
                                             * Number to dial for an outside line.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmLocationDisableCallWaitingCode,  /**<
-                                            * Code to dial to disable call waiting 
+                                            * Code to dial to disable call waiting
                                             * facility.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmLocationMobile,                  /**<
                                             * Mobile phone?
                                             * (TBool - default: none)
                                             */
-                                            
+
         ECmLocationUsePulseDial,            /**<
                                             * Use pulse dialling?
                                             * (TBool - default: none)
                                             */
-                                            
+
         ECmLocationWaitForDialTone,         /**<
                                             * Wait for the dial tone?
                                             * (TBool - default: none)
                                             */
-                                            
+
         ECmLocationPauseAfterDialOut,       /**<
                                             * Pause time after dial out.
                                             * (TUint32 - default: none)
                                             */
-                                            
+
         ECmLocationRangeMax = 3999,         /**<
                                             * Marks the end of the location
                                             * range
                                             */
-        
+
         // WAP specific attributes
         ECmWapIPGatewayAddress = 4000,      /**<
-                                            * WAP Gateway address, in this case an 
+                                            * WAP Gateway address, in this case an
                                             * IP address.
                                             * (String - default: none)
                                             */
-                                            
+
         ECmWapIPWSPOption,          /**<
-                                    * Enum value indicating whether 
-                                    * connection-oriented 
+                                    * Enum value indicating whether
+                                    * connection-oriented
                                     * or connectionless API should be used.
                                     * See valid values in TWapWSPOption.
-                                    * (TUint32 - default: 
+                                    * (TUint32 - default:
                                     * ECmWapWspOptionConnectionless)
                                     */
-                                            
+
         ECmWapIPSecurity,           /**<
                                     * Attempt secure WTLS connection to the gateway
                                     * (TBool - default: EFalse)
                                     */
-        
+
         ECmWapIPProxyPort,          /**<
                                     * Proxy port number. Required for WAP2.0 only.
                                     * (TUint32 - default: none)
                                     */
-                                            
+
         ECmWapIPProxyLoginName,     /**<
                                     * Proxy login name. Required for WAP2.0 only.
                                     * (String - default: none)
                                     */
-                                            
+
         ECmWapIPProxyLoginPass,     /**<
-                                    * Proxy login password. 
+                                    * Proxy login password.
                                     * Required for WAP2.0 only.
                                     * (String - default: none)
                                     */
-                                            
+
         ECmWapRangeMax = 4099,      /**<
                                     * Marks the end of the WAP specific range
                                     */
 
-        /** 
+        /**
         * The following attributes are common for many bearer types.
         * It's not sure that every IF or IP attribute is supported by
         * all bearer types.
-        * It's not possible to query these attributes via 
+        * It's not possible to query these attributes via
         * GetConnectionInfoXXX() functions.
         */
         ECmCommonAttributesStart = 5000, /**<
                                          * Marks the beginning of the common
                                          * attributes
                                          */
-        
+
         ECmIFName,                  /**<
                                     * Interface name
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIFParams,                /**<
                                     * Interface parameter string
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIFNetworks,              /**<
                                     * List of network protocols
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIFPromptForAuth,         /**<
                                     * Prompt user for authentication
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (TBool - default: none)
                                     */
-                                    
+
         ECmIFAuthName,              /**<
                                     * Authentication user name used by PPP
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIFAuthPass,              /**<
                                     * Authentication password used by PPP
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIFAuthRetries,           /**<
                                     * Number of times for retrying authentication
                                     * if it fails
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (TUint32 - default: none)
                                     */
-        
+
         ECmIPNetmask = 5050,        /**<
                                     * IP net mask of interface
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIPGateway,               /**<
                                     * IP address of gateway
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIPAddFromServer,         /**<
                                     * Get IP address from server?
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (TBool - default: none)
                                     */
-                                    
+
         ECmIPAddress,               /**<
                                     * IP address of interface
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIPDNSAddrFromServer,     /**<
                                     * Get DNS addresses from server?
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (TBool - default: none)
                                     */
-                                    
+
         ECmIPNameServer1,           /**<
                                     * IP address of primary name server
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIPNameServer2,           /**<
                                     * IP address of secondary name server
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIP6DNSAddrFromServer,    /**<
                                     * Get IP6 DNS addresses from server?
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (TBool - default: none)
                                     */
-                                    
+
         ECmIP6NameServer1,          /**<
                                     * IP6 address of primary name server
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIP6NameServer2,          /**<
                                     * IP6 address of secondary name server
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIPAddrLeaseValidFrom,    /**<
                                     * IP address valid from this time, used to
                                     * store dynamically assigned address lease
                                     * info
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-                                    
+
         ECmIPAddrLeaseValidTo,      /**<
                                     * IP address valid for use until this time,
                                     * used to store dynamically assigned
                                     * address lease info
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-        
+
         ECmConfigDaemonManagerName = 5100, /**<
                                             * Name of the ECom configuration
                                             * daemon manager component. This
@@ -636,12 +641,12 @@
                                             * server identified in
                                             * ECmConfigDaemonName. If
                                             * specified, ECmConfigDaemonName
-                                            * should also be specified.                                            
-                                            * It can be queried only via the 
+                                            * should also be specified.
+                                            * It can be queried only via the
                                             * connection method's GetXXXAttributeL()
                                             * (String - default: none)
                                             */
-                                            
+
         ECmConfigDaemonName,        /**<
                                     * Name of the configuration daemon server.
                                     * This server is used to provide further
@@ -649,65 +654,65 @@
                                     * dynamic IP address assignment. If
                                     * specified, ECmConfigDaemonManagerName
                                     * should also be specified.
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (String - default: none)
                                     */
-        
+
         ECmEnableLPCExtension = 5110,   /**<
                                         * Enable LCP extensions?
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (TBool - default: none)
                                         */
-                                        
+
         ECmDisablePlainTextAuth,        /**<
                                         * Disable plaintext authentication?
-                                        * It can be queried only via the 
+                                        * It can be queried only via the
                                         * connection method's GetXXXAttributeL()
                                         * (TBool - default: none)
                                         */
-                                        
+
         ECmCommonAttributesEnd = 5999,  /**<
                                         * Marks the end of common attributes
                                         */
-        
+
         /**
-        * The following methods can be queried only via 
+        * The following methods can be queried only via
         * connection method's GetXXXAttributeL()
         */
         ECmSpecialAttributes = 6000,   /**<
                                         * Marks the beginning of special
                                         * attributes
                                         */
-        
+
         ECmIsLinked,                /**<
                                     * Is connection method linked to any
                                     * virtual connection method?
-                                    * It can be queried only via the 
+                                    * It can be queried only via the
                                     * connection method's GetXXXAttributeL()
                                     * (TBool - default: none)
                                     */
-                                    
+
         ECmSpecialAttributesEnd = 8999  /**<
                                         * Marks the end of special attributes
                                         */
         };
 
-    /**  WAP WSP options */        
+    /**  WAP WSP options */
     enum TWapWSPOption
         {
         /**
         * Indicates that connectionless APIs should be used
         */
         ECmWapWspOptionConnectionless,
-        
+
         /**
         * Indicates that connection oriented APIs should be used
         */
         ECmWapWspOptionConnectionOriented
         };
-       
+
     }   // namespace CMManager
 
 #endif // CMCONNECTIONMETHODDEF_H
--- a/ipcm_pub/connection_settings_api/inc/cmpluginvpndef.h	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipcm_pub/connection_settings_api/inc/cmpluginvpndef.h	Thu Jul 22 16:37:38 2010 +0100
@@ -55,7 +55,8 @@
                                         */
         
         EVpnServicePolicyName = 30100,  /**<
-                                        * Policy name.
+                                        * Deprecated
+                                        * Always leaves with code KErrNotSupported.
                                         * (String - default: None)
                                         */
                                         
@@ -66,13 +67,27 @@
 
 
         EVpnIapId,                      /**<
+                                        * Provided for backward compatibility. 
+                                        * Use ECmNextLayerIapId instead.
+                                        *
                                         * Home IAP Id.
+                                        * 
+                                        * Setting will reset EVpnNetworkId and
+                                        * ECmNextLayerSNAPId to zero
+                                        * 
                                         * (TUint32 - default: None)
                                         */
 
         EVpnNetworkId,                  /**<
-                                        * Network Id.
-                                        * (TUint32 - default: None - read only)
+                                        * Provided for backward compatibility. 
+                                        * Use ECmNextLayerSNAPId instead.
+                                        * 
+                                        * Network Id. 
+                                        * 
+                                        * Setting will reset EVpnIapId and 
+                                        * ECmNextLayerIapId to zero.
+                                        * 
+                                        * (TUint32 - default: None)
                                         */
                                         
         EVpnServiceEnableLLMNR,         /**<
--- a/ipconnmgmt.pro	Thu Jun 17 22:32:02 2010 +0100
+++ b/ipconnmgmt.pro	Thu Jul 22 16:37:38 2010 +0100
@@ -12,18 +12,19 @@
 # Contributors:
 #
 # Description:
+# Qt project file for ipconnmgmt package.
 #
 
 TEMPLATE = subdirs
 
+CONFIG += ordered
+
 SUBDIRS  += \
     ipcm_plat \
     connectionutilities \
     cmmanager \
     connectionmonitoring
 
-CONFIG += ordered
-
-symbian*: {
-    SYMBIAN_PLATFORMS = WINSCW ARMV5
-} 
+symbian {
+    BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"./group/bld.inf\""
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/bwins/flextimerclientu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,31 @@
+EXPORTS
+	?ConstructL@CFlexPeriodic@@AAEXXZ @ 1 NONAME ; void CFlexPeriodic::ConstructL(void)
+	?ConstructL@CFlexTimer@@IAEXXZ @ 2 NONAME ; void CFlexTimer::ConstructL(void)
+	?At@CFlexTimer@@QAEXABVTTime@@@Z @ 3 NONAME ; void CFlexTimer::At(class TTime const &)
+	?Configure@CFlexTimer@@QAEHVTTimeIntervalMicroSeconds@@@Z @ 4 NONAME ; int CFlexTimer::Configure(class TTimeIntervalMicroSeconds)
+	?AtUTC@RFlexTimer@@QAEXAAVTRequestStatus@@ABVTTime@@@Z @ 5 NONAME ; void RFlexTimer::AtUTC(class TRequestStatus &, class TTime const &)
+	?After@RFlexTimer@@QAEXAAVTRequestStatus@@VTTimeIntervalMicroSeconds32@@@Z @ 6 NONAME ; void RFlexTimer::After(class TRequestStatus &, class TTimeIntervalMicroSeconds32)
+	??1CFlexPeriodic@@UAE@XZ @ 7 NONAME ; CFlexPeriodic::~CFlexPeriodic(void)
+	?DoCancel@CFlexTimer@@MAEXXZ @ 8 NONAME ; void CFlexTimer::DoCancel(void)
+	?Configure@CFlexPeriodic@@QAEHVTTimeIntervalMicroSeconds@@0@Z @ 9 NONAME ; int CFlexPeriodic::Configure(class TTimeIntervalMicroSeconds, class TTimeIntervalMicroSeconds)
+	?After@CFlexTimer@@QAEXVTTimeIntervalMicroSeconds@@@Z @ 10 NONAME ; void CFlexTimer::After(class TTimeIntervalMicroSeconds)
+	?Configure@CFlexTimer@@QAEHVTTimeIntervalMicroSeconds32@@@Z @ 11 NONAME ; int CFlexTimer::Configure(class TTimeIntervalMicroSeconds32)
+	?After@CFlexTimer@@QAEXVTTimeIntervalMicroSeconds32@@@Z @ 12 NONAME ; void CFlexTimer::After(class TTimeIntervalMicroSeconds32)
+	?Configure@CFlexPeriodic@@QAEHVTTimeIntervalMicroSeconds32@@0@Z @ 13 NONAME ; int CFlexPeriodic::Configure(class TTimeIntervalMicroSeconds32, class TTimeIntervalMicroSeconds32)
+	?NewL@CFlexPeriodic@@SAPAV1@H@Z @ 14 NONAME ; class CFlexPeriodic * CFlexPeriodic::NewL(int)
+	?AtUTC@CFlexTimer@@QAEXABVTTime@@@Z @ 15 NONAME ; void CFlexTimer::AtUTC(class TTime const &)
+	??1RFlexTimer@@QAE@XZ @ 16 NONAME ; RFlexTimer::~RFlexTimer(void)
+	?After@RFlexTimer@@QAEXAAVTRequestStatus@@VTTimeIntervalMicroSeconds@@@Z @ 17 NONAME ; void RFlexTimer::After(class TRequestStatus &, class TTimeIntervalMicroSeconds)
+	?AfterTicks@RFlexTimer@@QAEXAAVTRequestStatus@@H@Z @ 18 NONAME ; void RFlexTimer::AfterTicks(class TRequestStatus &, int)
+	??0CFlexPeriodic@@AAE@H@Z @ 19 NONAME ; CFlexPeriodic::CFlexPeriodic(int)
+	?At@RFlexTimer@@QAEXAAVTRequestStatus@@ABVTTime@@@Z @ 20 NONAME ; void RFlexTimer::At(class TRequestStatus &, class TTime const &)
+	?Configure@RFlexTimer@@QAEHVTTimeIntervalMicroSeconds@@@Z @ 21 NONAME ; int RFlexTimer::Configure(class TTimeIntervalMicroSeconds)
+	?Cancel@RFlexTimer@@QAEXXZ @ 22 NONAME ; void RFlexTimer::Cancel(void)
+	?Configure@RFlexTimer@@QAEHVTTimeIntervalMicroSeconds32@@@Z @ 23 NONAME ; int RFlexTimer::Configure(class TTimeIntervalMicroSeconds32)
+	??0CFlexTimer@@IAE@H@Z @ 24 NONAME ; CFlexTimer::CFlexTimer(int)
+	?Start@CFlexPeriodic@@QAEXVTTimeIntervalMicroSeconds32@@0VTCallBack@@1@Z @ 25 NONAME ; void CFlexPeriodic::Start(class TTimeIntervalMicroSeconds32, class TTimeIntervalMicroSeconds32, class TCallBack, class TCallBack)
+	??1CFlexTimer@@UAE@XZ @ 26 NONAME ; CFlexTimer::~CFlexTimer(void)
+	?Start@CFlexPeriodic@@QAEXVTTimeIntervalMicroSeconds@@0VTCallBack@@1@Z @ 27 NONAME ; void CFlexPeriodic::Start(class TTimeIntervalMicroSeconds, class TTimeIntervalMicroSeconds, class TCallBack, class TCallBack)
+	?Connect@RFlexTimer@@QAEHXZ @ 28 NONAME ; int RFlexTimer::Connect(void)
+	??0RFlexTimer@@QAE@XZ @ 29 NONAME ; RFlexTimer::RFlexTimer(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/eabi/flextimerclientu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,42 @@
+EXPORTS
+	_ZN10CFlexTimer10ConstructLEv @ 1 NONAME
+	_ZN10CFlexTimer2AtERK5TTime @ 2 NONAME
+	_ZN10CFlexTimer5AfterE25TTimeIntervalMicroSeconds @ 3 NONAME
+	_ZN10CFlexTimer5AfterE27TTimeIntervalMicroSeconds32 @ 4 NONAME
+	_ZN10CFlexTimer5AtUTCERK5TTime @ 5 NONAME
+	_ZN10CFlexTimer8DoCancelEv @ 6 NONAME
+	_ZN10CFlexTimer9ConfigureE25TTimeIntervalMicroSeconds @ 7 NONAME
+	_ZN10CFlexTimer9ConfigureE27TTimeIntervalMicroSeconds32 @ 8 NONAME
+	_ZN10CFlexTimerC2Ei @ 9 NONAME
+	_ZN10CFlexTimerD0Ev @ 10 NONAME
+	_ZN10CFlexTimerD1Ev @ 11 NONAME
+	_ZN10CFlexTimerD2Ev @ 12 NONAME
+	_ZN10RFlexTimer10AfterTicksER14TRequestStatusi @ 13 NONAME
+	_ZN10RFlexTimer2AtER14TRequestStatusRK5TTime @ 14 NONAME
+	_ZN10RFlexTimer5AfterER14TRequestStatus25TTimeIntervalMicroSeconds @ 15 NONAME
+	_ZN10RFlexTimer5AfterER14TRequestStatus27TTimeIntervalMicroSeconds32 @ 16 NONAME
+	_ZN10RFlexTimer5AtUTCER14TRequestStatusRK5TTime @ 17 NONAME
+	_ZN10RFlexTimer6CancelEv @ 18 NONAME
+	_ZN10RFlexTimer7ConnectEv @ 19 NONAME
+	_ZN10RFlexTimer9ConfigureE25TTimeIntervalMicroSeconds @ 20 NONAME
+	_ZN10RFlexTimer9ConfigureE27TTimeIntervalMicroSeconds32 @ 21 NONAME
+	_ZN10RFlexTimerC1Ev @ 22 NONAME
+	_ZN10RFlexTimerC2Ev @ 23 NONAME
+	_ZN10RFlexTimerD1Ev @ 24 NONAME
+	_ZN10RFlexTimerD2Ev @ 25 NONAME
+	_ZN13CFlexPeriodic10ConstructLEv @ 26 NONAME
+	_ZN13CFlexPeriodic4NewLEi @ 27 NONAME
+	_ZN13CFlexPeriodic5StartE25TTimeIntervalMicroSecondsS0_9TCallBackS1_ @ 28 NONAME
+	_ZN13CFlexPeriodic5StartE27TTimeIntervalMicroSeconds32S0_9TCallBackS1_ @ 29 NONAME
+	_ZN13CFlexPeriodic9ConfigureE25TTimeIntervalMicroSecondsS0_ @ 30 NONAME
+	_ZN13CFlexPeriodic9ConfigureE27TTimeIntervalMicroSeconds32S0_ @ 31 NONAME
+	_ZN13CFlexPeriodicC1Ei @ 32 NONAME
+	_ZN13CFlexPeriodicC2Ei @ 33 NONAME
+	_ZN13CFlexPeriodicD0Ev @ 34 NONAME
+	_ZN13CFlexPeriodicD1Ev @ 35 NONAME
+	_ZN13CFlexPeriodicD2Ev @ 36 NONAME
+	_ZTI10CFlexTimer @ 37 NONAME
+	_ZTI13CFlexPeriodic @ 38 NONAME
+	_ZTV10CFlexTimer @ 39 NONAME
+	_ZTV13CFlexPeriodic @ 40 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for Flexible timer client
+*
+*/
+
+/*
+* %version: 2 %
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/flextimerclient.iby 	CORE_MW_LAYER_IBY_EXPORT_PATH(flextimerclient.iby)
+
+PRJ_MMPFILES
+flextimerclient.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/group/flextimerclient.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Flexible timer client
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+#include <platform_paths.hrh>
+
+TARGET              flextimerclient.dll
+TARGETTYPE          dll
+UID                 0x1000008D 0x2002C382
+
+CAPABILITY          CAP_GENERAL_DLL
+VENDORID            VID_DEFAULT
+
+SOURCEPATH          ../src
+
+SOURCE              rflextimer.cpp
+SOURCE              flextimer.cpp 
+SOURCE              flexperiodic.cpp
+
+USERINCLUDE         ../inc
+USERINCLUDE         ../../server/inc
+USERINCLUDE         ../traces
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY             euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/rom/flextimerclient.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Flexible timer client
+*
+*/
+#ifndef FLEXTIMERCLIENT_IBY
+#define FLEXTIMERCLIENT_IBY
+
+file=ABI_DIR\BUILD_DIR\flextimerclient.dll           SHARED_LIB_DIR\flextimerclient.dll
+
+#endif // FLEXTIMERCLIENT_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/src/flexperiodic.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of CFlexPeriodic class
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// System include files
+// User include files go here:
+#include "flexperiodic.h"
+#include "flextimercommon.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flexperiodicTraces.h"
+#endif
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// Constructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CFlexPeriodic* CFlexPeriodic::NewL( TInt aPriority )
+    {
+
+    CFlexPeriodic* self = new ( ELeave ) CFlexPeriodic( aPriority );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CFlexPeriodic::~CFlexPeriodic()
+    {
+    OstTrace1( TRACE_NORMAL, CFLEXPERIODIC_CFLEXPERIODIC,
+            "CFlexPeriodic::~CFlexPeriodic;this=%x", this );
+
+    }
+
+// ---------------------------------------------------------------------------
+// Starts the periodic timer. 32-bit delay and interval parameters.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexPeriodic::Start( TTimeIntervalMicroSeconds32 aDelay,
+                                    TTimeIntervalMicroSeconds32 anInterval,
+                                    TCallBack aCallBack,
+                                    TCallBack aCallBackError )
+    {
+    OstTraceExt4( TRACE_NORMAL, CFLEXPERIODIC_START32,
+            "CFlexPeriodic::Start32;this=%x;aDelay=%d;"
+            "anInterval=%d;aCallBack=%x", ( TUint )this,
+            aDelay.Int(), anInterval.Int(), ( TUint )&( aCallBack ) );
+
+    TTimeIntervalMicroSeconds32 zero( 0 );
+    __ASSERT_ALWAYS(aDelay >= zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicDelayLessThanZero));
+    __ASSERT_ALWAYS(anInterval > zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicIntervalTooSmall));
+    __ASSERT_ALWAYS( aCallBack.iFunction != NULL,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicCallbackFunctionIsNull));
+    // aCallBackError is left unasserted on purpose.
+    // if error occurs and callback is null client is paniced.
+
+    // Interval value is saved for later use, delay is sent immediately
+    // to the server.
+    iInterval = MAKE_TINT64( 0, anInterval.Int() );
+    iCallBack = aCallBack;
+    iCallBackError = aCallBackError;
+    CFlexTimer::After( aDelay );
+    }
+
+// ---------------------------------------------------------------------------
+// Starts the periodic timer. 64-bit delay and interval parameters.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexPeriodic::Start( TTimeIntervalMicroSeconds aDelay,
+                                    TTimeIntervalMicroSeconds anInterval,
+                                    TCallBack aCallBack,
+                                    TCallBack aCallBackError )
+    {
+    OstTraceExt4( TRACE_NORMAL, CFLEXPERIODIC_START64,
+            "CFlexPeriodic::Start64;this=%x;aDelay=%lld;"
+            "anInterval=%lld;aCallBack=%x", ( TUint )this,
+            aDelay.Int64(), anInterval.Int64(), ( TUint )&( aCallBack ) );
+
+    TTimeIntervalMicroSeconds zero( 0 );
+    __ASSERT_ALWAYS(aDelay >= zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicDelayLessThanZero));
+    __ASSERT_ALWAYS(anInterval > zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicIntervalTooSmall));
+    __ASSERT_ALWAYS( aCallBack.iFunction != NULL,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicCallbackFunctionIsNull));
+    // aCallBackError is left unasserted on purpose.
+    // if error occurs and callback is null client is paniced.
+    
+    // Interval value is saved for later use, delay is sent immediately
+    // to the server.
+    iInterval = anInterval.Int64();
+    iCallBack = aCallBack;
+    iCallBackError = aCallBackError;
+    CFlexTimer::After( aDelay );
+    }
+
+// ---------------------------------------------------------------------------
+// Configures the flex window sizes for both the initial delay and the
+// consequent intervals after that.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CFlexPeriodic::Configure(
+                                 TTimeIntervalMicroSeconds32 aDelayWindow,
+                                 TTimeIntervalMicroSeconds32 aIntervalWindow )
+    {
+
+    OstTraceExt3( TRACE_NORMAL, CFLEXPERIODIC_CONFIGURE,
+            "CFlexPeriodic::Configure32;this=%x;"
+            "aDelayWindow=%d;aIntervalWindow=%d", ( TUint )this,
+            aDelayWindow.Int(), aIntervalWindow.Int() );
+
+    TTimeIntervalMicroSeconds32 zero( 0 );
+    __ASSERT_ALWAYS(aDelayWindow >= zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicDelayWindowLessThanZero));
+    __ASSERT_ALWAYS(aIntervalWindow >= zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicIntervalWindowLessThanZero));
+
+    // interval window is saved for later use. Delay window is sent
+    // immediately to server. 
+    TInt ret = CFlexTimer::Configure( aDelayWindow );
+    if ( ret == KErrNone )
+        {
+        // Interval window is changed only, if configuration is successful.
+        iIntervalWindow = MAKE_TINT64( 0, aIntervalWindow.Int() );
+        iSendConfigure = ETrue;
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Configures the flex window sizes for both the initial delay and the
+// consequent intervals after that. 64-bit version.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CFlexPeriodic::Configure( 
+                                   TTimeIntervalMicroSeconds aDelayWindow,
+                                   TTimeIntervalMicroSeconds aIntervalWindow )
+    {
+    OstTraceExt3( TRACE_NORMAL, DUP1_CFLEXPERIODIC_CONFIGURE,
+            "CFlexPeriodic::Configure64;this=%x;"
+            "aDelayWindow=%lld;aIntervalWindow=%lld", ( TUint )this,
+            aDelayWindow.Int64(), aIntervalWindow.Int64() );
+
+    TTimeIntervalMicroSeconds zero( 0 );
+    __ASSERT_ALWAYS(aDelayWindow >= zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicDelayWindowLessThanZero));
+    __ASSERT_ALWAYS(aIntervalWindow >= zero,
+            User::Panic(KCFlexPeriodicPanicCat,
+                    EFlexPeriodicIntervalWindowLessThanZero));
+
+    // interval window is saved for later use. Delay window is sent
+    // immediately to server. 
+    TInt ret = CFlexTimer::Configure( aDelayWindow );
+    if ( ret == KErrNone )
+        {
+        // Interval window is changed only, if configuration is successful.
+        iIntervalWindow = aIntervalWindow;
+        
+        // This is set to true only, if the server is able to receive the
+        // delay window configuration.
+        iSendConfigure = ETrue;
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles the active objects request completion event.
+// ---------------------------------------------------------------------------
+//
+void CFlexPeriodic::RunL()
+    {
+    if ( KErrNone == iStatus.Int() )
+        {
+        if ( iSendConfigure )
+            {
+            OstTrace1( TRACE_NORMAL, CFLEXPERIODIC_RUNL,
+                    "CFlexPeriodic::RunL;this=%x", ( TUint )this );
+    
+            CFlexTimer::Configure( iIntervalWindow );
+            // Reset the iSendConfigure to false so that this is sent only once.
+            iSendConfigure = EFalse;
+            }
+        CFlexTimer::After( iInterval );
+        iCallBack.CallBack();
+        }
+    // Error happended in server. timer is not restarted and
+    // iCallBackError is called to inform user
+    else
+        {
+        if ( NULL != iCallBackError.iFunction )
+            {
+            iCallBackError.CallBack();
+            }
+        // User has not defined iCallBackError
+        // Panic client.
+        else
+            {
+            OstTrace1( TRACE_NORMAL, CFLEXPERIODIC_RUNL_PANIC,
+            "CFlexPeriodic::RunL;this=%x;"
+            "Error returned from FlexTimerServer and no Error CallBack"
+            " is defined. Panicing client.", ( TUint )this );
+            User::Panic( KCFlexPeriodicPanicCat,
+                        EFlexPeriodicErrorCallbackFunctionIsNull );
+            }
+        }
+    }
+// ---------------------------------------------------------------------------
+// Second part of the two-phase construction.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexPeriodic::ConstructL()
+    {
+    CFlexTimer::ConstructL();
+
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Private constructor with priority.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CFlexPeriodic::CFlexPeriodic( TInt aPriority ) :
+    CFlexTimer( aPriority ), iSendConfigure( EFalse )
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/src/flextimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of CFlexTimer class
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+//#include <e32panic.h>
+
+#include "flextimer.h"
+#include "flextimerpanic.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimerTraces.h"
+#endif
+
+// ---------------------------------------------------------------------------
+// Destructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CFlexTimer::~CFlexTimer()
+    {
+    OstTrace1( TRACE_NORMAL, CFLEXTIMER_CFLEXTIMER,
+               "CFlexTimer::~CFlexTimer;this=%x", this );
+    
+    Cancel();
+    iTimer.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer at latest on the given interval. 32-bit interval.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexTimer::After( TTimeIntervalMicroSeconds32 aInterval )
+    {
+    OstTraceExt2( TRACE_NORMAL, CFLEXTIMER_AFTER32,
+                  "CFlexTimer::After32;this=%x;aInterval=%d",
+                  ( TUint )this, aInterval.Int() );
+    
+    __ASSERT_ALWAYS( IsAdded(),
+                     User::Panic( KCFlexTimerPanicCat, 
+                                  EFlexTimerNotAddedToActiveScheduler ) );
+    iTimer.After( iStatus, aInterval );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer at latest on the given interval. 64-bit interval.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexTimer::After( TTimeIntervalMicroSeconds aInterval )
+    {
+    OstTraceExt2( TRACE_NORMAL, CFLEXTIMER_AFTER64,
+                  "CFlexTimer::After64;this=%x;aInterval=%llu",
+                  ( TUint )this, aInterval.Int64() );
+    
+    __ASSERT_ALWAYS( IsAdded(),
+                     User::Panic(KCFlexTimerPanicCat,
+                                 EFlexTimerNotAddedToActiveScheduler ) );
+    iTimer.After( iStatus, aInterval );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer between at latest by the given time value.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexTimer::At( const TTime& aTime )
+    {
+    OstTraceExt2( TRACE_NORMAL, CFLEXTIMER_AT,
+                  "CFlexTimer::At;this=%x;aTime=%lld", ( TUint )this,
+                  aTime.Int64() );
+    
+    __ASSERT_ALWAYS( IsAdded(),
+                     User::Panic( KCFlexTimerPanicCat,
+                                  EFlexTimerNotAddedToActiveScheduler ) );
+    iTimer.At( iStatus, aTime );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer between at latest by the given time value.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexTimer::AtUTC( const TTime& aTime )
+    {
+    OstTraceExt2( TRACE_NORMAL, CFLEXTIMER_ATUTC,
+                  "CFlexTimer::AtUTC;this=%x;aTime=%lld",
+                  ( TUint )this, aTime.Int64() );
+    
+    __ASSERT_ALWAYS( IsAdded(),
+                     User::Panic(KCFlexTimerPanicCat,
+                                 EFlexTimerNotAddedToActiveScheduler ) );
+    iTimer.AtUTC( iStatus, aTime );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// Sets the window size in which alignment is possible for the timer.
+// This is a synchronous command. 32-bit function argument.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CFlexTimer::Configure( TTimeIntervalMicroSeconds32 aWindowSize )
+    {
+    OstTraceExt2( TRACE_NORMAL, CFLEXTIMER_CONFIGURE,
+                  "CFlexTimer::Configure32;this=%x;aWindowSize=%d",
+                  ( TUint )this, aWindowSize.Int() );
+    
+    return iTimer.Configure( aWindowSize );
+    }
+
+// ---------------------------------------------------------------------------
+// Sets the window size in which alignment is possible for the timer.
+// This is a synchronous command. 64-bit function argument.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CFlexTimer::Configure( TTimeIntervalMicroSeconds aWindowSize )
+    {
+    OstTraceExt2( TRACE_NORMAL, DUP1_CFLEXTIMER_CONFIGURE,
+                  "CFlexTimer::Configure64;this=%x;aWindowSize=%lld",
+                  ( TUint )this, aWindowSize.Int64() );
+    
+    return iTimer.Configure( aWindowSize );
+    }
+
+// ---------------------------------------------------------------------------
+// Constructs the object. Connects to the server and create a session.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexTimer::ConstructL()
+    {
+    OstTrace1( TRACE_NORMAL, CFLEXTIMER_CONSTRUCTL,
+               "CFlexTimer::ConstructL;this=%x", ( TUint )this );
+    
+    User::LeaveIfError(iTimer.Connect());
+    }
+
+// ---------------------------------------------------------------------------
+// Constructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CFlexTimer::CFlexTimer( TInt aPriority ) :
+    CActive( aPriority )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Inherited from CActive. Handles the object canceling operations.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CFlexTimer::DoCancel()
+    {
+    OstTrace1( TRACE_NORMAL, CFLEXTIMER_DOCANCEL,
+               "CFlexTimer::DoCancel;this=%x", ( TUint )this );
+    
+    iTimer.Cancel();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/src/rflextimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of RFlexTimer class
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+#include "rflextimer.h"
+#include "flextimercommon.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "rflextimerTraces.h"
+#endif
+
+
+_LIT( KFlexTimerSemaphoreName, "FlexTimerSemaphore" );
+
+// Semaphore count value initialization to 1. The 1st to call Wait() will
+// pass the semaphore. Other processes attempting entry will wait until the
+// 1st one has called Signal() on the semaphore.
+const TInt KPassFirstWaitEntry = 1;
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// Constructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RFlexTimer::RFlexTimer()
+    {
+    OstTrace1( TRACE_NORMAL, RFLEXTIMER_RFLEXTIMER,
+               "RFlexTimer::RFlexTimer;this=%x", this );
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Destructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RFlexTimer::~RFlexTimer()
+    {
+    OstTrace1( TRACE_NORMAL, DUP1_RFLEXTIMER_RFLEXTIMER,
+               "RFlexTimer::~RFlexTimer;this=%x", ( TUint )this );
+    
+    Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Connects to the server and create a session.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimer::Connect()
+    {
+    OstTrace1( TRACE_NORMAL, RFLEXTIMER_CONNECT,
+               "RFlexTimer::Connect;this=%x", ( TUint )this );
+    
+    // Not opened handle-number
+    const TInt kHandleNotOpened( 0 );
+    
+    // Starts the server, if it does not already exist in the system.
+    TInt ret = StartServer();
+
+    if ( ret == KErrNone )
+        { // No session, create it
+
+        // Handle() is zero when initialized RHandleBase. Close() also zeroes 
+        // the handle. If CreateSession() fails, Handle() is still zero.
+        // If session is created ok, the Handle() contains the (non zero)
+        // handle-number. 
+        //
+        // Handle() can be used for checking is the handle opened or not.
+        //
+        if ( Handle() == kHandleNotOpened )
+            {
+            // Creates the session for this client.
+            ret = CreateSession( KFlexTimerServerName,
+                                 Version(),
+                                 KFlexTimerServerMessageSlots );
+            }
+        else
+            { // Session already exists - panic.
+
+            OstTrace1( 
+                TRACE_NORMAL, 
+                DUP1_RFLEXTIMER_CONNECT,
+                "RFlexTimer::Connect already connected - PANIC;this=%x", 
+                ( TUint )this );
+        
+            User::Panic( KRFlexTimerPanicCat, EFlexTimerAlreadyConnected );
+            }
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Cancels any outstanding request to the server.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RFlexTimer::Cancel()
+    {
+    OstTrace1( TRACE_NORMAL, RFLEXTIMER_CANCEL,
+               "RFlexTimer::Cancel;this=%x", ( TUint )this );
+    
+    SendReceive( EFlexTimerServCancelRequest );
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer at latest on the given interval. 32-bit interval.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RFlexTimer::After( TRequestStatus& aStatus,
+                                 TTimeIntervalMicroSeconds32 aInterval )
+    {
+    OstTraceExt3( TRACE_NORMAL, RFLEXTIMER_AFTER32,
+                  "RFlexTimer::After32;this=%x;aStatus=%x;aInterval=%d",
+                  ( TUint )this, ( TUint )&( aStatus ), aInterval.Int() );
+    
+    const TTimeIntervalMicroSeconds32 ZERO_INTERVAL32(0);
+    __ASSERT_ALWAYS(aInterval >= ZERO_INTERVAL32,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerAfterIntervalLessThanZero));
+    
+    TIpcArgs args( aInterval.Int(), 0 );
+    //asynchronous request for timer creation and timeout request.    
+    SendReceive( EFlexTimerServAfterRequest, args, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer at latest on the given interval. 64-bit interval.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RFlexTimer::After( TRequestStatus& aStatus,
+                                 TTimeIntervalMicroSeconds aInterval )
+    {
+    OstTraceExt3( TRACE_NORMAL, RFLEXTIMER_AFTER64,
+                  "RFlexTimer::After64;this=%x;aStatus=%x;aInterval=%lld",
+                  ( TUint )this, ( TUint )&( aStatus ), aInterval.Int64() );
+    
+    const TTimeIntervalMicroSeconds ZERO_INTERVAL(0);
+    __ASSERT_ALWAYS(aInterval >= ZERO_INTERVAL,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerAfterIntervalLessThanZero));
+    
+    TIpcArgs args( I64LOW(aInterval.Int64()), I64HIGH(aInterval.Int64()) );
+    //asynchronous request for timer creation and timeout request.    
+    SendReceive( EFlexTimerServAfterRequest, args, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer at latest after the given number of ticks.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RFlexTimer::AfterTicks( TRequestStatus& aStatus, TInt aTicks )
+    {
+    OstTraceExt3( TRACE_NORMAL, RFLEXTIMER_AFTERTICKS,
+                  "RFlexTimer::AfterTicks;this=%x;aStatus=%d;aTicks=%d",
+                  ( TUint )this, ( TUint )&( aStatus ), aTicks );
+    
+    __ASSERT_ALWAYS(aTicks >= 0,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerAfterTicksIntervalLessThanZero));
+
+    TIpcArgs args( aTicks );
+    //asynchronous request for timer creation and timeout request.    
+    SendReceive( EFlexTimerServAfterTicksRequest, args, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer between at latest by the given time value.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RFlexTimer::At( TRequestStatus& aStatus, const TTime& aTime )
+    {
+    OstTraceExt3( TRACE_NORMAL, RFLEXTIMER_AT,
+                  "RFlexTimer::At;this=%x;aStatus=%d;aTime=%lld",
+                  ( TUint )this, ( TUint )&( aStatus ), aTime.Int64() );
+    
+    TTime nowTime;
+    nowTime.HomeTime();
+    
+    __ASSERT_ALWAYS(aTime >= nowTime,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerAtIntervalLessThanZero));
+    
+    TIpcArgs args( I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()) );
+    //asynchronous request for timer creation and timeout request.    
+    SendReceive( EFlexTimerServAtRequest, args, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// Fire timer between at latest by the given time value.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void RFlexTimer::AtUTC( TRequestStatus& aStatus, const TTime& aTime )
+    {
+    OstTraceExt3( TRACE_NORMAL, RFLEXTIMER_ATUTC,
+                  "RFlexTimer::AtUTC;this=%x;aStatus=%d;aTime=%lld",
+                  ( TUint )this, ( TUint )&( aStatus ), aTime.Int64() );
+    
+    TTime nowTime;
+    nowTime.UniversalTime();
+    
+    __ASSERT_ALWAYS(aTime >= nowTime,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerAtUTCIntervalLessThanZero));
+    
+    TIpcArgs args( I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()) );
+    //asynchronous request for timer creation and timeout request.    
+    SendReceive( EFlexTimerServAtUTCRequest, args, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// Sets the window size in which alignment is possible for the timer.
+// This is a synchronous command. 32-bit function version.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimer::Configure( TTimeIntervalMicroSeconds32 aWindowSize )
+    {
+    OstTraceExt2( TRACE_NORMAL, RFLEXTIMER_CONFIGURE,
+                  "RFlexTimer::Configure32;this=%x;aWindowSize=%d",
+                  ( TUint )this, aWindowSize.Int() );
+    
+    const TTimeIntervalMicroSeconds32 ZERO_INTERVAL32(0);
+    __ASSERT_ALWAYS(aWindowSize >= ZERO_INTERVAL32,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerWindowLessThanZero));
+    
+    TInt64 transfer = MAKE_TINT64( 0, aWindowSize.Int() );
+        
+    // Regardless of the user function, the window size is always transmitted
+    // as a 64-bit integer.
+    TIpcArgs args( EConfigureRequestWindowSize, 
+                   I64LOW(transfer), I64HIGH(transfer) );
+
+    return SendReceive( EFlexTimerServConfigureRequest, args );
+    }
+
+// ---------------------------------------------------------------------------
+// Sets the window size in which alignment is possible for the timer.
+// This is a synchronous command. 64-bit function version.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimer::Configure( TTimeIntervalMicroSeconds aWindowSize )
+    {
+    OstTraceExt2( TRACE_NORMAL, DUP1_RFLEXTIMER_CONFIGURE,
+                  "RFlexTimer::Configure64;this=%x;aWindowSize=%lld",
+                  ( TUint )this, aWindowSize.Int64() );
+    
+    const TTimeIntervalMicroSeconds ZERO_INTERVAL64(0);
+    __ASSERT_ALWAYS(aWindowSize >= ZERO_INTERVAL64,
+                    User::Panic(KRFlexTimerPanicCat,
+                                EFlexTimerWindowLessThanZero));
+    
+    // Regardless of the user function, the window size is always transmitted
+    // as a 64-bit integer.
+    TIpcArgs args( EConfigureRequestWindowSize,
+                   I64LOW(aWindowSize.Int64()),
+                   I64HIGH(aWindowSize.Int64()) );
+
+    return SendReceive( EFlexTimerServConfigureRequest, args  );
+    }
+
+// ---------------------------------------------------------------------------
+// Gets the version number.
+// ---------------------------------------------------------------------------
+//
+TVersion RFlexTimer::Version() const
+    {
+    return ( TVersion( KFlexTimerServMajorVersionNumber,
+                       KFlexTimerServMinorVersionNumber,
+                       KFlexTimerServBuildVersionNumber ) );
+    }
+
+// ---------------------------------------------------------------------------
+// Connects to the server. If server does not exist, it is created.
+// ---------------------------------------------------------------------------
+//
+TInt RFlexTimer::StartServer()
+    {
+    OstTrace1( TRACE_NORMAL, RFLEXTIMER_STARTSERVER,
+               "RFlexTimer::StartServer;this=%x", ( TUint )this );
+    
+    TFindServer findServer( KFlexTimerServerName );
+    TFullName serverName;
+
+    // See if the server is already started. 
+    TInt ret = findServer.Next( serverName );
+    
+    if ( ret != KErrNone )
+        {
+        //Server was not found so create one.
+        RProcess serverProcess;
+        TBuf<1> serverParameters;
+
+        // Semaphore to guard the opening of the server process.
+        RSemaphore semaphore;
+
+        // Prevent two clients from  creating the serverProcess at the same
+        // time.
+        if ( ( ret = semaphore.CreateGlobal( 
+                KFlexTimerSemaphoreName, KPassFirstWaitEntry ) ) != KErrNone )
+            {
+            ret = semaphore.OpenGlobal( KFlexTimerSemaphoreName );
+            }
+
+        if ( ret == KErrNone )
+            {
+            semaphore.Wait();
+
+            // See again if the server is already started. This doublechecking
+            // is necessary, since two or processes may have resolved the
+            // first findserver before any server was created.
+
+            // TFindServer sets its content only when instantiated.
+            // Just using findServer.Next() does not work in here.
+            TFindServer findServerAgain( KFlexTimerServerName );
+            if ( findServerAgain.Next( serverName ) != KErrNone )
+                {
+                // Load the executable for the server.
+                ret = serverProcess.Create( KFlexTimerServerExe,
+                                            serverParameters,
+                                            EOwnerThread );
+
+                if ( ret == KErrNone )
+                    {
+                    // Server has been created successfully. It is initially 
+                    // in suspended state. Now resume the server process.
+                    serverProcess.Resume();
+
+                    // Wait until the server process has been started.
+                    TRequestStatus status;
+                    serverProcess.Rendezvous( status );
+                    User::WaitForRequest( status );
+
+                    // Check if server has panicked during initialization.
+                    ret = serverProcess.ExitType();
+                    if ( ret == EExitPanic )
+                        {
+                        OstTrace1( TRACE_NORMAL, DUP1_RFLEXTIMER_STARTSERVER,
+                                "RFlexTimer::StartServer;this=%x; "
+                                "ERROR: Server paniced",
+                                ( TUint )this );
+
+                        ret = KErrServerTerminated;
+                        }
+                    else
+                        {
+                        ret = status.Int();
+                        }
+
+                    // The server process stands on its own. This handle can
+                    // be closed. 
+                    serverProcess.Close();
+                    }
+                else
+                    {
+                    OstTrace1( TRACE_NORMAL, DUP2_RFLEXTIMER_STARTSERVER,
+                            "RFlexTimer::StartServer;this=%x; "
+                            "ERROR: Server creation failed",
+                            ( TUint )this );
+                    }
+                }
+            
+            semaphore.Signal();
+            semaphore.Close();
+            }
+        }
+
+    return ret;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,4 @@
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+#include <opensystemtrace.h>
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/client/traces/fixed_id.definitions	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,33 @@
+#Fixed group and trace id definitions. If this file is removed, the identifiers are rebuilt.
+[GROUP]TRACE_NORMAL=0x3
+[TRACE]TRACE_NORMAL[0x3]_CFLEXPERIODIC_CFLEXPERIODIC=0x1
+[TRACE]TRACE_NORMAL[0x3]_CFLEXPERIODIC_CONFIGURE=0x4
+[TRACE]TRACE_NORMAL[0x3]_CFLEXPERIODIC_RUNL=0x6
+[TRACE]TRACE_NORMAL[0x3]_CFLEXPERIODIC_RUNL_PANIC=0x7
+[TRACE]TRACE_NORMAL[0x3]_CFLEXPERIODIC_START32=0x2
+[TRACE]TRACE_NORMAL[0x3]_CFLEXPERIODIC_START64=0x3
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_AFTER32=0x9
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_AFTER64=0xa
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_AT=0xb
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_ATUTC=0xc
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_CFLEXTIMER=0x8
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_CONFIGURE=0xd
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_CONSTRUCTL=0xf
+[TRACE]TRACE_NORMAL[0x3]_CFLEXTIMER_DOCANCEL=0x10
+[TRACE]TRACE_NORMAL[0x3]_DUP1_CFLEXPERIODIC_CONFIGURE=0x5
+[TRACE]TRACE_NORMAL[0x3]_DUP1_CFLEXTIMER_CONFIGURE=0xe
+[TRACE]TRACE_NORMAL[0x3]_DUP1_RFLEXTIMER_CONFIGURE=0x1c
+[TRACE]TRACE_NORMAL[0x3]_DUP1_RFLEXTIMER_CONNECT=0x14
+[TRACE]TRACE_NORMAL[0x3]_DUP1_RFLEXTIMER_RFLEXTIMER=0x12
+[TRACE]TRACE_NORMAL[0x3]_DUP1_RFLEXTIMER_STARTSERVER=0x1e
+[TRACE]TRACE_NORMAL[0x3]_DUP2_RFLEXTIMER_STARTSERVER=0x1f
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_AFTER32=0x16
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_AFTER64=0x17
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_AFTERTICKS=0x18
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_AT=0x19
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_ATUTC=0x1a
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_CANCEL=0x15
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_CONFIGURE=0x1b
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_CONNECT=0x13
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_RFLEXTIMER=0x11
+[TRACE]TRACE_NORMAL[0x3]_RFLEXTIMER_STARTSERVER=0x1d
Binary file keepalive/flextimer/doc_pub/flextimer_for_clients.chm has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/classesfordox.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,51 @@
+// Dummy empty classes for Doxygen documentation (main for inheritance graphs)
+
+// Symbian Classes
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class CBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class CActive : public CBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class RTimer : public RHandleBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class CTimer : public CActive {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class CPeriodic : public CTimer {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class RHandleBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class RSessionBase : public RHandleBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class CServer2 : public CActive {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class CSession2 : public CBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class RThread : public RHandleBase {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class TTime {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class TTimeIntervalMicroSeconds {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class TTimeIntervalMicroSeconds32 {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class TCallBack {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class TVersion {};
+
+/*! Symbian. http://developer.symbian.org/main/documentation/carbide/index.php */
+class TRequestStatus {};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/dox_base_settings.cfg	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,228 @@
+# Doxyfile 1.6.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING      = UTF-8
+PROJECT_NUMBER         =
+OUTPUT_DIRECTORY       =
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       =
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+STRIP_FROM_PATH        =
+STRIP_FROM_INC_PATH    =
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+QT_AUTOBRIEF           = YES
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 8
+ALIASES                =
+OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_JAVA   = NO
+OPTIMIZE_FOR_FORTRAN   = NO
+OPTIMIZE_OUTPUT_VHDL   = NO
+EXTENSION_MAPPING      =
+BUILTIN_STL_SUPPORT    = NO
+CPP_CLI_SUPPORT        = NO
+SIP_SUPPORT            = NO
+IDL_PROPERTY_SUPPORT   = YES
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+TYPEDEF_HIDES_STRUCT   = NO
+SYMBOL_CACHE_SIZE      = 0
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = YES
+EXTRACT_STATIC         = YES
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = YES
+EXTRACT_ANON_NSPACES   = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = NO
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_MEMBERS_CTORS_1ST = NO
+SORT_GROUP_NAMES       = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       =
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+SHOW_FILES             = YES
+SHOW_NAMESPACES        = YES
+FILE_VERSION_FILTER    =
+LAYOUT_FILE            =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT_ENCODING         = UTF-8
+FILE_PATTERNS          = *.h *.cpp *.dox
+EXCLUDE                =
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       =
+EXCLUDE_SYMBOLS        =
+EXAMPLE_PATH           =
+EXAMPLE_PATTERNS       =
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = . 
+INPUT_FILTER           =
+FILTER_PATTERNS        =
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            =
+HTML_FOOTER            =
+HTML_STYLESHEET        =
+HTML_ALIGN_MEMBERS     = YES
+HTML_DYNAMIC_SECTIONS  = NO
+GENERATE_DOCSET        = NO
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+GENERATE_CHI           = NO
+CHM_INDEX_ENCODING     =
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+GENERATE_QHP           = NO
+QCH_FILE               =
+QHP_NAMESPACE          =
+QHP_VIRTUAL_FOLDER     = doc
+QHP_CUST_FILTER_NAME   =
+QHP_CUST_FILTER_ATTRS  =
+QHP_SECT_FILTER_ATTRS  =
+QHG_LOCATION           =
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+USE_INLINE_TREES       = NO
+TREEVIEW_WIDTH         = 250
+FORMULA_FONTSIZE       = 10
+SEARCHENGINE           = YES
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         =
+LATEX_HEADER           =
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+LATEX_SOURCE_CODE      = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    =
+RTF_EXTENSIONS_FILE    =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             =
+XML_DTD                =
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+INCLUDE_PATH           =
+INCLUDE_FILE_PATTERNS  =
+SEARCH_INCLUDES        = YES
+EXPAND_AS_DEFINED      =
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES               =
+GENERATE_TAGFILE       =
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+MSCGEN_PATH            =
+HIDE_UNDOC_RELATIONS   = YES
+DOT_FONTNAME           = FreeSans
+DOT_FONTSIZE           = 10
+DOT_FONTPATH           =
+DOTFILE_DIRS           =
+DOT_GRAPH_MAX_NODES    = 50
+MAX_DOT_GRAPH_DEPTH    = 3
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/flextimer_for_clients.cfg	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,1329 @@
+# Doxyfile 1.5.4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file that 
+# follow. The default is UTF-8 which is also the encoding used for all text before 
+# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into 
+# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of 
+# possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = "Flexible Timers API"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 0.1.1
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       =
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, 
+# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, 
+# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, 
+# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = "panic=\par \"Panic code:\" \e" \
+                         "leave=\par \"Leave code:\" \e"
+
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 
+# include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct (or union) is 
+# documented as struct with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code where the coding convention is that all structs are 
+# typedef'ed and only the typedef is referenced never the struct's name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be extracted 
+# and appear in the documentation as a namespace called 'anonymous_namespace{file}', 
+# where file will be replaced with the base name of the file that contains the anonymous 
+# namespace. By default anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = NO
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from the 
+# version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = flextimer_for_clients.dox classesfordox.h ../client
+
+# This tag can be used to specify the character encoding of the source files that 
+# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default 
+# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. 
+# See http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = .svn html
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = */.svn/* */.svn */traces/*
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the output. 
+# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, 
+# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = CActive                        \
+                         CBase                          \
+                         CPeriodic                      \
+                         CServer2                       \
+                         CSession2                      \
+                         CTimer                         \
+                         RHandleBase                    \
+                         RSessionBase                   \
+                         RThread                        \
+                         RTimer                         \
+                         TCallBack                      \
+                         TRequestStatus                 \
+                         TTime                          \
+                         TTimeIntervalMicroSeconds      \
+                         TTimeIntervalMicroSeconds32    \
+                         TVersion
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = ./pics
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH 
+# then you must also enable this option. If you don't then doxygen will produce 
+# a warning and turn it on anyway
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.  Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = "C:\Program Files\HTML Help Workshop\hhc.exe"
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = IMPORT_C= \
+                         EXPORT_C= \
+                         "NONSHARABLE_CLASS(name)=class name"
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to 
+# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to 
+# specify the directory where the mscgen tool resides. If left empty the tool is assumed to 
+# be found in the default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will 
+# generate a caller dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable caller graphs for selected 
+# functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = "C:\Program Files\Graphviz2.26.3\bin"
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the number 
+# of direct children of the root node in a graph is already larger than 
+# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, which results in a white background. 
+# Warning: Depending on the platform used, enabling this option may lead to 
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to 
+# read).
+
+DOT_TRANSPARENT        = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/flextimer_for_clients.dox	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Flexible timer documentation's main page
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+
+/**
+@mainpage
+
+@section mainGeneral General
+
+Flexible timers are timers for synchronizing network access. This is achieved
+by providing a timer service that instead of generating timeout at exact moment
+of time, generates timeout within given window of time. This allows several
+timeouts to be aligned, and only one wakeup is needed instead of many. This
+improves battery life. The improvement depends on the used bearer and its 
+configuration.
+
+Flexible timers are designed to provided similar API with existing Symbian
+timers (RTimer, CTimer and CPeriodic), and (besides they extend the interfaces
+by providing 64-bit interface for After(). I.e. using At() for longer than 35
+minutes timers is not required.
+
+@subsection mainYes When you should consider using Flexible timers 
+- If your timer can handle several minutes variation in expiration times @b AND
+- If your timer is used to trigger network connectivity @b AND
+- If your timer is long enough (> 5 min)
+
+@subsection mainNo Who should NOT use Flexible timers
+- If you need accurate timing (in resolution of minutes) @b OR
+- If your timer is too rapid, i.e. less than 5 minutes @b OR
+- If you need timeout when phone is powered off @b OR
+- If you need reboot-proof timeouts
+
+@section mainTimerWindow Concept
+
+The main idea of flexible timer concept is that timers can expire @a early.
+The time how much earlier timer can expire, is called @b timer @b expiration 
+@b window (or just window).
+
+For example, a timer that is started to expire after 10 minutes timer that 
+window is configured to 2 minutes can expire at any time between 8 to 10 
+minutes. See the figure below.
+
+\image html FlexTimerWindowConcept.png
+
+There are two reasons when timer can expire:
+-# The timer has reached the time it's set to be expired
+-# Another timer is expiring within this timer's window
+
+In picture below is shown two set of periodical timers; normal timers and
+flexible timers. Each time a timer expires, it causes network access.
+
+\image html FlexTimersExample.png
+
+The picture also illustrates main differences between using normal and flexible
+timers:
+- number of network initializations decreases (12 vs. 6).
+- timers are being "drifted" (e.g. interval of Timer 2 is actually 12 minutes)
+
+@section mainArchitecture Architecture
+
+In picture below is illustrated components of flexible timers.
+
+\image html FlexTimerComponents.png
+
+When a client uses flexible timers, the actual timer request is forwarded to
+Flex Timer Server using Symbian's inter process communication (IPC). The
+biggest difference to normal timers is that flexible timers actually are run in
+different process than the client as the normal timers are run in local thread.
+
+@section mainLimitations Limitations of flexible timers
+
+@subsection mainTimerAccuracy Timer Accuracy
+
+Although the timer can be set to expire in 1 microsecond accuracy, the actual
+accuracy can vary from 1/64 second (one system tick) to 1 second. It depends
+when the timer is set; timers are "rounded" to the next full second.
+
+This implies that e.g. 1 microsecond periodic timer's period is 1 second; not
+1 microsecond.
+
+As the flexible timer's implementation relies on system ticks, it's possible 
+that the timer expires 1/64 second (one system tick) too early.
+
+I.e. the timer can expire from -1/64 second to +1 second when it is set.
+
+@note If timer accuracy at this resolution is concern for you, you should not
+use flexible timers at all. Use normal timers instead.
+
+@subsection mainMinValue Minimum timer value
+
+The minimum timer value is 0 microsecond. Only exception is CFlexPeriodic's
+interval that can be 1 microseconds. 
+
+@subsection mainMaxValue Maximum timer value
+
+Maximum value for timer is 2 years (i.e. 730 days, 63072000 seconds).
+
+@subsection mainMinWindow Minimum window value
+
+The minimum value for timer window is zero microseconds.
+
+@subsection mainMaxWindow Maximum window value
+
+The maximum value for timer window is two years (i.e. 730 days, 63072000 
+seconds). 
+
+The default value for window is 20% of the timer's value (e.g. 10 minutes timer
+has 2 minutes default window).
+
+@subsection mainTimerDrifting Timer drifting
+
+As the timer expiration can happen in timer expiration window, it usually
+causes periodic timers to "drift".
+
+For example:
+
+@c CPeriodic is started at 8 o'clock with 30 minute interval.
+It will then expire at 8.30, 9.00, ... 15.30, 16.00
+
+If @c CFlexPeriodic is used as a timer it can possibly expire at
+8.30, 9.00, 9.28, 9.55, ... 15.15, 15.42 etc. 
+
+@subsection mainReboot Reboot-proof
+
+Flexible timers are @b not reboot-proof. I.e. after reboot all timers has to
+be set again.
+
+@section mainHowTo How to start using flexible timers
+
+The flexible timer API is designed to be as similar to normal Symbian timers
+as possible. 
+
+In the table below is described Symbian OS timer and its corresponding flexible
+timer.
+
+<table border=1 bordercolor="#84B0C7" cellspacing="0" align="center">
+<tr><td><b>Symbian OS timer</b></td><td><b>Flexible timer</b></td></tr>
+<tr><td><code>CPeriodic</code></td><td><code>CFlexPeriodic</code></td></tr>
+<tr><td><code>CTimer</code></td><td><code>CFlexTimer</code></td></tr>
+<tr><td><code>RTimer</code></td><td><code>RFlexTimer</code></td></tr>
+</table>
+
+Using of flexible timer is easy and fun. There are only three following steps;
+
+-# Add following line to MMP-file
+   @code 
+   LIBRARY flextimer.lib 
+   @endcode
+-# Include flexible timer's header to your code files, e.g. for periodic timer
+   @code
+   #include <flexperiodic.h>
+   @endcode
+-# Convert the used Symbian OS timers to flexible timers, e.g.
+   @code
+   //Old: CPeriodic* myTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+   CFlexPeriodic* myTimer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+   ...
+   // By default the window is 20% of timer's values
+   myTimer->Start( myDelay, myInterval, myCallback ); // No changes
+   ...
+   myTimer->Cancel(); // No changes
+   delete myTimer; // No changes
+
+   @endcode
+
+More examples available in flexible timer's class documentation.
+
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/flextimer_for_devs.cfg	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,70 @@
+# Doxyfile 1.6.1
+
+@INCLUDE = dox_base_settings.cfg
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+PROJECT_NAME           = Flexible Timers & Timer Alignment Engine
+FULL_PATH_NAMES        = NO # YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = classesfordox.h \
+                         ..\
+
+RECURSIVE              = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+# These options affect the class and function descriptions
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO # YES
+REFERENCED_BY_RELATION = NO # YES
+REFERENCES_RELATION    = NO # YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the Windows help file generation
+#---------------------------------------------------------------------------
+
+# If this is NO, the rest of the help file generation options are not evaluated 
+GENERATE_HTMLHELP      = YES
+CHM_FILE               = ..\FlexTimerInternal.chm
+HHC_LOCATION           = "C:\Program Files\HTML Help Workshop\hhc.exe"
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If this is NO, the rest of the preprocessor options are not evaluated 
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = YES
+EXPAND_ONLY_PREDEF     = YES
+PREDEFINED             = IMPORT_C= \
+                         EXPORT_C= \
+                         "NONSHARABLE_CLASS(name)=class name"
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+# These parameters govern the type and amount of graphs in the document.
+#---------------------------------------------------------------------------
+
+# If this is NO, the rest of the graph options are not evaluated 
+HAVE_DOT               = YES
+
+CLASS_DIAGRAMS         = YES
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = YES
+CALLER_GRAPH           = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = "C:\Program Files\Graphviz2.26.3\bin"
Binary file keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/pics/FlexTimerComponents.png has changed
Binary file keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/pics/FlexTimerWindowConcept.png has changed
Binary file keepalive/flextimer/doc_pub/flextimer_for_clients_doxygen/pics/FlexTimersExample.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build info for flex timer modules.
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+#include "../client/group/bld.inf"
+#include "../server/group/bld.inf"
+
+PRJ_TESTMMPFILES
+#include "../test/testflextimer/group/bld.inf"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/bwins/flextimerengineu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,5 @@
+EXPORTS
+	?NewL@CFlexTimerEngine@@SAPAV1@XZ @ 1 NONAME ; class CFlexTimerEngine * CFlexTimerEngine::NewL(void)
+	?AddTimer@CFlexTimerEngine@@UAEHABVTTimeIntervalMicroSeconds@@0HPBVMFlexTimerServiceCB@@@Z @ 2 NONAME ; int CFlexTimerEngine::AddTimer(class TTimeIntervalMicroSeconds const &, class TTimeIntervalMicroSeconds const &, int, class MFlexTimerServiceCB const *)
+	?CancelTimer@CFlexTimerEngine@@UAEHPBVMFlexTimerServiceCB@@@Z @ 3 NONAME ; int CFlexTimerEngine::CancelTimer(class MFlexTimerServiceCB const *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/eabi/flextimerengineu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,15 @@
+EXPORTS
+	_ZN16CFlexTimerEngine11CancelTimerEPK19MFlexTimerServiceCB @ 1 NONAME
+	_ZN16CFlexTimerEngine4NewLEv @ 2 NONAME
+	_ZN16CFlexTimerEngine8AddTimerERK25TTimeIntervalMicroSecondsS2_iPK19MFlexTimerServiceCB @ 3 NONAME
+	_ZTI14CFlexTimerItem @ 4 NONAME
+	_ZTI16CFlexTimerEngine @ 5 NONAME
+	_ZTI19CFlexTimerContainer @ 6 NONAME
+	_ZTI21CFlexTimerWakeUpTimer @ 7 NONAME
+	_ZTV14CFlexTimerItem @ 8 NONAME
+	_ZTV16CFlexTimerEngine @ 9 NONAME
+	_ZTV19CFlexTimerContainer @ 10 NONAME
+	_ZTV21CFlexTimerWakeUpTimer @ 11 NONAME
+	_ZThn4_N16CFlexTimerEngine11CancelTimerEPK19MFlexTimerServiceCB @ 12 NONAME
+	_ZThn4_N16CFlexTimerEngine8AddTimerERK25TTimeIntervalMicroSecondsS2_iPK19MFlexTimerServiceCB @ 13 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for Flexible timer engine
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/flextimerengine.iby CORE_MW_LAYER_IBY_EXPORT_PATH(flextimerengine.iby)
+
+PRJ_MMPFILES
+flextimerengine.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/group/flextimerengine.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Flexible timer
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+#include <platform_paths.hrh>
+
+TARGET              flextimerengine.dll
+TARGETTYPE          DLL
+UID                 0x1000008D 0x2002DCE7
+
+CAPABILITY          CAP_GENERAL_DLL
+VENDORID            VID_DEFAULT
+
+USERINCLUDE         ../inc
+USERINCLUDE         ../../inc
+USERINCLUDE         ../traces
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY             euser.lib
+LIBRARY             hal.lib
+
+SOURCEPATH ../src
+
+SOURCE flextimercontainer.cpp
+SOURCE flextimerengine.cpp
+SOURCE flextimeritem.cpp
+SOURCE flextimerwakeuptimer.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/flextimercontainer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains definition of CFlexTimerContainer.
+ *
+ */
+
+// Protection against nested includes
+#ifndef FLEXTIMERCONTAINER_H
+#define FLEXTIMERCONTAINER_H
+
+// System includes
+#include <e32base.h>
+
+// Forward declarations
+class MFlexTimerServiceCB;
+class CFlexTimerItem;
+
+// Class declaration
+/**
+ *  Timer container that contains list of CFlexTimerItems, means to add and
+ *  delete them and implementation of algorithms that select which timers
+ *   should be expired.
+ */
+class CFlexTimerContainer : public CBase
+    {
+public:
+    /** Supported timer algorithms.*/
+    enum TFlexTimerAlgorithm
+        {
+        /** Simple algorithm timeouts all timers that have open timeout
+         * window when one timer expires.
+         */
+        EFlexTimerAlgorithmSimple = 1,
+        /** Latest possible algorithm tries to delay expiration of timer
+         * as long as possible.
+         */
+        EFlexTimerAlgorithmLatestPossible
+        };
+
+    /**
+     * Constructs new CFlexTimerContainer.
+     */
+    static CFlexTimerContainer* NewL();
+
+    /**
+     * Destructs timercontainer and all timers in the internal lists.
+     */
+    virtual ~CFlexTimerContainer();
+
+public:
+    /**
+     * Makes new timer item and adds it to timerlist.
+     *
+     * @param aWinStartInterval Time interval from present to left side of the
+     *  timer launch window
+     * @param aWinEndInterval Time interval from present to right side of the
+     *  timer launch window
+     * @param aCancelAtSystemTimeChange Whether system time change should
+     *  trigger abort
+     * @param aFlexTimerServiceCB Call back interface. Used to inform about
+     *  timeout, abort etc.
+     */
+    void AddTimerL(
+        const TTimeIntervalMicroSeconds& aWinStartInterval,
+        const TTimeIntervalMicroSeconds& aWinEndInterval,
+        TBool aCancelAtSystemTimeChange,
+        const MFlexTimerServiceCB* aFlexTimerServiceCB );
+
+    /**
+     * Finds correct timer according to aFlexTimerServiceCB and removes it
+     * from list and finally 
+     * deletes the corresponding CFlexTimerItem.
+     * @param aFlexTimerServiceCB Call back interface aka. session that
+     * handles timer.
+     * @return KErrNone or some system wide error code.
+     */
+    TInt RemoveTimer( const MFlexTimerServiceCB* aFlexTimerServiceCB );
+
+    /**
+     * Finds earliest moment that at least one timer must expire and after
+     * this function returns aNextTimeoutDelay contains number of microseconds
+     * from now to that moment.
+     *
+     * @param after return aNextTimeoutDelay contains time in microseconds
+     * from now till next timer expiry. If aNextTimeoutDelay is zero, it means
+     * that expiry time has already passed or is due right now
+     * @return Active timers indication
+     * - ETrue if there is at least one timer in queue
+     * - EFalse if there are no timers
+     */
+    TBool GetNextTimeout( TTimeIntervalMicroSeconds& aNextTimeoutDelay );
+
+    /**
+     * Fires all timers that can be fired according to algorithm that is
+     * supplied as parameter.
+     *
+     * @param aAlgorithmToBeUsed Algorithm that is used to fire timers.
+     * - EFlexTimerAlgorithmSimple
+     * - EFlexTimerAlgorithmLatestPossible
+     */
+    void FireTimers( TFlexTimerAlgorithm aAlgorithmToBeUsed );
+
+    /**
+     * Aborts and removes all timers that are marked with
+     * aCancelAtSystemTimeChange = ETrue during adding timer.
+     *
+     * @param aReason Timers will be aborted with this reason code. Can be
+     * e.g. KErrAbort
+     */
+    void AbortTimersDueToTimeChange( TInt aReason );
+
+private:
+    /**
+     * Private constructor.
+     */
+    CFlexTimerContainer();
+
+    /**
+     * Excecutes simple algorithm.
+     * 
+     * Moves timers (that can be fired right now) from iTimerList to
+     * candidateList.
+     * 
+     * @param aCandidateList After this function returns, this list contains
+     * all timers that can be fire right now.
+     * @param aCurrentTime Current safe UTC time.
+     */
+    void SimpleAlgorithm( TSglQue<CFlexTimerItem>& aCandidateList,
+        TTime& aCurrentTime );
+
+    /**
+     * Excecutes latest possible algorithm.
+     * 
+     * Moves timers (that don't necessarily be fired right now) from
+     * candidateList to iTimerList.
+     * 
+     * @param aCandidateList After this function returns, this list contains
+     * all timers that can be fire right now.
+     */
+    void LatestPossibleAlgorithm( TSglQue<CFlexTimerItem>& aCandidateList );
+
+    /**
+     * Fires all timers in aCandidateList. Calls Timeout() to all timers and
+     * deletes timer items.
+     * 
+     * @param aCandidateList Timers that are fired.
+     */
+    void ExpireTimers( TSglQue<CFlexTimerItem>& aCandidateList );
+
+    /**
+     * Gets current absolute time. The time in FlexTimer engine time base, not
+     * system time base. This time base is begins from the first call to
+     *  GetCurrentTime and it is base on system ticks.
+     * 
+     * @param aCurrentAbsoluteTime After this function returns this contains
+     * current flextimer timebase time.
+     */
+    void GetCurrentTime( TTime& aCurrentAbsoluteTime );
+
+    /**
+     * Converts microseconds interval to tick based reference time used by
+     * FlexTimer engine (also in microseconds). All FlexTimer timeout element
+     * time handling is based on this tick based absolute time.
+     *
+     * @param aInterval Interval to be converted.
+     */
+    inline TInt64 IntervalToAbsoluteTime(
+        const TTimeIntervalMicroSeconds& aInterval );
+
+    /**
+     * Converts ticks to microseconds.
+     *
+     * @param aTicks. Ticks to be converted to microseconds
+     */
+    inline TInt64 TicksToAbsoluteTime( TUint32 aTicks );
+
+private:
+    // Data
+    /**
+     * Linked list and iterator for all timer objects.
+     */
+    TSglQue<CFlexTimerItem> iTimerList;
+    
+    /**
+     * Length of system tick in milliseconds. The value is read once
+     * to member variable during construction of FlexTimerContainer so that
+     * it does not need be read every time the absolute time is calculated.
+     */
+    TInt iTickPeriod;
+     
+    /**
+     * Number of tics during the last time they were read. This is used to
+     * detect possible tick counter overflow and to calculate time passed
+     * since the last read.
+     */
+    TUint32 iLastTicks;
+    
+    /**
+     * Current FlexTimer engine time. This is system tick based time and
+     * it is updated every time someone request for it.
+     */
+    TInt64 iCurrentAbsoluteTime;
+    };
+
+#include "flextimercontainer.inl"
+
+#endif  //FLEXTIMERCONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/flextimercontainer.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This file contains inline functions of FlexTimerContainer class.
+ *
+ */
+
+// Protection against nested includes
+#ifndef FLEXTIMERCONTAINER_INL
+#define FLEXTIMERCONTAINER_INL
+
+// ---------------------------------------------------------------------------
+// Converts micro seconds interval to tick based absolute time (also in micro
+// seconds). All flextimer item time handling in engine is based on this tick
+// based absolute time. Note that the time is not using system time base.
+// ---------------------------------------------------------------------------
+//
+inline TInt64 CFlexTimerContainer::IntervalToAbsoluteTime(
+    const TTimeIntervalMicroSeconds& aInterval )
+    {
+    TTime tempTime;
+    GetCurrentTime( tempTime );
+
+    return tempTime.Int64() + aInterval.Int64();
+    }
+// ---------------------------------------------------------------------------
+// Converts system ticks to microseconds. 
+// ---------------------------------------------------------------------------
+//
+inline TInt64 CFlexTimerContainer::TicksToAbsoluteTime( const TUint32 aTicks )
+    {
+    return static_cast<TInt64> ( aTicks )
+        * static_cast<TInt64> ( iTickPeriod );
+    }
+
+#endif  //FLEXTIMERCONTAINER_INL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/flextimerengine.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains definition of CFlexTimerEngine.
+ *
+ */
+
+// Protection against nested includes
+#ifndef FLEXTIMERENGINE_H
+#define FLEXTIMERENGINE_H
+
+// System includes
+#include <e32base.h>
+
+// User includes
+#include "mflextimerservice.h"
+#include "mflextimerwakeuptimercb.h"
+
+// Forward declarations
+class MFlexTimerServiceCB;
+class CFlexTimerContainer;
+class CFlexTimerWakeUpTimer;
+
+// Class declaration
+/**
+ *  Flexible timer engine that acts as service point towards session.
+ *  Handles timer wakeups and system time changes.
+ */
+class CFlexTimerEngine : public CBase,
+        public MFlexTimerService,
+        public MFlexTimerWakeUpTimerCB
+    {
+public:
+
+    /**
+     * Constructs new timer engine.
+     */
+    IMPORT_C static CFlexTimerEngine* NewL();
+
+    /**
+     * Destructs timer item.
+     */
+    virtual ~CFlexTimerEngine();
+
+public:
+    /**
+     * Inherited from MFlexTimerService
+     */
+
+    /**
+     * Implementation of inherited pure virtual function
+     *  
+     * @see MFlexTimerService::AddTimer
+     */
+    IMPORT_C TInt AddTimer(
+        const TTimeIntervalMicroSeconds& aWinStartInterval,
+        const TTimeIntervalMicroSeconds& aWinEndInterval,
+        TBool aCancelAtSystemTimeChange,
+        const MFlexTimerServiceCB* aFlexTimerServiceCB );
+
+    /**
+     * Implementation of inherited pure virtual function
+     *  
+     * @see MFlexTimerService::CancelTimer
+     */
+    IMPORT_C TInt CancelTimer(
+        const MFlexTimerServiceCB* aFlexTimerServiceCB );
+
+    /**
+     * Inherited from MFlexTimerWakeUpTimerCB
+     */
+
+    /**
+     * Implementation of inherited pure virtual function
+     *  
+     * @see MFlexTimerWakeUpTimerCB::WakeUp
+     */
+    void WakeUp();
+
+    /**
+     * Implementation of inherited pure virtual function
+     *  
+     * @see MFlexTimerWakeUpTimerCB::SystemTimeChanged
+     */
+    void SystemTimeChanged();
+
+private:
+    /**
+     * Private constructor.
+     *  
+     */
+    CFlexTimerEngine();
+
+    /**
+     * Private 2nd pahse constructor.
+     *  
+     */
+    void ConstructL();
+
+    /**
+     * Finds out what is the next time we have to wake up to fire some
+     * FlexTimers and starts CTimer accordingly.
+     *  
+     */
+    void StartTimer();
+
+private:
+    // Data
+    /**
+     * Container for all timers. Lives and dies with engine.
+     */
+    CFlexTimerContainer* iFlexTimerContainer;
+
+    /**
+     * Wake up timer to watch flextimer firings and system time change
+     */
+    CFlexTimerWakeUpTimer* iWakeUpTimer;
+
+    };
+
+#endif  //FLEXTIMERENGINE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/flextimeritem.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains definition of CFlexTimerItem.
+ *
+ */
+
+// Protection against nested includes
+#ifndef FLEXTIMERITEM_H
+#define FLEXTIMERITEM_H
+
+// System includes
+#include <e32base.h>
+
+// User includes
+// None
+
+// Forward declarations
+class MFlexTimerServiceCB;
+
+// Class declaration
+/**
+ *  Timer item that contains expiry time, window size and other timer specific
+ *  parameters. Class implements container for one timer information in
+ *  FlexTimerServer.
+ */
+class CFlexTimerItem : public CBase
+    {
+public:
+
+    /** Constructor
+     *
+     * Constructs new timer item that contains all information needed to
+     * decide when to launch timer.
+     *
+     * @param aAbsoluteMinTime Left side of the timer launch window.
+     * @param aAbsoluteMaxTime Right side of the timer launch window.
+     * @param aCancelAtSystemTimeChange Whether system time change should
+     * trigger abort.
+     * @param aFlexTimerServiceCB Call back interface. Used to inform about
+     * timeout, abort etc.
+     * @return New CFlexTimer object.
+     */
+    static CFlexTimerItem* NewL( const TTime& aAbsoluteMinTime,
+        const TTime& aAbsoluteMaxTime,
+        TBool aCancelAtSystemTimeChange,
+        const MFlexTimerServiceCB* aFlexTimerServiceCB );
+
+    /** Destructor
+     * Destructs timer item.
+     */
+    virtual ~CFlexTimerItem();
+
+public:
+    /**
+     * Gets the earliest possible moment when this timer can expire. 
+     * Places value to reference parameter. 
+     *
+     * @param aMinAbsoluteTime After function returns this parameter contains
+     * absolute earliest moment when this timer can expire         
+     */
+    inline void GetMinAbsoluteTime( TTime& aMinAbsoluteTime );
+
+    /**
+     * Gets the latest possible moment when this timer must expire. 
+     * Places value to reference parameter. 
+     *
+     * @param aMaxAbsoluteTime After function returns this parameter contains
+     * absolute latest moment when this timer must expire       
+     */
+    inline void GetMaxAbsoluteTime( TTime& aMaxAbsoluteTime );
+
+    /**
+     * Checks whether this timer should be aborted if system time changes
+     *
+     * @return 
+     * ETrue - If timer should be aborted when system time changes
+     * EFalse - If timer should not be cancelled when system time changes        
+     */
+    inline TBool IsAbortedAtSystemTimeChange();
+
+    /**
+     * Returns timers corresponding CB session pointer.
+     *
+     * @return pointer to session that initiated this timer       
+     */
+    const MFlexTimerServiceCB* GetCB();
+
+private:
+    /**
+     * Private contructor. Constructs new timer item that contains all
+     * information needed to decide when to launch timer.
+     *
+     * @param aAbsoluteMinTime Left side of the timer launch window.
+     * @param aAbsoluteMaxTime Right side of the timer launch window.
+     * @param aCancelAtSystemTimeChange Whether system time change should
+     * trigger abort.
+     * @param aFlexTimerServiceCB Call back interface. Used to inform about
+     * timeout, abort etc.
+     *
+     * @return New CFlexTimer object.
+     * 
+     */
+    CFlexTimerItem( const TTime& aAbsoluteMinTime,
+        const TTime& aAbsoluteMaxTime,
+        TBool aCancelAtSystemTimeChange,
+        const MFlexTimerServiceCB* aFlexTimerServiceCB );
+
+public:
+    //Data
+    /**
+     * Single linked list link object for timers lists
+     */
+    TSglQueLink iLink;
+
+private:
+    // Data
+    /**
+     * Whether timer should be aborted when system time changes.
+     */
+    TBool iAbortAtSystemTimeChange;
+
+    /**
+     * Left side of the time window when timer can be fired
+     */
+    TTime iAbsoluteMinTime;
+
+    /**
+     * Right side of the time window when timer can be fired
+     */
+    TTime iAbsoluteMaxTime;
+
+    /**
+     * pointer to the session interface that is used to inform timeout
+     */
+    const MFlexTimerServiceCB* iMFlexTimerServiceCB;
+    };
+
+#include "flextimeritem.inl"
+
+#endif  //FLEXTIMERITEM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/flextimeritem.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This file contains inline functions of FlexTimerItem class.
+ *
+ */
+
+// Protection against nested includes
+#ifndef FLEXTIMERITEM_INL
+#define FLEXTIMERITEM_INL
+
+// ---------------------------------------------------------------------------
+// GetMinAbsoluteTime
+// ---------------------------------------------------------------------------
+//
+inline void CFlexTimerItem::GetMinAbsoluteTime( TTime& aMinAbsoluteTime )
+    {
+    aMinAbsoluteTime = iAbsoluteMinTime;
+    }
+// ---------------------------------------------------------------------------
+// GetMaxAbsoluteTime
+// ---------------------------------------------------------------------------
+//
+inline void CFlexTimerItem::GetMaxAbsoluteTime( TTime& aMaxAbsoluteTime )
+    {
+    aMaxAbsoluteTime = iAbsoluteMaxTime;
+    }
+// ---------------------------------------------------------------------------
+// IsAbortedAtSystemTimeChange
+// ---------------------------------------------------------------------------
+//
+inline TBool CFlexTimerItem::IsAbortedAtSystemTimeChange()
+    {
+    return iAbortAtSystemTimeChange;
+    }
+
+#endif  //FLEXTIMERITEM_INL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/flextimerwakeuptimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains definition of CFlexTimerWakeUpTimer.
+ *
+ */
+
+// Protection against nested includes
+#ifndef FLEXTIMERWAKEUPTIMER_H
+#define FLEXTIMERWAKEUPTIMER_H
+
+// System includes
+#include <e32base.h>
+
+// User includes
+// None
+
+// Forward declarations
+class MFlexTimerWakeUpTimerCB;
+
+// Class declaration
+/**
+ *  This class implements timer that is used to
+ *  - Inform timer engine that timeout algorithms should be excecuted
+ *  - Inform timer engine that system time has changed.
+ *
+ */
+class CFlexTimerWakeUpTimer : public CTimer
+    {
+public:
+
+    /**
+     * Contructs new wake up timer
+     * @param aObserver callback class
+     *
+     */
+    static CFlexTimerWakeUpTimer* NewL( MFlexTimerWakeUpTimerCB& aObserver );
+
+    /**
+     * Destructs wake up timer.
+     */
+    virtual ~CFlexTimerWakeUpTimer();
+
+public:
+    /**
+     * Starts timer. No need to cancel already running timer.
+     * @param aInterval time until timer should expire         
+     */
+
+    void StartTimer( TTimeIntervalMicroSeconds& aInterval );
+    
+    /**
+     * Stops timer.   
+     */
+    void StopTimer();
+
+    /**
+     * Inherited from CActive
+     * Handles timer expiration and callbacks.
+     */
+    void RunL();
+
+private:
+    // Functions
+    /**
+     * Private contructor.
+     * @param aObserver Callback class.         
+     */
+    CFlexTimerWakeUpTimer( MFlexTimerWakeUpTimerCB& aObserver );
+    /**
+     * Private 2nd phase contructor.   
+     */
+    void ConstructL();
+
+private:
+    // Data
+    /**
+     * Callback class
+     */
+    MFlexTimerWakeUpTimerCB& iObserver;
+
+    };
+
+#endif  //FLEXTIMERWAKEUPTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/inc/mflextimerwakeuptimercb.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains definition of MFlexTimerWakeUpTimerCB
+ *
+ */
+
+// Protection against nested includes
+#ifndef MFLEXTIMERWAKEUPTIMERCB_H
+#define MFLEXTIMERWAKEUPTIMERCB_H
+
+// Class declaration
+/**
+ *  Callback functions for FlexTimer engine wake up timers. If a client
+ *  wants to receive indicaitions from wake-up timer, it need to inherit
+ *  this interface and implement the callback methods.
+ */
+class MFlexTimerWakeUpTimerCB
+    {
+public:
+
+    /**
+     * This function is used to inform about timer expiry.
+     */
+    virtual void WakeUp() = 0;
+
+    /** Pure virtual functions*/
+    /**
+     * This function is used to inform about system time change.
+     */
+    virtual void SystemTimeChanged() = 0;
+    };
+
+#endif  //MFLEXTIMERWAKEUPTIMERCB_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/rom/flextimerengine.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Flexible timer
+*
+*/
+#ifndef FLEXTIMERENGINE_IBY
+#define FLEXTIMERENGINE_IBY
+
+file=ABI_DIR\BUILD_DIR\flextimerengine.dll           SHARED_LIB_DIR\flextimerengine.dll
+
+#endif // FLEXTIMERENGINE_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/src/flextimercontainer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains implementation of CFlexTimerContainer.
+ *
+ */
+
+// System include files
+#include <hal.h>
+
+// User include files
+#include "flextimercommon.h"
+#include "flextimercontainer.h"
+#include "flextimeritem.h"
+#include "mflextimerservicecb.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimercontainerTraces.h"
+#endif
+
+
+
+// This literal is only used by __ASSERT_DEBUG macro. Therefore, to prevent 
+// unnacessary warnings, it is not compiled into release builds.
+#ifdef _DEBUG
+static const TInt KCBNullPointer = 1;
+_LIT( KCBNullPointerDescriptor, "FlexTimerService CB is NULL." );
+#endif
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CFlexTimerContainer* CFlexTimerContainer::NewL()
+    {
+    CFlexTimerContainer* self = new (ELeave) CFlexTimerContainer();
+    
+    OstTrace1( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_NEWL,
+        "CFlexTimerContainer::NewL;this=%x",
+        ( TUint )self );
+    
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// destructor
+// If the list is not empty when coming here something has already gone wrong.
+// Lets just delete the timers and forget Timeout() calling
+// ---------------------------------------------------------------------------
+//
+CFlexTimerContainer::~CFlexTimerContainer()
+    {
+    CFlexTimerItem* item = NULL;
+    
+    OstTrace1(
+        TRACE_INTERNAL,
+        DUP1_CFLEXTIMERCONTAINER_CFLEXTIMERCONTAINER,
+        "CFlexTimerContainer::~CFlexTimerContainer;this=%x",
+        ( TUint )this );
+
+    while ( !iTimerList.IsEmpty() )
+        {
+        item = iTimerList.First();
+        iTimerList.Remove( *item );
+        delete item;
+        }
+    }
+// ---------------------------------------------------------------------------
+// Make new timer and add it to list. On purpose do not make sanity checks. 
+// Invalid(in the past) timers are found later.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::AddTimerL(
+    const TTimeIntervalMicroSeconds& aWinStartInterval,
+    const TTimeIntervalMicroSeconds& aWinEndInterval,
+    TBool aCancelAtSystemTimeChange,
+    const MFlexTimerServiceCB* aFlexTimerServiceCB )
+    {
+    OstTraceExt5( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_ADDTIMERL,
+        "CFlexTimerContainer::AddTimerL;this=%x;"
+        "aWinStartInterval=%Ld;"
+        "aWinEndInterval=%Ld;"
+        "aCancelAtSystemTimeChange=%u;"
+        "aFlexTimerServiceCB=%x",
+        ( TUint )this,
+        aWinStartInterval.Int64(),
+        aWinEndInterval.Int64(),
+        aCancelAtSystemTimeChange,
+        ( TUint )aFlexTimerServiceCB );
+    
+    __ASSERT_DEBUG( aFlexTimerServiceCB,
+            User::Panic( KCBNullPointerDescriptor, KCBNullPointer ) );
+
+    // Before creating new flextimer timeout item, the interval times are
+    // converted to absolute tick based time used by the engine.
+    TTime winAbsStart( IntervalToAbsoluteTime( aWinStartInterval ) );
+    TTime winAbsEnd( IntervalToAbsoluteTime( aWinEndInterval ) );
+    
+    CFlexTimerItem* newItem = CFlexTimerItem::NewL( winAbsStart,
+        winAbsEnd,
+        aCancelAtSystemTimeChange,
+        aFlexTimerServiceCB );
+
+    iTimerList.AddLast( *newItem );
+    }
+// ---------------------------------------------------------------------------
+// Loop through list and if timer containing same CB that is given as a
+// parameter is found, remove timer. If no timer found just return error code.
+// ---------------------------------------------------------------------------
+//
+TInt CFlexTimerContainer::RemoveTimer(
+    const MFlexTimerServiceCB* aFlexTimerServiceCB )
+    {
+    OstTraceExt2( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_REMOVETIMER,
+        "CFlexTimerContainer::RemoveTimer;this=%x;aFlexTimerServiceCB=%x",
+        ( TUint )this,
+        ( TUint )aFlexTimerServiceCB );
+
+    __ASSERT_DEBUG( aFlexTimerServiceCB,
+        User::Panic( KCBNullPointerDescriptor, KCBNullPointer ) );
+    
+    TSglQueIter<CFlexTimerItem> listIter( iTimerList );
+    CFlexTimerItem* item = NULL;
+
+    listIter.SetToFirst();
+    // Iter++ makes iterator to point to next element if one exists.
+    // Otherwise NULL.
+    while ( (item = listIter++) != NULL )
+        {
+        if ( item->GetCB() == aFlexTimerServiceCB )
+            {
+            iTimerList.Remove( *item );
+            delete item;
+            return KErrNone;
+            }
+        }
+    return KErrNotFound;
+    }
+// ---------------------------------------------------------------------------
+// Loop through timers and find time/timer that must expire next
+// Calculate time left to that moment and return it. 
+// ---------------------------------------------------------------------------
+//
+TBool CFlexTimerContainer::GetNextTimeout(
+    TTimeIntervalMicroSeconds& aNextTimeoutDelay )
+    {
+    TSglQueIter<CFlexTimerItem> listIter( iTimerList );
+    TTime currentAbsoluteTime( 0 );
+    CFlexTimerItem* item = NULL;
+    TTime tempTime( 0 );
+    TTime nextTimeout( 0 );
+
+    GetCurrentTime( currentAbsoluteTime );
+    // Take first item as a reference value.
+    listIter.SetToFirst();
+    item = listIter++;
+    if ( item )
+        {
+        item->GetMaxAbsoluteTime( nextTimeout );
+        }
+
+    // Find the timer that needs to expire next, and set nextTimeout to the
+    // time, when the timer needs to expire.
+    while ( (item = listIter++) != NULL )
+        {
+        item->GetMaxAbsoluteTime( tempTime );
+        if ( tempTime < nextTimeout )
+            {
+            nextTimeout = tempTime;
+            }
+        }
+    // Calculate difference between now -> min timeout time. If in past,
+    // return zero interval
+    aNextTimeoutDelay = nextTimeout.MicroSecondsFrom( currentAbsoluteTime );
+    if ( aNextTimeoutDelay < TTimeIntervalMicroSeconds( 0 ) )
+        {
+        aNextTimeoutDelay = 0;
+        }
+    
+    OstTraceExt2( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_GETNEXTTIMEOUT,
+        "CFlexTimerContainer::GetNextTimeout;this=%x;aNextTimeoutDelay=%Ld",
+        ( TUint )this,
+        aNextTimeoutDelay.Int64() );
+    
+    return !iTimerList.IsEmpty();
+    }
+// ---------------------------------------------------------------------------
+// Excecute selected algorithms and finally fire all timers in candidate list.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::FireTimers( TFlexTimerAlgorithm aAlgorithmToBeUsed )
+    {
+    OstTraceExt2( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_FIRETIMERS,
+        "CFlexTimerContainer::FireTimers;this=%x;aAlgorithmToBeUsed=%x",
+        ( TUint )this,
+        ( TUint )aAlgorithmToBeUsed );
+
+    TSglQue<CFlexTimerItem> candidateList( _FOFF( CFlexTimerItem, iLink ) );
+
+    TTime currentAbsoluteTime( 0 );
+
+    GetCurrentTime( currentAbsoluteTime );
+    
+    // Simple algorithm is always executed
+    SimpleAlgorithm( candidateList, currentAbsoluteTime );
+
+    if ( EFlexTimerAlgorithmLatestPossible == aAlgorithmToBeUsed )
+        {
+        LatestPossibleAlgorithm( candidateList );
+        }
+    ExpireTimers( candidateList );
+    }
+
+//
+// ---------------------------------------------------------------------------
+// Loop through timer list, call abort to timer if it is abortable.
+// Then remove timer from list and delete it.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::AbortTimersDueToTimeChange( TInt aReason )
+    {
+    OstTraceExt2( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_ABORTTIMERSDUETOTIMECHANGE,
+        "CFlexTimerContainer::AbortTimersDueToTimeChange;this=%x;aReason=%d",
+        ( TUint )this,
+        aReason );
+
+    TSglQueIter<CFlexTimerItem> listIter( iTimerList );
+    CFlexTimerItem* item = NULL;
+    listIter.SetToFirst();
+    
+    // Go through all timers and check if the timer has 
+    // AbortAtSystemTimeChange flag set, if so, abort the timer.
+    while ( (item = listIter++) != NULL )
+        {
+        if ( item->IsAbortedAtSystemTimeChange() )
+            {
+            item->GetCB()->Abort( aReason );
+            iTimerList.Remove( *item );
+            delete item;
+            }
+        }
+    }
+// ---------------------------------------------------------------------------
+// Constructor for CFlexTimerContainer
+// ---------------------------------------------------------------------------
+//
+CFlexTimerContainer::CFlexTimerContainer() :
+    iTimerList( _FOFF( CFlexTimerItem, iLink ) ),
+    iLastTicks( 0 ),
+    iCurrentAbsoluteTime( 0 )    
+    {
+    OstTrace1( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_CFLEXTIMERCONTAINER,
+        "CFlexTimerContainer::CFlexTimerContainer;this=%x",
+        ( TUint )this );
+    TInt err;
+    
+    // Get system tick length for converting tics to microseconds.
+    err = HAL::Get( HAL::ESystemTickPeriod, iTickPeriod );
+    
+    __ASSERT_ALWAYS(
+        err == KErrNone,
+        User::Panic(
+            KFlexTimerContainerPanicCat,
+            static_cast <TInt> ( EFlexTimerContainerNoTickPeriod ) ) );
+    }
+// ---------------------------------------------------------------------------
+// Loops through timer list and moves all timers that can be fired to
+// candidate list. Can be fired means that minimum time is reached. Note that
+// if we are late for some reason (very likely if someone has win size zero),
+// candidate list can now contain timers that are late (max time passed).
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::SimpleAlgorithm(
+    TSglQue<CFlexTimerItem>& aCandidateList,
+    TTime& aCurrentTime )
+    {
+    OstTraceExt3( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_SIMPLEALGORITHM,
+        "CFlexTimerContainer::SimpleAlgorithm;"
+        "this=%x;aCandidateList=%x;aCurrentTime=%Ld;",
+        ( TUint )this,
+        ( TUint )&aCandidateList,
+        aCurrentTime.Int64() );
+
+    TSglQueIter<CFlexTimerItem> listIter( iTimerList );
+    CFlexTimerItem* item = NULL;
+    TTime minTime( 0 );
+
+    listIter.SetToFirst();
+    // Iter++ makes iterator to point to next element if one exists.
+    // Otherwise NULL.
+    while ( (item = listIter++) != NULL )
+        {
+        item->GetMinAbsoluteTime( minTime );
+        if ( minTime <= aCurrentTime )
+            {
+            OstTraceExt2( TRACE_INTERNAL,
+                DUP1_CFLEXTIMERCONTAINER_SIMPLEALGORITHM,
+                "CFlexTimerContainer::SimpleAlgorithm - Adding item;"
+                "this=%x;item=%x",
+                ( TUint )this,
+                ( TUint )item );
+            // Remove from candidate list needs to be done before the
+            // item is added to back to iTimerList, because the lists
+            // use the same iLink member.
+            iTimerList.Remove( *item );
+            
+            // This timer can be timeouted, add it to timeout candidate list.
+            // The list is called candidate list, because the content of the
+            // list may be pruned by passing it to other algorithms for furher
+            // prosessing.
+            aCandidateList.AddLast( *item );
+            }
+        }
+    }
+
+//
+// ---------------------------------------------------------------------------
+// Loops through dropped list and candidate list and find timers where:
+// dropped timers right side of the window is earlier than candidate timers
+// right side of the window i.e. Candidate can be fired later with dropped
+// timer, without additional timer firings
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::LatestPossibleAlgorithm(
+    TSglQue<CFlexTimerItem>& aCandidateList )
+    {   
+    TSglQueIter<CFlexTimerItem> listIter( iTimerList );
+    TSglQueIter<CFlexTimerItem> candidateListIter( aCandidateList );
+    CFlexTimerItem* droppedItem = NULL;
+    CFlexTimerItem* candidateItem = NULL;
+    TTime droppedMaxTime( 0 );
+    TTime candidateMaxTime( 0 );
+    
+    OstTraceExt2( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_LATESTPOSSIBLEALGORITHM,
+        "CFlexTimerContainer::LatestPossibleAlgorithm;"
+        "this=%x;aCandidateList=%x",
+        ( TUint )this,
+        ( TUint )&aCandidateList );
+    
+    listIter.SetToFirst();
+    candidateListIter.SetToFirst();
+            
+    droppedItem = listIter++;
+    
+    if ( droppedItem != NULL )
+        {
+        // Initiliaze next dropped timeout time to some value.
+        droppedItem->GetMaxAbsoluteTime( droppedMaxTime );
+
+        // Loop through dropped timers and find the dropped timer that will have
+        // shortest time to its timeout.
+        while ( (droppedItem = listIter++) != NULL )
+            {
+            droppedItem->GetMaxAbsoluteTime( candidateMaxTime );
+            if ( droppedMaxTime > candidateMaxTime )
+                {
+                droppedMaxTime = candidateMaxTime;
+                }
+            }
+
+        // Loop through candidate timers
+        while ( (candidateItem = candidateListIter++) != NULL )
+            {
+            candidateItem->GetMaxAbsoluteTime( candidateMaxTime );
+            // If candidate can be fired together with dropped timer ->
+            // don't fire candidate yet.
+            if ( droppedMaxTime <= candidateMaxTime )
+                {
+                OstTraceExt2( TRACE_INTERNAL,
+                    DUP1_CFLEXTIMERCONTAINER_LATESTPOSSIBLEALGORITHM,
+                    "CFlexTimerContainer::LatestPossibleAlgorithm -"
+                    " Removing item;this=%x;candidateItem=%x",
+                    ( TUint )this,
+                    ( TUint )candidateItem );
+
+                // Remove from candidate list needs to be done before the
+                // item is added to back to iTimerList, because the lists
+                // use the same iLink member.
+                aCandidateList.Remove( *candidateItem );
+                // Add to first so we don't handle this again.
+                iTimerList.AddFirst( *candidateItem );
+                }
+            }
+        }
+    }
+// ---------------------------------------------------------------------------
+// Loops through candidate list and calls timeout to all timers.
+// Then removes timer from list and deletes it. 
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::ExpireTimers(
+    TSglQue<CFlexTimerItem>& aCandidateList )
+    {
+    OstTraceExt2( TRACE_INTERNAL,
+        CFLEXTIMERCONTAINER_EXPIRETIMERS,
+        "CFlexTimerContainer::ExpireTimers;this=%x;candidateList=%x",
+        ( TUint )this,
+        ( TUint )&aCandidateList );
+
+    TSglQueIter<CFlexTimerItem> candidateListIter( aCandidateList );
+    CFlexTimerItem* item = NULL;
+
+    candidateListIter.SetToFirst();
+    // Iter++ makes iterator to point to next element if one exists.
+    // Otherwise NULL.
+    while ( (item = candidateListIter++) != NULL )
+        {
+        item->GetCB()->Timeout();
+        aCandidateList.Remove( *item );
+        delete item;
+        }
+    }
+// ---------------------------------------------------------------------------
+// Get current time return current time in FlexTimer engine time base. This
+// time base is begins from the first call to GetCurrentTime and it is base on
+// system ticks.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerContainer::GetCurrentTime( TTime& aAbsoluteTime )
+    {
+    TUint32 currentTicks = User::TickCount();
+
+    // Accumulate current absolute time with the time passed since last
+    // update. Both currentTicks and iLastTicks are unsigned int types, thus
+    // "currentTicks - iLastTicks" will handle also the case currentTicks
+    // overflows.
+    iCurrentAbsoluteTime += TicksToAbsoluteTime( currentTicks
+            - iLastTicks );
+        
+    iLastTicks = currentTicks;
+    
+    // N.B. Even though the time is is returned as TTime, this time has own
+    // time base. (See function description)
+    aAbsoluteTime = iCurrentAbsoluteTime;
+    }
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/src/flextimerengine.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains implementation of CFlexTimerEngine.
+ *
+ */
+
+// System include files
+// None
+
+// User include files
+#include "flextimerengine.h"
+#include "flextimercontainer.h"
+#include "flextimerwakeuptimer.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimerengineTraces.h"
+#endif
+
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CFlexTimerEngine* CFlexTimerEngine::NewL()
+    {
+    CFlexTimerEngine* self = new (ELeave) CFlexTimerEngine();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CFlexTimerEngine::~CFlexTimerEngine()
+    {
+    OstTrace0( TRACE_INTERNAL,
+        CFLEXTIMERENGINE_CFLEXTIMERENGINE,
+        "CFlexTimerEngine::~CFlexTimerEngine" );
+
+    delete iFlexTimerContainer;
+    delete iWakeUpTimer;
+    }
+// ---------------------------------------------------------------------------
+// Add new timer and trap leave. Return Leave code to session.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CFlexTimerEngine::AddTimer(
+    const TTimeIntervalMicroSeconds& aWinStartInterval,
+    const TTimeIntervalMicroSeconds& aWinEndInterval,
+    TBool aCancelAtSystemTimeChange,
+    const MFlexTimerServiceCB* aFlexTimerServiceCB )
+    {
+    TRAPD( err,
+        iFlexTimerContainer->AddTimerL( aWinStartInterval,
+            aWinEndInterval,
+            aCancelAtSystemTimeChange,
+            aFlexTimerServiceCB ) );
+
+    if ( KErrNone == err )
+        {
+        StartTimer();
+        }
+    return err;
+    }
+// ---------------------------------------------------------------------------
+// Remove timer from container queue and start new wakeup watch timer
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CFlexTimerEngine::CancelTimer(
+    const MFlexTimerServiceCB* aFlexTimerServiceCB )
+    {
+    TInt error = iFlexTimerContainer->RemoveTimer( aFlexTimerServiceCB );
+    StartTimer();
+    
+    return error;
+    }
+
+// ---------------------------------------------------------------------------
+// Wakeup timer expired, Fire timers according to some algorithm set and
+// restart wakeup timer.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerEngine::WakeUp()
+    {
+    OstTrace0( TRACE_INTERNAL,
+        CFLEXTIMERENGINE_WAKEUP,
+        "CFlexTimerEngine::WakeUp" );
+    
+    iFlexTimerContainer->FireTimers(
+        CFlexTimerContainer::EFlexTimerAlgorithmLatestPossible );
+
+    StartTimer();
+    }
+// ---------------------------------------------------------------------------
+// System time is changed. Abort all timers that need to be aborted and
+// restart wakeup timer.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerEngine::SystemTimeChanged()
+    {
+    OstTrace0( TRACE_INTERNAL,
+        CFLEXTIMERENGINE_SYSTEMTIMECHANGED,
+        "CFlexTimerEngine::SystemTimeChanged" );
+    
+    iFlexTimerContainer->AbortTimersDueToTimeChange( KErrAbort );
+    StartTimer();
+    }
+// ---------------------------------------------------------------------------
+// Private constructor
+// ---------------------------------------------------------------------------
+//
+CFlexTimerEngine::CFlexTimerEngine() : iFlexTimerContainer( NULL ),
+    iWakeUpTimer( NULL )
+    {
+    OstTrace0( TRACE_INTERNAL,
+        DUP_CFLEXTIMERENGINE_CFLEXTIMERENGINE,
+        "CFlexTimerEngine::CFlexTimerEngine" );
+    //Nothing to do here
+    }
+// ---------------------------------------------------------------------------
+// Private 2nd phase construction
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerEngine::ConstructL()
+    {
+    iFlexTimerContainer = CFlexTimerContainer::NewL();
+    iWakeUpTimer = CFlexTimerWakeUpTimer::NewL( *this );
+    }
+// ---------------------------------------------------------------------------
+// Stop timer just in case it is already running (e.g. after AddTimer())
+// and Start new wakeup timer according to current situation in container
+// queues If timeout window has passed fire timers right now.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerEngine::StartTimer()
+    {
+    TTimeIntervalMicroSeconds nextTimeout;
+
+    // Stop the timer, because, if there are no more pending timeouts, the
+    // wake-up timer needs to be stopped. If timeouts are found, the timer is
+    // is restarted below.
+    iWakeUpTimer->StopTimer();
+
+    if ( iFlexTimerContainer->GetNextTimeout( nextTimeout ) )
+        {
+        // If timeout is in the future, timer is started to wake up at that
+        // moment.
+        if ( nextTimeout > TTimeIntervalMicroSeconds( 0 ) )
+            {
+            iWakeUpTimer->StartTimer( nextTimeout );
+            }
+        // If timer is due now or in the past, Lets fire those right now.
+        else
+            {
+            WakeUp();
+            }
+        }
+    // Else no timers, so no need for timeouts. Server is propably about to be
+    // deleted.
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/src/flextimeritem.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains implementation of CFlexTimerItem.
+ *
+ */
+
+// System include files
+// None
+
+// User include files go here:
+#include "flextimeritem.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimeritemTraces.h"
+#endif
+
+// ---------------------------------------------------------------------------
+// constructor
+// ---------------------------------------------------------------------------
+//
+CFlexTimerItem::CFlexTimerItem( const TTime& aAbsoluteMinTime,
+    const TTime& aAbsoluteMaxTime,
+    TBool aCancelAtSystemTimeChange,
+    const MFlexTimerServiceCB* aFlexTimerServiceCB ) :
+        iAbortAtSystemTimeChange( aCancelAtSystemTimeChange ),
+        iAbsoluteMinTime( aAbsoluteMinTime ),
+        iAbsoluteMaxTime( aAbsoluteMaxTime ),
+        iMFlexTimerServiceCB( aFlexTimerServiceCB )
+    {
+    OstTraceExt5( TRACE_INTERNAL,
+        CFLEXTIMERITEM_CFLEXTIMERITEM,
+        "CFlexTimerItem::CFlexTimerItem;this=%x;aAbsoluteMinTime=%Ld;"
+        "aAbsoluteMaxTime=%Ld;aCancelAtSystemTimeChange=%d;"
+        "aFlexTimerServiceCB=%x",
+        ( TUint )this,
+        aAbsoluteMinTime.Int64(),
+        aAbsoluteMaxTime.Int64(),
+        aCancelAtSystemTimeChange,
+        ( TUint )aFlexTimerServiceCB );
+
+    // Nothing to do - Coverity warning of uninitialize iLink.Next suppressed,
+    // because this should be initialized by TSglQueLink constructor.
+    // coverity[uninit_member]
+    }
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CFlexTimerItem* CFlexTimerItem::NewL( const TTime& aAbsoluteMinTime,
+    const TTime& aAbsoluteMaxTime,
+    TBool aCancelAtSystemTimeChange,
+    const MFlexTimerServiceCB* aFlexTimerServiceCB )
+    {
+    CFlexTimerItem* self = new (ELeave) CFlexTimerItem( aAbsoluteMinTime,
+        aAbsoluteMaxTime,
+        aCancelAtSystemTimeChange,
+        aFlexTimerServiceCB );
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// destructor, nothing to destruct
+// ---------------------------------------------------------------------------
+//
+CFlexTimerItem::~CFlexTimerItem()
+    {
+        OstTraceExt2( TRACE_INTERNAL,
+            DUP1_CFLEXTIMERITEM_CFLEXTIMERITEM,
+            "CFlexTimerItem::~CFlexTimerItem;this=%x;iMFlexTimerServiceCB=%x",
+            ( TUint )this,
+            ( TUint )iMFlexTimerServiceCB );
+    //Nothing to do here
+    }
+// ---------------------------------------------------------------------------
+// GetCB
+// ---------------------------------------------------------------------------
+//
+const MFlexTimerServiceCB* CFlexTimerItem::GetCB()
+    {
+    return iMFlexTimerServiceCB;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/src/flextimerwakeuptimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This class contains implementation of CFlexTimerWakeUpTimer.
+ *
+ */
+
+// System include files
+// None
+
+// User include files go here:
+#include "flextimerwakeuptimer.h"
+#include "mflextimerwakeuptimercb.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimerwakeuptimerTraces.h"
+#endif
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CFlexTimerWakeUpTimer* CFlexTimerWakeUpTimer::NewL(
+    MFlexTimerWakeUpTimerCB& aObserver )
+    {
+    CFlexTimerWakeUpTimer* self = new (ELeave) CFlexTimerWakeUpTimer(
+        aObserver );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+// ---------------------------------------------------------------------------
+// destructor, Cancel timer just in case it is still running.
+// ---------------------------------------------------------------------------
+//
+CFlexTimerWakeUpTimer::~CFlexTimerWakeUpTimer()
+    {
+    // Super class CTimer destructor Cancels any pending requests.
+    OstTrace0( TRACE_INTERNAL,
+        DUP1_CFLEXTIMERWAKEUPTIMER_CFLEXTIMERWAKEUPTIMER,
+        "CFlexTimerWakeUpTimer::~CFlexTimerWakeUpTimer" );
+    }
+// ---------------------------------------------------------------------------
+// Start timer so that it will expire aInterval after this moment.
+// UTC is used to get indications about system time change.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerWakeUpTimer::StartTimer( TTimeIntervalMicroSeconds& aInterval )
+    {
+    CTimer::Cancel();
+    TTime utcNow( 0 );
+
+    utcNow.UniversalTime();
+    utcNow = utcNow + aInterval;
+    
+    OstTraceExt1( TRACE_INTERNAL,
+        CFLEXTIMERWAKEUPTIMER_STARTTIMER,
+        "CFlexTimerWakeUpTimer::StartTimer;aInterval=%Ld",
+        aInterval.Int64() );
+
+    AtUTC( utcNow );
+    }
+// ---------------------------------------------------------------------------
+// just call Cancel. If timer is alreay running it will be stopped.
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerWakeUpTimer::StopTimer()
+    {
+    OstTrace0( TRACE_INTERNAL,
+        CFLEXTIMERWAKEUPTIMER_STOPTIMER,
+        "CFlexTimerWakeUpTimer::StopTimer" );
+
+    Cancel();
+    }
+// ---------------------------------------------------------------------------
+// KErrAbort comes if system time has changed. It is up to client to restart
+// timer
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerWakeUpTimer::RunL()
+    {
+    if ( KErrAbort == iStatus.Int() )
+        {
+        iObserver.SystemTimeChanged();
+        }
+    else
+        {
+        iObserver.WakeUp();
+        }
+    }
+// ---------------------------------------------------------------------------
+// Private constructor
+// ---------------------------------------------------------------------------
+//
+CFlexTimerWakeUpTimer::CFlexTimerWakeUpTimer(
+    MFlexTimerWakeUpTimerCB& aObserver ) :
+        CTimer( EPriorityStandard ), iObserver( aObserver )
+    {
+    OstTrace0( TRACE_INTERNAL,
+        CFLEXTIMERWAKEUPTIMER_CFLEXTIMERWAKEUPTIMER,
+        "CFlexTimerWakeUpTimer::CFlexTimerWakeUpTimer" );
+
+    //Nothing to do here
+    }
+// ---------------------------------------------------------------------------
+// Private 2nd phase construction
+// ---------------------------------------------------------------------------
+//
+void CFlexTimerWakeUpTimer::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    CTimer::ConstructL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* OST trace definition header.
+*/
+
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+#include <opensystemtrace.h>
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/engine/traces/fixed_id.definitions	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,25 @@
+#Fixed group and trace id definitions. If this file is removed, the identifiers are rebuilt.
+[GROUP]TRACE_INTERNAL=0x40
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_ABORTTIMERSDUETOTIMECHANGE=0x7
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_ADDTIMERL=0x3
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_CFLEXTIMERCONTAINER=0x8
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_EXPIRETIMERS=0xd
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_FIRETIMERS=0x6
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_GETNEXTTIMEOUT=0x5
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_LATESTPOSSIBLEALGORITHM=0xb
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_NEWL=0x1
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_REMOVETIMER=0x4
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERCONTAINER_SIMPLEALGORITHM=0x9
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERENGINE_CFLEXTIMERENGINE=0xe
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERENGINE_SYSTEMTIMECHANGED=0x10
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERENGINE_WAKEUP=0xf
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERITEM_CFLEXTIMERITEM=0x12
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERWAKEUPTIMER_CFLEXTIMERWAKEUPTIMER=0x17
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERWAKEUPTIMER_STARTTIMER=0x15
+[TRACE]TRACE_INTERNAL[0x40]_CFLEXTIMERWAKEUPTIMER_STOPTIMER=0x16
+[TRACE]TRACE_INTERNAL[0x40]_DUP1_CFLEXTIMERCONTAINER_CFLEXTIMERCONTAINER=0x2
+[TRACE]TRACE_INTERNAL[0x40]_DUP1_CFLEXTIMERCONTAINER_LATESTPOSSIBLEALGORITHM=0xc
+[TRACE]TRACE_INTERNAL[0x40]_DUP1_CFLEXTIMERCONTAINER_SIMPLEALGORITHM=0xa
+[TRACE]TRACE_INTERNAL[0x40]_DUP1_CFLEXTIMERITEM_CFLEXTIMERITEM=0x13
+[TRACE]TRACE_INTERNAL[0x40]_DUP1_CFLEXTIMERWAKEUPTIMER_CFLEXTIMERWAKEUPTIMER=0x14
+[TRACE]TRACE_INTERNAL[0x40]_DUP_CFLEXTIMERENGINE_CFLEXTIMERENGINE=0x11
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for Flexible timer server
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+// IBY-file
+../rom/flextimerserver.iby CORE_MW_LAYER_IBY_EXPORT_PATH(flextimerserver.iby)
+
+PRJ_MMPFILES
+#include "../engine/group/bld.inf"
+flextimerserver.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/group/flextimerserver.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Flexible timer
+*               server
+*/
+
+/*
+* %version: 1 %
+*/
+
+#include <platform_paths.hrh>
+
+TARGET              flextimerserver.exe
+TARGETTYPE          EXE
+UID                 0x1000008D 0x2002C383
+
+VENDORID            VID_DEFAULT
+CAPABILITY          CAP_SERVER
+
+USERINCLUDE         ../inc
+USERINCLUDE         ../traces
+USERINCLUDE         ../engine/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY             euser.lib
+// For system tick period
+LIBRARY             hal.lib
+LIBRARY             flextimerengine.lib
+
+SOURCEPATH          ../src
+SOURCE flextimerserver.cpp
+SOURCE flextimersession.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/flextimercommon.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: 
+ * Common header for flextimer client interface and server.
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef FLEXTIMERCOMMON_H
+#define FLEXTIMERCOMMON_H
+
+// System includes
+#include <e32base.h>
+
+#include "flextimerpanic.h"
+
+// Constants
+/**
+ * FlexTimerServer executable name used by clients when starting server
+ */
+_LIT( KFlexTimerServerExe, "FlexTimerServer.exe" );
+
+/**
+ * Identification name for the FlexTimerServer -server
+ */
+_LIT( KFlexTimerServerName,"FlexTimerServer" );
+
+/**
+ * Number of message slots reserved for each client session.
+ * There can be at most one outstanding asynchronous request at a time
+ * (pending timeout message). Second slot is needed for synchronous
+ * communication during that (e.g. for cancellation message).
+ */
+const TUint KFlexTimerServerMessageSlots = 2;
+
+/**
+ *  Version identifier. Client-server message interface compatibility
+ *  is maintained within a major version.
+ */
+const TUint KFlexTimerServMajorVersionNumber = 1;
+const TUint KFlexTimerServMinorVersionNumber = 0;
+const TUint KFlexTimerServBuildVersionNumber = 0;
+
+/**
+ * Default timeout window size. This is used, if client has not set the
+ * used timeout window. Default window is a fraction of an interval
+ * between current time and the expiration time.
+ * 
+ * @code
+ *   interval = endTime - currentTime;
+ *   defaultWindow = interval * KDefaultWindowMultiplier;
+ *   startTime = endTime - defaultWindow;
+ * @endcode
+ */
+const TReal64 KDefaultWindowMultiplier = 0.2;
+
+/**
+ *  Maximun lenght of FlexTimer  63072000000000 == 2a in microseconds.
+ */
+const TInt64 KFlexTimerMaxTimerLength = 63072000000000;
+
+// Data types
+/**
+ * Client-server interface message types (functions)
+ */
+enum TFlexTimerServRqst
+    {
+    EFlexTimerServCancelRequest = 1,
+    EFlexTimerServAtRequest,
+    EFlexTimerServAtUTCRequest,
+    EFlexTimerServAfterRequest,
+    EFlexTimerServAfterTicksRequest,
+    EFlexTimerServConfigureRequest
+    };
+
+/**
+ * Configuration message (EFlexTimerServConfigureRequest) type.
+ * This is stored as a first parameter in configuration request message,
+ * rest of the parameters and their types depend on this.
+ */
+enum TFlexTimerConfigureRequestType
+    {
+    EConfigureRequestWindowSize = 1
+    };
+
+#endif /* FLEXTIMERCOMMON_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/flextimerpanic.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: 
+ * Common header for flextimer panic codes.
+ *
+ */
+/*
+ * %version: 1 %
+ */
+#ifndef FLEXTIMERPANIC_H
+#define FLEXTIMERPANIC_H
+// System includes
+#include <e32base.h>
+
+
+/**
+ * Server and session panic category and codes
+ */
+// Panic category
+_LIT( KRFlexTimerPanicCat, "RFlexTimer");
+_LIT( KCFlexTimerPanicCat, "CFlexTimer");
+_LIT( KCFlexPeriodicPanicCat, "CFlexPeriodic");
+_LIT( KFlexTimerServerPanicCat, "FlexTimerServer" );
+_LIT( KFlexTimerSessionPanicCat, "FlexTimerSession" );
+_LIT( KFlexTimerContainerPanicCat, "FlexTimerContainer" );
+
+enum TFlexTimerPanic
+    {
+    /**
+     * Timer After-function has been provided with a negative interval value. 
+     * @see RFlexTimer
+     */
+    EFlexTimerAfterIntervalLessThanZero = 1,
+
+    /**
+     * Timer AfterTicks-function has been provided with a negative interval
+     * value. 
+     * @see RFlexTimer
+     */
+    EFlexTimerAfterTicksIntervalLessThanZero = 2,
+
+    /**
+     * Timer At-function has been provided with an expiry time prior to
+     * TTime::HomeTime. 
+     * @see RFlexTimer
+     * @see TTime
+     */
+    EFlexTimerAtIntervalLessThanZero = 3,
+
+    /**
+     * Timer AtUTC-function has been provided with an expiry time prior to
+     * TTime::UniversalTime. 
+     * @see RFlexTimer
+     * @see TTime
+     */
+    EFlexTimerAtUTCIntervalLessThanZero = 4,
+
+    /**
+     * Timer has been configured with flexible window size less than zero. 
+     * @see RFlexTimer
+     */
+    EFlexTimerWindowLessThanZero = 5,
+
+    /**
+     * Periodic timer Start-function has been called with delay value less
+     * than zero. 
+     * @see CFlexPeriodic
+     */
+    EFlexPeriodicDelayLessThanZero = 6,
+
+    /**
+     * Periodic timer Start-function has been called with interval value less
+     * than one microsecond.
+     * @see CFlexPeriodic
+     */
+    EFlexPeriodicIntervalTooSmall = 7,
+
+    /**
+     * Periodic has been configured with delay window size less than zero. 
+     * @see CFlexPeriodic
+     */
+    EFlexPeriodicDelayWindowLessThanZero = 8,
+
+    /**
+     * Periodic has been configured with interval window size less than zero. 
+     * @see CFlexPeriodic
+     */
+    EFlexPeriodicIntervalWindowLessThanZero = 9,
+
+    /**
+     * This panic is raised by the At(), After() and Lock() member functions
+     * of the CFlexTimer active object.
+     * 
+     * It is caused by an attempt to request a timer event when the CFlexTimer
+     * active object has not been added to the active scheduler.
+     * @see CFlexTimer
+     */
+    EFlexTimerNotAddedToActiveScheduler = 10,
+                
+    /**
+     * New timer has been issued while previous operation is still pending
+     * @see RFlexTimer
+     */
+    EFlexTimerServerErrorPendingTimer = 15,
+
+    /**
+     * Cleanup stack memory creation failed for FlexTimer server process
+     */
+    EFlexTimerServerCleanupStack = 20,
+
+    /**
+     * Memory allocation for active scheduler object filed in server creation
+     */
+    EFlexTimerServerActiveScheduler = 21,
+
+    /**
+     * Starting CServer2 based FlexTimer server failed
+     */
+    EFlexTimerServerStartServer = 23,
+    
+    /**
+     * User has issued a timer request with parameters that can not be
+     * fulfilled
+     */
+    EFlexTimerServerIllegalTimerValue = 24,
+
+    /**
+     * FlexTimer session failed to read tick period from HAL. This means that
+     * we are not able to map our tick time to system time.
+     */
+    EFlexTimerContainerNoTickPeriod = 30,
+
+    /**
+     * In CFlexPeriodic::Start() has been passed a NULL function pointer in
+     * TCallBack aCallBack parameter.
+     */
+    EFlexPeriodicCallbackFunctionIsNull = 31,
+    
+    /**
+     * In CFlexPeriodic::Start() has been passed a NULL function pointer in
+     * TCallBack aCallBackError parameter and error has occurred.
+     */
+    EFlexPeriodicErrorCallbackFunctionIsNull = 32,
+    
+    /**
+     * RFlexTimer::Connect() has been called twice without closing the handle
+     * first.
+     */
+    EFlexTimerAlreadyConnected = 33
+    };
+
+#endif /* FLEXTIMERPANIC_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/flextimerserver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Class definition for Flexible timer server. Server creates session
+ * objects and manages message passing to those.
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef FLEXTIMERSERVER_H
+#define FLEXTIMERSERVER_H
+
+// System includes
+#include <e32base.h>
+
+// Forward declarations
+class CFlexTimerEngine;
+
+// Class declaration
+/**
+ *  Flexible timer server class implements the server for FlexTimers. This
+ *  class provides services for creating new sessions, and for passing
+ *  a client message to dedicated session.
+ */
+class CFlexTimerServer : public CServer2
+    {
+    
+public:
+    /**
+     * Two phased constructor 
+     * 
+     * @param aPriority Active object priority for the server 
+     * @return Pointer to created server object
+     */
+    IMPORT_C static CFlexTimerServer* NewL( CActive::TPriority aPriority );
+
+    /**
+     * Destructor 
+     */
+    virtual ~CFlexTimerServer();
+
+public:
+
+    /**
+     * From: CServer2
+     * Function for creating a new session to this server. 
+     *
+     * @param aVersion Version identifier from client
+     * @param aMessage Reference to creation message sent by client
+     * @return Pointer to created session object
+     */
+    CSession2* NewSessionL( const TVersion& aVersion,
+                            const RMessage2& aMessage ) const;
+
+    /**
+     * Function for creating server thread resources. Creates the server
+     * object and active scheduler. Loops in the active scheduler to serve
+     * client requests until explicitly shutdown. Function leaves if the
+     * creation of needed resources fails.
+     */
+    static void StartServerL();
+
+private:
+
+    /**
+     * Constructor
+     * 
+     * @param aPriority Active object priority 
+     */
+    CFlexTimerServer( CActive::TPriority aPriority );
+
+    /**
+     * 2nd phase constructor, creates CFlexTimerEngine
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Pointer to FlexTimerEngine created during server start-up
+     */
+    CFlexTimerEngine* iTimerEngine;
+
+    };
+
+#endif /* FLEXTIMERSERVER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/flextimersession.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Class definition for Flexible timer server side sessions. Session
+ * instances handle the commmunication with clients and implement a 
+ * callback interface for the CFlexTimerEngine to fire timers
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef FLEXTIMERSESSION_H
+#define FLEXTIMERSESSION_H
+
+// System includes
+#include <e32base.h>
+
+// User includes
+#include "mflextimerservicecb.h"
+
+// Forward declarations
+class MFlexTimerService;
+
+// Class declaration
+/**
+ *  Flexible timer server side session
+ *  CFlexTimerSession implements sessions in CFlexTimerServer. A sessions
+ *  parses client messages and adds/cancels timers to CFlexTimerEngine. The
+ *  expiration of the timer completes client side message.
+ */
+class CFlexTimerSession : public CSession2, public MFlexTimerServiceCB
+    {
+
+public:
+
+    /**
+     * Constructor
+     * 
+     * @param aFlexTimerService A pointer to engine interface providing
+     *                          timeout service
+     */
+    CFlexTimerSession( MFlexTimerService* aFlexTimerService );
+
+    /**
+     * Destructor
+     */
+    virtual ~CFlexTimerSession();
+
+    /**
+     * From: CSession2
+     * Message handler servicing client requests. Interprets message type and
+     * passes it to correct function for processing.
+     * 
+     * @param aMessage Message from client
+     */
+    void ServiceL( const RMessage2& aMessage );
+
+    /**
+     * From CSession2
+     * Called by a server when it receives a disconnect message for the 
+     * session.
+     * 
+     * @param aMessage The disconnect message
+     */
+    void Disconnect( const RMessage2 &aMessage );
+    
+    /**
+     * From: MFlexTimerServiceCB
+     * Timeout callback function called by timeout engine when a timer
+     * associated to this session expires.
+     * 
+     * @see MFlexTimerServiceCB
+     */
+    virtual void Timeout() const;
+
+    /**
+     * From: MFlexTimerServiceCB
+     * Callback function called by CFlexTimerEngine, when a timer associated
+     * to this session is aborted. Most probable cause for this is At()-timer
+     * aborting due to the system time change
+     * 
+     * @param aReason Error code to be passed for client (KErrAbort in case 
+     *                of system time change)
+     *                
+     * @see MFlexTimerServiceCB
+     */
+    virtual void Abort( TInt aReason ) const;
+
+private:
+
+    /**
+     * Handles client messages that are issued using At()-function in
+     * RFlexTimer
+     * 
+     * @param aMessage Message from client
+     *
+     * @see RFlexTimer
+     */
+    void NewAtTimer( const RMessage2& aMessage );
+
+    /**
+     * Handles client messages that are issued using AtUTC()-function in
+     * RFlexTimer
+     * 
+     * @param aMessage Message from client
+     *
+     * @see RFlexTimer
+     */
+    void NewAtUtcTimer( const RMessage2& aMessage );
+
+    /**
+     * Handles client messages that a issued using After()-function in
+     * RFlexTimer
+     * 
+     * @param aMessage Message from client
+     * 
+     * @see RFlexTimer
+     */
+    void NewAfterTimer( const RMessage2& aMessage );
+
+    /**
+     * Handles client messages that a issued using AfterTicks()-function in
+     * RFlexTimer
+     * 
+     * @param aMessage Message from client
+     * 
+     * @see RFlexTimer
+     */
+    void NewAfterTicksTimer( const RMessage2& aMessage );
+
+    /**
+     * Handles timer cancellation initiated by client via RFlexTimer::Cancel
+     * 
+     * @param aMessage Message from client
+     * 
+     * @see RFlexTimer
+     */
+    void CancelTimer( const RMessage2& aMessage );
+
+    /**
+     * Configuration message handler, stores configuration parameters for
+     * this session
+     * 
+     * @param aMessage Message from client
+     * 
+     * @see RFlexTimer
+     */
+    void ConfigureParameters( const RMessage2& aMessage );
+
+    /**
+     * Inline function for calculating the period from current time to
+     * the timestamp given in message parameters. This is used for
+     * converting the timestamp given in At()- and AtUtc() -functions
+     * to an interval given to DoAddTimer function.
+     * 
+     * @param aRefTime  Reference time used as a basis for interval
+     *                  calculation (interval = timestamp - aRefTime)
+     * @param aMessage  Message containing timestamp in Int0 and Int1
+     *                  parameters (Int0 contains LSW)
+     * @param aInterval On return, contains the interval in microseconds
+     */
+    inline void GetIntervalToMsgTime( const RMessage2& aMessage,
+                                      TTime& aRefTime,
+                                      TTimeIntervalMicroSeconds& aInterval );
+    
+    /**
+     * Function for adding timer with desired window to engine, called in
+     * AtXxx() and AfterXxx() -functions
+     * 
+     * @param aMessage      Message from client. Stored if adding a timer is
+     *                      successful, completed if adding fails
+     * @param aInterval     Microseconds until to requested end time
+     * @param aRequestAbort ETrue if timer should be cancelled on system
+     *                      time change, EFalse otherwise
+     */
+    void DoAddTimer( const RMessage2& aMessage,
+                     TTimeIntervalMicroSeconds& aInterval,
+                     TBool aRequestAbort );
+
+private:
+
+    /**
+     * Pointer to engine interface through which new timers can be added
+     * and cancelled.
+     */
+    MFlexTimerService* iService;
+
+    /**
+     * Timeout window size in microseconds (64-bit). Timeout window is
+     * calculated backwards from the absolute timestamp given in AtXxx()
+     * and AfterXxx() -functions
+     */
+    TTimeIntervalMicroSeconds iTimerWinSize;
+
+    /**
+     * ETrue if client has not set timeout window, EFalse otherwise
+     */
+    TBool iUseDefaultWin;
+
+    /**
+     * Handle to pending timeout message
+     */
+    RMessagePtr2 iPendingTimeoutMsg;
+    };
+
+#include "flextimersession.inl"
+
+#endif /* FLEXTIMERSESSION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/flextimersession.inl	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - Initial contribution
+ *
+ * Description:
+ * This file contains inline functions of FlexTimerSession class.
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef FLEXTIMERSESSION_INL
+#define FLEXTIMERSESSION_INL
+
+// --------------------------------------------------------------------------
+// Function for calculating interval from current time to timestamp
+// --------------------------------------------------------------------------
+//
+inline void CFlexTimerSession::GetIntervalToMsgTime(
+        const RMessage2& aMessage,
+        TTime& aRefTime,
+        TTimeIntervalMicroSeconds& aInterval )
+    {
+    // Construct requested timestamp from the message
+    TInt timeLo( aMessage.Int0() );
+    TInt timeHi( aMessage.Int1() );
+    TInt64 timeStamp = MAKE_TINT64( timeHi, timeLo );
+    TTime reqTime( timeStamp );
+
+    // Calculate the difference between current time and requested time
+    // Reference time used by pure At()-timer is HomeTime
+    aInterval = reqTime.MicroSecondsFrom( aRefTime );
+    }
+
+#endif  /* FLEXTIMERSESSION_INL */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/mflextimerservice.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This class contains definition of MFlexTimerService
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef MFLEXTIMERSERVICE_H
+#define MFLEXTIMERSERVICE_H
+
+//Forward declarations
+class TTime;
+class MFlexTimerServiceCB;
+
+// Class declaration
+/**
+ *  Interface to flexible timer engine. This interface is used by client
+ *  sessions to start and cancel timers.
+ */
+class MFlexTimerService
+    {
+public:
+
+    /** Pure virtual functions*/
+    /**
+     * Function for adding a new timer with specified parameters. 
+     * After timer expires aFlexTimerServiceCB is used to inform a client
+     * session about that. Both parameter times should be in the future
+     * and min should be earlier than max
+     * 
+     * @param aWinStartInterval Time interval from present to left side of the
+     *  window
+     * @param aWinEndInterval Time interval from present to right side of the
+     *  window
+     * @param aCancelAtSystemTimeChange Whether timer should be aborted if
+     *  system time changes.
+     * @param aFlexTimerServiceCB Callback interface for timer
+     *  expiration (also used as an ID)
+     * 
+     * @return KErrNone or some other system wide error code.
+     *
+     */
+    virtual TInt AddTimer(
+            const TTimeIntervalMicroSeconds& aWinStartInterval,
+            const TTimeIntervalMicroSeconds& aWinEndInterval,
+            TBool aCancelAtSystemTimeChange,
+            const MFlexTimerServiceCB* aFlexTimerServiceCB ) = 0;
+
+    /**
+     * Function for cancellin a running timer. After this function returns,
+     * all references to corresponding timer are deleted and they can not be
+     * referred again.
+     * 
+     * @param aFlexTimerServiceCB ID used when timer was added
+     * @return KErrNone or some other system wide error code.
+     */
+    virtual TInt CancelTimer(
+            const MFlexTimerServiceCB* aFlexTimerServiceCB ) = 0;
+
+    };
+
+#endif  /* MFLEXTIMERSERVICE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/inc/mflextimerservicecb.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This class contains definition of MFlexTimerServiceCB
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef MFLEXTIMERSERVICECB_H
+#define MFLEXTIMERSERVICECB_H
+
+// Class declaration
+/**
+ *  Callback interface for Flexible timer engine to inform a session
+ *  about timeouts and aborts.
+ */
+class MFlexTimerServiceCB
+    {
+public:
+
+    /** Pure virtual functions*/
+    /**
+     * Function used for inform that a timeout has happened and client
+     * should be informed about it. After this function is called, there will
+     * no longer be indications related to this timer. After this function
+     * returns, the timer object will be deleted.
+     * 
+     */
+    virtual void Timeout() const = 0;
+
+    /**
+     * Function for informing client session that something has happended and
+     * timer should be aborted. After this function is called, there will
+     * no longer be indications related to this timer. After this function
+     * returns, the timer object will be deleted.
+     * 
+     * @param aReason Error code specifying why timer is aborted.
+     * 
+     * @see RFlexTimer
+     *
+     */
+    virtual void Abort( TInt aReason ) const = 0;
+
+    };
+
+#endif  /* MFLEXTIMERSERVICECB_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/rom/flextimerserver.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Flexible timer server
+*
+*/
+#ifndef FLEXTIMERSERVER_IBY
+#define FLEXTIMERSERVER_IBY
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\flextimerserver.exe PROGRAMS_DIR\flextimerserver.exe
+
+#endif // FLEXTIMERSERVER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/src/flextimerserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of CFlexTimerServer class.
+ *
+ */
+/*
+ * %version: 2 %
+ */
+
+// System include files
+#include <e32cmn.h>
+#include <e32std.h>
+// User include files go here:
+#include "flextimercommon.h"
+#include "flextimerserver.h"
+#include "flextimersession.h"
+#include "flextimerengine.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimerserverTraces.h"
+#endif
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// Two phased construction, 1st phase
+// --------------------------------------------------------------------------
+//
+EXPORT_C CFlexTimerServer* CFlexTimerServer::NewL(
+        CActive::TPriority aPriority )
+    {
+    CFlexTimerServer* self = new ( ELeave ) CFlexTimerServer( aPriority );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// Destructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServer::~CFlexTimerServer()
+    {
+    // Free allocated resources, CServer2 shutdowns sessions
+    delete iTimerEngine;
+
+    OstTrace0( TRACE_INTERNAL,
+            CFLEXTIMERSERVER_DEL,
+            "CFlexTimerServer::~CFlexTimerServer: exiting" );
+    }
+
+// --------------------------------------------------------------------------
+// Creation of new sessions, called by server framework
+// --------------------------------------------------------------------------
+//
+CSession2* CFlexTimerServer::NewSessionL( const TVersion& aVersion,
+                                          const RMessage2& /*aMessage*/ ) const
+    {
+    // Version checking, according to two main principles
+    // 1. Newer server will always support older clients (change this if
+    //    compatibility is changed at some phase)
+    // 2. Guaranteed that newer client will be compatible with older server 
+    //    within the same major version
+    if ( aVersion.iMajor > KFlexTimerServMajorVersionNumber )
+        {
+        OstTrace1(
+                TRACE_INTERNAL,
+                CFLEXTIMERSERVER_NEWSESSIONLVER,
+                "CFlexTimerServer::NewSessionL: Invalid major version (%d)",
+                aVersion.iMajor );
+        User::Leave( KErrNotSupported );
+        }
+
+    // Create and return session
+    CSession2* session = new ( ELeave ) CFlexTimerSession( iTimerEngine );
+
+    OstTrace1( TRACE_INTERNAL,
+            CFLEXTIMERSERVER_NEWSESSIONL,
+            "CFlexTimerServer::NewSessionL: Created; session=%x",
+            ( TUint )session );
+
+    return session;
+    }
+
+// --------------------------------------------------------------------------
+// Thread start function, loops in active scheduler
+// --------------------------------------------------------------------------
+//
+void CFlexTimerServer::StartServerL()
+    {
+    // Called when thread is created, create active scheduler
+    CActiveScheduler* sched = new CActiveScheduler;
+    if ( sched == NULL )
+        {
+        // Leave error code is used as a panic code
+        User::Leave( EFlexTimerServerActiveScheduler );
+        }
+    // Add active scheduler object to cleanup stack before installing it.
+    // It will be deleted, if any of the next operations fails.
+    CleanupStack::PushL( sched );
+    CActiveScheduler::Install( sched );
+
+    // Create server object and start it
+    CFlexTimerServer* flexServer = NULL;
+    flexServer = CFlexTimerServer::NewL( EPriorityStandard );
+
+    // Push the server object to cleanup stack before starting it
+    CleanupStack::PushL( flexServer );
+    
+    TInt err = KErrNone;
+    
+    err = flexServer->Start( KFlexTimerServerName );
+    if ( err != KErrNone )
+        {
+        // Leave error code is used as a panic code
+        User::Leave( EFlexTimerServerStartServer );
+        }
+
+    // Complete open rendezvous in this process (syncs with creator)
+    RProcess::Rendezvous( KErrNone );
+
+    // Active scheduler start will not leave, thus pop added objects
+    // from the cleanup stack. They will be deleted once the execution
+    // returns from the active scheduler (application is exiting)
+    CleanupStack::Pop( flexServer );
+    CleanupStack::Pop( sched );
+
+    OstTrace0( TRACE_INTERNAL,
+            CFLEXTIMERSERVER_START,
+            "CFlexTimerServer::StartServerL: Call ActiveScheduler" );
+
+    // Start active scheduler, thread stays in active scheduler loop
+    CActiveScheduler::Start();
+
+    OstTrace0( TRACE_INTERNAL,
+            CFLEXTIMERSERVER_EXIT,
+            "CFlexTimerServer::StartServerL: ActiveScheduler exit" );
+
+    // Delete allocated resources
+    delete flexServer;
+    delete sched;
+    }
+
+// --------------------------------------------------------------------------
+// Constructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServer::CFlexTimerServer( CActive::TPriority aPriority ) :
+    CServer2( aPriority ), iTimerEngine( NULL )
+    {
+
+    }
+
+// --------------------------------------------------------------------------
+// Two phased construction, 2nd phase
+// --------------------------------------------------------------------------
+//
+void CFlexTimerServer::ConstructL()
+    {
+    // Create engine, leaving is handled in server creation
+    iTimerEngine = CFlexTimerEngine::NewL();
+    OstTrace0( TRACE_INTERNAL,
+            CFLEXTIMERSERVER_CONSTRUCTL,
+            "CFlexTimerServer::ConstructL: Created engine" );
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// Main function of the server executable.
+// --------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    // Mark memory allocation check 
+    __UHEAP_MARK;
+
+    // Create cleanup stack
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    __ASSERT_ALWAYS( cleanup, User::Panic( KFlexTimerServerPanicCat,
+                    EFlexTimerServerCleanupStack ) );
+    // Start server
+    TRAPD( panicCode, CFlexTimerServer::StartServerL() );
+    if ( panicCode != KErrNone )
+        {
+        OstTrace1( TRACE_INTERNAL,
+                CFLEXTIMERSERVER_MAINERROR,
+                "CFlexTimerServer - Main: Start server failed (%d)",
+                panicCode );
+        delete cleanup;
+        User::Panic( KFlexTimerServerPanicCat, panicCode );
+        }
+    else
+        {
+        OstTrace0( TRACE_INTERNAL,
+                CFLEXTIMERSERVER_MAINEXIT,
+                "CFlexTimerServer - Main: Application exiting" );
+
+        // Delete cleanup stack
+        delete cleanup;
+        }
+
+    // Memory allocation check, panic in UDEB case of memory leak
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/server/src/flextimersession.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,509 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of CFlexTimerSession class.
+ *
+ */
+/*
+ * %version: 1 %
+ */
+
+// System include files
+#include <e32def.h>
+#include <e32cmn.h>
+#include <hal.h>
+
+// User include files go here:
+#include "flextimercommon.h"
+#include "flextimersession.h"
+#include "mflextimerservice.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimersessionTraces.h"
+#endif
+
+// Constants
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// Constructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerSession::CFlexTimerSession( MFlexTimerService* aFlexTimerService )
+:   iService( aFlexTimerService ),
+    iTimerWinSize( 0 ),
+    iUseDefaultWin( ETrue )
+    {
+    OstTrace1( TRACE_INTERNAL,
+               CFLEXTIMERSESSION,
+               "CFlexTimerSession::CFlexTimerSession; this=%x",
+               ( TUint )this );
+    }
+
+// --------------------------------------------------------------------------
+// Destructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerSession::~CFlexTimerSession()
+    {
+    OstTrace1( TRACE_INTERNAL,
+               CFLEXTIMERSESSIOND,
+               "CFlexTimerSession::~CFlexTimerSession; this=%x",
+               ( TUint )this );
+    }
+
+// --------------------------------------------------------------------------
+// Function called from CFlexTimerService::RunL for messages targeted to
+// this session
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::ServiceL( const RMessage2& aMessage )
+    {
+    TInt msgType( aMessage.Function() );
+
+    OstTraceExt2( TRACE_INTERNAL,
+                  CFLEXTIMERSESSION_MSG,
+                  "CFlexTimerSession::ServiceL; this=%x; msgType=%d",
+                  ( TInt )this,
+                  msgType );
+
+    // Check message type and pass it to correct handler. Handler either 
+    // stores the message or completes it immediately.
+    switch ( msgType )
+        {
+        case EFlexTimerServCancelRequest:
+            CancelTimer( aMessage );
+            break;
+        case EFlexTimerServAtRequest:
+            NewAtTimer( aMessage );
+            break;
+        case EFlexTimerServAtUTCRequest:
+            NewAtUtcTimer( aMessage );
+            break;
+        case EFlexTimerServAfterRequest:
+            NewAfterTimer( aMessage );
+            break;
+        case EFlexTimerServAfterTicksRequest:
+            NewAfterTicksTimer( aMessage );
+            break;
+        case EFlexTimerServConfigureRequest:
+            ConfigureParameters( aMessage );
+            break;
+        default:
+            OstTrace1(
+                    TRACE_INTERNAL,
+                    CFLEXTIMERSESSION_ERROR,
+                    "CFlexTimerSession::ServiceL: Unknown message; this=%x",
+                    ( TUint )this );
+            aMessage.Complete( KErrNotSupported );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// Timeout handler for triggering timers
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::Timeout() const
+    {
+    // Check for the validity of pending timeout request
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_TIMEOUT,
+                      "CFlexTimerSession::Timeout; this=%x; msg=%x",
+                      ( TUint )this,
+                      ( TUint )iPendingTimeoutMsg.Handle() );
+        // Complete message, this sets message pointer to NULL
+        iPendingTimeoutMsg.Complete( KErrNone );
+        }
+    else
+        {
+        // No valid message pointer, nothing we can do here
+        OstTrace1( TRACE_INTERNAL,
+                   CFLEXTIMERSESSION_TIMEOUT_ERROR,
+                   "CFlexTimerSession::Timeout: No Pending message; this=%x",
+                   ( TUint )this );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// Function for aborting At-timer
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::Abort( TInt aReason ) const
+    {
+    // Check for the validity of pending timeout request
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_ABORT,
+                      "CFlexTimerSession::Abort; this=%x; msg=%x",
+                      ( TUint )this,
+                      ( TUint )iPendingTimeoutMsg.Handle() );
+        // Complete message, this sets message pointer to NULL
+        iPendingTimeoutMsg.Complete( aReason );
+        }
+    else
+        {
+        // No valid message pointer, nothing we can do here
+        OstTrace1(
+                TRACE_INTERNAL,
+                CFLEXTIMERSESSION_ABORT_ERROR,
+                "CFlexTimerSession::Abort: No Pending message; this=%x",
+                ( TUint )this );
+
+        }
+    }
+
+// --------------------------------------------------------------------------
+// Handler function for starting At() -timer
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::NewAtTimer( const RMessage2& aMessage )
+    {
+
+    // Check that we do not have a pending timer request
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_ATPANIC,
+                      "CFlexTimerSession::NewAtTimer: Already pending; "
+                      "this=%x; msg=%x",
+                      ( TUint )this,
+                      ( TUint )iPendingTimeoutMsg.Handle() );
+
+        aMessage.Panic( KRFlexTimerPanicCat,
+                        EFlexTimerServerErrorPendingTimer );
+        return;
+        }
+
+    // Get interval from current time to the requested timestamp
+    TTime refTime;
+    refTime.HomeTime();
+    TTimeIntervalMicroSeconds interval;
+    GetIntervalToMsgTime( aMessage, refTime, interval );
+
+    OstTraceExt2( TRACE_INTERNAL,
+                  CFLEXTIMERSESSION_ATTIMER,
+                  "CFlexTimerSession::NewAtTimer; this=%x; interval=%lld",
+                  ( TUint )this,
+                  interval.Int64() );
+
+    // Add the timer to engine
+    DoAddTimer( aMessage, interval, ETrue );
+
+    }
+
+// --------------------------------------------------------------------------
+// Handler function for starting AtUTC() -timer
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::NewAtUtcTimer( const RMessage2& aMessage )
+    {
+
+    // Check that we do not have a pending timer request
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_ATUTCPANIC,
+                      "CFlexTimerSession::NewAtUtcTimer: Already pending; "
+                      "this=%x; msg=%x",
+                      ( TUint )this,
+                      ( TUint )iPendingTimeoutMsg.Handle() );
+
+        aMessage.Panic( KRFlexTimerPanicCat,
+                        EFlexTimerServerErrorPendingTimer );
+        return;
+        }
+
+    TTime refTime;
+    refTime.UniversalTime();
+    TTimeIntervalMicroSeconds interval;
+    GetIntervalToMsgTime( aMessage, refTime, interval );
+    
+    OstTraceExt2( 
+            TRACE_INTERNAL,
+            CFLEXTIMERSESSION_ATUTCTIMER,
+            "CFlexTimerSession::NewAtUtcTimer; this=%x; interval=%lld",
+            ( TUint )this,
+            interval.Int64() );
+
+    // Add the timer to engine
+    DoAddTimer( aMessage, interval, ETrue );
+
+    }
+
+// --------------------------------------------------------------------------
+// Handler function for starting After()-timer
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::NewAfterTimer( const RMessage2& aMessage )
+    {
+
+    // Check that we do not have a pending timer request
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_AFTERPANIC,
+                      "CFlexTimerSession::NewAfterTimer: Already pending; "
+                      "this=%x; msg=%x",
+                      ( TUint )this,
+                      ( TUint )iPendingTimeoutMsg.Handle() );
+
+        aMessage.Panic( KRFlexTimerPanicCat,
+                        EFlexTimerServerErrorPendingTimer );
+        return;
+        }
+
+    TInt64 timeStamp = MAKE_TINT64( aMessage.Int1(), aMessage.Int0() );
+    TTimeIntervalMicroSeconds interval( timeStamp );
+
+    OstTraceExt2(
+            TRACE_INTERNAL,
+            CFLEXTIMERSESSION_AFTERTIMER,
+            "CFlexTimerSession::NewAfterTimer; this=%x; interval=%llu",
+            ( TUint )this,
+            interval.Int64() );
+
+    // Add the timer to engine, request cancellation if the secure time
+    // is not available
+    DoAddTimer( aMessage, interval, EFalse );
+    }
+
+// --------------------------------------------------------------------------
+// Handler function for starting AfterTicks()-timer
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::NewAfterTicksTimer( const RMessage2& aMessage )
+    {
+
+    // Check that we do not have a pending timer request
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTraceExt2(
+                TRACE_INTERNAL,
+                CFLEXTIMERSESSION_AFTERTICKSPANIC,
+                "CFlexTimerSession::NewAfterTicksTimer: Already pending; "
+                "this=%x; msg=%x",
+                ( TUint )this,
+                ( TUint )iPendingTimeoutMsg.Handle() );
+
+        aMessage.Panic( KRFlexTimerPanicCat,
+                        EFlexTimerServerErrorPendingTimer );
+        return;
+        }
+
+    // Get the tick period from HAL and convert ticks to microseconds
+    TInt tickUs;
+    HAL::Get( HAL::ESystemTickPeriod, tickUs );
+
+    TTimeIntervalMicroSeconds interval =
+            static_cast<TInt64> ( aMessage.Int0() ) * tickUs;
+
+    OstTraceExt2(
+            TRACE_INTERNAL,
+            CFLEXTIMERSESSION_AFTERTICKSTIMER,
+            "CFlexTimerSession::NewAfterTicksTimer; this=%x; interval=%llu",
+            ( TUint )this,
+            interval.Int64() );
+
+    // Add the timer to engine
+    DoAddTimer( aMessage, interval, EFalse );
+    }
+
+// --------------------------------------------------------------------------
+// Handler function for cancelling running timer
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::CancelTimer( const RMessage2& aMessage )
+    {
+    TInt ret;
+    // Check that we have a pending timer request
+    if ( iPendingTimeoutMsg.IsNull() )
+        {
+        OstTrace1(
+                TRACE_INTERNAL,
+                CFLEXTIMERSESSION_CANCELERROR,
+                "CFlexTimerSession::CancelTimer: no pending msg; this=%x",
+                ( TUint )this );
+        ret = KErrNotFound;
+        }
+    else
+        {
+        ret = iService->CancelTimer( this );
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_CANCEL,
+                      "CFlexTimerSession::CancelTimer; this=%x; ret=%d",
+                      ( TUint )this,
+                      ret );
+
+        // Complete pending message, this sets message pointer to NULL
+        iPendingTimeoutMsg.Complete( KErrCancel );
+        }
+
+    // Complete cancel message
+    aMessage.Complete( ret );
+    }
+
+// --------------------------------------------------------------------------
+// Handler function for configuring timer parameters
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::ConfigureParameters( const RMessage2& aMessage )
+    {
+    TInt ret( KErrNone );
+
+    // Configuration is not allowed when there is a pending message
+    if ( !iPendingTimeoutMsg.IsNull() )
+        {
+        OstTrace1( TRACE_INTERNAL,
+                   CFLEXTIMERSESSION_CONFIGERROR,
+                   "CFlexTimerSession::ConfigureParameters: Timer pending; "
+                   "this=%x",
+                   ( TUint )this );
+        ret = KErrInUse;
+        }
+    else
+        {
+        TInt paramType( aMessage.Int0() );
+        OstTraceExt2( TRACE_INTERNAL,
+                      CFLEXTIMERSESSION_CONFIG,
+                      "CFlexTimerSession::ConfigureParameters; this=%x; "
+                      "paramType=%d",
+                      ( TUint )this,
+                      paramType );
+
+        switch ( paramType )
+            {
+            case EConfigureRequestWindowSize:
+                {
+                TInt winLo = aMessage.Int1();
+                TInt winHi = aMessage.Int2();
+
+                iTimerWinSize = MAKE_TINT64( winHi, winLo );
+                iUseDefaultWin = EFalse;
+
+                OstTraceExt1( TRACE_INTERNAL,
+                              CFLEXTIMERSESSION_CONFIGWIN,
+                              "CFlexTimerSession::ConfigureParameters; "
+                              "iTimerWinSize=%lld",
+                              iTimerWinSize.Int64() );
+                
+                if ( iTimerWinSize.Int64() < 0 ||
+                    iTimerWinSize.Int64() > KFlexTimerMaxTimerLength )
+                    {
+                    aMessage.Panic( KRFlexTimerPanicCat,
+                        EFlexTimerServerIllegalTimerValue );
+                    // Return after panicing the client -- completing the
+                    // message afterwards panics the server with USER 70.
+                    return;
+                    }
+                break;
+                }
+            default:
+                OstTrace0( TRACE_INTERNAL,
+                           CFLEXTIMERSESSION_CONFIGUNKNOWN,
+                           "CFlexTimerSession::ConfigureParameters: "
+                           "ERROR - Invalid parameter type" );
+                ret = KErrNotSupported;
+                break;
+            }
+        }
+    aMessage.Complete( ret );
+    }
+
+// --------------------------------------------------------------------------
+// Function for adding timer to engine and handling its return value
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::DoAddTimer( const RMessage2& aMessage,
+                                    TTimeIntervalMicroSeconds& aWinEnd,
+                                    TBool aRequestAbort )
+    {
+    OstTraceExt4( TRACE_INTERNAL,
+               CFLEXTIMERSESSION_ADDTIMER,
+               "CFlexTimerSession::DoAddTimer; this=%x; msg=%x; aWinEnd=%llu;"
+               " aRequestAbort=%d",
+               ( TUint )this,
+               ( TUint )aMessage.Handle(),
+               aWinEnd.Int64(),
+               aRequestAbort );  
+    
+    // Check that the timer has valid values.
+    if ( aWinEnd.Int64() < 0 || aWinEnd.Int64() > KFlexTimerMaxTimerLength)
+        {
+        OstTraceExt4( TRACE_INTERNAL, 
+                      CFLEXTIMERSESSION_DOADDTIMER, 
+                      "CFlexTimerSession::DoAddTimer;Invalid parameters "
+                      "- panicing client;this=%x;aMessage=%x;aWinEnd=%llu;"
+                      "aRequestAbort=%d", 
+                      ( TUint )this, 
+                      ( TUint )aMessage.Handle(), 
+                      aWinEnd.Int64(),
+                      aRequestAbort );
+        aMessage.Panic( KRFlexTimerPanicCat,
+                        EFlexTimerServerIllegalTimerValue );
+        return;
+        }
+    
+    TTimeIntervalMicroSeconds winStart;
+    TTimeIntervalMicroSeconds window = iTimerWinSize;
+    
+    if ( iUseDefaultWin )
+        {
+        window = static_cast<TInt64> ( static_cast<TReal64> ( aWinEnd.Int64() )
+            * KDefaultWindowMultiplier );
+        }
+
+    winStart = aWinEnd.Int64() - window.Int64();
+
+    // Store pending message. Not completed until timer expires.
+    // Note that in case of zero or negative timer value, message can
+    // be completed through Timeout() even before AddTimer returns. This
+    // implementation saves some checks and timer stopping/starting in engine.
+    iPendingTimeoutMsg = aMessage;
+
+    // Add timer to engine
+    TInt ret = iService->AddTimer( winStart, aWinEnd, aRequestAbort, this );
+
+    if ( KErrNone != ret )
+        {
+        // Failed, pass error code to client side
+        OstTraceExt2( TRACE_INTERNAL,
+                   CFLEXTIMERSESSION_ADDERROR,
+                   "CFlexTimerSession::DoAddTimer: Error; this=%x, ret=%d",
+                   ( TUint )this,
+                   ret );
+        // Complete pending message, this sets message pointer to NULL
+        iPendingTimeoutMsg.Complete( ret );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// From CSession2
+// Function for handling unintentional termination of the client
+// --------------------------------------------------------------------------
+//
+void CFlexTimerSession::Disconnect( const RMessage2 &aMessage )
+    {
+    // The client of this session has died.
+    
+    // Remove timer from engine.
+    iService->CancelTimer( this );
+
+    // Disconnect() must end with a call to the base class implementation, 
+    // which will delete the session object and complete the disconnect 
+    // message.
+    CSession2::Disconnect( aMessage );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/flextimer_build.bat	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,434 @@
+::---------------------------------------------------------------------------
+:: Helper for FlexTimer building and testing
+::
+:: Commands:
+::
+::  BUILD_ALL       Build component to all targets
+::  BUILD_ERROR     Inform user about failed build
+::  BUILD_OK        Inform user about passed build
+::  BUILD_TRACES    Build OST traces to targets WINSCW_UDEB and ARMV5_UDEB
+::  CHECK_EPOCROOT  Check that epocroot is set correctly
+::  CLEAN_NOLOGS    Reallyclean component, no output to screen
+::  DEL_CTC_REPORTS Delete old CTC reports
+::  GEN_CMT_REPORTS Generate CMT reports
+::  GEN_COV_REPORTS Generate and deliver Coveruty Prevent reports
+::  GEN_CS_REPORTS  Genrete CodeScanner reports
+::  GEN_CTC_REPORTS Generate CTC reports
+::  GEN_IMAGE       Make flash images
+::  GEN_SYMBOLS     Generate symbol files
+::  INSTRUMENT_CTC  Instrument CTC++ to component's WINSCW_UDEB target
+::  RUN_TESTS       Compile test component, run test application and check 
+::                  test results
+::  SCHEDULER       Execute commands from QUEUE
+::  SHOW_HELP       Show help of the script
+::  START_UP        Enable delayed environment expansion
+::  TEST_FAILED     Inform user about failed tests
+::  THE_END         Stop execution of the script
+::
+::---------------------------------------------------------------------------
+:: Change history:
+::
+:: 1.0  01-Apr-2010     First version in SVN
+::
+::---------------------------------------------------------------------------
+
+@echo off
+setlocal
+
+set VERSION=1.0 [01/04/2010 15:08:42]
+
+:: The source path is one dir up from the BAT's location
+for /f %%i in ("%0") do set SOURCE_PATH=%%~dpi..
+
+set MAKE_PATH=%SOURCE_PATH%\group\bld.inf
+set TEST_MAKE_PATH=%SOURCE_PATH%\test\testflextimer\group\bld.inf
+
+:: Commands for the component
+set CMD_BUILD_ALL=sbs -b %MAKE_PATH%
+set CMD_BUILD_CLEAN=sbs -b %MAKE_PATH% reallyclean
+set CMD_BUILD_TRACE=sbs -b %MAKE_PATH% -c winscw_udeb.tracecompiler -c armv5_udeb.tracecompiler
+
+:: Commands for test component
+set CMD_TEST_BUILD=sbs -b %TEST_MAKE_PATH% -c winscw_udeb -c armv5
+set CMD_TEST_RUN=start /wait %EPOCROOT%epoc32\release\winscw\udeb\atsinterface.exe -dtextshell -- -testmodule testflextimer
+
+:: Commands and settings for CTC++
+set CTC_OUTFILE=MON
+set CTC_OUTPATH=.
+set CMD_CTC_BUILD=ctcwrap -i m -v -2comp sbs.bat -b %MAKE_PATH% -c winscw_udeb
+set CMD_CTC_CLEAN=sbs -b %MAKE_PATH% -c winscw_udeb reallyclean
+set CMD_CTC_GEN=ctcpost %CTC_OUTPATH%\%CTC_OUTFILE%.sym %CTC_OUTPATH%\%CTC_OUTFILE%.dat ^| ctc2html
+
+:: Command for CMT
+set CMD_CMT_GEN=dir /s /b %SOURCE_PATH%\*.cpp %SOURCE_PATH%\*.inl ^| findstr /I /V "\\test\\" ^| cmt ^| cmt2html
+
+:: Commands and settings for Coverity Prevent
+set COV_OUTPATH=coverity
+set CMD_COV_BUILD=cov-build --dir %COV_OUTPATH% sbs -b %MAKE_PATH%
+set CMD_COV_ANALYZE=cov-analyze --dir %COV_OUTPATH% --all --symbian
+set CMD_COV_DELIVER=cov-commit-defects --dir %COV_OUTPATH% --remote trwsim47 --user cadsw --password cov3rity --product flextimer --cva
+set CMD_COV_SHOW_RESULTS=start http://trwsim47:5467
+
+:: Commands for iMaker
+set CMD_IMAKE_CORE=imaker vasco_ui core USE_SYMGEN=0
+set CMD_IMAKE_ROFS2=imaker vasco_ui rofs2 USE_SYMGEN=0
+set CMD_IMAKE_ROFS3=imaker vasco_ui rofs3 USE_SYMGEN=0
+set CMD_IMAKE_UDAERASE=imaker vasco_ui udaerase USE_SYMGEN=0
+set CMD_IMAKE_CORE_SYMBOLS=imaker vasco_ui romsymbol
+set CMD_IMAKE_ROFS2_SYMBOLS=imaker vasco_ui rofs2-symbol
+set CMD_IMAKE_ROFS3_SYMBOLS=imaker vasco_ui rofs3-symbol
+
+:: Commands and settings for CodeScanner
+set CODESCANNER_PATH=cs_output
+set CMD_CODESCANNER=codescanner -t off
+
+:: Python script for checking from test logs are tests passed
+set PY_ALL_TESTS_PASSED=^
+import re,sys;^
+file = open('%EPOCROOT%/epoc32/winscw/c/logs/testframework/testreport.txt');^
+txt = '\n'.join(file);^
+reg1 = re.search('^\s*(?:Passed cases\: (\d+))$', txt, re.MULTILINE);^
+reg2 = re.search('^\s*(?:Total cases\: (\d+))$', txt, re.MULTILINE);^
+sys.exit(0 if reg1.group(1)==reg2.group(1) else 1)
+
+:: Python script for parsing test result summary from test logs
+set PY_PARSE_TEST_RESULTS=^
+import re;^
+file = open('%EPOCROOT%/epoc32/winscw/c/logs/testframework/testreport.txt');^
+txt = '\n'.join(file);^
+reg = re.findall('^\s*(.*cases\: \d+)$', txt, re.MULTILINE);^
+print '\n'.join(reg);^
+file.close()
+
+::---------------------------------------------------------------------------
+:: Parse input
+::---------------------------------------------------------------------------
+
+if not "%1"=="__INITIALIZED__" (
+    goto START_UP
+
+) else (
+
+    if "%2"=="" (
+        set QUEUE=CHECK_EPOCROOT CLEAN_NOLOGS BUILD_ALL BUILD_TRACES RUN_TESTS GEN_CMT_REPORTS GEN_CS_REPORTS
+        goto SCHEDULER
+
+    ) else if /i "%2"=="build" (
+        set QUEUE=CHECK_EPOCROOT CLEAN_NOLOGS BUILD_ALL BUILD_TRACES
+        goto SCHEDULER
+
+    ) else if /i "%2"=="ctc" (
+        rem - atsinterface does not work with CTC instrumentation, use consoleui instead
+        rem - NOTE Emulator has to be closed manually
+        set CMD_TEST_RUN=start /wait %EPOCROOT%epoc32\release\winscw\udeb\consoleui.exe -dtextshell -- -testmodule testflextimer -run all
+        set QUEUE=CHECK_EPOCROOT INSTRUMENT_CTC DEL_CTC_REPORTS RUN_TESTS GEN_CTC_REPORTS
+        goto SCHEDULER
+
+    ) else if /i "%2"=="cov" (
+        set QUEUE=CHECK_EPOCROOT CLEAN_NOLOGS GEN_COV_REPORTS
+        goto SCHEDULER
+
+    ) else if /i "%2"=="image" (
+        set QUEUE=CHECK_EPOCROOT GEN_IMAGE GEN_SYMBOLS
+        goto SCHEDULER
+
+    ) else if /i "%2"=="test" (
+        set QUEUE=CHECK_EPOCROOT GEN_CMT_REPORTS GEN_CS_REPORTS
+        goto SCHEDULER
+
+    ) else if /i "%2"=="help" goto SHOW_HELP
+)
+
+echo Illegal parameter %2
+
+goto SHOW_HELP
+
+::---------------------------------------------------------------------------
+:START_UP
+::---------------------------------------------------------------------------
+:: Start a command shell with delayed environment expansion
+
+cmd.exe /V:ON /C %0 __INITIALIZED__ %1
+
+goto THE_END
+
+::---------------------------------------------------------------------------
+:SCHEDULER
+::---------------------------------------------------------------------------
+:: Run the build commands. Eat commands from QUEUE one by one
+
+for /f "tokens=1*" %%i in ( "!QUEUE!" ) do (
+    set QUEUE=%%j
+    rem echo ====================================================================
+    rem echo %%i
+    rem echo ====================================================================
+    goto %%i
+)
+
+goto BUILD_OK
+
+::---------------------------------------------------------------------------
+:BUILD_ALL
+::---------------------------------------------------------------------------
+
+call %CMD_BUILD_ALL%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:BUILD_TRACES
+::---------------------------------------------------------------------------
+
+call %CMD_BUILD_TRACE%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:CLEAN_NOLOGS
+::---------------------------------------------------------------------------
+:: Reallyclean FlexTimer component without showing compilation logs on screen
+
+call %CMD_BUILD_CLEAN% > NUL 2>&1
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:INSTRUMENT_CTC
+::---------------------------------------------------------------------------
+:: Instrument FlexTimer WINSCW UDEB with CTC++
+
+:: Remove old CTC symbols
+del %CTC_OUTPATH%\%CTC_OUTFILE%.sym > NUL 2>&1
+
+:: Clean old compilation
+call %CMD_CTC_CLEAN% > NUL 2>&1
+
+:: Instrument the code
+call %CMD_CTC_BUILD%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:DEL_CTC_REPORTS
+::---------------------------------------------------------------------------
+:: Delete CTC generated test reports. SYM-file is deleted before 
+:: instrumenting CTC.
+
+del %CTC_OUTPATH%\%CTC_OUTFILE%.dat > NUL 2>&1
+rmdir /q /s %CTC_OUTPATH%\CTCHTML > NUL 2>&1
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:RUN_TESTS
+::---------------------------------------------------------------------------
+
+:: Compile test component
+call %CMD_TEST_BUILD%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+echo Testing...
+
+:: Run test application
+%CMD_TEST_RUN%
+if not "%errorlevel%"=="0" goto TEST_FAILED
+
+:: Verify test results
+call python -c "%PY_ALL_TESTS_PASSED%"
+if not "%errorlevel%"=="0" goto TEST_FAILED
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:GEN_CTC_REPORTS
+::---------------------------------------------------------------------------
+
+:: Generate CTC++ reports
+call %CMD_CTC_GEN% 
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:GEN_CMT_REPORTS
+::---------------------------------------------------------------------------
+
+call %CMD_CMT_GEN%
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:GEN_COV_REPORTS
+::---------------------------------------------------------------------------
+
+:: Delete the old results
+rmdir /q /s %COV_OUTPATH% > NUL 2>&1
+
+:: Build with Coverity Prevent
+call %CMD_COV_BUILD%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+:: Analyze the code
+call %CMD_COV_ANALYZE%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+:: Deliver the results
+call %CMD_COV_DELIVER%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+:: Open the results
+%CMD_COV_SHOW_RESULTS%
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:GEN_CS_REPORTS
+::---------------------------------------------------------------------------
+
+set __CODESCANNER_LAST_DIR=
+set __CODESCANNER_PARAMETERS=
+
+:: Find all inc and src -directories that are not in codescanner results nor
+:: test code. Add '-i' parameter to every directory except the last one. (As
+:: codescanner -h states.)
+
+for /f "usebackq" %%i in (`dir /s /b %SOURCE_PATH%\src %SOURCE_PATH%\inc ^| findstr /V "\\test\\ \\%CODESCANNER_PATH%\\"`) do (
+    if defined __CODESCANNER_LAST_DIR set __CODESCANNER_PARAMETERS=!__CODESCANNER_PARAMETERS! -i !__CODESCANNER_LAST_DIR!
+    set __CODESCANNER_LAST_DIR=%%i
+)
+
+%CMD_CODESCANNER% %__CODESCANNER_PARAMETERS% %__CODESCANNER_LAST_DIR% %CODESCANNER_PATH%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+:: Open the results
+start %CODESCANNER_PATH%\problemIndex.html
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:CHECK_EPOCROOT
+::---------------------------------------------------------------------------
+
+:: Check that the given parameter is a root dir.
+for /f %%i in ("%EPOCROOT%") do (
+    if /i not "%EPOCROOT%"=="%%~di\" (
+        echo EPOCROOT is invalid: %EPOCROOT%
+        echo It should be a root of certain drive letter e.g. T:\
+        goto BUILD_ERROR
+    )
+)
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:GEN_IMAGE
+::---------------------------------------------------------------------------
+
+:: Go to the SDK drive
+for /f %%i in ("%EPOCROOT%") do %%~di
+
+:: Make image
+call %CMD_IMAKE_CORE%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+call %CMD_IMAKE_ROFS2%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+call %CMD_IMAKE_ROFS3%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+call %CMD_IMAKE_UDAERASE%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+echo.
+echo ======================================================================
+echo IMAGES ARE READY
+echo ======================================================================
+echo.
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:GEN_SYMBOLS
+::---------------------------------------------------------------------------
+
+:: Go to the SDK drive
+for /f %%i in ("%EPOCROOT%") do %%~di
+
+:: Generate symbols
+call %CMD_IMAKE_CORE_SYMBOLS%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+call %CMD_IMAKE_ROFS2_SYMBOLS%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+call %CMD_IMAKE_ROFS3_SYMBOLS%
+if not "%errorlevel%"=="0" goto BUILD_ERROR
+
+goto SCHEDULER
+
+::---------------------------------------------------------------------------
+:BUILD_ERROR
+::---------------------------------------------------------------------------
+
+echo.
+echo Build failed
+echo.
+
+goto THE_END
+
+::---------------------------------------------------------------------------
+:BUILD_OK
+::---------------------------------------------------------------------------
+
+echo.
+echo Build OK
+echo.
+
+goto THE_END
+
+::---------------------------------------------------------------------------
+:TEST_FAILED
+::---------------------------------------------------------------------------
+
+echo.
+echo Testing failed
+echo.
+
+call python -c "%PY_PARSE_TEST_RESULTS%"
+
+goto THE_END
+
+::---------------------------------------------------------------------------
+:SHOW_HELP
+::---------------------------------------------------------------------------
+echo.
+echo A script for building and testing FlexTimer. Version %VERSION%
+echo.
+echo Usage:
+echo    flextimer_build ^<option^>
+echo.
+echo Options:
+echo.
+echo    ^<none^>  Build component (with traces), build test component and run
+echo            tests, generate static analysis
+echo.
+echo    build   Rebuild component (with traces)
+echo.
+echo    cov     Generate and deliver Coverity Prevent report
+echo.
+echo    ctc     Instrument CTC++, build test component and run tests, 
+echo            generate test coverity reports
+echo.
+echo    image   Create CORE and ROFS1, ROFS2, ROFS3 and UDAERASE flash images
+echo.
+echo    help    Show this help
+echo.
+
+::---------------------------------------------------------------------------
+:THE_END
+::---------------------------------------------------------------------------
+endlocal
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/bmarm/testflextimeru.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void)
+	SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/bwins/testflextimeru.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/eabi/testflextimeru.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,10 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+	_ZTI15CTestRFlexTimer @ 3 NONAME
+	_ZTI20CInheritedCFlexTimer @ 4 NONAME
+	_ZTI21CInheritedCFlexTimer2 @ 5 NONAME
+	_ZTV15CTestRFlexTimer @ 6 NONAME
+	_ZTV20CInheritedCFlexTimer @ 7 NONAME
+	_ZTV21CInheritedCFlexTimer2 @ 8 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/bwins/flextimerservermonitorclientu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	?StartMonitoring@RFlexTimerServerMonitor@@QAEHXZ @ 1 NONAME ; int RFlexTimerServerMonitor::StartMonitoring(void)
+	?GetStatus@RFlexTimerServerMonitor@@QAEHAAH@Z @ 2 NONAME ; int RFlexTimerServerMonitor::GetStatus(int &)
+	?StopMonitoring@RFlexTimerServerMonitor@@QAEHXZ @ 3 NONAME ; int RFlexTimerServerMonitor::StopMonitoring(void)
+	?Connect@RFlexTimerServerMonitor@@QAEHXZ @ 4 NONAME ; int RFlexTimerServerMonitor::Connect(void)
+	??1RFlexTimerServerMonitor@@QAE@XZ @ 5 NONAME ; RFlexTimerServerMonitor::~RFlexTimerServerMonitor(void)
+	??0RFlexTimerServerMonitor@@QAE@XZ @ 6 NONAME ; RFlexTimerServerMonitor::RFlexTimerServerMonitor(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/eabi/flextimerservermonitorclientu.def	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,10 @@
+EXPORTS
+	_ZN23RFlexTimerServerMonitor14StopMonitoringEv @ 1 NONAME
+	_ZN23RFlexTimerServerMonitor15StartMonitoringEv @ 2 NONAME
+	_ZN23RFlexTimerServerMonitor7ConnectEv @ 3 NONAME
+	_ZN23RFlexTimerServerMonitor9GetStatusERi @ 4 NONAME
+	_ZN23RFlexTimerServerMonitorC1Ev @ 5 NONAME
+	_ZN23RFlexTimerServerMonitorC2Ev @ 6 NONAME
+	_ZN23RFlexTimerServerMonitorD1Ev @ 7 NONAME
+	_ZN23RFlexTimerServerMonitorD2Ev @ 8 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*     Server that monitors has FlexTimerServer crashed during testing.
+*/
+
+PRJ_PLATFORMS
+
+    DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+    ../rom/flextimerservermonitor.iby CORE_MW_LAYER_IBY_EXPORT_PATH(flextimerservermonitor.iby)
+
+PRJ_TESTMMPFILES
+
+PRJ_MMPFILES
+
+    flextimerservermonitorserver.mmp
+    flextimerservermonitorclient.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/group/flextimerservermonitorclient.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: 
+*       MMP file for client of server that monitors has FlexTimerServer 
+*       crashed during testing.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          flextimerservermonitorclient.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2002EA9C
+
+CAPABILITY      ALL -TCB
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../traces
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          rflextimerservermonitor.cpp
+
+LIBRARY         euser.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/group/flextimerservermonitorserver.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: 
+*       MMP file for server that monitors has FlexTimerServer crashed during 
+*       testing.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          flextimerservermonitorserver.exe
+TARGETTYPE      exe
+UID             0x1000008D 0x2002EA9B
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_SERVER
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../traces
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          flextimerservermonitorserver.cpp 
+SOURCE          flextimerservermonitorsession.cpp
+
+LIBRARY         euser.lib
+LIBRARY         flextimerclient.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/inc/flextimerservermonitorcommon.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Common definitions for FlexTimerServerMonitor client/server
+ *      communication.
+ */
+/*
+ * %version: 1 %
+ */
+#ifndef FLEXTIMERSERVERMONITORCOMMON_H
+#define FLEXTIMERSERVERMONITORCOMMON_H
+
+/**
+ * Function codes used in message passing between client and server.
+ */
+enum TFlexTimerServerMonitorRequests
+    {
+    EFlexTimerServerMonitorStartMonitoring = 1, ///< Start monitoring
+    EFlexTimerServerMonitorHasServerCrashed,    ///< Has monitored server crashed
+    EFlexTimerServerMonitorStopMonitoring       ///< Stop monitoring
+    };
+
+/**
+ * Panic category for FlexTimerServerMonitor server panics
+ */
+_LIT( KFlexTimerServerMonitorPanicCategory, "TestFlexTimer-Monitor" );
+
+/**
+ * Panic codes for panic category TestFlexTimer-Monitor
+ */
+enum TFlexTimerServerMonitorPanicCode
+    {
+    EActiveSchedulerCreationFailed = 1,
+    EServerCreationFailed,
+    EStartingServerFailed,
+    ECleanupStackCreationFailed
+    };
+
+
+const TUint KFlexTimerServerMonitorMajorVersionNumber = 0; ///< Major version
+const TUint KFlexTimerServerMonitorMinorVersionNumber = 1; ///< Minor version
+const TUint KFlexTimerServerMonitorBuildVersionNumber = 1; ///< Build version
+
+/**
+ * Name of the FlexTimer server monitor process
+ */
+_LIT( KFlexTimerServerMonitorServerName, "FlexTimerServerMonitorServer" );
+
+/**
+ * Name of the FlexTimer server monitor process executable
+ */
+_LIT( KFlexTimerServerMonitorServerExe, "flextimerservermonitorserver.exe" );
+
+/**
+ * Number of the message slots for FlexTimer server monitor process.
+ * 
+ * Due there are no asynchronous messaging, the number of slots can be one.
+ */
+const TInt KFlexTimerServerMonitorServerMessageSlots = 1;
+
+#endif // FLEXTIMERSERVERMONITORCOMMON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/inc/flextimerservermonitorserver.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Server implementation for FlexTimerServerMonitor.
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef FLEXTIMERSERVERMONITORSERVER_H
+#define FLEXTIMERSERVERMONITORSERVER_H
+
+// System includes
+#include <e32base.h>
+#include <rflextimer.h>
+
+// Class declaration
+/**
+ * A server for detecting, has FlexTimerServer crashed during the
+ * monitoring period.
+ */
+class CFlexTimerServerMonitorServer : public CServer2
+    {
+    
+public:
+    /**
+     * Two phased constructor 
+     * 
+     * @param aPriority Active object priority for the server 
+     * @return Pointer to created server object
+     */
+    IMPORT_C static CFlexTimerServerMonitorServer* NewL( 
+        CActive::TPriority aPriority );
+
+    /**
+     * Destructor 
+     */
+    virtual ~CFlexTimerServerMonitorServer();
+
+public:
+
+    /**
+     * From CServer2
+     * Function for creating a new session to this server. 
+     *
+     * @param aVersion Version identifier from client
+     * @param aMessage Reference to creation message sent by client
+     * @return Pointer to created session object
+     */
+    CSession2* NewSessionL( const TVersion& aVersion,
+                            const RMessage2& aMessage ) const;
+
+    /**
+     * Function for creating server thread resources. Creates the server
+     * object and active scheduler. Loops in the active scheduler to serve
+     * client requests until explicitly shutdown. Function leaves if the
+     * creation of needed resources fails.
+     */
+    static void StartServerL();
+
+    /**
+     * Start monitoring FlexTimer server crashing.
+     * 
+     * @return KErrNone when succeeded, KErrAlreadyExists if monitoring was
+     * already started, or any other system level error code.
+     */
+    TInt StartMonitoring();
+    
+    /**
+     * Stop monitoring FlexTimer server crashing.
+     * 
+     * @return KErrNone when succeeded, KErrNotFound if monitoring is not
+     * started.
+     */
+    TInt StopMonitoring();
+    
+    /**
+     * Get status of monitoring the server. I.e. has the server crashed or 
+     * not.
+     *
+     * @param aHasServerCrashed Return ETrue if server has crashed while
+     * monitoring, otherwise EFalse.
+     * @return KErrNone when succeeded, KErrNotFound if monitoring is not
+     * started.
+     */
+    TInt GetStatus( TBool& aHasServerCrashed );
+    
+private:
+
+    /**
+     * Constructor
+     * 
+     * @param aPriority Active object priority 
+     */
+    CFlexTimerServerMonitorServer( CActive::TPriority aPriority );
+
+private: // Data
+
+    /**
+     * Handle to FlexTimer server.
+     * This parameter needs to be in server due it is manipulated by
+     * multible sessions.
+     */
+    RFlexTimer iFlexTimer;
+    
+    /**
+     * State of monitoring. ETrue if monitoring has started, EFalse if not.
+     * This state is introduced for preventing starting/stopping the
+     * monitoring more than once in a row.
+     */
+    TBool iIsMonitoringOn;
+    };
+
+#endif /* FLEXTIMERSERVERMONITORSERVER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/inc/flextimerservermonitorsession.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Session implementation for FlexTimerServerMonitor server
+ */
+/*
+ * %version: 1 %
+ */
+// Protection against nested includes
+#ifndef FLEXTIMERSERVERMONITORSESSION_H
+#define FLEXTIMERSERVERMONITORSESSION_H
+
+// System includes
+#include <e32base.h>
+
+// Forward declarations
+class RFlexTimer;
+
+// Class declaration
+/**
+ * Session for FlexTimerServerMonitor server.
+ * Just receives requests from client and calls server's interface.
+ */
+class CFlexTimerServerMonitorSession : public CSession2
+    {
+
+public:
+
+    /**
+     * Two phase constructor
+     */
+    static CFlexTimerServerMonitorSession* NewL();
+
+    /**
+     * Destructor
+     */
+    virtual ~CFlexTimerServerMonitorSession();
+
+    /**
+     * From CSession2
+     * Message handler servicing client requests. Interprets message type and
+     * passes it to correct function for processing.
+     * 
+     * @param aMessage Message from client
+     */
+    void ServiceL( const RMessage2& aMessage );
+
+private:
+
+    /**
+     * Constructor
+     */
+    CFlexTimerServerMonitorSession();
+
+    /**
+     * 2nd phase constructor
+     */
+    void ConstructL();
+
+private: // Data
+
+    };
+
+#endif /* FLEXTIMERSERVERMONITORSESSION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/inc/rflextimerservermonitor.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Client implementation for FlexTimerServerMonitor
+ */
+
+/*
+ * %version: 1 %
+ */
+
+#ifndef RFLEXTIMERSERVERMONITOR_H
+#define RFLEXTIMERSERVERMONITOR_H
+
+// INCLUDE FILES
+#include <e32std.h> 
+
+// CLASS DECLARATION
+/**
+ * Client implementation for FlexTimerServerMonitor.
+ * Forwards all requests as synchronous messages to the client.
+ * 
+ * Creates the server if it is not up'n'running when connecting to the server
+ * at the first time.
+ * 
+ * StartMonitoring() has to be called before StopMonitoring() and GetStatus()
+ * works. Note! The starting can be done by different handle. I.e.
+ * 
+ * @code
+ * 
+ *      RFlexTimerServerMonitor mon1;
+ *      mon1.Connect();
+ *      mon1.StartMonitoring();
+ *      mon1.Close();
+ *      
+ *      .
+ *      .
+ *      . 
+ *      
+ *      RFlexTimerServerMonitor mon2;
+ *      mon2.Connect();
+ *      TBool hasCrashed;
+ *      mon2.GetStatus( hasCrashed );
+ *      // Do your stuff
+ *      ...
+ *      mon2.StopMonitoring();
+ *      mon2.Close();
+ *      
+ * @endcode
+ */
+class RFlexTimerServerMonitor : public RSessionBase
+    {
+public:
+    // Constructors and destructors
+
+    /**
+     * Constructor
+     */
+    IMPORT_C RFlexTimerServerMonitor();
+
+    /**
+     * Destructor
+     */
+    IMPORT_C ~RFlexTimerServerMonitor();
+
+    /**
+     * Connect to the server.
+     * 
+     * @return KErrNone on success. Otherwise returns one of the system-wide
+     * error codes.
+     */
+    IMPORT_C TInt Connect();
+
+    /**
+     * Start detecting the crashes.
+     * 
+     * @return KErrNone if succeeded, KErrAlreadyExists if monitoring is
+     * already activated, or any other system-wide error code.
+     */
+    IMPORT_C TInt StartMonitoring();
+
+    /**
+     * Stop detecting the crashes.
+     * 
+     * @return KErrNone if succeeded, KErrNotFound if monitoring is not
+     * activated, or any other system-wide error code.
+     */
+    IMPORT_C TInt StopMonitoring();
+    
+    /**
+     * Get the current status of monitoring.
+     * 
+     * 
+     * @param aHasServerCrashed ETrue if server has crashed, EFalse otherwise
+     * @return KErrNone if succeeded, KErrNotFound if monitoring is not
+     * activated, or any other system-wide error code.
+     */
+    IMPORT_C TInt GetStatus( TBool& aHasServerCrashed );
+    
+private:
+    
+    /**
+     * Gets the version number.
+     * @return The version.
+     */
+    TVersion Version() const;
+
+    /**
+     * Connects to the server. If server does not exist, it is created.
+     * @return KErrNone on success. Otherwise returns one of the system-wide
+     * error codes.
+     */
+    TInt StartServer();
+    };
+
+#endif // RFLEXTIMERSERVERMONITOR_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/rom/flextimerservermonitor.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef FLEXTIMERSERVERMONITOR_IBY
+#define FLEXTIMERSERVERMONITOR_IBY
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\flextimerservermonitorclient.dll SHARED_LIB_DIR\flextimerservermonitorclient.dll
+file=ABI_DIR\BUILD_DIR\flextimerservermonitorserver.exe SHARED_LIB_DIR\flextimerservermonitorserver.exe
+
+#endif // FLEXTIMERSERVERMONITOR_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/src/flextimerservermonitorserver.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Server implementation for FlexTimerServerMonitor
+ */
+/*
+ * %version: 2 %
+ */
+
+#include "flextimerservermonitorserver.h"
+#include "flextimerservermonitorcommon.h"
+#include "flextimerservermonitorsession.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimerservermonitorserverTraces.h"
+#endif
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// Construction
+// --------------------------------------------------------------------------
+//
+EXPORT_C CFlexTimerServerMonitorServer* CFlexTimerServerMonitorServer::NewL(
+    CActive::TPriority aPriority )
+    {
+    return new ( ELeave ) CFlexTimerServerMonitorServer( aPriority );
+    }
+
+// --------------------------------------------------------------------------
+// Destructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServerMonitorServer::~CFlexTimerServerMonitorServer()
+    {
+    iFlexTimer.Close();
+    }
+
+// --------------------------------------------------------------------------
+// Creation of new sessions, called by server framework
+// --------------------------------------------------------------------------
+//
+CSession2* CFlexTimerServerMonitorServer::NewSessionL( 
+    const TVersion& aVersion ,
+    const RMessage2& /* aMessage */ ) const
+    {
+
+    if ( aVersion.iMajor > KFlexTimerServerMonitorMajorVersionNumber )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    // Create and return session
+    return CFlexTimerServerMonitorSession::NewL();
+    }
+
+// --------------------------------------------------------------------------
+// Connect to FlexTimer service
+// --------------------------------------------------------------------------
+//
+TInt CFlexTimerServerMonitorServer::StartMonitoring()
+    {
+    if ( iIsMonitoringOn )
+        {
+        return KErrAlreadyExists;
+        }
+    iIsMonitoringOn = ETrue;
+    return iFlexTimer.Connect();
+    }
+
+// --------------------------------------------------------------------------
+// Close connection to FlexTimer service
+// --------------------------------------------------------------------------
+//
+TInt CFlexTimerServerMonitorServer::StopMonitoring()
+    {
+    if ( !iIsMonitoringOn )
+        {
+        return KErrNotFound; 
+        }
+    iIsMonitoringOn = EFalse;
+    iFlexTimer.Close();
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Get status of the monitored process
+// --------------------------------------------------------------------------
+//
+TInt CFlexTimerServerMonitorServer::GetStatus( TBool& aHasServerCrashed )
+    {
+    if ( !iIsMonitoringOn )
+        {
+        return KErrNotFound;
+        }
+    
+    // Check has the FlexTimerServer crashed by trying to configure
+    // the timer. If the server has crashed, it fails. Usually, in case of
+    // server crash this will return KErrServerTerminated (-15).
+    TInt ret = iFlexTimer.Configure( TTimeIntervalMicroSeconds( 1000000 ) );
+
+    if ( ret == KErrNone )
+        { // No crash.
+        aHasServerCrashed = EFalse;
+        }
+    else
+        { // Crash has happened.
+        aHasServerCrashed = ETrue;
+        }
+
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Thread start function, loops in active scheduler
+// --------------------------------------------------------------------------
+//
+void CFlexTimerServerMonitorServer::StartServerL()
+    {
+    // Called when thread is created, create active scheduler
+    CActiveScheduler* scheduler = new CActiveScheduler;
+    User::LeaveIfNull( scheduler );
+
+    // Add active scheduler object to cleanup stack before installing it.
+    // It will be deleted, if any of the next operations fails.
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+
+    // Create server object and start it
+    CFlexTimerServerMonitorServer* server( NULL );
+    server = CFlexTimerServerMonitorServer::NewL( EPriorityStandard );
+    
+    // Push the server object to cleanup stack before starting it
+    CleanupStack::PushL( server );
+
+    User::LeaveIfError( server->Start( KFlexTimerServerMonitorServerName ) );
+
+    // Complete open rendezvous in this process (syncs with creator)
+    RProcess::Rendezvous( KErrNone );
+
+    // Active scheduler start will not leave, thus pop added objects
+    // from the cleanup stack. They will be deleted once the execution
+    // returns from the active scheduler (application is exiting)
+    CleanupStack::Pop( server );
+    CleanupStack::Pop( scheduler );
+
+    // Start active scheduler, thread stays in active scheduler loop
+    CActiveScheduler::Start();
+
+    // Delete allocated resources
+    delete server;
+    delete scheduler;
+    }
+
+// --------------------------------------------------------------------------
+// Constructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServerMonitorServer::CFlexTimerServerMonitorServer( 
+    CActive::TPriority aPriority ) :
+    CServer2( aPriority ), iIsMonitoringOn( EFalse )
+    {
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// Main function of the server executable.
+// --------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    // Mark memory allocation check 
+    __UHEAP_MARK;
+
+    // Create cleanup stack
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    __ASSERT_ALWAYS(
+        cleanup != NULL, 
+        User::Panic( KFlexTimerServerMonitorPanicCategory, 
+                     ECleanupStackCreationFailed ) );
+    
+    // Start server
+    TRAPD( panicCode, CFlexTimerServerMonitorServer::StartServerL() );
+
+    delete cleanup;
+    if ( panicCode != KErrNone )
+        {
+        User::Panic( KFlexTimerServerMonitorPanicCategory, panicCode );
+        }
+
+    // Memory allocation check, panic in UDEB case of memory leak
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/src/flextimerservermonitorsession.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Session implementation for FlexTimerServerMonitor server
+ *
+ */
+/*
+ * %version: 1 %
+ */
+
+// System include files
+
+// User include files go here:
+#include <rflextimer.h>
+#include "flextimerservermonitorsession.h"
+#include "flextimerservermonitorcommon.h"
+#include "flextimerservermonitorserver.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "flextimerservermonitorsessionTraces.h"
+#endif
+
+// Constants
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// Constructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServerMonitorSession::CFlexTimerServerMonitorSession()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// Destructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServerMonitorSession::~CFlexTimerServerMonitorSession()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// 2nd phase constructor
+// --------------------------------------------------------------------------
+//
+void CFlexTimerServerMonitorSession::ConstructL()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// Two-phased constructor
+// --------------------------------------------------------------------------
+//
+CFlexTimerServerMonitorSession* CFlexTimerServerMonitorSession::NewL()
+    {
+    CFlexTimerServerMonitorSession* self =
+            new (ELeave) CFlexTimerServerMonitorSession();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// Handle clients' requests. Due the request implementations are simple
+// the actions are done in ServiceL and not dispatched to separate functions.
+// --------------------------------------------------------------------------
+//
+void CFlexTimerServerMonitorSession::ServiceL( const RMessage2& aMessage )
+    {
+    // This ain't the most elegant solution but here we go.
+    //
+    // Passing the server's reference as a parameter during session creation 
+    // would be another solution.
+    CFlexTimerServerMonitorServer* server = 
+        static_cast<CFlexTimerServerMonitorServer*>( 
+            const_cast<CServer2*>( Server() ) );
+
+    // Dispatch and execute the client's request
+    switch ( aMessage.Function() )
+        {
+        case EFlexTimerServerMonitorStartMonitoring:
+            {
+            aMessage.Complete( server->StartMonitoring() );
+            break;
+            }
+        case EFlexTimerServerMonitorHasServerCrashed:
+            {
+            TBool hasCrashed;
+
+            TInt ret = server->GetStatus( hasCrashed );
+
+            TPckgBuf<TBool> pckg( hasCrashed );
+            aMessage.WriteL( 0, pckg );
+            aMessage.Complete( ret );
+            break;
+            }
+        case EFlexTimerServerMonitorStopMonitoring:
+            {
+            aMessage.Complete( server->StopMonitoring() );
+            break;
+            }
+        default:
+            aMessage.Complete( KErrNotSupported );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/src/rflextimerservermonitor.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *      Client implementation for FlexTimerServerMonitor
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+#include "rflextimerservermonitor.h"
+#include "flextimerservermonitorcommon.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "rflextimerservermonitorTraces.h"
+#endif
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// Constructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RFlexTimerServerMonitor::RFlexTimerServerMonitor()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructs the object.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RFlexTimerServerMonitor::~RFlexTimerServerMonitor()
+    {
+    Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Connects to the server and create a session.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimerServerMonitor::Connect()
+    {
+    // Starts the server, if it does not already exist in the system.
+    TInt ret = StartServer();
+
+    if ( ret == KErrNone )
+        { // No session, create it
+        ret = CreateSession( 
+            KFlexTimerServerMonitorServerName,
+            Version(),
+            KFlexTimerServerMonitorServerMessageSlots );
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Start monitoring FlexTimer server crashes
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimerServerMonitor::StartMonitoring()
+    {
+    return SendReceive( EFlexTimerServerMonitorStartMonitoring );
+    }
+
+// ---------------------------------------------------------------------------
+// Get the status of the monitoring; has FlexTimer server crashed while
+// monitoring or not.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimerServerMonitor::GetStatus( TBool& aHasServerCrashed )
+    {
+    TPckgBuf<TBool> pckg;
+    TIpcArgs args( &pckg );
+
+    TInt ret = SendReceive( EFlexTimerServerMonitorHasServerCrashed, args );
+
+    // Extract the value returned from the server.
+    aHasServerCrashed = pckg();
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Stop monitoring FlexTimer server crashes
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt RFlexTimerServerMonitor::StopMonitoring()
+    {
+    return SendReceive( EFlexTimerServerMonitorStopMonitoring );
+    }
+
+// ---------------------------------------------------------------------------
+// Gets the version number.
+// ---------------------------------------------------------------------------
+//
+TVersion RFlexTimerServerMonitor::Version() const
+    {
+    return ( TVersion( KFlexTimerServerMonitorMajorVersionNumber,
+                       KFlexTimerServerMonitorMinorVersionNumber,
+                       KFlexTimerServerMonitorBuildVersionNumber ) );
+    }
+
+// ---------------------------------------------------------------------------
+// Connects to the server. If server does not exist, it is created.
+// ---------------------------------------------------------------------------
+//
+TInt RFlexTimerServerMonitor::StartServer()
+    {
+    TFindServer findServer( KFlexTimerServerMonitorServerName );
+    TFullName serverName;
+
+    // See if the server is already started. 
+    TInt ret = findServer.Next( serverName );
+    
+    if ( ret != KErrNone )
+        {
+        //Server was not found so create one.
+        RProcess serverProcess;
+        TBuf<1> serverParameters;
+
+        // Load the executable for the server.
+        ret = serverProcess.Create( KFlexTimerServerMonitorServerExe,
+                                    serverParameters,
+                                    EOwnerThread );
+
+        if ( ret == KErrNone )
+            {
+            // Server has been created successfully. It is initially 
+            // in suspended state. Now resume the server process.
+
+            // Wait until the server process has been started.
+            TRequestStatus status;
+            
+            serverProcess.Rendezvous( status );
+            serverProcess.Resume();
+            User::WaitForRequest( status );
+
+            // Check if server has panicked during initialization.
+            ret = serverProcess.ExitType();
+            if ( ret == EExitPanic )
+                {
+                ret = KErrServerTerminated;
+                }
+            else
+                {
+                ret = status.Int();
+                }
+
+            // The server process stands on its own. This handle can
+            // be closed. 
+            serverProcess.Close();
+            }
+        }
+    return ret;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/flextimerservermonitor/traces/OstTraceDefinitions.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,4 @@
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+#include <opensystemtrace.h>
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+	
+	DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in \epoc32\include
+// Example: 
+/*
+\agnmodel\inc\AGMCOMON.H
+*/
+
+
+PRJ_TESTEXPORTS
+../rom/testflextimer.iby CORE_MW_LAYER_IBY_EXPORT_PATH(testflextimer.iby)
+../init/testflextimer.ini /epoc32/data/z/system/data/testframework.ini
+../init/testflextimer.ini /epoc32/wins/c/TestFramework/testframework.ini
+../init/testflextimer.ini /epoc32/winscw/c/TestFramework/testframework.ini
+
+PRJ_TESTMMPFILES
+	
+	testflextimer.mmp
+
+PRJ_MMPFILES
+	
+//	TestFlexTimer_nrm.mmp
+
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+\agnmodel\group\agnmodel.mmp
+#if defined(MARM)
+\agnmodel\group\agsvexe.mmp
+#endif
+*/
+
+#include "../flextimerservermonitor/group/bld.inf"
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/group/testflextimer.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: MMP file for STIF Test Framework's Normal test module.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          testflextimer.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+VENDORID		VID_DEFAULT
+
+EPOCALLOWDLLDATA
+
+DEFFILE         testflextimer.def
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../flextimerservermonitor/inc
+USERINCLUDE     ../../../server/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          testflextimer.cpp 
+SOURCE          testcflextimer.cpp 
+SOURCE          inheritedcflextimer.cpp
+SOURCE			inheritedcflextimer2.cpp
+SOURCE			testflexperiodic.cpp 
+SOURCE			testrflextimer.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY			flextimerclient.lib
+LIBRARY         flextimerservermonitorclient.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/group/testflextimer.pkg	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,60 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+; 
+; Description:
+;
+; 	Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\TestFlexTimer.dll"   -   "!:\Sys\Bin\TestFlexTimer.dll"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/group/testflextimer_doxyfile.txt	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,238 @@
+# Copyright (c) 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Doxygen configuration for generating FlexTimer test
+#               specication.
+#
+#
+# Doxyfile 1.4.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = TestFlexTimer
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = \TestFlexTimer\
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+USE_WINDOWS_ENCODING   = YES
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = 
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = NO
+STRIP_FROM_PATH        = 
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+DISTRIBUTE_GROUP_DOC   = NO
+TAB_SIZE               = 8
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = NO
+EXTRACT_LOCAL_METHODS  = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = YES
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = NO
+GENERATE_TESTLIST      = NO
+GENERATE_BUGLIST       = NO
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = YES
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = \TestFlexTimer\
+FILE_PATTERNS          = *.h \
+                         *.rh \
+                         *.hrh
+RECURSIVE              = YES
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = 
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION    = YES
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = NO
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = YES
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = YES
+TOC_EXPAND             = YES
+DISABLE_INDEX          = YES
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = YES
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = YES
+RTF_OUTPUT             = Doc
+COMPACT_RTF            = YES
+RTF_HYPERLINKS         = YES
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = YES
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = NONSHARABLE_CLASS
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = YES
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+MAX_DOT_GRAPH_DEPTH    = 0
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/group/testflextimer_nrm.mmp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: MMP file for STIF Test Framework's Normal test module.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          testflextimer.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+VENDORID     	VID_DEFAULT
+
+EPOCALLOWDLLDATA
+
+DEFFILE         testflextimer.def
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../flextimerservermonitor/inc
+USERINCLUDE     ../../../server/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          testflextimer.cpp 
+SOURCE          testcflextimer.cpp
+SOURCE          inheritedcflextimer.cpp
+SOURCE			inheritedcflextimer2.cpp
+SOURCE			testflexperiodic.cpp 
+SOURCE			testrflextimer.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY			flextimerclient.lib
+LIBRARY         flextimerservermonitorclient.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/inc/inheritedcflextimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  CInheritedCFlexTimer inherits and implements CFlexTimer for testing purposes.
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+
+#ifndef CINHERITEDCFLEXTIMER_H
+#define CINHERITEDCFLEXTIMER_H
+
+// INCLUDE FILES
+#include "flextimer.h"
+
+// CLASS DECLARATION
+/**
+ *  desc
+ *
+ *  @see CFlexTimer
+ *  @see CPeriodic
+ *
+ */
+class CInheritedCFlexTimer : public CFlexTimer
+    {
+public:
+
+    /**
+     * A leaving constructor for the object.
+     * @param aPriority of the active object. If timing is critical, it
+     * should be higher than that of all other active objects owned by the
+     * scheduler.
+     * @return A pointer to a CInheritedCFlexTimer object on success.
+     * On error it leaves.
+     */
+    static CInheritedCFlexTimer* NewL( TInt aPriority,
+            TCallBack aCallBack );
+
+    /**
+     * Destructor for the object.
+     */
+    virtual ~CInheritedCFlexTimer();
+
+    /**
+     * desc
+     */
+    void SetCB( TCallBack aCallBack );
+
+    /**
+     * desc
+     */
+    TInt MyOwnConfigure( TTimeIntervalMicroSeconds32 aDelayWindow );
+
+protected:
+
+    /**
+     * Inherited from CActive.
+     */
+    virtual void RunL();
+
+private:
+
+    /**
+     * Constructs the object. The second phase of the construction.
+     */
+    void ConstructL();
+
+    /**
+     * Private constructor for the object.
+     * @param aPriority The priority of the active object. If timing is
+     * critical, it should be higher than that of all other active objects
+     * owned by the scheduler.
+     */
+    CInheritedCFlexTimer( TInt aPriority, TCallBack aCallBack );
+
+private:
+
+    /**
+     * The callback function which is called at the completion of
+     * flextimer server requests.
+     */
+    TCallBack iCallBack;
+
+    };
+
+#endif /* CINHERITEDCFLEXTIMER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/inc/inheritedcflextimer2.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  CInheritedCFlexTimer inherits and implements CFlexTimer for testing purposes.
+ *
+ */
+
+/*
+ * %version: 1 %
+ */
+
+#ifndef CINHERITEDCFLEXTIMER2_H
+#define CINHERITEDCFLEXTIMER2_H
+
+// INCLUDE FILES
+#include "flextimer.h"
+
+// CLASS DECLARATION
+/**
+ *  desc
+ *
+ *  @see CFlexTimer
+ *  @see CPeriodic
+ *
+ */
+class CInheritedCFlexTimer2 : public CFlexTimer
+    {
+public:
+
+    /**
+     * A leaving constructor for the object.
+     * @param aPriority of the active object. If timing is critical, it
+     * should be higher than that of all other active objects owned by the
+     * scheduler.
+     * @return A pointer to a CInheritedCFlexTimer2 object on success.
+     * On error it leaves.
+     */
+    static CInheritedCFlexTimer2* NewL( TInt aPriority,
+            TCallBack aCallBack, TInt aId );
+
+    /**
+     * Destructor for the object.
+     */
+    virtual ~CInheritedCFlexTimer2();
+
+    /**
+     * desc
+     */
+    void SetCB( TCallBack aCallBack );
+
+    /**
+     * desc
+     */
+    TInt MyOwnConfigure( TTimeIntervalMicroSeconds32 aDelayWindow );
+
+protected:
+
+    /**
+     * Inherited from CActive.
+     */
+    virtual void RunL();
+
+private:
+
+    /**
+     * Constructs the object. The second phase of the construction.
+     */
+    void ConstructL();
+
+    /**
+     * Private constructor for the object.
+     * @param aPriority The priority of the active object. If timing is
+     * critical, it should be higher than that of all other active objects
+     * owned by the scheduler.
+     */
+    CInheritedCFlexTimer2( TInt aPriority, TCallBack aCallBack, TInt aId );
+
+private:
+
+    /**
+     * The callback function which is called at the completion of
+     * flextimer server requests.
+     */
+    TCallBack iCallBack;
+
+    TInt iId;
+
+    };
+
+#endif /* CINHERITEDCFLEXTIMER2_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/inc/testcflextimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,972 @@
+/*
+ * ============================================================================
+ *  Name        : testflexperiodic.h
+ *  Part of     : src / testflextimer
+ *  Description : STIF test cases for CFlexPeriodic timer.
+ *  Version     : %version: 1 %
+ *
+ *  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *  All rights reserved.
+ *  This component and the accompanying materials are made available
+ *  under the terms of the License "Eclipse Public License v1.0"
+ *  which accompanies this distribution, and is available
+ *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ *  Initial Contributors:
+ *  Nokia Corporation - initial contribution.
+ *
+ *  Contributors:
+ *  Nokia Corporation
+ * ============================================================================
+ * Template version: 4.2
+ */
+
+#ifndef TESTCFLEXTIMER_H
+#define TESTCFLEXTIMER_H
+
+#include <e32base.h>
+#include "testflextimer.h"
+#include "inheritedcflextimer2.h"
+// FORWARD DECLARATIONS
+class CTestFlexTimer;
+
+class TTimerStruct
+    {
+public:
+    CInheritedCFlexTimer2 *iTimer;
+    TExtendedTestResult *iEResult;
+    TInt iTimersRunning; //For quick check that how many timers are currently running
+    TInt iCurrentlyActive; // Stupid as hell, but won't do another container
+    // This is only valid in first item and tells which item
+    // e.g CB belongs to.
+    CPeriodic *iStartTimer; // Same but this is start timer pointer.
+    TTimerStruct() :
+        iTimer(0), iEResult(0), iTimersRunning(0), iCurrentlyActive(0),
+                iStartTimer(0)
+        {
+        }
+    ;
+    };
+
+/**
+ *  STIF test cases for CFlexTimer class.
+ *  This class implements test cases for testing CFlexTimer class.
+ *
+ *  @since TB10.1
+ */
+NONSHARABLE_CLASS( CTestCFlexTimer ) : public CBase
+    {
+
+public:
+
+    /**
+     * Destructor.
+     */
+    virtual ~CTestCFlexTimer();
+
+    // Creating and firing timers - normal cases
+
+    /**
+     * @brief Create and destroy a timer - After
+     * 
+     * Test that timer can be instantiated and deleted.<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Create, start and delete timer.
+     * 
+     * @param aResult Result of the test for the FW.
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CreateAndDestroyCFlexTimerL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Create and expire a timer - After
+     * 
+     * Test that timer expires at it's max time <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - See that timeout is happening at latest possible moment.
+     * 
+     * @param aResult Result of the test for the FW.
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CreateAndExpireCFlexTimerL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Create two timers and expire those - overlapping - After 32bit
+     * 
+     * Test that two overlapping timers are fired at latest possible moment<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use overlapping time windows. (default window).<BR>
+     * - See that both timers expire when first timer expires.<BR>
+     * - Use 32bit After()
+     * 
+     * @param aResult Result of the test for the FW.
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CreateAndExpireTwoOverlappingAfterTimersL(
+            TTestResult& aResult, CTestFlexTimer *cb );
+
+    /**
+     * @brief Create two timers and expire those - overlapping - After 64bit
+     * 
+     * Test that two overlapping timers are fired at latest possible moment<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use overlapping time windows. (default window).<BR>
+     * - See that both timers expire when first timer expires.<BR>
+     * - use 64bit After().
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CreateAndExpireTwoOverlappingAfterTimers64L(
+            TTestResult& aResult, CTestFlexTimer *cb );
+
+    /**
+     * @brief Create two timers and expire those - not overlapping - After
+     * 
+     * Test that two timer that are not overlapping are fired at their own max time.<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use non-overlapping time windows. (default window).<BR>
+     * - See that both timers expire at latest possible moment.<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CreateAndExpireTwoNonOverlappingAfterTimersL(
+            TTestResult& aResult, CTestFlexTimer *cb );
+
+    /**
+     * @brief Create 2000 timers and expire those - After
+     * 
+     * Test that many timers are started and expired at rapid sequence<BR><BR>
+     * - Use class that is inherited from CFlexTimer.
+     * - Start and expire at 2000 timers. Some of having overlapping
+     * windows (default window)with each other and others not having.<BR> 
+     * - See that all timers expire within their window. Start timers so that at least 1000 timers.
+     * - are running simultaneously. <BR>
+     * - No need to check that they expire at latest possible moment
+     * - that is checked in algorithm tests.
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt HumongousAmountOfTimeridelidilidousL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Create and expire three timers - After/At/AtUTC
+     * 
+     * Test that At, After and AtUTC are handled equally<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start timers and wait for them to expire.<BR>
+     * - Start timers so that timers started with After and At
+     * overlap and timer started with AtUTC does not overlap.<BR>
+     * - See that After and At expire at the same time and that
+     * - AT UTC expires at it's max time
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CreateAndExpireThreeTimersL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    // Cancelling timers - normal cases
+
+    /**
+     * @brief Cancel a timer
+     * 
+     * See that normal cancelling works<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start timers With At, AtUTC and After.<BR>
+     * - Cancel a running timers and see that those do not expire anymore.<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt NormalCancelL( TTestResult& aResult, CTestFlexTimer *cb );
+
+    /**
+     * @brief Cancel a timer that would have triggered another timer - After
+     * 
+     * Test that canceling timer actually cancels it<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start two timers with overlapping windows.<BR>
+     * - Cancel first timer before it expires and check that
+     * second timer is fired at it's max time.
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt CancelTimerThatWouldHaveTriggeredAnotherTimerL(
+            TTestResult& aResult, CTestFlexTimer *cb );
+
+    //Configuring align window
+
+    /**
+     * @brief Configure time window - overlap 1
+     * 
+     * Test that Timers are triggered correctly after Configure<BR><BR> 
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use two timers. Set first timer having 50% window
+     * and second having 10% window.<BR>
+     * - Set timers so that first timers max window overlaps 1s with
+     * second timers window -> first timer causes second timer to be fired 
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureCTimerOverlap1L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure time window - overlap 2
+     * 
+     * Test that Timers are triggered correctly after Configure<BR><BR> 
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use 64bit IF.
+     * - Use two timers. Set first timer having 50% window
+     * and second having 10% window.<BR>
+     * - Set timers so that first timers min window overlaps 1s with
+     * second timers window -> second timer causes first timer to be fired 
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureCTimerOverlap2L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure time window - overlap 3
+     * 
+     * Test that if many Configures are used, latest is the one that remains. Also test 0 and 100% values<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use two timers. Set first timer having 0% window
+     * then overwrite that by giving 100% window to first timer.<BR>
+     * - Give second timer 0% window.<BR>
+     * - Start second timer so that it overlaps with first timer<BR>
+     * - See that first timer is fired when second is fired. 
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureCTimerOverlap3L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure time window - non-overlap
+     * 
+     * Test that Timers are triggered correctly after Configure<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use two timers. Set first timer having 0% window
+     * and second having 10% window.<BR>
+     * - Set timers so that second timers max window is 1 seconds earlier than first timers
+     * min window.<BR>
+     * - See that both timers fire at max time
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureCTimerNonOverlap1L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure time window - non-overlap 2
+     * 
+     * Test that Timers are triggered correctly after Configure<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Use two timers. Set first timer having 100% window
+     * - then overwrite that by giving first timer 50% window.<BR>
+     * - Give second timer 50% window.<BR>
+     * - Set timers so that second timers max window is 1 seconds earlier than first timers
+     * min window.<BR>
+     * - See that both timers fire at max time
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureCTimerNonOverlap2L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    //Time changes
+    /**
+     * @brief System time changes
+     * 
+     * Test that changing system time cancels AT and AtUTC timers and leaves After timers running<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start three timers. At/AtUTC/After<BR>
+     * - Change system time e.g. User::SetHomeTime()<BR>
+     * - See that At/AtUTC timers are cancelled with error code KErrAbort<BR>
+     * - See that remaining timer is fired at max time<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt SystemTimeChangesL( TTestResult& aResult, CTestFlexTimer *cb );
+
+    /**
+     * @brief Timezone changes
+     * 
+     * Test that changing time zone cancels AT and AtUTC timers and leaves After timers running<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start three timers. At/AtUTC/After<BR>
+     * - Change timezone e.g. User::SetUTCOffset()<BR>
+     * - See that At/AtUTC timers are cancelled with error code KErrAbort<BR>
+     * - See that remaining timer is fired at max time
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt TimeZoneChangesL( TTestResult& aResult, CTestFlexTimer *cb );
+
+    // Misuse of API cases
+    /**
+     * @brief call After with dumbass parameters 
+     * 
+     * Test that stupid parameters do not cause any harm<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(32bit) with interval 1. See that timer expires almost right away<BR>
+     * - Call After(32bit) with interval 0x7FFFFFFF. Cancel timer<BR>
+     * - Call After(64bit) with interval 1. See that timer expires almost right away<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt DumbAssParametersForCTimerL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call After with dumbass parameters 
+     * 
+     * Test that calling After(32bit) with zero interval panics client<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(32bit) with interval 0.
+     * - See that client is paniced
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt DumbAssParametersForCTimerZero32bitL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call After with dumbass parameters 
+     * 
+     * Test that calling After(64bit) with zero interval panics client<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(64bit) with interval 0.
+     * - See that client is paniced
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt DumbAssParametersForCTimerZero64bitL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call After with dumbass parameters 
+     * 
+     * Test that calling After(64bit) with 0xFFFFFFFFFFFFFFFF interval panics client<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(64bit) with interval 0xFFFFFFFFFFFFFFFF.
+     * - See that client is paniced
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt DumbAssParametersForCTimer64MaxL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call After with dumbass parameters 
+     * 
+     * Test that calling After(64bit) with three years interval panics client<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(64bit) with interval 93312000*1000*1000.
+     * - See that client is paniced
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt DumbAssParametersForCTimer64ThreeYearsL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call After with dumbass parameters 
+     * 
+     * Test that calling After(64bit) with one year interval panics client<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(64bit) with interval 30*1000*1000*1000*1000.
+     * - Cancel timer
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt DumbAssParametersForCTimer64OneYearL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief call After with invalid parameters 
+     * 
+     * Test that negative intervals cause panic in After()<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(32bit) with negative interval See that it causes a panic.<BR>
+     * TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AfterWithNegativeValueL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call After(64bit) with invalid parameters 
+     * 
+     * Test that negative intervals cause panic in After()<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call After(64bit) with negative interval See that it causes a panic.<BR>
+     * TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AfterWithNegativeValue64L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief call At with current time 
+     * 
+     * Test that At() with current time panics<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call At with current time. See that client panics<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AtWithCurrentTimeL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief call AtUTC with current time 
+     * 
+     * Test that AtUTC() with current time panics<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call At with current time. See that client panics<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AtUTCWithCurrentTimeL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    /**
+     * @brief call At with time three years from now 
+     * 
+     * Test that At() with three years from now panics<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call At with three years from now. See that client panics<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AtWithThreeYearsL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    /**
+     * @brief call At with time one year from now 
+     * 
+     * Test that At() with one year from now panics<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call At with one year from now. 
+     * - Cancel timer<BR>
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AtWithOneYearL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief call At/AtUTC with invalid parameters 
+     * 
+     * Test that calling At() with time that is in the past causes panic<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call At with time in the past<BR>
+     * See that it causes panic TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt AtWithTimeInThePastL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Cancel an expired timer - After
+     * 
+     * Test that calling already expired timer does not cause any harm<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start timer and wait for it to expire. After it expires
+     * cancel it<BR>
+     * - Start timer again and see that it expires normally.
+     * 
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt
+            CancelExpiredTimerL( TTestResult& aResult, CTestFlexTimer *cb );
+
+    // Hilarious Configure calls
+    /**
+     * @brief Left edge of the time window lays in the past - max check
+     * 
+     * Test that no harm is done if left side of the window lays in the past<BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure with window_size x.<BR>
+     * - Call After with interval < x.<BR>
+     * - See that timer expires when max time is reached
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureLeftSideInThePastL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Left edge of the time window lays in the past - window check
+     * 
+     * Test that window works when left side of the window lays in the past <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure with window_size x.<BR>
+     * - Call After with interval < x.<BR>
+     * - Start another timer that expires before first timer.<BR>
+     * - See that both timers expire when max time of the second timer is reached.
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureLeftSideInThePastWindowCheckL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure(32bit) with negative window_size
+     * 
+     * Test that negative window panics client <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure(32bit) with negative window_size value.<BR>
+     * - See that it causes panic TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureWithNegativeWindowSize32L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure(64bit) with negative window_size
+     * 
+     * Test that negative window panics client <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure(64bit) with negative window_size value.<BR>
+     * - See that it causes panic TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureWithNegativeWindowSize64L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Configure(32bit) with 0xFFFFFFFF window_size
+     * 
+     * Test that 0xFFFFFFFF is valid window size <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure(32bit) with 0xFFFFFFFF window_size value.<BR>
+     * - See that it causes no harm
+     *  
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureWithMaxWindow32L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief Configure(64bit) with three year window_size
+     * 
+     * Test that negative window panics client <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure(64bit) with three year window_size value.<BR>
+     * - See that it causes panic TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureWithThreeYearWindow64L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+    
+    /**
+     * @brief Configure(64bit) with max window_size
+     * 
+     * Test that negative window panics client <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Call Configure(64bit) with max window_size value.<BR>
+     * - See that it causes panic TODO what panic? Shouldn't this read in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureWithMaxWindow64L( TTestResult& aResult,
+            CTestFlexTimer *cb );
+        
+    /**
+     * @brief Call configure after starting timer
+     * 
+     * Test that configure is not used and returns error while timer is already running <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start timer.<BR>
+     * - Call Configure.<BR>
+     * - See that configure returns KErrInUse.<BR>
+     * - See that timer expires normally.
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt ConfigureWhileTimerIsInUseL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /**
+     * @brief Start timer twice
+     * 
+     * Test that client is paniced if timer is started twise <BR><BR>
+     * - Use class that is inherited from CFlexTimer.<BR>
+     * - Start timer with After()<BR>
+     * - Start timer again with At()<BR>
+     * - See that client panics with code EFlexTimerServerErrorPendingTimer //TODO referense in documentation
+     * 
+     * @param TBD
+     * @return The status of execution of the test. KErrNone if the test
+     *         was executed ok, any system wide errorcode otherwise.
+     */
+    static TInt TimerIsStartedTwiceL( TTestResult& aResult,
+            CTestFlexTimer *cb );
+
+    /*****************************************
+     * CB functions used by CFlexTimer tests *
+     /*****************************************/
+
+    /**
+     * @brief Check timer stop code and stop active scheduler
+     * 
+     * Simple function that stops the active scheduler. Checks that Error code is KErrNone
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackStopSchedulerKErrNone(
+            TAny* aArgument );
+
+    /**
+     * @brief Check timer stop code and stop active scheduler
+     * 
+     * Simple function that stops the active scheduler. Checks that Error code is KErrCancel
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackStopSchedulerKErrCancel(
+            TAny* aArgument );
+
+    /**
+     * @brief Check timer stop code and stop active scheduler
+     * 
+     * Simple function that stops the active scheduler. Checks that Error code is KErrAbort
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackStopSchedulerKErrAbort(
+            TAny* aArgument );
+
+    /**
+     * @brief Check timer stop code
+     * 
+     * Simple function that checks that Error code is KErrNone
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackKErrNone( TAny* aArgument );
+
+    /**
+     * @brief Check timer stop code
+     * 
+     * Simple function that checks that Error code is KErrAbort
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackKErrAbort( TAny* aArgument );
+
+    /**
+     * @brief Check error code and mark timestamps
+     * 
+     * Function that checks that Error code is KErrNone. ans saves timestamps
+     * @see CreateAndExpireTwoOverlappingAfterTimersL
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackKErrNoneMarkTimestamp(
+            TAny* aArgument );
+
+    /**
+     * @brief Check error code and mark timestamps
+     * 
+     * Function that checks that Error code is KErrNone. ans saves timestamps
+     * @see CreateAndExpireTwoOverlappingAfterTimersL
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt InheritedFlexTimerCallbackKErrNoneMarkTimestampStopScheduler(
+            TAny* aArgument );
+
+    /**
+     * @brief Stop active scheduler
+     * 
+     * Function that stops the active scheduler
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt StopActiveScheduler( TAny* aArgument );
+
+    /**
+     * @brief Changes system time and cancels CPeriodic given as parameter
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt ChangeSystemTime1sAndCancel( TAny* aArgument );
+
+    /**
+     * @brief Changes system time and cancels CPeriodic given as parameter
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt ChangeTimeZoneAndCancel( TAny* aArgument );
+
+    /**
+     * @brief Changes system time and cancels CPeriodic given as parameter
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt ChangeSecureTimeAndCancel( TAny* aArgument );
+
+    /**
+     * @brief cancel CFlexTimer given as parameter
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CancelCFlexTimer( TAny* aArgument );
+
+    /**
+     * @brief See that expiry reason is correct. Array versio
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt StopSchedulerKErrNoneArray( TAny* aArgument );
+
+    /**
+     * @brief cancel CFlexTimer given as parameter also cancel CPeriodic
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CancelCFlexTimerCancelPeriodic( TAny* aArgument );
+    /**
+     * @brief cancel CFlexTimer given as parameter
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CancelCFlexTimerArray( TAny* aArgument );
+    /**
+     * @brief cancel CFlexTimer given as parameter and stops active scheduler
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CancelCFlexTimerAndStopActiveScheduler( TAny* aArgument );
+
+    /**
+     * @brief stops activescheduler and cancels it self
+     * 
+     * N/A
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt StopSchedulerAndCancel( TAny* aArgument );
+
+    /**
+     * @brief Not called CB
+     * 
+     * Fails if gets called
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt NotCalledCB( TAny* aArgument );
+    
+    /**
+     * @brief Callback function, that calls StartTimerAndAddToList
+     * 
+     * -
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CTestCFlexTimer::StartTimerAndAddToListCB( TAny* aArgument );
+    /**
+     * @brief Start random timer and add it to list given as parameter
+     * 
+     * -
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt StartTimerAndAddToList(
+        RArray<TTimerStruct>* aArgument, TInt aTimers );
+
+    /**
+     * @brief Stop timer and mark time to list given as parameter
+     * 
+     * -
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt StopTimer( TAny* aArgument );
+    /**
+     * @brief Try to configure timer and see that KErrInUse is returned
+     * 
+     * -
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt ConfigureKErrInUseArray( TAny* aArgument );
+
+    /**
+     * @brief start timer again
+     * 
+     * -
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt StartTimerAgainArray( TAny* aArgument );
+    
+    /**
+     * @brief Create two overlapping timers and start, run and expire them
+     * during high CPU load.
+     * 
+     * Test steps:<BR>
+     * 1. Create CFlexTimer_1, (inteval = 10s, window=0.2*10s (default))<BR>
+     * 2. Create CFlexTimer_2, (inteval = 8s, window=0.2*8s (default))<BR>
+     * 3. Start 99% CPU Load<BR>
+     * 4. Start timers<BR>
+     * 5. Wait timers to expire<BR>
+     * 6. Stop CPU load<BR>
+     * 5. Check that timers expired within ~8sec<BR>
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL(
+            TTestResult& aResult, CTestFlexTimer *cb );
+    
+    /**
+     * @brief Create 100  timers and start, run and expire them during high
+     *  CPU load.
+     * 
+     * Test steps:<BR>
+     * 1. Create 100 random timers with random interval and window.<BR>
+     * 3. Start 98% CPU Load<BR>
+     * 4. Start timers<BR>
+     * 5. Wait timers to expire<BR>
+     * 6. Stop CPU load<BR>
+     * 5. Check that timers expired within expected limits.<BR>
+     * 
+     * @param N/A
+     * @return N/A
+     */
+    static TInt CTestCFlexTimer::CpuLoadManyTimersL(
+            TTestResult& aResult, CTestFlexTimer *cb );
+private:
+
+    /**
+     * Constructor is private to prevent instantiation of the class. 
+     */
+    CTestCFlexTimer();
+
+    };
+
+#endif // TESTCFLEXTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/inc/testflexperiodic.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,775 @@
+/*
+* ============================================================================
+*  Name        : testflexperiodic.h
+*  Part of     : src / testflextimer
+*  Description : STIF test cases for CFlexPeriodic timer.
+*  Version     : %version: 1 %
+*
+*  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+*  All rights reserved.
+*  This component and the accompanying materials are made available
+*  under the terms of the License "Eclipse Public License v1.0"
+*  which accompanies this distribution, and is available
+*  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+*  Initial Contributors:
+*  Nokia Corporation - initial contribution.
+*
+*  Contributors:
+*  Nokia Corporation
+* ============================================================================
+* Template version: 4.2
+*/
+
+#ifndef TESTFLEXPERIODIC_H
+#define TESTFLEXPERIODIC_H
+
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CFlexPeriodic;
+
+/**
+ *  STIF test cases for CFlexPeriodic class.
+ *  This class is only a container for STIF test cases - it should NOT be
+ *  instantiated, just call the static functions.
+ *
+ *  @lib testflextimer.lib
+ *  @since TB10.1
+ */
+NONSHARABLE_CLASS( CTestFlexPeriodic ) : public CBase
+    {
+
+/**
+ * Data for restarting timer in callback function.
+ */
+struct TRestartInfo
+    {
+    CFlexPeriodic* iTimer;                      ///< Pointer to the timer
+    TInt iFirstTicksLeft;                       ///< Number of times the 1st timer settings are run
+    RArray<TTime>* iFirstTimestamps;            ///< Timestamps for the 1st timer settings
+    RArray<TTime>* iSecondTimestamps;           ///< Timestamps for the 2nd timer settings
+    TTimeIntervalMicroSeconds iSecondInterval;  ///< Interval for the 2nd timer settings
+    };
+
+/**
+ * Data for CFlexPeriodic::Configure() tests
+ */
+struct TConfigureInfo
+    {
+    CFlexPeriodic* iTimer;   ///< Pointer to the timer under testing
+    TInt iDelayWindow;       ///< value for delay window to be set
+    TInt iIntervalWindow;    ///< value for interval window to be set
+    TInt iConfigResult32;    ///< Result of configure(32 bit)
+    TInt iConfigResult64;    ///< Result of configure(64 bit)
+    };
+
+/**
+ * Data for running a test case in own thread
+ */
+struct TTestCaseArguments
+    {
+    TInt (*iTestFunction)( TTestResult&, CTestFlexTimer* ); ///< Function pointer to the test case to be run
+    TTestResult& iResult;                                   ///< The result of the test (argument for the test case)
+    CTestFlexTimer* iCallback;                              ///< Pointer to the STIF test class (argument for the test case)
+    };
+
+public:
+
+    /**
+    * Destructor.
+    */
+    virtual ~CTestFlexPeriodic();
+
+    /**
+    * @brief Create and expire CFlexPeriodic timer.
+    * 
+    * Create and start one CFlexPeriodic timer with 1 sec delay and interval 
+    * wait for 5 secs. Check that the timer has been expired at correct times.
+    * 
+    * Timer expiration times (sec):
+    * 1, 2, 3, 4, ...
+    * 
+    * Tests:
+    * - CFlexPeriodic::NewL()
+    * - CFlexPeriodic::Start() 32-bit
+    * - CFlexPeriodic::Cancel()
+    * - CFlexPeriodic::~CFlexPeriodic()
+    * - Expiration of CFlexPeriodic timers
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartOneTimerL( TTestResult& aResult, 
+                                CTestFlexTimer* aCallback );
+    
+    /**
+    * @brief Create and expire CFlexPeriodic timer with Error CB.
+    * 
+    * Create and start one CFlexPeriodic timer with 1 sec delay and interval 
+    * wait for 5 secs. Give timer also Error CB argument.
+    * Check that the timer has been expired at correct times.
+    * If callback gets called case panics.
+    * 
+    * Timer expiration times (sec):
+    * 1, 2, 3, 4, ...
+    * 
+    * Tests:
+    * - CFlexPeriodic::NewL()
+    * - CFlexPeriodic::Start() 32-bit
+    * - CFlexPeriodic::Cancel()
+    * - CFlexPeriodic::~CFlexPeriodic()
+    * - Expiration of CFlexPeriodic timers
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartOneTimerWithErrorCbL( TTestResult& aResult, 
+                                CTestFlexTimer* aCallback );
+    
+    /**
+    * @brief Restart CFlexPeriodic in callback function. 
+    *
+    * Start a periodic timer with 1 sec delay and interval.
+    *
+    * After 2 expiration cancel and start the timer in its callback function
+    * with 2 secs delay and interval.
+    * 
+    * Timer expiration times (sec):
+    * 1, 2, 4, 6, 8, ...
+    * 
+    * Tests:
+    * - CFlexPeriodic::NewL()
+    * - CFlexPeriodic::Start() 64-bit
+    * - CFlexPeriodic::Cancel()
+    * - CFlexPeriodic::~CFlexPeriodic()
+    * - Expiration of CFlexPeriodic timers
+    * - Cancelling and starting timer in callback function
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CallbackRestartL( TTestResult& aResult, 
+                                  CTestFlexTimer* aCallback ); 
+
+    /**
+    * @brief Configure window sizes, 32 bit
+    * 
+    * Start 2 timers:
+    * T1:
+    * - delay       3.0 sec, window 0.0 sec
+    * - interval    2.0 sec, window 1.5 sec
+    * T2:
+    * - delay       3.5 sec, window 1.5 sec
+    * - interval    1.0 sec, window 0.0 sec
+    *
+    * Both timers shoud expire at (sec)
+    * 3.0, 4.0, 5.0, 6.0, ...
+    * 
+    * Functionality of delay window is tested in sec 3.0 expiration and
+    * functionality of interval window is tested in other expirations.
+    *
+    * Tests:
+    * - CFlexPeriodic::NewL()
+    * - CFlexPeriodic::Configure() 32-bit
+    * - CFlexPeriodic::Start() 32-bit
+    * - CFlexPeriodic::Cancel()
+    * - CFlexPeriodic::~CFlexPeriodic()
+    * - Expiration of CFlexPeriodic timers
+    * - Delay
+    * - Interval
+    * - Delay window
+    * - Interval window  
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWindow32L( TTestResult& aResult,
+                                    CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Configure window sizes, 64 bit
+    * 
+    * @see ConfigureWindow32L for test setup.
+    * 
+    * Tests:
+    * - CFlexPeriodic::NewL()
+    * - CFlexPeriodic::Configure() 64-bit
+    * - CFlexPeriodic::Start() 64-bit
+    * - CFlexPeriodic::Cancel()
+    * - CFlexPeriodic::~CFlexPeriodic()
+    * - Expiration of CFlexPeriodic timers
+    * - Delay
+    * - Interval
+    * - Delay window
+    * - Interval window  
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWindow64L( TTestResult& aResult,
+                                    CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Configure window sizes, 32 bit and 64 bit
+    * 
+    * @see ConfigureWindow32L for test setup.
+    * 
+    * Tests:
+    * - CFlexPeriodic::NewL()
+    * - CFlexPeriodic::Configure() 32-bit
+    * - CFlexPeriodic::Configure() 64-bit
+    * - CFlexPeriodic::Start() 32-bit
+    * - CFlexPeriodic::Start() 64-bit
+    * - CFlexPeriodic::Cancel()
+    * - CFlexPeriodic::~CFlexPeriodic()
+    * - Expiration of CFlexPeriodic timers
+    * - Delay
+    * - Interval
+    * - Delay window
+    * - Interval window  
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWindowMixL( TTestResult& aResult,
+                                     CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Configure timer after it has been started.
+    * 
+    * Start two timers:
+    * T1:
+    * - delay 1 microsecond, window 0
+    * - interval 1 sec, window 0
+    * 
+    * T2:
+    * - delay 2 sec, default window
+    * - interval 2 sec, default window
+    * 
+    * Try to configure T2 with 1.5 sec delay and interval windows by both
+    * 32 bit and 64 bit Configure(). Check that configure returns KErrInUse
+    * and it has not changed the window sizes. The timer expirations should be
+    * T1: 1, 2, 3, 4, 5, 6, 7, 8, ...
+    * T2:    2,    4,    6,    8, ...  
+    * 
+    * Cancel the timer T2 and set its callback function to call Configure() 
+    * (32 bit and 64 bit versions) while the timer is running. Check that both
+    * configurations return KErrInUse
+    *
+    * Cancel timer T2 and configure its delay and interval windows to 1.5 sec.
+    * Let the timer(s) run a while and check that the timer expirations are:
+    * T1: ..., 10, 11, 12, 13, ...
+    * T2: ..., 10, 11, 12, 13, ...
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureAfterStartL( TTestResult& aResult,
+                                      CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start a running timer.
+    * 
+    * Test should panic with E32USER-CBase 42 (attempt to active CActive when 
+    * a request is still outstanding).
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartAfterStartL( TTestResult& aResult,
+                                  CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start a running timer in its callback function.
+    * 
+    * Test should panic with E32USER-CBase 42 (attempt to active CActive when 
+    * a request is still outstanding).
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartInCallbackL( TTestResult& aResult,
+                                  CTestFlexTimer* aCallback );
+
+    /**
+    * Start timer with negative delay (32 bit).
+    * 
+    * Start should panic with CFlexPeriodic 6 (EFlexPeriodicDelayLessThanZero)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithNegativeDelay32L( TTestResult& aResult, 
+                                           CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Start timer with zero interval (32 bit).
+    * 
+    * Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithZeroInterval32L( TTestResult& aResult, 
+                                          CTestFlexTimer*  aCallback  );
+    
+    /**
+    * @brief Start timer with negative interval (32 bit).
+    * 
+    * Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithNegativeInterval32L( TTestResult& aResult, 
+                                              CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Start timer with negative delay (64 bit).
+    * 
+    * Start should panic with CFlexPeriodic 6 (EFlexPeriodicDelayLessThanZero)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithNegativeDelay64L( TTestResult& aResult, 
+                                          CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Start timer with zero interval (64 bit).
+    * 
+    * Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithZeroInterval64L( TTestResult& aResult, 
+                                          CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Start timer with negative interval (64 bit).
+    * 
+    * Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithNegativeInterval64L( TTestResult& aResult, 
+                                              CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Configure timer with negative delay window (32 bit).
+    * 
+    * Configure should panic with CFlexPeriodic 9 
+    * (EFlexPeriodicIntervalWindowLessThanZero)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWithNegativeDelayWindow32L( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Configure timer with negative interval window (32 bit).
+    * 
+    * Configure should panic with CFlexPeriodic 8 
+    * (EFlexPeriodicDelayWindowLessThanZero)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWithNegativeIntervalWindow32L( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Configure timer with negative delay window (64 bit).
+    * 
+    * Configure should panic with CFlexPeriodic 9 
+    * (EFlexPeriodicIntervalWindowLessThanZero)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWithNegativeDelayWindow64L( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Configure timer with negative interval window (64 bit).
+    * 
+    * Configure should panic with CFlexPeriodic 8 
+    * (EFlexPeriodicDelayWindowLessThanZero)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ConfigureWithNegativeIntervalWindow64L( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    
+    /**
+    * @brief Test timer start allowed value range.
+    * 
+    * Start timers with following parameters:
+    * 
+    * T1:
+    * - Configure (32 bit): delay window 1 sec, interval window 1 sec
+    * - Start (32 bit): delay 0 microseconds, interval 1 sec
+    * 
+    * T2:
+    * - Configure (32 bit): delay window 1 sec, interval window 1 sec
+    * - Start (32 bit): delay 0x7FFFFF microseconds, interval 1 sec
+    * 
+    * T3:
+    * - Configure (32 bit): delay window 1 sec, interval window 1 sec
+    * - Start (32 bit): delay 1 sec, interval 0 microseconds
+    * 
+    * T4:
+    * - Configure (32 bit): delay window 1 sec, interval window 1 sec
+    * - Start (32 bit): delay 1 sec, interval 0x7FFFFF microseconds
+    *
+    * T5:
+    * - Configure (64 bit): delay window 1 sec, interval window 1 sec
+    * - Start (64 bit): delay 0 microseconds, interval 1 sec
+    * 
+    * T6:
+    * - Configure (64 bit): delay window 1 sec, interval window 1 sec
+    * - Start (64 bit): delay 1 year, interval 1 sec
+    * 
+    * T7:
+    * - Configure (64 bit): delay window 1 sec, interval window 1 sec
+    * - Start (64 bit): delay 1 sec, interval 0 microseconds
+    * 
+    * T8:
+    * - Configure (64 bit): delay window 1 sec, interval window 1 sec
+    * - Start (64 bit): delay 1 sec, interval 1 year
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithMinAndMaxL( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    
+    /**
+    * @brief Start timer with maximum delay (64 bit), 0x7FFFFFFFFFFFFFFF.
+    * 
+    * Start should panic with  CFlexPeriodic 24 
+    * (EFlexTimerServerIllegalTimerValue)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithMaximumDelay64L( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Start timer with maximum interval (64 bit), 0x7FFFFFFFFFFFFFFF.
+    * 
+    * Start should panic with  CFlexPeriodic 24 
+    * (EFlexTimerServerIllegalTimerValue)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithMaximumInterval64L( 
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+    
+    /**
+    * @brief Start timer with NULL callback function (32 bit)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithNullCallBack32L(
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    /**
+    * @brief Start timer with NULL callback function (64 bit)
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt StartWithNullCallBack64L(
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+    
+    /**
+    * @brief Crash client with active periodic flexible timer.
+    * 
+    * Start two timers in separate threads:
+    * T1: delay 1 sec, interval 1 sec with default windows
+    * T2: delay 1 sec, interval 1 sec with default windows
+    * 
+    * Panic timer T1's thread after 3 sec.
+    * 
+    * Cancel T2 after 5 sec and check that it had worked correctly.
+    * Implementation of T2 uses test case StartOneTimerL().
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ClientCrashL(
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+
+private:
+
+    /**
+    * Constructor is private to prevent instantiation of the class. 
+    */
+    CTestFlexPeriodic();
+
+    /**
+     * Run active scheduler for given time.
+     * @param aPeriod Time to run active scheduler.
+     */
+    static void WaitL( TTimeIntervalMicroSeconds32 aPeriod );
+
+    /**
+     * Stop the active scheduler. A function for TCallBack.
+     * @param aArgument Not used.
+     * @return KErrNone. Always.
+     */
+    static TInt StopScheduler( TAny* aArgument );
+
+
+    /**
+     * Do nothing. A function for TCallBack.
+     * @param aArgument Not used.
+     * @return KErrNone.
+     */
+    static TInt DoNothing( TAny* aArgument );
+    
+    /**
+     * Panics testcase if get called. A function for TCallBack.
+     * @param aArgument Not used.
+     * @return KErrNone.
+     */
+    static TInt PanicClient( TAny* aArgument );
+    
+    /**
+     * Add current time to given array. A function for TCallBack.
+     * @param aArgument Timestamp storage, type: RArray<TTime>*
+     * @return KErrNone.
+     */
+    static TInt AddTimestamp( TAny* aArgument );
+
+    /**
+     * Restart the given timer. A function for TCallBack.
+     * @param aArgument The restart data, type: TRestartInfo*
+     * @return KErrNone.
+     */
+    static TInt RestartTimer( TAny* aArgument );
+
+    /**
+     * Configure timer without cancellation in callback. A function for 
+     * TCallBack.
+     * @param aArgument The conficure data, type: TConfigureInfo*
+     * @return KErrNone.
+     */
+    static TInt ConfigureTimer( TAny* aArgument );
+
+    /**
+     * Start timer without cancellation in callback. A function for TCallBack.
+     * @param aArgument The timer, type: CFlexPeriodic*
+     * @return KErrNone.
+     */
+    static TInt StartTimer( TAny* aArgument );
+
+    /**
+     * Verify that the timestamps are expired at maximum window
+     * @param aTimestamps An array of times
+     * @param aDelay Requested delay of the 1st time
+     * @param aInterval Requested delay from the 2nd time
+     * @param aDelayWindow Time how much 1st time can be early
+     * @param aIntervalWindow Time how much times can be early from the 2nd time 
+     * @return ETrue if all timestamps are in given delay
+     */
+    static TBool AreTimestampsAtWindow( 
+        const RArray<TTime>& aTimestamps,
+        const TTimeIntervalMicroSeconds32& aDelay,
+        const TTimeIntervalMicroSeconds32& aInterval,
+        const TTimeIntervalMicroSeconds32& aDelayWindow,
+        const TTimeIntervalMicroSeconds32& aIntervalWindow );
+
+    /**
+     * Verify that the timestamps are expired at maximum window
+     * @param aTimestamps An array of times
+     * @param aDelay Requested delay of the 1st time
+     * @param aInterval Requested delay from the 2nd time
+     * @param aDelayWindow Time how much 1st time can be early
+     * @param aIntervalWindow Time how much times can be early from the 2nd time 
+     * @return ETrue if all timestamps are in given delay
+     */
+    static TBool AreTimestampsAtWindow( 
+        const RArray<TTime>& aTimestamps,
+        const TTimeIntervalMicroSeconds& aDelay,
+        const TTimeIntervalMicroSeconds& aInterval,
+        const TTimeIntervalMicroSeconds& aDelayWindow,
+        const TTimeIntervalMicroSeconds& aIntervalWindow );
+
+    /**
+     * Compare two arrays of timestamps.
+     * @param aLeft Array of timestamps to be compared
+     * @param aRight Array of timestamps to be compared
+     * @return ETrue if the arrays has the same timestamps, EFalse otherwise
+     */
+    static TBool AreTimestampsSame( 
+        const RArray<TTime>& aLeft, 
+        const RArray<TTime>& aRight );
+
+    /**
+     * Parameter types of two timers are templated, so, 32 bit and 64 bit
+     * interfaces can be tested without duplicated source code.
+     * 
+     * Possible values for template are:
+     * - TTimeIntervalMicroSeconds
+     * - TTimeIntervalMicroSeconds32
+     */
+    template <class firstType, class secondType> 
+    static TInt ConfigureWindowL( TTestResult& aResult );
+
+    /**
+     * Template function for NOK API test cases.
+     * 
+     * Types for CFlexPeriodic::Start() and CFlexPeriodic::Configure() are
+     * templated, so, 32 bit and 64 bin interfaces can be tested without
+     * duplicated code.
+     * 
+     * Function creates a flexible periodic timer, configures is, starts it.
+     * After one second the timer will be cancelled and destroyed.
+     * 
+     * Possible values for configureType and startType are:
+     * - TTimeIntervalMicroSeconds
+     * - TTimeIntervalMicroSeconds32
+     *
+     * @param aDelay Value for timer's delay in start
+     * @param aInterval Value for timer's interval in start
+     * @param aDelayWindow Value for timer's delay window in configure
+     * @param aIntervalWindow Value for timer's interval window in configure
+     */
+    template <class configureType, class startType>
+    static void ConfigureAndStartTimerL( 
+        RArray<TTime>& aTimestamps,
+        TInt64 aDelay,
+        TInt64 aInterval,
+        TInt64 aDelayWindow,
+        TInt64 aIntervalWindow );
+
+    /**
+    * Start timer with NULL callback function
+    * 
+    * Possible values for startType are:
+    * - TTimeIntervalMicroSeconds
+    * - TTimeIntervalMicroSeconds32
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    template <class startType>
+    static TInt StartWithNullCallBackL(
+        TTestResult& aResult, 
+        CTestFlexTimer*  aCallback  );
+    
+    /**
+    * Run test case in own thread
+    * 
+    * @param aThread The thread in which the test case is run
+    * @param aArguments Arguments for running a test case
+    * @return The status of execution of the test
+    */
+    static TInt RunInThread( 
+        RThread& aThread,
+        TTestCaseArguments& aArguments );
+
+    /**
+    * Start running a thread. A function of format TThreadFunction.
+    * Create trap harness for the thread and call RunTestCaseL()
+    * 
+    * @param aArgument Test case data, type: TTestCaseArguments
+    * @return The status of running the thread
+    */
+    static TInt RunTestCase( TAny* aArgument );
+
+    /**
+    * The second phase of start running a thread.
+    * Initialize scheduler and start the test case.
+    * 
+    * @param aArgument Test case data, type: TTestCaseArguments
+    */
+    static void RunTestCaseL( TAny* aArgument );
+
+    /**
+    * Panic thread after a while. 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt DoPanicL( TTestResult& aResult, CTestFlexTimer*  aCallback  );
+
+    };
+
+#endif // TESTFLEXPERIODIC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/inc/testflextimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,373 @@
+/*
+* Copyright (c) 2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: STIF normal test module declaration
+*
+*/
+
+#ifndef TESTFLEXTIMER_H
+#define TESTFLEXTIMER_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+#include <NormalHardcodedAssert.h>
+
+// MACROS
+#define TEST_MODULE_VERSION_MAJOR 0
+#define TEST_MODULE_VERSION_MINOR 0
+#define TEST_MODULE_VERSION_BUILD 0
+
+// Logging path
+_LIT( KTestFlexTimerLogPath, "\\logs\\testframework\\TestFlexTimer\\" ); 
+// Log file
+_LIT( KTestFlexTimerLogFile, "TestFlexTimer.txt" ); 
+_LIT( KTestFlexTimerLogFileWithTitle, "TestFlexTimer_[%S].txt" );
+
+_LIT( KTestFlexTimerPanicCategory, "FLEX-TEST" );
+
+// Function pointer related internal definitions
+#define GETPTR &  
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+
+// Forward declaration
+class CTestFlexTimer;
+
+// A typedef for function that does the actual testing,
+// function is a type 
+// TInt CDemoModule::<NameOfFunction> ( TTestResult& aResult, CTestFlexTimer *cb )
+typedef TInt (*TestFunction)(TTestResult&, CTestFlexTimer*);    
+
+const TInt KTimerAccuracyMicroSeconds = 1000 * 1000; //1s - accuracy of symbian At timer.
+const double KDefaultWindowMultiplier = 0.2; //default window. defined in flextimersession.cpp 
+const TUint KTickInMicroSeconds( 1000000 / 64 ); // One tick = 1/64 sec
+
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC           iCaseName;    
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {        
+        };
+    };
+
+//Exteded result that can "return" also status code to CB function 
+class TExtendedTestResult
+    {
+    public:
+        TTestResult *iTestResult; //the real test result
+        TInt iStatusCode; //Return code from timer
+        TBool iCaseAlreadyFailed;
+        TInt iTimerID;
+        TInt64 iTimerStartedTime;
+        TInt64 iTimerStoppedTime;
+        TInt64 iTimerExpiryTime;
+
+    TExtendedTestResult(TTestResult *aResult) : iTestResult( aResult ), iStatusCode(0), iCaseAlreadyFailed(EFalse), 
+            iTimerID(0), iTimerStartedTime(0), iTimerStoppedTime(0) {};
+    };
+// CLASS DECLARATION
+
+/**
+*  This a TestFlexTimer class.
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CTestFlexTimer) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CTestFlexTimer* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTestFlexTimer();
+  
+    public: // Functions from base classes
+
+        
+        /**
+        * From CTestModuleBase InitL is used to initialize the TestFlexTimer. 
+        *       It is called once for every instance of TestFlexTimer after
+        *       its creation.
+        * @since ?Series60_version
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of TestFlexTimer.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from TestFlexTimer. 
+        * @since ?Series60_version
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since ?Series60_version
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& /* aFailureType */,
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; User may add implementation for OOM test 
+        * environment initialization. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL. User may add implementation 
+        * for OOM test warning handling. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */);
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+
+        /**
+         * Method used to log version of test module
+         */
+        void SendTestModuleVersion();
+
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTestFlexTimer();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Check for settings and create logger with test case title in file name.
+        */
+        void CreateTitleLoggerL(void);
+
+        /**
+        * Check for logger settings and delete title logger.
+        */
+        void DeleteTitleLogger(void);
+
+        /**
+         * Function returning test case name and pointer to test case function.
+         * @since ?Series60_version
+         * @param aCaseNumber test case number
+         * @return TCaseInfo 
+         */
+        const TCaseInfo Case( const TInt aCaseNumber ) const;
+
+        /**
+        * Start monitoring FlexTimer server crashes
+        * 
+        * @param aResult The result of the test.
+        * @param aCallback Pointer to the STIF test class
+        * @return The status of execution of the test. KErrNone if the test
+        *         was executed ok, any system wide errorcode otherwise.
+        */
+        static TInt StartServerMonitoringL(
+            TTestResult& aResult, 
+            CTestFlexTimer* aCallback );
+
+        /**
+        * Stop monitoring FlexTimer server crashes and fail the test case if
+        * a crash has happened.
+        * 
+        * @param aResult The result of the test.
+        * @param aCallback Pointer to the STIF test class
+        * @return The status of execution of the test. KErrNone if the test
+        *         was executed ok, any system wide errorcode otherwise.
+        */
+        static TInt StopServerMonitoringL(
+            TTestResult& aResult, 
+            CTestFlexTimer* aCallback );
+        
+        /**
+        * Start second FlexTimerServer. 
+        * 
+        * Increase test coverage by testing server side destructors.
+        * 
+        * Starting of the server fails with panic "FlexTimerServer" 23 
+        * (EFlexTimerServerStartServer).
+        * 
+        * @param aResult The result of the test.
+        * @param aCallback Pointer to the STIF test class
+        * @return The status of execution of the test. KErrNone if the test
+        *         was executed ok, any system wide errorcode otherwise.
+        */
+        static TInt StartSecondServerL(
+            TTestResult& aResult, 
+            CTestFlexTimer* aCallback );
+        
+        /**
+        * Changes Test client thread priority to EPriorityMuchMore
+        * 
+        * @param aResult The result of the test, always Passed.
+        * @param aCallback Pointer to the STIF test class
+        * @return The status of execution of the test. KErrNone always
+        */
+        static TInt SetThreadPriorityMuchMore(
+            TTestResult& aResult, 
+            CTestFlexTimer* aCallback );
+        
+        /**
+        * Changes Test client thread priority to EPriorityNormal
+        * 
+        * @param aResult The result of the test, always Passed.
+        * @param aCallback Pointer to the STIF test class
+        * @return The status of execution of the test. KErrNone always
+        */
+        static TInt SetThreadPriorityNormal(
+            TTestResult& aResult, 
+            CTestFlexTimer* aCallback );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+        CStifLogger * iLog;
+
+        // Standard logger
+        CStifLogger *iStdLog;
+
+        // Logger for currently running test case
+        CStifLogger *iTCLog;
+        
+        // Flag saying if test case title should be added to log file name
+        TBool iAddTestCaseTitleToLogName;
+        
+        // Flag saying if test module version was already sent
+        TBool iVersionLogged;
+
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+        
+        //CTimer CB failed case
+        TBool iCTimerCBFailedCase;
+        
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // TESTFLEXTIMER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/inc/testrflextimer.h	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,520 @@
+/*
+* ============================================================================
+*  Name        : testrflextimer.h
+*  Part of     : src / testflextimer
+*  Description : STIF test cases for RFlexTimer
+*  Version     : %version: 1 %
+*
+*  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+*  All rights reserved.
+*  This component and the accompanying materials are made available
+*  under the terms of the License "Eclipse Public License v1.0"
+*  which accompanies this distribution, and is available
+*  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+*  Initial Contributors:
+*  Nokia Corporation - initial contribution.
+*
+*  Contributors:
+*  Nokia Corporation
+* ============================================================================
+* Template version: 4.2
+*/
+
+#ifndef TESTRFLEXTIMER_H
+#define TESTRFLEXTIMER_H
+
+
+#include <e32base.h>
+
+/**
+ *  STIF test cases for RFlexTimer class.
+ *  This class is only a container for STIF test cases - it should NOT be
+ *  instantiated, just call the static functions.
+ *
+ *  @lib testflextimer.lib
+ *  @since TB10.1
+ */
+class CTestRFlexTimer : public CBase
+    {
+
+public:
+
+    /**
+    * Destructor.
+    */
+    virtual ~CTestRFlexTimer();
+
+    /**
+    * @brief Start a timer using After (32 bit) and wait it to expire
+    * 
+    * Open RFlexTimer handle and connect to the server. Set timer to expire
+    * after 3 secs. Close the handle and check that the expiration is done
+    * at correct time.
+    * 
+    * Tests:
+    * - RFlexTimer::RFlexTimer()
+    * - RFlexTimer::Connect()
+    * - RFlexTimer::After() 32 bit
+    * - RFlexTimer::Close()
+    * - RFlexTimer::~RFlexTimer()
+    * - Expiration of timer
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ExpireAfter32L( TTestResult& aResult,
+                                CTestFlexTimer* aCallback );
+
+
+    /**
+    * @brief Start a timer using After (64 bit) and wait it to expire
+    * 
+    * Open RFlexTimer handle and connect to the server. Set timer to expire
+    * after 3 secs. Close the handle and check that the expiration is done
+    * at correct time.
+    * 
+    * Tests:
+    * - RFlexTimer::RFlexTimer()
+    * - RFlexTimer::Connect()
+    * - RFlexTimer::After() 64 bit
+    * - RFlexTimer::Close()
+    * - RFlexTimer::~RFlexTimer()
+    * - Expiration of timer
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ExpireAfter64L( TTestResult& aResult,
+                                CTestFlexTimer* aCallback );
+
+
+    /**
+    * @brief Start a timer using AfterTicks and wait it to expire
+    *
+    * Open RFlexTimer handle and connect to the server. Set timer to expire
+    * after 192 ticks (3 secs). Close the handle and check that the 
+    * expiration is done at correct time.
+    * 
+    * Tests:
+    * - RFlexTimer::RFlexTimer()
+    * - RFlexTimer::Connect()
+    * - RFlexTimer::AfterTicks()
+    * - RFlexTimer::Close()
+    * - RFlexTimer::~RFlexTimer()
+    * - Expiration of timer
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ExpireAfterTicksL( TTestResult& aResult,
+                                   CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start a timer using At and wait it to expire
+    *
+    * Open RFlexTimer handle and connect to the server. Set timer to expire
+    * after 3 secs from now. Close the handle and check that the expiration is
+    * done at correct time.
+    * 
+    * Tests:
+    * - RFlexTimer::RFlexTimer()
+    * - RFlexTimer::Connect()
+    * - RFlexTimer::At()
+    * - RFlexTimer::Close()
+    * - RFlexTimer::~RFlexTimer()
+    * - Expiration of timer
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ExpireAtL( TTestResult& aResult,
+                           CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start a timer using AtUTC and wait it to expire
+    *
+    * Open RFlexTimer handle and connect to the server. Set timer to expire
+    * after 3 secs from now. Close the handle and check that the expiration is
+    * done at correct time.
+    * 
+    * Tests:
+    * - RFlexTimer::RFlexTimer()
+    * - RFlexTimer::Connect()
+    * - RFlexTimer::AtUTC()
+    * - RFlexTimer::Close()
+    * - RFlexTimer::~RFlexTimer()
+    * - Expiration of timer
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ExpireAtUtcL( TTestResult& aResult,
+                              CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start timer using After (32 bit) without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt After32WithoutConnect( TTestResult& aResult,
+                                       CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start timer using After (64 bit) without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt After64WithoutConnect( TTestResult& aResult,
+                                       CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start timer using AfterTicks without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt AfterTicksWithoutConnect( TTestResult& aResult,
+                                          CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start timer using At without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt AtWithoutConnect( TTestResult& aResult,
+                                  CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Start timer using AtUtc without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt AtUtcWithoutConnect( TTestResult& aResult,
+                                     CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Configure (32 bit) timer without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt Configure32WithoutConnect( TTestResult& aResult,
+                                           CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Configure (64 bit) timer without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt Configure64WithoutConnect( TTestResult& aResult,
+                                           CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Cancel timer using RFlexTimer without connecting to the server first.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * KERN-EXEC 0.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CancelWithoutConnect( TTestResult& aResult,
+                                      CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Set timer twice by After.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer).
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CallAfterTwiceL( TTestResult& aResult,
+                                 CTestFlexTimer* aCallback );
+    
+
+    /**
+    * @brief Set timer twice by AfterTicks.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer).
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CallAfterTicksTwiceL( TTestResult& aResult,
+                                      CTestFlexTimer* aCallback );
+    
+    /**
+    * @brief Set timer twice by At.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer).
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CallAtTwiceL( TTestResult& aResult,
+                              CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Set timer twice by AtUTC.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer).
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CallAtUtcTwiceL( TTestResult& aResult,
+                                 CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Connect to timer server twice.
+    *
+    * This tests illeagal usage of the interface and it'll panic with 
+    * RFlexTimer 32 (EFlexTimerAlreadyConnected).
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CallConnectTwiceL( TTestResult& aResult,
+                                   CTestFlexTimer* aCallback );
+
+    
+    /**
+    * @brief Reconnect to timer server.
+    *
+    * Connect, close and connect again the handle.
+    * 
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ReconnectL( TTestResult& aResult,
+                            CTestFlexTimer* aCallback );
+
+    
+    /**
+    * @brief Cancel timer using RFlexTimer without starting it first.
+    *
+    * This tests a leagal uage of the interface. Timer can be cancelled 
+    * without setting it first.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt CancelWithoutStart( TTestResult& aResult,
+                                    CTestFlexTimer* aCallback );
+    
+    /**
+    * @brief Call AfterTicks() with negative value.
+    *
+    * This test illegal usage of the interface. There has to be zero or more 
+    * ticks.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt NegativeTicksInAfterTicksL(
+        TTestResult& aResult, 
+        CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Call AfterTicks() with zero.
+    *
+    * This tests leagal usage of the interface.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ZeroTicksInAfterTicksL(
+        TTestResult& aResult, 
+        CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Change system time during AfterTicks timer is running.
+    * 
+    * Set timer to be expired after 640 ticks (10 sec). After 1 sec from
+    * starting the timer, add system time 3 seconds. Check that the timer
+    * expires after 10 seconds from starting (13 secs by system time).
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt ChangeTimeWhileAfterTicksL(
+        TTestResult& aResult, 
+        CTestFlexTimer* aCallback );
+
+    /**
+    * @brief Test that timer window works correctly.
+    * 
+    * Create three timers:
+    * T1: expire after 4-8 secs
+    * T2: expire after 7-8 secs
+    * T3: expire after 5 secs
+    *
+    * T1 and T2 are AfterTicks -timers T3 is After timer.
+    * 
+    * Check that T1 has expired after 5 secs and T2 after 8 secs of setting.
+    *
+    * @param aResult The result of the test.
+    * @param aCallback Pointer to the STIF test class
+    * @return The status of execution of the test. KErrNone if the test
+    *         was executed ok, any system wide errorcode otherwise.
+    */
+    static TInt TestAfterTicksWindowL(
+        TTestResult& aResult, 
+        CTestFlexTimer* aCallback );
+
+private:
+
+    /**
+    * Constructor.
+    * Keep it private to prevent instantiation of the class.
+    */
+    CTestRFlexTimer();
+
+    /**
+    * Check is the delay in the window.
+    * @param aDelay Interval to be checked.
+    * @param aInterval Interval of the timer.
+    * @param aWindow Allowed window of the timer. 
+    * @return ETrue if the delay is correc, EFalse otherwise.
+    */
+    static TBool IsDelayOk( 
+        const TTimeIntervalMicroSeconds aDelay,
+        const TTimeIntervalMicroSeconds32 aInterval,
+        const TTimeIntervalMicroSeconds32 aWindow );
+
+    /**
+    * Check is the delay in the window.
+    * @param aDelay Interval to be checked.
+    * @param aInterval Interval of the timer.
+    * @param aWindow Allowed window of the timer. 
+    * @return ETrue if the delay is correc, EFalse otherwise.
+    */
+    static TBool IsDelayOk( 
+        const TTimeIntervalMicroSeconds aDelay,
+        const TTimeIntervalMicroSeconds32 aInterval,
+        const TTimeIntervalMicroSeconds aWindow );
+
+    /**
+    * Check is the delay in the window.
+    * @param aDelay Interval to be checked.
+    * @param aInterval Interval of the timer.
+    * @param aWindow Allowed window of the timer. 
+    * @return ETrue if the delay is correc, EFalse otherwise.
+    */
+    static TBool IsDelayOk( 
+        const TTimeIntervalMicroSeconds aDelay,
+        const TTimeIntervalMicroSeconds aInterval,
+        const TTimeIntervalMicroSeconds32 aWindow );
+
+    /**
+    * Check is the delay in the window.
+    * @param aDelay Interval to be checked.
+    * @param aInterval Interval of the timer.
+    * @param aWindow Allowed window of the timer. 
+    * @return ETrue if the delay is correc, EFalse otherwise.
+    */
+    static TBool IsDelayOk( 
+        const TTimeIntervalMicroSeconds aDelay,
+        const TTimeIntervalMicroSeconds aInterval,
+        const TTimeIntervalMicroSeconds aWindow );
+    
+    /**
+    * A helper function for AfterTicks() testing.
+    * -# Creates RFlexTimer handle, 
+    * -# connects it to the server, 
+    * -# configures timer's window (default 0 microseconds),
+    * -# set the timer to expire after given ticks,
+    * -# wait timer to be expired
+    * -# return the delay of the timer
+    * 
+    * @param aTicks Timer's interval in number of ticks
+    * @param aWindowSize Timer's window (default 0 microseconds)
+    * @return The delay of the timer in microseconds
+    */
+    static TTimeIntervalMicroSeconds ExecuteAfterTicksL(
+        TInt aTicks,
+        TTimeIntervalMicroSeconds aWindowSize = 0 );
+    
+private: // data
+
+    };
+
+#endif // TESTRFLEXTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/init/testflextimer.ini	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,217 @@
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#   + XML, Test report will be xml type, for example 'TestReport.xml'.
+#          Note, that xml format is available only when output is set to FILE.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module.
+# 	- Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation
+#		DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02
+#
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 'Empty', 'Summary', 'Environment',
+                              #                      'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT         # Possible values: TXT, HTML or XML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+DisableMeasurement= stifmeasurementdisablenone  # Possible values are:
+              # 'stifmeasurementdisablenone', 'stifmeasurementdisableall'
+              # 'stifmeasurementplugin01', 'stifmeasurementplugin02',
+              # 'stifmeasurementplugin03', 'stifmeasurementplugin04',
+              # 'stifmeasurementplugin05' or 'stifbappeaprofiler'
+
+Timeout= 0                    # Default timeout value for each test case. In milliseconds
+#UITestingSupport= YES        # Possible values: YES or NO
+#SeparateProcesses= YES       # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testflextimer
+[End_Module]
+
+
+# Load testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleXXX used configuration file(s)
+#TestCaseFile= c:\testframework\testcases1.cfg
+#TestCaseFile= c:\testframework\testcases2.cfg
+#TestCaseFile= c:\testframework\manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+#	- Will write log file in unicode format.
+#		+ YES, Log file will be written in unicode format
+#		+ NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+#CreateLogDirectories= YES    # Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML         # Possible values: TXT or HTML
+#EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML         # Possible values: TXT or HTML
+#HardwareOutput= FILE         # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES       # Possible values: YES or NO
+#WithTimeStamp= YES           # Possible values: YES or NO
+#WithLineBreak= YES           # Possible values: YES or NO
+#WithEventRanking= YES        # Possible values: YES or NO
+
+#FileUnicode= YES             # Possible values: YES or NO
+#AddTestCaseTitle= YES        # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set filters to be used by ConsoleUI.
+# 	If you want to use filter with ConsoleUI, simply remove comments
+# 	from section below and provide valid filter entries.
+#   Each filter line has to start with "filter= " keyword.
+#   Filter can contain special wildcard characters:
+#     *  which stands for none or any literal;
+#     ?  which stands for single character.
+#   Filters are not case-sensitive.
+
+#[Filters]
+#filter= *math*
+#filter= *radio*
+#[End_Filters]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/rom/testflextimer.iby	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Flexible timer tests
+*
+*/
+#ifndef TESTFLEXTIMER_IBY
+#define TESTFLEXTIMER_IBY
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\testflextimer.dll SHARED_LIB_DIR\testflextimer.dll
+
+#endif // TESTFLEXTIMER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/src/inheritedcflextimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of CFlexPeriodic class
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// System include files
+// User include files go here:
+#include "inheritedcflextimer.h"
+//For exteded test result
+#include "testflextimer.h"
+// External function prototypes
+// Local constants go here
+// Panic category
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// Constructs the object.
+// ---------------------------------------------------------------------------
+//
+CInheritedCFlexTimer* CInheritedCFlexTimer::NewL( TInt aPriority,
+        TCallBack aCallBack )
+    {
+
+    CInheritedCFlexTimer* self = new (ELeave) CInheritedCFlexTimer(aPriority,
+            aCallBack);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructs the object.
+// ---------------------------------------------------------------------------
+//
+CInheritedCFlexTimer::~CInheritedCFlexTimer()
+    {
+
+    }
+
+// ---------------------------------------------------------------------------
+// Desc
+// ---------------------------------------------------------------------------
+//
+void CInheritedCFlexTimer::SetCB( TCallBack aCallBack )
+    {
+    iCallBack = aCallBack;
+    }
+
+// ---------------------------------------------------------------------------
+// Desc
+// ---------------------------------------------------------------------------
+//
+TInt CInheritedCFlexTimer::MyOwnConfigure(
+        TTimeIntervalMicroSeconds32 aDelayWindow )
+    {
+    TInt ret = CFlexTimer::Configure(aDelayWindow);
+    if (ret == KErrNone)
+        {
+        //
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles the active objects request completion event.
+// ---------------------------------------------------------------------------
+//
+void CInheritedCFlexTimer::RunL()
+    {
+    //Give code to test case
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (iCallBack.iPtr);
+    eRes->iStatusCode = iStatus.Int();
+    iCallBack.CallBack();
+    }
+
+// ---------------------------------------------------------------------------
+// Second part of the two-phase construction.
+// ---------------------------------------------------------------------------
+//
+void CInheritedCFlexTimer::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    CFlexTimer::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// Private constructor with priority.
+// ---------------------------------------------------------------------------
+//
+CInheritedCFlexTimer::CInheritedCFlexTimer( TInt aPriority,
+        TCallBack aCallBack ) :
+    CFlexTimer(aPriority), iCallBack(aCallBack)
+    {
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/src/inheritedcflextimer2.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of CFlexPeriodic class
+ *
+ */
+/*
+ * %version: 1 %
+ */
+// System include files
+// User include files go here:
+#include "inheritedcflextimer2.h"
+//For exteded test result
+#include "testcflextimer.h"
+#include <e32debug.h>
+// External function prototypes
+// Local constants go here
+// Panic category
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// Constructs the object.
+// ---------------------------------------------------------------------------
+//
+CInheritedCFlexTimer2* CInheritedCFlexTimer2::NewL( TInt aPriority,
+        TCallBack aCallBack, TInt aId )
+    {
+    RDebug::Printf("CInheritedCFlexTimer2::NewL");
+    CInheritedCFlexTimer2* self = new (ELeave) CInheritedCFlexTimer2(
+            aPriority, aCallBack, aId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructs the object.
+// ---------------------------------------------------------------------------
+//
+CInheritedCFlexTimer2::~CInheritedCFlexTimer2()
+    {
+
+    }
+
+// ---------------------------------------------------------------------------
+// Desc
+// ---------------------------------------------------------------------------
+//
+void CInheritedCFlexTimer2::SetCB( TCallBack aCallBack )
+    {
+    iCallBack = aCallBack;
+    }
+
+// ---------------------------------------------------------------------------
+// Desc
+// ---------------------------------------------------------------------------
+//
+TInt CInheritedCFlexTimer2::MyOwnConfigure(
+        TTimeIntervalMicroSeconds32 aDelayWindow )
+    {
+    TInt ret = CFlexTimer::Configure(aDelayWindow);
+    if (ret == KErrNone)
+        {
+        //
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles the active objects request completion event.
+// ---------------------------------------------------------------------------
+//
+void CInheritedCFlexTimer2::RunL()
+    {
+    RDebug::Printf("CInheritedCFlexTimer2::RunL");
+    //Give code to test case
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (iCallBack.iPtr);
+    (*list)[0].iCurrentlyActive = iId;
+    (*list)[iId].iEResult->iStatusCode = iStatus.Int();
+    iCallBack.CallBack();
+    }
+
+// ---------------------------------------------------------------------------
+// Second part of the two-phase construction.
+// ---------------------------------------------------------------------------
+//
+void CInheritedCFlexTimer2::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    CFlexTimer::ConstructL();
+    }
+
+// ---------------------------------------------------------------------------
+// Private constructor with priority.
+// ---------------------------------------------------------------------------
+//
+CInheritedCFlexTimer2::CInheritedCFlexTimer2( TInt aPriority,
+        TCallBack aCallBack, TInt aId ) :
+    CFlexTimer(aPriority), iCallBack(aCallBack), iId(aId)
+    {
+    RDebug::Printf("CInheritedCFlexTimer2::CInheritedCFlexTimer2");
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/src/testcflextimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,3236 @@
+/*
+ * ============================================================================
+ *  Name        : testflexperiodic.cpp
+ *  Part of     : src / testflextimer
+ *  Description : STIF test cases for CFlexPeriodic timer.
+ *  Version     : %version: 1 %
+ *
+ *  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *  All rights reserved.
+ *  This component and the accompanying materials are made available
+ *  under the terms of the License "Eclipse Public License v1.0"
+ *  which accompanies this distribution, and is available
+ *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ *  Initial Contributors:
+ *  Nokia Corporation - initial contribution.
+ *
+ *  Contributors:
+ *  Nokia Corporation
+ * ============================================================================
+ * Template version: 4.1
+ */
+
+#include <e32debug.h>           // for RDebug
+#include <e32math.h>             // for Math::Rand()
+#include <StifTestInterference.h>
+#include "testflextimer.h"      // for global constants & CB
+#include "testcflextimer.h"
+#include "flextimerpanic.h"     // for panic constants
+#include "inheritedcflextimer.h"// CFlexTimer implementation (CB is always TExtendedTestResult*)
+#include "inheritedcflextimer2.h"// another CFlexTimer implementation (CB is always RArray<TTimerStruct> *list)
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+const TInt64 KTickResolution( 1000000 / 64 );
+const TInt KExtraSlack = 500 * 1000;
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CTestCFlexTimer::CTestCFlexTimer()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CTestCFlexTimer::~CTestCFlexTimer()
+    {
+    }
+// --------------------------------------------------------------------------
+// Start timer and delete it.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CreateAndDestroyCFlexTimerL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TExtendedTestResult *eResult = new TExtendedTestResult(&aResult);
+    CInheritedCFlexTimer
+            * timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard,
+                    TCallBack(
+                            InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                            eResult));
+
+    TTimeIntervalMicroSeconds32 expireTime(5 * 1000 * 1000); //5s
+    timer->After(expireTime);
+    CActiveScheduler::Start();
+
+    delete timer;
+    timer = NULL;
+    _LIT( KDescription , "Test case passed");
+    aResult.SetResult(KErrNone, KDescription);
+    delete eResult;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Start timer and see that it expires at max time
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CreateAndExpireCFlexTimerL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TExtendedTestResult *eResult = new TExtendedTestResult(&aResult);
+    CInheritedCFlexTimer
+            * timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard,
+                    TCallBack(
+                            InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                            eResult));
+
+    // Expire in 5 seconds
+    TTimeIntervalMicroSeconds32 expireTime(5 * 1000 * 1000);
+
+    // Save current time.
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer->After(expireTime);
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    //See if CB has failed the case
+    if (eResult->iCaseAlreadyFailed)
+        {
+        delete timer;
+        delete eResult;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timer expiry happened within maxtime to maxtime+accuracy
+    if ((utcNow + expireTime) <= utcNow2 && (utcNow + expireTime
+            + TTimeIntervalMicroSeconds32(KTimerAccuracyMicroSeconds))
+            > utcNow2)
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer;
+    delete eResult;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CreateAndExpireTwoOverlappingAfterTimersL(
+        TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds32 expireTime2(static_cast<TInt64> ((10 * 1000
+            * 1000 - static_cast<float> (10 * 1000 * 1000)
+            * KDefaultWindowMultiplier)));
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(15 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds32(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime2) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime2 + TTimeIntervalMicroSeconds32(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        RDebug::Printf("utcNow = %lld\n", utcNow.Int64());
+        RDebug::Printf("eResult1->iTimerStoppedTime = %lld\n",
+                eResult1->iTimerStoppedTime);
+        RDebug::Printf("eResult2->iTimerStoppedTime = %lld\n",
+                eResult2->iTimerStoppedTime);
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time. 64bit version
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CreateAndExpireTwoOverlappingAfterTimers64L(
+        TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(10 * 1000 * 1000);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds expireTime2(static_cast<TInt64> ((10 * 1000
+            * 1000 - static_cast<float> (10 * 1000 * 1000)
+            * KDefaultWindowMultiplier)));
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(15 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime2) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime2 + TTimeIntervalMicroSeconds(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at their own max time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CreateAndExpireTwoNonOverlappingAfterTimersL(
+        TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    //Expire one second before first timers window starts
+    TTimeIntervalMicroSeconds32 expireTime2(static_cast<TInt64> ((10 * 1000
+            * 1000 - static_cast<float> (10 * 1000 * 1000)
+            * KDefaultWindowMultiplier)) - 1 * 1000 * 1000);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(15 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within at their own max time edge.
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds32(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime1) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime1 + TTimeIntervalMicroSeconds32(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Start many timers and see that nothing goes wrong when they are expired at rapid sequence
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::HumongousAmountOfTimeridelidilidousL(
+        TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    RDebug::Printf("HugemongousAmountOfTimeridelidilidousL");
+    // This list will contain all the timer structs, expiry times etc.
+    // First cell will always tell which timer is currently active
+    // active info is transferred from e.g. InheritedCFlexTimer2::RunL to CB function
+    RArray<TTimerStruct> timers;
+    // This CB contains all the logic about timer addition
+    StartTimerAndAddToList( &timers, 2000 );
+    // CBs stop this after all timers are expired 
+    CActiveScheduler::Start();
+    // Delete CPeriodic that was used to launch new FlexTimers
+    delete timers[0].iStartTimer;
+    _LIT( KDescriptionP , "Passed");
+    aResult.SetResult(KErrNone, KDescriptionP);
+    // Loop throug list and see if timers fired within limits.
+    // also delete all stuff reserved earlier by StartTimerAndAddToList
+    while (timers.Count())
+        {
+        // Have fun with reading this. It is not as bad as it looks
+        // Just checks if CB already failed the case
+        // and if timer was launched within its window(default) and timer accuracy
+        if (!(!timers[0].iEResult->iCaseAlreadyFailed
+                && (timers[0].iEResult->iTimerStartedTime
+                        + timers[0].iEResult->iTimerExpiryTime
+                        - (static_cast<float> (timers[0].iEResult->iTimerExpiryTime)
+                                * KDefaultWindowMultiplier)
+                        <= timers[0].iEResult->iTimerStoppedTime+KTickResolution)
+                && (timers[0].iEResult->iTimerStartedTime
+                        + timers[0].iEResult->iTimerExpiryTime
+                        + KTimerAccuracyMicroSeconds)
+                        > timers[0].iEResult->iTimerStoppedTime))
+            {
+            _LIT( KDescription , "Some timer was not fired within its window.\n");
+            aResult.SetResult(KErrGeneral, KDescription);
+
+            }
+        delete timers[0].iEResult->iTestResult;
+        delete timers[0].iEResult;
+        delete timers[0].iTimer;
+        timers.Remove(0);
+        }
+    // Case was executed
+    timers.Close();
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start three timers At, AtUTC and After and see that they are treated equally.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CreateAndExpireThreeTimersL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TTestResult *res3 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    TExtendedTestResult *eResult3 = new TExtendedTestResult(res3);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    eResult2->iTimerID = 3;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    CInheritedCFlexTimer* timer3 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult3));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(10 * 1000 * 1000);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds expireTime2(9 * 1000 * 1000);
+    TTimeIntervalMicroSeconds expireTime3(3 * 1000 * 1000); // Expire far enough from others
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    TTime homeNow(0);
+    homeNow.HomeTime();
+
+    timer1->After(expireTime1);
+    timer2->At(homeNow + expireTime2);
+    timer3->AtUTC(utcNow + expireTime3);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(15 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(
+            eResult1->iTestResult->iResult,
+            eResult1->iTestResult->iResultDes );
+        }
+    else if (eResult2->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(
+            eResult2->iTestResult->iResult,
+            eResult2->iTestResult->iResultDes );
+        }
+    else if (eResult3->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(
+            eResult3->iTestResult->iResult,
+            eResult3->iTestResult->iResultDes );
+        }
+
+    // Check if timers expiry happened within limits.
+    // First and second timer at seconds timers max time and third at its own max time.
+    //
+    // Compare results against utcNow due timer's stopped time is UTC.
+    else if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution) && 
+        (utcNow + expireTime2 + TTimeIntervalMicroSeconds( KTimerAccuracyMicroSeconds)) > TTime( eResult2->iTimerStoppedTime) &&
+
+        (utcNow + expireTime2) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && 
+        (utcNow + expireTime2 + TTimeIntervalMicroSeconds( KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime) &&
+
+        (utcNow + expireTime3) <= TTime(eResult3->iTimerStoppedTime+KTickResolution) && 
+        (utcNow + expireTime3 + TTimeIntervalMicroSeconds( KTimerAccuracyMicroSeconds)) > TTime( eResult3->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete timer3;
+    delete eResult1;
+    delete eResult2;
+    delete eResult3;
+    delete res1;
+    delete res2;
+    delete res3;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start three timers At, AtUTC and After and see that they can be cancelled.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::NormalCancelL( TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TTestResult *res3 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    TExtendedTestResult *eResult3 = new TExtendedTestResult(res3);
+    eResult1->iTimerID = 0;
+    eResult2->iTimerID = 1;
+    eResult3->iTimerID = 2;
+    CInheritedCFlexTimer2* timer1 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult1), 0);
+    CInheritedCFlexTimer2* timer2 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult2), 1);
+    CInheritedCFlexTimer2* timer3 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult3), 2);
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(10 * 1000 * 1000);
+    //just something
+    TTimeIntervalMicroSeconds expireTime2(static_cast<TInt64> ((10 * 1000
+            * 1000 - static_cast<float> (10 * 1000 * 1000)
+            * KDefaultWindowMultiplier)));
+    TTimeIntervalMicroSeconds expireTime3(7 * 1000 * 1000); // just something
+    RArray<TTimerStruct> timers;
+    TTimerStruct *s1 = new TTimerStruct();
+    s1->iEResult = eResult1;
+    s1->iTimer = timer1;
+    timers.Append(*s1);
+    TTimerStruct *s2 = new TTimerStruct();
+    s2->iEResult = eResult2;
+    s2->iTimer = timer2;
+    timers.Append(*s2);
+    TTimerStruct *s3 = new TTimerStruct();
+    s3->iEResult = eResult3;
+    s3->iTimer = timer3;
+    timers.Append(*s3);
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    TTime homeNow(0);
+    homeNow.HomeTime();
+
+    timer1->After(expireTime1);
+    timer2->At(homeNow + expireTime2);
+    timer3->AtUTC(utcNow + expireTime3);
+
+    timers[0].iCurrentlyActive = 0; //CB uses this to decide which timer to cancel;
+
+    //Timer to cancel timers under test and cancel active scheduler
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(15 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CPeriodic *pp = CPeriodic::NewL(EPriorityNormal);
+    s1->iStartTimer = pp;
+    pp->Start(3 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            CancelCFlexTimerArray, &timers));
+    CPeriodic *ppp = CPeriodic::NewL(EPriorityNormal);
+    s2->iStartTimer = ppp;
+    ppp->Start(4 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            CancelCFlexTimerArray, &timers));
+    CPeriodic *pppp = CPeriodic::NewL(EPriorityNormal);
+    s3->iStartTimer = pppp;
+    pppp->Start(5 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            CancelCFlexTimerArray, &timers));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    delete pp;
+    delete ppp;
+    delete pppp;
+    delete s1;
+    delete s2;
+    delete s3;
+    _LIT( KDescription , "Passed");
+    aResult.SetResult(KErrNone, KDescription);
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed
+            || eResult3->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        if (eResult2->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult3->iTestResult->iResult,
+                    eResult3->iTestResult->iResultDes);
+            }
+        }
+    delete timer1;
+    delete timer2;
+    delete timer3;
+    delete eResult1;
+    delete eResult2;
+    delete eResult3;
+    delete res1;
+    delete res2;
+    delete res3;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CancelTimerThatWouldHaveTriggeredAnotherTimerL(
+        TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult1));
+    CInheritedCFlexTimer
+            * timer2 =
+                    CInheritedCFlexTimer::NewL(
+                            CActive::EPriorityStandard,
+                            TCallBack(
+                                    InheritedFlexTimerCallbackKErrNoneMarkTimestampStopScheduler,
+                                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds32 expireTime2(static_cast<TInt64> ((10 * 1000
+            * 1000 - static_cast<float> (10 * 1000 * 1000)
+            * KDefaultWindowMultiplier)));
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to cancel Timer 1
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(3 * 1000 * 1000, 1000, TCallBack(CancelCFlexTimer, timer1));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds32(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureCTimerOverlap1L( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds32 expireTime1(16 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 window1(8 * 1000 * 1000);
+    timer1->Configure(window1);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds32 expireTime2(9 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 window2(1 * 1000 * 1000);
+    timer2->Configure(window2);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(17 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds32(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime2) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime2 + TTimeIntervalMicroSeconds32(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureCTimerOverlap2L( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(16 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window1(8 * 1000 * 1000);
+    timer1->Configure(window1);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds expireTime2(17 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window2(1 * 1000 * 1000);
+    timer2->Configure(window2);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(18 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within timer1 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime1) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime1 + TTimeIntervalMicroSeconds(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime1) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime1 + TTimeIntervalMicroSeconds(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureCTimerOverlap3L( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(16 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window1(16 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 zeroWindow(0);
+    timer1->Configure(zeroWindow);
+    timer1->Configure(window1);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds expireTime2(8 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window2(0);
+    timer2->Configure(window2);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(18 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime2) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime2 + TTimeIntervalMicroSeconds(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at their own max time
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureCTimerNonOverlap1L( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(16 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window1(0);
+    timer1->Configure(window1);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds expireTime2(15 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window2(1 * 1000 * 1000);
+    timer2->Configure(window2);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(18 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timer expired within their own  maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime1) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime1 + TTimeIntervalMicroSeconds(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at their own max time
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureCTimerNonOverlap2L( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(16 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window1(16 * 1000 * 1000);
+    timer1->Configure(window1);
+    window1 = 8 * 1000 * 1000;
+    timer1->Configure(window1);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds expireTime2(7 * 1000 * 1000);
+    TTimeIntervalMicroSeconds window2(4 * 1000 * 1000);
+    timer2->Configure(window2);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(18 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timer expired within their own  maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime1) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime1 + TTimeIntervalMicroSeconds(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start three timers and see that system time change aborts At & AtUtc timers
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::SystemTimeChangesL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TTestResult *res3 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    TExtendedTestResult *eResult3 = new TExtendedTestResult(res3);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    eResult3->iTimerID = 3;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(
+                    InheritedFlexTimerCallbackKErrAbort, eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(
+                    InheritedFlexTimerCallbackKErrAbort, eResult2));
+    CInheritedCFlexTimer* timer3 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                    eResult3));
+    // Expire in 10, 11 and 12 seconds. One and two are to be aborted
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 expireTime2(11 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 expireTime3(12 * 1000 * 1000);
+
+    
+    // Save current time as ticks. This use case will change system time
+    // and timestamps will not be exact -- ticks are.
+    TUint startTicks( User::TickCount() );
+    
+    TTime now, nowUtc;
+    now.HomeTime();
+    nowUtc.UniversalTime();
+
+    timer1->At(now + expireTime1);
+    timer2->AtUTC(nowUtc + expireTime2);
+    timer3->After(expireTime3);
+
+    //Timer to change system time after timers have been running for a while
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(5 * 1000 * 1000, 1000, TCallBack(ChangeSystemTime1sAndCancel, p));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed
+            || eResult3->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else if (eResult2->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult3->iTestResult->iResult,
+                    eResult3->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete timer3;
+        delete eResult1;
+        delete eResult2;
+        delete eResult3;
+        delete res1;
+        delete res2;
+        delete res3;
+        return KErrNone;
+        }
+    // Get new current time
+    TUint endTicks( User::TickCount() );
+    TInt delay( ( endTicks - startTicks ) * KTickInMicroSeconds );
+    
+    //Check if timers expiry happened within timer3 maxtime to maxtime+accuracy
+    if ( delay+KTickResolution >= expireTime3.Int() && 
+         delay < expireTime3.Int() + KTimerAccuracyMicroSeconds )
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete timer3;
+    delete eResult1;
+    delete eResult2;
+    delete eResult3;
+    delete res1;
+    delete res2;
+    delete res3;
+
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start three timers and see that time zone change aborts At & AtUtc timers
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::TimeZoneChangesL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TTestResult *res3 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    TExtendedTestResult *eResult3 = new TExtendedTestResult(res3);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    eResult3->iTimerID = 3;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(
+                    InheritedFlexTimerCallbackKErrAbort, eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(
+                    InheritedFlexTimerCallbackKErrAbort, eResult2));
+    CInheritedCFlexTimer* timer3 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                    eResult3));
+    // Expire in 10, 11 and 12 seconds. One and two are to be aborted
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 expireTime2(11 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 expireTime3(12 * 1000 * 1000);
+
+    // Save current time as ticks. This use case will change system time
+    // and timestamps will not be exact -- ticks are.
+    TUint startTicks( User::TickCount() );
+    
+    TTime now, nowUtc;
+    now.HomeTime();
+    nowUtc.UniversalTime();
+    
+    timer1->At(now + expireTime1);
+    timer2->AtUTC(nowUtc + expireTime2);
+    timer3->After(expireTime3);
+
+    //Timer to change system time after timers have been running for a while
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(5 * 1000 * 1000, 1000, TCallBack(ChangeTimeZoneAndCancel, p));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed
+            || eResult3->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else if (eResult2->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult3->iTestResult->iResult,
+                    eResult3->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete timer3;
+        delete eResult1;
+        delete eResult2;
+        delete eResult3;
+        delete res1;
+        delete res2;
+        delete res3;
+        return KErrNone;
+        }
+
+    // Get new current time
+    TUint endTicks( User::TickCount() );
+    TInt delay( ( endTicks - startTicks ) * KTickInMicroSeconds );
+    
+    //Check if timers expiry happened within timer3 maxtime to maxtime+accuracy
+    if ( delay+KTickResolution >= expireTime3.Int() && 
+         delay < expireTime3.Int() + KTimerAccuracyMicroSeconds )
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete timer3;
+    delete eResult1;
+    delete eResult2;
+    delete eResult3;
+    delete res1;
+    delete res2;
+    delete res3;
+
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::DumbAssParametersForCTimerL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+    CInheritedCFlexTimer
+            * timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard,
+                    TCallBack(
+                            InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                            eResult));
+
+    /*32 bit IF called with 1 parameter*/
+    /***********************************/
+    // Expire in 3 seconds. 
+    TTimeIntervalMicroSeconds32 expireTime(1);
+    // Save current time
+    TTime now(0);
+    now.HomeTime();
+    timer->After(expireTime);
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    //See if CB has failed the case
+    if (eResult->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult->iTestResult->iResult,
+                eResult->iTestResult->iResultDes);
+        delete timer;
+        delete eResult;
+        delete res;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime now2(0);
+    now2.HomeTime();
+    //Check if timers expiry happened immediately.
+    if (!((now + expireTime) <= now2 && (now + expireTime
+            + TTimeIntervalMicroSeconds32(KTimerAccuracyMicroSeconds)) > now2))
+        {
+        _LIT( KDescription , "32 bit After(1) failed.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        delete timer;
+        delete eResult;
+        delete res;
+        return KErrNone;
+        }
+
+    /*32 bit IF called with max parameter*/
+    /***********************************/
+    expireTime = 0x7FFFFFFF;
+    now.HomeTime();
+    delete timer;
+    timer = NULL;
+    timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard, TCallBack(
+            NotCalledCB, eResult));
+    timer->After(expireTime);
+    //Timer to change system time after timers have been running for a while
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(5 * 1000 * 1000, 1000, TCallBack(
+            CancelCFlexTimerAndStopActiveScheduler, timer));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    p->Cancel();
+    delete p;
+    //See if CB has failed the case
+    if (eResult->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult->iTestResult->iResult,
+                eResult->iTestResult->iResultDes);
+        delete timer;
+        delete eResult;
+        delete res;
+        return KErrNone;
+        }
+
+    /*64 bit IF called with 1 parameter*/
+    /***********************************/
+    // Expire in 3 seconds. 
+    TTimeIntervalMicroSeconds expireTime64(1);
+    // Save current time
+    now.HomeTime();
+    delete timer;
+    timer = NULL;
+    timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard, TCallBack(
+            InheritedFlexTimerCallbackStopSchedulerKErrNone, eResult));
+    timer->After(expireTime64);
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    //See if CB has failed the case
+    if (eResult->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult->iTestResult->iResult,
+                eResult->iTestResult->iResultDes);
+        delete timer;
+        delete eResult;
+        delete res;
+        return KErrNone;
+        }
+    // Get new current time
+    now2.HomeTime();
+    //Check if timers expiry happened immediately
+    if (!((now + expireTime64) <= now2 && (now + expireTime64
+            + TTimeIntervalMicroSeconds(KTimerAccuracyMicroSeconds)) > now2))
+        {
+        _LIT( KDescription , "64 bit After(1) failed.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        delete timer;
+        delete eResult;
+        delete res;
+        return KErrNone;
+        }
+    // Finally if we are here set whole case to passed.
+    _LIT( KDescription , "Passed");
+    aResult.SetResult(KErrNone, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::DumbAssParametersForCTimerZero32bitL( TTestResult& aResult,
+        CTestFlexTimer* /* cb */ )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    /*32 bit IF called with 0 parameter*/
+    /***********************************/
+    const TTimeIntervalMicroSeconds32 kExpireTime32(0);
+
+    // Save current time
+    TTime startTime;
+    startTime.HomeTime();
+
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+        CActive::EPriorityStandard, 
+        TCallBack( InheritedFlexTimerCallbackStopSchedulerKErrNone, eResult ) );
+
+    timer->After( kExpireTime32 );
+
+    CActiveScheduler::Start();  // WAIT timer to expire
+
+    TTime endTime;
+    endTime.HomeTime();
+    
+    TTimeIntervalMicroSeconds delay = endTime.MicroSecondsFrom( startTime );
+    
+    if ( delay.Int64() < kExpireTime32.Int() || 
+         delay.Int64() > kExpireTime32.Int() + KTimerAccuracyMicroSeconds )
+        {
+        aResult.SetResult( KErrGeneral, _L("Wrong expiration") );
+        }
+    else
+        {
+        aResult.SetResult( KErrNone, _L("Test case passed") );
+        }
+    
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::DumbAssParametersForCTimerZero64bitL( TTestResult& aResult,
+        CTestFlexTimer* /* cb */ )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    /*64 bit IF called with 0 parameter*/
+    /***********************************/
+    const TTimeIntervalMicroSeconds kExpireTime64(0);
+
+    // Save current time
+    TTime startTime;
+    startTime.HomeTime();
+
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(InheritedFlexTimerCallbackStopSchedulerKErrNone, eResult));
+
+    timer->After(kExpireTime64);
+    CActiveScheduler::Start();  // WAIT timer to expire
+
+    TTime endTime;
+    endTime.HomeTime();
+    
+    TTimeIntervalMicroSeconds delay = endTime.MicroSecondsFrom( startTime );
+    
+    if ( delay.Int64()+KTickResolution < kExpireTime64.Int64() || 
+         delay.Int64() > kExpireTime64.Int64() + KTimerAccuracyMicroSeconds )
+        {
+        aResult.SetResult( KErrGeneral, _L("Wrong expiration") );
+        }
+    else
+        {
+        aResult.SetResult( KErrNone, _L("Test case passed") );
+        }
+    
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::DumbAssParametersForCTimer64MaxL( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    /*64 bit IF called with 0x7FFFFFFFFFFFFFFF parameter*/
+    /***********************************/
+    // This will cause panic 
+    TTimeIntervalMicroSeconds expireTime64(0x7FFFFFFFFFFFFFFF);
+    // Save current time
+    TTime now(0);
+    now.HomeTime();
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerServerIllegalTimerValue);
+    timer->After(expireTime64);
+    // Start timer that stops active scheduler just in case.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(3 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CActiveScheduler::Start();
+    delete p;
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "64 bit After(0x7FFFFFFFFFFFFFFF) failed to panic.\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::DumbAssParametersForCTimer64ThreeYearsL( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    /*64 bit IF called with 93312000000000 (about three years) parameter*/
+    /***********************************/
+    // This will cause panic since only two years ahead timers are supported 
+    TTimeIntervalMicroSeconds expireTime64(93312000000000);
+    // Save current time
+    TTime now(0);
+    now.HomeTime();
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerServerIllegalTimerValue);
+    timer->After(expireTime64);
+    // Start timer that stops active scheduler just in case.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(3 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CActiveScheduler::Start();
+    delete p;
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "64 bit After(93312000000000) failed to panic.\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start one year timer and cancel it.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::DumbAssParametersForCTimer64OneYearL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    RDebug::Printf("DumbAssParametersForCTimer64OneYearL");
+    TTestResult *res1 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    eResult1->iTimerID = 0;
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1( 33312000000000 ); // About on year
+    //just something
+    RArray<TTimerStruct> timers;
+    CInheritedCFlexTimer2* timer1 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB,
+                    &timers), 0);
+    TTimerStruct *s1 = new TTimerStruct();
+    s1->iEResult = eResult1;
+    s1->iTimer = timer1;
+    timers.Append(*s1);
+
+    timer1->After(expireTime1);
+
+    timers[0].iCurrentlyActive = 0;
+
+    //Timers to cancel timer and stop scheduler.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(7 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CPeriodic *pp = CPeriodic::NewL(EPriorityNormal);
+    s1->iStartTimer = pp;
+    pp->Start(5 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            CancelCFlexTimerArray, &timers));
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p; delete pp;
+    delete s1;
+    _LIT( KDescription , "Passed");
+    aResult.SetResult(KErrNone, KDescription);
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult1->iTestResult->iResult,
+                eResult1->iTestResult->iResultDes);
+        }
+    
+    delete timer1;
+    delete eResult1;
+    delete res1;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with negative value
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AfterWithNegativeValueL( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    // This will cause panic
+    TTimeIntervalMicroSeconds32 expireTime(-1);
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerAfterIntervalLessThanZero);
+    timer->After(expireTime);
+    CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "32 bit After(-1) failed to panic.\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with negative value
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AfterWithNegativeValue64L( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    // This will cause panic
+    TTimeIntervalMicroSeconds expireTime(-1);
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerAfterIntervalLessThanZero);
+    timer->After(expireTime);
+    CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "64 bit After(-1) failed to panic.\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AtWithCurrentTimeL( TTestResult& aResult,
+        CTestFlexTimer* /* cb */ )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    TTimeIntervalMicroSeconds expireTime64(0);
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+        CActive::EPriorityStandard, 
+        TCallBack(InheritedFlexTimerCallbackStopSchedulerKErrNone, eResult));
+
+    // Save current time
+    TTime now(0);
+    now.HomeTime();
+    timer->At(now + expireTime64);
+    CActiveScheduler::Start(); // WAIT timer to expire
+
+    // Analyze results
+    TTime endTime;
+    endTime.HomeTime();
+    
+    TTimeIntervalMicroSeconds delay = endTime.MicroSecondsFrom( now );
+
+    if ( delay.Int64()+KTickResolution < expireTime64.Int64() || 
+         delay.Int64() > expireTime64.Int64() + KTimerAccuracyMicroSeconds )
+        {
+        aResult.SetResult(KErrGeneral, _L("Wrong expiration"));
+        }
+    else
+        {
+        aResult.SetResult( KErrNone, _L("Test case passed") );
+        }
+
+    // Clean up
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AtUTCWithCurrentTimeL( TTestResult& aResult,
+        CTestFlexTimer* /* cb */ )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    TTimeIntervalMicroSeconds expireTime64(0);
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+        CActive::EPriorityStandard, 
+        TCallBack(InheritedFlexTimerCallbackStopSchedulerKErrNone, eResult));
+
+    // Save current time
+    TTime now(0);
+    now.UniversalTime();
+    timer->AtUTC(now + expireTime64);
+    CActiveScheduler::Start(); // WAIT timer to expire
+
+    // Analyze results
+    TTime endTime;
+    endTime.UniversalTime();
+    
+    TTimeIntervalMicroSeconds delay = endTime.MicroSecondsFrom( now );
+
+    if ( delay.Int64()+KTickResolution < expireTime64.Int64() || 
+         delay.Int64() > expireTime64.Int64() + KTimerAccuracyMicroSeconds )
+        {
+        aResult.SetResult(KErrGeneral, _L("Wrong expiration"));
+        }
+    else
+        {
+        aResult.SetResult( KErrNone, _L("Test case passed") );
+        }
+
+    // Clean up
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timers with dumbass parameters
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AtWithThreeYearsL( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = 1;
+
+    // This will cause panic 
+    TTimeIntervalMicroSeconds expireTime64(93312000000000);
+    CInheritedCFlexTimer *timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerServerIllegalTimerValue);
+    // Save current time
+    TTime now(0);
+    now.HomeTime();
+    timer->At(now + expireTime64);
+    // Start timer that stops active scheduler just in case.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(3 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CActiveScheduler::Start();
+    delete p;
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "At(93312000000000) failed to panic.\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start one year timer and cancel it.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AtWithOneYearL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    RDebug::Printf("AtWithOneYearL");
+    TTestResult *res1 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    eResult1->iTimerID = 0;
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1( 33312000000000 ); // About on year
+    //just something
+    RArray<TTimerStruct> timers;
+    CInheritedCFlexTimer2* timer1 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB,
+                    &timers), 0);
+    TTimerStruct *s1 = new TTimerStruct();
+    s1->iEResult = eResult1;
+    s1->iTimer = timer1;
+    timers.Append(*s1);
+    TTime now(0);
+    now.HomeTime();
+    timer1->At(now + expireTime1);
+
+    timers[0].iCurrentlyActive = 0;
+
+    //Timers to cancel timer and stop scheduler.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(7 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CPeriodic *pp = CPeriodic::NewL(EPriorityNormal);
+    s1->iStartTimer = pp;
+    pp->Start(5 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            CancelCFlexTimerArray, &timers));
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p; delete pp;
+    delete s1;
+    _LIT( KDescription , "Passed");
+    aResult.SetResult(KErrNone, KDescription);
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult1->iTestResult->iResult,
+                eResult1->iTestResult->iResultDes);
+        }
+    delete timer1;
+    delete eResult1;
+    delete res1;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Call At and AtUTC with time in the past
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::AtWithTimeInThePastL( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    RDebug::Printf("AtWithTimeInThePastL");
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+
+    // Expire in the past
+    TTimeIntervalMicroSeconds expireTime(-1);
+    CInheritedCFlexTimer* timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    // Save current time
+    TTime homeNow(0);
+    homeNow.HomeTime();
+    TTime homeExpireTime(homeNow + expireTime);
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerAtIntervalLessThanZero);
+    timer->At(homeExpireTime);
+    CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "At in the past failed to panic.\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timer, expire, cancel, start again and expire
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CancelExpiredTimerL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TExtendedTestResult *eResult = new TExtendedTestResult(&aResult);
+    CInheritedCFlexTimer
+            * timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard,
+                    TCallBack(
+                            InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                            eResult));
+
+    // Expire in 5 seconds
+    TTimeIntervalMicroSeconds32 expireTime(5 * 1000 * 1000);
+
+    // Save current time.
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer->After(expireTime);
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    // Ignore time and cb stuff
+    // Cancel timer that just expired
+    timer->Cancel();
+
+    // Start timer again
+    // Save current time.
+    utcNow.UniversalTime();
+
+    timer->After(expireTime);
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    //See if CB has failed the case
+    if (eResult->iCaseAlreadyFailed)
+        {
+        delete timer;
+        delete eResult;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timer expiry happened within maxtime to maxtime+accuracy
+    if ((utcNow + expireTime) <= utcNow2+TTimeIntervalMicroSeconds32(KTickResolution) && (utcNow + expireTime
+            + TTimeIntervalMicroSeconds32(KTimerAccuracyMicroSeconds))
+            > utcNow2)
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer;
+    delete eResult;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start timer that has left side of the window in the past.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureLeftSideInThePastL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    TExtendedTestResult *eResult = new TExtendedTestResult(&aResult);
+    CInheritedCFlexTimer
+            * timer = CInheritedCFlexTimer::NewL(CActive::EPriorityStandard,
+                    TCallBack(
+                            InheritedFlexTimerCallbackStopSchedulerKErrNone,
+                            eResult));
+
+    // Expire in 5 seconds
+    TTimeIntervalMicroSeconds32 winTime(10 * 1000 * 1000);
+    TTimeIntervalMicroSeconds32 expireTime(5 * 1000 * 1000);
+
+    // Save current time.
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    timer->Configure(winTime);
+    timer->After(expireTime);
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    //See if CB has failed the case
+    if (eResult->iCaseAlreadyFailed)
+        {
+        delete timer;
+        delete eResult;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timer expiry happened within maxtime to maxtime+accuracy
+    if ((utcNow + expireTime) <= utcNow2+TTimeIntervalMicroSeconds32(KTickResolution) && (utcNow + expireTime
+            + TTimeIntervalMicroSeconds32(KTimerAccuracyMicroSeconds))
+            > utcNow2)
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer;
+    delete eResult;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Start two timers and see that window works if another is started with left 
+// side of the window in the past.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureLeftSideInThePastWindowCheckL(
+        TTestResult& aResult, CTestFlexTimer */*cb*/)
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds32 expireTime2(9 * 1000 * 1000);
+
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+
+    timer1->Configure(TTimeIntervalMicroSeconds(15 * 1000 * 1000));
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(17 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed || eResult2->iCaseAlreadyFailed)
+        {
+        if (eResult1->iCaseAlreadyFailed)
+            {
+            aResult.SetResult(eResult1->iTestResult->iResult,
+                    eResult1->iTestResult->iResultDes);
+            }
+        else
+            {
+            aResult.SetResult(eResult2->iTestResult->iResult,
+                    eResult2->iTestResult->iResultDes);
+            }
+        delete timer1;
+        delete timer2;
+        delete eResult1;
+        delete eResult2;
+        delete res1;
+        delete res2;
+        return KErrNone;
+        }
+    // Get new current time
+    TTime utcNow2(0);
+    utcNow2.UniversalTime();
+
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if ((utcNow + expireTime2) <= TTime(eResult2->iTimerStoppedTime+KTickResolution)
+            && (utcNow + expireTime2 + TTimeIntervalMicroSeconds32(
+                    KTimerAccuracyMicroSeconds)) > TTime(
+                    eResult2->iTimerStoppedTime) &&
+
+    (utcNow + expireTime2) <= TTime(eResult1->iTimerStoppedTime+KTickResolution) && (utcNow
+            + expireTime2 + TTimeIntervalMicroSeconds32(
+            KTimerAccuracyMicroSeconds)) > TTime(eResult1->iTimerStoppedTime))
+        {
+        _LIT( KDescription , "Passed");
+        aResult.SetResult(KErrNone, KDescription);
+        }
+    else
+        {
+        _LIT( KDescription , "Some timer was fired either too early or too late.\n");
+        aResult.SetResult(KErrGeneral, KDescription);
+        }
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    return KErrNone;
+
+    }
+
+// --------------------------------------------------------------------------
+// Call Configure 32 bit with Negative window size
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureWithNegativeWindowSize32L(
+        TTestResult& aResult, CTestFlexTimer *cb )
+    {
+    RDebug::Printf("ConfigureWithNegativeWindowSize32L");
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+
+    // negative time
+    TTimeIntervalMicroSeconds32 confTime(-1);
+    CInheritedCFlexTimer* timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerWindowLessThanZero);
+    timer->Configure(confTime);
+    //CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "Configure(32) with negative interval failed to panic\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Call Configure 64 bit with Negative window size
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureWithNegativeWindowSize64L(
+        TTestResult& aResult, CTestFlexTimer *cb )
+    {
+    RDebug::Printf("ConfigureWithNegativeWindowSize64L");
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+
+    // negative time
+    TTimeIntervalMicroSeconds confTime(-1);
+    CInheritedCFlexTimer* timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerWindowLessThanZero);
+    timer->Configure(confTime);
+    //CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "Configure(64) with negative interval failed to panic\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// -
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureWithMaxWindow32L(
+        TTestResult& aResult, CTestFlexTimer* /* cb */ )
+    {
+    RDebug::Printf("ConfigureWithMaxWindow32L");
+    TTestResult *res1 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    eResult1->iTimerID = 0;
+    TTimeIntervalMicroSeconds32 expireTime1( 0x7FFFFFFF );
+    //just something
+    RArray<TTimerStruct> timers;
+    CInheritedCFlexTimer2* timer1 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB,
+                    &timers), 0);
+    TTimerStruct *s1 = new TTimerStruct();
+    s1->iEResult = eResult1;
+    s1->iTimer = timer1;
+    timers.Append(*s1);
+    timer1->Configure(expireTime1);
+    timer1->After(expireTime1);
+
+    timers[0].iCurrentlyActive = 0;
+
+    //Timers to cancel timer and stop scheduler.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(7 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StopActiveScheduler));
+    CPeriodic *pp = CPeriodic::NewL(EPriorityNormal);
+    s1->iStartTimer = pp;
+    pp->Start(5 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            CancelCFlexTimerArray, &timers));
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p; delete pp;
+    delete s1;
+    _LIT( KDescription , "Passed");
+    aResult.SetResult(KErrNone, KDescription);
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult1->iTestResult->iResult,
+                eResult1->iTestResult->iResultDes);
+        }
+    delete timer1;
+    delete eResult1;
+    delete res1;
+    return KErrNone;
+    }
+// --------------------------------------------------------------------------
+// -
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureWithThreeYearWindow64L(
+        TTestResult& aResult, CTestFlexTimer *cb )
+    {
+    RDebug::Printf("ConfigureWithThreeYearWindow64L");
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+
+    // negative time
+    TTimeIntervalMicroSeconds confTime(93312000000000);
+    CInheritedCFlexTimer* timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerServerIllegalTimerValue);
+    timer->Configure(confTime);
+    //CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "Configure(93312000000000 failed to panic\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// -
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureWithMaxWindow64L(
+        TTestResult& aResult, CTestFlexTimer *cb )
+    {
+    RDebug::Printf("ConfigureWithMaxWindow64L");
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+
+    // negative time
+    TTimeIntervalMicroSeconds confTime(0x7FFFFFFFFFFFFFFF);
+    CInheritedCFlexTimer* timer = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult));
+    //Accept panic as passed case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic,
+            EFlexTimerServerIllegalTimerValue);
+    timer->Configure(confTime);
+    //CActiveScheduler::Start();
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    _LIT( KDescription , "Configure(0x7FFFFFFFFFFFFFFF) failed to panic\n");
+    aResult.SetResult(KErrGeneral, KDescription);
+    delete timer;
+    delete eResult;
+    delete res;
+    return KErrNone;
+    }
+// --------------------------------------------------------------------------
+// Start timer and call configure while it is running
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureWhileTimerIsInUseL( TTestResult& aResult,
+        CTestFlexTimer */*cb*/)
+    {
+    RDebug::Printf("ConfigureWhileTimerIsInUseL");
+    TTestResult *res1 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    eResult1->iTimerID = 0;
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(10 * 1000 * 1000);
+    //just something
+    RArray<TTimerStruct> timers;
+    CInheritedCFlexTimer2* timer1 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(StopSchedulerKErrNoneArray,
+                    &timers), 0);
+    TTimerStruct *s1 = new TTimerStruct();
+    s1->iEResult = eResult1;
+    s1->iTimer = timer1;
+    timers.Append(*s1);
+
+    TTime homeNow(0);
+    homeNow.HomeTime();
+
+    timer1->After(expireTime1);
+
+    timers[0].iCurrentlyActive = 0;
+
+    //Timer to call configure while timer is running
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(5 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            ConfigureKErrInUseArray, &timers));
+
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    delete p;
+    delete s1;
+    _LIT( KDescription , "Passed");
+    aResult.SetResult(KErrNone, KDescription);
+    //See if CB has failed the case
+    if (eResult1->iCaseAlreadyFailed)
+        {
+        aResult.SetResult(eResult1->iTestResult->iResult,
+                eResult1->iTestResult->iResultDes);
+        delete timer1;
+        delete eResult1;
+        delete res1;
+        return KErrNone;
+        }
+    TTime homeNow2(0);
+    homeNow2.HomeTime();
+    //Check if timers expiry happened within timer2 maxtime to maxtime+accuracy
+    if (!((homeNow + expireTime1) <= homeNow2+TTimeIntervalMicroSeconds32(KTickResolution) && (homeNow + expireTime1
+            + TTimeIntervalMicroSeconds32(KTimerAccuracyMicroSeconds))
+            > homeNow2))
+        {
+        _LIT( KEDescription , "Timer was not fired within limits");
+        aResult.SetResult(KErrGeneral, KEDescription);
+        }
+    delete timer1;
+    delete eResult1;
+    delete res1;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// timer is started twice
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::TimerIsStartedTwiceL( TTestResult& aResult,
+        CTestFlexTimer *cb )
+    {
+    TTestResult *res1 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    eResult1->iTimerID = 0;
+    CInheritedCFlexTimer2* timer1 = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard, TCallBack(NotCalledCB, eResult1), 0);
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds expireTime1(10 * 1000 * 1000);
+    RArray<TTimerStruct> timers;
+    TTimerStruct *s1 = new TTimerStruct();
+    s1->iEResult = eResult1;
+    s1->iTimer = timer1;
+    timers.Append(*s1);
+
+    timer1->After(expireTime1);
+    timers[0].iCurrentlyActive = 0; //CB uses this to decide which timer to start again;
+
+    //Timer to start timer again
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+    p->Start(5 * 1000 * 1000, 30 * 1000 * 1000, TCallBack(
+            StartTimerAgainArray, &timers));
+    // Panic category: "E32USER-CBase"
+    // Panic reason:   42 (attempt to active CActive when a request is still 
+    // outstanding.
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::EPanic, 42);
+    // Start scheduler and wait for callback to panic it
+    CActiveScheduler::Start();
+    // We should never get here -> fail the case
+    cb->TestModuleIf().SetExitReason(CTestModuleIf::ENormal, KErrNone);
+    delete p;
+    delete s1;
+    _LIT( KDescription , "double start failed to panic.");
+    aResult.SetResult(KErrGeneral, KDescription);
+
+    delete timer1;
+    delete eResult1;
+    delete res1;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// See that timer is stoppped with valid reason and stop scheduler
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackStopSchedulerKErrNone(
+        TAny* aArgument )
+    {
+    RDebug::Printf("InheritedFlexTimerCallbackStopSchedulerKErrNone");
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrNone)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason\n");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// See that timer is stoppped with valid reason and stop scheduler
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackStopSchedulerKErrAbort(
+        TAny* aArgument )
+    {
+    RDebug::Printf("InheritedFlexTimerCallbackStopSchedulerKErrAbort");
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrAbort)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// See that timer is stoppped with valid reason and stop scheduler
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackStopSchedulerKErrCancel(
+        TAny* aArgument )
+    {
+    RDebug::Printf("InheritedFlexTimerCallbackStopSchedulerKErrCancel");
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrCancel)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// See that timer is stoppped with valid reason
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackKErrNone( TAny* aArgument )
+    {
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrNone)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// See that timer is stoppped with valid reason
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackKErrAbort( TAny* aArgument )
+    {
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrAbort)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// See that both timers are stoppped with valid reason and save expiry time
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackKErrNoneMarkTimestamp(
+        TAny* aArgument )
+    {
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrNone)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    eRes->iTimerStoppedTime = utcNow.Int64();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// See that both timers are stoppped with valid reason and save expiry time
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::InheritedFlexTimerCallbackKErrNoneMarkTimestampStopScheduler(
+        TAny* aArgument )
+    {
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    if (eRes->iStatusCode != KErrNone)
+        {
+        eRes->iCaseAlreadyFailed = ETrue;
+        _LIT(KError,"Error: Wrong timer expiry reason");
+        eRes->iTestResult->SetResult(KErrGeneral, KError);
+        }
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    eRes->iTimerStoppedTime = utcNow.Int64();
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Stop active scheduler
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StopActiveScheduler( TAny*/*aArgument*/)
+    {
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Change system time + 1s and cancel Periodic timer given as parameter
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ChangeSystemTime1sAndCancel( TAny* aArgument )
+    {
+    RDebug::Printf("ChangeSystemTime1sAndCancel");
+    TTime now(0);
+    now.HomeTime();
+    User::SetHomeTime(now + TTimeIntervalMicroSeconds32(1000 * 1000));
+    CPeriodic *p = reinterpret_cast<CPeriodic*> (aArgument);
+    p->Cancel();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Change time zone and cancel Periodic timer given as parameter
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ChangeTimeZoneAndCancel( TAny* aArgument )
+    {
+    RDebug::Printf("ChangeTimeZoneAndCancel");
+    TTimeIntervalSeconds currentUtcOffset( User::UTCOffset() );
+    User::SetUTCOffset( currentUtcOffset.Int() + 3000 );
+    CPeriodic *p = reinterpret_cast<CPeriodic*> (aArgument);
+    p->Cancel();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Change secure time + 1s and cancel Periodic timer given as parameter
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ChangeSecureTimeAndCancel( TAny* aArgument )
+    {
+    RDebug::Printf("ChangeSecureTimeAndCancel");
+    TTime now(0);
+    now.UniversalTime();
+    User::SetUTCTimeSecure(now + TTimeIntervalMicroSeconds32(1000 * 1000));
+    CPeriodic *p = reinterpret_cast<CPeriodic*> (aArgument);
+    p->Cancel();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Fail result if this is called
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::NotCalledCB( TAny* aArgument )
+    {
+    TExtendedTestResult *eRes =
+            reinterpret_cast<TExtendedTestResult*> (aArgument);
+    eRes->iCaseAlreadyFailed = ETrue;
+    _LIT(KError,"Error: invalid CB called");
+    eRes->iTestResult->SetResult(KErrGeneral, KError);
+    return 1; //nada
+    }
+
+// --------------------------------------------------------------------------
+// Stop active schduler and cancel Periodic timer given as paramter
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StopSchedulerAndCancel( TAny* aArgument )
+    {
+    CPeriodic *p = reinterpret_cast<CPeriodic*> (aArgument);
+    p->Cancel();
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Cancels CFlexTimer given a parameter
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CancelCFlexTimer( TAny* aArgument )
+    {
+    CFlexTimer *p = reinterpret_cast<CFlexTimer*> (aArgument);
+    p->Cancel();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Cancels CFlexTimer
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CancelCFlexTimerArray( TAny* aArgument )
+    {
+    RDebug::Printf("CancelCFlexTimerCancelPeriodic");
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (aArgument);
+    (*list)[(*list)[0].iCurrentlyActive].iTimer->Cancel();
+    (*list)[0].iCurrentlyActive += 1;
+    return 1; // nada
+    }
+// --------------------------------------------------------------------------
+// Cancels CFlexTimer and CPeriodic given a parameter
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CancelCFlexTimerCancelPeriodic( TAny* aArgument )
+    {
+    RDebug::Printf("CancelCFlexTimerCancelPeriodic");
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (aArgument);
+    (*list)[(*list)[0].iCurrentlyActive].iTimer->Cancel();
+    (*list)[0].iCurrentlyActive += 1;
+    (*list)[0].iStartTimer->Cancel();
+    return 1; // nada
+    }
+// --------------------------------------------------------------------------
+// See that timer is stoppped with valid reason and stop scheduler
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StopSchedulerKErrNoneArray( TAny* aArgument )
+    {
+    RDebug::Printf("StopSchedulerKErrNoneArray");
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (aArgument);
+    if ((*list)[(*list)[0].iCurrentlyActive].iEResult->iStatusCode
+            != KErrNone)
+        {
+        (*list)[(*list)[0].iCurrentlyActive].iEResult->iCaseAlreadyFailed
+                = ETrue;
+        _LIT(KErrorDes,"Error: Wrong timer expiry reason");
+        (*list)[(*list)[0].iCurrentlyActive].iEResult->iTestResult->SetResult(
+                KErrGeneral, KErrorDes);
+        }
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Cancels CFlexTimer given a parameter and stops active scheduler
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CancelCFlexTimerAndStopActiveScheduler( TAny* aArgument )
+    {
+    CFlexTimer *p = reinterpret_cast<CFlexTimer*> (aArgument);
+    p->Cancel();
+    CActiveScheduler::Stop();
+    return 1; // nada
+    }
+    
+// --------------------------------------------------------------------------
+// Callback for StartTimerAndAddToList method. This is hack to enable aTimers
+// parameter in StartTimerAndAddToList method.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StartTimerAndAddToListCB( TAny* aArgument )
+    {
+    return StartTimerAndAddToList(
+        reinterpret_cast<RArray<TTimerStruct>*> (aArgument), -1 );
+    }
+
+// --------------------------------------------------------------------------
+// Starts timer and adds it to list given as param
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StartTimerAndAddToList(
+    RArray<TTimerStruct>* aList, TInt aTimers )
+    {
+    const TInt KTimerStartInterval = 5 * 1000; //Start new timer every 5ms
+    const TInt KTimerMaxDelay = 15 * 1000 * 1000; //Timer delay is between 0 and 15 seconds
+    static TInt numberOfTimers = 0; // How many timers to start
+    
+    if (aTimers > 0)
+        {
+        numberOfTimers = aTimers;
+        }
+
+    TTestResult *res = new TTestResult();
+    TExtendedTestResult *eResult = new TExtendedTestResult(res);
+    eResult->iTimerID = aList->Count();
+    CInheritedCFlexTimer2* timer = CInheritedCFlexTimer2::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(StopTimer, reinterpret_cast<TAny*> (aList)),
+            eResult->iTimerID);
+
+    // Expire in 0-15s seconds
+    TInt random = Math::Random() % (KTimerMaxDelay);
+    TTimeIntervalMicroSeconds expireTime(random);
+    TTimerStruct *s = new TTimerStruct();
+    s->iEResult = eResult;
+    s->iTimer = timer;
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    s->iEResult->iTimerStartedTime = utcNow.Int64();
+    s->iEResult->iTimerExpiryTime = expireTime.Int64();
+    TInt listerr = aList->Append(*s);
+    if (KErrNone != listerr)
+        {
+        RDebug::Printf("Error: Adding to list failed %d", listerr);
+        }
+    (*aList)[0].iTimersRunning += 1;
+    timer->After(expireTime);
+    //First time here. Lets start timer to make many timers.
+    if (aList->Count() == 1)
+        {
+        CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+        p->Start(KTimerStartInterval, KTimerStartInterval, TCallBack(
+                StartTimerAndAddToListCB, reinterpret_cast<TAny*> (aList) ));
+        (*aList)[0].iStartTimer = p;
+        }
+    RDebug::Printf("StartTimerAndAddToList: timers running %d",
+            (*aList)[0].iTimersRunning);
+    RDebug::Printf("StartTimerAndAddToList: list->Count() %d", aList->Count());
+    if (aList->Count() == numberOfTimers)
+        {
+        ((*aList)[0].iStartTimer->Cancel());
+        }
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// Starts timer and adds it to list given as param
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StopTimer( TAny* aArgument )
+    {
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (aArgument);
+    RDebug::Printf("StopTimer: timers running %d", (*list)[0].iTimersRunning);
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    (*list)[0].iTimersRunning -= 1;
+    (*list)[(*list)[0].iCurrentlyActive].iEResult->iTimerStoppedTime
+            = utcNow.Int64();
+    if ((*list)[0].iTimersRunning == 0)
+        {
+        (*list)[0].iStartTimer->Cancel();
+        CActiveScheduler::Stop();
+        }
+    return 1; // nada
+    }
+// --------------------------------------------------------------------------
+// Try to configure timer ans see that correct error code is returned
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::ConfigureKErrInUseArray( TAny* aArgument )
+    {
+    RDebug::Printf("ConfigureKErrInUseArray");
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (aArgument);
+    TInt error = (*list)[(*list)[0].iCurrentlyActive].iTimer->Configure(
+            TTimeIntervalMicroSeconds(12 * 1000 * 1000));
+    if (KErrInUse != error)
+        {
+        (*list)[(*list)[0].iCurrentlyActive].iEResult->iCaseAlreadyFailed
+                = ETrue;
+        _LIT(KError,"Error: Wrong return code 64bit if\n");
+        (*list)[(*list)[0].iCurrentlyActive].iEResult->iTestResult->SetResult(
+                KErrGeneral, KError);
+        return 1;
+        }
+    //Try same with 32 bit if
+    error = (*list)[(*list)[0].iCurrentlyActive].iTimer->Configure(
+            TTimeIntervalMicroSeconds32(12 * 1000 * 1000));
+    if (KErrInUse != error)
+        {
+        (*list)[(*list)[0].iCurrentlyActive].iEResult->iCaseAlreadyFailed
+                = ETrue;
+        _LIT(KError,"Error: Wrong return code 32bit if\n");
+        (*list)[(*list)[0].iCurrentlyActive].iEResult->iTestResult->SetResult(
+                KErrGeneral, KError);
+        }
+    return 1; // nada
+    }
+
+// --------------------------------------------------------------------------
+// start timer again
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::StartTimerAgainArray( TAny* aArgument )
+    {
+    RDebug::Printf("StartTimerAgainArray");
+    RArray<TTimerStruct> *list =
+            reinterpret_cast<RArray<TTimerStruct>*> (aArgument);
+    (*list)[(*list)[0].iCurrentlyActive].iTimer->After(
+            TTimeIntervalMicroSeconds(12 * 1000 * 1000));
+    return 1; // nada
+    }
+// --------------------------------------------------------------------------
+// Start two timers and see that they expire at the same time.
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL(
+        TTestResult& aResult, CTestFlexTimer *cb )
+    {
+    TTestResult *res1 = new TTestResult();
+    TTestResult *res2 = new TTestResult();
+    TExtendedTestResult *eResult1 = new TExtendedTestResult(res1);
+    TExtendedTestResult *eResult2 = new TExtendedTestResult(res2);
+    
+
+    eResult1->iTimerID = 1;
+    eResult2->iTimerID = 2;
+    
+    CInheritedCFlexTimer* timer1 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult1));
+    CInheritedCFlexTimer* timer2 = CInheritedCFlexTimer::NewL(
+            CActive::EPriorityStandard,
+            TCallBack(InheritedFlexTimerCallbackKErrNoneMarkTimestamp,
+                    eResult2));
+    
+    // Expire in 10 seconds
+    TTimeIntervalMicroSeconds32 expireTime1(10 * 1000 * 1000);
+    //Expire within first timers default window
+    TTimeIntervalMicroSeconds32 expireTime2(static_cast<TInt64> ((10 * 1000
+            * 1000 - static_cast<float> (10 * 1000 * 1000)
+            * KDefaultWindowMultiplier)));
+    
+    // Save current time
+    TTime utcNow(0);
+    utcNow.UniversalTime();
+    
+    timer1->After(expireTime1);
+    timer2->After(expireTime2);
+    
+    //Timer to stop active scheduler after timers under test are completed.
+    CPeriodic *p = CPeriodic::NewL(EPriorityNormal);
+
+    p->Start(15 * 1000 * 1000, 1000, TCallBack(StopActiveScheduler));
+
+    MSTIFTestInterference* interference =  MSTIFTestInterference::NewL(
+        cb, MSTIFTestInterference::EThread );
+
+    // Start interference to generate 99% CPU load (100 ms load, 1% idle)
+    interference->StartL( MSTIFTestInterference::ECpuLoad, 1, 100 );
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    interference->Stop();
+    delete interference;
+    
+    delete p;
+
+    // Check results
+    TInt64 timer1RightWin =
+        utcNow.Int64() + static_cast<TInt64>(expireTime1.Int());
+    TInt64 timer2RightWin =
+        utcNow.Int64() + static_cast<TInt64>(expireTime2.Int());
+    TInt64 timer1LeftWin = timer2RightWin - static_cast<TInt64>(
+        (static_cast<TReal64>(expireTime1.Int()) * KDefaultWindowMultiplier));
+    TInt64 timer2LeftWin = timer2RightWin - static_cast<TInt64>(
+        (static_cast<TReal64>(expireTime2.Int()) * KDefaultWindowMultiplier));
+    TInt64 timer1StopedTime = eResult1->iTimerStoppedTime;
+    TInt64 timer2StopedTime = eResult2->iTimerStoppedTime;
+    
+    //See if Timer 1 Callback has failed the case
+    if (eResult1->iCaseAlreadyFailed)
+        {
+        _LIT( KDescription ,"Timer 1 has failed" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    //See if Timer 2 Callback has failed the case
+    else if (eResult2->iCaseAlreadyFailed)
+        {
+        _LIT( KDescription,"Timer 2 has failed" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    // Check if timer 1 has timed out too early
+    else if ((timer1StopedTime + KTickResolution) < timer1LeftWin)
+        {
+        _LIT( KDescription, "Timer 1 timed out too early" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    // Check if timer 1 has timed out too Late
+    else if ((timer1StopedTime - KTimerAccuracyMicroSeconds) > timer1RightWin)
+        {
+        _LIT( KDescription, "Timer 1 timed out too late" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    // Check if timer 2 has timed out too early
+    else if ((timer2StopedTime + KTickResolution) < timer2LeftWin)
+        {
+        _LIT( KDescription, "Timer 2 timed out too early" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    // Check if timer 2 has timed out too Late
+    else if ((timer2StopedTime - KTimerAccuracyMicroSeconds - KExtraSlack) > timer2RightWin)
+        {
+        _LIT( KDescription, "Timer 2 timed out too late" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    // Check that the timers 1 and 2 timed out at the same time
+    else if (((timer1StopedTime + KTimerAccuracyMicroSeconds) < timer2StopedTime) ||
+        ((timer1StopedTime - KTimerAccuracyMicroSeconds) > timer2StopedTime))
+        {
+        _LIT( KDescription, "Timers 1 and 2 did not timeout at the same time" );
+        aResult.SetResult( KErrGeneral, KDescription );
+        }
+    // Everything was successful
+    else
+        {
+        _LIT( KDescription, "Passed" );
+        aResult.SetResult( KErrNone, KDescription );
+        }
+    
+    // Case was executed
+    delete timer1;
+    delete timer2;
+    delete eResult1;
+    delete eResult2;
+    delete res1;
+    delete res2;
+    
+    return KErrNone;
+    }
+// --------------------------------------------------------------------------
+// Start many timers and see that nothing goes wrong when they are expired at rapid sequence
+// --------------------------------------------------------------------------
+//
+TInt CTestCFlexTimer::CpuLoadManyTimersL(
+        TTestResult& aResult, CTestFlexTimer *cb )
+    {
+    RDebug::Printf("CpuLoadManyTimersL");
+    // This list will contain all the timer structs, expiry times etc.
+    // First cell will always tell which timer is currently active
+    // active info is transferred from e.g. InheritedCFlexTimer2::RunL to CB function
+    RArray<TTimerStruct> timers;
+    // This CB contains all the logic about timer addition
+    StartTimerAndAddToList( &timers, 100 );
+    
+    MSTIFTestInterference* interference =  MSTIFTestInterference::NewL(
+        cb, MSTIFTestInterference::EThread );
+    // Start interference to generate 99% CPU load (100 ms load, 1% idle)
+    interference->StartL( MSTIFTestInterference::ECpuLoad, 1, 50 );
+    // Start scheduler and wait for callback to stop it
+    CActiveScheduler::Start();
+    interference->Stop();
+    delete interference;
+    
+    // Delete CPeriodic that was used to launch new FlexTimers
+    delete timers[0].iStartTimer;
+    _LIT( KDescriptionP , "Passed");
+    aResult.SetResult(KErrNone, KDescriptionP);
+    // Loop throug list and see if timers fired within limits.
+    // also delete all stuff reserved earlier by StartTimerAndAddToList
+    while (timers.Count())
+        {
+        TInt64 rightWin = timers[0].iEResult->iTimerStartedTime +
+            timers[0].iEResult->iTimerExpiryTime;
+        TInt64 leftWin = rightWin -
+            (static_cast<float> (timers[0].iEResult->iTimerExpiryTime) *
+                KDefaultWindowMultiplier);
+        TInt64 stopTime = timers[0].iEResult->iTimerStoppedTime;
+        
+        // Have fun with reading this. It is not as bad as it looks
+        // Just checks if CB already failed the case
+        // and if timer was launched within its window(default) and timer accuracy
+        if (timers[0].iEResult->iCaseAlreadyFailed)
+            {
+            _LIT( KDescription , "Case was failed earlier for unknown reason.");
+            aResult.SetResult(KErrGeneral, KDescription);
+            }
+        // Check if timer has expired before the window has started.
+        else if((stopTime + KTickResolution)  < leftWin)
+            {
+            _LIT( KDescription , "Some timer has expired too soon");
+            aResult.SetResult(KErrGeneral, KDescription);
+            }
+        // Check if timeout has happened too long time after window end.
+        else if (stopTime > (rightWin + KTimerAccuracyMicroSeconds + KExtraSlack))
+            {
+            _LIT( KDescription , "Some timer has expired too late");
+            aResult.SetResult(KErrGeneral, KDescription);
+            }
+        delete timers[0].iEResult->iTestResult;
+        delete timers[0].iEResult;
+        delete timers[0].iTimer;
+        timers.Remove(0);
+        }
+    // Case was executed
+    timers.Close();
+    return KErrNone;
+    }
+
+// ======== GLOBAL FUNCTIONS ========
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/src/testflexperiodic.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,2091 @@
+/*
+* ============================================================================
+*  Name        : testflexperiodic.cpp
+*  Part of     : src / testflextimer
+*  Description : STIF test cases for CFlexPeriodic timer.
+*  Version     : %version: 1 %
+*
+*  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+*  All rights reserved.
+*  This component and the accompanying materials are made available
+*  under the terms of the License "Eclipse Public License v1.0"
+*  which accompanies this distribution, and is available
+*  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+*  Initial Contributors:
+*  Nokia Corporation - initial contribution.
+*
+*  Contributors:
+*  Nokia Corporation
+* ============================================================================
+* Template version: 4.1
+*/
+
+#include <e32debug.h>               // for RDebug
+#include <flexperiodic.h>           // for CFlexPeriodic
+#include <stiftesteventinterface.h> // for TEventIf 
+#include "testflextimer.h"          // for global constants
+#include "testflexperiodic.h"
+
+/**
+ *  Timer can be expired 1 sec late
+ *  
+ *  Note! Definition
+ *  
+ *      const TTimeIntervalMicroSeconds32 KTimerResolution( 1000000 );
+ * 
+ * will cause writable static data due non-trivial constructor of 
+ * TTimeIntervalMicroSeconds32.
+ *  
+ */
+const TInt KTimerResolution( 1000000 );
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CTestFlexPeriodic::CTestFlexPeriodic()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CTestFlexPeriodic::~CTestFlexPeriodic()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// _ _ _ ____ _ ___    _    ____ ____ ___  
+// | | | |__| |  |     |    |  | |  | |__] 
+// |_|_| |  | |  |     |___ |__| |__| |    
+//                                         
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Start scheduler for given time.
+// ---------------------------------------------------------------------------
+//
+void CTestFlexPeriodic::WaitL( TTimeIntervalMicroSeconds32 aPeriod )
+    {
+    CPeriodic* watchdog = CPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( watchdog );
+    watchdog->Start( aPeriod, aPeriod, TCallBack( StopScheduler, NULL ) );
+    
+    // Start scheduler. Wait here until the timer expires and stops the
+    // scheduler.
+    CActiveScheduler::Start();
+    
+    // Clean-up
+    watchdog->Cancel();
+    CleanupStack::PopAndDestroy( watchdog );
+    }
+
+// ---------------------------------------------------------------------------
+// TCallBack function to stop the scheduler.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StopScheduler( TAny* /* aArgument */ )
+    {
+    CActiveScheduler::Stop();
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------------------------
+// ____ ____ _    _    ___  ____ ____ _  _ ____ 
+// |    |__| |    |    |__] |__| |    |_/  [__  
+// |___ |  | |___ |___ |__] |  | |___ | \_ ___] 
+//                                              
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// TCallBack function that does nothing. Not ment to be called - just to 
+// fulfill the interface.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::DoNothing( TAny* /* aArgument */ )
+    {
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TCallBack function that panics testcase if it get called.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::PanicClient( TAny* /* aArgument */ )
+    {
+    User::Panic(_L("NotCalled CB got called"), 0xDEAD);
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// TCallBack function for adding time stamp to an RArray of TTimes.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::AddTimestamp( TAny* aArgument )
+    {
+    __ASSERT_ALWAYS(
+        aArgument != NULL,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+
+    //RDebug::Print( _L("CTestFlexPeriodic::AddTimestamp()") );
+    
+    RArray<TTime>* times =  reinterpret_cast<RArray<TTime>*>( aArgument );
+
+    TTime now;
+    now.UniversalTime();
+
+    TInt err = times->Append( now ); // Data is copied by RArray
+    __ASSERT_ALWAYS(
+        err == KErrNone,
+        User::Panic( KTestFlexTimerPanicCategory, err ) );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TCallBack function for restarting CFlexPeriodic timer.
+// Action depends the value of iFirstTicksLeft;
+// >0 -- Add timestamp to iFirstTimestamps 
+// <0 -- Add timestamp to iSecondTimestamps
+// =0 -- Add timestamp to iFirstTimestamps AND iSecondTimestamps AND restart
+//       the timer with iSecondInterval
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::RestartTimer( TAny* aArgument )
+    {
+    __ASSERT_ALWAYS(
+        aArgument != NULL,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+
+    TRestartInfo* info =  reinterpret_cast<TRestartInfo*>( aArgument );
+
+    __ASSERT_ALWAYS(
+        info->iTimer != NULL && 
+        info->iFirstTimestamps != NULL && 
+        info->iSecondTimestamps != NULL,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+    
+    // Add current time to timestamps
+    // Data is copied by RArray - no need to use heap
+    TTime now;
+    now.UniversalTime();
+    
+    TInt ticks( info->iFirstTicksLeft-- ); // Update the ticks
+    TInt err( KErrNone );
+    if ( ticks > 0 )
+        {
+        err = info->iFirstTimestamps->Append( now );
+        }
+    else if ( ticks < 0 )
+        {
+        err = info->iSecondTimestamps->Append( now );
+        }
+    else // ticks == 0
+        {
+        // Set the timestamps.
+        // 1st timer settings expiration time is the starting time of the
+        // second timer settings. Add timestamp to both arrays.
+        err = info->iFirstTimestamps->Append( now );
+        __ASSERT_ALWAYS(
+            err == KErrNone,
+            User::Panic( KTestFlexTimerPanicCategory, err ) );
+        err = info->iSecondTimestamps->Append( now );
+
+        // Restart the timer
+        info->iTimer->Cancel();
+        info->iTimer->Start(
+            info->iSecondInterval,
+            info->iSecondInterval, 
+            TCallBack( RestartTimer, info ) );
+        }
+    __ASSERT_ALWAYS(
+        err == KErrNone,
+        User::Panic( KTestFlexTimerPanicCategory, err ) );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TCallBack function for trying to configure timer in callback.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureTimer( TAny* aArgument )
+    {
+    __ASSERT_ALWAYS(
+        aArgument != NULL,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+
+    TConfigureInfo* info =  reinterpret_cast<TConfigureInfo*>( aArgument );
+
+    const TTimeIntervalMicroSeconds32 delayWindow32( info->iDelayWindow );
+    const TTimeIntervalMicroSeconds32 intervalWindow32( info->iIntervalWindow );
+
+    const TTimeIntervalMicroSeconds delayWindow64( info->iDelayWindow );
+    const TTimeIntervalMicroSeconds intervalWindow64( info->iIntervalWindow );
+
+    info->iConfigResult32 = info->iTimer->Configure( delayWindow32,
+                                                     intervalWindow32);
+
+    info->iConfigResult64 = info->iTimer->Configure( delayWindow64,
+                                                     intervalWindow64);
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TCallBack function for starting a flexible periodic timer.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartTimer( TAny* aArgument )
+    {
+    __ASSERT_ALWAYS(
+        aArgument != NULL,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+
+    const TTimeIntervalMicroSeconds32 KTimerDelay( 2000000 );
+    const TTimeIntervalMicroSeconds32 KTimerInterval( 2000000 );
+
+    CFlexPeriodic* timer =  reinterpret_cast<CFlexPeriodic*>( aArgument );
+
+    timer->Start(
+        KTimerDelay,
+        KTimerInterval,
+        TCallBack( StartTimer, timer )
+        );
+
+    return KErrNone;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// ___ _ _  _ ____ ____ ___ ____ _  _ ___     ____ _  _ _  _ ____ . ____ 
+//  |  | |\/| |___ [__   |  |__| |\/| |__]    |___ |  | |\ | |    ' [__  
+//  |  | |  | |___ ___]  |  |  | |  | |       |    |__| | \| |___   ___] 
+//
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Verify that the timestamps are expired at window.
+//
+// Note that the timer resolution is 1 sec, so, the actual expiration time can
+// be later than set.
+// ---------------------------------------------------------------------------
+//
+TBool CTestFlexPeriodic::AreTimestampsAtWindow( 
+    const RArray<TTime>& aTimestamps,
+    const TTimeIntervalMicroSeconds32& aDelay,
+    const TTimeIntervalMicroSeconds32& aInterval,
+    const TTimeIntervalMicroSeconds32& aDelayWindow,
+    const TTimeIntervalMicroSeconds32& aIntervalWindow )
+    {
+    __ASSERT_ALWAYS(
+        aTimestamps.Count() >= 2 && 
+        aDelay.Int() >= 0 &&
+        aInterval.Int() >= 0 &&
+        aDelayWindow.Int() >= 0 &&
+        aIntervalWindow.Int() >= 0,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+
+    // Timestamps are correct unless proved otherwise 
+    TBool ret = ETrue;
+
+    // For the 1st expiration is delay
+    TTimeIntervalMicroSeconds delay;
+    delay = aTimestamps[1].MicroSecondsFrom( aTimestamps[0] );
+    RDebug::Print( _L("Timer delay %Ld"), delay.Int64() );
+
+    if ( delay < aDelay.Int() - aDelayWindow.Int() || 
+         delay > aDelay.Int() + KTimerResolution )
+        {
+        ret = EFalse;
+        }
+
+    // The rest of the expirations are intervals
+    for ( TInt i( 2 ); i < aTimestamps.Count(); ++i )
+        {
+        TTimeIntervalMicroSeconds interval;
+        interval = aTimestamps[i].MicroSecondsFrom( aTimestamps[i-1] );
+        RDebug::Print( _L("Timer interval %Ld"), interval.Int64() );
+
+        if ( interval < aInterval.Int() - aIntervalWindow.Int() || 
+             interval > aInterval.Int() + KTimerResolution )
+            {
+            ret = EFalse;
+            }
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Convert the intervals from 64 bit to 32 bit and call 32 bit checking 
+// function.
+// ---------------------------------------------------------------------------
+//
+TBool CTestFlexPeriodic::AreTimestampsAtWindow( 
+    const RArray<TTime>& aTimestamps,
+    const TTimeIntervalMicroSeconds& aDelay,
+    const TTimeIntervalMicroSeconds& aInterval,
+    const TTimeIntervalMicroSeconds& aDelayWindow,
+    const TTimeIntervalMicroSeconds& aIntervalWindow )
+    {
+    __ASSERT_ALWAYS(
+        I64HIGH( aDelay.Int64() ) == 0 &&
+        I64HIGH( aInterval.Int64() ) == 0 &&
+        I64HIGH( aDelayWindow.Int64() ) == 0 &&
+        I64HIGH( aIntervalWindow.Int64() ) == 0,
+        User::Panic( KTestFlexTimerPanicCategory, KErrArgument ) );
+
+    TTimeIntervalMicroSeconds32 delay( I64INT( aDelay.Int64() ) );
+    TTimeIntervalMicroSeconds32 interval( I64INT( aInterval.Int64() ) );
+    TTimeIntervalMicroSeconds32 delayWindow( I64INT( aDelayWindow.Int64() ) );
+    TTimeIntervalMicroSeconds32 intervalWindow( I64INT( aIntervalWindow.Int64() ) );
+
+    return AreTimestampsAtWindow( aTimestamps, 
+                                  delay,
+                                  interval,
+                                  delayWindow,
+                                  intervalWindow );
+    }
+
+// ---------------------------------------------------------------------------
+// Compare are timestamp arrays same
+// ---------------------------------------------------------------------------
+//
+TBool CTestFlexPeriodic::AreTimestampsSame(
+    const RArray<TTime>& aLeft,
+    const RArray<TTime>& aRight )
+    {
+    TBool ret( ETrue );
+    if ( aLeft.Count() == aRight.Count() )
+        {
+        for ( TInt i( 0 ); i < aLeft.Count(); ++i )
+            {
+            if ( aLeft[i] != aRight[i] )
+                { // Different timestamp has been found
+                ret = EFalse;
+                break;
+                }
+            }
+        }
+    else
+        { // Arrays has different number of timestamps.
+        ret = EFalse;
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// ___ ____ _  _ ___  _    ____ ___ ____    ____ _  _ _  _ ____ . ____ 
+//  |  |___ |\/| |__] |    |__|  |  |___    |___ |  | |\ | |    ' [__  
+//  |  |___ |  | |    |___ |  |  |  |___    |    |__| | \| |___   ___] 
+//
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Configure window sizes - template function
+// 
+// Timers are designed so that the 1st timer will test that the delay is
+// correct and the 2nd timer will test that the interval is correct
+// ---------------------------------------------------------------------------
+template <class firstType, class secondType>
+TInt CTestFlexPeriodic::ConfigureWindowL( TTestResult& aResult )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const firstType KFirstDelay( 3000000 );             // 3 sec
+    const firstType KFirstInterval( 2000000 );          // 2 sec
+    const firstType KFirstDelayWindow( 0 );             // no window
+    const firstType KFirstIntervalWindow( 1500000 );    // 1.5 sec
+
+    const secondType KSecondDelay( 3500000 );           // 3.5 sec
+    const secondType KSecondInterval( 1000000 );        // 1 sec
+    const secondType KSecondDelayWindow( 1500000 );     // 1.5 sec
+    const secondType KSecondIntervalWindow( 0 );        // no window
+
+    const TUint KTestRunTime( 10000000 ); // 10 sec
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // Create, configure and start the flexible periodic timer
+    RArray<TTime> firstTimestamps;
+    CFlexPeriodic* firstTimer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( firstTimer );
+    firstTimer->Configure( KFirstDelayWindow, KFirstIntervalWindow );
+    firstTimer->Start( 
+        KFirstDelay, 
+        KFirstInterval, 
+        TCallBack( AddTimestamp, &firstTimestamps ) );
+
+    RArray<TTime> secondTimestamps;
+    CFlexPeriodic* secondTimer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( secondTimer );
+    secondTimer->Configure( KSecondDelayWindow, KSecondIntervalWindow );
+    secondTimer->Start( 
+        KSecondDelay, 
+        KSecondInterval,
+        TCallBack( AddTimestamp, &secondTimestamps ) );
+
+    // Initialize timer expiration time array with starting time to 
+    // ease analysing of data.
+    TTime startTime;
+    startTime.UniversalTime();
+    firstTimestamps.Append( startTime );
+    secondTimestamps.Append( startTime );
+
+    // The execution will be pending here while active scheduler is running...
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // Analyze results
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    // Check the 1st timer expiration time
+    if ( !AreTimestampsAtWindow( 
+            firstTimestamps, 
+            KFirstDelay, 
+            KFirstInterval, 
+            KFirstDelayWindow, 
+            KFirstIntervalWindow ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. First timer not in window.") );
+        }
+
+    // Check the 2nd timer expiration time
+    else if ( !AreTimestampsAtWindow( 
+            secondTimestamps, 
+            KSecondDelay, 
+            KSecondInterval, 
+            KSecondDelayWindow, 
+            KSecondIntervalWindow ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Second timer not in window.") );
+        }
+    
+    // Check that both timers are expired at the same time
+    else if ( !AreTimestampsSame( firstTimestamps, secondTimestamps ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Timers are not expired at the same time.") );
+        }
+
+    // Clean up
+    secondTimer->Cancel();
+    secondTimestamps.Close();
+    CleanupStack::PopAndDestroy( secondTimer );
+
+    firstTimer->Cancel();
+    firstTimestamps.Close();
+    CleanupStack::PopAndDestroy( firstTimer );
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Configure window sizes and start timer with given values - template 
+// function
+// ---------------------------------------------------------------------------
+template <class configureType, class startType>
+void CTestFlexPeriodic::ConfigureAndStartTimerL( 
+    RArray<TTime>& aTimestamps,
+    TInt64 aDelay,
+    TInt64 aInterval,
+    TInt64 aDelayWindow,
+    TInt64 aIntervalWindow )
+    {
+    const startType KDelay( aDelay );
+    const startType KInterval( aInterval );
+    const configureType KDelayWindow( aDelayWindow );
+    const configureType KIntervalWindow( aIntervalWindow );
+
+    const TUint KTestRunTime( 3000000 );
+
+    TTime now;
+    now.UniversalTime();
+    aTimestamps.Append( now );
+
+    // Create and start the flexible periodic timer
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+    timer->Configure( KDelayWindow, KIntervalWindow );
+    timer->Start( KDelay, KInterval, TCallBack( AddTimestamp, &aTimestamps ) );
+    
+    // The execution will be pending here while active scheduler is running...
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // Clean up
+    timer->Cancel();
+    CleanupStack::PopAndDestroy( timer );
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with NULL callback 
+// ---------------------------------------------------------------------------
+//
+template<class startType>
+TInt CTestFlexPeriodic::StartWithNullCallBackL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const startType KTimerDelay( 1000000 );
+    const startType KTimerInterval( 1000000 );
+
+    TInt(* nullCallback)(TAny*) = NULL;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   31 (EFlexPeriodicCallbackFunctionIsNull)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 31 );
+    
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+    timer->Start( 
+        KTimerDelay, 
+        KTimerInterval, 
+        TCallBack( nullCallback, NULL ) );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timer->Cancel();
+    CleanupStack::PopAndDestroy( timer );
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Panic thread after a few seconds
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::DoPanicL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const TTimeIntervalMicroSeconds32 KTimerDelay( 1000000 );
+    const TTimeIntervalMicroSeconds32 KTimerInterval( 1000000 );
+    const TTimeIntervalMicroSeconds32 KTestRunTime( 3000000 );
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+    timer->Start( 
+        KTimerDelay, 
+        KTimerInterval, 
+        TCallBack( DoNothing, NULL ) );
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    User::Panic(_L("Die die die!"), 0xDEAD);
+
+    // We should NEVER be here...
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timer->Cancel();
+    CleanupStack::PopAndDestroy( timer );
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// ____ _  _ _  _    _ _  _    ___ _  _ ____ ____ ____ ___  
+// |__/ |  | |\ |    | |\ |     |  |__| |__/ |___ |__| |  \ 
+// |  \ |__| | \|    | | \|     |  |  | |  \ |___ |  | |__/ 
+//
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Run test case in own thread
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::RunInThread( 
+    RThread& aThread, 
+    TTestCaseArguments& aArguments )
+    {
+    // RThread::Create() parameters
+    const TInt stackSize = 1024;
+    const TInt heapMinSize = 1024;
+    const TInt heapMaxSize = 1024;
+
+    TBuf<8> processName;
+    processName.Format( _L("%x"), &aArguments.iResult );
+    
+    // Create the thread
+    TInt ret = aThread.Create(
+        processName,
+        RunTestCase, 
+        stackSize,
+        heapMinSize,
+        heapMaxSize,
+        &aArguments,
+        EOwnerProcess );
+
+    // Start execution of the thread
+    aThread.Resume();
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Create cleanup stack
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::RunTestCase( TAny* aArgument )
+    {
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+
+    // Out of memory assert
+    __ASSERT_ALWAYS(
+        cleanup != NULL, 
+        User::Panic( KTestFlexTimerPanicCategory, KErrNoMemory ) );
+    
+    TRAPD( err, CTestFlexPeriodic::RunTestCaseL( aArgument ) );
+
+    delete cleanup;
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// Create scheduler and run the test case
+// ---------------------------------------------------------------------------
+//
+void CTestFlexPeriodic::RunTestCaseL( TAny* aArgument )
+    {
+    // Create and install active scheduler
+    CActiveScheduler* scheduler = scheduler = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+    
+    // Parse the arguments
+    TTestCaseArguments* args = reinterpret_cast<TTestCaseArguments*>( aArgument );
+    
+    // Call the function pointer with given arguments
+    TInt ret = (*(args->iTestFunction))(args->iResult, args->iCallback );
+    User::LeaveIfError( ret );
+
+    // Clean up
+    CleanupStack::PopAndDestroy( scheduler );
+    }
+
+// ---------------------------------------------------------------------------
+// ___ ____ ____ ___    ____ ____ ____ ____ ____ 
+//  |  |___ [__   |     |    |__| [__  |___ [__  
+//  |  |___ ___]  |     |___ |  | ___] |___ ___] 
+//
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start one CFlexPeriodic and wait for few expirations.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartOneTimerL( 
+        TTestResult& aResult, 
+        CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const TTimeIntervalMicroSeconds32 KTickInterval( 1000000 ); // 1 sec
+    const TUint KTestRunTime( 5000000 );
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // Storage for flexible periodic timer timestamps
+    RArray<TTime> timestamps;
+
+    // Create and start the flexible periodic timer
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+    timer->Start( 
+        KTickInterval, 
+        KTickInterval, 
+        TCallBack( AddTimestamp, &timestamps ) );
+
+    // Initialize timer expiration time array with starting time to 
+    // ease analysing of data.
+    TTime startTime;
+    startTime.UniversalTime();
+    timestamps.Append( startTime );
+    
+    // The execution will be pending here while active scheduler is running...
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // Analyze results
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    // Only start time in timestamp array
+    if ( timestamps.Count() == 1 )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. No timer expired.") );
+        }
+
+    // Check that the timers are expired at maximum delay due there are only
+    // one timer, so, no alignment can be happened.
+    if ( !AreTimestampsAtWindow( timestamps, KTickInterval, KTickInterval, 0, 0 ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Timer not in maximum window.") );
+        }
+
+    // Clean up
+    timer->Cancel();
+    timestamps.Close();
+    CleanupStack::PopAndDestroy( timer );
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start one CFlexPeriodic and wait for few expirations.
+// Give also Error callback function.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartOneTimerWithErrorCbL( 
+        TTestResult& aResult, 
+        CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const TTimeIntervalMicroSeconds32 KTickInterval( 1000000 ); // 1 sec
+    const TUint KTestRunTime( 5000000 );
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // Storage for flexible periodic timer timestamps
+    RArray<TTime> timestamps;
+
+    // Create and start the flexible periodic timer
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+    timer->Start( 
+        KTickInterval, 
+        KTickInterval, 
+        TCallBack( AddTimestamp, &timestamps ),
+        TCallBack( PanicClient, NULL ) );
+
+    // Initialize timer expiration time array with starting time to 
+    // ease analysing of data.
+    TTime startTime;
+    startTime.UniversalTime();
+    timestamps.Append( startTime );
+    
+    // The execution will be pending here while active scheduler is running...
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // Analyze results
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    // Only start time in timestamp array
+    if ( timestamps.Count() == 1 )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. No timer expired.") );
+        }
+
+    // Check that the timers are expired at maximum delay due there are only
+    // one timer, so, no alignment can be happened.
+    if ( !AreTimestampsAtWindow( timestamps, KTickInterval, KTickInterval, 0, 0 ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Timer not in maximum window.") );
+        }
+
+    // Clean up
+    timer->Cancel();
+    timestamps.Close();
+    CleanupStack::PopAndDestroy( timer );
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start one CFlexPeriodic, cancel it and restart it in callback
+// function.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::CallbackRestartL( 
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const TTimeIntervalMicroSeconds KTickInterval( 1000000 ); // 1 sec
+    const TTimeIntervalMicroSeconds KTick2ndInterval( 2000000 ); // 2 sec
+    const TUint KTestRunTime( 10000000 );
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    RArray<TTime> firstTimestamps;
+    RArray<TTime> secondTimestamps;
+
+    TRestartInfo info;
+    info.iTimer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    info.iFirstTicksLeft = 1;
+    info.iFirstTimestamps = &firstTimestamps;
+    info.iSecondTimestamps = &secondTimestamps;
+    info.iSecondInterval = KTick2ndInterval;
+
+    // Create and start the flexible periodic timer
+    CleanupStack::PushL( info.iTimer );
+    info.iTimer->Start( 
+        KTickInterval, 
+        KTickInterval, 
+        TCallBack( RestartTimer, &info ) );
+
+    // Initialize timer expiration time array with starting time to 
+    // ease analysing of data.
+    TTime startTime;
+    startTime.UniversalTime();
+    firstTimestamps.Append( startTime );
+    
+    // The execution will be pending here while active scheduler is running...
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // Analyze results
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    // Check the 1st timer expiration time
+    if ( !AreTimestampsAtWindow( firstTimestamps, KTickInterval, KTickInterval, 0, 0 ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Pre-reset timer not in maximum window.") );
+        }
+    
+    // Check the rest of timers
+    else if ( !AreTimestampsAtWindow( secondTimestamps, KTick2ndInterval, KTick2ndInterval, 0, 0 ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Post-reset timer not in maximum window.") );
+        }
+    
+    // Clean up
+    info.iTimer->Cancel();
+    firstTimestamps.Close();
+    secondTimestamps.Close();
+    CleanupStack::PopAndDestroy( info.iTimer );
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure window sizes - 32 bit
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWindow32L( 
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    return ConfigureWindowL<TTimeIntervalMicroSeconds32,TTimeIntervalMicroSeconds32>( aResult );
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure window sizes - 64 bit
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWindow64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    return ConfigureWindowL<TTimeIntervalMicroSeconds,TTimeIntervalMicroSeconds>( aResult );
+    }
+
+// ---------------------------------------------------------------------------
+// OK TEST CASE: Configure window sizes - mixed 32 bit and 64 bit
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWindowMixL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    return ConfigureWindowL<TTimeIntervalMicroSeconds32,TTimeIntervalMicroSeconds>( aResult );
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure after timer has started 
+// The test case is divided into following parts:
+// 1) Remove slack from the heartbeat to make it sure that timer's default
+//    windows does not cause the drifting of the timer.
+// 2) Start timer, try to configure it, verify that configure has not been
+//    changed (no alignment should be made by heartbeat)
+// 3) Cancel the timer and start it with a callback that tries to configure
+//    it while in callback, check the results
+// 4) Verify that the configuration stil works by happened timer alignment
+//    by the heartbeat
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureAfterStartL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    
+    // Heartbeat timer
+    // Use 1us to adjust the engine's timer. 0 returns immediately.
+    const TTimeIntervalMicroSeconds32 KHeartbeatDelay( 1 );
+    const TTimeIntervalMicroSeconds32 KHeartbeatInterval( 1000000 );
+    const TTimeIntervalMicroSeconds32 KHeartbeatDelayWindow( 0 );
+    const TTimeIntervalMicroSeconds32 KHeartbeatIntervalWindow( 0 );
+
+    // Timer under test
+    const TTimeIntervalMicroSeconds32 KTimerDelayNow( 0 );
+    const TTimeIntervalMicroSeconds32 KTimerDelay( 2000000 );
+    const TTimeIntervalMicroSeconds32 KTimerInterval( 2000000 );
+    const TTimeIntervalMicroSeconds32 KTimerInitialDelayWindow( 0 );
+    const TTimeIntervalMicroSeconds32 KTimerInitialIntervalWindow( 0 );
+
+    const TTimeIntervalMicroSeconds32 KTimerDelayWindow32( 1500000 );
+    const TTimeIntervalMicroSeconds32 KTimerIntervalWindow32( 1500000 );
+
+    const TTimeIntervalMicroSeconds KTimerDelayWindow64( 1500000 );
+    const TTimeIntervalMicroSeconds KTimerIntervalWindow64( 1500000 );
+    
+    const TUint KConfigNokTestRunTime( 7000000 );
+    const TUint KTestCbConfigRunTime( KHeartbeatInterval.Int() );
+    const TUint KConfigOkTestRunTime( 4000000 );
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Create, configure and initialize and start the heartbeat
+    // This timer is used for checking that the timer under test is reacting
+    // correctly to configurations.
+    RArray<TTime> heartbeatTimes;
+    CFlexPeriodic* heartbeat = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( heartbeat );
+    heartbeat->Configure( KHeartbeatDelayWindow, KHeartbeatIntervalWindow );
+    heartbeat->Start( 
+        KHeartbeatDelay, 
+        KHeartbeatInterval, 
+        TCallBack( AddTimestamp, &heartbeatTimes ) );
+
+    // Remove the slack from timer start up -- wait till next second
+    const TInt64 KSecondInMicroSeconds( 1000000 );
+    TTime now;
+    now.UniversalTime();
+    heartbeatTimes.Append( now );
+    TUint slack( I64LOW( KSecondInMicroSeconds - now.Int64() % KSecondInMicroSeconds ) );
+
+                     //    //  ___     _____
+    WaitL( slack ); // // // //_ // //  //
+                   //_//_// //  // //  //
+
+    // Create and start the flexible periodic timer
+    RArray<TTime> timestamps;
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+    timer->Configure( KTimerInitialDelayWindow, KTimerInitialIntervalWindow );
+    timer->Start( 
+        KTimerDelay, 
+        KTimerInterval, 
+        TCallBack( AddTimestamp, &timestamps ) );
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    if ( timer->Configure( KTimerDelayWindow32, KTimerIntervalWindow32 ) != KErrInUse )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. 32 bit configure didn't return KErrInUse") );
+        }
+    else if ( timer->Configure( KTimerDelayWindow64, KTimerIntervalWindow64 ) != KErrInUse )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. 64 bit configure didn't return KErrInUse") );
+        }
+
+    // Initialize timer expiration time array with starting time to 
+    // ease analysing of data.
+    now.UniversalTime();
+    timestamps.Append( now );
+                                     //    //  ___     _____
+    WaitL( KConfigNokTestRunTime ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+
+    // Check the 1st timer expiration time
+    RDebug::Print( _L("Timer:") );
+    if ( !AreTimestampsAtWindow( 
+            timestamps, 
+            KTimerDelay,
+            KTimerInterval,
+            KTimerInitialDelayWindow,
+            KTimerInitialIntervalWindow ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Configuration changed after start. ") );
+        }
+
+    // Restart the timer to try configuration while callback
+    timer->Cancel();
+
+    TConfigureInfo configInfo;
+    configInfo.iTimer = timer;
+    configInfo.iDelayWindow = KTimerDelayWindow32.Int();
+    configInfo.iIntervalWindow = KTimerIntervalWindow32.Int();
+    configInfo.iConfigResult32 = 0xDEADBEEF; // Initialize result
+    configInfo.iConfigResult64 = 0xDEADBEEF; // Initialize result
+
+    timer->Start(
+        KTimerDelayNow, 
+        KTimerInterval, 
+        TCallBack( ConfigureTimer, &configInfo ) );
+
+                                    //    //  ___     _____
+    WaitL( KTestCbConfigRunTime ); // // // //_ // //  //
+                                  //_//_// //  // //  //
+
+    timer->Cancel();
+
+    RDebug::Print( _L("configInfo.iConfigResult32=%d (0x%x)"), configInfo.iConfigResult32, configInfo.iConfigResult32 );
+    RDebug::Print( _L("configInfo.iConfigResult64=%d (0x%x)"), configInfo.iConfigResult64, configInfo.iConfigResult64 );
+
+    // Analyze the results
+    if ( configInfo.iConfigResult32 != KErrInUse )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. 32 bit configure in callback didn't return KErrInUse") );
+        }
+    else if ( configInfo.iConfigResult64 != KErrInUse )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. 64 bit configure in callback didn't return KErrInUse") );
+        }
+
+    // Test that the configuration still works
+    RArray<TTime> secondTimestamps;
+    now.UniversalTime();
+    secondTimestamps.Append( now );
+
+    if ( timer->Configure( KTimerDelayWindow32, KTimerIntervalWindow32 ) != KErrNone )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Configure failed.") );
+        }
+    else
+        {
+        timer->Start(
+            KTimerDelay,
+            KTimerInterval,
+            TCallBack( AddTimestamp, &secondTimestamps ));
+
+                                        //    //  ___     _____
+        WaitL( KConfigOkTestRunTime ); // // // //_ // //  //
+                                      //_//_// //  // //  //
+
+        // Check timestamps, they should be the same as heartbeat
+        RDebug::Print( _L("secondTimestamps:") );
+        if ( !AreTimestampsAtWindow( 
+                secondTimestamps, 
+                KHeartbeatInterval, // Heartbeat was running already 
+                KHeartbeatInterval,
+                KHeartbeatInterval, // There can be adjustement with 1st expiration 
+                0 ) )
+            {
+            aResult.SetResult( 
+                KErrGeneral, 
+                _L("Test case failed. Configure does not work.") );
+            }
+        }
+
+    RDebug::Print( _L("Heartbeat:") );
+    if ( !AreTimestampsAtWindow( 
+            heartbeatTimes, 
+            KHeartbeatDelay,
+            KHeartbeatInterval,
+            KHeartbeatDelayWindow,
+            KHeartbeatIntervalWindow ) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Heartbeat failure.") );
+        }
+
+    // Clean up
+    timestamps.Close();
+    secondTimestamps.Close();
+    timer->Cancel();
+    CleanupStack::PopAndDestroy( timer );
+
+    heartbeatTimes.Close();
+    heartbeat->Cancel();
+    CleanupStack::PopAndDestroy( heartbeat );
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a running timer again.
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartAfterStartL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const TTimeIntervalMicroSeconds32 KTimerDelay( 2000000 );
+    const TTimeIntervalMicroSeconds32 KTimerInterval( 2000000 );
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+
+    // This start should work...
+    timer->Start( 
+        KTimerDelay, 
+        KTimerInterval, 
+        TCallBack( DoNothing, NULL ) );
+
+    // ... and next start should panic with
+    // Panic category: "E32USER-CBase"
+    // Panic reason:   42 (attempt to active CActive when a request is still 
+    //                     outstanding)
+    
+    // Set panic code 42 to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        42 );
+
+    timer->Start( 
+        KTimerDelay, 
+        KTimerInterval, 
+        TCallBack( DoNothing, NULL ) );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    // Clean up
+    timer->Cancel();
+    CleanupStack::PopAndDestroy( timer );
+
+    __UHEAP_MARKEND;    
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a running timer again in callback function
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartInCallbackL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    // Constants
+    const TTimeIntervalMicroSeconds32 KTimerDelay( 1000000 );
+    const TTimeIntervalMicroSeconds32 KTimerInterval( 1000000 );
+    const TTimeIntervalMicroSeconds32 KTestRunTime( 3000000 );
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    CFlexPeriodic* timer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
+    CleanupStack::PushL( timer );
+
+    // The callback should panic with
+    // Panic category: "E32USER-CBase"
+    // Panic reason:   42 (attempt to active CActive when a request is still 
+    //                     outstanding)
+    
+    // Set panic code 42 to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        42 );
+
+    timer->Start( 
+        KTimerDelay, 
+        KTimerInterval, 
+        TCallBack( StartTimer, timer ) );
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    // Clean up
+    timer->Cancel();
+    CleanupStack::PopAndDestroy( timer );
+
+    __UHEAP_MARKEND;    
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with negative delay, 32 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithNegativeDelay32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+
+    RArray<TTime> timestamps;
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   6 (EFlexPeriodicDelayLessThanZero)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 6 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+    
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with zero interval, 32 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithZeroInterval32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( 0 );
+
+    RArray<TTime> timestamps;
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   7 (EFlexPeriodicIntervalTooSmall)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 7 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with negative interval, 32 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithNegativeInterval32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+
+    RArray<TTime> timestamps;
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   7 (EFlexPeriodicIntervalTooSmall)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 7 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with negative delay, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithNegativeDelay64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   6 (EFlexPeriodicDelayLessThanZero)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 6 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with zero interval, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithZeroInterval64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( 0 );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   7 (EFlexPeriodicIntervalTooSmall)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 7 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with negative interval, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithNegativeInterval64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   7 (EFlexPeriodicIntervalTooSmall)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 7 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure timer with negative delay window, 32 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWithNegativeDelayWindow32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   8 (EFlexPeriodicDelayWindowLessThanZero)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 8 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KAllowedValue,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure timer with negative interval window, 32 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWithNegativeIntervalWindow32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   9 (EFlexPeriodicIntervalWindowLessThanZero)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 9 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KAllowedValue,
+        KAllowedValue,
+        KAllowedValue,
+        KIllegalValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure timer with negative delay window, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWithNegativeDelayWindow64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   8 (EFlexPeriodicDelayWindowLessThanZero)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 8 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KAllowedValue,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure timer with negative interval window, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ConfigureWithNegativeIntervalWindow64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt KIllegalValue( -1 );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   9 (EFlexPeriodicIntervalWindowLessThanZero)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 9 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KAllowedValue,
+        KAllowedValue,
+        KAllowedValue,
+        KIllegalValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start with minimum and maximum values
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithMinAndMaxL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KMinimumDelayValue( 0 );
+    const TInt KMinimumIntervalValue( 1 );
+    const TInt KNormalValue( 1000000 );
+    const TInt KMaximum32BitValue( 0x7FFFFFFF );
+
+//    const TInt64 KLarge64BitValue( 0x6FFFFFFFFFFFFFFF );  // Should not panic (till few years)
+
+    // Years * Days * Hours * Minutes * Seconds * Microseconds
+    const TInt64 KLarge64BitValue( ((TInt64)(1)) * 365 * 24 * 60 * 60 * 1000000 );
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    RArray<TTime> timestamps;
+
+    TTime now;
+    now.UniversalTime();
+
+    // > DEBUG
+    TTimeIntervalMicroSeconds longLongInterval( KLarge64BitValue );
+    now += longLongInterval;
+    TDateTime date;
+    date = now.DateTime();
+    // < DEBUG
+
+    // Start with min delay, 32 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KMinimumDelayValue,
+        KNormalValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    if ( !AreTimestampsAtWindow(
+            timestamps,
+            TTimeIntervalMicroSeconds32( KMinimumDelayValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ) ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 32 bit min delay failed") );
+        }
+    timestamps.Reset();
+
+    // Start with max delay, 32 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KMaximum32BitValue,
+        KNormalValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    // Only one timestamp (the start time) is allowed
+    if ( timestamps.Count() > 1 )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 32 bit max delay failed") );
+        }
+    timestamps.Reset();
+
+    // Start with min interval, 32 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KNormalValue,
+        KMinimumIntervalValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    if ( !AreTimestampsAtWindow(
+            timestamps,
+            TTimeIntervalMicroSeconds32( KNormalValue ),
+            TTimeIntervalMicroSeconds32( KMinimumIntervalValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ) ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 32 bit min interval failed") );
+        }
+    timestamps.Reset();
+
+    // Start with max interval, 32 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32>(
+        timestamps,
+        KNormalValue,
+        KMaximum32BitValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    if ( !AreTimestampsAtWindow(
+            timestamps,
+            TTimeIntervalMicroSeconds32( KNormalValue ),
+            TTimeIntervalMicroSeconds32( KMaximum32BitValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ),
+            TTimeIntervalMicroSeconds32( KNormalValue ) ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 32 bit min interval failed") );
+        }
+    timestamps.Reset();
+
+    // Start with min delay, 64 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KMinimumDelayValue,
+        KNormalValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    if ( !AreTimestampsAtWindow(
+            timestamps,
+            TTimeIntervalMicroSeconds( KMinimumDelayValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ) ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 64 bit min delay failed") );
+        }
+    timestamps.Reset();
+
+    // Start with large delay, 64 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KLarge64BitValue,
+        KNormalValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    // Only one timestamp (the start time) is allowed
+    if ( timestamps.Count() > 1 )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 64 bit max delay failed") );
+        }
+    timestamps.Reset();
+
+    // Start with min interval, 64 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KNormalValue,
+        KMinimumIntervalValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    if ( !AreTimestampsAtWindow(
+            timestamps,
+            TTimeIntervalMicroSeconds( KNormalValue ),
+            TTimeIntervalMicroSeconds( KMinimumIntervalValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ) ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 64 bit min interval failed") );
+        }
+    timestamps.Reset();
+
+    // Start with large interval, 64 bit
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KNormalValue,
+        KLarge64BitValue,
+        KNormalValue,
+        KNormalValue );
+    // Validate results
+    // AreTimestampsAtWindow() does not accept values over 0xFFFFFFFF.
+    // However, this is not a problem due there should be only the timestamps
+    // of start time and delay expiration; 32 bit value can be used instead of
+    // the real interval.
+    if ( !AreTimestampsAtWindow(
+            timestamps,
+            TTimeIntervalMicroSeconds( KNormalValue ),
+            TTimeIntervalMicroSeconds( KMaximum32BitValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ),
+            TTimeIntervalMicroSeconds( KNormalValue ) ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. 64 bit max interval failed") );
+        }
+    timestamps.Reset();
+
+    // If test execution is here, we'll passed
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    // Clean up
+    timestamps.Close();
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with maximum delay, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithMaximumDelay64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt64 KIllegalValue( 0x7FFFFFFFFFFFFFFF );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   24 (EFlexTimerServerIllegalTimerValue)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 24 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with maximum interval, 64 bit interface
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithMaximumInterval64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback  )
+    {
+    __UHEAP_MARK;
+
+    const TInt KAllowedValue( 1 );
+    const TInt64 KIllegalValue( 0x7FFFFFFFFFFFFFFF );
+    
+    RArray<TTime> timestamps;
+    
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // ConfigureAndStartTimerL should panic:
+    //  Category: "CFlexPeriodic" 
+    //  Reason:   24 (EFlexTimerServerIllegalTimerValue)
+    // Set the panic code to acceptable exit reason
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::EPanic, 24 );
+
+    ConfigureAndStartTimerL<TTimeIntervalMicroSeconds, TTimeIntervalMicroSeconds>(
+        timestamps,
+        KAllowedValue,
+        KIllegalValue,
+        KAllowedValue,
+        KAllowedValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( CTestModuleIf::ENormal, KErrNone );
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    // Clean up
+    timestamps.Close();
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with NULL callback (32 bit)
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithNullCallBack32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    return StartWithNullCallBackL<TTimeIntervalMicroSeconds32>( aResult, aCallback );
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with NULL callback (64 bit)
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::StartWithNullCallBack64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    return StartWithNullCallBackL<TTimeIntervalMicroSeconds>( aResult, aCallback );
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Client crashes
+// 1) Start two timers in separate threads
+// 2) The 1st timer will panic after a while
+// 3) Check that the 2nd timer is ok -> server works OK
+// ---------------------------------------------------------------------------
+//
+TInt CTestFlexPeriodic::ClientCrashL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    __UHEAP_MARK;
+
+    // Must be bigger than ClientCrashL and StartOneTimerL
+    const TTimeIntervalMicroSeconds32 KTestRunTime( 6000000 );
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Start test case ClientCrashL
+    RThread threadA;
+    TTestResult resultA;
+    TTestCaseArguments caseA = { DoPanicL, resultA, aCallback }; 
+    RunInThread( threadA, caseA );
+
+    // Start test case StartOneTimerL
+    RThread threadB;
+    TTestResult resultB;
+    TTestCaseArguments caseB = { StartOneTimerL, resultB, aCallback }; 
+    RunInThread( threadB, caseB );
+
+                            //    //  ___     _____
+    WaitL( KTestRunTime ); // // // //_ // //  //
+                          //_//_// //  // //  //
+
+    // Analyze results
+    aResult.SetResult(KErrNone, _L("Test case passed.") );
+
+    // ClientCrashL should be paniced with reason 0xDEAD
+    if ( threadA.ExitType() != EExitPanic || threadA.ExitReason() != 0xDEAD )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Client did not panic (correctly).") );
+        }
+    // StartOneTimerL should be finished ok
+    else if ( resultB.iResult != KErrNone || threadB.ExitType() == EExitPanic )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Timer failed.") );
+        }
+
+    threadA.Close();
+    threadB.Close();
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/src/testflextimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,745 @@
+/*
+* Copyright (c) 2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+
+// INCLUDE FILES
+#include <StifTestInterface.h>
+#include "TestFlexTimer.h"
+#include "SettingServerClient.h"
+#include "testflexperiodic.h"
+#include "testcflextimer.h"
+#include "testrflextimer.h"
+#include "rflextimerservermonitor.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::CTestFlexTimer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTestFlexTimer::CTestFlexTimer()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void CTestFlexTimer::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
+
+    iStdLog = CStifLogger::NewL( KTestFlexTimerLogPath, 
+                                 KTestFlexTimerLogFile);
+    iLog = iStdLog;
+    
+    iVersionLogged = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTestFlexTimer* CTestFlexTimer::NewL()
+    {
+    CTestFlexTimer* self = new (ELeave) CTestFlexTimer;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CTestFlexTimer::~CTestFlexTimer()
+    { 
+    iLog = NULL;
+    delete iStdLog;
+    iStdLog = NULL;
+    delete iTCLog;
+    iTCLog = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt CTestFlexTimer::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::CreateTitleLoggerL
+// Check for settings and create logger with test case title in file name.
+// -----------------------------------------------------------------------------
+//
+void CTestFlexTimer::CreateTitleLoggerL(void)
+    {
+    //Open new log file with test case title in file name
+    if(iAddTestCaseTitleToLogName)
+        {
+        // Check if there is no test case logger already created.
+        if(iTCLog) 
+            { 
+            delete iTCLog; 
+            iTCLog = NULL; 
+            } 
+            
+        TFileName logFileName;
+        TName title;
+        TestModuleIf().GetTestCaseTitleL(title);
+        
+        logFileName.Format(KTestFlexTimerLogFileWithTitle, &title);
+
+        iTCLog = CStifLogger::NewL(KTestFlexTimerLogPath, 
+                                 logFileName);
+        iLog = iTCLog; 
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::CreateStdLoggerL
+// Check for logger settings and create standard logger.
+// -----------------------------------------------------------------------------
+//
+void CTestFlexTimer::DeleteTitleLogger(void)
+    {
+    //Delete title logger
+    if(iAddTestCaseTitleToLogName)
+        {
+        iLog = iStdLog;
+        delete iTCLog;
+        iTCLog = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt CTestFlexTimer::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+    
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+        
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+        }
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt CTestFlexTimer::RunTestCaseL(
+    const TInt aCaseNumber,
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+    SendTestModuleVersion();
+
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case( aCaseNumber );
+
+    _LIT( KLogInfo, "Starting testcase [%S]" );
+    iLog->Log( KLogInfo, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        //Open new log file with test case title in file name
+        CreateTitleLoggerL();
+    
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+
+        // Create and install an active scheduler for timers
+        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
+        CleanupStack::PushL( scheduler );
+        CActiveScheduler::Install( scheduler );
+        //execStatus  = ( this->*iMethod )( aResult );
+        TRAPD(err, execStatus  = ( *iMethod )( aResult, this ));
+
+        CleanupStack::PopAndDestroy( scheduler );
+
+        // Test case was executed
+        DeleteTitleLogger();
+
+        User::LeaveIfError(err);
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+TBool CTestFlexTimer::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& /* aFirstMemFailure */, 
+                                TInt& /* aLastMemFailure */ ) 
+    {
+    _LIT( KOOMTestQueryL, "CTestFlexTimer::OOMTestQueryL" );
+    iLog->Log( KOOMTestQueryL ); 
+
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+void CTestFlexTimer::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+void CTestFlexTimer::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestFlexTimer::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//                  
+void CTestFlexTimer::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+//-----------------------------------------------------------------------------
+// CTemplateScriptTestFlexTimer::SendTestModuleVersion
+// Method used to send version of test module
+//-----------------------------------------------------------------------------
+//
+void CTestFlexTimer::SendTestModuleVersion()
+	{
+	if(iVersionLogged)
+		{
+		return;
+		}
+	
+	TVersion moduleVersion;
+	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
+	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
+	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
+	
+	TFileName moduleName;
+	moduleName = _L("TestFlexTimer.dll");
+
+	TBool newVersionOfMethod = ETrue;
+	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+	iVersionLogged = ETrue;
+	}
+
+// ---------------------------------------------------------------------------
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+//
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// ---------------------------------------------------------------------------
+//
+const TCaseInfo CTestFlexTimer::Case( const TInt aCaseNumber ) const 
+    {
+    static TCaseInfoInternal const KCases[] =
+        {
+        // To add new test cases, add new items to this array
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // CDemoModule::PrintTest. Otherwise the compiler
+        // gives errors.
+
+        // Start FlexTimer server monitoring
+        ENTRY( "FlexTimerServer: Start crash monitoring", CTestFlexTimer::StartServerMonitoringL ),
+	    ENTRY( "FlexTimerClient: Change Priority: MuchMore", CTestFlexTimer::SetThreadPriorityMuchMore ),
+        ENTRY( "FlexTimerClient: Change Priority: Normal", CTestFlexTimer::SetThreadPriorityNormal ),
+
+        // CFlexPeriodic tests
+        ENTRY( "CFlexPeriodic: Start one timer", CTestFlexPeriodic::StartOneTimerL ),
+        ENTRY( "CFlexPeriodic: Start one timer with error CB", CTestFlexPeriodic::StartOneTimerWithErrorCbL ),
+        ENTRY( "CFlexPeriodic: Restart timer in callback", CTestFlexPeriodic::CallbackRestartL ),
+        ENTRY( "CFlexPeriodic: 32bit configure", CTestFlexPeriodic::ConfigureWindow32L ),
+        ENTRY( "CFlexPeriodic: 64bit configure", CTestFlexPeriodic::ConfigureWindow64L ),
+        ENTRY( "CFlexPeriodic: Mixed bit configure", CTestFlexPeriodic::ConfigureWindowMixL ),
+        ENTRY( "CFlexPeriodic: Configure after start", CTestFlexPeriodic::ConfigureAfterStartL ),
+        ENTRY( "CFlexPeriodic: Start timer twice", CTestFlexPeriodic::StartAfterStartL ),
+        ENTRY( "CFlexPeriodic: Start timer in callback", CTestFlexPeriodic::StartInCallbackL ),
+        ENTRY( "CFlexPeriodic: Start timer with negative delay (32 bit)", CTestFlexPeriodic::StartWithNegativeDelay32L ),
+        ENTRY( "CFlexPeriodic: Start timer with zero interval (32 bit)", CTestFlexPeriodic::StartWithZeroInterval32L ),
+        ENTRY( "CFlexPeriodic: Start timer with negative interval (32 bit)", CTestFlexPeriodic::StartWithNegativeInterval32L ),
+        ENTRY( "CFlexPeriodic: Start timer with negative delay (64 bit)", CTestFlexPeriodic::StartWithNegativeDelay64L ),
+        ENTRY( "CFlexPeriodic: Start timer with zero interval (64 bit)", CTestFlexPeriodic::StartWithZeroInterval64L ),
+        ENTRY( "CFlexPeriodic: Start timer with negative interval (64 bit)", CTestFlexPeriodic::StartWithNegativeInterval64L ),
+        ENTRY( "CFlexPeriodic: Configure timer with negative delay window (32 bit)", CTestFlexPeriodic::ConfigureWithNegativeDelayWindow32L ),
+        ENTRY( "CFlexPeriodic: Configure timer with negative interval window (32 bit)", CTestFlexPeriodic::ConfigureWithNegativeIntervalWindow32L ),
+        ENTRY( "CFlexPeriodic: Configure timer with negative delay window (64 bit)", CTestFlexPeriodic::ConfigureWithNegativeDelayWindow64L ),
+        ENTRY( "CFlexPeriodic: Configure timer with negative interval window (64 bit)", CTestFlexPeriodic::ConfigureWithNegativeIntervalWindow64L ),
+        ENTRY( "CFlexPeriodic: Start timer with min and max values", CTestFlexPeriodic::StartWithMinAndMaxL ),
+        ENTRY( "CFlexPeriodic: Start timer with maximum delay (64 bit)", CTestFlexPeriodic::StartWithMaximumDelay64L ),
+        ENTRY( "CFlexPeriodic: Start timer with maximum interval (64 bit)", CTestFlexPeriodic::StartWithMaximumInterval64L ),
+        ENTRY( "CFlexPeriodic: Start timer NULL callback function (32 bit)", CTestFlexPeriodic::StartWithNullCallBack32L ),
+        ENTRY( "CFlexPeriodic: Start timer NULL callback function (64 bit)", CTestFlexPeriodic::StartWithNullCallBack64L ),
+        ENTRY( "CFlexPeriodic: Client crash", CTestFlexPeriodic::ClientCrashL ),
+        //CFlexTimer tests
+        ENTRY( "CFlexTimer: Create and destroy a timer - After", CTestCFlexTimer::CreateAndDestroyCFlexTimerL ),
+        ENTRY( "CFlexTimer: Create and expire a timer - After", CTestCFlexTimer::CreateAndExpireCFlexTimerL ),
+        ENTRY( "CFlexTimer: Create two timers and expire those - overlapping - After 32bit", CTestCFlexTimer::CreateAndExpireTwoOverlappingAfterTimersL ),
+        ENTRY( "CFlexTimer: Create two timers and expire those - overlapping - After 64bit", CTestCFlexTimer::CreateAndExpireTwoOverlappingAfterTimers64L ),
+        ENTRY( "CFlexTimer: Create two timers and expire those - non overlapping - After", CTestCFlexTimer::CreateAndExpireTwoNonOverlappingAfterTimersL ),
+        ENTRY( "CFlexTimer: Create zillion timers and expire them at rapid sequence", CTestCFlexTimer::HumongousAmountOfTimeridelidilidousL ),
+        ENTRY( "CFlexTimer: Create overlapping After and At timers and non-overlapping AtUTC", CTestCFlexTimer::CreateAndExpireThreeTimersL ),
+        ENTRY( "CFlexTimer: Start and cancel timers", CTestCFlexTimer::NormalCancelL ),
+        ENTRY( "CFlexTimer: Cancel timer that would have triggered another timer", CTestCFlexTimer::CancelTimerThatWouldHaveTriggeredAnotherTimerL ),
+        ENTRY( "CFlexTimer: Configure 50 pct and 10 pct windows - overlap - 1", CTestCFlexTimer::ConfigureCTimerOverlap1L ),
+        ENTRY( "CFlexTimer: Configure 50 pct and 10 pct windows - overlap - 2", CTestCFlexTimer::ConfigureCTimerOverlap2L ),
+        ENTRY( "CFlexTimer: Configure 0 pct and 100 pct windows - overlap - 3", CTestCFlexTimer::ConfigureCTimerOverlap3L ),
+        ENTRY( "CFlexTimer: Configure 0 pct and 10 pct windows - non-overlap - 1", CTestCFlexTimer::ConfigureCTimerNonOverlap1L ),
+        ENTRY( "CFlexTimer: Configure 50 pct and 50 pct windows - non-overlap - 2", CTestCFlexTimer::ConfigureCTimerNonOverlap2L ),     
+        ENTRY( "CFlexTimer: System Time Changes", CTestCFlexTimer::SystemTimeChangesL ),
+        ENTRY( "CFlexTimer: Time zone changes", CTestCFlexTimer::TimeZoneChangesL ),
+        ENTRY( "CFlexTimer: Dumbass parameters for CFlexTimer", CTestCFlexTimer::DumbAssParametersForCTimerL ),
+        ENTRY( "CFlexTimer: 32bit After called with zero interval", CTestCFlexTimer::DumbAssParametersForCTimerZero32bitL ),
+        ENTRY( "CFlexTimer: 64bit After called with zero interval", CTestCFlexTimer::DumbAssParametersForCTimerZero64bitL ),
+        ENTRY( "CFlexTimer: 64bit After called with max interval", CTestCFlexTimer::DumbAssParametersForCTimer64MaxL ),
+        ENTRY( "CFlexTimer: 64bit After called with three year interval", CTestCFlexTimer::DumbAssParametersForCTimer64ThreeYearsL ),
+        ENTRY( "CFlexTimer: 64bit After called with one year interval", CTestCFlexTimer::DumbAssParametersForCTimer64OneYearL ),
+        ENTRY( "CFlexTimer: After (32bit) called with negative value", CTestCFlexTimer::AfterWithNegativeValueL ),
+        ENTRY( "CFlexTimer: At with current time", CTestCFlexTimer::AtWithCurrentTimeL ),
+        ENTRY( "CFlexTimer: AtUTC with current time", CTestCFlexTimer::AtUTCWithCurrentTimeL ),
+        ENTRY( "CFlexTimer: At with three year timer", CTestCFlexTimer::AtWithThreeYearsL ),
+        ENTRY( "CFlexTimer: At with one year timer", CTestCFlexTimer::AtWithOneYearL ),
+        ENTRY( "CFlexTimer: At() with time in the past", CTestCFlexTimer::AtWithTimeInThePastL ),
+        ENTRY( "CFlexTimer: Cancel timer that is already expired", CTestCFlexTimer::CancelExpiredTimerL ),
+        ENTRY( "CFlexTimer: Left side of the window is in the past", CTestCFlexTimer::ConfigureLeftSideInThePastL ),
+        ENTRY( "CFlexTimer: Left side of the window is in the past", CTestCFlexTimer::ConfigureLeftSideInThePastWindowCheckL ),
+        ENTRY( "CFlexTimer: Configure(32bit) called with negative window size", CTestCFlexTimer::ConfigureWithNegativeWindowSize32L ),
+        ENTRY( "CFlexTimer: Configure(64bit) called with negative window size", CTestCFlexTimer::ConfigureWithNegativeWindowSize64L ),
+        ENTRY( "CFlexTimer: Configure(32bit) called with max positive value", CTestCFlexTimer::ConfigureWithMaxWindow32L ),
+        ENTRY( "CFlexTimer: Configure(64bit) called with three year value", CTestCFlexTimer::ConfigureWithThreeYearWindow64L ),
+        ENTRY( "CFlexTimer: Configure(64bit) called with max positive value", CTestCFlexTimer::ConfigureWithMaxWindow64L ),
+        ENTRY( "CFlexTimer: Configure called while timer is already in use", CTestCFlexTimer::ConfigureWhileTimerIsInUseL ),
+        ENTRY( "CFlexTimer: Timer is started twise", CTestCFlexTimer::TimerIsStartedTwiceL ),
+        ENTRY( "CFlexTimer: Two timers, while high CPU load.", CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL ),
+        ENTRY( "CFlexTimer: Many timers, while high CPU load.", CTestCFlexTimer::CpuLoadManyTimersL ),
+        // RFlexTimer tests
+        ENTRY( "RFlexTimer: Start timer with After (32 bit)", CTestRFlexTimer::ExpireAfter32L ),
+        ENTRY( "RFlexTimer: Start timer with After (64 bit)", CTestRFlexTimer::ExpireAfter64L ),
+        ENTRY( "RFlexTimer: Start timer with AfterTicks", CTestRFlexTimer::ExpireAfterTicksL ),
+        ENTRY( "RFlexTimer: Start timer with At", CTestRFlexTimer::ExpireAtL ),
+        ENTRY( "RFlexTimer: Start timer with AtUTC", CTestRFlexTimer::ExpireAtUtcL ),
+        ENTRY( "RFlexTimer: Call After (32 bit) before Connect", CTestRFlexTimer::After32WithoutConnect ),
+        ENTRY( "RFlexTimer: Call After (64 bit) before Connect", CTestRFlexTimer::After64WithoutConnect ),
+        ENTRY( "RFlexTimer: Call AfterTicks before Connect", CTestRFlexTimer::AfterTicksWithoutConnect ),
+        ENTRY( "RFlexTimer: Call At before Connect", CTestRFlexTimer::AtWithoutConnect ),
+        ENTRY( "RFlexTimer: Call AtUTC before Connect", CTestRFlexTimer::AtUtcWithoutConnect ),
+        ENTRY( "RFlexTimer: Call Configure (32 bit) before Connect", CTestRFlexTimer::Configure32WithoutConnect ),
+        ENTRY( "RFlexTimer: Call Configure (64 bit) before Connect", CTestRFlexTimer::Configure64WithoutConnect ),
+        ENTRY( "RFlexTimer: Call Cancel before Connect", CTestRFlexTimer::CancelWithoutConnect ),
+        ENTRY( "RFlexTimer: Call After twice", CTestRFlexTimer::CallAfterTwiceL ),
+        ENTRY( "RFlexTimer: Call AfterTicks twice", CTestRFlexTimer::CallAfterTicksTwiceL ),
+        ENTRY( "RFlexTimer: Call At twice", CTestRFlexTimer::CallAtTwiceL ),
+        ENTRY( "RFlexTimer: Call AtUTC twice", CTestRFlexTimer::CallAtUtcTwiceL ),
+        ENTRY( "RFlexTimer: Call Connect twice", CTestRFlexTimer::CallConnectTwiceL ),
+        ENTRY( "RFlexTimer: Reconnect to the server", CTestRFlexTimer::ReconnectL ),
+        ENTRY( "RFlexTimer: Cancel before start", CTestRFlexTimer::CancelWithoutStart ),
+        ENTRY( "RFlexTimer: Call AfterTicks with negative ticks", CTestRFlexTimer::NegativeTicksInAfterTicksL ),
+        ENTRY( "RFlexTimer: Call AfterTicks with zero ticks", CTestRFlexTimer::ZeroTicksInAfterTicksL ),
+        ENTRY( "RFlexTimer: Change time while AfterTicks running", CTestRFlexTimer::ChangeTimeWhileAfterTicksL ),
+        ENTRY( "RFlexTimer: Test AfterTicks windows", CTestRFlexTimer::TestAfterTicksWindowL ),
+        // High priority client tests
+        ENTRY( "FlexTimerClient: Change Priority: MuchMore", CTestFlexTimer::SetThreadPriorityMuchMore ),
+        ENTRY( "CFlexTimer: Two timers, while high CPU load.", CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL ),
+        ENTRY( "CFlexTimer: Many timers, while high CPU load.", CTestCFlexTimer::CpuLoadManyTimersL ),
+        ENTRY( "FlexTimerClient: Change Priority: Normal", CTestFlexTimer::SetThreadPriorityNormal ),
+        // FlexTimerServer tests
+        ENTRY( "FlexTimerServer: Stop crash monitoring", CTestFlexTimer::StopServerMonitoringL ),
+
+        ENTRY( "FlexTimerServer: Start second server", CTestFlexTimer::StartSecondServerL ),
+        };
+    
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+    }
+
+// ========== Server level test cases ==========
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start monitoring the FlexTimer server
+// ---------------------------------------------------------------------------
+TInt CTestFlexTimer::StartServerMonitoringL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    RFlexTimerServerMonitor monitor;
+    User::LeaveIfError( monitor.Connect() );
+    User::LeaveIfError( monitor.StartMonitoring() );
+    monitor.Close();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Stop monitoring the FlexTimer server and check has the server
+// crashded.
+// ---------------------------------------------------------------------------
+TInt CTestFlexTimer::StopServerMonitoringL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    RFlexTimerServerMonitor monitor;
+    User::LeaveIfError( monitor.Connect() );
+    
+    TBool hasServerCrashed; 
+    User::LeaveIfError( monitor.GetStatus( hasServerCrashed ) );
+    
+    User::LeaveIfError( monitor.StopMonitoring() );
+    monitor.Close();
+
+    // By default everything has gone ok 
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( hasServerCrashed )
+        {
+        aResult.SetResult( 
+            KErrGeneral,
+            _L("Test case failed. FlexTimerServer has crashed.") );
+        }
+    
+    return KErrNone;        
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start second FlexTimerServer. Main purpose of this test case is 
+// to increase test coverage.
+// ---------------------------------------------------------------------------
+TInt CTestFlexTimer::StartSecondServerL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+
+    // Default result if anything leaves i.e. no analyze done.
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // Make sure that the server is up'n'running
+    RFlexTimer timer;
+    timer.Connect();
+    timer.Close();
+    
+    // Open handle to the server process
+    RProcess flexTimerServer;
+    User::LeaveIfError( flexTimerServer.Create( 
+            _L("FlexTimerServer.exe"), 
+            _L(""), 
+            EOwnerThread ) );
+
+    // Kick the server runnin'
+    flexTimerServer.Resume();
+
+    // Wait until the server process has been started.
+    TRequestStatus status;
+    flexTimerServer.Rendezvous( status );
+    User::WaitForRequest( status );
+
+    // Kill the server - if it has been able to been created
+    flexTimerServer.Kill( 0 );
+    
+    // Clean up
+    flexTimerServer.Close();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// TEST CASE: This test case can be used to change client priority to 
+// EPriorityMuchMore.
+// ---------------------------------------------------------------------------
+TInt CTestFlexTimer::SetThreadPriorityMuchMore(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    RThread thisThread;
+    
+    thisThread.SetPriority( EPriorityMuchMore );
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// TEST CASE: This test case can be used to change client priority to 
+// EPriorityMuchMore.
+// ---------------------------------------------------------------------------
+TInt CTestFlexTimer::SetThreadPriorityNormal(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    RThread thisThread;
+    
+    thisThread.SetPriority( EPriorityNormal );
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    return KErrNone;
+    }
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return CTestFlexTimer::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/flextimer/test/testflextimer/src/testrflextimer.cpp	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,1228 @@
+/*
+* ============================================================================
+*  Name        : testrflextimer.cpp
+*  Part of     : src / testflextimer
+*  Description : STIF test cases for RFlexTimer
+*  Version     : %version: 1 %
+*
+*  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+*  All rights reserved.
+*  This component and the accompanying materials are made available
+*  under the terms of the License "Eclipse Public License v1.0"
+*  which accompanies this distribution, and is available
+*  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+*  Initial Contributors:
+*  Nokia Corporation - initial contribution.
+*
+*  Contributors:
+*  Nokia Corporation
+* ============================================================================
+* Template version: 4.1
+*/
+
+#include <e32debug.h>               // for RDebug
+#include <rflextimer.h>             // for RFlexTimer
+#include <stiftesteventinterface.h> // for TEventIf 
+#include "testflextimer.h"          // for global constants
+#include "testrflextimer.h"
+
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CTestRFlexTimer::CTestRFlexTimer()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CTestRFlexTimer::~CTestRFlexTimer()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// ___  ____ _    ____ _   _    ____ _  _ ____ ____ _  _ ____ 
+// |  \ |___ |    |__|  \_/     |    |__| |___ |    |_/  [__  
+// |__/ |___ |___ |  |   |      |___ |  | |___ |___ | \_ ___] 
+// 
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+TBool CTestRFlexTimer::IsDelayOk( 
+    const TTimeIntervalMicroSeconds aDelay,
+    const TTimeIntervalMicroSeconds32 aInterval,
+    const TTimeIntervalMicroSeconds32 aWindow )
+    {
+    TTimeIntervalMicroSeconds interval( aInterval.Int() );
+    TTimeIntervalMicroSeconds window( aWindow.Int() );
+    return IsDelayOk( aDelay, interval, window );
+    }
+
+// ---------------------------------------------------------------------------
+TBool CTestRFlexTimer::IsDelayOk( 
+    const TTimeIntervalMicroSeconds aDelay,
+    const TTimeIntervalMicroSeconds32 aInterval,
+    const TTimeIntervalMicroSeconds aWindow )
+    {
+    TTimeIntervalMicroSeconds interval( aInterval.Int() );
+    return IsDelayOk( aDelay, interval, aWindow );
+    }
+
+// ---------------------------------------------------------------------------
+TBool CTestRFlexTimer::IsDelayOk( 
+    const TTimeIntervalMicroSeconds aDelay,
+    const TTimeIntervalMicroSeconds aInterval,
+    const TTimeIntervalMicroSeconds32 aWindow )
+    {
+    TTimeIntervalMicroSeconds window( aWindow.Int() );
+    return IsDelayOk( aDelay, aInterval, window );
+    }
+
+// ---------------------------------------------------------------------------
+TBool CTestRFlexTimer::IsDelayOk( 
+    const TTimeIntervalMicroSeconds aDelay,
+    const TTimeIntervalMicroSeconds aInterval,
+    const TTimeIntervalMicroSeconds aWindow )
+    {
+    /**
+     *  Timer can be expired 1 sec late or 1 system tick (15625 microseconds)
+     *  early.
+     */
+    const TInt64 KTimerResolution( 1000000 ); 
+    const TInt64 KTickResolution( 1000000 / 64 );
+    
+    RDebug::Print( 
+       _L("=== Timer delay: %Ld, interval: %Ld, window: %Ld"), 
+       aDelay.Int64(),
+       aInterval.Int64(),
+       aWindow.Int64() );
+    
+    return !( aDelay.Int64() < aInterval.Int64() - aWindow.Int64() - KTickResolution ||
+              aDelay.Int64() > aInterval.Int64() + KTimerResolution );
+    }
+
+// ---------------------------------------------------------------------------
+// Create, configure, start with AfterTicks and close RFlexTimer 
+// ---------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CTestRFlexTimer::ExecuteAfterTicksL(
+    TInt aTicks,
+    TTimeIntervalMicroSeconds aWindowSize )
+    {
+    // Create, connect and configure the timer handle
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+    User::LeaveIfError( timer.Configure( aWindowSize ) );
+    
+    TTime startTime;
+    startTime.UniversalTime();
+    
+    // Run the timer and wait its expiration
+    TRequestStatus status;
+    timer.AfterTicks( status, aTicks );
+    User::WaitForRequest( status );
+    
+    TTime endTime;
+    endTime.UniversalTime();
+
+    // Clean up
+    timer.Close();
+
+    // Return running time of the timer
+    return endTime.MicroSecondsFrom( startTime );
+    }
+
+// ---------------------------------------------------------------------------
+// ___ ____ ____ ___    ____ ____ ____ ____ ____ 
+//  |  |___ [__   |     |    |__| [__  |___ [__  
+//  |  |___ ___]  |     |___ |  | ___] |___ ___] 
+//
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a timer using After (32 bit) and wait it to expire.
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ExpireAfter32L(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+    
+    const TTimeIntervalMicroSeconds32 KInterval( 3000000 ); // Time to wait timer
+    const TTimeIntervalMicroSeconds KWindow( 0 );           // Window for check results
+
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    timer.After( status, KInterval );
+
+                                     //    //  ___     _____
+    User::WaitForRequest( status ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // Verify the test
+    TTime endTime;
+    endTime.UniversalTime();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
+        }
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a timer using After (32 bit) and wait it to expire.
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ExpireAfter64L(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+    
+    const TTimeIntervalMicroSeconds KInterval( 3000000 );   // Time to wait timer
+    const TTimeIntervalMicroSeconds KWindow( 0 );           // Window for check results
+
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    timer.After( status, KInterval );
+
+                                     //    //  ___     _____
+    User::WaitForRequest( status ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // Verify the test
+    TTime endTime;
+    endTime.UniversalTime();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
+        }
+    
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a timer using AfterTicks and wait it to expire.
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ExpireAfterTicksL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+    
+    const TTimeIntervalMicroSeconds32 KInterval( 3000000 );     // Time to wait timer
+    const TTimeIntervalMicroSeconds KWindow( 0 );               // Window for check results
+    const TTimeIntervalMicroSeconds32 KOneTick( 1000000 / 64 ); // System tick: 1/64 sec
+
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+    
+    timer.AfterTicks( status, KInterval.Int() / KOneTick.Int() );
+    
+                                     //    //  ___     _____
+    User::WaitForRequest( status ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // Verify the test
+    TTime endTime;
+    endTime.UniversalTime();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
+        }
+    
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a timer using At and wait it to expire.
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ExpireAtL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+    
+    const TTimeIntervalMicroSeconds KInterval( 3000000 ); // Time to wait timer
+    const TTimeIntervalMicroSeconds KWindow( 0 );         // Window for check results
+
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    TTime now;
+    now.HomeTime();
+    
+    timer.At( status, now + KInterval );
+
+                                     //    //  ___     _____
+    User::WaitForRequest( status ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+    
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // Verify the test
+    TTime endTime;
+    endTime.UniversalTime();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
+        }
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start a timer using AtUTC and wait it to expire.
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ExpireAtUtcL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    __UHEAP_MARK;
+    
+    const TTimeIntervalMicroSeconds KInterval( 3000000 ); // Time to wait timer
+    const TTimeIntervalMicroSeconds KWindow( 0 );         // Window for check results
+
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    TTime now;
+    now.UniversalTime();
+    
+    timer.AtUTC( status, now + KInterval );
+
+                                     //    //  ___     _____
+    User::WaitForRequest( status ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // Verify the test
+    TTime endTime;
+    endTime.UniversalTime();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
+        }
+
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with After (32 bit) without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::After32WithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    TRequestStatus status;
+
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    timer.After( status, TTimeIntervalMicroSeconds32( 1000000 ) );
+    User::WaitForRequest( status ); // PANIC
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with After (64 bit) without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::After64WithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    TRequestStatus status;
+
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+
+    // Do the actual test
+    //-----------------------------------------------------
+    
+    RFlexTimer timer;
+
+    timer.After( status, TTimeIntervalMicroSeconds( 1000000 ) );
+    User::WaitForRequest( status ); // PANIC
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with AfterTicks without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::AfterTicksWithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    TRequestStatus status;
+
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+
+    timer.AfterTicks( status, 1000 );
+    User::WaitForRequest( status ); // PANIC
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with At without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::AtWithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    TRequestStatus status;
+
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+
+    TTime expirationTime;
+    expirationTime.HomeTime();
+    expirationTime += TTimeIntervalMicroSeconds( 1000000 );
+    
+    timer.At( status, expirationTime );
+    User::WaitForRequest( status ); // PANIC
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start timer with At without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::AtUtcWithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    TRequestStatus status;
+
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+
+    TTime expirationTime;
+    expirationTime.UniversalTime();
+    expirationTime += TTimeIntervalMicroSeconds( 1000000 );
+    
+    timer.AtUTC( status, expirationTime );
+    User::WaitForRequest( status ); // PANIC
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure (32 bit) timer without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::Configure32WithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+
+    timer.Configure( TTimeIntervalMicroSeconds32( 1000000 ) ); // PANIC
+    // Configure is synchronous command. No need to wait.
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Configure (32 bit) timer without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::Configure64WithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+
+    timer.Configure( TTimeIntervalMicroSeconds( 1000000 ) ); // PANIC
+    // Configure is synchronous command. No need to wait.
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Cancel timer without connecting first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CancelWithoutConnect(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+
+    // Test should panic with
+    // Category: "KERN-EXEC"
+    // Reason:   0
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        0 );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    timer.Cancel(); // PANIC
+    // Cancel is synchronous command. No need to wait.
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Call After twice
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CallAfterTwiceL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Test should panic with
+    // Category: "RFlexTimer"
+    // Reason:   15 (EFlexTimerServerErrorPendingTimer)
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        15 );
+
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    timer.After( status, TTimeIntervalMicroSeconds32( 100000 ) );
+    timer.After( status, TTimeIntervalMicroSeconds( 100000 ) );
+
+    User::WaitForRequest( status ); // PANIC
+
+    timer.Close();
+
+    //-----------------------------------------------------
+
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Call AfterTicks twice
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CallAfterTicksTwiceL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Test should panic with
+    // Category: "RFlexTimer"
+    // Reason:   15 (EFlexTimerServerErrorPendingTimer)
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        15 );
+
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    timer.AfterTicks( status, 1000 );
+    timer.AfterTicks( status, 1000 );
+
+    User::WaitForRequest( status ); // PANIC
+
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Call At twice
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CallAtTwiceL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Test should panic with
+    // Category: "RFlexTimer"
+    // Reason:   15 (EFlexTimerServerErrorPendingTimer)
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        15 );
+
+    TRequestStatus status;
+
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+
+    TTime expirationTime;
+    expirationTime.HomeTime();
+    expirationTime += TTimeIntervalMicroSeconds( 1000000 );
+    
+    timer.At( status, expirationTime );
+    timer.At( status, expirationTime );
+
+    User::WaitForRequest( status ); // PANIC
+
+    timer.Close();
+
+    //-----------------------------------------------------
+
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Call AtUTC twice
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CallAtUtcTwiceL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Test should panic with
+    // Category: "RFlexTimer"
+    // Reason:   15 (EFlexTimerServerErrorPendingTimer)
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        15 );
+
+    TRequestStatus status;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+    
+    TTime expirationTime;
+    expirationTime.UniversalTime();
+    expirationTime += TTimeIntervalMicroSeconds( 1000000 );
+    
+    timer.AtUTC( status, expirationTime );
+    timer.AtUTC( status, expirationTime );
+
+    
+    User::WaitForRequest( status ); // PANIC
+
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Call Connect twice
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CallConnectTwiceL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Test should panic with
+    // Category: "RFlexTimer"
+    // Reason:   33 (EFlexTimerAlreadyConnected)
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        33 );
+
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+    User::LeaveIfError( timer.Connect() ); // PANIC
+
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Reconnect the handle to the server
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ReconnectL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+    timer.Close();
+    User::LeaveIfError( timer.Connect() );
+    timer.Close();
+    
+    //-----------------------------------------------------
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Cancel timer without starting it first
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::CancelWithoutStart(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+
+    User::LeaveIfError( timer.Connect() );
+    timer.Cancel();
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start tick timer with negative ticks
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::NegativeTicksInAfterTicksL(
+    TTestResult& aResult, 
+    CTestFlexTimer* aCallback )
+    {
+    const TInt KTestValue( -1 );
+    
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    // Test should panic with
+    // Category: "RFlexTimer"
+    // Reason:   2 (EFlexTimerAfterTicksIntervalLessThanZero)
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::EPanic,
+        2 );
+
+    TTimeIntervalMicroSeconds delay = ExecuteAfterTicksL( KTestValue );
+
+    // No panic, change result back to normal
+    aCallback->TestModuleIf().SetExitReason( 
+        CTestModuleIf::ENormal,
+        KErrNone );
+
+    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Start tick timer with zero ticks
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ZeroTicksInAfterTicksL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    const TInt KTestValue( 0 );
+    
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTimeIntervalMicroSeconds delay = ExecuteAfterTicksL( KTestValue );
+
+    // Analyze the results
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( delay, 
+                     TTimeIntervalMicroSeconds( KTestValue ),
+                     TTimeIntervalMicroSeconds( 0 )) )
+        {
+        aResult.SetResult( 
+            KErrGeneral, 
+            _L("Test case failed. Wrong expiration time.") );
+        }
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Change system time while tick timer is active
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::ChangeTimeWhileAfterTicksL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+    const TTimeIntervalMicroSeconds32 KTimerInterval( 10000000 );   // Time to wait timer
+    const TTimeIntervalMicroSeconds KWaitTillChangeTime( 1000000 ); // Time to wait before change system time
+    const TTimeIntervalMicroSeconds KTimeChange( 3000000 );         // Duration to change system time
+
+    // Interval for check results
+    const TTimeIntervalMicroSeconds KInterval( KTimerInterval.Int() + KTimeChange.Int64() );
+    const TTimeIntervalMicroSeconds KWindow( 0 );                   // Window for check results
+    const TTimeIntervalMicroSeconds32 KOneTick( 1000000 / 64 );     // System tick: 1/64 sec
+
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus status, helperStatus;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timer;
+    User::LeaveIfError( timer.Connect() );
+    
+    timer.AfterTicks( status, KTimerInterval.Int() / KOneTick.Int() );
+
+    //-----------------------------------------------------
+    // ... meanwhile change system time
+
+        RFlexTimer helper;
+        
+        User::LeaveIfError( helper.Connect() );
+        helper.After( helperStatus, KWaitTillChangeTime );
+    
+                                               //    //  ___     _____
+        User::WaitForRequest( helperStatus ); // // // //_ // //  //
+                                             //_//_// //  // //  //
+        
+        TTime newNow;
+        newNow.UniversalTime();
+        newNow += KTimeChange;
+        
+        User::SetUTCTime( newNow );
+    
+        helper.Close();
+
+    // The test continues...
+    //-----------------------------------------------------
+    
+                                     //    //  ___     _____
+    User::WaitForRequest( status ); // // // //_ // //  //
+                                   //_//_// //  // //  //
+
+    timer.Close();
+
+    //-----------------------------------------------------
+
+    // Verify the test
+    TTime endTime;
+    endTime.UniversalTime();
+
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
+        {
+        //RDebug::Print( _L("Timer delay: %lld"), 
+        //               endTime.MicroSecondsFrom( startTime ).Int64() );
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
+        }
+    
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// TEST CASE: Timer window works correctly
+// ---------------------------------------------------------------------------
+//
+TInt CTestRFlexTimer::TestAfterTicksWindowL(
+    TTestResult& aResult, 
+    CTestFlexTimer* /* aCallback */ )
+    {
+
+    // T1: expiration after 4-8 sec
+    const TTimeIntervalMicroSeconds32 KTimerOneInterval( 8000000 );
+    const TTimeIntervalMicroSeconds32 KTimerOneWindow( 4000000 );
+
+    // T2: expiration after 9-10 sec
+    // T2's interval must not overlap with T1's -- otherwise T1 will be 
+    // delayed
+    const TTimeIntervalMicroSeconds32 KTimerTwoInterval( 10000000 );
+    const TTimeIntervalMicroSeconds32 KTimerTwoWindow( 1000000 );
+
+    // T3: expiration after 5 secs
+    const TTimeIntervalMicroSeconds KAfterTimerInterval( 5000000 );
+    const TTimeIntervalMicroSeconds KAfterTimerWindow( 0 );
+
+    // System tick: 1/64 sec
+    const TTimeIntervalMicroSeconds32 KOneTick( 1000000 / 64 );
+    const TTimeIntervalMicroSeconds KNoWindow( 0 );
+
+    
+    
+    // Initialize case
+    aResult.SetResult( KErrGeneral, _L("Test case leaved") );
+
+    TTime startTime;
+    startTime.UniversalTime();
+    TRequestStatus oneStatus, twoStatus, afterStatus;
+    
+    // Do the actual test
+    //-----------------------------------------------------
+
+    RFlexTimer timerOne;
+    User::LeaveIfError( timerOne.Connect() );
+    timerOne.Configure( KTimerOneWindow );
+    timerOne.AfterTicks( oneStatus, KTimerOneInterval.Int() / KOneTick.Int() );
+
+    RFlexTimer timerTwo;
+    User::LeaveIfError( timerTwo.Connect() );
+    timerTwo.Configure( KTimerTwoWindow );
+    timerTwo.AfterTicks( twoStatus, KTimerTwoInterval.Int() / KOneTick.Int() );
+    
+    RFlexTimer afterTimer;
+    User::LeaveIfError( afterTimer.Connect() );
+    afterTimer.Configure( KAfterTimerWindow );
+    afterTimer.After( afterStatus, KAfterTimerInterval );
+    
+                                        //    //  ___     _____
+    User::WaitForRequest( oneStatus ); // // // //_ // //  //
+                                      //_//_// //  // //  //
+
+    TTime oneEndTime;
+    oneEndTime.UniversalTime();
+                                        //    //  ___     _____
+    User::WaitForRequest( twoStatus ); // // // //_ // //  //
+                                      //_//_// //  // //  //
+
+    TTime twoEndTime;
+    twoEndTime.UniversalTime();
+    
+    timerOne.Close();
+    timerTwo.Close();
+    afterTimer.Close();
+
+    //-----------------------------------------------------
+    
+    // Handle afterStatus too - to get rid of unhandled asynchronous message
+    // error from STIF.
+    User::WaitForRequest( afterStatus );
+    
+    aResult.SetResult( KErrNone, _L("Test case passed") );
+    
+    // T1 should be expired at the same time than T3 - check with T3's values
+    if ( !IsDelayOk( oneEndTime.MicroSecondsFrom( startTime ), KAfterTimerInterval, KNoWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Timer one wrong expiration.") );
+        }
+    // T2 should be expired at it's max window
+    else if ( !IsDelayOk( twoEndTime.MicroSecondsFrom( startTime ), KTimerTwoInterval, KNoWindow ) )
+        {
+        aResult.SetResult( KErrGeneral, _L("Test case failed. Timer two wrong expiration.") );
+        }
+    
+    __UHEAP_MARKEND;
+
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keepalive/group/bld.inf	Thu Jul 22 16:37:38 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Build info for keepalive collection.
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+#include "../flextimer/group/bld.inf"
+
+PRJ_TESTMMPFILES
+
--- a/layers.sysdef.xml	Thu Jun 17 22:32:02 2010 +0100
+++ b/layers.sysdef.xml	Thu Jul 22 16:37:38 2010 +0100
@@ -7,7 +7,6 @@
   <systemModel>
     <layer name="mw_layer">
       <module name="ipconnmgmt">
-        <unit unitID="netdo.ipconnmgmt" mrp="" bldFile="&layer_real_source_path;/group" name="ipconnmgmt" />
         <unit unitID="netdo.ipconnmgmtqt" mrp="" bldFile="&layer_real_source_path;" name="ipconnmgmtqt" proFile="ipconnmgmt.pro" qmakeArgs="-r"/>
       </module>
     </layer>