locationrequestmgmt/networkrequesthandler/src/EPos_CPosDialogCtrl.cpp
changeset 0 9cfd9a3ee49c
child 18 54d74d217042
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2005-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 
       
    18 // INCLUDE FILES
       
    19 #include <s32mem.h>
       
    20 #include <lbs/epos_privacy.h>
       
    21 #include <lbs/epos_cposcontactrequestor.h>
       
    22 #include <lbs/epos_cposservicerequestor.h>
       
    23 #include <lbs/epos_rposrequestorstack.h>
       
    24 #include <lbs/epos_privacynotifier.hrh>
       
    25 #include "EPos_CPosDialogCtrl.h"
       
    26 #include <lbs/lbslocclasstypes.h>
       
    27 
       
    28 // CONSTANTS
       
    29 #if defined(NRH_UNIT_TEST)
       
    30 // For the NRH unit test, use a different Q&N notifier implementation UID.
       
    31 // This is so that we can have both the unit test Q&N notifier and
       
    32 // the integration test Q&N notifier (with the real implementation UID)
       
    33 // in the same ROM.
       
    34 const TUid KNotifierUid = { 0x10283744 };
       
    35 #else
       
    36 const TUid KNotifierUid = { KPosPrivacyNotifierImplUid };
       
    37 #endif // NRH_UNIT_TEST
       
    38 
       
    39 // The output descriptor for Notifier calls. Since we want to pass
       
    40 // just a dummy null descriptor there is no need to create a HBufC
       
    41 // each time.
       
    42 TPtr8 nullPtr(reinterpret_cast<TUint8*>(NULL), 0);
       
    43 
       
    44 
       
    45 // ================= MEMBER FUNCTIONS =======================
       
    46 
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 //
       
    50 CPosDialogCtrl::CPosDialogCtrl() : CActive(EPriorityNormal),
       
    51     iRequestQueue(1) // Set granularity to 1
       
    52     {
       
    53     CActiveScheduler::Add(this);
       
    54     }
       
    55 
       
    56 // EPOC default constructor can leave.
       
    57 void CPosDialogCtrl::ConstructL()
       
    58     {
       
    59     TInt err = iNotifier.Connect();
       
    60     User::LeaveIfError(err);
       
    61     }
       
    62 
       
    63 // Two-phased constructor.
       
    64 CPosDialogCtrl* CPosDialogCtrl::InstanceL()
       
    65     {
       
    66     CPosDialogCtrl* self = new (ELeave) CPosDialogCtrl;
       
    67     CleanupStack::PushL(self);
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop(self);
       
    70     return self;
       
    71     }
       
    72 
       
    73 // Destructor
       
    74 CPosDialogCtrl::~CPosDialogCtrl()
       
    75     {
       
    76     Cancel();
       
    77     TInt count = iRequestQueue.Count();
       
    78     for (TInt i = 0; i < count; i++)
       
    79         {
       
    80         DoCompleteRequest(0, KErrServerTerminated);
       
    81         }
       
    82 
       
    83     iNotifier.Close();
       
    84     iRequestQueue.Close();
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // CPosDialogCtrl::NotifyL
       
    89 //
       
    90 // (other items were commented in a header).
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 void CPosDialogCtrl::NotifyL(
       
    94 	TLbsExternalRequestInfo& aRequestInfo,
       
    95     const TPosRequestData& aRequestData)
       
    96     {
       
    97     TRequest request;
       
    98     request.iType = TPosQNInputData::ENotification;
       
    99     request.iRequestInfo = &aRequestInfo;
       
   100     request.iStatus = NULL;
       
   101     request.iRequestSource = aRequestData.iRequestSource;
       
   102     request.iTimeoutStrategy = aRequestData.iTimeoutStrategy;
       
   103     request.iRequestDecision = aRequestData.iRequestDecision;
       
   104     request.iCancelReason = aRequestData.iCancelReason;
       
   105     request.iNotificationReason = aRequestData.iNotificationReason;
       
   106 
       
   107     ScheduleRequestL(request);
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------
       
   111 // CPosDialogCtrl::VerifyL
       
   112 //
       
   113 // (other items were commented in a header).
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 void CPosDialogCtrl::VerifyL(
       
   117     TRequestStatus& aStatus,
       
   118 	TLbsExternalRequestInfo& aRequestInfo,
       
   119     const TPosRequestData& aRequestData)
       
   120     {
       
   121     aStatus = KRequestPending;
       
   122 
       
   123     TRequest request;
       
   124     request.iType = TPosQNInputData::EQuery;
       
   125     request.iRequestInfo = &aRequestInfo;
       
   126     request.iStatus = &aStatus;
       
   127     request.iRequestSource = aRequestData.iRequestSource;
       
   128     request.iTimeoutStrategy = aRequestData.iTimeoutStrategy;
       
   129     request.iRequestDecision = aRequestData.iRequestDecision;
       
   130     request.iCancelReason = aRequestData.iCancelReason;
       
   131     request.iNotificationReason = aRequestData.iNotificationReason;
       
   132 
       
   133     GivePriorityToVerificationL(request);
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CPosDialogCtrl::CancelLaunch
       
   138 //
       
   139 // (other items were commented in a header).
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CPosDialogCtrl::CancelLaunch(TRequestStatus& aStatus)
       
   143     {
       
   144     TInt count = iRequestQueue.Count();
       
   145 
       
   146     if (count > 0 && iRequestQueue[0].iStatus == &aStatus)
       
   147         {
       
   148         Cancel();
       
   149         DoCompleteRequest(0, KErrCancel);
       
   150         NextRequest();
       
   151         }
       
   152     else
       
   153         {
       
   154         for (TInt i = 1; i < count; ++i)
       
   155             {
       
   156             if (iRequestQueue[i].iStatus == &aStatus)
       
   157                 {
       
   158                 DoCompleteRequest(i, KErrCancel);
       
   159                 return;
       
   160                 }
       
   161             }
       
   162         }
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------
       
   166 // CPosDialogCtrl::CancelLaunch
       
   167 //
       
   168 // (other items were commented in a header).
       
   169 // ---------------------------------------------------------
       
   170 //
       
   171 void CPosDialogCtrl::CancelLaunch(
       
   172     TRequestStatus& aStatus,
       
   173     TInt& aErrorCode,
       
   174     TInt& aResponse,
       
   175     TBool& aRequestQueued,
       
   176     TPosVerifyCancelReason aCancelReason)
       
   177     {
       
   178     TInt count = iRequestQueue.Count();
       
   179 
       
   180     if (count > 0 && iRequestQueue[0].iStatus == &aStatus)
       
   181         {
       
   182         TPtr8 nullPtr(reinterpret_cast<TUint8*>(NULL), 0);
       
   183         TPosQNInputData data;
       
   184         data.iId = iRequestQueue[0].iId;
       
   185         data.iCancelReason = aCancelReason;
       
   186 
       
   187         TPckg<TPosQNInputData> dataPtr(data);
       
   188 
       
   189         aErrorCode = iNotifier.UpdateNotifier(KNotifierUid, dataPtr, nullPtr);
       
   190         if( KErrNone==aErrorCode  /* && iRequestQueue[0].iTimeoutStrategy == EPosDecisionAccepted  */)  
       
   191 	        {
       
   192 	        // If there is an error, notifications will be triggered through PrivManager
       
   193 	        TRAPD(err,CreateNotificationAndEnqueueL());
       
   194 	        err = err; // To avoid compiler warning
       
   195 	        }
       
   196         aResponse = iStatus.Int();
       
   197         aRequestQueued = EFalse;
       
   198         }
       
   199     else
       
   200         {
       
   201         aResponse = KErrNone;
       
   202         aErrorCode = KErrNone;
       
   203         aRequestQueued = ETrue;
       
   204         }
       
   205     CancelLaunch(aStatus);
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------
       
   209 // CPosDialogCtrl::RunL
       
   210 //
       
   211 // (other items were commented in a header).
       
   212 // ---------------------------------------------------------
       
   213 //
       
   214 void CPosDialogCtrl::RunL()
       
   215     {
       
   216     if (iRequestQueue.Count() > 0)
       
   217         {
       
   218         DoCompleteRequest(0, iStatus.Int());
       
   219         NextRequest();
       
   220         }
       
   221     }
       
   222 
       
   223 // ---------------------------------------------------------
       
   224 // CPosDialogCtrl::DoCancel
       
   225 //
       
   226 // (other items were commented in a header).
       
   227 // ---------------------------------------------------------
       
   228 //
       
   229 void CPosDialogCtrl::DoCancel()
       
   230     {
       
   231     if (iStatus == KRequestPending)
       
   232         {
       
   233         iNotifier.CancelNotifier(KNotifierUid);
       
   234         }
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------
       
   238 // CPosDialogCtrl::DialogActive
       
   239 //
       
   240 // (other items were commented in a header).
       
   241 // ---------------------------------------------------------
       
   242 //
       
   243 TBool CPosDialogCtrl::DialogActive() const
       
   244     {
       
   245     return iRequestQueue.Count() > 0;
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------
       
   249 // CPosDialogCtrl::NextRequest
       
   250 //
       
   251 // (other items were commented in a header).
       
   252 // ---------------------------------------------------------
       
   253 //
       
   254 void CPosDialogCtrl::NextRequest()
       
   255     {
       
   256     while (iRequestQueue.Count() > 0)
       
   257         {
       
   258         TInt err = StartNotifierRequest();
       
   259         if (err)
       
   260             {
       
   261             DoCompleteRequest(0, err);
       
   262             }
       
   263         else
       
   264             {
       
   265             return;
       
   266             }
       
   267         }
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // CPosDialogCtrl::DoCompleteRequest
       
   272 //
       
   273 // (other items were commented in a header).
       
   274 // ---------------------------------------------------------
       
   275 //
       
   276 void CPosDialogCtrl::DoCompleteRequest(
       
   277     TInt aIndex,
       
   278     TInt aCompletionCode)
       
   279     {
       
   280     TRequest request = iRequestQueue[aIndex];
       
   281     if (request.iType == TPosQNInputData::ENotification)
       
   282         {
       
   283         delete request.iRequestInfo;
       
   284         }
       
   285     else
       
   286         {
       
   287         TRequestStatus* status = request.iStatus;
       
   288         User::RequestComplete(status, aCompletionCode);
       
   289         }
       
   290     iRequestQueue.Remove(aIndex);
       
   291     iRequestQueue.Compress();
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------
       
   295 // CPosDialogCtrl::ScheduleRequestL
       
   296 //
       
   297 // (other items were commented in a header).
       
   298 // ---------------------------------------------------------
       
   299 //
       
   300 void CPosDialogCtrl::ScheduleRequestL(TRequest& aRequest)
       
   301     {
       
   302     // Start a new request.    
       
   303     aRequest.iId = ++iRequestId;
       
   304     User::LeaveIfError(iRequestQueue.Append(aRequest));
       
   305 
       
   306     if (iRequestQueue.Count() == 1)
       
   307         {
       
   308         TInt err = StartNotifierRequest();
       
   309 
       
   310         if (err != KErrNone)
       
   311             {
       
   312             DoCompleteRequest(0, err);
       
   313             }
       
   314         }
       
   315     }
       
   316 
       
   317 // ---------------------------------------------------------
       
   318 // CPosDialogCtrl::StartNotifierRequest
       
   319 //
       
   320 // (other items were commented in a header).
       
   321 // ---------------------------------------------------------
       
   322 //
       
   323 TInt CPosDialogCtrl::StartNotifierRequest()
       
   324     {
       
   325     TRequest request = iRequestQueue[0];
       
   326     
       
   327     // Convert the TLbsExternalRequestInfo into a CPosRequestorStack
       
   328     RPosRequestorStack reqStack;
       
   329     TRAPD(err, ExtractRequestorsL(*request.iRequestInfo, reqStack));
       
   330     if (err != KErrNone)
       
   331     	{
       
   332     	return err;
       
   333     	}
       
   334     TInt dataSize = CalcSize(reqStack);
       
   335 
       
   336     HBufC8* reqStackBuf = HBufC8::New(dataSize);
       
   337     if (!reqStackBuf)
       
   338         {
       
   339         reqStack.ResetAndDestroy();
       
   340         return KErrNoMemory;
       
   341         }
       
   342 
       
   343     TPtr8 ptr = reqStackBuf->Des();
       
   344     TRAP(err, CreateSerializedStackL(ptr, reqStack));
       
   345     if (err == KErrNone)
       
   346         {
       
   347         TPosQNInputData data;
       
   348         data.iId = request.iId;
       
   349         data.iType = request.iType;
       
   350         data.iDataSize = dataSize;
       
   351         data.iDataPtr = NULL;
       
   352         data.iRequestSource = request.iRequestSource;
       
   353         data.iTimeoutStrategy = request.iTimeoutStrategy;
       
   354         data.iRequestDecision = request.iRequestDecision;
       
   355         data.iNotificationReason = request.iNotificationReason;
       
   356         data.iCancelReason = request.iCancelReason;
       
   357 
       
   358         TPckg<TPosQNInputData> dataPtr(data);
       
   359 
       
   360         HBufC8* buffer = HBufC8::New(KPosQNInputDataClassSize +
       
   361             reqStackBuf->Size());
       
   362         if (!buffer)
       
   363             {
       
   364             delete reqStackBuf;
       
   365             return KErrNoMemory;
       
   366             }
       
   367 
       
   368         buffer->Des().Append(dataPtr);
       
   369         buffer->Des().Append(*reqStackBuf);
       
   370 
       
   371         delete reqStackBuf;
       
   372         reqStackBuf = NULL;
       
   373 
       
   374         iNotifier.StartNotifierAndGetResponse(
       
   375             iStatus, KNotifierUid, nullPtr, nullPtr);
       
   376         SetActive();
       
   377 
       
   378         err = iNotifier.UpdateNotifier(KNotifierUid, *buffer, nullPtr);
       
   379         if (err != KErrNone)
       
   380             {
       
   381             Cancel();
       
   382             }
       
   383         delete buffer;
       
   384         }
       
   385 
       
   386     delete reqStackBuf;
       
   387     reqStack.ResetAndDestroy();
       
   388     return err;
       
   389     }
       
   390 
       
   391 // ---------------------------------------------------------
       
   392 // CPosDialogCtrl::CreateSerializedStackL
       
   393 //
       
   394 // (other items were commented in a header).
       
   395 // ---------------------------------------------------------
       
   396 //
       
   397 void CPosDialogCtrl::CreateSerializedStackL(
       
   398     TDes8& aBuffer,
       
   399     const RPosRequestorStack& aRequestStack)
       
   400     {
       
   401     RDesWriteStream writeStream(aBuffer);
       
   402     CleanupClosePushL(writeStream);
       
   403     aRequestStack.ExternalizeL(writeStream);
       
   404     writeStream.CommitL();
       
   405     CleanupStack::PopAndDestroy(1, &writeStream);
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------
       
   409 // CPosDialogCtrl::CalcSize
       
   410 //
       
   411 // (other items were commented in a header).
       
   412 // ---------------------------------------------------------
       
   413 //
       
   414 TInt CPosDialogCtrl::CalcSize(
       
   415     const RPosRequestorStack& aRequestStack)
       
   416     {
       
   417     TInt size = sizeof(TInt);	// One TInt for number of requestors.
       
   418     const TInt numRequestors = aRequestStack.Count();
       
   419     for (TInt i = 0; i < numRequestors; i++)
       
   420     	{
       
   421     	const CPosRequestor* requestor = aRequestStack[i];
       
   422     	
       
   423     	// Add on the size of the requestor class, the 
       
   424     	// descriptor it contains, and an extra TInt which
       
   425     	// is used to store the length of the descriptor.
       
   426     	size += sizeof(CPosRequestor);
       
   427     	size += sizeof(TInt);
       
   428     	size += requestor->RequestorIdString().Size();
       
   429     	}
       
   430 
       
   431     return size;
       
   432     }
       
   433 
       
   434 /** Convert a TLbsExternalRequestInfo into a RPosRequestorStack.
       
   435  */
       
   436 void CPosDialogCtrl::ExtractRequestorsL(
       
   437  		const TLbsExternalRequestInfo& aRequestInfo,
       
   438      	RPosRequestorStack& aRequestors)
       
   439  	{	
       
   440  	// Convert the Client name into a CPosRequestor::ERequestorService requestor.
       
   441  	switch (aRequestInfo.ClassType())
       
   442  		{
       
   443  		case EExternalRequestInfoClass:
       
   444  			{
       
   445  			TBuf<KLbsMaxClientNameSize> buf;
       
   446  			aRequestInfo.GetClientName(buf);
       
   447  			AddRequestorL(CPosRequestor::ERequestorService,
       
   448  						  aRequestInfo.ClientNameFormat(),
       
   449  						  aRequestInfo.RequestType(),
       
   450  						  aRequestInfo.NetworkType(),
       
   451  						  buf,
       
   452  						  aRequestors
       
   453  						  );
       
   454  			break;
       
   455  			}
       
   456  		case (EExternalRequestInfoClass 
       
   457  			  | EExternalRequestInfoClass2):
       
   458  		  	{
       
   459    			const TLbsExternalRequestInfo2& info = static_cast<const TLbsExternalRequestInfo2&>(aRequestInfo);
       
   460    			TBuf<KLbsMaxClientNameSize2> buf;
       
   461  			info.GetClientName(buf);
       
   462  			AddRequestorL(CPosRequestor::ERequestorService,
       
   463  						  aRequestInfo.ClientNameFormat(),
       
   464  						  aRequestInfo.RequestType(),
       
   465  						  aRequestInfo.NetworkType(),
       
   466  						  buf,
       
   467  						  aRequestors
       
   468  						  );		
       
   469  		  	break;
       
   470  		  	}
       
   471  		default:
       
   472  			{
       
   473  			// Unrecognised TLbsExternalRequestInfo class type, so ignore it.
       
   474  			break;
       
   475  			}
       
   476  		}	
       
   477  	
       
   478  	// Convert the Requestor name into a CPosRequestor::ERequestorContact requestor.
       
   479  	switch (aRequestInfo.ClassType())
       
   480  		{
       
   481  		case EExternalRequestInfoClass:
       
   482  			{
       
   483  			TBuf<KLbsMaxRequesterIdSize> buf;
       
   484  			aRequestInfo.GetRequesterId(buf);
       
   485  			AddRequestorL(CPosRequestor::ERequestorContact,
       
   486  						  aRequestInfo.RequesterIdFormat(),
       
   487  						  aRequestInfo.RequestType(),
       
   488  						  aRequestInfo.NetworkType(),
       
   489  						  buf,
       
   490  						  aRequestors
       
   491  						  );
       
   492  			break;
       
   493  			}
       
   494  		case (EExternalRequestInfoClass 
       
   495  			  | EExternalRequestInfoClass2):
       
   496  		  	{
       
   497    			const TLbsExternalRequestInfo2& info = static_cast<const TLbsExternalRequestInfo2&>(aRequestInfo);
       
   498    			TBuf<KLbsMaxRequesterIdSize2> buf;
       
   499  			info.GetRequesterId(buf);
       
   500  			AddRequestorL(CPosRequestor::ERequestorContact,
       
   501  						  aRequestInfo.RequesterIdFormat(),
       
   502  						  aRequestInfo.RequestType(),
       
   503  						  aRequestInfo.NetworkType(),
       
   504  						  buf,
       
   505  						  aRequestors
       
   506  						  );
       
   507  		  	break;
       
   508  		  	}
       
   509  		default:
       
   510  			{
       
   511  			// Unrecognised TLbsExternalRequestInfo class type, so ignore it.
       
   512  			break;
       
   513  			}
       
   514  		}
       
   515  	}
       
   516 
       
   517  /**
       
   518  */	
       
   519 void CPosDialogCtrl::AddRequestorL(
       
   520  		CPosRequestor::TRequestorType aRequestorType,
       
   521  		TLbsExternalRequestInfo::TFormatIndicator aIdType,
       
   522  	    CPosRequestor::TRequestType aRequestType,
       
   523  	    CPosRequestor::TNetworkType aNetworkType,
       
   524  		const TDesC& aId,
       
   525  		RPosRequestorStack& aRequestors)
       
   526  	{
       
   527  	CPosRequestor::TRequestorIdFormat format = CPosRequestor::EIdFormatUnknown;
       
   528  	switch (aIdType)
       
   529  		{
       
   530  		case TLbsExternalRequestInfo::EFormatLogicalName :
       
   531  			format = CPosRequestor::EIdFormatGenericName;
       
   532  			break;
       
   533  		case TLbsExternalRequestInfo::EFormatMSISDN :
       
   534  			format = CPosRequestor::EIdFormatPhoneNumber;
       
   535  			break;
       
   536  		case TLbsExternalRequestInfo::EFormatEmailAddress :
       
   537  			format = CPosRequestor::EIdFormatEmail;
       
   538  			break;
       
   539  		case TLbsExternalRequestInfo::EFormatURL :
       
   540  			format = CPosRequestor::EIdFormatUrl;
       
   541  			break;
       
   542  		case TLbsExternalRequestInfo::EFormatSIPURL :
       
   543  			format = CPosRequestor::EIdFormatSIPUrl;
       
   544  			break;
       
   545  		case TLbsExternalRequestInfo::EFormatIMSPublicIdentity :
       
   546  			format = CPosRequestor::EIdFormatIMSPublicIdentity;
       
   547  			break;
       
   548  		case TLbsExternalRequestInfo::EFormatMIN:
       
   549  			format = CPosRequestor::EIdFormatMIN;
       
   550  			break;
       
   551  		case TLbsExternalRequestInfo::EFormatMDN:
       
   552  			format = CPosRequestor::EIdFormatMDN;
       
   553  			break;
       
   554  		}
       
   555 
       
   556  	// Only add the requestor to the stack if it is a recognised format.
       
   557  	if (format != CPosRequestor::EIdFormatUnknown)
       
   558  		{
       
   559  	    CPosRequestor* requestor = NULL;
       
   560  	    if (aRequestorType == CPosRequestor::ERequestorContact)
       
   561  	        {
       
   562  	        requestor = CPosContactRequestor::NewLC(format, aId);
       
   563  	        }
       
   564  	    else
       
   565  	        {
       
   566  	        requestor = CPosServiceRequestor::NewLC(format, aId);
       
   567  	        }
       
   568  	        
       
   569  	    requestor->SetRequestType(aRequestType);
       
   570  	    requestor->SetNetworkType(aNetworkType);
       
   571      	User::LeaveIfError(aRequestors.Append(requestor));
       
   572      	CleanupStack::Pop(requestor);
       
   573  		}	
       
   574  	}
       
   575  
       
   576  
       
   577 // ---------------------------------------------------------
       
   578 // CPosDialogCtrl::GivePriorityToVerificationL
       
   579 //
       
   580 // (other items were commented in a header).
       
   581 // ---------------------------------------------------------
       
   582 //
       
   583 void CPosDialogCtrl::GivePriorityToVerificationL(TRequest& aRequest)
       
   584     {
       
   585     TBool notificationDeferred = EFalse;
       
   586     
       
   587     if( iRequestQueue.Count() == 0 )
       
   588 	    {
       
   589 	    ScheduleRequestL(aRequest);
       
   590 	    return;
       
   591 	    }
       
   592 	if ( iRequestQueue[0].iType == TPosQNInputData::ENotification )
       
   593 		{
       
   594 		notificationDeferred=ETrue; // To indicate that notification is deferred,dont remove it from queue.
       
   595 		}
       
   596 		
       
   597 	EnqueueRequestL(aRequest);
       
   598 	
       
   599 	if(notificationDeferred)
       
   600 		{
       
   601 		Cancel();	
       
   602 	    DeferNotificationL();
       
   603 		}
       
   604     }
       
   605 // ---------------------------------------------------------
       
   606 // CPosDialogCtrl::EnqueueRequestL
       
   607 //
       
   608 // (other items were commented in a header).
       
   609 // ---------------------------------------------------------
       
   610 //
       
   611 void CPosDialogCtrl::EnqueueRequestL(TRequest& aRequest)
       
   612     {
       
   613     aRequest.iId = ++iRequestId;
       
   614     
       
   615     for( TInt i = 1; i < iRequestQueue.Count(); i++ )
       
   616 		{
       
   617 		if ( iRequestQueue[i].iType == TPosQNInputData::ENotification )
       
   618 			{
       
   619 			User::LeaveIfError(iRequestQueue.Insert( aRequest,i ));
       
   620 			return;
       
   621 			}
       
   622 		}
       
   623 	
       
   624     User::LeaveIfError(iRequestQueue.Append(aRequest));
       
   625     }
       
   626 
       
   627 // ---------------------------------------------------------
       
   628 // CPosDialogCtrl::DeferNotificationL
       
   629 //
       
   630 // (other items were commented in a header).
       
   631 // ---------------------------------------------------------
       
   632 //
       
   633 void CPosDialogCtrl::DeferNotificationL()
       
   634 	{
       
   635 	if( KErrCancel == iStatus.Int() )
       
   636 		{
       
   637 		//Notification request has been cancelled..Defer it by adding 
       
   638 		// after verification requests,remove it from first place & schedule next request.
       
   639 		TRequest request = iRequestQueue[0];
       
   640 		EnqueueRequestL(request);
       
   641 		}
       
   642 	iRequestQueue.Remove(0);
       
   643     iRequestQueue.Compress();
       
   644 	NextRequest();	
       
   645 	}
       
   646 
       
   647 // ---------------------------------------------------------
       
   648 // CPosDialogCtrl::CreateNotificationAndEnqueueL
       
   649 //
       
   650 // (other items were commented in a header).
       
   651 // ---------------------------------------------------------
       
   652 //
       
   653 void CPosDialogCtrl::CreateNotificationAndEnqueueL()
       
   654 	{   
       
   655     TRequest verifyRequest = iRequestQueue[0];   
       
   656     TRequest notifyRequest;
       
   657     TLbsExternalRequestInfo* requestinfocopy = NULL;
       
   658     
       
   659     if (verifyRequest.iRequestInfo->ClassType() == EExternalRequestInfoClass) 
       
   660         {        
       
   661         requestinfocopy = new (ELeave) TLbsExternalRequestInfo;
       
   662         CleanupStack::PushL(requestinfocopy);
       
   663         Mem::Copy(requestinfocopy, verifyRequest.iRequestInfo, sizeof(TLbsExternalRequestInfo));
       
   664         }
       
   665     else 
       
   666         {
       
   667         __ASSERT_DEBUG(verifyRequest.iRequestInfo->ClassType() == EExternalRequestInfoClass | EExternalRequestInfoClass2, User::Invariant());
       
   668         requestinfocopy = new (ELeave) TLbsExternalRequestInfo2;
       
   669         CleanupStack::PushL(requestinfocopy);
       
   670         Mem::Copy(requestinfocopy, verifyRequest.iRequestInfo, sizeof(TLbsExternalRequestInfo2));        
       
   671         }
       
   672 
       
   673     notifyRequest.iRequestInfo = requestinfocopy;    
       
   674     notifyRequest.iType = TPosQNInputData::ENotification;
       
   675     notifyRequest.iStatus = NULL;
       
   676     notifyRequest.iRequestSource = EPosRequestSourceNetwork;
       
   677     
       
   678     notifyRequest.iTimeoutStrategy = EPosDecisionNotAvailable;
       
   679     notifyRequest.iRequestDecision = verifyRequest.iTimeoutStrategy;
       
   680     
       
   681     notifyRequest.iCancelReason = EPosCancelReasonTimeout; 
       
   682     notifyRequest.iNotificationReason = EPosVerificationTimeout;
       
   683     
       
   684     EnqueueRequestL(notifyRequest);        
       
   685     CleanupStack::Pop(requestinfocopy);
       
   686     
       
   687 	}
       
   688 //  End of File