|
1 /* |
|
2 * Copyright (c) 2006 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: XIMP Framework server event manager implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ximpeventmanager.h" |
|
19 #include "ximpeventcapsule.h" |
|
20 #include "ximpcontexteventqueue.h" |
|
21 #include "ximppsccontextimp.h" |
|
22 |
|
23 |
|
24 // ======== LOCAL FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // OrderOfEvents() |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 TInt OrderOfEvents( const CXIMPContextEventQueue& aFirst, const CXIMPContextEventQueue& aSecond ) |
|
31 { |
|
32 TUint32 firstSessionId = aFirst.SessionIdOfQueue(); |
|
33 TUint32 secondSessionId = aSecond.SessionIdOfQueue(); |
|
34 if( firstSessionId < secondSessionId ) |
|
35 { |
|
36 return -1; |
|
37 } |
|
38 else if( firstSessionId == secondSessionId ) |
|
39 { |
|
40 return 0; |
|
41 } |
|
42 else |
|
43 { |
|
44 return 1; |
|
45 } |
|
46 } |
|
47 |
|
48 // ======== MEMBER FUNCTIONS ======== |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CXIMPEventManager::CXIMPHostManager() |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CXIMPEventManager::CXIMPEventManager() |
|
55 { |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CXIMPEventManager::ConstructL() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CXIMPEventManager::ConstructL() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CXIMPEventManager::NewL() |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C CXIMPEventManager* CXIMPEventManager::NewL() |
|
73 { |
|
74 CXIMPEventManager* self = new( ELeave ) CXIMPEventManager; |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CXIMPEventManager::~CXIMPEventManager() |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CXIMPEventManager::~CXIMPEventManager() |
|
87 { |
|
88 iEventQueues.Close(); |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CXIMPEventManager::RegisterSessionQueueL() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C void CXIMPEventManager::RegisterSessionQueueL( CXIMPContextEventQueue& aQueue ) |
|
97 { |
|
98 TLinearOrder< CXIMPContextEventQueue > order( *OrderOfEvents ); |
|
99 iEventQueues.InsertInOrderL( &aQueue, order ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CXIMPEventManager::UnregisterSessionQueue() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C void CXIMPEventManager::UnregisterSessionQueue( CXIMPContextEventQueue& aQueue ) |
|
107 { |
|
108 TLinearOrder< CXIMPContextEventQueue > order( *OrderOfEvents ); |
|
109 TInt index = iEventQueues.FindInOrder( &aQueue, order ); |
|
110 if( index >= 0 ) |
|
111 { |
|
112 iEventQueues.Remove( index ); |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CXIMPEventManager::AddEventL() |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C void CXIMPEventManager::AddEventL( CXIMPApiEventBase& aEvent, |
|
121 CXIMPPscContext* aContext ) |
|
122 { |
|
123 if( aContext ) |
|
124 { |
|
125 RPointerArray< CXIMPPscContext > array; |
|
126 CleanupClosePushL( array ); |
|
127 array.AppendL( aContext ); |
|
128 AddEventL( aEvent, array ); |
|
129 CleanupStack::PopAndDestroy(); // array |
|
130 } |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CXIMPEventManager::ActivateEventL() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C void CXIMPEventManager::ActivateEventL( CXIMPApiEventBase& aEvent, |
|
138 CXIMPPscContext* aContext ) |
|
139 { |
|
140 if( aContext ) |
|
141 { |
|
142 aContext->EventQueue().ActivatePreservedEventL( aEvent ); |
|
143 } |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CXIMPEventManager::ActivateRequestCompleteEvent() |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 EXPORT_C void CXIMPEventManager::ActivateRequestCompleteEvent( CXIMPRequestCompleteEventImp& aEvent, |
|
151 CXIMPPscContext* aContext ) |
|
152 { |
|
153 if( aContext ) |
|
154 { |
|
155 aContext->EventQueue().ActivateRequestCompleteEvent( aEvent ); |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CXIMPEventManager::AddEventL() |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C void CXIMPEventManager::AddEventL( CXIMPApiEventBase& aEvent, |
|
164 RPointerArray< CXIMPPscContext >& aSessions ) |
|
165 { |
|
166 CXIMPEventCapsule* capsulatedEvent = CXIMPEventCapsule::NewL( aEvent ); |
|
167 CleanupClosePushL( *capsulatedEvent ); |
|
168 TInt sessionCount = aSessions.Count(); |
|
169 for( TInt a = 0; a < sessionCount; ++a ) |
|
170 { |
|
171 aSessions[ a ]->EventQueue().AddEventL( *capsulatedEvent ); |
|
172 } |
|
173 CleanupStack::PopAndDestroy( capsulatedEvent ); |
|
174 } |
|
175 |
|
176 |
|
177 // End of file |