|
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 #ifndef WAITINGEVENT_H |
|
18 #define WAITINGEVENT_H |
|
19 |
|
20 // INCLUDES |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 |
|
24 // CLASS DECLARATION |
|
25 |
|
26 |
|
27 /** |
|
28 * CWaitingEvent - class representing waiting events |
|
29 * Object of that type is created when there was a request for the event. |
|
30 * After event is requested, it can wait for another event. |
|
31 */ |
|
32 class CWaitingEvent : public CBase |
|
33 { |
|
34 public: |
|
35 // Destructor. |
|
36 ~CWaitingEvent(); |
|
37 |
|
38 // Two-phased constructor. |
|
39 static CWaitingEvent* NewL(const TDesC& aEventName, const TInt aCallerId); |
|
40 |
|
41 // Two-phased constructor. |
|
42 static CWaitingEvent* NewLC(const TDesC& aEventName, const TInt aCallerId); |
|
43 |
|
44 // Wait for event (allowed only if event is in requested state) |
|
45 void WaitL(const RMessage2& aMessage, const CSession2* aSession); |
|
46 |
|
47 // Complete waiting event |
|
48 void CompleteEventL(); |
|
49 |
|
50 // Cancel event |
|
51 void CancelEvent(void); |
|
52 |
|
53 // Checks if event name is the same as provided in argument |
|
54 TInt IsMatchingEvent(const TDesC& aEventName, const TInt aCallerId); |
|
55 |
|
56 // Checks if event name is the same as provided in argument |
|
57 TInt IsMatchingEvent(const TDesC& aEventName); |
|
58 |
|
59 // Checks if event's session is the same as provided in argument |
|
60 TInt IsMatchingSession(const CSession2* aSession); |
|
61 |
|
62 // Give event name |
|
63 const TDesC& EventName(); |
|
64 |
|
65 // Check if event is in requested state |
|
66 TInt IsRequested(); |
|
67 |
|
68 // Check if event is waitng |
|
69 TInt IsWaiting(); |
|
70 |
|
71 // Notify requested event, that indicatin event |
|
72 void NotifyRequestedEventL(); |
|
73 |
|
74 // Give owner id |
|
75 TInt OwnerId(); |
|
76 private: |
|
77 // Shows current state of the event |
|
78 enum TEventState |
|
79 { |
|
80 EEventRequested, |
|
81 EEventWaiting |
|
82 }; |
|
83 |
|
84 // Constructor for performing 1st stage construction |
|
85 CWaitingEvent(const TInt aCallerId); |
|
86 |
|
87 // Constructor for performing 2nd stage construction |
|
88 void ConstructL(const TDesC& aEventName); |
|
89 |
|
90 // Panics the client |
|
91 void PanicClient(const RMessage2& aMessage, const TInt aPanic) const; |
|
92 |
|
93 private: |
|
94 // Event name |
|
95 HBufC* iEventName; |
|
96 |
|
97 // Owner id. The same named waiting event may be requested by different callers - so we need to distinguish them |
|
98 const TInt iOwnerId; |
|
99 |
|
100 // Message to complete with event |
|
101 RMessage2* iMessage; |
|
102 |
|
103 // Session of the waiting event |
|
104 CSession2* iSession; |
|
105 |
|
106 // State of the event |
|
107 TEventState iState; |
|
108 |
|
109 // Defines if indication event was set in the moment when this waiting event was in requested state |
|
110 TBool iEventSetWhenRequested; |
|
111 }; |
|
112 |
|
113 #endif // WAITINGEVENT_H |
|
114 |
|
115 // EOF |