phonebookengines/contactsmodel/cntsrv/src/CViewSubSessions.cpp
changeset 24 0ba2181d7c28
parent 0 e686773b3f54
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 /*
     2 // All rights reserved.
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // This component and the accompanying materials are made available
     3 * All rights reserved.
     4 // under the terms of "Eclipse Public License v1.0"
     4 * This component and the accompanying materials are made available
     5 // which accompanies this distribution, and is available
     5 * under the terms of "Eclipse Public License v1.0"
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 * which accompanies this distribution, and is available
     7 //
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 // Initial Contributors:
     8 *
     9 // Nokia Corporation - initial contribution.
     9 * Initial Contributors:
    10 //
    10 * Nokia Corporation - initial contribution.
    11 // Contributors:
    11 *
    12 //
    12 * Contributors:
    13 // Description:
    13 *
    14 //
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
    15 
    18 
    16 /**
    19 /**
    17  @file
    20  @file
    18  @internalComponent
    21  @internalComponent
    19  @released
    22  @released
    20 */
    23 */
    21 
    24 
    22 
    25 
    23 #include "cntviewprivate.h"
    26 #include "cntviewprivate.h"
    24 #include "CViewSubSessions.h"
    27 #include "cviewsubsessions.h"
    25 #include "CCntIpcCodes.h"
    28 #include "ccntipccodes.h"
    26 #include "CCntDbManager.h"
    29 #include "ccntdbmanager.h"
    27 #include "CCntServer.h"
    30 #include "ccntserver.h"
    28 #include <cntviewstore.h>
    31 #include <cntviewstore.h>
    29 #include "CCntLogger.h"
    32 #include "ccntlogger.h"
    30 #include "CCntStateMachine.h"
    33 #include "ccntstatemachine.h"
    31 
    34 
    32 
    35 
    33 extern void DebugLogViewNotification(const TDesC& aMethod, const TContactViewEvent& aEvent);
    36 extern void DebugLogViewNotification(const TDesC& aMethod, const TContactViewEvent& aEvent);
    34 
    37 
    35 
    38 
   125 					for( pos = lastItemRemovedPosition-1; pos < eventsCount;++pos ) 
   128 					for( pos = lastItemRemovedPosition-1; pos < eventsCount;++pos ) 
   126 						{
   129 						{
   127 						if(iEvents[pos].iInt >= aEvent.iInt && 
   130 						if(iEvents[pos].iInt >= aEvent.iInt && 
   128 								iEvents[pos].iContactId != aEvent.iContactId)
   131 								iEvents[pos].iContactId != aEvent.iContactId)
   129 							{
   132 							{
   130 							if( iEvents[pos].iEventType == TContactViewEvent::EItemRemoved || iEvents[pos].iEventType == TContactViewEvent::EItemAdded)  
   133 							iEvents[pos].iInt++;
   131 								{
       
   132 								iEvents[pos].iInt++;
       
   133 								}
       
   134 							}
   134 							}
   135 						}
   135 						}
   136 					iQueueError = iEvents.Insert(aEvent, lastItemRemovedPosition);		
   136 					iQueueError = iEvents.Insert(aEvent, lastItemRemovedPosition);		
   137 					}
   137 					}
   138 				else
   138 				else
   151 							{
   151 							{
   152 							iQueueError = iEvents.Insert(event, pos);
   152 							iQueueError = iEvents.Insert(event, pos);
   153 							eventsCount=iEvents.Count();
   153 							eventsCount=iEvents.Count();
   154 							for(TUint loop=pos+1; loop<eventsCount; ++loop)
   154 							for(TUint loop=pos+1; loop<eventsCount; ++loop)
   155 								{
   155 								{
   156 								if( iEvents[pos].iEventType == TContactViewEvent::EItemRemoved || iEvents[pos].iEventType == TContactViewEvent::EItemAdded)
   156 								iEvents[loop].iInt++;
   157 									{
       
   158 									iEvents[loop].iInt++;
       
   159 									}
       
   160 								}						
   157 								}						
   161 							haveToAppendEvent = EFalse;										
   158 							haveToAppendEvent = EFalse;										
   162 							break;
   159 							break;
   163 							}				
   160 							}				
   164 						}
   161 						}
   169 				 	}
   166 				 	}
   170 				}
   167 				}
   171 			}
   168 			}
   172 		else 
   169 		else 
   173 			{
   170 			{
   174 			iQueueError = iEvents.Append(event);	
   171 			if(event.iEventType == TContactViewEvent::EItemRemoved)
       
   172 				{
       
   173 				TBool anyEventWithSameInt = EFalse;												
       
   174 				for( pos=0; pos<eventsCount; ++pos ) 
       
   175 					{
       
   176 					if(iEvents[pos].iEventType == TContactViewEvent::EItemAdded)
       
   177 						{								
       
   178 						if(iEvents[pos].iInt == event.iInt)
       
   179 							{
       
   180 							iEvents.Remove(pos);
       
   181 							eventsCount=iEvents.Count();
       
   182 							for(TUint loop=pos; loop<eventsCount; ++loop)
       
   183 								{
       
   184 								iEvents[loop].iInt--;
       
   185 								}						
       
   186 							anyEventWithSameInt=ETrue;	
       
   187 							break;									
       
   188 							}					
       
   189 						}
       
   190 					}						
       
   191 				pos=0;	
       
   192 				if(!anyEventWithSameInt) 
       
   193 					{
       
   194 					while(pos < eventsCount && iEvents[pos].iInt <= event.iInt)
       
   195 						{
       
   196 						pos++;
       
   197 						}
       
   198 					if(pos!=eventsCount)
       
   199 						{	
       
   200 						iQueueError = iEvents.Insert(event, pos);
       
   201 						eventsCount=iEvents.Count();
       
   202 						for(TUint loop=pos+1; loop<eventsCount; ++loop)
       
   203 							{
       
   204 							iEvents[loop].iInt--;
       
   205 							}	
       
   206 						}
       
   207 					else
       
   208 						{
       
   209 						iQueueError = iEvents.Append(event);
       
   210 						}
       
   211 					}
       
   212 				}
       
   213 			else
       
   214 				{
       
   215 				iQueueError = iEvents.Append(event);	
       
   216 				}
   175 			}
   217 			}
   176 		DEBUG_PRINTVN2(__VERBOSE_DEBUG__,_L("[CNTMODEL] CViewSubSessionQueue::QueueEvent(): ->Q:"), event);
   218 		DEBUG_PRINTVN2(__VERBOSE_DEBUG__,_L("[CNTMODEL] CViewSubSessionQueue::QueueEvent(): ->Q:"), event);
   177 		}
   219 		}
   178 	}
   220 	}
   179 
   221