serviceproviders/sapi_landmarks/landmarksservice/src/clandmarkmanageobjects.cpp
changeset 26 5d0ec8b709be
parent 5 989d2f495d90
equal deleted inserted replaced
23:50974a8b132e 26:5d0ec8b709be
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "clandmarkmanageobjects.h"
    19 #include "clandmarkmanageobjects.h"
    20 #include "clandmarkcmdbase.h"
    20 #include "clandmarkcmdbase.h"
       
    21 #include "clandmarkdummyao.h"
       
    22 #include "clandmarkoperation.h"
    21 
    23 
    22 // ============================ MEMBER FUNCTIONS ===============================
    24 // ============================ MEMBER FUNCTIONS ===============================
    23 
    25 
    24 // -----------------------------------------------------------------------------
    26 // -----------------------------------------------------------------------------
    25 // CLandmarkManageObjects::NewL()
    27 // CLandmarkManageObjects::NewL()
    51 CLandmarkManageObjects::~CLandmarkManageObjects( )
    53 CLandmarkManageObjects::~CLandmarkManageObjects( )
    52 	{
    54 	{
    53 	Cancel ( );
    55 	Cancel ( );
    54 	iObjects.ResetAndDestroy ( );
    56 	iObjects.ResetAndDestroy ( );
    55 	iObjects.Close();
    57 	iObjects.Close();
       
    58 	iDummyObjects.ResetAndDestroy();
       
    59 	iDummyObjects.Close();
       
    60 	iOrgObjects.ResetAndDestroy();
       
    61 	iOrgObjects.Close();
    56 	}
    62 	}
    57 
    63 
    58 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    59 // CLandmarkManageObjects::Start()
    65 // CLandmarkManageObjects::Start()
    60 // Start asynchronous operation.
    66 // Start asynchronous operation.
    75 void CLandmarkManageObjects::AppendL( CLandmarkCmdBase* aObject )
    81 void CLandmarkManageObjects::AppendL( CLandmarkCmdBase* aObject )
    76 	{
    82 	{
    77 	iObjects.AppendL (aObject );
    83 	iObjects.AppendL (aObject );
    78 	}
    84 	}
    79 
    85 
       
    86 void CLandmarkManageObjects::AppendL(CLandmarkDummyAO* aObject)
       
    87 	{
       
    88 	iDummyObjects.AppendL(aObject);
       
    89 	}
       
    90 
       
    91 void CLandmarkManageObjects::AppendL(CLandmarkOperation* aObject)
       
    92 	{
       
    93 	iOrgObjects.AppendL(aObject);
       
    94 	}
    80 // -----------------------------------------------------------------------------
    95 // -----------------------------------------------------------------------------
    81 // CLandmarkManageObjects::CancelObject()
    96 // CLandmarkManageObjects::CancelObject()
    82 // Execute the next step.
    97 // Execute the next step.
    83 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    84 //
    99 //
    85 void CLandmarkManageObjects::CancelObject( TInt32 aTransactionId )
   100 void CLandmarkManageObjects::CancelObject( TInt32 aTransactionId )
    86 	{
   101 	{
    87 	TInt count = iObjects.Count ( );
   102 	TBool isDone = EFalse;
    88 	for (TInt i = 0; i< count; ++i )
   103 	TInt count = iObjects.Count();
       
   104 	for (TInt i = 0; i < count; ++i)
    89 		{
   105 		{
    90 		if ( iObjects[i]->TransactionId ( )== aTransactionId )
   106 		if ( iObjects[i]->TransactionId ( )== aTransactionId )
    91 			{
   107 			{
    92 			iObjects[i]->Cancel ( );
   108 			iObjects[i]->Cancel();
       
   109 			isDone = ETrue;
    93 			break;
   110 			break;
       
   111 			}
       
   112 		}
       
   113 	if( !isDone )
       
   114 		{
       
   115 		count = iOrgObjects.Count();
       
   116 		for (TInt i = 0; i < count; ++i)
       
   117 			{
       
   118 			if (iOrgObjects[i]->TransactionId() == aTransactionId)
       
   119 				{
       
   120 				iOrgObjects[i]->Cancel();
       
   121 				break;
       
   122 				}
    94 			}
   123 			}
    95 		}
   124 		}
    96 	}
   125 	}
    97 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
    98 // CLandmarkManageObjects::RunL()
   127 // CLandmarkManageObjects::RunL()
   114 			//Decrement index count since the present node
   143 			//Decrement index count since the present node
   115 			//has been deleted.
   144 			//has been deleted.
   116 			--i;
   145 			--i;
   117 			}
   146 			}
   118 		}
   147 		}
       
   148 	count = iDummyObjects.Count();
       
   149 	for (TInt i = 0; i < count; ++i)
       
   150 		{
       
   151 		if (!iDummyObjects[i]->IsActive())
       
   152 			{
       
   153 			delete iDummyObjects[i];
       
   154 			//Removes a node from the RPointerArray.
       
   155 			iDummyObjects.Remove(i);
       
   156 			//Decrement node count.
       
   157 			--count;
       
   158 			//Decrement index count since the present node
       
   159 			//has been deleted.
       
   160 			--i;
       
   161 			}
       
   162 		}
       
   163 	count = iOrgObjects.Count();
       
   164 	for (TInt i = 0; i < count; ++i)
       
   165 		{
       
   166 		if (!iOrgObjects[i]->IsActive())
       
   167 			{
       
   168 			delete iOrgObjects[i];
       
   169 			//Removes a node from the RPointerArray.
       
   170 			iOrgObjects.Remove(i);
       
   171 			//Decrement node count.
       
   172 			--count;
       
   173 			//Decrement index count since the present node
       
   174 			//has been deleted.
       
   175 			--i;
       
   176 			}
       
   177 		}
   119 	}
   178 	}
   120 
   179 
   121 // -----------------------------------------------------------------------------
   180 // -----------------------------------------------------------------------------
   122 // CLandmarkManageObjects::DoCancel()
   181 // CLandmarkManageObjects::DoCancel()
   123 // Cancel asynchronous call.
   182 // Cancel asynchronous call.