diff -r 238255e8b033 -r 84d9eb65b26f messagingapp/msgnotifications/msgnotifier/src/msgnotifier.cpp --- a/messagingapp/msgnotifications/msgnotifier/src/msgnotifier.cpp Fri Apr 16 14:56:15 2010 +0300 +++ b/messagingapp/msgnotifications/msgnotifier/src/msgnotifier.cpp Mon May 03 12:29:07 2010 +0300 @@ -19,78 +19,114 @@ // SYSTEM INCLUDES #include #include - - +#include +#include +#include +#include +QTM_USE_NAMESPACE //USER INCLUDES #include "msgnotifier.h" #include "msgnotifier_p.h" #include "msgsimnumberdetector.h" #include "msgnotificationdialogpluginkeys.h" +#include "msginfodefs.h" +#include "ccsdefs.h" +#include "unidatamodelloader.h" +#include "unidatamodelplugininterface.h" #include "debugtraces.h" +// LOCALIZATION CONSTANTS +#define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") +#define LOC_BUSINESS_CARD hbTrId("txt_messaging_dpopinfo_business_card") +#define CARD_SEPERATOR "-" + // plugin ids -const QString InidcationsPluginId - ("com.nokia.messaging.indicatorplugin/1.0"); -const QString NotificationPluginId - ("com.nokia.messaging.newmsgnotificationdialog/1.0"); +const QString IndicationsPluginId("com.nokia.messaging.newindicatorplugin"); +const QString PendingMsgPluginId("com.nokia.messaging.pendingindicatorplugin"); +const QString FailedMsgPluginId("com.nokia.messaging.failedindicatorplugin"); +const QString NotificationPluginId("com.nokia.messaging.newmsgnotificationdialog"); // ---------------------------------------------------------------------------- // MsgNotifier::MsgNotifier // @see MsgNotifier.h // ---------------------------------------------------------------------------- -MsgNotifier::MsgNotifier(QObject* parent):QObject(parent) - { +MsgNotifier::MsgNotifier(QObject* parent) : + QObject(parent) +{ QDEBUG_WRITE("MsgNotifier::MsgNotifier : Enter") - - d_ptr = new MsgNotifierPrivate(this); - - mSimHandler = new MsgSimNumDetector(); - - QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit") - } + + d_ptr = new MsgNotifierPrivate(this); + + mSimHandler = new MsgSimNumDetector(); + + QDEBUG_WRITE("MsgNotifier::MsgNotifier : Exit") +} // ---------------------------------------------------------------------------- // MsgNotifier::~MsgNotifier // @see MsgNotifier.h // ---------------------------------------------------------------------------- MsgNotifier::~MsgNotifier() - { +{ QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") - + delete d_ptr; delete mSimHandler; - + QDEBUG_WRITE("MsgNotifier::~MsgNotifier : Enter") - } - - +} // ---------------------------------------------------------------------------- // MsgNotifier::displayNewMessageNotification // @see MsgNotifier.h // ---------------------------------------------------------------------------- void MsgNotifier::displayNewMessageNotification(NotificationData& data) - { +{ QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification : Enter") QDEBUG_WRITE("MsgNotifier::displayNewMessageNotification :" " Printing notification data") - QDEBUG_WRITE_FORMAT("First Name : ", data.mFirstName); - QDEBUG_WRITE_FORMAT("Last Name : ", data.mLastName); + QDEBUG_WRITE_FORMAT("Name : ", data.mDisplayName); QDEBUG_WRITE_FORMAT("Number : ", data.mContactNum); QDEBUG_WRITE_FORMAT("Description : ", data.mDescription); QDEBUG_WRITE_FORMAT("Type : ", data.mMsgType); QDEBUG_WRITE_FORMAT("Conv Id : ", data.mConversationId); - + QDEBUG_WRITE_FORMAT("Msv Entry Id : ", data.msvEntryId); // Fill data to variant map QVariantMap notificationData; - notificationData[QString(KFirstNameKey)] = data.mFirstName ; - notificationData[QString(KLastNameKey)] = data.mLastName; - notificationData[QString(KNickNameKey)] = QString(); + + //incase of BT messages show filename as description + QString description; + if ( ECsBlueTooth == data.mMsgType) + { + data.mDisplayName = LOC_RECEIVED_FILES; + QFileInfo fileinfo(data.mDescription); + description = fileinfo.fileName(); + } + else if ( ECsBioMsg_VCard == data.mMsgType) + { + UniDataModelLoader* pluginLoader = new UniDataModelLoader; + UniDataModelPluginInterface* bioMsgPlugin = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg); + bioMsgPlugin->setMessageId(data.msvEntryId); + if (bioMsgPlugin->attachmentCount() > 0) + { + UniMessageInfoList attList = bioMsgPlugin->attachmentList(); + QString attachmentPath = attList[0]->path(); + description = LOC_BUSINESS_CARD; + description.append(CARD_SEPERATOR); + description.append(getVcardDisplayName(attachmentPath)); + } + delete pluginLoader; + } + else + { + description = data.mDescription; + } + notificationData[QString(KDisplayNameKey)] = data.mDisplayName ; notificationData[QString(KConversationIdKey)] = data.mConversationId; notificationData[QString(KMessageTypeKey)] = data.mMsgType; - notificationData[QString(KMessageBodyKey)] = data.mDescription; - notificationData[QString(KMessageSubjectKey)] = QString(); + notificationData[QString(KMessageBodyKey)] = description; + notificationData[QString(KMessageSubjectKey)] = description; notificationData[QString(KContactAddressKey)] = data.mContactNum; // call device dialog to show notification @@ -105,24 +141,95 @@ // MsgNotifier::updateIndications // @see MsgNotifier.h // ---------------------------------------------------------------------------- -void MsgNotifier::updateIndications(int unreadCount) - { - QDEBUG_WRITE("MsgNotifier::updateIndications Enter") - - HbIndicator indicator; - if(unreadCount) - { - indicator.activate(InidcationsPluginId); - QDEBUG_WRITE("MsgNotifier::updateIndications Indications Activated") - } - else - { - indicator.deactivate(InidcationsPluginId); - QDEBUG_WRITE("MsgNotifier::updateIndications Indications Deactivated") - } - - QDEBUG_WRITE("MsgNotifier::updateIndications Exit") +void MsgNotifier::updateUnreadIndications(int unreadCount) +{ + QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Enter") + + HbIndicator indicator; + if (unreadCount) { + QByteArray dataArray; + QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); + MsgInfo info; + info.mIndicatorType = NewIndicatorPlugin; + + // only the unread count is used for unread indications as of now. + // the other values are not needed. + + info.mMsgCount = unreadCount; + info.mConversationId = -1; + + info.serialize(messageStream); + QVariant parameter(dataArray); + + indicator.activate(IndicationsPluginId, parameter); + QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Indications Activated") + } + else { + indicator.deactivate(IndicationsPluginId); + QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Indications Deactivated") } + QDEBUG_WRITE("MsgNotifier::updateUnreadIndications Exit") +} + +// ---------------------------------------------------------------------------- +// MsgNotifier::updateOutboxIndications +// @see MsgNotifier.h +// ---------------------------------------------------------------------------- +void MsgNotifier::updateOutboxIndications(MsgInfo& data) +{ + QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Enter") + + HbIndicator indicator; + if (data.mMsgCount) { + QByteArray dataArray; + QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); + data.serialize(messageStream); + QVariant parameter(dataArray); + indicator.activate(indicatorName(data.mIndicatorType), parameter); + QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Indications Activated") + } + else { + indicator.deactivate(indicatorName(data.mIndicatorType)); + QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Indications Deactivated") + } + + QDEBUG_WRITE("MsgNotifier::updateOutboxIndications Exit") +} + +//--------------------------------------------------------------- +// MsgNotifier::getVcardDisplayName +// @see header +//--------------------------------------------------------------- +QString MsgNotifier::getVcardDisplayName(const QString& filePath) +{ + QString displayName; + //open file for parsing + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly)) { + return displayName; + } + // parse contents + QVersitReader reader; + reader.setDevice(&file); + if (reader.startReading()) { + if (reader.waitForFinished()) { + QList versitDocuments = reader.results(); + // Use the resulting document + if (versitDocuments.count() > 0) { + QVersitContactImporter importer; + QList contacts = importer.importContacts(versitDocuments); + // get display-name + if (contacts.count() > 0) { + QContactManager* contactManager = new QContactManager("symbian"); + displayName = contactManager->synthesizedDisplayLabel(contacts[0]); + delete contactManager; + } + } + } + } + file.close(); + return displayName; +} //EOF