|
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: Notification server main class. |
|
15 * Handles calling notifications and inidcations |
|
16 * |
|
17 */ |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <hbdevicedialog.h> |
|
21 #include <hbindicator.h> |
|
22 #include <qfileinfo.h> |
|
23 |
|
24 //USER INCLUDES |
|
25 #include "msgnotifier.h" |
|
26 #include "msgnotifier_p.h" |
|
27 #include "msgsimnumberdetector.h" |
|
28 #include "msgnotificationdialogpluginkeys.h" |
|
29 #include "msginfodefs.h" |
|
30 #include "ccsdefs.h" |
|
31 #include "unidatamodelloader.h" |
|
32 #include "unidatamodelplugininterface.h" |
|
33 #include "msgcontacthandler.h" |
|
34 |
|
35 #include "debugtraces.h" |
|
36 |
|
37 // LOCALIZATION CONSTANTS |
|
38 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
|
39 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_dpopinfo_business_card") |
|
40 #define CARD_SEPERATOR "-" |
|
41 |
|
42 // plugin ids |
|
43 const QString IndicationsPluginId("com.nokia.messaging.newindicatorplugin"); |
|
44 const QString PendingMsgPluginId("com.nokia.messaging.pendingindicatorplugin"); |
|
45 const QString FailedMsgPluginId("com.nokia.messaging.failedindicatorplugin"); |
|
46 const QString NotificationPluginId("com.nokia.messaging.newmsgnotificationdialog"); |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // MsgNotifier::MsgNotifier |
|
50 // @see MsgNotifier.h |
|
51 // ---------------------------------------------------------------------------- |
|
52 MsgNotifier::MsgNotifier(QObject* parent) : |
|
53 QObject(parent) |
|
54 { |
|
55 QDEBUG_WRITE("MsgNotifier::MsgNotifier : Enter") |
|
56 |
|
57 d_ptr = new MsgNotifierPrivate(this); |
|
58 |
|
59 mSimHandler = new MsgSimNumDetector(); |
|
60 |
|
61 QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit") |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // MsgNotifier::~MsgNotifier |
|
66 // @see MsgNotifier.h |
|
67 // ---------------------------------------------------------------------------- |
|
68 MsgNotifier::~MsgNotifier() |
|
69 { |
|
70 QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") |
|
71 |
|
72 delete d_ptr; |
|
73 delete mSimHandler; |
|
74 |
|
75 QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------------------------- |
|
79 // MsgNotifier::displayNewMessageNotification |
|
80 // @see MsgNotifier.h |
|
81 // ---------------------------------------------------------------------------- |
|
82 void MsgNotifier::displayNewMessageNotification(NotificationData& data) |
|
83 { |
|
84 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Enter") |
|
85 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification :" |
|
86 " Printing notification data") |
|
87 |
|
88 QDEBUG_WRITE_FORMAT("Name : ", data.mDisplayName); |
|
89 QDEBUG_WRITE_FORMAT("Number : ", data.mContactNum); |
|
90 QDEBUG_WRITE_FORMAT("Description : ", data.mDescription); |
|
91 QDEBUG_WRITE_FORMAT("Type : ", data.mMsgType); |
|
92 QDEBUG_WRITE_FORMAT("Conv Id : ", data.mConversationId); |
|
93 QDEBUG_WRITE_FORMAT("Msv Entry Id : ", data.msvEntryId); |
|
94 // Fill data to variant map |
|
95 QVariantMap notificationData; |
|
96 |
|
97 //incase of BT messages show filename as description |
|
98 QString description; |
|
99 if ( ECsBlueTooth == data.mMsgType) |
|
100 { |
|
101 data.mDisplayName = LOC_RECEIVED_FILES; |
|
102 QFileInfo fileinfo(data.mDescription); |
|
103 description = fileinfo.fileName(); |
|
104 } |
|
105 else if ( ECsBioMsg_VCard == data.mMsgType) |
|
106 { |
|
107 UniDataModelLoader* pluginLoader = new UniDataModelLoader; |
|
108 UniDataModelPluginInterface* bioMsgPlugin = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg); |
|
109 bioMsgPlugin->setMessageId(data.msvEntryId); |
|
110 if (bioMsgPlugin->attachmentCount() > 0) |
|
111 { |
|
112 UniMessageInfoList attList = bioMsgPlugin->attachmentList(); |
|
113 QString attachmentPath = attList[0]->path(); |
|
114 description = LOC_BUSINESS_CARD; |
|
115 description.append(CARD_SEPERATOR); |
|
116 description.append( |
|
117 MsgContactHandler::getVCardDisplayName(attachmentPath)); |
|
118 } |
|
119 delete pluginLoader; |
|
120 } |
|
121 else |
|
122 { |
|
123 description = data.mDescription; |
|
124 } |
|
125 notificationData[QString(KDisplayNameKey)] = data.mDisplayName ; |
|
126 notificationData[QString(KConversationIdKey)] = data.mConversationId; |
|
127 notificationData[QString(KMessageTypeKey)] = data.mMsgType; |
|
128 notificationData[QString(KMessageBodyKey)] = description; |
|
129 notificationData[QString(KMessageSubjectKey)] = description; |
|
130 notificationData[QString(KContactAddressKey)] = data.mContactNum; |
|
131 |
|
132 // call device dialog to show notification |
|
133 HbDeviceDialog deviceDialog ; |
|
134 deviceDialog.show(NotificationPluginId,notificationData); |
|
135 |
|
136 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Exit") |
|
137 } |
|
138 |
|
139 |
|
140 // ---------------------------------------------------------------------------- |
|
141 // MsgNotifier::updateIndications |
|
142 // @see MsgNotifier.h |
|
143 // ---------------------------------------------------------------------------- |
|
144 void MsgNotifier::updateUnreadIndications(int unreadCount) |
|
145 { |
|
146 QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Enter") |
|
147 |
|
148 HbIndicator indicator; |
|
149 if (unreadCount) { |
|
150 QByteArray dataArray; |
|
151 QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
152 MsgInfo info; |
|
153 info.mIndicatorType = NewIndicatorPlugin; |
|
154 |
|
155 // only the unread count is used for unread indications as of now. |
|
156 // the other values are not needed. |
|
157 |
|
158 info.mMsgCount = unreadCount; |
|
159 info.mConversationId = -1; |
|
160 |
|
161 info.serialize(messageStream); |
|
162 QVariant parameter(dataArray); |
|
163 |
|
164 indicator.activate(IndicationsPluginId, parameter); |
|
165 QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Indications Activated") |
|
166 } |
|
167 else { |
|
168 indicator.deactivate(IndicationsPluginId); |
|
169 QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Indications Deactivated") |
|
170 } |
|
171 |
|
172 QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Exit") |
|
173 } |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // MsgNotifier::updateOutboxIndications |
|
177 // @see MsgNotifier.h |
|
178 // ---------------------------------------------------------------------------- |
|
179 void MsgNotifier::updateOutboxIndications(MsgInfo& data) |
|
180 { |
|
181 QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Enter") |
|
182 |
|
183 HbIndicator indicator; |
|
184 if (data.mMsgCount) { |
|
185 QByteArray dataArray; |
|
186 QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
187 data.serialize(messageStream); |
|
188 QVariant parameter(dataArray); |
|
189 indicator.activate(indicatorName(data.mIndicatorType), parameter); |
|
190 QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Indications Activated") |
|
191 } |
|
192 else { |
|
193 indicator.deactivate(indicatorName(data.mIndicatorType)); |
|
194 QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Indications Deactivated") |
|
195 } |
|
196 |
|
197 QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Exit") |
|
198 } |
|
199 |
|
200 //EOF |