2
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <e32std.h>
|
|
18 |
#include <e32svr.h>
|
|
19 |
|
|
20 |
#include <stfeventsystemerrorcodes.h>
|
|
21 |
#include "stfasynceventlist.h"
|
|
22 |
#include <stfasynceventactive.h>
|
|
23 |
|
|
24 |
|
|
25 |
// Implementation of list of asynchronous events
|
|
26 |
|
|
27 |
/**
|
|
28 |
*/
|
|
29 |
EXPORT_C CAsyncEventList* CAsyncEventList::NewL()
|
|
30 |
{
|
|
31 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::NewL()"));
|
|
32 |
CAsyncEventList* self = new (ELeave) CAsyncEventList();
|
|
33 |
CleanupStack::PushL(self);
|
|
34 |
|
|
35 |
// Construct the object
|
|
36 |
self->ConstructL();
|
|
37 |
|
|
38 |
// Remove from cleanup stack
|
|
39 |
CleanupStack::Pop(self);
|
|
40 |
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
/**
|
|
45 |
*/
|
|
46 |
void CAsyncEventList::ConstructL()
|
|
47 |
{
|
|
48 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::ConstructL()"));
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
*/
|
|
53 |
CAsyncEventList::CAsyncEventList()
|
|
54 |
{
|
|
55 |
RDebug::Print(_L("STF [ESC]: CAsyncEventList::CAsyncEventList()"));
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
|
59 |
*/
|
|
60 |
EXPORT_C CAsyncEventList::~CAsyncEventList()
|
|
61 |
{
|
|
62 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::~CAsyncEventList() #1-start"));
|
|
63 |
CancelAllAsyncEvents();
|
|
64 |
iAsyncEvents.ResetAndDestroy();
|
|
65 |
iAsyncEvents.Close();
|
|
66 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::~CAsyncEventList() #1-end"));
|
|
67 |
}
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Add active object to the list.
|
|
71 |
*/
|
|
72 |
EXPORT_C void CAsyncEventList::AddAsyncEventL(CAsyncEventActive* aAsyncEvent)
|
|
73 |
{
|
|
74 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::AddAsyncEventL()"));
|
|
75 |
if(iAsyncEvents.Find(aAsyncEvent) >= 0)
|
|
76 |
{
|
|
77 |
User::Leave(KErrAlreadyExists);
|
|
78 |
}
|
|
79 |
iAsyncEvents.AppendL(aAsyncEvent);
|
|
80 |
}
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Remove active object from the list.
|
|
84 |
*/
|
|
85 |
EXPORT_C void CAsyncEventList::RemoveAsyncEventL(CAsyncEventActive* aAsyncEvent)
|
|
86 |
{
|
|
87 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::RemoveAsyncEventL()"));
|
|
88 |
TInt index = iAsyncEvents.Find(aAsyncEvent);
|
|
89 |
//RDebug::Print(_L("STF [ESC]: CAsyncEventList::RemoveAsyncEventL() index=[%d]"), index);
|
|
90 |
if(index >= 0)
|
|
91 |
{
|
|
92 |
iAsyncEvents.Remove(index);
|
|
93 |
}
|
|
94 |
}
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Cancel and remove all active objects from the list.
|
|
98 |
*/
|
|
99 |
void CAsyncEventList::CancelAllAsyncEvents()
|
|
100 |
{
|
|
101 |
RDebug::Print(_L("STF [ESC]: CAsyncEventList::CancelAllAsyncEvents()"));
|
|
102 |
while(iAsyncEvents.Count())
|
|
103 |
{
|
|
104 |
CAsyncEventActive* asyncEvent = iAsyncEvents[0];
|
|
105 |
asyncEvent->Cancel();
|
|
106 |
iAsyncEvents.Remove(0);
|
|
107 |
delete asyncEvent;
|
|
108 |
}
|
|
109 |
}
|