|
1 /* |
|
2 * Copyright (c) 2009 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: Listen to conversation server events and parse the |
|
15 * events. These parse infomation passed to notifications and indications. |
|
16 * |
|
17 */ |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <msvapi.h> |
|
21 #include <ccsclientconversation.h> |
|
22 #include <ccsrequesthandler.h> |
|
23 #include <ccsconversationentry.h> |
|
24 |
|
25 //USER INCLUDES |
|
26 #include "msgnotifier.h" |
|
27 #include "msgnotifier_p.h" |
|
28 #include "s60qconversions.h" |
|
29 |
|
30 #include <QtDebug> |
|
31 |
|
32 #define QDEBUG_WRITE(str) {qDebug() << str;} |
|
33 #define QDEBUG_WRITE_FORMAT(str, val) {qDebug() << str << val;} |
|
34 #define QCRITICAL_WRITE(str) {qCritical() << str;} |
|
35 #define QCRITICAL_WRITE_FORMAT(str, val) {qCritical() << str << val;} |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // MsgNotifierPrivate::MsgNotifierPrivate |
|
39 // @see MsgNotifierPrivate.h |
|
40 // ---------------------------------------------------------------------------- |
|
41 MsgNotifierPrivate::MsgNotifierPrivate(MsgNotifier* MsgNotifier): |
|
42 q_ptr(MsgNotifier), |
|
43 mCvServer(NULL) |
|
44 { |
|
45 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Enter") |
|
46 TRAP_IGNORE(initL()); |
|
47 QDEBUG_WRITE("MsgNotifierPrivate::MsgNotifierPrivate : Exit") |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // MsgNotifierPrivate::~MsgNotifierPrivate |
|
52 // @see MsgNotifierPrivate.h |
|
53 // ---------------------------------------------------------------------------- |
|
54 MsgNotifierPrivate::~MsgNotifierPrivate() |
|
55 { |
|
56 QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Enter") |
|
57 if(mCvServer) |
|
58 { |
|
59 mCvServer->RemoveConversationListChangeEventL (this); |
|
60 delete mCvServer; |
|
61 mCvServer = NULL; |
|
62 } |
|
63 QDEBUG_WRITE("MsgNotifierPrivate::~MsgNotifierPrivate : Exit") |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // MsgNotifierPrivate::initL |
|
68 // @see MsgNotifierPrivate.h |
|
69 // ---------------------------------------------------------------------------- |
|
70 void MsgNotifierPrivate::initL() |
|
71 { |
|
72 QDEBUG_WRITE("MsgNotifierPrivate::initL : Enter") |
|
73 |
|
74 mCvServer = CCSRequestHandler::NewL(); |
|
75 mCvServer->RequestConversationListChangeEventL(this); |
|
76 updateIndications(); |
|
77 |
|
78 QDEBUG_WRITE("MsgNotifierPrivate::initL : Exit") |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // MsgNotifierPrivate::AddConversationList |
|
83 // @see MsgNotifierPrivate.h |
|
84 // ---------------------------------------------------------------------------- |
|
85 void MsgNotifierPrivate::AddConversationList( |
|
86 const CCsClientConversation& aClientConversation) |
|
87 { |
|
88 QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Enter") |
|
89 |
|
90 processListEntry(aClientConversation); |
|
91 updateIndications(); |
|
92 |
|
93 QDEBUG_WRITE("MsgNotifierPrivate::AddConversationList : Exit") |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // MsgNotifierPrivate::DeleteConversationList |
|
98 // @see MsgNotifierPrivate.h |
|
99 // ---------------------------------------------------------------------------- |
|
100 void MsgNotifierPrivate::DeleteConversationList( |
|
101 const CCsClientConversation& /*aClientConversation*/) |
|
102 { |
|
103 QDEBUG_WRITE("MsgNotifierPrivate::DeleteConversationList : Enter") |
|
104 updateIndications(); |
|
105 QDEBUG_WRITE("MsgNotifierPrivate::DeleteConversationList : Exit") |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // MsgNotifierPrivate::ModifyConversationList |
|
110 // @see MsgNotifierPrivate.h |
|
111 // ---------------------------------------------------------------------------- |
|
112 void MsgNotifierPrivate:: ModifyConversationList( |
|
113 const CCsClientConversation& aClientConversation) |
|
114 { |
|
115 QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Enter") |
|
116 |
|
117 processListEntry(aClientConversation); |
|
118 updateIndications(); |
|
119 |
|
120 QDEBUG_WRITE("MsgNotifierPrivate::ModifyConversationList : Exit") |
|
121 } |
|
122 |
|
123 // ---------------------------------------------------------------------------- |
|
124 // MsgNotifierPrivate::RefreshConversationList |
|
125 // @see MsgNotifierPrivate.h |
|
126 // ---------------------------------------------------------------------------- |
|
127 void MsgNotifierPrivate::RefreshConversationList() |
|
128 { |
|
129 |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // MsgNotifierPrivate::processListEntry |
|
134 // @see MsgNotifierPrivate.h |
|
135 // ---------------------------------------------------------------------------- |
|
136 void MsgNotifierPrivate::processListEntry( |
|
137 const CCsClientConversation& aClientConversation) |
|
138 { |
|
139 QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Enter") |
|
140 |
|
141 CCsConversationEntry* convEntry = |
|
142 aClientConversation.GetConversationEntry(); |
|
143 |
|
144 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry Direction", |
|
145 convEntry->ConversationDir()) |
|
146 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry New Entry Attribute", |
|
147 convEntry->IsAttributeSet(ECsAttributeNewEntryAdded)) |
|
148 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::processListEntry Unread Attribute", |
|
149 convEntry->IsAttributeSet(ECsAttributeUnread)) |
|
150 |
|
151 bool newFlag=convEntry->IsAttributeSet(ECsAttributeNewEntryAdded); |
|
152 |
|
153 if((convEntry->ConversationDir() == ECsDirectionIncoming) |
|
154 && convEntry->IsAttributeSet(ECsAttributeNewEntryAdded) |
|
155 && convEntry->IsAttributeSet(ECsAttributeUnread)) |
|
156 { |
|
157 QDEBUG_WRITE("processListEntry : Processing data for Notification") |
|
158 |
|
159 NotificationData notifData; |
|
160 |
|
161 notifData.mConversationId = aClientConversation.GetConversationEntryId(); |
|
162 notifData.mMsgType = convEntry->GetType(); |
|
163 |
|
164 HBufC* firstName = aClientConversation.GetFirstName(); |
|
165 HBufC* lastName = aClientConversation.GetLastName(); |
|
166 HBufC* number = convEntry->Contact(); |
|
167 HBufC* descrp = convEntry->Description(); |
|
168 |
|
169 if(firstName) |
|
170 { |
|
171 notifData.mFirstName = |
|
172 S60QConversions::s60DescToQString(*firstName); |
|
173 } |
|
174 if(lastName) |
|
175 { |
|
176 notifData.mLastName = S60QConversions::s60DescToQString(*lastName); |
|
177 } |
|
178 if(number) |
|
179 { |
|
180 notifData.mContactNum = S60QConversions::s60DescToQString(*number); |
|
181 } |
|
182 if(descrp) |
|
183 { |
|
184 notifData.mDescription = S60QConversions::s60DescToQString(*descrp); |
|
185 } |
|
186 |
|
187 q_ptr->displayNewMessageNotification(notifData); |
|
188 |
|
189 QDEBUG_WRITE("processListEntry : Notification display called") |
|
190 } |
|
191 |
|
192 QDEBUG_WRITE("MsgNotifierPrivate::processListEntry : Exit") |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // MsgNotifierPrivate::updateIndications |
|
197 // @see MsgNotifierPrivate.h |
|
198 // ---------------------------------------------------------------------------- |
|
199 void MsgNotifierPrivate::updateIndications() |
|
200 { |
|
201 QDEBUG_WRITE("MsgNotifierPrivate::updateIndicationsL : Enter") |
|
202 |
|
203 int unreadCount(0); |
|
204 TRAP_IGNORE(unreadCount = mCvServer->GetTotalUnreadCountL()); |
|
205 |
|
206 QDEBUG_WRITE_FORMAT("MsgNotifierPrivate::" |
|
207 "updateIndications unreadCount = ",unreadCount ); |
|
208 |
|
209 //activate or deactivate indications based on unread count |
|
210 q_ptr->updateIndications(unreadCount); |
|
211 |
|
212 QDEBUG_WRITE("MsgNotifierPrivate::updateIndicationsL : Exit") |
|
213 } |
|
214 //EOF |