| author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> | 
| Wed, 18 Aug 2010 09:45:25 +0300 | |
| changeset 52 | 12db4185673b | 
| parent 31 | ebfee66fde93 | 
| child 70 | a15d9966050f | 
| permissions | -rw-r--r-- | 
| 31 | 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 | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 38 | #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 39 | #define LOC_BUSINESS_CARD hbTrId("txt_messaging_dpopinfo_business_card")
 | 
| 31 | 40 | #define CARD_SEPERATOR "-" | 
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 41 | #define LOC_MULTIMEDIA_MSG hbTrId("txt_messaging_dpopinfo_multimedia_message")
 | 
| 31 | 42 | |
| 43 | // plugin ids | |
| 44 | const QString IndicationsPluginId("com.nokia.messaging.newindicatorplugin");
 | |
| 45 | const QString PendingMsgPluginId("com.nokia.messaging.pendingindicatorplugin");
 | |
| 46 | const QString FailedMsgPluginId("com.nokia.messaging.failedindicatorplugin");
 | |
| 47 | const QString NotificationPluginId("com.nokia.messaging.newmsgnotificationdialog");
 | |
| 48 | ||
| 49 | // ---------------------------------------------------------------------------- | |
| 50 | // MsgNotifier::MsgNotifier | |
| 51 | // @see MsgNotifier.h | |
| 52 | // ---------------------------------------------------------------------------- | |
| 53 | MsgNotifier::MsgNotifier(QObject* parent) : | |
| 54 | QObject(parent) | |
| 55 | {
 | |
| 56 |     QDEBUG_WRITE("MsgNotifier::MsgNotifier : Enter")
 | |
| 57 | ||
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 58 | d_ptr = q_check_ptr(new MsgNotifierPrivate(this)); | 
| 31 | 59 | |
| 60 | mSimHandler = new MsgSimNumDetector(); | |
| 61 | ||
| 62 |     QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit")
 | |
| 63 | } | |
| 64 | ||
| 65 | // ---------------------------------------------------------------------------- | |
| 66 | // MsgNotifier::~MsgNotifier | |
| 67 | // @see MsgNotifier.h | |
| 68 | // ---------------------------------------------------------------------------- | |
| 69 | MsgNotifier::~MsgNotifier() | |
| 70 | {
 | |
| 71 |     QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter")
 | |
| 72 | ||
| 73 | delete d_ptr; | |
| 74 | delete mSimHandler; | |
| 75 | ||
| 76 |     QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter")
 | |
| 77 | } | |
| 78 | ||
| 79 | // ---------------------------------------------------------------------------- | |
| 80 | // MsgNotifier::displayNewMessageNotification | |
| 81 | // @see MsgNotifier.h | |
| 82 | // ---------------------------------------------------------------------------- | |
| 83 | void MsgNotifier::displayNewMessageNotification(NotificationData& data) | |
| 84 | {
 | |
| 85 |     QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Enter")
 | |
| 86 |     QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification :"
 | |
| 87 | " Printing notification data") | |
| 88 | ||
| 89 |     QDEBUG_WRITE_FORMAT("Name : ", data.mDisplayName);
 | |
| 90 |     QDEBUG_WRITE_FORMAT("Number : ", data.mContactNum);
 | |
| 91 |     QDEBUG_WRITE_FORMAT("Description : ", data.mDescription);
 | |
| 92 |     QDEBUG_WRITE_FORMAT("Type : ", data.mMsgType);
 | |
| 93 |     QDEBUG_WRITE_FORMAT("Conv Id : ", data.mConversationId);
 | |
| 94 |     QDEBUG_WRITE_FORMAT("Msv Entry Id : ", data.msvEntryId);
 | |
