|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Class header for CWsfEventHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef C_WSFEVENTHANDLER_H |
|
23 #define C_WSFEVENTHANDLER_H |
|
24 |
|
25 // EXTERNAL INCLUDES |
|
26 #include <e32base.h> |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "wsfsession.h" |
|
30 #include "wsfservercommon.h" |
|
31 #include "wsfstatechangeobserver.h" |
|
32 |
|
33 |
|
34 // CLASS DEFINITION |
|
35 /** |
|
36 * Class to handle callbacks from the server |
|
37 * |
|
38 * CWsfEventHandler acts as a gateway between the client and the server. |
|
39 * Its main task is to hand over notifications of server events if the client |
|
40 * has requested that. |
|
41 * |
|
42 * @lib wsfclient.lib |
|
43 * @since S60 5.0 |
|
44 */ |
|
45 |
|
46 NONSHARABLE_CLASS( CWsfEventHandler ): public CActive |
|
47 { |
|
48 public: // Constructors and destructor |
|
49 /** |
|
50 * Factory function. |
|
51 * @since S60 5.0 |
|
52 * @param aSession Client-side handle to the server session |
|
53 * Ownership not passed. |
|
54 * @param aObserver The object which should be notified on event |
|
55 * Ownership not passed. |
|
56 */ |
|
57 static CWsfEventHandler* NewL( RWsfSession& aSession, |
|
58 MWsfStateChangeObserver& aObserver ); |
|
59 |
|
60 ~CWsfEventHandler(); |
|
61 |
|
62 |
|
63 private: |
|
64 /** |
|
65 * Constructor |
|
66 * @since S60 5.0 |
|
67 * @param aSession Client-side handle to the server session. |
|
68 * Ownership not passed. |
|
69 * @param aObserver The object which should be notified on event. |
|
70 * Ownership not passed. |
|
71 */ |
|
72 CWsfEventHandler( RWsfSession& aSession, |
|
73 MWsfStateChangeObserver& aObserver ); |
|
74 |
|
75 void ConstructL(); |
|
76 |
|
77 |
|
78 public: // new methods |
|
79 /** |
|
80 * Set the listening active object as active |
|
81 * @since S60 5.0 |
|
82 */ |
|
83 void Start(); |
|
84 |
|
85 /** |
|
86 * Get reference to the event container |
|
87 * @since S60 5.0 |
|
88 * @return Reference to the event container. |
|
89 */ |
|
90 TPckgBuf<TWsfNotifyEventContainer>& EventContainer(); |
|
91 |
|
92 /** |
|
93 * Change the event observer by resetting the reference |
|
94 * @since S60 5.0 |
|
95 * @param aObserver The object which should be notified on event. |
|
96 * Ownership not passed. |
|
97 */ |
|
98 void ResetObserver( MWsfStateChangeObserver& aObserver ); |
|
99 |
|
100 /** |
|
101 * Prevents the ongoing connecting process from notifying the observer |
|
102 * if the connecting flag is set |
|
103 * @since S60 5.0 |
|
104 */ |
|
105 void BlockNextConnectedEvent(); |
|
106 |
|
107 /** |
|
108 * Sets the connecting flag. Used by RWsfSession to mark the interval |
|
109 * of the connection creation. |
|
110 * @since S60 5.0 |
|
111 * @param aConnecting The value of the flag. |
|
112 */ |
|
113 void SetConnecting( TBool aConnecting ); |
|
114 |
|
115 /** |
|
116 * Gets the connecting flag. |
|
117 * @since S60 5.0 |
|
118 * @return The value of the flag. |
|
119 */ |
|
120 TBool Connecting() const; |
|
121 |
|
122 |
|
123 private: // from CActive |
|
124 void RunL(); |
|
125 void DoCancel(); |
|
126 TInt RunError( TInt aError ); |
|
127 |
|
128 private: |
|
129 /** |
|
130 * Handle the RunL trapped |
|
131 * @since S60 5.0 |
|
132 */ |
|
133 void DoRunL(); |
|
134 |
|
135 private: |
|
136 /** |
|
137 * Client-side handle for the server session. Not owned. |
|
138 */ |
|
139 RWsfSession* iSession; |
|
140 |
|
141 /** |
|
142 * The object which should be notified on event. Not owned. |
|
143 */ |
|
144 MWsfStateChangeObserver* iObserver; |
|
145 |
|
146 /** |
|
147 * Event container |
|
148 */ |
|
149 TPckgBuf<TWsfNotifyEventContainer> iEvent; |
|
150 |
|
151 /** |
|
152 * Indicates whether the connection created event should be suppressed |
|
153 */ |
|
154 TBool iBlockConnectedEvent; |
|
155 |
|
156 /** |
|
157 * Indicates whether there is an ongoing connecting process |
|
158 */ |
|
159 TBool iConnecting; |
|
160 |
|
161 }; |
|
162 |
|
163 |
|
164 #endif // C_WSFEVENTHANDLER_H |