17 */ |
17 */ |
18 |
18 |
19 // SYSTEM INCLUDES |
19 // SYSTEM INCLUDES |
20 #include <hbdevicedialog.h> |
20 #include <hbdevicedialog.h> |
21 #include <hbindicator.h> |
21 #include <hbindicator.h> |
22 |
22 #include <qfileinfo.h> |
23 |
23 #include <qversitcontactimporter.h> |
|
24 #include <qversitreader.h> |
|
25 #include <qtcontacts.h> |
|
26 QTM_USE_NAMESPACE |
24 //USER INCLUDES |
27 //USER INCLUDES |
25 #include "msgnotifier.h" |
28 #include "msgnotifier.h" |
26 #include "msgnotifier_p.h" |
29 #include "msgnotifier_p.h" |
27 #include "msgsimnumberdetector.h" |
30 #include "msgsimnumberdetector.h" |
28 #include "msgnotificationdialogpluginkeys.h" |
31 #include "msgnotificationdialogpluginkeys.h" |
|
32 #include "msginfodefs.h" |
|
33 #include "ccsdefs.h" |
|
34 #include "unidatamodelloader.h" |
|
35 #include "unidatamodelplugininterface.h" |
29 #include "debugtraces.h" |
36 #include "debugtraces.h" |
30 |
37 |
|
38 // LOCALIZATION CONSTANTS |
|
39 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
|
40 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_dpopinfo_business_card") |
|
41 #define CARD_SEPERATOR "-" |
|
42 |
31 // plugin ids |
43 // plugin ids |
32 const QString InidcationsPluginId |
44 const QString IndicationsPluginId("com.nokia.messaging.newindicatorplugin"); |
33 ("com.nokia.messaging.indicatorplugin/1.0"); |
45 const QString PendingMsgPluginId("com.nokia.messaging.pendingindicatorplugin"); |
34 const QString NotificationPluginId |
46 const QString FailedMsgPluginId("com.nokia.messaging.failedindicatorplugin"); |
35 ("com.nokia.messaging.newmsgnotificationdialog/1.0"); |
47 const QString NotificationPluginId("com.nokia.messaging.newmsgnotificationdialog"); |
36 |
48 |
37 // ---------------------------------------------------------------------------- |
49 // ---------------------------------------------------------------------------- |
38 // MsgNotifier::MsgNotifier |
50 // MsgNotifier::MsgNotifier |
39 // @see MsgNotifier.h |
51 // @see MsgNotifier.h |
40 // ---------------------------------------------------------------------------- |
52 // ---------------------------------------------------------------------------- |
41 MsgNotifier::MsgNotifier(QObject* parent):QObject(parent) |
53 MsgNotifier::MsgNotifier(QObject* parent) : |
42 { |
54 QObject(parent) |
|
55 { |
43 QDEBUG_WRITE("MsgNotifier::MsgNotifier : Enter") |
56 QDEBUG_WRITE("MsgNotifier::MsgNotifier : Enter") |
44 |
57 |
45 d_ptr = new MsgNotifierPrivate(this); |
58 d_ptr = new MsgNotifierPrivate(this); |
46 |
59 |
47 mSimHandler = new MsgSimNumDetector(); |
60 mSimHandler = new MsgSimNumDetector(); |
48 |
61 |
49 QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit") |
62 QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit") |
50 } |
63 } |
51 |
64 |
52 // ---------------------------------------------------------------------------- |
65 // ---------------------------------------------------------------------------- |
53 // MsgNotifier::~MsgNotifier |
66 // MsgNotifier::~MsgNotifier |
54 // @see MsgNotifier.h |
67 // @see MsgNotifier.h |
55 // ---------------------------------------------------------------------------- |
68 // ---------------------------------------------------------------------------- |
56 MsgNotifier::~MsgNotifier() |
69 MsgNotifier::~MsgNotifier() |
57 { |
70 { |
58 QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") |
71 QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") |
59 |
72 |
60 delete d_ptr; |
73 delete d_ptr; |
61 delete mSimHandler; |
74 delete mSimHandler; |
62 |
75 |
63 QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") |
76 QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") |
64 } |
77 } |
65 |
|
66 |
|
67 |
78 |
68 // ---------------------------------------------------------------------------- |
79 // ---------------------------------------------------------------------------- |
69 // MsgNotifier::displayNewMessageNotification |
80 // MsgNotifier::displayNewMessageNotification |
70 // @see MsgNotifier.h |
81 // @see MsgNotifier.h |
71 // ---------------------------------------------------------------------------- |
82 // ---------------------------------------------------------------------------- |
72 void MsgNotifier::displayNewMessageNotification(NotificationData& data) |
83 void MsgNotifier::displayNewMessageNotification(NotificationData& data) |
73 { |
84 { |
74 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Enter") |
85 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Enter") |
75 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification :" |
86 QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification :" |
76 " Printing notification data") |
87 " Printing notification data") |
77 |
88 |
78 QDEBUG_WRITE_FORMAT("First Name : ", data.mFirstName); |
89 QDEBUG_WRITE_FORMAT("Name : ", data.mDisplayName); |
79 QDEBUG_WRITE_FORMAT("Last Name : ", data.mLastName); |
|
80 QDEBUG_WRITE_FORMAT("Number : ", data.mContactNum); |
90 QDEBUG_WRITE_FORMAT("Number : ", data.mContactNum); |
81 QDEBUG_WRITE_FORMAT("Description : ", data.mDescription); |
91 QDEBUG_WRITE_FORMAT("Description : ", data.mDescription); |
82 QDEBUG_WRITE_FORMAT("Type : ", data.mMsgType); |
92 QDEBUG_WRITE_FORMAT("Type : ", data.mMsgType); |
83 QDEBUG_WRITE_FORMAT("Conv Id : ", data.mConversationId); |
93 QDEBUG_WRITE_FORMAT("Conv Id : ", data.mConversationId); |
84 |
94 QDEBUG_WRITE_FORMAT("Msv Entry Id : ", data.msvEntryId); |
85 // Fill data to variant map |
95 // Fill data to variant map |
86 QVariantMap notificationData; |
96 QVariantMap notificationData; |
87 notificationData[QString(KFirstNameKey)] = data.mFirstName ; |
97 |
88 notificationData[QString(KLastNameKey)] = data.mLastName; |
98 //incase of BT messages show filename as description |
89 notificationData[QString(KNickNameKey)] = QString(); |
99 QString description; |
|
100 if ( ECsBlueTooth == data.mMsgType) |
|
101 { |
|
102 data.mDisplayName = LOC_RECEIVED_FILES; |
|
103 QFileInfo fileinfo(data.mDescription); |
|
104 description = fileinfo.fileName(); |
|
105 } |
|
106 else if ( ECsBioMsg_VCard == data.mMsgType) |
|
107 { |
|
108 UniDataModelLoader* pluginLoader = new UniDataModelLoader; |
|
109 UniDataModelPluginInterface* bioMsgPlugin = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg); |
|
110 bioMsgPlugin->setMessageId(data.msvEntryId); |
|
111 if (bioMsgPlugin->attachmentCount() > 0) |
|
112 { |
|
113 UniMessageInfoList attList = bioMsgPlugin->attachmentList(); |
|
114 QString attachmentPath = attList[0]->path(); |
|
115 description = LOC_BUSINESS_CARD; |
|
116 description.append(CARD_SEPERATOR); |
|
117 description.append(getVcardDisplayName(attachmentPath)); |
|
118 } |
|
119 delete pluginLoader; |
|
120 } |
|
121 else |
|
122 { |
|
123 description = data.mDescription; |
|
124 } |
|
125 notificationData[QString(KDisplayNameKey)] = data.mDisplayName ; |
90 notificationData[QString(KConversationIdKey)] = data.mConversationId; |
126 notificationData[QString(KConversationIdKey)] = data.mConversationId; |
91 notificationData[QString(KMessageTypeKey)] = data.mMsgType; |
127 notificationData[QString(KMessageTypeKey)] = data.mMsgType; |
92 notificationData[QString(KMessageBodyKey)] = data.mDescription; |
128 notificationData[QString(KMessageBodyKey)] = description; |
93 notificationData[QString(KMessageSubjectKey)] = QString(); |
129 notificationData[QString(KMessageSubjectKey)] = description; |
94 notificationData[QString(KContactAddressKey)] = data.mContactNum; |
130 notificationData[QString(KContactAddressKey)] = data.mContactNum; |
95 |
131 |
96 // call device dialog to show notification |
132 // call device dialog to show notification |
97 HbDeviceDialog deviceDialog ; |
133 HbDeviceDialog deviceDialog ; |
98 deviceDialog.show(NotificationPluginId,notificationData); |
134 deviceDialog.show(NotificationPluginId,notificationData); |
103 |
139 |
104 // ---------------------------------------------------------------------------- |
140 // ---------------------------------------------------------------------------- |
105 // MsgNotifier::updateIndications |
141 // MsgNotifier::updateIndications |
106 // @see MsgNotifier.h |
142 // @see MsgNotifier.h |
107 // ---------------------------------------------------------------------------- |
143 // ---------------------------------------------------------------------------- |
108 void MsgNotifier::updateIndications(int unreadCount) |
144 void MsgNotifier::updateUnreadIndications(int unreadCount) |
109 { |
145 { |
110 QDEBUG_WRITE("MsgNotifier::updateIndications Enter") |
146 QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Enter") |
111 |
147 |
112 HbIndicator indicator; |
148 HbIndicator indicator; |
113 if(unreadCount) |
149 if (unreadCount) { |
114 { |
150 QByteArray dataArray; |
115 indicator.activate(InidcationsPluginId); |
151 QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
116 QDEBUG_WRITE("MsgNotifier::updateIndications Indications Activated") |
152 MsgInfo info; |
117 } |
153 info.mIndicatorType = NewIndicatorPlugin; |
118 else |
154 |
119 { |
155 // only the unread count is used for unread indications as of now. |
120 indicator.deactivate(InidcationsPluginId); |
156 // the other values are not needed. |
121 QDEBUG_WRITE("MsgNotifier::updateIndications Indications Deactivated") |
157 |
122 } |
158 info.mMsgCount = unreadCount; |
123 |
159 info.mConversationId = -1; |
124 QDEBUG_WRITE("MsgNotifier::updateIndications Exit") |
160 |
125 } |
161 info.serialize(messageStream); |
126 |
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 //--------------------------------------------------------------- |
|
201 // MsgNotifier::getVcardDisplayName |
|
202 // @see header |
|
203 //--------------------------------------------------------------- |
|
204 QString MsgNotifier::getVcardDisplayName(const QString& filePath) |
|
205 { |
|
206 QString displayName; |
|
207 //open file for parsing |
|
208 QFile file(filePath); |
|
209 if (!file.open(QIODevice::ReadOnly)) { |
|
210 return displayName; |
|
211 } |
|
212 // parse contents |
|
213 QVersitReader reader; |
|
214 reader.setDevice(&file); |
|
215 if (reader.startReading()) { |
|
216 if (reader.waitForFinished()) { |
|
217 QList<QVersitDocument> versitDocuments = reader.results(); |
|
218 // Use the resulting document |
|
219 if (versitDocuments.count() > 0) { |
|
220 QVersitContactImporter importer; |
|
221 QList<QContact> contacts = importer.importContacts(versitDocuments); |
|
222 // get display-name |
|
223 if (contacts.count() > 0) { |
|
224 QContactManager* contactManager = new QContactManager("symbian"); |
|
225 displayName = contactManager->synthesizedDisplayLabel(contacts[0]); |
|
226 delete contactManager; |
|
227 } |
|
228 } |
|
229 } |
|
230 } |
|
231 file.close(); |
|
232 return displayName; |
|
233 } |
127 |
234 |
128 //EOF |
235 //EOF |