datacommsserver/esockserver/ssock/ss_DataMonitoringProvider.cpp
branchRCL_3
changeset 14 4ccf8e394726
parent 0 dfb7c4ff071f
equal deleted inserted replaced
13:0b0e9fce0b58 14:4ccf8e394726
   112 		return;
   112 		return;
   113 		}
   113 		}
   114 
   114 
   115 	// Ensure this client has not registered before or if it has, any outstanding requests are
   115 	// Ensure this client has not registered before or if it has, any outstanding requests are
   116 	// marked as cancelled.
   116 	// marked as cancelled.
   117 	TInt requestIdx = iReceivedNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));
   117 	TInt requestIdx = iReceivedNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));
   118 	if(requestIdx != KErrNotFound && !iReceivedNotificationRequests[requestIdx]->Cancelled())
   118 	if(requestIdx != KErrNotFound)
   119 		{
   119 		{
   120 		delete notificationRequest;
   120 		delete notificationRequest;
   121 		CDataMonitoringResponder::Error(aResponder, KErrInUse);
   121 		CDataMonitoringResponder::Error(aResponder, KErrInUse);
   122 		return;
   122 		return;
   123 		}
   123 		}
   160 	{
   160 	{
   161 	// Set up an exemplar request using the specified client ID
   161 	// Set up an exemplar request using the specified client ID
   162 	TNotificationRequest exemplarRequest(NULL, aClientId);
   162 	TNotificationRequest exemplarRequest(NULL, aClientId);
   163 	
   163 	
   164 	// Locate the request matching the specified client ID
   164 	// Locate the request matching the specified client ID
   165 	TInt requestIdx = iReceivedNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));	
   165 	TInt requestIdx = iReceivedNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));	
   166 	if(requestIdx != KErrNotFound && !iReceivedNotificationRequests[requestIdx]->Cancelled())
   166 	if(requestIdx != KErrNotFound)
   167 		{
   167 		{
   168 		TNotificationRequest* notificationRequest = iReceivedNotificationRequests[requestIdx];
   168 		TNotificationRequest* notificationRequest = iReceivedNotificationRequests[requestIdx];
   169 		
   169 		
   170 		// Cancel it and complete the client
   170 		// Cancel it and complete the client
   171 		notificationRequest->SetCancelled();
   171 		notificationRequest->SetCancelled();
   172 		CDataMonitoringResponder::CancelRequest(notificationRequest->Responder());
   172 		CDataMonitoringResponder::CancelRequest(notificationRequest->Responder());
       
   173 		
       
   174 		iReceivedNotificationRequests.Remove(requestIdx); 
       
   175         delete notificationRequest;
   173 		}
   176 		}
   174 	}
   177 	}
   175 
   178 
   176 /**
   179 /**
   177 
   180 
   185 		return;
   188 		return;
   186 		}
   189 		}
   187 	
   190 	
   188 	// Ensure this client has not registered before or if it has, any outstanding requests are
   191 	// Ensure this client has not registered before or if it has, any outstanding requests are
   189 	// marked as cancelled.
   192 	// marked as cancelled.
   190 	TInt requestIdx = iSentNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));
   193 	TInt requestIdx = iSentNotificationRequests.Find(notificationRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));
   191 	if(requestIdx != KErrNotFound && !iSentNotificationRequests[requestIdx]->Cancelled())
   194 	if(requestIdx != KErrNotFound)
   192 		{
   195 		{
   193 		delete notificationRequest;
   196 		delete notificationRequest;
   194 		CDataMonitoringResponder::Error(aResponder, KErrInUse);
   197 		CDataMonitoringResponder::Error(aResponder, KErrInUse);
   195 		return;
   198 		return;
   196 		}
   199 		}
   233 	{
   236 	{
   234 	// Set up an exemplar request using the specified client id
   237 	// Set up an exemplar request using the specified client id
   235 	TNotificationRequest exemplarRequest(NULL, aClientId);
   238 	TNotificationRequest exemplarRequest(NULL, aClientId);
   236 	
   239 	
   237 	// Locate the request matching the specified client id
   240 	// Locate the request matching the specified client id
   238 	TInt requestIdx = iSentNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIds));
   241 	TInt requestIdx = iSentNotificationRequests.Find(&exemplarRequest, TIdentityRelation<TNotificationRequest>(TNotificationRequest::CompareClientIdsAndCancelledFlag));
   239 	if(requestIdx != KErrNotFound && !iSentNotificationRequests[requestIdx]->Cancelled())
   242 	if(requestIdx != KErrNotFound)
   240 		{
   243 		{
   241 		TNotificationRequest* notificationRequest = iSentNotificationRequests[requestIdx];
   244 		TNotificationRequest* notificationRequest = iSentNotificationRequests[requestIdx];
   242 		
   245 		
   243 		// Cancel it and complete the client
   246 		// Cancel it and complete the client
   244 		notificationRequest->SetCancelled();
   247 		notificationRequest->SetCancelled();
   245 		CDataMonitoringResponder::CancelRequest(notificationRequest->Responder());
   248 		CDataMonitoringResponder::CancelRequest(notificationRequest->Responder());
       
   249 
       
   250 		iSentNotificationRequests.Remove(requestIdx);
       
   251 		delete notificationRequest;
   246 		}
   252 		}
   247 	}
   253 	}
   248 
   254 
   249 /**
   255 /**
   250 	Call from data to control plane to indicate the received data volume notification
   256 	Call from data to control plane to indicate the received data volume notification
   525 		{
   531 		{
   526 		return EFalse;
   532 		return EFalse;
   527 		}
   533 		}
   528 	}
   534 	}
   529 
   535 
       
   536 /**
       
   537     Compares two TNotificationRequest objects using their client ids and the cancelled flag as the criteria.
       
   538 */
       
   539 TBool TNotificationRequest::CompareClientIdsAndCancelledFlag(const TNotificationRequest& aFirst, const TNotificationRequest& aSecond)
       
   540     {
       
   541     if(aFirst.ClientId() == aSecond.ClientId())
       
   542         {
       
   543         return aFirst.Cancelled() == aSecond.Cancelled();
       
   544         }
       
   545     else
       
   546         {
       
   547         return EFalse;
       
   548         }
       
   549     }
       
   550 
   530 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TDataMonitoringProvisioningInfoBase, TDataMonitoringProvisioningInfoBase::iUid, TDataMonitoringProvisioningInfoBase::iId)
   551 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TDataMonitoringProvisioningInfoBase, TDataMonitoringProvisioningInfoBase::iUid, TDataMonitoringProvisioningInfoBase::iId)
   531 	REGISTER_ATTRIBUTE(TDataMonitoringProvisioningInfoBase, iDataVolumesPtr, TMeta<TDataMonitoringProvisioningInfoBase*>)
   552 	REGISTER_ATTRIBUTE(TDataMonitoringProvisioningInfoBase, iDataVolumesPtr, TMeta<TDataMonitoringProvisioningInfoBase*>)
   532 	REGISTER_ATTRIBUTE(TDataMonitoringProvisioningInfoBase, iThresholdsPtr, TMeta<TDataMonitoringProvisioningInfoBase*>)
   553 	REGISTER_ATTRIBUTE(TDataMonitoringProvisioningInfoBase, iThresholdsPtr, TMeta<TDataMonitoringProvisioningInfoBase*>)
   533 END_ATTRIBUTE_TABLE()
   554 END_ATTRIBUTE_TABLE()
   534 
   555