sdkcreationmw/sdkruntimes/new_wsock_3pc/src/winsockmcpr.cpp
changeset 2 82fb8aa91b2c
equal deleted inserted replaced
1:ac50fd48361b 2:82fb8aa91b2c
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19  @prototype
       
    20 */
       
    21 
       
    22 #if 0
       
    23 #include <comms-infras/ss_log.h>
       
    24 #include <elements/sm_core.h>
       
    25 #include <in_sock.h>
       
    26 #include <comms-infras/ss_tiermanagerutils.h>
       
    27 #include <comms-infras/ss_nodeinterfaces.h>
       
    28 #include <comms-infras/ss_coreactivities.h>
       
    29 #else
       
    30 #include <comms-infras/ss_log.h>
       
    31 #include <comms-infras/ss_tiermanagerutils.h>
       
    32 #include <comms-infras/coremcpractivities.h>
       
    33 #include <comms-infras/agentmcpractivities.h>
       
    34 #include "winsockprovision.h"
       
    35 #include "winsockagenthandler.h"
       
    36 #include "winsockmcpr.h"
       
    37 #include <comms-infras/ss_msgintercept.h>
       
    38 
       
    39 #endif
       
    40 
       
    41 using namespace Messages;
       
    42 using namespace MeshMachine;
       
    43 using namespace ESock;
       
    44 using namespace NetStateMachine;
       
    45 using namespace MCprActivities;
       
    46 
       
    47 
       
    48 #ifdef _DEBUG
       
    49 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    50 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    51 _LIT(KSpecAssert_NifManAgtPrCgntm, "NifManAgtPrCgntm");
       
    52 #endif
       
    53 
       
    54 
       
    55 #ifdef _DEBUG
       
    56 #define KWinSockMCprTag KESockMetaConnectionTag
       
    57 _LIT8(KWinSockMCprSubTag, "winsockmcpr");
       
    58 #endif
       
    59 
       
    60 // No Bearer Activity
       
    61 namespace WinsockMCPRNoBearerActivity
       
    62 {
       
    63 DECLARE_DEFINE_NODEACTIVITY(ECFActivityNoBearer, activity, TCFControlProvider::TNoBearer)
       
    64     FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingNoBearer, MeshMachine::TNoTag)
       
    65     LAST_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBearer)
       
    66 NODEACTIVITY_END()
       
    67 }
       
    68 
       
    69 // Activity Map
       
    70 namespace WinsockMCprStates
       
    71 {
       
    72 DECLARE_DEFINE_ACTIVITY_MAP(stateMap)
       
    73    ACTIVITY_MAP_ENTRY(WinsockMCPRNoBearerActivity, activity)
       
    74 ACTIVITY_MAP_END_BASE(AgentMCprActivities, agentMCprActivities)
       
    75 } // namespace RawIPMCprStates
       
    76 
       
    77 using namespace ESock;
       
    78 using namespace Messages;
       
    79 using namespace NetStateMachine;
       
    80 using namespace CommsDat;
       
    81 using namespace PRActivities;
       
    82 
       
    83 
       
    84 CWinsockMetaConnectionProvider* CWinsockMetaConnectionProvider::NewL(ESock::CMetaConnectionProviderFactoryBase& aFactory, const ESock::TProviderInfo& aProviderInfo)
       
    85     {
       
    86     // coverity[alloc_fn] coverity[alias] coverity[assign]
       
    87     CWinsockMetaConnectionProvider* winmcpr = new (ELeave) CWinsockMetaConnectionProvider (aFactory, aProviderInfo);
       
    88     // coverity[push]
       
    89     CleanupStack::PushL(winmcpr);
       
    90     // coverity[alias] coverity[double_push]
       
    91     winmcpr->ConstructL();
       
    92     CleanupStack::Pop(winmcpr);
       
    93     return winmcpr;
       
    94     }
       
    95 
       
    96 /**
       
    97 Constructor for the Agent Meta Connection Provider
       
    98 @param aFactory The parent factory which created this MCPr
       
    99 */
       
   100 EXPORT_C CWinsockMetaConnectionProvider::CWinsockMetaConnectionProvider(CMetaConnectionProviderFactoryBase& aFactory, const ESock::TProviderInfo& aProviderInfo)
       
   101 :CAgentMetaConnectionProvider(aFactory, aProviderInfo, WinsockMCprStates::stateMap::Self())                                                                                                                            	
       
   102 	{
       
   103    LOG_NODE_CREATE(KWinSockMCprSubTag, CWinsockMetaConnectionProvider);
       
   104 	//iQueryConnSettingsImpl = NULL;
       
   105 	}
       
   106 
       
   107 
       
   108 /**
       
   109 D'tor
       
   110 */
       
   111 EXPORT_C CWinsockMetaConnectionProvider::~CWinsockMetaConnectionProvider()
       
   112 	{
       
   113 	CWinsockMetaConnectionProvider::CancelAvailabilityMonitoring(); //Don't call virtual for obvious reasons!
       
   114     DestroyIapView();
       
   115 	//delete iQueryConnSettingsImpl;
       
   116     LOG_NODE_DESTROY(KWinSockMCprSubTag, CWinsockMetaConnectionProvider);
       
   117 	}
       
   118 
       
   119 EXPORT_C void CWinsockMetaConnectionProvider::ConstructL()
       
   120 	{
       
   121 	CAgentMetaConnectionProvider::ConstructL();
       
   122 	//CCoreMetaConnectionProvider::ConstructL();
       
   123     ProvisionAgentInfoL();
       
   124 	}
       
   125 
       
   126 
       
   127 void CWinsockMetaConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage)
       
   128     {
       
   129     __CFLOG_VAR((KWinSockMCprTag, KWinSockMCprSubTag, _L8("CWinsockMetaConnectionProvider %08x:\tReceivedL() aCFMessage=%d"),
       
   130        this, aMessage.MessageId()));
       
   131 
       
   132     ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient);
       
   133 
       
   134     TNodeContext<CWinsockMetaConnectionProvider> ctx(*this, aMessage, aSender, aRecipient);
       
   135     CCoreMetaConnectionProvider::Received(ctx);
       
   136     User::LeaveIfError(ctx.iReturn);
       
   137     }
       
   138 /**
       
   139 */
       
   140 void CWinsockMetaConnectionProvider::ProvisionAgentInfoL()
       
   141     {
       
   142     __CFLOG_VAR((KAgentMCprTag, KAgentMCprSubTag, _L8("CWinsockMetaConnectionProvider %08x:\tProvisionAgentInfoL()"), this));
       
   143 
       
   144     // It is possible that an AgentProvisionInfo structure has previously been allocated
       
   145     // We create a new one anyway and override it, meaning the reference on the old one can
       
   146     // possibly be released (handled for us) resulting in its deletion 
       
   147 #if 0
       
   148     RMetaExtensionContainer mec;
       
   149     mec.Open(AccessPointConfig());
       
   150     CleanupClosePushL(mec);
       
   151 
       
   152     CAgentProvisionInfo* agentProvisionInfo = new (ELeave) CAgentProvisionInfo;
       
   153     CleanupStack::PushL(agentProvisionInfo);
       
   154     mec.AppendExtensionL(agentProvisionInfo);
       
   155 	CleanupStack::Pop(agentProvisionInfo);
       
   156 
       
   157     HBufC* agentName(NULL);
       
   158 
       
   159     OpenIapViewL();
       
   160     IapView()->GetTextL(KCDTIdBearerAgent, agentName);
       
   161     __ASSERT_DEBUG(agentName, User::Panic(KSpecAssert_NifManAgtPrCgntm, 1));
       
   162 
       
   163 
       
   164     agentProvisionInfo->SetAgentName(*agentName);
       
   165     delete agentName;
       
   166 
       
   167     agentProvisionInfo->SetIapId(IapView()->IapId());
       
   168     TUint32 netId;
       
   169     IapView()->GetIntL(KCDTIdIAPNetwork,netId);
       
   170     agentProvisionInfo->SetNetworkId(netId);
       
   171     agentProvisionInfo->SetBearerSet(0xFF);
       
   172 
       
   173     TUint32 reconnectAttempts = 0;
       
   174     IapView()->GetIntL(KCDTIdMaxConnectionAttempts, reconnectAttempts);
       
   175     agentProvisionInfo->SetReconnectAttempts(reconnectAttempts);
       
   176 
       
   177 
       
   178     agentProvisionInfo->SetCredentials(CreateCredentialsInfoL());
       
   179     iAgentMCPrDoneWithIapView = ETrue;
       
   180     CloseIapView();
       
   181     
       
   182     // Safely reached the end, commit the changes
       
   183 	AccessPointConfig().Close();
       
   184     AccessPointConfig().Open(mec);
       
   185     CleanupStack::PopAndDestroy(&mec);
       
   186     
       
   187 #endif
       
   188     }
       
   189 
       
   190 
       
   191 /**
       
   192 Create the Credentials structure in the Agent Provisioning Info, and populate it
       
   193 with initial values from CommsDat.
       
   194 
       
   195 Assumes that IapView() has been setup.
       
   196 */
       
   197 CCredentialsConfig* CWinsockMetaConnectionProvider::CreateCredentialsInfoL()
       
   198 	{
       
   199 	__ASSERT_DEBUG(IapView(), User::Panic(KSpecAssert_NifManAgtPrCgntm, 2));
       
   200 	CCredentialsConfig* pCredentialsConfig = CCredentialsConfig::NewLC(IapView());
       
   201 	CleanupStack::Pop(pCredentialsConfig);
       
   202 	return pCredentialsConfig;
       
   203 	}
       
   204 
       
   205 
       
   206 /**
       
   207 Opens a ref counted Iap View. This must be closed with a call to CloseIapView
       
   208 once the view has been finished with.
       
   209 @return A pointer to the populated CCommsDatIapView.
       
   210 */
       
   211 EXPORT_C CCommsDatIapView* CWinsockMetaConnectionProvider::OpenIapViewL()
       
   212 	{
       
   213 	if (iIapView == NULL)
       
   214     	{
       
   215     	iIapView = CCommsDatIapView::NewL(ProviderInfo().APId());
       
   216     	}
       
   217 
       
   218     iIapViewRefCount++;
       
   219 
       
   220 	return iIapView;
       
   221 	}
       
   222 
       
   223 
       
   224 /**
       
   225 Opens a ref counted Iap View adding the returned object to the cleanup stack.
       
   226 This must be closed with a call to CloseIapView once the view has been finished
       
   227 with.
       
   228 @return A pointer to the populated CCommsDatIapView.
       
   229 */
       
   230 EXPORT_C CCommsDatIapView* CWinsockMetaConnectionProvider::OpenIapViewLC()
       
   231 	{
       
   232 	CCommsDatIapView* iapView = OpenIapViewL();
       
   233 	CleanupStack::PushL(TCleanupItem(CleanupCloseIapView, this));
       
   234 	return iapView;
       
   235 	}
       
   236 
       
   237 
       
   238 /**
       
   239 The cleanup stack method used to cleanly release the Iap View
       
   240 @note Removal of the item from the cleanup stack may not always cause deletion
       
   241 of the object. It still remains ref counted, and is only releasable once both
       
   242 the ref count has reached zero and the AgentMCPr base class has had a chance
       
   243 to use it for Provisioning.
       
   244 */
       
   245 EXPORT_C void CWinsockMetaConnectionProvider::CleanupCloseIapView(TAny* aThis)
       
   246 	{
       
   247 	reinterpret_cast<CWinsockMetaConnectionProvider*>(aThis)->CloseIapView();
       
   248 	}
       
   249 
       
   250 
       
   251 /**
       
   252 Closes a reference to the Iap View.
       
   253 @note The Iap View may not be deleted after this call. It is only deleted once
       
   254 both the ref count has reached zero and the AgentMCPr base class has had a
       
   255 chance to use it for Provisioning.
       
   256 */
       
   257 EXPORT_C void CWinsockMetaConnectionProvider::CloseIapView()
       
   258 	{
       
   259 	if (iAgentMCPrDoneWithIapView && --iIapViewRefCount == 0)
       
   260     	{
       
   261     	DestroyIapView();
       
   262         }
       
   263 	}
       
   264 
       
   265 void CWinsockMetaConnectionProvider::DestroyIapView()
       
   266 	{
       
   267 	delete iIapView;
       
   268 	iIapView = NULL;
       
   269 	}
       
   270 
       
   271 
       
   272 /**
       
   273 Gets a pointer to the current Iap View.
       
   274 @return A pointer to the current Iap View.
       
   275 @note A call to OpenIapViewL or OpenIapViewLC must be made prior to calling
       
   276 this method to ensure the returned value is valid.
       
   277 */
       
   278 EXPORT_C CCommsDatIapView* CWinsockMetaConnectionProvider::IapView()
       
   279 	{
       
   280 	__ASSERT_DEBUG(iIapView, User::Panic(KSpecAssert_NifManAgtPrCgntm, 4));
       
   281 	return iIapView;
       
   282 	}
       
   283 
       
   284 /**
       
   285 Sets the Agent Notification Handler to be used by the AgentSCPr
       
   286 @param aNotificationHandler - Pointer to an implementation of the
       
   287 CAgentNotificationHandler class. This must exist for the lifetime of the MCPr.
       
   288 */
       
   289 EXPORT_C void CWinsockMetaConnectionProvider::SetAgentNotificationHandlerL (CAgentNotificationHandler* aNotificationHandler)
       
   290    {
       
   291 #if 0
       
   292 	CAgentProvisionInfo* agentProvisionInfo = const_cast<CAgentProvisionInfo*>(static_cast<const CAgentProvisionInfo*>(AccessPointConfig().FindExtension(CAgentProvisionInfo::TypeId())));
       
   293 	if (aNotificationHandler || agentProvisionInfo)
       
   294 	    {
       
   295        	if (agentProvisionInfo==NULL)
       
   296        		{
       
   297        		RMetaExtensionContainer mec;
       
   298        		mec.Open(AccessPointConfig());
       
   299        		CleanupClosePushL(mec);
       
   300        		
       
   301        	    agentProvisionInfo = new (ELeave) CAgentProvisionInfo;
       
   302        	    CleanupStack::PushL(agentProvisionInfo);
       
   303        		mec.AppendExtensionL(agentProvisionInfo);
       
   304        		CleanupStack::Pop(agentProvisionInfo);
       
   305        		
       
   306        		AccessPointConfig().Close();
       
   307        		AccessPointConfig().Open(mec);
       
   308        		
       
   309             CleanupStack::PopAndDestroy(&mec);
       
   310        		}
       
   311 
       
   312         agentProvisionInfo->SetAgentNotificationHandler(aNotificationHandler);
       
   313 	    }
       
   314 	
       
   315 #endif
       
   316     }
       
   317 
       
   318 /**
       
   319 Retreives an IPv4 address from a CCommsDatIapView
       
   320 @param aIapView - A pointer to a CCommsDatIapView to obtain the field from
       
   321 @param aElementId - The commsdat element Id of the field containing the IPv4 address
       
   322 @param aAddr - The variable to receive the IPv4 address
       
   323 */
       
   324 EXPORT_C void CWinsockMetaConnectionProvider::GetIp4AddrL(CCommsDatIapView* aIapView, TMDBElementId aElementId, TUint32& aAddr)
       
   325 	{
       
   326     User::LeaveIfError(GetIp4Addr(aIapView, aElementId, aAddr));
       
   327 	}
       
   328 
       
   329 
       
   330 /**
       
   331 Non-leaving version of GetIp4AddrL. Retreives an IPv4 address from a CCommsDatIapView.
       
   332 @param aIapView - A pointer to a CCommsDatIapView to obtain the field from
       
   333 @param aElementId - The commsdat element Id of the field containing the IPv4 address
       
   334 @param aAddr - The variable to receive the IPv4 address
       
   335 @return A system-wide error code. KErrNone on success.
       
   336 */
       
   337 EXPORT_C TInt CWinsockMetaConnectionProvider::GetIp4Addr(CCommsDatIapView* aIapView, TMDBElementId aElementId, TUint32& aAddr)
       
   338     {
       
   339     aAddr = KInetAddrNone;
       
   340     HBufC* buf = NULL;
       
   341     TInt err = aIapView->GetText(aElementId, buf);
       
   342     if (err == KErrNone)
       
   343 		{
       
   344 		__ASSERT_DEBUG(buf, User::Panic(KSpecAssert_NifManAgtPrCgntm, 5));
       
   345 
       
   346 		TInetAddr addr;
       
   347 		if ((err = addr.Input(*buf)) == KErrNone)
       
   348 		    {
       
   349 		    aAddr = addr.Address();
       
   350 		    }
       
   351     	delete buf;
       
   352     	}
       
   353 
       
   354 #ifdef _DEBUG
       
   355 	if (err != KErrNone)
       
   356 		{
       
   357 		__CFLOG_VAR((KAgentMCprTag, KAgentMCprSubTag, _L8("CWinsockMetaConnectionProvider:\tGetIp4Addr(): error %d reading CommsDat field %08x"),
       
   358 					 err, aElementId));
       
   359     	}
       
   360 #endif
       
   361 
       
   362     return err;
       
   363     }
       
   364 
       
   365 
       
   366 /**
       
   367 Retreives an IPv6 address from a CCommsDatIapView.
       
   368 @param aIapView - A pointer to a CCommsDatIapView to obtain the field from
       
   369 @param aElementId - The commsdat element Id of the field containing the IPv6 address
       
   370 @param aAddr - The variable to receive the IPv6 address
       
   371 */
       
   372 EXPORT_C void CWinsockMetaConnectionProvider::GetIp6AddrL(CCommsDatIapView* aIapView, TMDBElementId aElementId, TIp6Addr& aAddr)
       
   373 	{
       
   374     User::LeaveIfError(GetIp6Addr(aIapView, aElementId, aAddr));
       
   375 	}
       
   376 
       
   377 
       
   378 /**
       
   379 Non-leaving version of GetIp6AddrL. Retreives an IPv6 address from a CCommsDatIapView.
       
   380 @param aIapView - A pointer to a CCommsDatIapView to obtain the field from
       
   381 @param aElementId - The commsdat element Id of the field containing the IPv6 address
       
   382 @param aAddr - The variable to receive the IPv6 address
       
   383 @return A system-wide error code. KErrNone on success.
       
   384 */
       
   385 EXPORT_C TInt CWinsockMetaConnectionProvider::GetIp6Addr(CCommsDatIapView* aIapView, TMDBElementId aElementId, TIp6Addr& aAddr)
       
   386 	{
       
   387 	aAddr = KInet6AddrNone;
       
   388 	HBufC* buf = NULL;
       
   389 	TInt err = aIapView->GetText(aElementId, buf);
       
   390 	if (err == KErrNone)
       
   391     	{
       
   392     	__ASSERT_DEBUG(buf, User::Panic(KSpecAssert_NifManAgtPrCgntm, 6));
       
   393 
       
   394     	TInetAddr ip6Addr;
       
   395     	if ((err = ip6Addr.Input(*buf)) == KErrNone)
       
   396         	{
       
   397         	aAddr = ip6Addr.Ip6Address();
       
   398         	}
       
   399     	delete buf;
       
   400     	}
       
   401 
       
   402 #ifdef _DEBUG
       
   403 	if (err != KErrNone)
       
   404 		{
       
   405 		__CFLOG_VAR((KAgentMCprTag, KAgentMCprSubTag, _L8("CWinsockMetaConnectionProvider:\tGetIp6Addr(): error %d reading CommsDat field %08x"),
       
   406 					 err, aElementId));
       
   407     	}
       
   408 #endif
       
   409 
       
   410     return err;
       
   411 	}
       
   412 
       
   413 
       
   414 #ifdef _DEBUG
       
   415 EXPORT_C void CWinsockMetaConnectionProvider::StartAvailabilityMonitoringL(const TNodeCtxId& aAvailabilityActivity)
       
   416 	{
       
   417 	__ASSERT_DEBUG(iAvailabilitySubscriber==NULL, User::Panic(KSpecAssert_NifManAgtPrCgntm, 7)); //Only one start allowed from the availability activity!
       
   418 //	iAvailabilitySubscriber = CAvailabilitySubscriber::NewL(aAvailabilityActivity, ProviderInfo().APId());
       
   419 //	AddClientL(iAvailabilitySubscriber->Id(), TClientType(TClientType::ERegistrar, TCFClientType::EAvailabilityProvider));
       
   420 #else
       
   421 EXPORT_C void CWinsockMetaConnectionProvider::StartAvailabilityMonitoringL(const Messages::TNodeCtxId& /*aAvailabilityActivity*/)
       
   422 	{
       
   423 #endif
       
   424 	}
       
   425 
       
   426 EXPORT_C void CWinsockMetaConnectionProvider::CancelAvailabilityMonitoring()
       
   427 	{
       
   428 #ifdef _DEBUG
       
   429 	if (iAvailabilitySubscriber)
       
   430 		{
       
   431 	//	RemoveClient(iAvailabilitySubscriber->Id());
       
   432 		iAvailabilitySubscriber = NULL; //iAvailabilitySubscriber will delete itself when cancelled from the availability activity
       
   433 		}
       
   434 #endif
       
   435 	}
       
   436 
       
   437 /**
       
   438 Retrieves the MLinkCprLegacyDataAccessExtApi implementation
       
   439 @param aInterface Pointer to the interface implementation.
       
   440 */
       
   441 void CWinsockMetaConnectionProvider::ReturnInterfacePtrL(MLinkMCprLegacyDataAccessApiExt*& aInterface)
       
   442     {
       
   443     //aInterface = this;
       
   444     }
       
   445 
       
   446 /**
       
   447 Retrieves the MQueryConnSettingsApiExt implementation
       
   448 @param aInterface Pointer to the interface implementation.
       
   449 
       
   450 */
       
   451 
       
   452 void CWinsockMetaConnectionProvider::ReturnInterfacePtrL(MQueryConnSettingsApiExt*& aInterface)
       
   453     {
       
   454     
       
   455 #if 0 // Need to be written for winsock   
       
   456     if (!iQueryConnSettingsImpl)
       
   457     	{
       
   458     	const CAgentProvisionInfo* provisionInfo = AgentProvisionInfo();
       
   459     	iQueryConnSettingsImpl = new (ELeave)CAgentQueryConnSettingsImpl(*provisionInfo, AccessPointConfig());
       
   460     	}
       
   461     aInterface = iQueryConnSettingsImpl;
       
   462 #endif
       
   463     }
       
   464 
       
   465 
       
   466 #if 0
       
   467 EXPORT_C void CWinsockMetaConnectionProvider::GetIntSettingL(const TDesC& aSettingName, TUint32& aValue, MPlatsecApiExt* aPlatsecItf)
       
   468     {
       
   469     const CAgentProvisionInfo* provisionInfo = AgentProvisionInfo();
       
   470     if (!provisionInfo)
       
   471         {
       
   472         User::Leave (KErrNotReady);
       
   473         }
       
   474 
       
   475     TMDBElementId elementId = MapFieldNameL(aSettingName, aPlatsecItf);
       
   476     MQueryConnSettingsApiExt* queryItf;
       
   477     ReturnInterfacePtrL(queryItf);
       
   478 
       
   479     TInt err = queryItf->GetInt(elementId, aValue, aPlatsecItf);
       
   480     if (err == KErrNotFound)
       
   481         {
       
   482         elementId = SecondChanceModemBearerLegacyMapFieldNameL(aSettingName, aPlatsecItf);
       
   483         err = queryItf->GetInt(elementId, aValue, aPlatsecItf);
       
   484         }
       
   485     User::LeaveIfError(err);
       
   486     }
       
   487 
       
   488 
       
   489 EXPORT_C void CWinsockMetaConnectionProvider::GetBoolSettingL(const TDesC& aSettingName, TBool& aValue, MPlatsecApiExt* aPlatsecItf)
       
   490     {
       
   491     const CAgentProvisionInfo* provisionInfo = AgentProvisionInfo();
       
   492     if (!provisionInfo)
       
   493         {
       
   494         User::Leave (KErrNotReady);
       
   495         }
       
   496 
       
   497     TMDBElementId elementId = MapFieldNameL(aSettingName, aPlatsecItf);
       
   498     MQueryConnSettingsApiExt* queryItf;
       
   499     ReturnInterfacePtrL(queryItf);
       
   500 
       
   501     TInt err = queryItf->GetBool(elementId, aValue, aPlatsecItf);
       
   502     if (err == KErrNotFound)
       
   503         {
       
   504         elementId = SecondChanceModemBearerLegacyMapFieldNameL(aSettingName, aPlatsecItf);
       
   505         err = queryItf->GetBool(elementId, aValue, aPlatsecItf);
       
   506         }
       
   507     User::LeaveIfError(err);
       
   508     }
       
   509 
       
   510 
       
   511 EXPORT_C void CWinsockMetaConnectionProvider::GetDes8SettingL(const TDesC& aSettingName, TDes8& aValue, MPlatsecApiExt* aPlatsecItf)
       
   512     {
       
   513     const CAgentProvisionInfo* provisionInfo = AgentProvisionInfo();
       
   514     if (!provisionInfo)
       
   515         {
       
   516         User::Leave (KErrNotReady);
       
   517         }
       
   518 
       
   519     TMDBElementId elementId = MapFieldNameL(aSettingName, aPlatsecItf);
       
   520     MQueryConnSettingsApiExt* queryItf;
       
   521     ReturnInterfacePtrL(queryItf);
       
   522 
       
   523     HBufC8* value;
       
   524     TInt err = queryItf->GetText(elementId, value, aPlatsecItf);
       
   525     if (err == KErrNotFound)
       
   526         {
       
   527         elementId = SecondChanceModemBearerLegacyMapFieldNameL(aSettingName, aPlatsecItf);
       
   528         err = queryItf->GetText(elementId, value, aPlatsecItf);
       
   529         }
       
   530     User::LeaveIfError(err);
       
   531     aValue = *value;
       
   532     delete value;
       
   533     }
       
   534 
       
   535 
       
   536 EXPORT_C void CWinsockMetaConnectionProvider::GetDes16SettingL(const TDesC& aSettingName, TDes16& aValue, MPlatsecApiExt* aPlatsecItf)
       
   537     {
       
   538     const CAgentProvisionInfo* provisionInfo = AgentProvisionInfo();
       
   539     if (!provisionInfo)
       
   540         {
       
   541         User::Leave (KErrNotReady);
       
   542         }
       
   543 
       
   544     TMDBElementId elementId = MapFieldNameL(aSettingName, aPlatsecItf);
       
   545     MQueryConnSettingsApiExt* queryItf;
       
   546     ReturnInterfacePtrL(queryItf);
       
   547 
       
   548     HBufC* value;
       
   549     TInt err = queryItf->GetText(elementId, value, aPlatsecItf);
       
   550     if (err == KErrNotFound)
       
   551         {
       
   552         elementId = SecondChanceModemBearerLegacyMapFieldNameL(aSettingName, aPlatsecItf);
       
   553         err = queryItf->GetText(elementId, value, aPlatsecItf);
       
   554         }
       
   555     User::LeaveIfError(err);
       
   556     aValue = *value;
       
   557     delete value;
       
   558     }
       
   559 
       
   560 
       
   561 EXPORT_C void CWinsockMetaConnectionProvider::GetLongDesSettingL(const TDesC& aSettingName, HBufC*& aValue, MPlatsecApiExt* aPlatsecItf)
       
   562     {
       
   563     aValue = NULL;
       
   564 
       
   565     const CAgentProvisionInfo* provisionInfo = AgentProvisionInfo();
       
   566     if (!provisionInfo)
       
   567         {
       
   568         User::Leave (KErrNotReady);
       
   569         }
       
   570 
       
   571     TMDBElementId elementId = MapFieldNameL(aSettingName, aPlatsecItf);
       
   572     MQueryConnSettingsApiExt* queryItf;
       
   573     ReturnInterfacePtrL(queryItf);
       
   574 
       
   575     TInt err = queryItf->GetText(elementId, aValue, aPlatsecItf);
       
   576     if (err == KErrNotFound)
       
   577         {
       
   578         elementId = SecondChanceModemBearerLegacyMapFieldNameL(aSettingName, aPlatsecItf);
       
   579         err = queryItf->GetText(elementId, aValue, aPlatsecItf);
       
   580         }
       
   581     User::LeaveIfError(err);
       
   582 
       
   583     }
       
   584 
       
   585 #endif
       
   586 TMDBElementId CWinsockMetaConnectionProvider::MapFieldNameL(const TDesC& aSettingName, MPlatsecApiExt* aPlatsecItf)
       
   587     {
       
   588     _LIT(KSlash, "\\");
       
   589     TInt pos = aSettingName.Find(KSlash);
       
   590     if (pos != KErrNotFound)
       
   591         {
       
   592       //  return CommDbShimUtil::GetElementIdFromFieldNameL(aSettingName);
       
   593         }
       
   594 
       
   595     MQueryConnSettingsApiExt* queryItf;
       
   596     ReturnInterfacePtrL(queryItf);
       
   597 
       
   598     HBufC16* serviceTable;
       
   599     User::LeaveIfError(queryItf->GetText(KCDTIdIAPServiceType, serviceTable, aPlatsecItf));
       
   600 
       
   601     const TInt KMaxFieldSize = 2*KCommsDbSvrMaxFieldLength + 1;
       
   602     TBuf<KMaxFieldSize> field;
       
   603 
       
   604     field = *serviceTable;
       
   605     delete serviceTable;
       
   606 
       
   607     field.Append(KSlash);
       
   608     field.Append(aSettingName);
       
   609     //return CommDbShimUtil::GetElementIdFromFieldNameL(field);
       
   610     }
       
   611 
       
   612 TMDBElementId CWinsockMetaConnectionProvider::SecondChanceModemBearerLegacyMapFieldNameL(const TDesC& aSettingName, MPlatsecApiExt* aPlatsecItf)
       
   613     {
       
   614     //This nasty looking method re-implements the lagacy behaviour whereat, despite the current IAP not
       
   615     //featuring the ModemBearer table (because it represnts LAN for instance) would still serve queries
       
   616     //addressed to "ModemBearer\\<field>>" assuming the local equivallent of the ModemBearer (e.g: LanBearer)
       
   617     //table is actually meant.
       
   618     _LIT(KSlash, "\\");
       
   619     TInt pos = aSettingName.Find(KSlash);
       
   620     if (pos != KErrNotFound)
       
   621         {
       
   622         TPtrC left = aSettingName.Left(pos);
       
   623         TPtrC right = aSettingName.Mid(pos+1);
       
   624         if (left.CompareC(TPtrC(MODEM_BEARER)) == 0)
       
   625             {
       
   626             HBufC16* bearerTable;
       
   627 
       
   628             MQueryConnSettingsApiExt* queryItf;
       
   629             ReturnInterfacePtrL(queryItf);
       
   630 
       
   631             User::LeaveIfError(queryItf->GetText(KCDTIdIAPBearerType, bearerTable, aPlatsecItf));
       
   632 
       
   633             const TInt KMaxFieldSize = 2*KCommsDbSvrMaxFieldLength + 1;
       
   634             TBuf<KMaxFieldSize> field;
       
   635 
       
   636             field = *bearerTable;
       
   637             delete bearerTable;
       
   638 
       
   639             field.Append(KSlash);
       
   640             field.Append(right);
       
   641             return MapFieldNameL(field, aPlatsecItf);
       
   642             }
       
   643         }
       
   644     User::Leave(KErrNotFound);
       
   645     return 0;
       
   646     }
       
   647 
       
   648 /**
       
   649 Retrieves the Agent Provider specific provisioning information as given by the MCpr
       
   650 transition.
       
   651 
       
   652 @internalTechnology
       
   653 */
       
   654 const CAgentProvisionInfo* CWinsockMetaConnectionProvider::AgentProvisionInfo()
       
   655     {
       
   656 #if 0
       
   657     }
       
   658     const CAgentProvisionInfo* agentProvisionInfo = static_cast<const CAgentProvisionInfo*>(AccessPointConfig().FindExtension(CAgentProvisionInfo::TypeId()));
       
   659 	__ASSERT_DEBUG(agentProvisionInfo, User::Panic(KSpecAssert_NifManAgtPrCgntm, 8));
       
   660     return agentProvisionInfo;
       
   661 #endif
       
   662     }
       
   663