|
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: message handler notification |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CSERVICEWIDGETMESSAGEHANDLER_H |
|
22 #define CSERVICEWIDGETMESSAGEHANDLER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 // imcache |
|
26 #include <mimcacheeventhandler.h> |
|
27 #include <imcachedefs.h> |
|
28 |
|
29 // farword declaration |
|
30 class MIMCacheAccessor; |
|
31 class CIMCacheFactory; |
|
32 class MServiceWidgetNewMessageObserver; |
|
33 |
|
34 const TUid KConversationViewAppUid = {0x20012425}; |
|
35 const TUid KIMPhoneBookUid = {0x101f4cce}; |
|
36 |
|
37 /** |
|
38 * @class im cache message handler class implementation |
|
39 * @since 5.0 |
|
40 */ |
|
41 |
|
42 class CServiceWidgetMessageHandler : public CBase, |
|
43 public MIMCacheEventHandler |
|
44 { |
|
45 |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 * @param aMessageObserver, refernce to content handler |
|
51 * @param aServiceId, service id to monitor |
|
52 * @param aOwnUserId, own user id |
|
53 */ |
|
54 static CServiceWidgetMessageHandler* NewL(MServiceWidgetNewMessageObserver& aMessageObserver, |
|
55 TInt aServiceId, |
|
56 const TDesC& aOwnUserId ); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * @param aMessageObserver, refernce to content handler |
|
61 * @param aServiceId, service id to monitor |
|
62 * @param aOwnUserId, own user id |
|
63 */ |
|
64 static CServiceWidgetMessageHandler* NewLC(MServiceWidgetNewMessageObserver& aMessageObserver, |
|
65 TInt aServiceId, |
|
66 const TDesC& aOwnUserId ); |
|
67 |
|
68 /** |
|
69 * Standard C++ destructor |
|
70 */ |
|
71 ~CServiceWidgetMessageHandler(); |
|
72 |
|
73 public : // new methods |
|
74 |
|
75 /** |
|
76 * get the unread counts |
|
77 * @return count |
|
78 */ |
|
79 TInt GetUnreadMessageCountL(); |
|
80 |
|
81 /** |
|
82 * get the unread sender |
|
83 * @return sender |
|
84 */ |
|
85 const TDesC& GetUnreadSenderId() ; |
|
86 |
|
87 /** check if only one sender or multiple |
|
88 * @return ETrue or False |
|
89 */ |
|
90 TBool IsSingleMessageSender(); |
|
91 |
|
92 |
|
93 public: // from MIMCacheEventHandler |
|
94 |
|
95 /** |
|
96 * Gets called when data update is available. |
|
97 * Client can then decide wether to use the old one |
|
98 * or the updated one. |
|
99 * @param aNewMessage, new message details |
|
100 */ |
|
101 void HandleIMCacheEventL(TIMCacheEventType aEvent, TAny* aChatMessage = NULL ) ; |
|
102 |
|
103 |
|
104 |
|
105 private: // Implementation |
|
106 |
|
107 /** |
|
108 * Standard C++ constructor |
|
109 */ |
|
110 CServiceWidgetMessageHandler(MServiceWidgetNewMessageObserver& aMessageObserver ); |
|
111 |
|
112 /** |
|
113 * Performs the 2nd phase of construction. |
|
114 * @param aOwnUserId, user id |
|
115 */ |
|
116 void ConstructL( const TDesC& aOwnUserId, TInt aServiceId ); |
|
117 |
|
118 /** |
|
119 * serach the given id in array |
|
120 * @param aNewSenderId, sender user id |
|
121 * @return ETrue if found |
|
122 */ |
|
123 TBool IsExistInSendersArrayL( const TDesC& aNewSenderId ) ; |
|
124 |
|
125 /** |
|
126 * synchronized the senders array by deleting the sender |
|
127 * which is not having any unread message |
|
128 */ |
|
129 void SynchronizeSendersArrayL() ; |
|
130 |
|
131 /* |
|
132 * plays the msg tone for incoming messages |
|
133 * |
|
134 */ |
|
135 void PlayMsgAlertToneL(); |
|
136 |
|
137 private: // Data |
|
138 // not owns , reference to contententpritizer |
|
139 MServiceWidgetNewMessageObserver& iMessageObserver; |
|
140 // owns : im cache accessor |
|
141 MIMCacheAccessor* iAccessor; |
|
142 //owns : im cache factory |
|
143 CIMCacheFactory* iIMCacheFactory; |
|
144 // owns : sender is unique or multiple sender |
|
145 RPointerArray<HBufC> iSendersArray; |
|
146 }; |
|
147 |
|
148 #endif /*CSERVICEWIDGETMESSAGEHANDLER_H*/ |
|
149 |