telephonyserverplugins/simtsy/src/CSimMbmsPacketContext.cpp
changeset 31 8ab6687fb94c
parent 0 3553901f7fa8
child 42 3adadc800673
equal deleted inserted replaced
26:8767c6acf334 31:8ab6687fb94c
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   475 			return NotifyStatusChangeCancel(aTsyReqHandle);
   475 			return NotifyStatusChangeCancel(aTsyReqHandle);
   476 		case EPacketContextGetStatus:
   476 		case EPacketContextGetStatus:
   477 			return GetStatus(aTsyReqHandle,
   477 			return GetStatus(aTsyReqHandle,
   478 					REINTERPRET_CAST(RPacketContext::TContextStatus*, dataPtr));
   478 					REINTERPRET_CAST(RPacketContext::TContextStatus*, dataPtr));
   479 		case EPacketContextUpdateMbmsSessionList:
   479 		case EPacketContextUpdateMbmsSessionList:
   480 			return UpdateMbmsSessionListL(aTsyReqHandle,
   480 			return UpdateMbmsSessionList(aTsyReqHandle,
   481 					REINTERPRET_CAST(TMbmsAction*, dataPtr),
   481 					REINTERPRET_CAST(TMbmsAction*, dataPtr),
   482 					REINTERPRET_CAST(TUint*, dataPtr2));	
   482 					REINTERPRET_CAST(TUint*, dataPtr2));	
   483 		case EPacketContextInitialiseContext:
   483 		case EPacketContextInitialiseContext:
   484 			return InitialiseContext(aTsyReqHandle, aPackage.Des1n());
   484 			return InitialiseContext(aTsyReqHandle, aPackage.Des1n());
   485 		case EPacketContextInitialiseContextCancel:
   485 		case EPacketContextInitialiseContextCancel:
  1128 		ReqCompleted(aTsyReqHandle,KErrNone);
  1128 		ReqCompleted(aTsyReqHandle,KErrNone);
  1129 		}
  1129 		}
  1130 	return KErrNone;
  1130 	return KErrNone;
  1131 	}
  1131 	}
  1132 
  1132 
  1133 TInt CSimMbmsPacketContext::UpdateMbmsSessionListL(const TTsyReqHandle aTsyReqHandle,TMbmsAction* aAction, TUint* aSessionId)
  1133 TInt CSimMbmsPacketContext::UpdateMbmsSessionList(const TTsyReqHandle aTsyReqHandle,TMbmsAction* aAction, TUint* aSessionId)
  1134 /**
  1134 /**
  1135 * client's interest in updating the MBMS session's list.
  1135 * client's interest in updating the MBMS session's list.
  1136 * This is achieved  by updating the list maintained internally by the context
  1136 * This is achieved  by updating the list maintained internally by the context
  1137 * 
  1137 * 
  1138 * @param aTsyReqHandle Tsy Request handle for the client request
  1138 * @param aTsyReqHandle Tsy Request handle for the client request
  1139 * @param aAction TMbmsAction - ADD/ REMOVE / REMOVE_ALL
  1139 * @param aAction TMbmsAction - ADD/ REMOVE / REMOVE_ALL
  1140 * @param aSessionId sessoinID to be used for the updation.
  1140 * @param aSessionId sessoinID to be used for the updation.
  1141 * @return KErrNone
  1141 * @return KErrNone
  1142 */
  1142 */
  1143 	{
  1143 	{
  1144 	LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionListL called");
  1144 	LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionList called");
  1145 
  1145 
  1146 	TInt error=KErrNone;
  1146 	TInt error=KErrNone;
  1147 	iUpdateSessionHandle = aTsyReqHandle;
  1147 	iUpdateSessionHandle = aTsyReqHandle;
  1148 	TKeyArrayFix key(0, ECmpTUint);
  1148 	TKeyArrayFix key(0, ECmpTUint);
  1149 	TInt position =-1;
  1149 	TInt position =-1;
  1150 
  1150 
  1151 	switch(*aAction)
  1151 	switch(*aAction)
  1152 		{
  1152 		{
  1153 		case SIMTSY_PACKET_MBMS_ADD_ENTRIES:
  1153 		case SIMTSY_PACKET_MBMS_ADD_ENTRIES:
  1154 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionListL Action: ADD ");
  1154 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionList Action: ADD ");
  1155 			TRAP(error,iSessionIdList->AppendL(*aSessionId));
  1155 			
  1156 			if(error == KErrNone)
  1156 			// TRAP can contain multiple statments
  1157 				{
  1157 			TRAP(error,iSessionIdList->AppendL(*aSessionId);
  1158 				//iSessionIdList->At(0) = ++iNumOfSessionId;
  1158                     //iSessionIdList->At(0) = ++iNumOfSessionId;
  1159 				iSessionIdList->Delete(0);
  1159                     iSessionIdList->Delete(0);
  1160 				iSessionIdList->InsertL(0,++iNumOfSessionId);
  1160                     iSessionIdList->InsertL(0,++iNumOfSessionId));
  1161 				iMbmsUpdateSessionTimer->Start(RandTime(),this,ETimerIdMbmsUpdateSessionId);
  1161 			
  1162 				}
  1162             iMbmsUpdateSessionTimer->Start(RandTime(),this,ETimerIdMbmsUpdateSessionId);
  1163 			else
  1163 
       
  1164 			if(error != KErrNone)
  1164 				{
  1165 				{
  1165 				ReqCompleted(iUpdateSessionHandle,error);
  1166 				ReqCompleted(iUpdateSessionHandle,error);
  1166 				}
  1167 				}
  1167 			break;
  1168 			break;
  1168 
  1169 
  1169 		case SIMTSY_PACKET_MBMS_REM_ENTRIES:
  1170 		case SIMTSY_PACKET_MBMS_REM_ENTRIES:
  1170 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionListL Action: REMOVE ");
  1171 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionList Action: REMOVE ");
  1171 			iSessionIdList->Find(*aSessionId,key,position);
  1172 			iSessionIdList->Find(*aSessionId,key,position);
  1172 			if(position != -1)
  1173 			if(position != -1)
  1173 				{
  1174 				{
  1174 				iSessionIdList->Delete(position);
  1175 				iSessionIdList->Delete(position);
  1175 				//iSessionIdList->At(0) = --iNumOfSessionId;
  1176 				//iSessionIdList->At(0) = --iNumOfSessionId;
  1176 				iSessionIdList->InsertL(0,--iNumOfSessionId);
  1177 				TRAP(error, iSessionIdList->InsertL(0,--iNumOfSessionId));
       
  1178 	            if(error != KErrNone)
       
  1179 	                {
       
  1180 	                ReqCompleted(iUpdateSessionHandle,error);
       
  1181 	                }
  1177 				iMbmsUpdateSessionTimer->Start(RandTime(),this,ETimerIdMbmsUpdateSessionId);
  1182 				iMbmsUpdateSessionTimer->Start(RandTime(),this,ETimerIdMbmsUpdateSessionId);
  1178 				}
  1183 				}
  1179 			else
  1184 			else
  1180 				{
  1185 				{
  1181 				error = KErrNotFound;
  1186 				error = KErrNotFound;
  1182 				ReqCompleted(iUpdateSessionHandle,error);
  1187 				ReqCompleted(iUpdateSessionHandle,error);
  1183 				}
  1188 				}
  1184 			break;
  1189 			break;
  1185 
  1190 
  1186 		case SIMTSY_PACKET_MBMS_REM_ALL_ENTRIES:
  1191 		case SIMTSY_PACKET_MBMS_REM_ALL_ENTRIES:
  1187 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionListL Action: REMOVE_ALL ");
  1192 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionList Action: REMOVE_ALL ");
  1188 			iNumOfSessionId=0;
  1193 			iNumOfSessionId=0;
  1189 			//iSessionIdList->At(0) = iNumOfSessionId;
  1194 			//iSessionIdList->At(0) = iNumOfSessionId;
  1190 			iSessionIdList->InsertL(0,iNumOfSessionId);
  1195 			TRAP(error, iSessionIdList->InsertL(0,iNumOfSessionId));
       
  1196             if(error != KErrNone)
       
  1197                 {
       
  1198                 ReqCompleted(iUpdateSessionHandle,error);
       
  1199                 }
  1191 			iSessionIdList->Delete(1,iSessionIdList->Count()); // removing all session ids from the list
  1200 			iSessionIdList->Delete(1,iSessionIdList->Count()); // removing all session ids from the list
  1192 			ReqCompleted(aTsyReqHandle, KErrNone);
  1201 			ReqCompleted(aTsyReqHandle, KErrNone);
  1193 			break;
  1202 			break;
  1194 
  1203 
  1195 		default:
  1204 		default:
  1196 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionListL Action: Default ");
  1205 			LOGPACKET1("CSimMbmsPacketContext::UpdateMbmsSessionList Action: Default ");
  1197 			ReqCompleted(aTsyReqHandle,KErrNotFound);
  1206 			ReqCompleted(aTsyReqHandle,KErrNotFound);
  1198 			break;
  1207 			break;
  1199 		}
  1208 		}
  1200 	return KErrNone;
  1209 	return KErrNone;
  1201 	}
  1210 	}