|
1 /* |
|
2 * Copyright (c) 2007 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 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_NATFWASYNCCALLBACK_H |
|
22 #define C_NATFWASYNCCALLBACK_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include "natfwcallbackinfo.h" |
|
27 |
|
28 // CLASS DECLARATION |
|
29 /** |
|
30 * CNatFwAsyncCallback is an active object used to guarantee that when the |
|
31 * function calls to the MNATFWConnectivityObserver are made, the upper layer |
|
32 * can delete any plugin related object it owns. |
|
33 */ |
|
34 NONSHARABLE_CLASS( CNatFwAsyncCallback ) : public CActive |
|
35 { |
|
36 public: // Constructor and destructor |
|
37 |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 */ |
|
41 static CNatFwAsyncCallback* NewL(); |
|
42 |
|
43 /** |
|
44 * Frees the resources of CNatFwAsyncCallback. Any issued callback |
|
45 * request that have not yet been executed, are discarded. |
|
46 * |
|
47 * @since s60 3.2 |
|
48 */ |
|
49 ~CNatFwAsyncCallback(); |
|
50 |
|
51 public: // New functions |
|
52 |
|
53 /** |
|
54 * Orders a specified callback function to be called, and provides all |
|
55 * necessary parameters. |
|
56 * |
|
57 * @since s60 3.2 |
|
58 * @param aController Event registration controller |
|
59 * @param aFunction Identifies the function of |
|
60 * MNATFWConnectivityObserver to use |
|
61 * @param aSessionId Session ID |
|
62 * @param aStreamId Stream ID |
|
63 * @param aErrorCode Error reason |
|
64 * @return void |
|
65 */ |
|
66 void MakeCallbackL( MNATFWRegistrationController& aController, |
|
67 CNatFwCallbackInfo::TFunction aFunction, |
|
68 TUint aSessionId, |
|
69 TUint aStreamId, |
|
70 TInt aErrorCode, |
|
71 TAny* aEventData ); |
|
72 |
|
73 /** |
|
74 * Removes all pending callbacks, which have the specified |
|
75 * stream ID as a parameter. |
|
76 * |
|
77 * @since s60 3.2 |
|
78 * @param aStreamId |
|
79 * @return void |
|
80 */ |
|
81 void CancelCallback( TUint aStreamId ); |
|
82 |
|
83 protected: // From CActive |
|
84 |
|
85 void DoCancel(); |
|
86 |
|
87 void RunL(); |
|
88 |
|
89 TInt RunError( TInt aError ); |
|
90 |
|
91 private: // Constructors |
|
92 |
|
93 CNatFwAsyncCallback(); |
|
94 |
|
95 private: // New functions, for internal use |
|
96 |
|
97 /** |
|
98 * Starts waiting for MakeCallbackL events. |
|
99 * |
|
100 * @since s60 3.2 |
|
101 * @return void |
|
102 */ |
|
103 void WaitForRequestsL(); |
|
104 |
|
105 /** |
|
106 * Wakes system up. |
|
107 * |
|
108 * @since s60 3.2 |
|
109 * @return void |
|
110 */ |
|
111 void Wakeup(); |
|
112 |
|
113 /** |
|
114 * Calls the oldest callback entry, if any. |
|
115 * |
|
116 * @since s60 3.2 |
|
117 * @return void |
|
118 */ |
|
119 void ExecuteFirstCallback(); |
|
120 |
|
121 private: // Data |
|
122 |
|
123 /** |
|
124 * Callback requests that have not yet been executed |
|
125 */ |
|
126 TSglQue<CNatFwCallbackInfo> iPendingCallbacks; |
|
127 }; |
|
128 |
|
129 #endif // C_NATFWASYNCCALLBACK_H |