datacommsserver/networkingdialogapi/src/ND_DLGSL.CPP
changeset 0 dfb7c4ff071f
child 14 8b5d60ce1e94
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 "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  @internalComponent
       
    19 */
       
    20 
       
    21 #include <commsdattypesv1_1.h>
       
    22 #include <commsdattypesv1_1_partner.h>
       
    23 #include <metadatabase.h>
       
    24 using namespace CommsDat;
       
    25 #include <cdbpreftable.h>
       
    26 #include <agentdialog.h>
       
    27 #include "ND_DLGSL.H"
       
    28 #include <es_ini.h>
       
    29 #include <commsdattypeinfov1_1_internal.h>
       
    30 
       
    31 /** Literal accepts the String */
       
    32 _LIT(KSelectTitle,"Select %S");
       
    33 
       
    34 /** Literal accepts the String */
       
    35 _LIT(KSelectPrompt,"%S");
       
    36 
       
    37 /** Literal accepts the Integer */
       
    38 _LIT(KWarnPrompt,"Connection failed with %d");
       
    39 
       
    40 /** Literal Specifies the New Connection */
       
    41 _LIT(KWarnPromptNoError,"New connection");
       
    42 
       
    43 /** Literal Conain the String trying to connect to server */
       
    44 _LIT(KAttemptPrompt,"Attempt to connect to %S?");
       
    45 
       
    46 /** Literal prompts to Select IAP */
       
    47 _LIT(KIAP,"IAP");
       
    48 /** Literal prompts to Select IAP */
       
    49 _LIT(KAP, "Access Point");
       
    50 
       
    51 /** Literal Specifies QoSWarning */
       
    52 _LIT(KQoSWarnTitle,"The connection quality is lower than required");
       
    53 
       
    54 /** Literal Specifies Disconnect option */
       
    55 _LIT(KQoSWarnPrompt,"Do you wish to disconnect?");
       
    56 
       
    57 namespace ND_DLDSL
       
    58 	{
       
    59 const TInt KOneSecond=1000000;			//< TimeInterval of OneSecond 
       
    60 const TInt KTimeInterval=KOneSecond;	//< TimeInterval to start the CPctTimer
       
    61 const TInt KNotifierLength=16;			//< NotifierLength
       
    62 const TText KFullStop='.';				//< Constant to hold FullStop
       
    63 	}
       
    64 
       
    65 CDialogBase::CDialogBase(CNetDialDialogSession* aSession, TInt aPriority)
       
    66 	: CActive(aPriority),
       
    67 	iSession(aSession),
       
    68 	iAgentDialogInput(iAgentDialogInputBuf()),
       
    69 	iAgentDialogOutput(iAgentDialogOutputBuf())
       
    70 /**
       
    71 CDialogBase Constructor.
       
    72 */
       
    73 	{
       
    74 	__FLOG_OPEN(KDlgSvrLogSubsys, KDlgSvrLogComponent);
       
    75 	}
       
    76 
       
    77 void CDialogBase::ConstructL()
       
    78 /**
       
    79 Completes construction of the CDialogBase object.
       
    80 */
       
    81 	{
       
    82 	iNotifier = new(ELeave) RNotifier();
       
    83 	User::LeaveIfError(iNotifier->Connect());
       
    84 	
       
    85 	_LIT(KAgentDialogIniFileName, "agentdialog.ini");
       
    86 	_LIT(KNotifierUidTag, "NotifierUid");
       
    87 	CESockIniData* cfgFile = NULL;
       
    88 	
       
    89 	// coverity[SYMBIAN.CLEANUP_STACK] coverity [alloc_fn]
       
    90     // coverity[SYMBIAN.CLEANUP_STACK] coverity [assign]
       
    91 	TRAPD(err, cfgFile = CESockIniData::NewL(KAgentDialogIniFileName));
       
    92 	// coverity[SYMBIAN.CLEANUP_STACK] coverity [leave_without_push]
       
    93 	__FLOG_1(_L("Agent dialog config file for  - returned %d"),err);
       
    94 
       
    95         if (err == KErrNone)
       
    96 		{
       
    97 		// the file was opened correctly
       
    98 		TInt val = 0;
       
    99 		if (cfgFile->FindVar(KNotifierUidTag, val))
       
   100 			{
       
   101 			// the value was found, build a TUid to assign to the member variable
       
   102 			iUidAgentDialogNotifier = TUid::Uid(val);
       
   103 			__FLOG(_L("Uid Found in ini file"));
       
   104 			}
       
   105 		else
       
   106 			{
       
   107 			// value was not found, use the default UID for agent dialog notifiers
       
   108 			iUidAgentDialogNotifier = KUidAgentDialogNotifier;
       
   109 			}
       
   110 		delete cfgFile;	
       
   111 		}
       
   112 	else
       
   113 		{
       
   114 		// the ini file was not found so use the default UID for agent dialog notifiers
       
   115 		iUidAgentDialogNotifier = KUidAgentDialogNotifier;
       
   116 		}
       
   117 	__FLOG_1(_L("Uid Loaded ===>%x"),iUidAgentDialogNotifier.iUid);	
       
   118 	}
       
   119 
       
   120 CDialogBase::~CDialogBase()
       
   121 /**
       
   122 Destructor.
       
   123 */
       
   124 	{
       
   125 	if (iNotifier!=NULL)
       
   126 		{
       
   127 		iNotifier->Close();
       
   128 		delete iNotifier;
       
   129 		}
       
   130 	delete iCallBack;
       
   131 	__FLOG_CLOSE;
       
   132 	}	
       
   133 	
       
   134 
       
   135 void CDialogBase::StartNotifierAndGetResponse()
       
   136 /**
       
   137 Utility function to start the dialog notifier
       
   138  */
       
   139 	{
       
   140 	__ASSERT_DEBUG(iNotifier!=NULL, User::Invariant());
       
   141 
       
   142 	__FLOG_1(_L("CDialogBase::StartNotifierAndGetResponse - Openning Dialog - Uid Loaded ===>%x "),
       
   143 		iUidAgentDialogNotifier.iUid);
       
   144 	iNotifier->StartNotifierAndGetResponse( iStatus, iUidAgentDialogNotifier, iAgentDialogInputBuf, iAgentDialogOutputBuf );
       
   145 	SetActive();
       
   146 	}
       
   147 
       
   148 void CDialogBase::CancelNotifier()
       
   149 /**
       
   150  Utility function to cancel the dialog notifier
       
   151 */
       
   152 	{
       
   153 	__ASSERT_DEBUG(iNotifier!=NULL, User::Invariant());
       
   154 	iCancelFlag=ETrue;
       
   155 	iNotifier->CancelNotifier(iUidAgentDialogNotifier);
       
   156 	}
       
   157 
       
   158 void CDialogBase::DoCancel()
       
   159 /**
       
   160  Cancel the outstanding request - most of the derived classes have a
       
   161  common DoCancel method, so it seems reasonable to factor it here
       
   162 */
       
   163 	{
       
   164 	CancelNotifier();
       
   165 	}
       
   166 
       
   167 
       
   168 
       
   169 
       
   170 
       
   171 CIAPSelection* CIAPSelection::NewL(CMDBSession* aDb,CNetDialDialogSession* aSession, TInt aPriority)
       
   172 /**
       
   173 IAP Selection
       
   174 
       
   175 @param aDb pointer to communications database.
       
   176 @param aSession pointer to NetDialDialogSession.
       
   177 @param aPriority Priority.
       
   178 @return Pointer to IAPSelection object.
       
   179 */
       
   180 	{
       
   181 	CIAPSelection* r=new(ELeave) CIAPSelection(aDb,aSession,aPriority);
       
   182 	CleanupStack::PushL(r);
       
   183 	r->ConstructL();
       
   184 	CleanupStack::Pop();
       
   185 	return r;
       
   186 	}
       
   187 
       
   188 CIAPSelection::CIAPSelection(CMDBSession* aDb,CNetDialDialogSession* aSession, TInt aPriority)
       
   189 	: CDialogBase(aSession, aPriority),
       
   190 	iDb(aDb)
       
   191 
       
   192 	
       
   193 /**
       
   194 CIAPSelection Constructor
       
   195 */
       
   196 	{}
       
   197 
       
   198 void CIAPSelection::ConstructL()
       
   199 /**
       
   200 Completes construction of the CIAPSelection object.
       
   201 
       
   202 @see CDialogBase::ConstructL().
       
   203 */
       
   204 	{
       
   205 	CDialogBase::ConstructL();
       
   206 	CActiveScheduler::Add(this);
       
   207 		InitRecordSetL();
       
   208 	}
       
   209 
       
   210 CIAPSelection::~CIAPSelection()
       
   211 /**
       
   212 CIAPSelection Destructor.
       
   213 */
       
   214 	{
       
   215 	Cancel();
       
   216 	delete iTable;
       
   217 	}
       
   218 	
       
   219 void CIAPSelection::InitRecordSetL()
       
   220 	{
       
   221 	delete iTable;
       
   222 	iTable = NULL;
       
   223 	iTable = new (ELeave)CMDBRecordSet<CCDConnectionPrefsRecord>(KCDTIdConnectionPrefsRecord);
       
   224 	//CCDConnectionPrefsRecord* ptrTemplate = new (ELeave) CCDConnectionPrefsRecord();
       
   225 	CCDConnectionPrefsRecord* ptrTemplate = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord));
       
   226 	CleanupStack::PushL(ptrTemplate);
       
   227 	User::LeaveIfError((iTable->iRecords).Append(ptrTemplate));
       
   228 	CleanupStack::Pop(ptrTemplate);
       
   229 	iRecordIndex = 0;
       
   230 	}
       
   231 	
       
   232 void CIAPSelection::GetIAPL(TUint32& aIAPId, const TConnectionPrefs& aPrefs, TInt aError, TCallBack aCallBack)
       
   233 /**
       
   234 Gets the IAP.
       
   235 
       
   236 @param aIAPId The id of the IAP service.
       
   237 @param aPrefs Specifies the rank and desired direction of the connection and bearer.
       
   238 @param aError Any error code, or KErrNone if no error.
       
   239 @param aCallBack Encapsulates a general call-back function.
       
   240 */
       
   241 	{
       
   242 	iCancelFlag = EFalse;
       
   243 	iCallBack = new(ELeave) CAsyncCallBack(aCallBack,CActive::EPriorityStandard);
       
   244 	iIAPId = &aIAPId;
       
   245 	iRecordsPresent = ETrue;
       
   246 
       
   247 	if(iRecordIndex != 0)
       
   248 		{
       
   249 		InitRecordSetL();
       
   250 		}
       
   251 
       
   252 	static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex])->iBearerSet = aPrefs.iBearerSet;
       
   253 	static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex])->iDirection = aPrefs.iDirection;
       
   254 
       
   255 	if(iTable->FindL(*iDb))
       
   256 		{
       
   257 		CCDIAPRecord* ptrIapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   258 		CleanupStack::PushL(ptrIapRecord);
       
   259 		
       
   260 		CCDConnectionPrefsRecord* connpref = static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex]);
       
   261 		ptrIapRecord->SetRecordId(connpref->iDefaultIAP);
       
   262 		ptrIapRecord->LoadL(*iDb);
       
   263 		connpref->iDefaultIAP.iLinkedRecord = ptrIapRecord;
       
   264 		CleanupStack::Pop(ptrIapRecord);
       
   265 		SelectL(aError);
       
   266 		}
       
   267 	else
       
   268 	// else case is common part for failure
       
   269 		{
       
   270 		if (aError!=KErrNone)
       
   271 			{
       
   272 			iAgentDialogInput.iTitle.Format(KWarnPrompt,aError);
       
   273 			}
       
   274 		_LIT(noService,"No IAP Records Found");
       
   275 		iAgentDialogInput.iTitle.Append(noService);
       
   276 		iAgentDialogInput.iDialog = EContinueDialog;
       
   277 		StartNotifierAndGetResponse();
       
   278 		iRecordsPresent = EFalse;
       
   279 		}
       
   280 	}
       
   281 
       
   282 void CIAPSelection::SelectL(TInt aError)
       
   283 /**
       
   284 @param aError Any error code, or KErrNone if no error.
       
   285 */
       
   286 	{
       
   287 	if (aError!=KErrNone)
       
   288 		{
       
   289 		iAgentDialogInput.iTitle.Format(KWarnPrompt,aError);
       
   290 //		iAgentDialogInput.iTitle.Append(KCarriageReturn);
       
   291 		}
       
   292 	iAgentDialogInput.iTitle.AppendFormat(KSelectTitle,&KIAP);
       
   293 	ReselectL();
       
   294 	}
       
   295 
       
   296 void CIAPSelection::ReselectL()
       
   297 	{
       
   298 	CCDIAPRecord* ptrIapRecord  = static_cast<CCDIAPRecord*>(static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex])->iDefaultIAP.iLinkedRecord);
       
   299 
       
   300 	if(!ptrIapRecord)
       
   301 		{
       
   302 		CCDIAPRecord* ptrIapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   303 		CleanupStack::PushL(ptrIapRecord);
       
   304 		
       
   305 		CCDConnectionPrefsRecord* connpref = static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex]);
       
   306 		ptrIapRecord->SetRecordId(connpref->iDefaultIAP);
       
   307 		ptrIapRecord->LoadL(*iDb);
       
   308 		connpref->iDefaultIAP.iLinkedRecord = ptrIapRecord;
       
   309 		
       
   310 		CleanupStack::Pop(ptrIapRecord);
       
   311 		}
       
   312 
       
   313 	TBuf<KCommsDbSvrDefaultTextFieldLength> tmpBuffer;
       
   314 	tmpBuffer = ptrIapRecord->iRecordName;
       
   315 	iAgentDialogInput.iLabel.Format(KSelectPrompt,&tmpBuffer);
       
   316 	iAgentDialogInput.iDialog = ENoYesDialog;
       
   317 	StartNotifierAndGetResponse();
       
   318 	}
       
   319 
       
   320 void CIAPSelection::RunL()
       
   321 /**
       
   322 Handles an active object’s request completion event.
       
   323 */
       
   324 	{
       
   325 	if (iStatus < KErrNone)
       
   326 		{
       
   327 		__FLOG_1(_L("Dialog returned with %d"),iStatus.Int());
       
   328 		iResultStatus=iStatus.Int();
       
   329 		if((iResultStatus==KErrNone)&&(iCancelFlag))
       
   330 			{
       
   331 			iResultStatus=KErrCancel;
       
   332 			}
       
   333 		iCallBack->Call();
       
   334 		return;
       
   335 		}
       
   336 
       
   337 	if (iRecordsPresent)
       
   338 		{
       
   339 		if (iStatus.Int() == EAgentYesPressed)	//YES Pressed
       
   340 			{
       
   341 			__FLOG(_L("Dialog returned after \"Yes\" was pressed"));
       
   342 			*iIAPId = static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex])->iDefaultIAP;
       
   343 			iResultStatus=KErrNone;
       
   344 			iCallBack->Call();	
       
   345 			}
       
   346 		else
       
   347 			{
       
   348 			__FLOG_1(_L("No pressed selecting next record - returned %d"),iStatus.Int());
       
   349 			if(iRecordIndex < (iTable->iRecords.Count() - 1))
       
   350 				{
       
   351 				iRecordIndex++;
       
   352 				}
       
   353 			else
       
   354 				{
       
   355 				iRecordIndex = 0;
       
   356 				}					
       
   357 			
       
   358 			CCDIAPRecord* ptrIapRecord  = static_cast<CCDIAPRecord*>(static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex])->iDefaultIAP.iLinkedRecord);
       
   359 	
       
   360 			if(!ptrIapRecord)
       
   361 				{
       
   362 				CCDIAPRecord* ptrIapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   363 				
       
   364 				CCDConnectionPrefsRecord* connpref = static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex]);
       
   365 				ptrIapRecord->SetRecordId(connpref->iDefaultIAP);
       
   366 				connpref->iDefaultIAP.iLinkedRecord = ptrIapRecord;				
       
   367 				}				
       
   368 			
       
   369 			static_cast<CCDIAPRecord*>(static_cast<CCDConnectionPrefsRecord*>(iTable->iRecords[iRecordIndex])->iDefaultIAP.iLinkedRecord)->LoadL(*iDb);
       
   370 				
       
   371 			ReselectL();
       
   372 			}
       
   373 		}
       
   374 	else
       
   375 		{
       
   376 		iResultStatus=KErrCancel;
       
   377 		iCallBack->Call();
       
   378 		}
       
   379 	}
       
   380 
       
   381 TInt CIAPSelection::Status()
       
   382 /**
       
   383 Gets the Status
       
   384 @return the status.
       
   385 */
       
   386 	{
       
   387 	return iResultStatus;
       
   388 	}
       
   389 
       
   390 
       
   391 CAccessPointSelection* CAccessPointSelection::NewL(CMDBSession* aDb,CNetDialDialogSession* aSession, TInt aPriority)
       
   392 /**
       
   393 AccessPoint Selection
       
   394 
       
   395 @param aDb pointer to communications database.
       
   396 @param aSession pointer to NetDialDialogSession.
       
   397 @param aPriority Priority.
       
   398 @return Pointer to AccessPointSelection object.
       
   399 */
       
   400 	{
       
   401 	CAccessPointSelection* r=new(ELeave) CAccessPointSelection(aDb,aSession,aPriority);
       
   402 	CleanupStack::PushL(r);
       
   403 	r->ConstructL();
       
   404 	CleanupStack::Pop();
       
   405 	return r;
       
   406 	}
       
   407 
       
   408 CAccessPointSelection::CAccessPointSelection(CMDBSession* aDb,CNetDialDialogSession* aSession, TInt aPriority)
       
   409 	: CDialogBase(aSession, aPriority),
       
   410 	iDb(aDb)
       
   411 /**
       
   412 CIAPSelection Constructor
       
   413 */
       
   414 	{
       
   415 	}
       
   416 
       
   417 void CAccessPointSelection::ConstructL()
       
   418 /**
       
   419 Completes construction of the CAccessPointSelection object.
       
   420 
       
   421 @see CDialogBase::ConstructL().
       
   422 */
       
   423 	{
       
   424 	CDialogBase::ConstructL();
       
   425 	CActiveScheduler::Add(this);
       
   426 	}
       
   427 
       
   428 CAccessPointSelection::~CAccessPointSelection()
       
   429 /**
       
   430 CAccessPointSelection Destructor.
       
   431 */
       
   432 	{
       
   433 	Cancel();
       
   434 	delete iTable;
       
   435 	}
       
   436 	
       
   437 void CAccessPointSelection::InitRecordSetL(TUint32 aDefaultAP, TInt aTierId)
       
   438 	{
       
   439 	ASSERT(iTable==0);
       
   440 	iTable = new (ELeave) CMDBRecordSet<CCDAccessPointRecord>(KCDTIdAccessPointRecord);
       
   441 	iTable->LoadL(*iDb);
       
   442 	
       
   443     //just to show the TableId and RecordId
       
   444     TInt bitMask = KCDMaskShowRecordType | KCDMaskShowRecordId;
       
   445 
       
   446 	// sort with default SNAP first
       
   447 	for (TInt i = 0; i < iTable->iRecords.Count(); i++)
       
   448 		{
       
   449 		//if (static_cast<CCDAccessPointRecord*>(iTable->iRecords[i])->iRecordTag == aDefaultAP)
       
   450 		CCDAccessPointRecord* aprec = static_cast<CCDAccessPointRecord*>(iTable->iRecords[i]);
       
   451 		TInt id = aprec->ElementId() & bitMask;
       
   452 		if ( (static_cast<CCDAccessPointRecord*>(iTable->iRecords[i])->ElementId() & bitMask) == aDefaultAP)
       
   453 			{
       
   454 			CMDBRecordBase* t = iTable->iRecords[i];
       
   455 			iTable->iRecords[i] = iTable->iRecords[0];
       
   456 			iTable->iRecords[0] = t;
       
   457 			break;
       
   458 			}
       
   459 		}
       
   460 
       
   461 	// filter out all access points that do not belong to the specified group
       
   462     CMDBField<TInt>* tierTagId = new(ELeave) CMDBField<TInt>(KCDTIdTierRecord | KCDTIdRecordTag);
       
   463     CleanupStack::PushL(tierTagId);
       
   464 
       
   465 	for (TInt i = iTable->iRecords.Count() - 1; i >= 0; i--)
       
   466 		{
       
   467 		ASSERT((iTable->iRecords[i]->TypeId() & KCDMaskShowRecordType) == KCDTIdAccessPointRecord);
       
   468         //this is the ElementId of the linked TierRec...
       
   469 		TMDBElementId tierElementId = static_cast<CCDAccessPointRecord*>(iTable->iRecords[i])->iTier;	// was iAccessPointGID; tiers subsume groups concept
       
   470 		TInt tierRecId = (tierElementId & KCDMaskShowRecordId) >> 8;
       
   471 		
       
   472 		tierTagId->SetRecordId(tierRecId);
       
   473 		
       
   474 		tierTagId->LoadL(*iDb);
       
   475 		
       
   476 		TInt tierId = *tierTagId;
       
   477 		if (tierId != aTierId)
       
   478 			{
       
   479 			CMDBRecordBase* ptr = iTable->iRecords[i];
       
   480 			iTable->iRecords.Remove(i);
       
   481 			delete ptr;			
       
   482 			}
       
   483 		}
       
   484     CleanupStack::PopAndDestroy(tierTagId);
       
   485 	}
       
   486 	
       
   487 void CAccessPointSelection::GetAccessPointL(TUint32& aAPId, TInt aTierId, TCallBack aCallBack)
       
   488 /**
       
   489 Gets the access point.
       
   490 
       
   491 @param aAPId The id of the access point.
       
   492 @param aTierId Specifies the tier id.
       
   493 @param aError Any error code, or KErrNone if no error.
       
   494 @param aCallBack Encapsulates a general call-back function.
       
   495 */
       
   496 	{
       
   497 	User::LeaveIfError(aTierId>0? KErrNone : KErrArgument);
       
   498 
       
   499 	iCallBack = new(ELeave) CAsyncCallBack(aCallBack,CActive::EPriorityStandard);
       
   500 	iCancelFlag = EFalse;
       
   501 	iAPId = &aAPId;
       
   502 	iRecordsPresent = ETrue;
       
   503 
       
   504 	//Get UID of the tier's manager having the tier's id.
       
   505     CCDTierRecord* tierRec = static_cast<CCDTierRecord*>(CCDTierRecord::RecordFactoryL(KCDTIdTierRecord));
       
   506 	CleanupStack::PushL(tierRec);
       
   507     tierRec->iRecordTag = aTierId;
       
   508 	TBool found = tierRec->FindL(*iDb);
       
   509 	if (!found)
       
   510     	{
       
   511     	User::Leave(KErrNotFound);
       
   512     	}
       
   513 	ASSERT(tierRec->iTierManagerName.TypeId() == KCDTIdTierManagerName); // Panics if built against incorrect CommsDat.
       
   514 
       
   515 	if (tierRec->iDefaultAccessPoint != 0)
       
   516 		{
       
   517 		TInt defaultAP = tierRec->iDefaultAccessPoint;
       
   518 		InitRecordSetL(defaultAP,aTierId);
       
   519 		if (iTable->iRecords.Count() > 0)
       
   520 			{
       
   521 			iAgentDialogInput.iTitle.AppendFormat(KSelectTitle, &KAP);
       
   522 			ReselectL();
       
   523 			}
       
   524 		else
       
   525 			{
       
   526 			iAgentDialogInput.iTitle.Format(KWarnPrompt,KErrNotFound);
       
   527 			_LIT(noService, "No Access Point Records Found");
       
   528 			iAgentDialogInput.iTitle.Append(noService);
       
   529 			iAgentDialogInput.iDialog = EContinueDialog;
       
   530 			StartNotifierAndGetResponse();
       
   531 			iRecordsPresent = EFalse;
       
   532 			}
       
   533 		}
       
   534 	CleanupStack::PopAndDestroy(tierRec);
       
   535 
       
   536 	}
       
   537 
       
   538 void CAccessPointSelection::ReselectL()
       
   539 	{
       
   540 	TBuf<KCommsDbSvrDefaultTextFieldLength> tmpBuffer;
       
   541 	CCDAccessPointRecord* snapRecord = static_cast<CCDAccessPointRecord*>(iTable->iRecords[iRecordIndex]);
       
   542 	tmpBuffer = snapRecord->iRecordName;
       
   543 	iAgentDialogInput.iLabel.Format(KSelectPrompt,&tmpBuffer);
       
   544 	iAgentDialogInput.iDialog = ENoYesDialog;
       
   545 	StartNotifierAndGetResponse();
       
   546 	}
       
   547 
       
   548 void CAccessPointSelection::RunL()
       
   549 /**
       
   550 Handles an active object’s request completion event.
       
   551 */
       
   552 	{
       
   553 	if (iStatus < KErrNone)
       
   554 		{
       
   555 		__FLOG_1(_L("Dialog returned with %d"),iStatus.Int());
       
   556 		iResultStatus=iStatus.Int();
       
   557 		if((iResultStatus==KErrNone)&&(iCancelFlag))
       
   558 			{
       
   559 			iResultStatus=KErrCancel;
       
   560 			}
       
   561 		iCallBack->Call();
       
   562 		return;
       
   563 		}
       
   564 
       
   565 	if (iRecordsPresent)
       
   566 		{
       
   567 		if (iStatus.Int() == EAgentYesPressed)	//YES Pressed
       
   568 			{
       
   569 			__FLOG(_L("Dialog returned after \"Yes\" was pressed"));
       
   570 			CCDAccessPointRecord* snapRecord = static_cast<CCDAccessPointRecord*>(iTable->iRecords[iRecordIndex]);
       
   571 			*iAPId = snapRecord->iRecordTag;
       
   572 			iResultStatus=KErrNone;
       
   573 			iCallBack->Call();	
       
   574 			}
       
   575 		else
       
   576 			{
       
   577 			__FLOG_1(_L("No pressed selecting next record - returned %d"),iStatus.Int());
       
   578 			if(iRecordIndex < (iTable->iRecords.Count() - 1))
       
   579 				{
       
   580 				iRecordIndex++;
       
   581 				}
       
   582 			else
       
   583 				{
       
   584 				iRecordIndex = 0;
       
   585 				}					
       
   586 
       
   587 			ReselectL();
       
   588 			}
       
   589 		}
       
   590 	else
       
   591 		{
       
   592 		iResultStatus=KErrCancel;
       
   593 		iCallBack->Call();
       
   594 		}
       
   595 	}
       
   596 
       
   597 TInt CAccessPointSelection::Status()
       
   598 /**
       
   599 Gets the Status
       
   600 @return the status.
       
   601 */
       
   602 	{
       
   603 	return iResultStatus;
       
   604 	}
       
   605 
       
   606 
       
   607 CModemAndLocationSelection* CModemAndLocationSelection::NewL(CMDBSession* aDb,CNetDialDialogSession* aSession, TInt aPriority)
       
   608 /**
       
   609 Modem And Location Selection
       
   610 @param aDb pointer to communications database/commsdat session.
       
   611 @param aSession pointer to NetDialDialogSession.
       
   612 @param aPriority Priority.
       
   613 @return A Pointer to CModemAndLocationSelection object.
       
   614 */
       
   615 	{
       
   616 	CModemAndLocationSelection* r=new(ELeave) CModemAndLocationSelection(aDb,aSession,aPriority);
       
   617 	CleanupStack::PushL(r);
       
   618 	r->ConstructL();
       
   619 	CleanupStack::Pop();
       
   620 	return r;
       
   621 	}
       
   622 
       
   623 CModemAndLocationSelection::CModemAndLocationSelection(CMDBSession* aDb,CNetDialDialogSession* aSession, TInt aPriority)
       
   624 	: CDialogBase(aSession, aPriority),
       
   625 	iDb(aDb)
       
   626 	
       
   627 /**
       
   628 Constructor
       
   629 */
       
   630 	{}
       
   631 
       
   632 void CModemAndLocationSelection::ConstructL()
       
   633 /**
       
   634 Create a new CModemAndLocationSelection object.
       
   635 */
       
   636 	{
       
   637 	CDialogBase::ConstructL();
       
   638 	CActiveScheduler::Add(this);
       
   639 	}
       
   640 
       
   641 void CModemAndLocationSelection::InitRecordSetL(TMDBElementId aRecordId)
       
   642 	{
       
   643 	delete iTable;
       
   644 	iTable = NULL;
       
   645 
       
   646 	CCDRecordBase* ptrTemplate;
       
   647 	if(aRecordId == KCDTIdModemBearerRecord)
       
   648 		{
       
   649 		iTable = new (ELeave)CMDBRecordSet<CCDModemBearerRecord>(KCDTIdModemBearerRecord);
       
   650 		ptrTemplate = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
       
   651 		}
       
   652 	else
       
   653 		{
       
   654 		iTable = new (ELeave)CMDBRecordSet<CCDLocationRecord>(KCDTIdLocationRecord);
       
   655 		ptrTemplate = static_cast<CCDLocationRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdLocationRecord));
       
   656 		}		
       
   657 
       
   658 	CleanupStack::PushL(ptrTemplate);
       
   659 	User::LeaveIfError((iTable->iRecords).Append(ptrTemplate));
       
   660 	CleanupStack::Pop(ptrTemplate);
       
   661 
       
   662 	iRecordIndex = 0;
       
   663 	}
       
   664 CModemAndLocationSelection::~CModemAndLocationSelection()
       
   665 /**
       
   666 Destructor
       
   667 */
       
   668 	{
       
   669 	Cancel();
       
   670 	delete iTable;
       
   671 	}
       
   672 
       
   673 void CModemAndLocationSelection::GetModemAndLocationL(TUint32& aModemId, TUint32& aLocationId, TCallBack aCallBack)
       
   674 /**
       
   675 Shows a dialog to enable the user to choose which modem and location to use for data transactions
       
   676 
       
   677 @param aModemId The id of of the record in the modem table to be used for data transactions
       
   678 @param aLocationId The id of the record in the location table to be used for the modem for data transactions
       
   679 @param aStatus Any error code, or KErrNone if no error
       
   680 */
       
   681 	{
       
   682 	iCancelFlag = EFalse;
       
   683 	iCallBack = new(ELeave) CAsyncCallBack(aCallBack,CActive::EPriorityStandard);
       
   684 	iModemId = &aModemId;
       
   685 	iLocationId = &aLocationId;
       
   686 	
       
   687 	StartModemSelectL();
       
   688 	}
       
   689 
       
   690 void CModemAndLocationSelection::StartModemSelectL()
       
   691 /**
       
   692 Shows a dialog to enable the user to start the modem.
       
   693 */
       
   694 	{
       
   695 	iState=EEnterModem;
       
   696 	InitRecordSetL(KCDTIdModemBearerRecord);	
       
   697 	TRAPD(result, iTable->LoadL(*iDb)); 
       
   698 
       
   699 	if (result != KErrNone)	
       
   700 		{
       
   701 		DisplayNoRecordsL();
       
   702 		}
       
   703 	else
       
   704 		{
       
   705 		SelectL(TPtrC(MODEM),KErrNone);
       
   706 		}
       
   707 	}
       
   708 
       
   709 void CModemAndLocationSelection::StartLocationSelectL()
       
   710 	{
       
   711 	iState=EEnterLocation;
       
   712 	delete iTable;
       
   713 	iTable = NULL;
       
   714 	InitRecordSetL(KCDTIdLocationRecord);	
       
   715 	TRAPD(result, iTable->LoadL(*iDb)); 
       
   716 
       
   717 	if (result != KErrNone)
       
   718 		{
       
   719 		DisplayNoRecordsL();
       
   720 		}
       
   721 	else
       
   722 		{
       
   723 		SelectL(TPtrC(LOCATION),KErrNone);
       
   724 		}
       
   725 	}
       
   726 
       
   727 void CModemAndLocationSelection::SelectL(const TDesC& aTable, TInt aError)
       
   728 	{
       
   729 	if (aError!=KErrNone)
       
   730 		{
       
   731 		iAgentDialogInput.iTitle.Format(KWarnPrompt,aError);
       
   732 		iAgentDialogInput.iTitle.Append(KCarriageReturn);
       
   733 		iAgentDialogInput.iTitle.AppendFormat(KSelectTitle,&aTable);
       
   734 		}
       
   735 	else
       
   736 		{
       
   737 		iAgentDialogInput.iTitle.Format(KSelectTitle,&aTable);
       
   738 		}
       
   739 	ReselectL();
       
   740 	}
       
   741 
       
   742 void CModemAndLocationSelection::ReselectL()
       
   743 	{
       
   744 	TBuf<KCommsDbSvrDefaultTextFieldLength> tmpBuffer;
       
   745 		tmpBuffer = static_cast<CCDRecordBase*>(iTable->iRecords[iRecordIndex])->iRecordName;
       
   746 		iAgentDialogInput.iLabel.Format(KSelectPrompt,&tmpBuffer);
       
   747 	iAgentDialogInput.iDialog = ENoYesDialog;
       
   748 	StartNotifierAndGetResponse();
       
   749 	}
       
   750 
       
   751 void CModemAndLocationSelection::DisplayNoRecordsL()
       
   752 /**
       
   753 @Leave ENoRecordFound If no records found.
       
   754 */
       
   755 	{
       
   756 	switch(iState)
       
   757 		{
       
   758 	case EEnterModem:
       
   759 			{
       
   760 			_LIT(noModem,"No Modem Records Found");
       
   761 			iAgentDialogInput.iTitle.Copy(noModem);
       
   762 			}
       
   763 		break;
       
   764 	case EEnterLocation:
       
   765 			{
       
   766 			_LIT(noLocation,"No Location Records Found");
       
   767 			iAgentDialogInput.iTitle.Copy(noLocation);
       
   768 			}
       
   769 		break;
       
   770 	default:
       
   771 			{	
       
   772 			_LIT(noRecords,"No Records Found");
       
   773 			iAgentDialogInput.iTitle.Copy(noRecords);
       
   774 			}
       
   775 		break;
       
   776 		}	
       
   777 	
       
   778 	iAgentDialogInput.iDialog = EContinueDialog;
       
   779 	StartNotifierAndGetResponse();
       
   780 
       
   781 	iState=ENoRecordFound;
       
   782 	}
       
   783 
       
   784 void CModemAndLocationSelection::RunL()
       
   785 /**
       
   786 Handles an active object’s request completion event.
       
   787 */
       
   788 	{
       
   789 	if (iStatus < KErrNone)
       
   790 		{
       
   791 		iResultStatus=iStatus.Int();
       
   792 		if((iResultStatus==KErrNone)&&(iCancelFlag))
       
   793 			{
       
   794 			iResultStatus=KErrCancel;
       
   795 			}
       
   796 		iCallBack->Call();
       
   797 		return;
       
   798 		}
       
   799 	
       
   800 	switch(iState)
       
   801 		{
       
   802 		case EEnterModem:
       
   803 			if(iStatus.Int() == EAgentYesPressed)	//Yes Pressed
       
   804 				{
       
   805 				*iModemId = (iTable->iRecords[iRecordIndex])->RecordId();
       
   806 				//iStatusResult is not yet KErrNone because need to enter the location too
       
   807 				StartLocationSelectL();
       
   808 				}
       
   809 			else
       
   810 				{
       
   811 				if(iRecordIndex < (iTable->iRecords.Count() - 1))
       
   812 					{
       
   813 					iRecordIndex++;
       
   814 					}
       
   815 				else
       
   816 					{
       
   817 					iRecordIndex = 0;
       
   818 					}						
       
   819 				ReselectL();
       
   820 			}
       
   821 			break;
       
   822 		case EEnterLocation:
       
   823 			if(iStatus.Int()  == EAgentYesPressed) //Yes Pressed
       
   824 				{
       
   825 				*iLocationId = (iTable->iRecords[iRecordIndex])->RecordId();
       
   826 				iResultStatus=KErrNone;
       
   827 				iCallBack->Call();	
       
   828 				}
       
   829 			else
       
   830 				{
       
   831 				if(iRecordIndex < (iTable->iRecords.Count() - 1))
       
   832 					{
       
   833 					iRecordIndex++;
       
   834 					}
       
   835 				else
       
   836 					{
       
   837 					iRecordIndex = 0;
       
   838 					}	
       
   839 				ReselectL();
       
   840 				}
       
   841 			break;
       
   842 		case ENoRecordFound:
       
   843 			iResultStatus=KErrCancel;
       
   844 			iCallBack->Call();
       
   845 			break;
       
   846 	
       
   847 		default:
       
   848 			User::Leave(KErrNotFound);
       
   849 			break;
       
   850 		}
       
   851 	}
       
   852 
       
   853 TInt CModemAndLocationSelection::Status()
       
   854 /**
       
   855 Gets the Status.
       
   856 
       
   857 @return the status.
       
   858 */
       
   859 	{
       
   860 	return iResultStatus;
       
   861 	}
       
   862 
       
   863 CIAPWarning* CIAPWarning::NewL(CNetDialDialogSession* aSession, TInt aPriority)
       
   864 /**
       
   865 IAP Warning.
       
   866 
       
   867 @param aSession pointer to NetDialDialogSession.
       
   868 @param aPriority Priority.
       
   869 @return A Pointer to CIAPWarning object.
       
   870 */
       
   871 	{
       
   872 	CIAPWarning* r=new(ELeave) CIAPWarning(aSession,aPriority);
       
   873 	CleanupStack::PushL(r);
       
   874 	r->ConstructL();
       
   875 	CleanupStack::Pop();
       
   876 	return r;
       
   877 	}
       
   878 
       
   879 CIAPWarning::CIAPWarning(CNetDialDialogSession* aSession, TInt aPriority)
       
   880 	: CDialogBase(aSession, aPriority)
       
   881 /**
       
   882 Constructor
       
   883 */
       
   884 	{}
       
   885 
       
   886 void CIAPWarning::ConstructL()
       
   887 /**
       
   888 Create a new CIAPWarning object.
       
   889 */
       
   890 	{
       
   891 	CDialogBase::ConstructL();
       
   892 	CActiveScheduler::Add(this);
       
   893 	}
       
   894 
       
   895 CIAPWarning::~CIAPWarning()
       
   896 /**
       
   897 Destructor.
       
   898 */
       
   899 	{
       
   900 	Cancel();
       
   901 	}
       
   902 
       
   903 void CIAPWarning::WarnIAPL(const TConnectionPrefs& /*aPrefs*/, TInt aLastError, const TDesC& aNewIapName, TBool& aResponse, TCallBack aCallBack)
       
   904 /**
       
   905 Warn IAP
       
   906 
       
   907 @param aPrefs Specifies the rank and desired direction of the connection and bearer.
       
   908 @param aLastError The error with which previous connection failed.
       
   909 @param aNewIapName The name of the IAP to be used for next connection.
       
   910 @param aResponse Specifies whether to proceed with the connection or stop the connection attempt.
       
   911 @param aCallBack Constructs the callback object with the specified callback function .
       
   912 */
       
   913 	{
       
   914 	iCancelFlag = EFalse;
       
   915 	iCallBack = new(ELeave) CAsyncCallBack(aCallBack,CActive::EPriorityStandard);
       
   916 	iResponse = &aResponse;
       
   917 
       
   918 	if (aLastError < KErrNone)
       
   919 		{
       
   920 		iAgentDialogInput.iTitle.Format(KWarnPrompt,aLastError);
       
   921 		iAgentDialogInput.iLabel.Format(KAttemptPrompt,&aNewIapName);
       
   922 		iAgentDialogInput.iDialog = ENoYesDialog;
       
   923 		}
       
   924 	else
       
   925 		{
       
   926 		iAgentDialogInput.iTitle.Copy(KWarnPromptNoError);
       
   927 		iAgentDialogInput.iLabel.Format(KAttemptPrompt,&aNewIapName);
       
   928 		iAgentDialogInput.iDialog = ENoYesDialog;
       
   929 		}
       
   930 	StartNotifierAndGetResponse();
       
   931 
       
   932 	}
       
   933 
       
   934 void CIAPWarning::RunL()
       
   935 /**
       
   936 Handles an active object’s request completion event.
       
   937 */
       
   938 	{
       
   939 	iResultStatus = iStatus.Int();
       
   940 	*iResponse = (iStatus.Int() == EAgentYesPressed);
       
   941 
       
   942 	if(iResultStatus == KErrNone && iCancelFlag)
       
   943 		{
       
   944 		iResultStatus = KErrCancel;
       
   945 		}
       
   946 
       
   947 	if (iResultStatus > KErrNone)
       
   948 		{
       
   949 		iResultStatus = KErrNone;
       
   950 		}
       
   951 		
       
   952 	iCallBack->Call();	
       
   953 	}
       
   954 
       
   955 TInt CIAPWarning::Status()
       
   956 /**
       
   957 Gets the Status
       
   958 
       
   959 @return the status.
       
   960 */
       
   961 	{
       
   962 	return iResultStatus;
       
   963 	}
       
   964 
       
   965 
       
   966 CLogin* CLogin::NewL(CNetDialDialogSession* aSession, TInt aPriority)
       
   967 /**
       
   968 Login Dialog
       
   969 
       
   970 @param aSession pointer to NetDialDialogSession.
       
   971 @param aPriority Priority.
       
   972 @return Pointer to CLogin object.
       
   973 */
       
   974 	{
       
   975 	CLogin* login=new(ELeave) CLogin(aSession,aPriority);
       
   976 	CleanupStack::PushL(login);
       
   977 	login->ConstructL();
       
   978 	CleanupStack::Pop();
       
   979 	return login;
       
   980 	}
       
   981 
       
   982 CLogin::CLogin(CNetDialDialogSession* aSession, TInt aPriority)
       
   983 	: CDialogBase(aSession, aPriority)
       
   984 /**
       
   985 Constructor.
       
   986 */
       
   987 	{
       
   988 	CActiveScheduler::Add(this);
       
   989 	}
       
   990 
       
   991 CLogin::~CLogin()
       
   992 /**
       
   993 Destructor.
       
   994 */
       
   995 	{
       
   996 	Cancel();
       
   997 	}
       
   998 
       
   999 void CLogin::GetUserPassL(TDes& aUsername, TDes& aPassword, TCallBack aCallBack)
       
  1000 /**
       
  1001 Get the User Name and Password.
       
  1002 
       
  1003 @param aUsername Username.
       
  1004 @param aPassword Password.
       
  1005 @param aCallBack Constructs the callback object with the specified callback function.
       
  1006 */
       
  1007 	{
       
  1008 	iCancelFlag=EFalse;
       
  1009 	iCallBack=new(ELeave) CAsyncCallBack(aCallBack,0);
       
  1010 	iUsername=&aUsername;
       
  1011 	iPassword=&aPassword;
       
  1012 	StartGetUsername();
       
  1013 	}
       
  1014 
       
  1015 void CLogin::StartGetUsername()
       
  1016 	{
       
  1017 	_LIT(KLoginUsernamePrompt,"Select Login Username");
       
  1018 	iAgentDialogInput.iTitle.Copy(KLoginUsernamePrompt);
       
  1019 	iAgentDialogInput.iLabel.Copy(*iUsername);
       
  1020 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1021 	StartNotifierAndGetResponse();
       
  1022 	iState = EEnterName;
       
  1023 	}
       
  1024 
       
  1025 void CLogin::StartGetPassword()
       
  1026 	{
       
  1027 	_LIT(KLoginPasswordPrompt,"Select Login Password");
       
  1028 	iAgentDialogInput.iTitle.Copy(KLoginPasswordPrompt);
       
  1029 	iAgentDialogInput.iLabel.Copy(*iPassword);
       
  1030 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1031 	StartNotifierAndGetResponse();
       
  1032 	iState = EEnterPass;
       
  1033 	}
       
  1034 
       
  1035 void CLogin::RunL()
       
  1036 /**
       
  1037 Handles an active object’s request completion event.
       
  1038 */
       
  1039 	{
       
  1040 	if (iStatus.Int() < KErrNone)
       
  1041 		{
       
  1042 		iResultStatus=iStatus.Int();
       
  1043 		if((iResultStatus==KErrNone)&&(iCancelFlag))
       
  1044 			{
       
  1045 			iResultStatus=KErrCancel;
       
  1046 			}
       
  1047 		iCallBack->Call();
       
  1048 		return;
       
  1049 		}
       
  1050 
       
  1051 	switch(iState)
       
  1052 		{
       
  1053 	case EEnterName:
       
  1054 		if(iStatus.Int() == EAgentYesPressed)	//yes Pressed
       
  1055 			{
       
  1056 			StartGetPassword();
       
  1057 			}
       
  1058 		else
       
  1059 			{
       
  1060 			for(TInt i=0;i<iUsername->Length();i++)
       
  1061 				{
       
  1062 				TChar aChar=(TChar)(++(*iUsername)[i]);
       
  1063 				if(!aChar.IsAlphaDigit())
       
  1064 					{
       
  1065 					(*iUsername)[i]=ND_DLDSL::KFullStop;
       
  1066 					}
       
  1067 				}
       
  1068 			StartGetUsername();
       
  1069 			}
       
  1070 		break;
       
  1071 
       
  1072 	case EEnterPass:
       
  1073 		if(iStatus.Int() == EAgentYesPressed)	//Yes PRessed
       
  1074 			{
       
  1075 			iResultStatus=KErrNone;
       
  1076 			iCallBack->Call();
       
  1077 			}
       
  1078 		else
       
  1079 			{
       
  1080 			for(TInt i=0;i<iPassword->Length();i++)
       
  1081 				{
       
  1082 				TChar aChar=(TChar)(++(*iPassword)[i]);
       
  1083 				if(!aChar.IsAlphaDigit())
       
  1084 					{
       
  1085 					(*iPassword)[i]=ND_DLDSL::KFullStop;
       
  1086 					}
       
  1087 				}
       
  1088 			StartGetPassword();
       
  1089 			}
       
  1090 		break;
       
  1091 
       
  1092 	default:
       
  1093 		User::Leave(KErrNotFound);
       
  1094 		break;
       
  1095 		}
       
  1096 
       
  1097 	}
       
  1098 
       
  1099 
       
  1100 TInt CLogin::Status()
       
  1101 /**
       
  1102 Gets the Status.
       
  1103 
       
  1104 @return the status.
       
  1105 */
       
  1106 	{
       
  1107 	return iResultStatus;
       
  1108 	}
       
  1109 
       
  1110 CAuthenticate* CAuthenticate::NewL(CNetDialDialogSession* aSession, TInt aPriority)
       
  1111 /**
       
  1112 Authentication Dialog.
       
  1113 
       
  1114 @param aSession pointer to NetDialDialogSession.
       
  1115 @param aPriority Priority.
       
  1116 @return Pointer to CLogin object.
       
  1117 */
       
  1118 	{
       
  1119 	CAuthenticate* authenticate=new(ELeave) CAuthenticate(aSession,aPriority);
       
  1120 	CleanupStack::PushL(authenticate);
       
  1121 	authenticate->ConstructL();
       
  1122 	CleanupStack::Pop();
       
  1123 	return authenticate;
       
  1124 	}
       
  1125 
       
  1126 CAuthenticate::CAuthenticate(CNetDialDialogSession* aSession, TInt aPriority)
       
  1127 	: CDialogBase(aSession, aPriority)
       
  1128 /**
       
  1129 Constructor.
       
  1130 */
       
  1131 	{
       
  1132 	CActiveScheduler::Add(this);
       
  1133 	}
       
  1134 
       
  1135 CAuthenticate::~CAuthenticate()
       
  1136 /**
       
  1137 Destructor.
       
  1138 */
       
  1139 	{
       
  1140 	Cancel();
       
  1141 	}
       
  1142 
       
  1143 void CAuthenticate::GetUserPassL(TDes& aUsername, TDes& aPassword, TCallBack aCallBack)
       
  1144 /**
       
  1145 Get the User Name and Password.
       
  1146 
       
  1147 @param aUsername Username.
       
  1148 @param aPassword Password.
       
  1149 @param aCallBack Constructs the callback object with the specified callback function.
       
  1150 */
       
  1151 	{
       
  1152 	iCancelFlag=EFalse;
       
  1153 	iCallBack=new(ELeave) CAsyncCallBack(aCallBack,0);
       
  1154 	iUsername=&aUsername;
       
  1155 	iPassword=&aPassword;
       
  1156 	StartGetUsername();
       
  1157 	}
       
  1158 
       
  1159 void CAuthenticate::StartGetUsername()
       
  1160 	{
       
  1161 	_LIT(KAuthUsernamePrompt,"Select Authentication Username");
       
  1162 	iAgentDialogInput.iTitle.Copy(KAuthUsernamePrompt);
       
  1163 	iAgentDialogInput.iLabel.Copy(*iUsername);
       
  1164 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1165 	StartNotifierAndGetResponse();
       
  1166 	iState = EEnterName;
       
  1167 	}
       
  1168 
       
  1169 void CAuthenticate::StartGetPassword()
       
  1170 	{
       
  1171 	_LIT(KAuthPasswordPrompt,"Select Authentication Password");
       
  1172 	iAgentDialogInput.iTitle.Copy(KAuthPasswordPrompt);
       
  1173 	iAgentDialogInput.iLabel.Copy(*iPassword);
       
  1174 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1175 	StartNotifierAndGetResponse();
       
  1176 	iState = EEnterPass;
       
  1177 	}
       
  1178 
       
  1179 void CAuthenticate::RunL()
       
  1180 /**
       
  1181 Handles an active object’s request completion event.
       
  1182 */
       
  1183 	{
       
  1184 	if (iStatus.Int() < KErrNone)
       
  1185 		{
       
  1186 		iResultStatus=iStatus.Int();
       
  1187 		if((iResultStatus==KErrNone)&&(iCancelFlag))
       
  1188 			{
       
  1189 			iResultStatus=KErrCancel;
       
  1190 			}
       
  1191 		iCallBack->Call();
       
  1192 		return;
       
  1193 		}
       
  1194 
       
  1195 	if (iStatus.Int() == EAgentNoPressed)
       
  1196 		{
       
  1197 		iResultStatus=EAgentNoPressed;
       
  1198 		iCallBack->Call();
       
  1199 		return;
       
  1200 		}
       
  1201 
       
  1202 	switch(iState)
       
  1203 		{
       
  1204 	case EEnterName:
       
  1205 		if(iStatus.Int() == EAgentYesPressed)	//Yes PRessed
       
  1206 			{
       
  1207 			StartGetPassword();
       
  1208 			}
       
  1209 		else
       
  1210 			{
       
  1211 			for(TInt i=0;i<iUsername->Length();i++)
       
  1212 				{
       
  1213 				TChar aChar=(TChar)(++(*iUsername)[i]);
       
  1214 				if(!aChar.IsAlphaDigit())
       
  1215 					{
       
  1216 					(*iUsername)[i]=ND_DLDSL::KFullStop;
       
  1217 					}
       
  1218 				}
       
  1219 			StartGetUsername();
       
  1220 			}
       
  1221 		break;
       
  1222 
       
  1223 	case EEnterPass:
       
  1224 		if(iStatus.Int() == EAgentYesPressed)	//Yes PRessed
       
  1225 			{
       
  1226 			iResultStatus=KErrNone;
       
  1227 			iCallBack->Call();
       
  1228 			}
       
  1229 		else
       
  1230 			{
       
  1231 			for(TInt i=0;i<iPassword->Length();i++)
       
  1232 				{
       
  1233 				TChar aChar=(TChar)(++(*iPassword)[i]);
       
  1234 				if(!aChar.IsAlphaDigit())
       
  1235 					{
       
  1236 					(*iPassword)[i]=ND_DLDSL::KFullStop;
       
  1237 					}
       
  1238 				}
       
  1239 			StartGetPassword();
       
  1240 			}
       
  1241 		break;
       
  1242 		
       
  1243 	default:
       
  1244 		User::Leave(KErrNotFound);
       
  1245 		break;
       
  1246 		}
       
  1247 	}
       
  1248 
       
  1249 TInt CAuthenticate::Status()
       
  1250 /**
       
  1251 Gets the Status.
       
  1252 
       
  1253 @return the status.
       
  1254 */
       
  1255 	{
       
  1256 	return iResultStatus;
       
  1257 	}
       
  1258 
       
  1259 
       
  1260 CReconnect* CReconnect::NewL(CNetDialDialogSession* aSession, TInt aPriority)
       
  1261 /**
       
  1262 Reconnection Dialog
       
  1263 
       
  1264 @param aSession pointer to NetDialDialogSession.
       
  1265 @param aPriority Priority.
       
  1266 @return Pointer to CReconnect object.
       
  1267 */
       
  1268 	{
       
  1269 	CReconnect* reconnect=new(ELeave) CReconnect(aSession,aPriority);
       
  1270 	CleanupStack::PushL(reconnect);
       
  1271 	reconnect->ConstructL();
       
  1272 	CleanupStack::Pop();
       
  1273 	return reconnect;
       
  1274 	}
       
  1275 
       
  1276 CReconnect::CReconnect(CNetDialDialogSession* aSession, TInt aPriority)
       
  1277 	: CDialogBase(aSession, aPriority)
       
  1278 /**
       
  1279 Constructor.
       
  1280 */
       
  1281 	{
       
  1282 	CActiveScheduler::Add(this);
       
  1283 	}
       
  1284 
       
  1285 CReconnect::~CReconnect()
       
  1286 /**
       
  1287 Destructor.
       
  1288 */
       
  1289 	{
       
  1290 	Cancel();
       
  1291 	}
       
  1292 
       
  1293 void CReconnect::ReconnectL(TCallBack aCallBack)
       
  1294 /**
       
  1295 Shows a reconnect dialog when connection has been broken during data transfer.
       
  1296 
       
  1297 @param aCallBack Encapsulates a general call-back function.
       
  1298 */
       
  1299 	{
       
  1300 	iCancelFlag=EFalse;
       
  1301 	iCallBack=new(ELeave) CAsyncCallBack(aCallBack,CActive::EPriorityStandard);
       
  1302 	_LIT(KReconnectTitle,"Reconnect Dialog");
       
  1303 	iAgentDialogInput.iTitle.Copy(KReconnectTitle);
       
  1304 	_LIT(KReconnectPrompt,"Reconnect? ");
       
  1305 	iAgentDialogInput.iLabel.Copy(KReconnectPrompt);
       
  1306 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1307 	StartNotifierAndGetResponse();
       
  1308 	}
       
  1309 
       
  1310 void CReconnect::RunL()
       
  1311 /**
       
  1312 Handles an active object’s request completion event.
       
  1313 */
       
  1314 	{
       
  1315 	if (iStatus>=KErrNone)
       
  1316 		{
       
  1317 		if(iStatus.Int() == EAgentYesPressed)
       
  1318 			{
       
  1319 			iResultStatus=ETrue;
       
  1320 			}
       
  1321 		else
       
  1322 			{
       
  1323 			iResultStatus=EFalse;
       
  1324 			}
       
  1325 		if(iCancelFlag)
       
  1326 			{
       
  1327 			iResultStatus=EFalse;
       
  1328 			}
       
  1329 		iCallBack->Call();
       
  1330 		return;
       
  1331 		}
       
  1332 	iResultStatus=EFalse;
       
  1333 	iCallBack->Call();
       
  1334 	}
       
  1335 
       
  1336 TBool CReconnect::Status()
       
  1337 /**
       
  1338 Gets the Status
       
  1339 
       
  1340 @return the status.
       
  1341 */
       
  1342 	{
       
  1343 	return iResultStatus;
       
  1344 	}
       
  1345 
       
  1346 void CReconnect::DoCancel()
       
  1347 /**
       
  1348 Implements cancellation of an outstanding request 
       
  1349 */
       
  1350 	{
       
  1351 	CancelNotifier();
       
  1352 	
       
  1353 	iResultStatus = EFalse; // choose "no"
       
  1354 	// need to call this so that the previous reconnect request is completed (otherwise the cancellation can block forever)
       
  1355 	iCallBack->Call();
       
  1356 	}
       
  1357 
       
  1358 CPct* CPct::NewL(CNetDialDialogSession* aSession, TInt aPriority)
       
  1359 /**
       
  1360 CPct definitions
       
  1361 
       
  1362 @param aSession pointer to NetDialDialogSession.
       
  1363 @param aPriority Priority.
       
  1364 @return Pointer to CPct object.
       
  1365 */ 
       
  1366 	{
       
  1367 	CPct* r=new(ELeave) CPct(aSession,aPriority);
       
  1368 	CleanupStack::PushL(r);
       
  1369 	r->ConstructL();
       
  1370 	CleanupStack::Pop();
       
  1371 	return r;
       
  1372 	}
       
  1373 
       
  1374 CPct::CPct(CNetDialDialogSession* aSession, TInt aPriority)
       
  1375 	: CDialogBase(aSession, aPriority),
       
  1376 	iState(ENone),
       
  1377 	iDestroyCallBack(EPriorityStandard)
       
  1378 /**
       
  1379 Constructor
       
  1380 */
       
  1381 	{
       
  1382 	CActiveScheduler::Add(this);
       
  1383 	}	
       
  1384 
       
  1385 void CPct::ConstructL()
       
  1386 /**
       
  1387 Create a new CPct object.
       
  1388 */
       
  1389 	{
       
  1390 	iTimer=CPctTimer::NewL(this);
       
  1391 	iStartBuffer=0;
       
  1392 	CDialogBase::ConstructL();
       
  1393 	}
       
  1394 
       
  1395 CPct::~CPct()
       
  1396 /**
       
  1397 Destructor
       
  1398 */
       
  1399 	{
       
  1400 	Cancel();
       
  1401 	delete iTimer;
       
  1402 	}
       
  1403 
       
  1404 void CPct::WritePct(TDes& aBuffer)
       
  1405 	{
       
  1406 	if (iState==ERead)
       
  1407 		return;
       
  1408 	
       
  1409 	iCancelFlag=EFalse;
       
  1410 	iWriteBuffer.Copy(aBuffer);
       
  1411 
       
  1412 	for(TInt i=0;i<iWriteBuffer.Length();i++)
       
  1413 		{
       
  1414 		if (iWriteBuffer[i]==KCarriageReturn || iWriteBuffer[i]==KLineFeed)
       
  1415 			iWriteBuffer[i]=ND_DLDSL::KFullStop;
       
  1416 		}
       
  1417 
       
  1418 	if (iState==EWrite)
       
  1419 		{
       
  1420 		__ASSERT_DEBUG(iTimer!=NULL, User::Invariant());
       
  1421 		iTimer->Cancel();
       
  1422 		}
       
  1423 
       
  1424 	DoWrite();
       
  1425 	}
       
  1426 
       
  1427 void CPct::DoWrite()
       
  1428 	{
       
  1429 	__ASSERT_DEBUG(iTimer!=NULL, User::Invariant());
       
  1430 	__ASSERT_DEBUG(iNotifier!=NULL, User::Invariant());
       
  1431 
       
  1432 	if (iStartBuffer<(iWriteBuffer.Length()-ND_DLDSL::KNotifierLength))
       
  1433 		{
       
  1434 		iNotifier->InfoPrint(iWriteBuffer.Mid(iStartBuffer,ND_DLDSL::KNotifierLength));
       
  1435 		iStartBuffer+=4;
       
  1436 		iTimer->Start();
       
  1437 		iState=EWrite;
       
  1438 		}
       
  1439 	else
       
  1440 		iState=ENone;
       
  1441 	}
       
  1442 	
       
  1443 void CPct::PctTimerComplete(TInt /*aStatus*/)
       
  1444 	{
       
  1445 	DoWrite();
       
  1446 	}
       
  1447 
       
  1448 void CPct::ReadPctL(TDes& aBuffer,TCallBack& aCallBack)
       
  1449 	{
       
  1450 	if (iTimer!=NULL)
       
  1451 		iTimer->Cancel();
       
  1452 	
       
  1453 	iCancelFlag=EFalse;
       
  1454 	delete iCallBack;
       
  1455 	iCallBack=new(ELeave) CAsyncCallBack(aCallBack,0);
       
  1456 	iReadBuffer=&aBuffer;
       
  1457 	StartRead();
       
  1458 	}
       
  1459 
       
  1460 void CPct::StartRead()
       
  1461 	{
       
  1462 	__ASSERT_DEBUG(iNotifier!=NULL, User::Invariant());
       
  1463 
       
  1464 	iAgentDialogInput.iTitle.Copy(iWriteBuffer.Right(Min(ND_DLDSL::KNotifierLength,iWriteBuffer.Length())));
       
  1465 	iAgentDialogInput.iLabel.Copy(*iReadBuffer);
       
  1466 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1467 	StartNotifierAndGetResponse();
       
  1468 	iState=ERead;	
       
  1469 	}
       
  1470 
       
  1471 void CPct::DestroyPctNotificationL(TCallBack& aCallBack)
       
  1472 	{
       
  1473 	__ASSERT_DEBUG(!iDestroyCallBackOutstanding, User::Invariant());
       
  1474 
       
  1475 	iDestroyCallBackOutstanding = ETrue;
       
  1476 	iDestroyCallBack.Set(aCallBack);
       
  1477 	}
       
  1478 
       
  1479 void CPct::ClosePct()
       
  1480 /**
       
  1481 Close the Pct dialog.
       
  1482 */
       
  1483 	{
       
  1484 	__ASSERT_DEBUG(!iDestroyCallBackOutstanding, User::Invariant());
       
  1485 
       
  1486 	DoTimerCancel();
       
  1487 	}	
       
  1488 	
       
  1489 TInt CPct::Status()
       
  1490 /**
       
  1491 Gets the Status
       
  1492 
       
  1493 @return the status.
       
  1494 */
       
  1495 	{
       
  1496 	return iResultStatus;
       
  1497 	}
       
  1498 
       
  1499 void CPct::DoReadCancel()
       
  1500 /**
       
  1501 Cancels read only.  Does not cancel destroy notification
       
  1502 */
       
  1503 	{
       
  1504 	iCancelFlag=ETrue;		
       
  1505 	}
       
  1506 
       
  1507 void CPct::DoTimerCancel()
       
  1508 /**
       
  1509 Cancels timer only.  This is not a real cancel as the timer is just so that you can see the
       
  1510 writes all the time.
       
  1511 */
       
  1512 	{
       
  1513 	if (iTimer!=NULL)
       
  1514 		{
       
  1515 		iTimer->Cancel();
       
  1516 		delete iTimer;
       
  1517 		iTimer=NULL;
       
  1518 		}	
       
  1519 	}
       
  1520 
       
  1521 void CPct::DoNotificationCancel()
       
  1522 /**
       
  1523 Cancel Notification only.
       
  1524 */
       
  1525 	{
       
  1526 	if (iDestroyCallBackOutstanding)
       
  1527 		{
       
  1528 		iResultStatus = KErrCancel;
       
  1529 		iDestroyCallBack.Call();
       
  1530 		iDestroyCallBackOutstanding = EFalse;
       
  1531 		}
       
  1532 	}
       
  1533 
       
  1534 void CPct::DoCancel()
       
  1535 /**
       
  1536 Implements cancellation of an outstanding request 
       
  1537 */
       
  1538 	{
       
  1539 	DoReadCancel();
       
  1540 	DoTimerCancel();
       
  1541 	DoNotificationCancel();
       
  1542 	}
       
  1543 
       
  1544 void CPct::RunL()
       
  1545 /**
       
  1546 Handles an active object’s request completion event.
       
  1547 */
       
  1548 	{
       
  1549 	if (iState!=ERead)
       
  1550 		User::Leave(KErrNotFound);
       
  1551 
       
  1552 	if (iCancelFlag)
       
  1553 		{
       
  1554 		iResultStatus=KErrCancel;
       
  1555 		iCallBack->Call();
       
  1556 		iState=ENone;
       
  1557 		return;
       
  1558 		}
       
  1559 	
       
  1560 	if (iStatus.Int() < KErrNone)
       
  1561 		{
       
  1562 		
       
  1563 		iResultStatus=iStatus.Int();
       
  1564 		iCallBack->Call();
       
  1565 		iState=ENone;
       
  1566 		return;
       
  1567 		}
       
  1568 
       
  1569 	if(iStatus.Int() == EAgentYesPressed)
       
  1570 		{
       
  1571 		iResultStatus=KErrNone;
       
  1572 		iCallBack->Call();
       
  1573 		iState=EWrite;
       
  1574 		WritePct(iWriteBuffer);
       
  1575 		}
       
  1576 	else
       
  1577 		{
       
  1578 		for(TInt i=0;i<iReadBuffer->Length();i++)
       
  1579 			{
       
  1580 			TChar ch=(TChar)(++(*iReadBuffer)[i]);
       
  1581 			if(!ch.IsAlphaDigit())
       
  1582 				(*iReadBuffer)[i]=ND_DLDSL::KFullStop;
       
  1583 			}
       
  1584 		StartRead();
       
  1585 		}
       
  1586 	}
       
  1587 
       
  1588 CPctTimer* CPctTimer::NewL(CPct* aNotifier)
       
  1589 /**
       
  1590 CPctTimer Definition. Create a new CPctTimer object.
       
  1591 
       
  1592 @return A Pointer to CPctTimer object.
       
  1593 */
       
  1594 	{
       
  1595 	CPctTimer* r=new(ELeave) CPctTimer(aNotifier);
       
  1596 	CleanupStack::PushL(r);
       
  1597 	r->ConstructL();
       
  1598 	CleanupStack::Pop();
       
  1599 	return r;
       
  1600 	}
       
  1601 
       
  1602 CPctTimer::CPctTimer(CPct* aNotifier) 
       
  1603 	: CTimer(0),
       
  1604 	iNotifier(aNotifier)
       
  1605 /**
       
  1606 Constructor.
       
  1607 */
       
  1608 	{
       
  1609 	CActiveScheduler::Add(this);
       
  1610 	}
       
  1611 
       
  1612 CPctTimer::~CPctTimer()
       
  1613 /**
       
  1614 Destructor.
       
  1615 */
       
  1616 	{
       
  1617 	Cancel();
       
  1618 	}
       
  1619 
       
  1620 void CPctTimer::Start()
       
  1621 /**
       
  1622 Start the Pct Timer.
       
  1623 */
       
  1624 	{
       
  1625 	After(ND_DLDSL::KTimeInterval);
       
  1626 	}
       
  1627 
       
  1628 void CPctTimer::RunL()
       
  1629 /**
       
  1630 Handles an active object’s request completion event.
       
  1631 */
       
  1632 	{
       
  1633 	iNotifier->PctTimerComplete(iStatus.Int());
       
  1634 	}
       
  1635 
       
  1636 CQoSWarning* CQoSWarning::NewL(CNetDialDialogSession* aSession, TInt aPriority)
       
  1637 /**
       
  1638 QoS Warning.
       
  1639 
       
  1640 @param aSession pointer to NetDialDialogSession.
       
  1641 @param aPriority Priority.
       
  1642 @return Pointer to CQoSWarning object.
       
  1643 */
       
  1644 	{
       
  1645 	CQoSWarning* r=new(ELeave) CQoSWarning(aSession,aPriority);
       
  1646 	CleanupStack::PushL(r);
       
  1647 	r->ConstructL();
       
  1648 	CleanupStack::Pop();
       
  1649 	return r;
       
  1650 	}
       
  1651 
       
  1652 CQoSWarning::CQoSWarning(CNetDialDialogSession* aSession, TInt aPriority)
       
  1653 	: CDialogBase(aSession, aPriority)
       
  1654 /**
       
  1655 Constructor.
       
  1656 */
       
  1657 	{}
       
  1658 
       
  1659 void CQoSWarning::ConstructL()
       
  1660 /**
       
  1661 Create a new CPctTimer object.
       
  1662 */
       
  1663 	{
       
  1664 	CDialogBase::ConstructL();
       
  1665 	CActiveScheduler::Add(this);
       
  1666 	}
       
  1667 
       
  1668 CQoSWarning::~CQoSWarning()
       
  1669 /**
       
  1670 Destructor.
       
  1671 */
       
  1672 	{
       
  1673 	Cancel();
       
  1674 	}
       
  1675 
       
  1676 void CQoSWarning::WarnQoSL(TBool& aResponse, TCallBack aCallBack)
       
  1677 /**
       
  1678 Warn QoS
       
  1679 
       
  1680 @param aResponse Specifies whether to proceed with the connection or stop the connection attempt.
       
  1681 @param aCallBack Encapsulates a general call-back function.
       
  1682 */
       
  1683 	{
       
  1684 	iCancelFlag = EFalse;
       
  1685 	iCallBack = new(ELeave) CAsyncCallBack(aCallBack,CActive::EPriorityStandard);
       
  1686 	iResponse = &aResponse;
       
  1687 
       
  1688 	iAgentDialogInput.iTitle.Copy(KQoSWarnTitle);
       
  1689 	iAgentDialogInput.iLabel.Copy(KQoSWarnPrompt);
       
  1690 	iAgentDialogInput.iDialog = ENoYesDialog;
       
  1691 	StartNotifierAndGetResponse();
       
  1692 	}
       
  1693 
       
  1694 void CQoSWarning::RunL()
       
  1695 /**
       
  1696 Handles an active object’s request completion event.
       
  1697 */
       
  1698 	{
       
  1699 	iResultStatus = iStatus.Int();
       
  1700 	*iResponse = (iStatus.Int() == EAgentYesPressed);
       
  1701 
       
  1702 	if(iResultStatus == KErrNone && iCancelFlag)
       
  1703 		iResultStatus = KErrCancel;
       
  1704 
       
  1705 	if (iResultStatus > KErrNone)
       
  1706 		iResultStatus = KErrNone;
       
  1707 
       
  1708 	iCallBack->Call();	
       
  1709 	}
       
  1710 
       
  1711 TInt CQoSWarning::Status()
       
  1712 /**
       
  1713 Gets the Status.
       
  1714 
       
  1715 @return the status.
       
  1716 */
       
  1717 	{
       
  1718 	return iResultStatus;
       
  1719 	}