982 if( compare == 0 ) |
983 if( compare == 0 ) |
983 { |
984 { |
984 // The cache holds a new notification for this notifier, trigger it |
985 // The cache holds a new notification for this notifier, trigger it |
985 CNotificationCacheItem* item = iNotificationCache[mid]; |
986 CNotificationCacheItem* item = iNotificationCache[mid]; |
986 iNotificationCache.Remove(mid); |
987 iNotificationCache.Remove(mid); |
|
988 iNotificationCache.Compress(); |
987 |
989 |
988 CleanupStack::PushL( item ); |
990 CleanupStack::PushL( item ); |
989 |
991 |
990 entry.TriggerCachedL( item->iCode, item->iData ); |
992 entry.TriggerCachedL( item->iCode, item->iData ); |
991 |
993 |
1086 } |
1089 } |
1087 |
1090 |
1088 CleanupStack::Pop( buffer ); |
1091 CleanupStack::Pop( buffer ); |
1089 return buffer; |
1092 return buffer; |
1090 } |
1093 } |
|
1094 |
|
1095 // --------------------------------------------------------------------------- |
|
1096 // CacheNotificationL caches a notifier event |
|
1097 // --------------------------------------------------------------------------- |
|
1098 // |
|
1099 |
|
1100 CMdCSerializationBuffer* CMdSServerSession::CombineUriNotificationsBuffersL(CMdCSerializationBuffer& aLeftBuffer, |
|
1101 CMdCSerializationBuffer& aRightBuffer ) |
|
1102 { |
|
1103 // IDs are always stored in object IDs, |
|
1104 // even if those are actually relation or event IDs |
|
1105 |
|
1106 aLeftBuffer.PositionL( KNoOffset ); |
|
1107 aRightBuffer.PositionL( KNoOffset ); |
|
1108 |
|
1109 const TMdCItemIds& leftItemIds = TMdCItemIds::GetFromBufferL( aLeftBuffer ); |
|
1110 const TMdCItemIds& rightItemIds = TMdCItemIds::GetFromBufferL( aRightBuffer ); |
|
1111 |
|
1112 // check that namespaces match |
|
1113 if ( leftItemIds.iNamespaceDefId != rightItemIds.iNamespaceDefId ) |
|
1114 { |
|
1115 return NULL; |
|
1116 } |
|
1117 |
|
1118 // create new buffer, which will contain combined results |
|
1119 const TInt leftBufferSize = aLeftBuffer.Size(); |
|
1120 const TInt rightBufferSize = aRightBuffer.Size(); |
|
1121 CMdCSerializationBuffer* buffer = CMdCSerializationBuffer::NewLC( |
|
1122 leftBufferSize + rightBufferSize ); |
|
1123 |
|
1124 TMdCItemIds combinedItemIds; |
|
1125 |
|
1126 // use left buffer's data as base line |
|
1127 Mem::Copy( &combinedItemIds, &leftItemIds, sizeof( TMdCItemIds ) ); |
|
1128 |
|
1129 // and add right buffer's count |
|
1130 combinedItemIds.iObjectIds.iPtr.iCount += rightItemIds.iObjectIds.iPtr.iCount; |
|
1131 |
|
1132 combinedItemIds.SerializeL( *buffer ); |
|
1133 |
|
1134 // move left and right buffer to begin of items |
|
1135 aLeftBuffer.PositionL( leftItemIds.iObjectIds.iPtr.iOffset ); |
|
1136 aRightBuffer.PositionL( rightItemIds.iObjectIds.iPtr.iOffset ); |
|
1137 |
|
1138 // copy IDs from left and right buffers to combined buffer |
|
1139 for (TInt i = 0; i < leftItemIds.iObjectIds.iPtr.iCount; ++i) |
|
1140 { |
|
1141 TItemId id; |
|
1142 aLeftBuffer.ReceiveL( id ); |
|
1143 buffer->InsertL( id ); |
|
1144 } |
|
1145 |
|
1146 for (TInt i = 0; i < rightItemIds.iObjectIds.iPtr.iCount; ++i) |
|
1147 { |
|
1148 TItemId id; |
|
1149 aRightBuffer.ReceiveL( id ); |
|
1150 buffer->InsertL( id ); |
|
1151 } |
|
1152 |
|
1153 //Add combined URI count |
|
1154 TUint32 leftUriCount ( 0 ); |
|
1155 aLeftBuffer.ReceiveL( leftUriCount ); |
|
1156 TUint32 rightUriCount ( 0 ); |
|
1157 aRightBuffer.ReceiveL( rightUriCount ); |
|
1158 buffer->InsertL( TUint32( leftUriCount + rightUriCount) ); |
|
1159 |
|
1160 //Add uris |
|
1161 HBufC* uri = NULL; |
|
1162 for( TInt i( 0 ); i < leftUriCount; i++ ) |
|
1163 { |
|
1164 //Get uri |
|
1165 uri = aLeftBuffer.ReceiveDes16L(); |
|
1166 CleanupStack::PushL( uri ); |
|
1167 buffer->InsertL( *uri ); |
|
1168 CleanupStack::Pop( uri ); |
|
1169 } |
|
1170 |
|
1171 for( TInt i( 0 ); i < rightUriCount; i++ ) |
|
1172 { |
|
1173 //Get uri |
|
1174 uri = aRightBuffer.ReceiveDes16L(); |
|
1175 CleanupStack::PushL( uri ); |
|
1176 buffer->InsertL( *uri ); |
|
1177 CleanupStack::Pop( uri ); |
|
1178 } |
|
1179 |
|
1180 CleanupStack::Pop( buffer ); |
|
1181 return buffer; |
|
1182 } |
1091 |
1183 |
1092 CMdCSerializationBuffer* CMdSServerSession::CombineItemBuffersL( CMdCSerializationBuffer& aLeftBuffer, |
1184 CMdCSerializationBuffer* CMdSServerSession::CombineItemBuffersL( CMdCSerializationBuffer& aLeftBuffer, |
1093 CMdCSerializationBuffer& aRightBuffer ) |
1185 CMdCSerializationBuffer& aRightBuffer ) |
1094 { |
1186 { |
1095 // Current implementation supports only combining relations |
1187 // Current implementation supports only combining relations |
1174 CNotificationCacheItem& notificationItem = *iNotificationCache[i]; |
1266 CNotificationCacheItem& notificationItem = *iNotificationCache[i]; |
1175 if ( notificationItem.iId == aId && notificationItem.iCode == aCompleteCode ) |
1267 if ( notificationItem.iId == aId && notificationItem.iCode == aCompleteCode ) |
1176 { |
1268 { |
1177 CMdCSerializationBuffer* data = NULL; |
1269 CMdCSerializationBuffer* data = NULL; |
1178 // combine buffers |
1270 // combine buffers |
1179 if ( notificationItem.iCode != ERelationItemNotifyRemove ) |
1271 if( notificationItem.iCode == EObjectNotifyAddWithUri || |
|
1272 notificationItem.iCode == EObjectNotifyModifyWithUri || |
|
1273 notificationItem.iCode == EObjectNotifyRemoveWithUri ) |
|
1274 { |
|
1275 data = CombineUriNotificationsBuffersL( *notificationItem.iData, *aData ); |
|
1276 } |
|
1277 else if ( notificationItem.iCode != ERelationItemNotifyRemove ) |
1180 { |
1278 { |
1181 data = CombineBuffersL( *notificationItem.iData, *aData ); |
1279 data = CombineBuffersL( *notificationItem.iData, *aData ); |
1182 } |
1280 } |
1183 else |
1281 else |
1184 { |
1282 { |