|
1 /* |
|
2 * Copyright (c) 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: cache message change observer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CIMCACHEACCESSEVENTHANDLER_H__ |
|
20 #define __CIMCACHEACCESSEVENTHANDLER_H__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <s32mem.h> |
|
25 |
|
26 #include <imcachedefs.h> |
|
27 |
|
28 class MIMCacheClient; |
|
29 class MIMCacheEventHandler; |
|
30 |
|
31 /** |
|
32 * a class to listen to server cache message change |
|
33 */ |
|
34 NONSHARABLE_CLASS( CIMCacheAccessEventHandler ): public CActive |
|
35 { |
|
36 public: |
|
37 /** |
|
38 * Two-phased constructor. |
|
39 * @param aRegistrar ,client refence |
|
40 * @param aHandler a handler to send data to ui client |
|
41 */ |
|
42 static CIMCacheAccessEventHandler* NewL( MIMCacheClient& aRegistrar , |
|
43 MIMCacheEventHandler& aHandler ); |
|
44 /** |
|
45 * ~CIMCacheAccessEventHandler. |
|
46 */ |
|
47 virtual ~CIMCacheAccessEventHandler(); |
|
48 |
|
49 public: // From CActive |
|
50 |
|
51 /** |
|
52 * RunL |
|
53 */ |
|
54 void RunL(); |
|
55 |
|
56 /** |
|
57 * DoCancel |
|
58 */ |
|
59 void DoCancel(); |
|
60 |
|
61 /** |
|
62 * RunError |
|
63 */ |
|
64 TInt RunError( TInt /* aError */); |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 public : // new functions |
|
71 /** |
|
72 * UnRegisterObserver from server |
|
73 */ |
|
74 void UnRegisterObserver(); |
|
75 private: |
|
76 |
|
77 /** |
|
78 * default CIMCacheAccessEventHandler |
|
79 * @param aRegistrar ,client refence |
|
80 * @param aHandler a handler to send data to ui client |
|
81 */ |
|
82 CIMCacheAccessEventHandler( MIMCacheClient& aRegistrar, |
|
83 MIMCacheEventHandler& aHandler); |
|
84 /** |
|
85 * default ConstructL |
|
86 */ |
|
87 void ConstructL(); |
|
88 |
|
89 |
|
90 /** |
|
91 * Gets called when data update is available. |
|
92 * Client can then decide wether to use the old one |
|
93 * @param aBuffer structure of SIMCacheMessageData type |
|
94 */ |
|
95 void GetBufferChatDataL(); |
|
96 |
|
97 |
|
98 /** |
|
99 * Gets called when data update is available. |
|
100 * extract the chat data and send to client |
|
101 * @param aChatDataBuffer ,buffer containing number of chat data |
|
102 * @param aMore, indicate that there is still pending packets |
|
103 */ |
|
104 void InternalizeChatDataL( TPtr8 aChatDataBuffer , TBool& aMore ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Gets called when data update is available. |
|
109 * get data buffer from server |
|
110 * @param aEventType, type of data |
|
111 */ |
|
112 void GetBufferedChatItemL( TIMCacheEventType aEventType ); |
|
113 |
|
114 /** |
|
115 * read the stream and write into buffer |
|
116 * @param aEventType, type of data |
|
117 * @param aChatItemBuffer structure of SIMCacheContactData type |
|
118 */ |
|
119 |
|
120 void InternalizeChatItemL( TIMCacheEventType aEventType, |
|
121 TPtr8 aChatItemBuffer ); |
|
122 |
|
123 private: // data |
|
124 |
|
125 // doesn't own: registrar |
|
126 MIMCacheClient& iRegistrar; |
|
127 // owned , need to observer to server or not |
|
128 TBool iContinueObserving ; |
|
129 // client side observer event |
|
130 MIMCacheEventHandler& iAccessHandler; |
|
131 |
|
132 }; |
|
133 |
|
134 #endif // __CIMCACHEACCESSEVENTHANDLER_H__ |
|
135 |
|
136 |
|
137 // END OF FILE |
|
138 |