| 95 | // Fill data to variant map | |
| 96 | QVariantMap notificationData; | |
| 97 | ||
| 98 | //incase of BT messages show filename as description | |
| 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( | |
| 118 | MsgContactHandler::getVCardDisplayName(attachmentPath)); | |
| 119 | } | |
| 120 | delete pluginLoader; | |
| 121 | } | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 122 | else if( data.mDescription.isEmpty() && (ECsMMS == data.mMsgType || ECsAudio == data.mMsgType) ) | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 123 |         {
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 124 | description = LOC_MULTIMEDIA_MSG; | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 125 | } | 
| 31 | 126 | else | 
| 127 |         {
 | |
| 128 | description = data.mDescription; | |
| 129 | } | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 130 | |
| 31 | 131 | notificationData[QString(KDisplayNameKey)] = data.mDisplayName ; | 
| 132 | notificationData[QString(KConversationIdKey)] = data.mConversationId; | |
| 133 | notificationData[QString(KMessageTypeKey)] = data.mMsgType; | |
| 134 | notificationData[QString(KMessageBodyKey)] = description; | |
| 135 | notificationData[QString(KMessageSubjectKey)] = description; | |
| 136 | notificationData[QString(KContactAddressKey)] = data.mContactNum; | |
| 137 | ||
| 138 | // call device dialog to show notification | |
| 139 | HbDeviceDialog deviceDialog ; | |
| 140 | deviceDialog.show(NotificationPluginId,notificationData); | |
| 141 | ||
| 142 |     QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Exit")
 | |
| 143 | } | |
| 144 | ||
| 145 | ||
| 146 | // ---------------------------------------------------------------------------- | |
| 147 | // MsgNotifier::updateIndications | |
| 148 | // @see MsgNotifier.h | |
| 149 | // ---------------------------------------------------------------------------- | |
| 150 | void MsgNotifier::updateUnreadIndications(int unreadCount) | |
| 151 | {
 | |
| 152 |     QDEBUG_WRITE("MsgNotifier::updateUnreadIndications  Enter")
 | |
| 153 | ||
| 154 | HbIndicator indicator; | |
| 155 |     if (unreadCount) {
 | |
| 156 | QByteArray dataArray; | |
| 157 | QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); | |
| 158 | MsgInfo info; | |
| 159 | info.mIndicatorType = NewIndicatorPlugin; | |
| 160 | ||
| 161 | // only the unread count is used for unread indications as of now. | |
| 162 | // the other values are not needed. | |
| 163 | ||
| 164 | info.mMsgCount = unreadCount; | |
| 165 | info.mConversationId = -1; | |
| 166 | ||
| 167 | info.serialize(messageStream); | |
| 168 | QVariant parameter(dataArray); | |
| 169 | ||
| 170 | indicator.activate(IndicationsPluginId, parameter); | |
| 171 |         QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Indications Activated")
 | |
| 172 | } | |
| 173 |     else {
 | |
| 174 | indicator.deactivate(IndicationsPluginId); | |
| 175 |         QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Indications Deactivated")
 | |
| 176 | } | |
| 177 | ||
| 178 |     QDEBUG_WRITE("MsgNotifier::updateUnreadIndications  Exit")
 | |
| 179 | } | |
| 180 | ||
| 181 | // ---------------------------------------------------------------------------- | |
| 182 | // MsgNotifier::updateOutboxIndications | |
| 183 | // @see MsgNotifier.h | |
| 184 | // ---------------------------------------------------------------------------- | |
| 185 | void MsgNotifier::updateOutboxIndications(MsgInfo& data) | |
| 186 | {
 | |
| 187 |     QDEBUG_WRITE("MsgNotifier::updateOutboxIndications  Enter")
 | |
| 188 | ||
| 189 | HbIndicator indicator; | |
| 190 |     if (data.mMsgCount) {
 | |
| 191 | QByteArray dataArray; | |
| 192 | QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); | |
| 193 | data.serialize(messageStream); | |
| 194 | QVariant parameter(dataArray); | |
| 195 | indicator.activate(indicatorName(data.mIndicatorType), parameter); | |
| 196 |         QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Indications Activated")
 | |
| 197 | } | |
| 198 |     else {
 | |
| 199 | indicator.deactivate(indicatorName(data.mIndicatorType)); | |
| 200 |         QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Indications Deactivated")
 | |
| 201 | } | |
| 202 | ||
| 203 |     QDEBUG_WRITE("MsgNotifier::updateOutboxIndications  Exit")
 | |
| 204 | } | |
| 205 | ||
| 206 | //EOF |